diff --git a/src/dllmain.cpp b/src/dllmain.cpp index 66e75cf..dc75f16 100644 --- a/src/dllmain.cpp +++ b/src/dllmain.cpp @@ -18,17 +18,17 @@ static void InitFeatures() { Randomizer.Initialize(); } -static void ProcessNodesRecursive(RwFrame * frame, void* pEntity, eNodeEntityType type) { +static void ProcessNodesRecursive(RwFrame * frame, void* pEntity, eModelEntityType type) { if(frame) { const std::string name = GetFrameNodeName(frame); - if (type == eNodeEntityType::Vehicle) { + if (type == eModelEntityType::Vehicle) { CVehicle *pVeh = static_cast(pEntity); HandleBar.Process(frame, pVeh); } if ((name[0] == 'x' && name[1] == '_')|| (name[0] == 'f' && name[1] == 'c' && name[2] == '_')) { - if (type == eNodeEntityType::Vehicle) { + if (type == eModelEntityType::Vehicle) { CVehicle *pVeh = static_cast(pEntity); Chain.Process(frame, pVeh); FrontBrake.Process(frame, pVeh); @@ -41,13 +41,13 @@ static void ProcessNodesRecursive(RwFrame * frame, void* pEntity, eNodeEntityTyp GearLever.Process(frame, pVeh); GearSound.Process(frame, pVeh); Randomizer.Process(frame, static_cast(pVeh), type); - } else if (type == eNodeEntityType::Weapon) { + } else if (type == eModelEntityType::Weapon) { CWeapon *pWep = static_cast(pEntity); BodyState.Process(frame, pWep); BodyState.ProcessZen(frame, pWep); BloodRemap.Process(frame, pWep); Randomizer.Process(frame, static_cast(pWep), type); - } else if (type == eNodeEntityType::Object) { + } else if (type == eModelEntityType::Object) { /* processing weapon & jetpack pickups here @@ -55,7 +55,7 @@ static void ProcessNodesRecursive(RwFrame * frame, void* pEntity, eNodeEntityTyp CWeapon *pWep = static_cast(pEntity); BodyState.Process(frame, pWep); BodyState.ProcessZen(frame, pWep); - } else if (type == eNodeEntityType::Ped) { + } else if (type == eModelEntityType::Ped) { Randomizer.Process(frame, pEntity, type); } } @@ -83,21 +83,21 @@ BOOL WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved) { }; Events::vehicleRenderEvent += [](CVehicle* pVeh) { - ProcessNodesRecursive((RwFrame *)pVeh->m_pRwClump->object.parent, pVeh, eNodeEntityType::Vehicle); + ProcessNodesRecursive((RwFrame *)pVeh->m_pRwClump->object.parent, pVeh, eModelEntityType::Vehicle); }; objectRenderEvent += [](CObject *pObj) { - ProcessNodesRecursive((RwFrame *)pObj->m_pRwClump->object.parent, pObj, eNodeEntityType::Object); + ProcessNodesRecursive((RwFrame *)pObj->m_pRwClump->object.parent, pObj, eModelEntityType::Object); }; Events::pedRenderEvent += [](CPed* pPed) { // peds - ProcessNodesRecursive((RwFrame *)pPed->m_pRwClump->object.parent, pPed, eNodeEntityType::Ped); + ProcessNodesRecursive((RwFrame *)pPed->m_pRwClump->object.parent, pPed, eModelEntityType::Ped); // jetpack CTaskSimpleJetPack *pTask = pPed->m_pIntelligence->GetTaskJetPack(); if (pTask && pTask->m_pJetPackClump) { - ProcessNodesRecursive((RwFrame *)pTask->m_pJetPackClump->object.parent, pPed, eNodeEntityType::Weapon); + ProcessNodesRecursive((RwFrame *)pTask->m_pJetPackClump->object.parent, pPed, eModelEntityType::Weapon); } // weapons @@ -108,7 +108,7 @@ BOOL WINAPI DllMain(HINSTANCE hDllHandle, DWORD nReason, LPVOID Reserved) { if (pWeaponInfo) { CWeaponModelInfo* pWeaponModelInfo = static_cast(CModelInfo::GetModelInfo(pWeaponInfo->m_nModelId1)); if (pWeaponModelInfo && pWeaponModelInfo->m_pRwClump) { - ProcessNodesRecursive((RwFrame *)pWeaponModelInfo->m_pRwClump->object.parent, pWeapon, eNodeEntityType::Weapon); + ProcessNodesRecursive((RwFrame *)pWeaponModelInfo->m_pRwClump->object.parent, pWeapon, eModelEntityType::Weapon); } } } diff --git a/src/features/common/randomizer.cpp b/src/features/common/randomizer.cpp index 5072b3e..795a4a8 100644 --- a/src/features/common/randomizer.cpp +++ b/src/features/common/randomizer.cpp @@ -15,7 +15,7 @@ void RandomizerFeature::Initialize() { }; } -void RandomizerFeature::Process(RwFrame* frame, void* ptr, eNodeEntityType type) { +void RandomizerFeature::Process(RwFrame* frame, void* ptr, eModelEntityType type) { std::string name = GetFrameNodeName(frame); if (NODE_FOUND(name, NODE_ID)) { diff --git a/src/features/common/randomizer.h b/src/features/common/randomizer.h index 291ec6d..f5601c6 100644 --- a/src/features/common/randomizer.h +++ b/src/features/common/randomizer.h @@ -11,7 +11,7 @@ class RandomizerFeature : public IFeature { public: void Initialize(); - void Process(RwFrame* frame, void* ptr, eNodeEntityType type); + void Process(RwFrame* frame, void* ptr, eModelEntityType type); }; extern RandomizerFeature Randomizer; \ No newline at end of file diff --git a/src/features/common/remap.cpp b/src/features/common/remap.cpp index 0b056b9..52a8520 100644 --- a/src/features/common/remap.cpp +++ b/src/features/common/remap.cpp @@ -8,7 +8,7 @@ RemapFeature Remap; -void RemapFeature::LoadRemaps(CBaseModelInfo *pModelInfo, int model, eNodeEntityType type) +void RemapFeature::LoadRemaps(CBaseModelInfo *pModelInfo, int model, eModelEntityType type) { if (pModelInfo) { @@ -61,32 +61,32 @@ static std::map m_pBloodState; void RemapFeature::Initialize() { Events::vehicleRenderEvent.before += [this](CVehicle* ptr) { - BeforeRender(reinterpret_cast(ptr), eNodeEntityType::Vehicle); + BeforeRender(reinterpret_cast(ptr), eModelEntityType::Vehicle); }; Events::pedRenderEvent.before += [this](CPed* pPed) { - BeforeRender(reinterpret_cast(pPed), eNodeEntityType::Ped); + BeforeRender(reinterpret_cast(pPed), eModelEntityType::Ped); }; weaponRenderEvent.before += [this](CPed* pPed) { CWeapon *pWeapon = &pPed->m_aWeapons[pPed->m_nActiveWeaponSlot]; if (pWeapon) { - BeforeRender(reinterpret_cast(pWeapon), eNodeEntityType::Weapon); + BeforeRender(reinterpret_cast(pWeapon), eModelEntityType::Weapon); } }; Events::vehicleRenderEvent.after += [this](CVehicle* ptr) { - AfterRender(reinterpret_cast(ptr), eNodeEntityType::Vehicle); + AfterRender(reinterpret_cast(ptr), eModelEntityType::Vehicle); }; Events::pedRenderEvent.after += [this](CPed* pPed) { - AfterRender(reinterpret_cast(pPed), eNodeEntityType::Ped); + AfterRender(reinterpret_cast(pPed), eModelEntityType::Ped); }; weaponRenderEvent.after += [this](CPed* pPed) { CWeapon *pWeapon = &pPed->m_aWeapons[pPed->m_nActiveWeaponSlot]; if (pWeapon) { - AfterRender(reinterpret_cast(pWeapon), eNodeEntityType::Weapon); + AfterRender(reinterpret_cast(pWeapon), eModelEntityType::Weapon); } }; @@ -104,7 +104,7 @@ void RemapFeature::Initialize() { }; } -void RemapFeature::AfterRender(void* ptr, eNodeEntityType type) { +void RemapFeature::AfterRender(void* ptr, eModelEntityType type) { for (auto &e : m_pOriginalTextures) { *e.first = e.second; } @@ -134,7 +134,7 @@ bool RemapFeature::GetKilledState(CWeapon *pWeapon) { return state; } -void RemapFeature::BeforeRender(void* ptr, eNodeEntityType type) { +void RemapFeature::BeforeRender(void* ptr, eModelEntityType type) { int model = Util::GetEntityModel(ptr, type); CBaseModelInfo *pModelInfo = CModelInfo::GetModelInfo(model); @@ -148,7 +148,7 @@ void RemapFeature::BeforeRender(void* ptr, eNodeEntityType type) { return; } - if (type == eNodeEntityType::Weapon) { + if (type == eModelEntityType::Weapon) { data.useBlood = GetKilledState(static_cast(ptr)); } diff --git a/src/features/common/remap.h b/src/features/common/remap.h index 20cfd3c..8191b04 100644 --- a/src/features/common/remap.h +++ b/src/features/common/remap.h @@ -23,10 +23,10 @@ class RemapFeature : public IFeature { private: bool GetKilledState(CWeapon *pWeapon); - void LoadRemaps(CBaseModelInfo *pModelInfo, int model, eNodeEntityType type); + void LoadRemaps(CBaseModelInfo *pModelInfo, int model, eModelEntityType type); - void BeforeRender(void* ptr, eNodeEntityType type); - void AfterRender(void* ptr, eNodeEntityType type); + void BeforeRender(void* ptr, eModelEntityType type); + void AfterRender(void* ptr, eModelEntityType type); public: RemapFeature () {}; diff --git a/src/log.h b/src/log.h index 0912f95..bb6dd51 100644 --- a/src/log.h +++ b/src/log.h @@ -10,18 +10,18 @@ class Logger { private: enum class LogLevel { - Debug, - Info, - Warn, - Error, - None, + Debug, + Info, + Warn, + Error, + None, }; std::mutex logMutex; // Add a mutex for thread safety public: explicit Logger(const std::string& logName = "Logger.log") : logName(logName) { - pLog.open(logName, std::ios::out); // Open in out mode + pLog.open(logName, std::ios::out); // Open in out mode } Logger(const Logger&) = delete; @@ -29,27 +29,27 @@ class Logger { template void Warn(const std::string& fmt, Args&&... args) noexcept { - LogMessage(LogLevel::Warn, fmt, std::forward(args)...); + LogMessage(LogLevel::Warn, fmt, std::forward(args)...); } template void Info(const std::string& fmt, Args&&... args) noexcept { - LogMessage(LogLevel::Info, fmt, std::forward(args)...); + LogMessage(LogLevel::Info, fmt, std::forward(args)...); } template void Debug(const std::string& fmt, Args&&... args) noexcept { - LogMessage(LogLevel::Debug, fmt, std::forward(args)...); + LogMessage(LogLevel::Debug, fmt, std::forward(args)...); } template void Error(const std::string& fmt, Args&&... args) noexcept { - LogMessage(LogLevel::Error, fmt, std::forward(args)...); + LogMessage(LogLevel::Error, fmt, std::forward(args)...); } template void Print(const std::string& fmt, Args&&... args) noexcept { - LogMessage(LogLevel::None, fmt, std::forward(args)...); + LogMessage(LogLevel::None, fmt, std::forward(args)...); } private: @@ -59,18 +59,18 @@ class Logger { template void LogMessage(LogLevel logLevel, const std::string& fmt, Args&&... args) noexcept { - std::scoped_lock lock(logMutex); // Lock for thread safety + std::scoped_lock lock(logMutex); // Lock for thread safety - if (!pLog.is_open()) { - pLog.open(logName, std::ios::out); // Open in out mode - } + if (!pLog.is_open()) { + pLog.open(logName, std::ios::out); // Open in out mode + } - std::string logMessage = fmt; - if (logLevel != LogLevel::None) { - const char* levelNames[] = {"D", "I", "W", "E", ""}; - logMessage = "[" + std::string(levelNames[static_cast(logLevel)]) + "] " + logMessage; - } + std::string logMessage = fmt; + if (logLevel != LogLevel::None) { + const char* levelNames[] = {"D", "I", "W", "E", ""}; + logMessage = "[" + std::string(levelNames[static_cast(logLevel)]) + "] " + logMessage; + } - pLog << std::vformat(logMessage, std::make_format_args(std::forward(args)...)) << std::endl; + pLog << std::vformat(logMessage, std::make_format_args(std::forward(args)...)) << std::endl; } }; diff --git a/src/pch.cpp b/src/pch.cpp index 3f165f7..3360321 100644 --- a/src/pch.cpp +++ b/src/pch.cpp @@ -1,2 +1,3 @@ #include "pch.h" + std::shared_ptr gLogger = std::make_shared(MOD_NAME".log"); \ No newline at end of file diff --git a/src/pch.h b/src/pch.h index 49f86b0..d507b55 100644 --- a/src/pch.h +++ b/src/pch.h @@ -12,11 +12,11 @@ using namespace plugin; -enum class eNodeEntityType { - Ped, - Object, - Vehicle, - Weapon, +enum class eModelEntityType { + Ped, + Object, + Vehicle, + Weapon, }; #define MOD_DATA_PATH(x) PLUGIN_PATH((char*)("ModelExtras/"x)) diff --git a/src/util.cpp b/src/util.cpp index ce03b21..4ed2cfa 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -305,9 +305,9 @@ float Util::GetVehicleSpeedRealistic(CVehicle * vehicle) { return wheelSpeed; } -unsigned int Util::GetEntityModel(void *ptr, eNodeEntityType type) { +unsigned int Util::GetEntityModel(void *ptr, eModelEntityType type) { int model = 0; - if (type == eNodeEntityType::Weapon) { + if (type == eModelEntityType::Weapon) { CWeaponInfo* pWeaponInfo = CWeaponInfo::GetWeaponInfo(reinterpret_cast(ptr)->m_eWeaponType, FindPlayerPed()->GetWeaponSkill(reinterpret_cast(ptr)->m_eWeaponType)); if (pWeaponInfo){ diff --git a/src/util.h b/src/util.h index 8325b7d..26059a9 100644 --- a/src/util.h +++ b/src/util.h @@ -1,6 +1,6 @@ #pragma once -typedef enum class eNodeEntityType eNodeEntityType; +typedef enum class eModelEntityType eModelEntityType; class Util { public: @@ -12,7 +12,7 @@ class Util { // Returns the speed of the vehicle handler static float GetVehicleSpeedRealistic(CVehicle * vehicle); - static unsigned int GetEntityModel(void *ptr, eNodeEntityType type); + static unsigned int GetEntityModel(void *ptr, eModelEntityType type); // Rotate model frame static void SetFrameRotationX(RwFrame* frame, float angle);