diff --git a/include/ArmorAddonOverrideService.h b/include/ArmorAddonOverrideService.h index c83534b..fbce9d7 100644 --- a/include/ArmorAddonOverrideService.h +++ b/include/ArmorAddonOverrideService.h @@ -9,10 +9,10 @@ #include "outfit.pb.h" namespace RE { - class TESObjectARMO; + class TESObjectARMO; } -enum class LocationType: std::uint32_t { +enum class LocationType : std::uint32_t { World = 0, Town = 1, Dungeon = 2, @@ -35,118 +35,119 @@ struct WeatherFlags { }; struct Outfit { - Outfit() {}; // we shouldn't need this, really, but std::unordered_map is a brat - Outfit(const char* n) : name(n), isFavorite(false), allowsPassthrough(false), requiresEquipped(false) {}; - Outfit(const Outfit& other) = default; - Outfit(const char* n, const Outfit& other) : name(n), isFavorite(false), allowsPassthrough(false), requiresEquipped(false) { - this->armors = other.armors; - } - std::string name; // can't be const; prevents assigning to Outfit vars - std::unordered_set armors; - bool isFavorite; - bool allowsPassthrough; - bool requiresEquipped; + Outfit(){};// we shouldn't need this, really, but std::unordered_map is a brat + Outfit(const char* n) : name(n), isFavorite(false), allowsPassthrough(false), requiresEquipped(false){}; + Outfit(const Outfit& other) = default; + Outfit(const char* n, const Outfit& other) : name(n), isFavorite(false), allowsPassthrough(false), requiresEquipped(false) { + this->armors = other.armors; + } + std::string name;// can't be const; prevents assigning to Outfit vars + std::unordered_set armors; + bool isFavorite; + bool allowsPassthrough; + bool requiresEquipped; - bool conflictsWith(RE::TESObjectARMO*) const; - bool hasShield() const; - std::unordered_set computeDisplaySet(const std::unordered_set& equipped); + bool conflictsWith(RE::TESObjectARMO*) const; + bool hasShield() const; + std::unordered_set computeDisplaySet(const std::unordered_set& equipped); - void load(const proto::Outfit& proto, const SKSE::SerializationInterface*); - void load_legacy(const SKSE::SerializationInterface* intfc, std::uint32_t version); // can throw ArmorAddonOverrideService::load_error - proto::Outfit save() const; // can throw ArmorAddonOverrideService::save_error + void load(const proto::Outfit& proto, const SKSE::SerializationInterface*); + void load_legacy(const SKSE::SerializationInterface* intfc, std::uint32_t version);// can throw ArmorAddonOverrideService::load_error + proto::Outfit save() const; // can throw ArmorAddonOverrideService::save_error }; const constexpr char* g_noOutfitName = ""; -static Outfit g_noOutfit(g_noOutfitName); // can't be const; prevents us from assigning it to Outfit&s +static Outfit g_noOutfit(g_noOutfitName);// can't be const; prevents us from assigning it to Outfit&s class ArmorAddonOverrideService { - public: - typedef Outfit Outfit; - static constexpr std::uint32_t signature = 'AAOS'; - enum { - kSaveVersionV1 = 1, - kSaveVersionV2 = 2, - kSaveVersionV3 = 3, - kSaveVersionV4 = 4 // First version with protobuf - }; - // - static constexpr std::uint32_t ce_outfitNameMaxLength = 256; // SKSE caps serialized std::strings and const char*s to 256 bytes. - // - static void _validateNameOrThrow(const char* outfitName); - // - struct bad_name : public std::runtime_error { - explicit bad_name(const std::string& what_arg) : runtime_error(what_arg) {}; - }; - struct load_error : public std::runtime_error { - explicit load_error(const std::string& what_arg) : runtime_error(what_arg) {}; - }; - struct name_conflict : public std::runtime_error { - explicit name_conflict(const std::string& what_arg) : runtime_error(what_arg) {}; - }; - struct save_error : public std::runtime_error { - explicit save_error(const std::string& what_arg) : runtime_error(what_arg) {}; - }; - // - private: - struct OutfitReferenceByName : public cobb::istring { - OutfitReferenceByName(const value_type* s) : cobb::istring(s) {}; - OutfitReferenceByName(const basic_string& other) : cobb::istring(other) {}; - // - operator Outfit&() { +public: + typedef Outfit Outfit; + static constexpr std::uint32_t signature = 'AAOS'; + enum { + kSaveVersionV1 = 1, + kSaveVersionV2 = 2, + kSaveVersionV3 = 3, + kSaveVersionV4 = 4// First version with protobuf + }; + // + static constexpr std::uint32_t ce_outfitNameMaxLength = 256;// SKSE caps serialized std::strings and const char*s to 256 bytes. + // + static void _validateNameOrThrow(const char* outfitName); + // + struct bad_name: public std::runtime_error { + explicit bad_name(const std::string& what_arg) : runtime_error(what_arg){}; + }; + struct load_error: public std::runtime_error { + explicit load_error(const std::string& what_arg) : runtime_error(what_arg){}; + }; + struct name_conflict: public std::runtime_error { + explicit name_conflict(const std::string& what_arg) : runtime_error(what_arg){}; + }; + struct save_error: public std::runtime_error { + explicit save_error(const std::string& what_arg) : runtime_error(what_arg){}; + }; + // +private: + struct OutfitReferenceByName: public cobb::istring { + OutfitReferenceByName(const value_type* s) : cobb::istring(s){}; + OutfitReferenceByName(const basic_string& other) : cobb::istring(other){}; + // + operator Outfit&() { return ArmorAddonOverrideService::GetInstance().outfits.at(*this); - } - }; - public: - struct ActorOutfitAssignments { + } + }; + +public: + struct ActorOutfitAssignments { cobb::istring currentOutfitName = g_noOutfitName; std::map locationOutfits; - }; - bool enabled = true; - std::map outfits; - // TODO: You probably shouldn't use an Actor pointer to refer to actors. It works for the PlayerCharacter, but likely not for NPCs. - std::map actorOutfitAssignments; - // Location-based switching - bool locationBasedAutoSwitchEnabled = false; - // - static ArmorAddonOverrideService& GetInstance() { - static ArmorAddonOverrideService instance; - return instance; - }; - // - Outfit& getOutfit(const char* name); // throws std::out_of_range if not found - Outfit& getOrCreateOutfit(const char* name); // can throw bad_name - // - void addOutfit(const char* name); // can throw bad_name - void addOutfit(const char* name, std::vector armors); // can throw bad_name - Outfit& currentOutfit(RE::RawActorHandle target); - bool hasOutfit(const char* name) const; - void deleteOutfit(const char* name); - void setFavorite(const char* name, bool favorite); - void setOutfitPassthrough(const char* name, bool allowPassthrough); - void setOutfitEquipRequired(const char* name, bool requiresEquipped); - void modifyOutfit(const char* name, std::vector& add, std::vector& remove, bool createIfMissing = false); // can throw bad_name if (createIfMissing) - void renameOutfit(const char* oldName, const char* newName); // throws name_conflict if the new name is already taken; can throw bad_name; throws std::out_of_range if the oldName doesn't exist - void setOutfit(const char* name, RE::RawActorHandle target); - void addActor(RE::RawActorHandle target); - void removeActor(RE::RawActorHandle target); - std::unordered_set listActors(); - // - void setLocationBasedAutoSwitchEnabled(bool) noexcept; - void setOutfitUsingLocation(LocationType location, RE::RawActorHandle target); - void setLocationOutfit(LocationType location, const char* name, RE::RawActorHandle target); - void unsetLocationOutfit(LocationType location, RE::RawActorHandle target); - std::optional getLocationOutfit(LocationType location, RE::RawActorHandle target); - std::optional checkLocationType(const std::unordered_set& keywords, const WeatherFlags& weather_flags, RE::RawActorHandle target); - // - bool shouldOverride(RE::RawActorHandle target) const noexcept; - void getOutfitNames(std::vector& out, bool favoritesOnly = false) const; - void setEnabled(bool) noexcept; - // - void refreshCurrentIfChanged(const char* testName); - // - void reset(); - void load(const SKSE::SerializationInterface* intfc, const proto::OutfitSystem& data); // can throw load_error - void load_legacy(const SKSE::SerializationInterface* intfc, std::uint32_t version); // can throw load_error - proto::OutfitSystem save(); // can throw save_error - // - void dump() const; + }; + bool enabled = true; + std::map outfits; + // TODO: You probably shouldn't use an Actor pointer to refer to actors. It works for the PlayerCharacter, but likely not for NPCs. + std::map actorOutfitAssignments; + // Location-based switching + bool locationBasedAutoSwitchEnabled = false; + // + static ArmorAddonOverrideService& GetInstance() { + static ArmorAddonOverrideService instance; + return instance; + }; + // + Outfit& getOutfit(const char* name); // throws std::out_of_range if not found + Outfit& getOrCreateOutfit(const char* name);// can throw bad_name + // + void addOutfit(const char* name); // can throw bad_name + void addOutfit(const char* name, std::vector armors);// can throw bad_name + Outfit& currentOutfit(RE::RawActorHandle target); + bool hasOutfit(const char* name) const; + void deleteOutfit(const char* name); + void setFavorite(const char* name, bool favorite); + void setOutfitPassthrough(const char* name, bool allowPassthrough); + void setOutfitEquipRequired(const char* name, bool requiresEquipped); + void modifyOutfit(const char* name, std::vector& add, std::vector& remove, bool createIfMissing = false);// can throw bad_name if (createIfMissing) + void renameOutfit(const char* oldName, const char* newName); // throws name_conflict if the new name is already taken; can throw bad_name; throws std::out_of_range if the oldName doesn't exist + void setOutfit(const char* name, RE::RawActorHandle target); + void addActor(RE::RawActorHandle target); + void removeActor(RE::RawActorHandle target); + std::unordered_set listActors(); + // + void setLocationBasedAutoSwitchEnabled(bool) noexcept; + void setOutfitUsingLocation(LocationType location, RE::RawActorHandle target); + void setLocationOutfit(LocationType location, const char* name, RE::RawActorHandle target); + void unsetLocationOutfit(LocationType location, RE::RawActorHandle target); + std::optional getLocationOutfit(LocationType location, RE::RawActorHandle target); + std::optional checkLocationType(const std::unordered_set& keywords, const WeatherFlags& weather_flags, RE::RawActorHandle target); + // + bool shouldOverride(RE::RawActorHandle target) const noexcept; + void getOutfitNames(std::vector& out, bool favoritesOnly = false) const; + void setEnabled(bool) noexcept; + // + void refreshCurrentIfChanged(const char* testName); + // + void reset(); + void load(const SKSE::SerializationInterface* intfc, const proto::OutfitSystem& data);// can throw load_error + void load_legacy(const SKSE::SerializationInterface* intfc, std::uint32_t version); // can throw load_error + proto::OutfitSystem save(); // can throw save_error + // + void dump() const; }; \ No newline at end of file diff --git a/include/OutfitSystem.h b/include/OutfitSystem.h index b72ac96..90ab532 100644 --- a/include/OutfitSystem.h +++ b/include/OutfitSystem.h @@ -4,9 +4,8 @@ namespace RE { namespace BSScript { class IVirtualMachine; } -} +}// namespace RE -namespace OutfitSystem -{ +namespace OutfitSystem { bool RegisterPapyrus(RE::BSScript::IVirtualMachine* registry); } diff --git a/include/PlayerSkinning.h b/include/PlayerSkinning.h index 148e858..22cb34f 100644 --- a/include/PlayerSkinning.h +++ b/include/PlayerSkinning.h @@ -4,9 +4,8 @@ namespace SKSE { class Trampoline; } -namespace OutfitSystem -{ +namespace OutfitSystem { extern SKSE::Trampoline* g_localTrampoline; extern SKSE::Trampoline* g_branchTrampoline; void ApplyPlayerSkinningHooks(); -} \ No newline at end of file +}// namespace OutfitSystem \ No newline at end of file diff --git a/include/RE/REAugments.h b/include/RE/REAugments.h index 7a00a62..d9a77e7 100644 --- a/include/RE/REAugments.h +++ b/include/RE/REAugments.h @@ -12,31 +12,29 @@ namespace RE { public: inline static constexpr auto RTTI = RTTI_InventoryChanges__IItemChangeVisitor; - virtual ~IItemChangeVisitorAugment() {}; // 00 + virtual ~IItemChangeVisitorAugment(){};// 00 - enum VisitorReturn: std::uint32_t { + enum VisitorReturn : std::uint32_t { kStop, kContinue }; // add - virtual VisitorReturn Visit(InventoryEntryData* a_entryData) = 0; // 01 - virtual void Unk_02(void) {}; // 02 - { return 1; } - virtual void Unk_03(void) {}; // 03 + virtual VisitorReturn Visit(InventoryEntryData* a_entryData) = 0;// 01 + virtual void Unk_02(void){}; // 02 - { return 1; } + virtual void Unk_03(void){}; // 03 }; static_assert(sizeof(IItemChangeVisitorAugment) == 0x8); - namespace InventoryChangesAugments { - void ExecuteVisitor(RE::InventoryChanges* thisPtr, RE::InventoryChanges::IItemChangeVisitor * a_visitor); - void ExecuteAugmentVisitor(RE::InventoryChanges* thisPtr, RE::IItemChangeVisitorAugment * a_visitor); - void ExecuteVisitorOnWorn(RE::InventoryChanges* thisPtr, RE::InventoryChanges::IItemChangeVisitor * a_visitor); - void ExecuteAugmentVisitorOnWorn(RE::InventoryChanges* thisPtr, RE::IItemChangeVisitorAugment * a_visitor); - } + void ExecuteVisitor(RE::InventoryChanges* thisPtr, RE::InventoryChanges::IItemChangeVisitor* a_visitor); + void ExecuteAugmentVisitor(RE::InventoryChanges* thisPtr, RE::IItemChangeVisitorAugment* a_visitor); + void ExecuteVisitorOnWorn(RE::InventoryChanges* thisPtr, RE::InventoryChanges::IItemChangeVisitor* a_visitor); + void ExecuteAugmentVisitorOnWorn(RE::InventoryChanges* thisPtr, RE::IItemChangeVisitorAugment* a_visitor); + }// namespace InventoryChangesAugments namespace AIProcessAugments { - enum class Flag : std::uint8_t - { + enum class Flag : std::uint8_t { kNone = 0, kUnk01 = 1 << 0, kUnk02 = 1 << 1, @@ -47,12 +45,12 @@ namespace RE { }; void SetEquipFlag(RE::AIProcess* thisPtr, Flag a_flag); void UpdateEquipment(RE::AIProcess* thisPtr, Actor* a_actor); - } + }// namespace AIProcessAugments namespace TESObjectARMOAugments { bool ApplyArmorAddon(RE::TESObjectARMO* thisPtr, TESRace* a_race, ActorWeightModel* a_model, bool a_isFemale); bool TestBodyPartByIndex(RE::TESObjectARMO* thisPtr, std::uint32_t a_index); - } -} + }// namespace TESObjectARMOAugments +}// namespace RE -#endif //SKYRIMOUTFITSYSTEMSE_INCLUDE_RE_REAUGMENTS_H +#endif//SKYRIMOUTFITSYSTEMSE_INCLUDE_RE_REAUGMENTS_H diff --git a/include/SOS_PCH.h b/include/SOS_PCH.h index c4d0931..614bebd 100644 --- a/include/SOS_PCH.h +++ b/include/SOS_PCH.h @@ -14,9 +14,9 @@ #include #ifdef NDEBUG -# include +#include #else -# include +#include #endif #pragma warning(pop) @@ -28,17 +28,17 @@ namespace util { using SKSE::stl::report_and_fail; } -#define DllExport __declspec( dllexport ) +#define DllExport __declspec(dllexport) namespace Plugin { using namespace std::literals; inline constexpr REL::Version VERSION{SKYRIMOUTFITSYSTEMSE_VERSION_MAJOR, SKYRIMOUTFITSYSTEMSE_VERSION_MINOR, SKYRIMOUTFITSYSTEMSE_VERSION_PATCH}; inline constexpr auto NAME = "SkyrimOutfitSystemSE"sv; -} +}// namespace Plugin namespace RE { using RawActorHandle = RE::ActorHandle::native_handle_type; } -#endif //SKYRIMOUTFITSYSTEMSE_SOS_PCH_H +#endif//SKYRIMOUTFITSYSTEMSE_SOS_PCH_H diff --git a/include/version.h b/include/version.h index 15e7fc9..f43423d 100644 --- a/include/version.h +++ b/include/version.h @@ -1,13 +1,13 @@ -#ifndef SKYRIMOUTFITSYSTEMSE_VERSION_INCLUDED +#ifndef SKYRIMOUTFITSYSTEMSE_VERSION_INCLUDED #define SKYRIMOUTFITSYSTEMSE_VERSION_INCLUDED #define SKYRIMOUTFITSYSTEMSE_MAKE_STR_HELPER(x) #x #define SKYRIMOUTFITSYSTEMSE_MAKE_STR(x) SKYRIMOUTFITSYSTEMSE_MAKE_STR_HELPER(x) -#define SKYRIMOUTFITSYSTEMSE_VERSION_MAJOR 0 -#define SKYRIMOUTFITSYSTEMSE_VERSION_MINOR 4 -#define SKYRIMOUTFITSYSTEMSE_VERSION_PATCH 0 -#define SKYRIMOUTFITSYSTEMSE_VERSION_BETA 0 -#define SKYRIMOUTFITSYSTEMSE_VERSION_VERSTRING SKYRIMOUTFITSYSTEMSE_MAKE_STR(SKYRIMOUTFITSYSTEMSE_VERSION_MAJOR) "." SKYRIMOUTFITSYSTEMSE_MAKE_STR(SKYRIMOUTFITSYSTEMSE_VERSION_MINOR) "." SKYRIMOUTFITSYSTEMSE_MAKE_STR(SKYRIMOUTFITSYSTEMSE_VERSION_PATCH) "." SKYRIMOUTFITSYSTEMSE_MAKE_STR(SKYRIMOUTFITSYSTEMSE_VERSION_BETA) +#define SKYRIMOUTFITSYSTEMSE_VERSION_MAJOR 0 +#define SKYRIMOUTFITSYSTEMSE_VERSION_MINOR 4 +#define SKYRIMOUTFITSYSTEMSE_VERSION_PATCH 0 +#define SKYRIMOUTFITSYSTEMSE_VERSION_BETA 0 +#define SKYRIMOUTFITSYSTEMSE_VERSION_VERSTRING SKYRIMOUTFITSYSTEMSE_MAKE_STR(SKYRIMOUTFITSYSTEMSE_VERSION_MAJOR) "." SKYRIMOUTFITSYSTEMSE_MAKE_STR(SKYRIMOUTFITSYSTEMSE_VERSION_MINOR) "." SKYRIMOUTFITSYSTEMSE_MAKE_STR(SKYRIMOUTFITSYSTEMSE_VERSION_PATCH) "." SKYRIMOUTFITSYSTEMSE_MAKE_STR(SKYRIMOUTFITSYSTEMSE_VERSION_BETA) #endif diff --git a/src/ArmorAddonOverrideService.cpp b/src/ArmorAddonOverrideService.cpp index 518d65d..0781b91 100644 --- a/src/ArmorAddonOverrideService.cpp +++ b/src/ArmorAddonOverrideService.cpp @@ -549,7 +549,7 @@ void ArmorAddonOverrideService::load(const SKSE::SerializationInterface* intfc, cobb::istring(data.obsolete_current_outfit_name().data(), data.obsolete_current_outfit_name().size()); for (const auto& locOutfitData : data.obsolete_location_based_outfits()) { this->actorOutfitAssignments[RE::PlayerCharacter::GetSingleton()->GetHandle().native_handle()].locationOutfits.emplace(LocationType(locOutfitData.first), - cobb::istring(locOutfitData.second.data(), locOutfitData.second.size())); + cobb::istring(locOutfitData.second.data(), locOutfitData.second.size())); } } } diff --git a/src/OutfitSystem.cpp b/src/OutfitSystem.cpp index a299053..105c531 100644 --- a/src/OutfitSystem.cpp +++ b/src/OutfitSystem.cpp @@ -4,10 +4,10 @@ #include "ArmorAddonOverrideService.h" +#include "RE/REAugments.h" #include "cobb/strings.h" #include "cobb/utf8naturalsort.h" #include "cobb/utf8string.h" -#include "RE/REAugments.h" #include diff --git a/src/hooking/Hooks_AE.cpp b/src/hooking/Hooks_AE.cpp index f2c1336..30f00cc 100644 --- a/src/hooking/Hooks_AE.cpp +++ b/src/hooking/Hooks_AE.cpp @@ -286,7 +286,6 @@ namespace HookingAE { } }// namespace FixEquipConflictCheck - namespace FixSkillLeveling { using namespace Hooking::FixSkillLeveling; @@ -316,25 +315,25 @@ namespace HookingAE { // std::uint32_t heavy = ebp (32-bit) // All these registers are non-volatile - push(rcx); // 8 + push(rcx);// 8 // We now push the register data onto the stack, laid out as the struct would be. - sub(rsp, 0x4); // Fake a push of the ebp - mov(ptr[rsp], ebp);// 4 - sub(rsp, 0x4); // Fake a push of the r15d - mov(ptr[rsp], r15d); // 4 - push(rbx); // 8 - push(r13); // 8 + sub(rsp, 0x4); // Fake a push of the ebp + mov(ptr[rsp], ebp); // 4 + sub(rsp, 0x4); // Fake a push of the r15d + mov(ptr[rsp], r15d);// 4 + push(rbx); // 8 + push(r13); // 8 // We don't need to fixup rsp because the pushes above should leave it 16-byte aligned // rcx is already the right value, so just set rdx to point to the data we pushed - mov(rdx, rsp); // rsp points to the start of the pushed data + mov(rdx, rsp);// rsp points to the start of the pushed data sub(rsp, 0x20); call(ptr[rip + f_Inner]); add(rsp, 0x20); pop(r13); pop(rbx); - mov(r15d, ptr[rsp]); // Fake a pop of r15d + mov(r15d, ptr[rsp]);// Fake a pop of r15d add(rsp, 0x4); - mov(ebp, ptr[rsp]); // Fake a pop of ebp + mov(ebp, ptr[rsp]);// Fake a pop of ebp add(rsp, 0x4); pop(rcx); test(al, al); @@ -424,4 +423,4 @@ namespace HookingAE { RTTIPrinter::Apply(); #endif } -}// namespace Hooking +}// namespace HookingAE diff --git a/src/hooking/Hooks_PRE_AE.cpp b/src/hooking/Hooks_PRE_AE.cpp index cbc723c..1277493 100644 --- a/src/hooking/Hooks_PRE_AE.cpp +++ b/src/hooking/Hooks_PRE_AE.cpp @@ -345,4 +345,4 @@ namespace HookingPREAE { FixEquipConflictCheck::Apply(); FixSkillLeveling::Apply(); } -}// namespace Hooking +}// namespace HookingPREAE diff --git a/src/hooking/Patches.cpp b/src/hooking/Patches.cpp index 9f4738e..f85b456 100644 --- a/src/hooking/Patches.cpp +++ b/src/hooking/Patches.cpp @@ -44,14 +44,14 @@ namespace Hooking { std::unordered_set equipped; }; - template + template class EquippedVisitorFn: public RE::IItemChangeVisitorAugment { // // If the player has a shield equipped, and if we're not overriding that // shield, then we need to grab the equipped shield's worn-flags. // public: - explicit EquippedVisitorFn(F callable) : callable(callable) {}; + explicit EquippedVisitorFn(F callable) : callable(callable){}; virtual VisitorReturn Visit(RE::InventoryEntryData* data) override { auto form = data->object; if (form) { @@ -237,7 +237,7 @@ namespace Hooking { static_assert(sizeof(Visitor) == 0x18); bool Inner(RE::BipedAnim* biped, Visitor* bipedVisitor) { - auto target = biped->actorRef.get(); // Retain via smart pointer. + auto target = biped->actorRef.get();// Retain via smart pointer. if (!target) return false; auto actor = skyrim_cast(target.get()); if (!actor) return false;