slimmed down
This commit is contained in:
@@ -3,52 +3,14 @@
|
||||
#include "playerslot.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
enum class FieldType
|
||||
{
|
||||
Bool,
|
||||
Int8,
|
||||
UInt8,
|
||||
Int16,
|
||||
UInt16,
|
||||
Int32,
|
||||
UInt32,
|
||||
Int64,
|
||||
UInt64,
|
||||
Float,
|
||||
Bytes,
|
||||
StringPtr,
|
||||
};
|
||||
|
||||
struct FieldPathSegment
|
||||
{
|
||||
std::string className;
|
||||
std::string fieldName;
|
||||
};
|
||||
|
||||
struct OverrideRule
|
||||
{
|
||||
int id {};
|
||||
int recipientSlot {-1};
|
||||
std::string target;
|
||||
std::string className;
|
||||
std::string fieldName;
|
||||
std::vector<FieldPathSegment> path;
|
||||
FieldType type {FieldType::Int32};
|
||||
uint64_t bits {};
|
||||
bool enabled {true};
|
||||
};
|
||||
|
||||
struct AppliedOverride
|
||||
{
|
||||
uint8_t* address {};
|
||||
FieldType type {};
|
||||
uint64_t originalBits {};
|
||||
std::vector<uint8_t> originalBytes;
|
||||
std::vector<uint8_t> original;
|
||||
};
|
||||
|
||||
struct CompiledOverrideRule
|
||||
@@ -60,9 +22,7 @@ struct CompiledOverrideRule
|
||||
std::string fieldPath;
|
||||
int32_t offset {};
|
||||
int32_t size {};
|
||||
FieldType type {FieldType::Int32};
|
||||
std::vector<uint8_t> value;
|
||||
std::string stringValue;
|
||||
bool enabled {true};
|
||||
};
|
||||
|
||||
@@ -70,52 +30,24 @@ class OverrideManager
|
||||
{
|
||||
public:
|
||||
void Clear();
|
||||
bool AddFromTokens(int argc, const char** argv, std::string& error);
|
||||
int AddCompiledRule(int recipientSlot, int entityIndex, const char* className, const char* fieldPath, const char* type, const char* value, std::string& error);
|
||||
void Compact();
|
||||
int AddRuleBytes(int recipientSlot, int entityIndex, const char* className, const char* fieldPath, const void* value, int valueSize, std::string& error);
|
||||
bool RemoveRule(int id);
|
||||
bool MarkRuleDirty(int id);
|
||||
bool MarkEntityFieldDirty(int entityIndex, const char* className, const char* fieldPath, std::string& error);
|
||||
bool AddWeaponItemDefRule(int recipientSlot, const char* target, uint16_t itemDefinitionIndex, std::string& error);
|
||||
bool SetHealthMoneyTest(bool enabled, std::string& error);
|
||||
bool SetHealth42Test(bool enabled, std::string& error);
|
||||
bool SetRecipientHealthValue(int recipientSlot, int value, std::string& error);
|
||||
void ClearRecipientHealthValues();
|
||||
void Dump() const;
|
||||
void SetTrace(bool value) { m_trace = value; }
|
||||
bool Trace() const { return m_trace; }
|
||||
size_t RuleCount() const { return m_rules.size() + m_compiledRules.size(); }
|
||||
size_t DynamicRuleCount() const { return (m_healthMoneyTest ? 1 : 0) + (m_health42Test ? 1 : 0); }
|
||||
bool Empty() const { return m_rules.empty() && m_compiledRules.empty() && !m_healthMoneyTest && !m_health42Test; }
|
||||
bool Health42Test() const { return m_health42Test; }
|
||||
bool TryGetHealth42Value(CPlayerSlot recipient, int& value) const;
|
||||
bool HasPackedOverrides() const { return !m_compiledRules.empty() || m_health42Test; }
|
||||
bool Empty() const { return m_rules.empty(); }
|
||||
bool HasPackedOverrides() const { return !m_rulesByEntity.empty(); }
|
||||
|
||||
std::vector<AppliedOverride> ApplyForRecipient(CPlayerSlot slot);
|
||||
std::vector<AppliedOverride> ApplyForPackedEntity(CPlayerSlot recipient, int entityIndex, void* entityData);
|
||||
std::vector<AppliedOverride> ApplyGlobalHealth42();
|
||||
int MarkPlayerHealthDirty();
|
||||
void Restore(const std::vector<AppliedOverride>& applied);
|
||||
|
||||
private:
|
||||
bool EntityMatches(uintptr_t entity, const OverrideRule& rule) const;
|
||||
uintptr_t FindFirstEntityForTarget(const OverrideRule& rule) const;
|
||||
uint8_t* ResolveAddress(uintptr_t entity, const OverrideRule& rule) const;
|
||||
void ApplyHealthMoneyTest(CPlayerSlot slot, std::vector<AppliedOverride>& applied);
|
||||
bool ResolveFieldPath(const char* className, const char* fieldPath, int32_t& offset, int32_t& size, std::string& typeName, std::string& error) const;
|
||||
bool CompileValue(FieldType type, int32_t fieldSize, const char* value, std::vector<uint8_t>& out, std::string& stringValue, std::string& error) const;
|
||||
void RebuildCompiledIndex();
|
||||
bool ResolveFieldPath(const char* className, const char* fieldPath, int32_t& offset, int32_t& size, std::string& error) const;
|
||||
void RebuildIndex();
|
||||
bool MarkEntityFieldDirtyByOffset(int entityIndex, int32_t offset);
|
||||
|
||||
std::vector<OverrideRule> m_rules;
|
||||
std::vector<CompiledOverrideRule> m_compiledRules;
|
||||
std::unordered_map<int, std::vector<size_t>> m_compiledRulesByEntity;
|
||||
std::vector<CompiledOverrideRule> m_rules;
|
||||
std::unordered_map<int, std::vector<size_t>> m_rulesByEntity;
|
||||
int m_nextId {1};
|
||||
bool m_trace {false};
|
||||
bool m_healthMoneyTest {false};
|
||||
bool m_health42Test {false};
|
||||
int m_defaultHealth42Value {42};
|
||||
std::array<bool, 64> m_recipientHealthSet {};
|
||||
std::array<int, 64> m_recipientHealthValue {};
|
||||
};
|
||||
|
||||
extern OverrideManager g_overrides;
|
||||
|
||||
Reference in New Issue
Block a user