[StructuredData] Correctly update stats (by @RektInator)
This commit is contained in:
parent
ea3ac3ddcb
commit
e7c2d10d19
@ -116,8 +116,39 @@ namespace Components
|
||||
}
|
||||
}
|
||||
|
||||
bool StructuredData::UpdateVersionOffsets(Game::StructuredDataDefSet *set, Game::StructuredDataBuffer *buffer, Game::StructuredDataDef *whatever)
|
||||
{
|
||||
Game::StructuredDataDef* newDef = &set->defs[0];
|
||||
Game::StructuredDataDef* oldDef = &set->defs[0];
|
||||
|
||||
for(unsigned int i = 0; i < set->defCount; ++i)
|
||||
{
|
||||
if(newDef->version < set->defs[i].version)
|
||||
{
|
||||
newDef = &set->defs[i];
|
||||
}
|
||||
|
||||
if(set->defs[i].version == *reinterpret_cast<int*>(buffer->data))
|
||||
{
|
||||
oldDef = &set->defs[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (newDef->version >= 159 && oldDef->version <= 158)
|
||||
{
|
||||
// this should move the data 320 bytes infront
|
||||
std::memmove(&buffer->data[3963], &buffer->data[3643], oldDef->size - 3643);
|
||||
}
|
||||
|
||||
// StructuredData_UpdateVersion
|
||||
return Utils::Hook::Call<bool(void*, void*, void*)>(0x456830)(set, buffer, whatever);
|
||||
}
|
||||
|
||||
StructuredData::StructuredData()
|
||||
{
|
||||
// Correctly upgrade stats
|
||||
Utils::Hook(0x42F088, StructuredData::UpdateVersionOffsets, HOOK_CALL).install()->quick();
|
||||
|
||||
// 15 or more custom classes
|
||||
Utils::Hook::Set<BYTE>(0x60A2FE, NUM_CUSTOM_CLASSES);
|
||||
|
||||
@ -127,7 +158,7 @@ namespace Components
|
||||
AssetHandler::OnLoad([] (Game::XAssetType type, Game::XAssetHeader asset, std::string filename, bool* /*restrict*/)
|
||||
{
|
||||
// Only intercept playerdatadef loading
|
||||
if (filename != "mp/playerdata.def" || type != Game::XAssetType::ASSET_TYPE_STRUCTUREDDATADEF) return;
|
||||
if (type != Game::XAssetType::ASSET_TYPE_STRUCTUREDDATADEF || filename != "mp/playerdata.def") return;
|
||||
|
||||
// Store asset
|
||||
Game::StructuredDataDefSet* data = asset.structuredData;
|
||||
|
@ -31,6 +31,8 @@ namespace Components
|
||||
#endif
|
||||
|
||||
private:
|
||||
static bool UpdateVersionOffsets(Game::StructuredDataDefSet *set, Game::StructuredDataBuffer *buffer, Game::StructuredDataDef *oldDef);
|
||||
|
||||
static void PatchPlayerDataEnum(Game::StructuredDataDef* data, PlayerDataType type, std::vector<std::string>& entries);
|
||||
static void PatchAdditionalData(Game::StructuredDataDef* data, std::unordered_map<std::string, std::string>& patches);
|
||||
|
||||
|
@ -1554,6 +1554,12 @@ namespace Game
|
||||
StructuredDataDef *defs;
|
||||
};
|
||||
|
||||
struct StructuredDataBuffer
|
||||
{
|
||||
char *data;
|
||||
size_t size; // 8188
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
StructuredDataDef* data;
|
||||
|
Loading…
Reference in New Issue
Block a user