working weapon concealment

This commit is contained in:
2026-08-10 16:59:45 +02:00
parent 4e9500f0ea
commit 9a23169b6b
13 changed files with 927 additions and 66 deletions

View File

@@ -13,6 +13,18 @@ struct AppliedOverride
std::vector<uint8_t> original;
};
enum class OverrideRuleKind
{
Bytes,
VectorFirstFromField,
};
struct FieldAddressStep
{
int32_t offset {};
bool dereference {};
};
struct CompiledOverrideRule
{
int id {};
@@ -20,10 +32,17 @@ struct CompiledOverrideRule
int entityIndex {-1};
std::string className;
std::string fieldPath;
std::string sourceFieldPath;
int32_t offset {};
int32_t size {};
int32_t sourceSize {};
std::vector<FieldAddressStep> addressSteps;
std::vector<FieldAddressStep> sourceAddressSteps;
std::vector<uint8_t> value;
OverrideRuleKind kind {OverrideRuleKind::Bytes};
bool enabled {true};
mutable bool debugLogged {false};
mutable bool recipientMismatchLogged {false};
};
class OverrideManager
@@ -32,18 +51,21 @@ public:
void Clear();
void Compact();
int AddRuleBytes(int recipientSlot, int entityIndex, const char* className, const char* fieldPath, const void* value, int valueSize, std::string& error);
int AddRuleVectorFirstFromField(int recipientSlot, int entityIndex, const char* className, const char* vectorFieldPath, const char* sourceFieldPath, std::string& error);
bool RemoveRule(int id);
bool MarkEntityFieldDirty(int entityIndex, const char* className, const char* fieldPath, std::string& error);
bool Empty() const { return m_rules.empty(); }
bool HasPackedOverrides() const { return !m_rulesByEntity.empty(); }
bool HasRulesForEntity(int entityIndex) const { return m_rulesByEntity.find(entityIndex) != m_rulesByEntity.end(); }
std::vector<AppliedOverride> ApplyForPackedEntity(CPlayerSlot recipient, int entityIndex, void* entityData);
void Restore(const std::vector<AppliedOverride>& applied);
private:
bool ResolveFieldPath(const char* className, const char* fieldPath, int32_t& offset, int32_t& size, std::string& error) const;
bool ResolveFieldPath(const char* className, const char* fieldPath, int32_t& offset, int32_t& size, std::vector<FieldAddressStep>& addressSteps, std::string& error) const;
void RebuildIndex();
bool MarkEntityFieldDirtyByOffset(int entityIndex, int32_t offset);
bool MarkEntityFullDirty(int entityIndex);
std::vector<CompiledOverrideRule> m_rules;
std::unordered_map<int, std::vector<size_t>> m_rulesByEntity;