Structureddata stuff in fastfiles
This commit is contained in:
parent
52d7504437
commit
2886928f0b
@ -133,7 +133,6 @@ namespace Components
|
||||
AntiCheat::AntiCheat()
|
||||
{
|
||||
AntiCheat::EmptyHash();
|
||||
QuickPatch::OnFrame(AntiCheat::Frame);
|
||||
|
||||
#ifdef DEBUG
|
||||
Command::Add("penis", [] (Command::Params)
|
||||
@ -141,6 +140,7 @@ namespace Components
|
||||
AntiCheat::CrashClient();
|
||||
});
|
||||
#else
|
||||
QuickPatch::OnFrame(AntiCheat::Frame);
|
||||
QuickPatch::Once(AntiCheat::PatchWinAPI);
|
||||
#endif
|
||||
}
|
||||
|
@ -262,6 +262,7 @@ namespace Components
|
||||
AssetHandler::RegisterInterface(new Assets::IMaterialPixelShader());
|
||||
AssetHandler::RegisterInterface(new Assets::IMaterialTechniqueSet());
|
||||
AssetHandler::RegisterInterface(new Assets::IMaterialVertexShader());
|
||||
AssetHandler::RegisterInterface(new Assets::IStructuredDataDefSet());
|
||||
AssetHandler::RegisterInterface(new Assets::IMaterialVertexDeclaration());
|
||||
}
|
||||
|
||||
|
@ -68,4 +68,5 @@ namespace Components
|
||||
#include "AssetInterfaces\IMaterialPixelShader.hpp"
|
||||
#include "AssetInterfaces\IMaterialTechniqueSet.hpp"
|
||||
#include "AssetInterfaces\IMaterialVertexShader.hpp"
|
||||
#include "AssetInterfaces\IStructuredDataDefSet.hpp"
|
||||
#include "AssetInterfaces\IMaterialVertexDeclaration.hpp"
|
||||
|
151
src/Components/Modules/AssetInterfaces/IStructuredDataDefSet.cpp
Normal file
151
src/Components/Modules/AssetInterfaces/IStructuredDataDefSet.cpp
Normal file
@ -0,0 +1,151 @@
|
||||
#include <STDInclude.hpp>
|
||||
|
||||
namespace Assets
|
||||
{
|
||||
void IStructuredDataDefSet::Save_StructuredDataEnumArray(Game::StructuredDataEnum* enums, int numEnums, Components::ZoneBuilder::Zone* builder)
|
||||
{
|
||||
Utils::Stream* buffer = builder->GetBuffer();
|
||||
|
||||
Game::StructuredDataEnum* destEnums = buffer->Dest<Game::StructuredDataEnum>();
|
||||
buffer->SaveArray(enums, numEnums);
|
||||
|
||||
for (int i = 0; i < numEnums; ++i)
|
||||
{
|
||||
Game::StructuredDataEnum* destEnum = &destEnums[i];
|
||||
Game::StructuredDataEnum* enum_ = &enums[i];
|
||||
|
||||
if (enum_->indices)
|
||||
{
|
||||
Assert_Size(Game::StructuredDataEnumEntry, 8);
|
||||
buffer->Align(Utils::Stream::ALIGN_4);
|
||||
|
||||
Game::StructuredDataEnumEntry* destIndices = buffer->Dest<Game::StructuredDataEnumEntry>();
|
||||
buffer->SaveArray(enum_->indices, enum_->numIndices);
|
||||
|
||||
for (int j = 0; j < enum_->numIndices; ++j)
|
||||
{
|
||||
Game::StructuredDataEnumEntry* destIndex = &destIndices[j];
|
||||
Game::StructuredDataEnumEntry* index = &enum_->indices[j];
|
||||
|
||||
if (index->key)
|
||||
{
|
||||
buffer->SaveString(index->key);
|
||||
destIndex->key = reinterpret_cast<char*>(-1);
|
||||
}
|
||||
}
|
||||
|
||||
destEnum->indices = reinterpret_cast<Game::StructuredDataEnumEntry*>(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IStructuredDataDefSet::Save_StructuredDataStructArray(Game::StructuredDataStruct* structs, int numStructs, Components::ZoneBuilder::Zone* builder)
|
||||
{
|
||||
Utils::Stream* buffer = builder->GetBuffer();
|
||||
|
||||
Game::StructuredDataStruct* destStructs = buffer->Dest<Game::StructuredDataStruct>();
|
||||
buffer->SaveArray(structs, numStructs);
|
||||
|
||||
for (int i = 0; i < numStructs; ++i)
|
||||
{
|
||||
Game::StructuredDataStruct* destStruct = &destStructs[i];
|
||||
Game::StructuredDataStruct* struct_ = &structs[i];
|
||||
|
||||
if (struct_->property)
|
||||
{
|
||||
Assert_Size(Game::StructuredDataStructProperty, 16);
|
||||
buffer->Align(Utils::Stream::ALIGN_4);
|
||||
|
||||
Game::StructuredDataStructProperty* destProperties = buffer->Dest<Game::StructuredDataStructProperty>();
|
||||
buffer->SaveArray(struct_->property, struct_->numProperties);
|
||||
|
||||
for (int j = 0; j < struct_->numProperties; ++j)
|
||||
{
|
||||
Game::StructuredDataStructProperty* destProperty = &destProperties[j];
|
||||
Game::StructuredDataStructProperty* property = &struct_->property[j];
|
||||
|
||||
if (property->name)
|
||||
{
|
||||
buffer->SaveString(property->name);
|
||||
destProperty->name = reinterpret_cast<char*>(-1);
|
||||
}
|
||||
}
|
||||
|
||||
destStruct->property = reinterpret_cast<Game::StructuredDataStructProperty*>(-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void IStructuredDataDefSet::Save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder)
|
||||
{
|
||||
Assert_Size(Game::StructuredDataDefSet, 12);
|
||||
|
||||
Utils::Stream* buffer = builder->GetBuffer();
|
||||
Game::StructuredDataDefSet* asset = header.structuredData;
|
||||
Game::StructuredDataDefSet* dest = buffer->Dest<Game::StructuredDataDefSet>();
|
||||
buffer->Save(asset, sizeof(Game::StructuredDataDefSet));
|
||||
|
||||
buffer->PushBlock(Game::XFILE_BLOCK_VIRTUAL);
|
||||
|
||||
if (asset->name)
|
||||
{
|
||||
buffer->SaveString(builder->GetAssetName(this->GetType(), asset->name));
|
||||
dest->name = reinterpret_cast<char*>(-1);
|
||||
}
|
||||
|
||||
if (asset->data)
|
||||
{
|
||||
Assert_Size(Game::StructuredDataDef, 52);
|
||||
buffer->Align(Utils::Stream::ALIGN_4);
|
||||
|
||||
Game::StructuredDataDef* destDataArray = buffer->Dest<Game::StructuredDataDef>();
|
||||
buffer->SaveArray(asset->data, asset->count);
|
||||
|
||||
for (int i = 0; i < asset->count; ++i)
|
||||
{
|
||||
Game::StructuredDataDef* destData = &destDataArray[i];
|
||||
Game::StructuredDataDef* data = &asset->data[i];
|
||||
|
||||
if (data->enums)
|
||||
{
|
||||
Assert_Size(Game::StructuredDataEnum, 12);
|
||||
buffer->Align(Utils::Stream::ALIGN_4);
|
||||
|
||||
IStructuredDataDefSet::Save_StructuredDataEnumArray(data->enums, data->numEnums, builder);
|
||||
destData->enums = reinterpret_cast<Game::StructuredDataEnum*>(-1);
|
||||
}
|
||||
|
||||
if (data->structs)
|
||||
{
|
||||
Assert_Size(Game::StructuredDataStruct, 16);
|
||||
buffer->Align(Utils::Stream::ALIGN_4);
|
||||
|
||||
IStructuredDataDefSet::Save_StructuredDataStructArray(data->structs, data->numStructs, builder);
|
||||
destData->structs = reinterpret_cast<Game::StructuredDataStruct*>(-1);
|
||||
}
|
||||
|
||||
if (data->indexedArrays)
|
||||
{
|
||||
Assert_Size(Game::StructuredDataIndexedArray, 16);
|
||||
buffer->Align(Utils::Stream::ALIGN_4);
|
||||
|
||||
buffer->SaveArray(data->indexedArrays, data->numIndexedArrays);
|
||||
destData->indexedArrays = reinterpret_cast<Game::StructuredDataIndexedArray*>(-1);
|
||||
}
|
||||
|
||||
if (data->enumArrays)
|
||||
{
|
||||
Assert_Size(Game::StructuredDataEnumedArray, 16);
|
||||
buffer->Align(Utils::Stream::ALIGN_4);
|
||||
|
||||
buffer->SaveArray(data->enumArrays, data->numEnumArrays);
|
||||
destData->enumArrays = reinterpret_cast<Game::StructuredDataEnumedArray*>(-1);
|
||||
}
|
||||
}
|
||||
|
||||
dest->data = reinterpret_cast<Game::StructuredDataDef*>(-1);
|
||||
}
|
||||
|
||||
buffer->PopBlock();
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
namespace Assets
|
||||
{
|
||||
class IStructuredDataDefSet : public Components::AssetHandler::IAsset
|
||||
{
|
||||
public:
|
||||
virtual Game::XAssetType GetType() override { return Game::XAssetType::ASSET_TYPE_STRUCTUREDDATADEF; };
|
||||
|
||||
virtual void Save(Game::XAssetHeader header, Components::ZoneBuilder::Zone* builder) override;
|
||||
|
||||
void Save_StructuredDataEnumArray(Game::StructuredDataEnum* enums, int numEnums, Components::ZoneBuilder::Zone* builder);
|
||||
void Save_StructuredDataStructArray(Game::StructuredDataStruct* structs, int numStructs, Components::ZoneBuilder::Zone* builder);
|
||||
};
|
||||
}
|
@ -8,31 +8,15 @@ namespace Components
|
||||
|
||||
char* Command::Params::operator[](size_t index)
|
||||
{
|
||||
if (index >= this->Length())
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
if (this->IsSV)
|
||||
{
|
||||
return Game::cmd_argv_sv[this->CommandId][index];
|
||||
}
|
||||
else
|
||||
{
|
||||
return Game::cmd_argv[this->CommandId][index];
|
||||
}
|
||||
if (index >= this->Length()) return "";
|
||||
if (this->IsSV) return Game::cmd_argv_sv[this->CommandId][index];
|
||||
else return Game::cmd_argv[this->CommandId][index];
|
||||
}
|
||||
|
||||
size_t Command::Params::Length()
|
||||
{
|
||||
if (this->IsSV)
|
||||
{
|
||||
return Game::cmd_argc_sv[this->CommandId];
|
||||
}
|
||||
else
|
||||
{
|
||||
return Game::cmd_argc[this->CommandId];
|
||||
}
|
||||
if (this->IsSV) return Game::cmd_argc_sv[this->CommandId];
|
||||
else return Game::cmd_argc[this->CommandId];
|
||||
}
|
||||
|
||||
std::string Command::Params::Join(size_t startIndex)
|
||||
|
@ -16,9 +16,9 @@ namespace Components
|
||||
}
|
||||
|
||||
// Load custom weapons, if present (force that later on)
|
||||
if (FastFiles::Exists("weapons_mp"))
|
||||
if (FastFiles::Exists("weapons_iw4x_mp"))
|
||||
{
|
||||
data.push_back({ "weapons_mp", 1, 0 });
|
||||
data.push_back({ "weapons_iw4x_mp", 1, 0 });
|
||||
}
|
||||
|
||||
return FastFiles::LoadDLCUIZones(data.data(), data.size(), sync);
|
||||
@ -33,9 +33,9 @@ namespace Components
|
||||
Game::XZoneInfo info = { nullptr, 2, 0 };
|
||||
|
||||
// Custom ui stuff
|
||||
if (FastFiles::Exists("iw4x_ui_mp"))
|
||||
if (FastFiles::Exists("ui_iw4x_mp"))
|
||||
{
|
||||
info.name = "iw4x_ui_mp";
|
||||
info.name = "ui_iw4x_mp";
|
||||
data.push_back(info);
|
||||
}
|
||||
else // Fallback
|
||||
@ -50,6 +50,19 @@ namespace Components
|
||||
return FastFiles::LoadLocalizeZones(data.data(), data.size(), sync);
|
||||
}
|
||||
|
||||
void FastFiles::LoadGfxZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync)
|
||||
{
|
||||
std::vector<Game::XZoneInfo> data;
|
||||
Utils::Merge(&data, zoneInfo, zoneCount);
|
||||
|
||||
if (FastFiles::Exists("code_post_gfx_iw4x_mp"))
|
||||
{
|
||||
data.push_back({ "code_post_gfx_iw4x_mp", zoneInfo->allocFlags, zoneInfo->freeFlags });
|
||||
}
|
||||
|
||||
Game::DB_LoadXAssets(data.data(), data.size(), sync);
|
||||
}
|
||||
|
||||
// This has to be called every time fastfiles are loaded :D
|
||||
void FastFiles::LoadLocalizeZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync)
|
||||
{
|
||||
@ -142,6 +155,7 @@ namespace Components
|
||||
{
|
||||
Utils::Hook(0x506BC7, FastFiles::LoadInitialZones, HOOK_CALL).Install()->Quick();
|
||||
Utils::Hook(0x60B4AC, FastFiles::LoadDLCUIZones, HOOK_CALL).Install()->Quick();
|
||||
Utils::Hook(0x506B25, FastFiles::LoadGfxZones, HOOK_CALL).Install()->Quick();
|
||||
}
|
||||
|
||||
// basic checks (hash jumps, both normal and playlist)
|
||||
|
@ -19,5 +19,6 @@ namespace Components
|
||||
static const char* GetZoneLocation(const char* file);
|
||||
static void LoadInitialZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync);
|
||||
static void LoadDLCUIZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync);
|
||||
static void LoadGfxZones(Game::XZoneInfo *zoneInfo, unsigned int zoneCount, int sync);
|
||||
};
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ namespace Components
|
||||
//Maps::AddDependency("oilrig", "mp_subbase");
|
||||
//Maps::AddDependency("gulag", "mp_subbase");
|
||||
//Maps::AddDependency("invasion", "mp_rust");
|
||||
Maps::AddDependency("^(?!mp_).*", "dependencies_mp"); // All maps not starting with "mp_"
|
||||
Maps::AddDependency("^(?!mp_).*", "dependencies_iw4x_mp"); // All maps not starting with "mp_"
|
||||
}
|
||||
|
||||
Maps::~Maps()
|
||||
|
@ -88,20 +88,6 @@ namespace Components
|
||||
dataEnum->indices = StructuredData::Indices[type];
|
||||
}
|
||||
|
||||
void StructuredData::DumpDataDef(Game::StructuredDataDefSet* dataDef)
|
||||
{
|
||||
if (!dataDef || !dataDef->data) return;
|
||||
|
||||
json11::Json definition =
|
||||
json11::Json::object
|
||||
{
|
||||
{ "version", dataDef->data->version },
|
||||
//{ "enums", [ 0 ] },
|
||||
};
|
||||
|
||||
Utils::WriteFile(Utils::VA("raw/%s.json", dataDef->name), definition.dump());
|
||||
}
|
||||
|
||||
StructuredData* StructuredData::GetSingleton()
|
||||
{
|
||||
if (!StructuredData::Singleton)
|
||||
@ -114,6 +100,9 @@ namespace Components
|
||||
|
||||
StructuredData::StructuredData()
|
||||
{
|
||||
// Only execute this when building zones
|
||||
if (!ZoneBuilder::IsEnabled()) return;
|
||||
|
||||
StructuredData::Singleton = this;
|
||||
ZeroMemory(StructuredData::IndexCount, sizeof(StructuredData));
|
||||
|
||||
@ -142,12 +131,6 @@ namespace Components
|
||||
return header;
|
||||
});
|
||||
|
||||
Command::Add("dumpDataDef", [] (Command::Params params)
|
||||
{
|
||||
if (params.Length() < 2) return;
|
||||
StructuredData::DumpDataDef(Game::DB_FindXAssetHeader(Game::XAssetType::ASSET_TYPE_STRUCTUREDDATADEF, params[1]).structuredData);
|
||||
});
|
||||
|
||||
// ---------- Weapons ----------
|
||||
StructuredData::AddPlayerDataEntry(StructuredData::ENUM_WEAPONS, 1, "m40a3");
|
||||
StructuredData::AddPlayerDataEntry(StructuredData::ENUM_WEAPONS, 2, "ak47classic");
|
||||
|
@ -33,8 +33,6 @@ namespace Components
|
||||
std::string name;
|
||||
int statOffset;
|
||||
};
|
||||
|
||||
static void DumpDataDef(Game::StructuredDataDefSet* dataDef);
|
||||
static void PatchPlayerDataEnum(Game::StructuredDataDefSet* data, PlayerDataType type, std::vector<EnumEntry>& entries);
|
||||
static StructuredData* GetSingleton();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user