-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e8ff12a
commit bf4e3f5
Showing
18 changed files
with
19,174 additions
and
17,222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
#pragma once | ||
|
||
#include "Maps.h" | ||
|
||
class Conflicts : public Singleton<Conflicts> | ||
{ | ||
public: | ||
static void PrepareDistribution() noexcept; | ||
|
||
static void PrepareDistributionImpl(const Maps::TConflictTestMap& test_map) noexcept; | ||
}; | ||
#pragma once | ||
|
||
#include "Maps.h" | ||
|
||
class Conflicts : public Singleton<Conflicts> | ||
{ | ||
public: | ||
static void PrepareDistribution() noexcept; | ||
|
||
static void PrepareDistributionImpl(const Maps::TConflictTestMap& test_map) noexcept; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
#pragma once | ||
|
||
#include "Utility.h" | ||
|
||
class Distributor : public Singleton<Distributor> | ||
{ | ||
public: | ||
static void Distribute() noexcept; | ||
|
||
static void AddDistribute(const Maps::TDistrVec& distr_vec) noexcept; | ||
|
||
static void RemoveDistribute(const Maps::TDistrVec& distr_vec) noexcept; | ||
|
||
static void ReplaceDistribute(const Maps::TDistrVec& distr_vec) noexcept; | ||
}; | ||
#pragma once | ||
|
||
#include "Utility.h" | ||
|
||
class Distributor : public Singleton<Distributor> | ||
{ | ||
public: | ||
static void Distribute() noexcept; | ||
|
||
static void AddDistribute(const Maps::TDistrVec& distr_vec) noexcept; | ||
|
||
static void RemoveDistribute(const Maps::TDistrVec& distr_vec) noexcept; | ||
|
||
static void ReplaceDistribute(const Maps::TDistrVec& distr_vec) noexcept; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
#pragma once | ||
|
||
namespace Hooks | ||
{ | ||
void Install() noexcept; | ||
|
||
class SetFormEditorID : public Singleton<SetFormEditorID> | ||
{ | ||
public: | ||
static bool Thunk(RE::TESForm* a_this, const char* a_str) noexcept; | ||
|
||
inline static REL::Relocation<decltype(&Thunk)> func; | ||
|
||
static constexpr std::size_t idx{ 51 }; // 0x33 | ||
}; | ||
} // namespace Hooks | ||
#pragma once | ||
|
||
namespace Hooks | ||
{ | ||
void Install() noexcept; | ||
|
||
class SetFormEditorID : public Singleton<SetFormEditorID> | ||
{ | ||
public: | ||
static bool Thunk(RE::TESForm* a_this, const char* a_str) noexcept; | ||
|
||
inline static REL::Relocation<decltype(&Thunk)> func; | ||
|
||
static constexpr std::size_t idx{ 51 }; // 0x33 | ||
}; | ||
} // namespace Hooks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#pragma once | ||
|
||
void InitializeLogging() noexcept; | ||
#pragma once | ||
|
||
void InitializeLogging() noexcept; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,132 +1,132 @@ | ||
#pragma once | ||
|
||
#include "parallel_hashmap/phmap.h" | ||
|
||
enum class DistrType | ||
{ | ||
Add, | ||
Remove, | ||
RemoveAll, | ||
Replace, | ||
ReplaceAll, | ||
Error | ||
}; | ||
|
||
class DistrToken | ||
{ | ||
public: | ||
bool operator==(const DistrToken&) const = default; | ||
|
||
DistrType type{}; | ||
std::string filename{}; | ||
std::string to_identifier{}; | ||
std::string identifier{}; | ||
std::optional<std::int32_t> count{}; | ||
std::optional<std::string> rhs{}; | ||
std::optional<std::int32_t> rhs_count{}; | ||
}; | ||
|
||
class Container | ||
{ | ||
public: | ||
explicit operator bool() const | ||
{ | ||
return container; | ||
} | ||
|
||
RE::TESContainer* container{}; | ||
RE::FormID container_form_id{}; | ||
RE::FormType container_type{}; | ||
std::string container_name{}; | ||
}; | ||
|
||
struct DistrObject | ||
{ | ||
DistrType type{}; | ||
RE::TESBoundObject* bound_object{}; | ||
std::string filename{}; | ||
std::optional<std::int32_t> count{}; | ||
std::optional<RE::TESBoundObject*> replace_with_object{}; | ||
std::optional<std::int32_t> replace_with_count{}; | ||
std::optional<Container> container{}; | ||
}; | ||
|
||
struct FormIDAndPluginName | ||
{ | ||
RE::FormID form_id{}; | ||
std::string plugin_name{}; | ||
}; | ||
|
||
class Maps : public Singleton<Maps> | ||
{ | ||
public: | ||
static std::int32_t ToInt32(const std::string_view& s) | ||
{ | ||
return static_cast<std::int32_t>(std::strtol(s.data(), nullptr, 0)); | ||
} | ||
|
||
static std::uint32_t ToUint32(const std::string_view& s) | ||
{ | ||
return static_cast<std::uint32_t>(std::strtol(s.data(), nullptr, 0)); | ||
} | ||
|
||
static std::size_t GetPos(const std::string_view s, const char c) | ||
{ | ||
const auto ptr{ std::strrchr(s.data(), c) }; | ||
|
||
return static_cast<std::size_t>(ptr - s.data()); | ||
} | ||
|
||
using TDistrTokenVec = std::vector<DistrToken>; | ||
using TConflictTestMap = phmap::parallel_flat_hash_map<std::string, TDistrTokenVec>; | ||
|
||
inline static TConflictTestMap add_conflict_test_map; | ||
|
||
inline static TConflictTestMap remove_conflict_test_map; | ||
|
||
inline static TConflictTestMap replace_conflict_test_map; | ||
|
||
using TDistrVec = std::vector<DistrObject>; | ||
inline static TDistrVec distr_object_vec; | ||
}; | ||
|
||
// fmt helpers | ||
inline auto format_as(const DistrType& type) | ||
{ | ||
switch (type) | ||
{ | ||
case DistrType::Add: | ||
return "ADD"; | ||
case DistrType::Remove: | ||
return "REMOVE"; | ||
case DistrType::RemoveAll: | ||
return "REMOVE ALL"; | ||
case DistrType::Replace: | ||
return "REPLACE"; | ||
case DistrType::ReplaceAll: | ||
return "REPLACE ALL"; | ||
default: | ||
return "ERROR"; | ||
} | ||
} | ||
|
||
inline auto format_as(const DistrToken& token) | ||
{ | ||
const auto& [type, filename, to_identifier, identifier, count, rhs, rhs_count]{ token }; | ||
return fmt::format("[Type: {} / Filename: {} / To: {} / Identifier: {} / Count: {} / RHS: {} / RHS Count: {}]", type, filename, to_identifier, | ||
identifier, count.value_or(-1), rhs.value_or("null"), rhs_count.value_or(-1)); | ||
} | ||
|
||
inline auto format_as(const DistrObject& obj) | ||
{ | ||
const auto& [type, bound_object, filename, count, replace_with_obj, replace_with_count, container]{ obj }; | ||
#pragma once | ||
|
||
#include "parallel_hashmap/phmap.h" | ||
|
||
enum class DistrType | ||
{ | ||
Add, | ||
Remove, | ||
RemoveAll, | ||
Replace, | ||
ReplaceAll, | ||
Error | ||
}; | ||
|
||
class DistrToken | ||
{ | ||
public: | ||
bool operator==(const DistrToken&) const = default; | ||
|
||
DistrType type{}; | ||
std::string filename{}; | ||
std::string to_identifier{}; | ||
std::string identifier{}; | ||
std::optional<std::int32_t> count{}; | ||
std::optional<std::string> rhs{}; | ||
std::optional<std::int32_t> rhs_count{}; | ||
}; | ||
|
||
class Container | ||
{ | ||
public: | ||
explicit operator bool() const | ||
{ | ||
return container; | ||
} | ||
|
||
RE::TESContainer* container{}; | ||
RE::FormID container_form_id{}; | ||
RE::FormType container_type{}; | ||
std::string container_name{}; | ||
}; | ||
|
||
struct DistrObject | ||
{ | ||
DistrType type{}; | ||
RE::TESBoundObject* bound_object{}; | ||
std::string filename{}; | ||
std::optional<std::int32_t> count{}; | ||
std::optional<RE::TESBoundObject*> replace_with_object{}; | ||
std::optional<std::int32_t> replace_with_count{}; | ||
std::optional<Container> container{}; | ||
}; | ||
|
||
struct FormIDAndPluginName | ||
{ | ||
RE::FormID form_id{}; | ||
std::string plugin_name{}; | ||
}; | ||
|
||
class Maps : public Singleton<Maps> | ||
{ | ||
public: | ||
static std::int32_t ToInt32(const std::string_view& s) | ||
{ | ||
return static_cast<std::int32_t>(std::strtol(s.data(), nullptr, 0)); | ||
} | ||
|
||
static std::uint32_t ToUint32(const std::string_view& s) | ||
{ | ||
return static_cast<std::uint32_t>(std::strtol(s.data(), nullptr, 0)); | ||
} | ||
|
||
static std::size_t GetPos(const std::string_view s, const char c) | ||
{ | ||
const auto ptr{ std::strrchr(s.data(), c) }; | ||
|
||
return static_cast<std::size_t>(ptr - s.data()); | ||
} | ||
|
||
using TDistrTokenVec = std::vector<DistrToken>; | ||
using TConflictTestMap = phmap::parallel_flat_hash_map<std::string, TDistrTokenVec>; | ||
|
||
inline static TConflictTestMap add_conflict_test_map; | ||
|
||
inline static TConflictTestMap remove_conflict_test_map; | ||
|
||
inline static TConflictTestMap replace_conflict_test_map; | ||
|
||
using TDistrVec = std::vector<DistrObject>; | ||
inline static TDistrVec distr_object_vec; | ||
}; | ||
|
||
// fmt helpers | ||
inline auto format_as(const DistrType& type) | ||
{ | ||
switch (type) | ||
{ | ||
case DistrType::Add: | ||
return "ADD"; | ||
case DistrType::Remove: | ||
return "REMOVE"; | ||
case DistrType::RemoveAll: | ||
return "REMOVE ALL"; | ||
case DistrType::Replace: | ||
return "REPLACE"; | ||
case DistrType::ReplaceAll: | ||
return "REPLACE ALL"; | ||
default: | ||
return "ERROR"; | ||
} | ||
} | ||
|
||
inline auto format_as(const DistrToken& token) | ||
{ | ||
const auto& [type, filename, to_identifier, identifier, count, rhs, rhs_count]{ token }; | ||
return fmt::format("[Type: {} / Filename: {} / To: {} / Identifier: {} / Count: {} / RHS: {} / RHS Count: {}]", type, filename, to_identifier, | ||
identifier, count.value_or(-1), rhs.value_or("null"), rhs_count.value_or(-1)); | ||
} | ||
|
||
inline auto format_as(const DistrObject& obj) | ||
{ | ||
const auto& [type, bound_object, filename, count, replace_with_obj, replace_with_count, container]{ obj }; | ||
// clang-format off | ||
return | ||
fmt::format( | ||
"[Type: {} / Filename: {} / Bound object: {} (0x{:x}) / Count: {} / Replace with: {} (0x{:x}) / Replace count: {} / Container: {} (0x{:x}) ({})]", | ||
type, filename, bound_object ? bound_object->GetName() : "null", bound_object ? bound_object->GetFormID() : 0, count.value_or(-1), | ||
replace_with_obj.has_value() ? (replace_with_obj.value() ? replace_with_obj.value()->GetName() : "null") : "null", | ||
replace_with_obj.has_value() ? (replace_with_obj.value() ? replace_with_obj.value()->GetFormID() : 0) : 0, replace_with_count.value_or(-1), | ||
container.has_value() ? container.value().container_name : "null", container.has_value() ? container.value().container_form_id : 0, container.has_value() ? container->container_type : RE::FormType::Container); | ||
// clang-format on | ||
} | ||
container.has_value() ? container.value().container_name : "null", container.has_value() ? container.value().container_form_id : 0, container.has_value() ? container->container_type : RE::FormType::Container); | ||
// clang-format on | ||
} |
Oops, something went wrong.