Skip to content

Commit

Permalink
Replaced term "exclusion group" with "exclusive group".
Browse files Browse the repository at this point in the history
Yeah, it bothered me too much 🤓
  • Loading branch information
adya committed Mar 12, 2024
1 parent 35c2d0a commit 4f4f793
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 44 deletions.
2 changes: 1 addition & 1 deletion SPID/cmake/headerlist.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set(headers ${headers}
include/Distribute.h
include/DistributeManager.h
include/DistributePCLevelMult.h
include/ExclusionGroups.h
include/ExclusiveGroups.h
include/FormData.h
include/KeywordDependencies.h
include/LogBuffer.h
Expand Down
2 changes: 1 addition & 1 deletion SPID/cmake/sourcelist.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set(sources ${sources}
src/Distribute.cpp
src/DistributeManager.cpp
src/DistributePCLevelMult.cpp
src/ExclusionGroups.cpp
src/ExclusiveGroups.cpp
src/FormData.cpp
src/KeywordDependencies.cpp
src/LogBuffer.cpp
Expand Down
20 changes: 10 additions & 10 deletions SPID/include/ExclusionGroups.h → SPID/include/ExclusiveGroups.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#include "LookupConfigs.h"

namespace Exclusion
namespace ExclusiveGroups
{
using GroupName = std::string;
using LinkedGroups = std::unordered_map<RE::TESForm*, std::unordered_set<GroupName>>;
Expand All @@ -13,35 +13,35 @@ namespace Exclusion
/// <summary>
/// Does a forms lookup similar to what Filters do.
///
/// As a result this method configures Manager with discovered valid exclusion groups.
/// As a result this method configures Manager with discovered valid exclusive groups.
/// </summary>
/// <param name=""></param>
/// <param name="exclusion">A Raw exclusion entries that should be processed/</param>
void LookupExclusions(RE::TESDataHandler* const dataHandler, INI::ExclusionsVec& exclusion);
/// <param name="rawExclusiveGroups">A raw exclusive group entries that should be processed/</param>
void LookupExclusiveGroups(RE::TESDataHandler* const dataHandler, INI::ExclusiveGroupsVec& rawExclusiveGroups);

/// <summary>
/// Gets a set of all forms that are in the same exclusion group as the given form.
/// Note that a form can appear in multiple exclusion groups, all of those groups are returned.
/// Gets a set of all forms that are in the same exclusive group as the given form.
/// Note that a form can appear in multiple exclusive groups, all of those groups are returned.
/// </summary>
/// <param name="form"></param>
/// <returns>A union of all groups that contain a given form.</returns>
std::unordered_set<RE::TESForm*> MutuallyExclusiveFormsForForm(RE::TESForm* form) const;

/// <summary>
/// Retrieves all exclusion groups.
/// Retrieves all exclusive groups.
/// </summary>
/// <returns>A reference to discovered exclusion groups</returns>
/// <returns>A reference to discovered exclusive groups</returns>
const Groups& GetGroups() const;

private:
/// <summary>
/// A map of exclusion group names related to each form in the exclusion groups.
/// A map of exclusive group names related to each form in the exclusive groups.
/// Provides a quick and easy way to get names of all groups that need to be checked.
/// </summary>
LinkedGroups linkedGroups{};

/// <summary>
/// A map of exclusion groups names and the forms that are part of each exclusion group.
/// A map of exclusive groups names and the forms that are part of each exclusive group.
/// </summary>
Groups groups{};
};
Expand Down
10 changes: 5 additions & 5 deletions SPID/include/LookupConfigs.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,24 @@ namespace INI
std::string path{};
};

struct Exclusion
struct RawExclusiveGroup
{
std::string name{};

/// Raw filters in Exclusion only use NOT and MATCH, there is no meaning for ALL, so it's ignored.
/// Raw filters in RawExclusiveGroup only use NOT and MATCH, there is no meaning for ALL, so it's ignored.
Filters<FormOrEditorID> rawFormFilters{};
std::string path{};
};

using DataVec = std::vector<Data>;
using ExclusionsVec = std::vector<Exclusion>;
using ExclusiveGroupsVec = std::vector<RawExclusiveGroup>;

inline StringMap<DataVec> configs{};

/// <summary>
/// A raw list of ExclusionGroups that will be processed along with configs.
/// A list of RawExclusiveGroups that will be processed along with configs.
/// </summary>
inline ExclusionsVec exclusions{};
inline ExclusiveGroupsVec exclusiveGroups{};

std::pair<bool, bool> GetConfigs();
}
2 changes: 1 addition & 1 deletion SPID/include/LookupNPC.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace NPC

/// <summary>
/// Checks whether given NPC already has another form that is mutually exclusive with the given form,
/// according to the exclusion groups configuration.
/// according to the exclusive groups configuration.
/// </summary>
/// <param name="otherForm">A Form that needs to be checked.</param>
/// <returns></returns>
Expand Down
10 changes: 5 additions & 5 deletions SPID/src/ExclusionGroups.cpp → SPID/src/ExclusiveGroups.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "ExclusionGroups.h"
#include "ExclusiveGroups.h"
#include "FormData.h"

void Exclusion::Manager::LookupExclusions(RE::TESDataHandler* const dataHandler, INI::ExclusionsVec& exclusions)
void ExclusiveGroups::Manager::LookupExclusiveGroups(RE::TESDataHandler* const dataHandler, INI::ExclusiveGroupsVec& exclusiveGroups)
{
groups.clear();
linkedGroups.clear();

for (auto& [name, filterIDs, path] : exclusions) {
for (auto& [name, filterIDs, path] : exclusiveGroups) {
auto& forms = groups[name];
FormVec match{};
FormVec formsNot{};
Expand Down Expand Up @@ -41,7 +41,7 @@ void Exclusion::Manager::LookupExclusions(RE::TESDataHandler* const dataHandler,
}
}

std::unordered_set<RE::TESForm*> Exclusion::Manager::MutuallyExclusiveFormsForForm(RE::TESForm* form) const
std::unordered_set<RE::TESForm*> ExclusiveGroups::Manager::MutuallyExclusiveFormsForForm(RE::TESForm* form) const
{
std::unordered_set<RE::TESForm*> forms{};
if (auto it = linkedGroups.find(form); it != linkedGroups.end()) {
Expand All @@ -57,7 +57,7 @@ std::unordered_set<RE::TESForm*> Exclusion::Manager::MutuallyExclusiveFormsForFo
return forms;
}

const Exclusion::Groups& Exclusion::Manager::GetGroups() const
const ExclusiveGroups::Groups& ExclusiveGroups::Manager::GetGroups() const
{
return groups;
}
17 changes: 8 additions & 9 deletions SPID/src/LookupConfigs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,33 +46,33 @@ namespace INI
return newValue;
}

std::optional<Exclusion> parse_exclusion(const std::string& a_key, const std::string& a_value, const std::string& a_path)
std::optional<RawExclusiveGroup> parse_exclusive_group(const std::string& a_key, const std::string& a_value, const std::string& a_path)
{
if (a_key != "ExclusionGroup") {
if (a_key != "ExclusiveGroup") {
return std::nullopt;
}

const auto sections = string::split(a_value, "|");
const auto size = sections.size();

if (size == 0) {
logger::warn("IGNORED: ExclusionGroup must have a name: {} = {}"sv, a_key, a_value);
logger::warn("IGNORED: ExclusiveGroup must have a name: {} = {}"sv, a_key, a_value);
return std::nullopt;
}

if (size == 1) {
logger::warn("IGNORED: ExclusionGroup must have at least one filter name: {} = {}"sv, a_key, a_value);
logger::warn("IGNORED: ExclusiveGroup must have at least one filter name: {} = {}"sv, a_key, a_value);
return std::nullopt;
}

auto split_IDs = distribution::split_entry(sections[1]);

if (split_IDs.empty()) {
logger::warn("ExclusionGroup must have at least one Form Filter : {} = {}"sv, a_key, a_value);
logger::warn("ExclusiveGroup must have at least one Form Filter : {} = {}"sv, a_key, a_value);
return std::nullopt;
}

Exclusion group{};
RawExclusiveGroup group{};
group.name = sections[0];
group.path = a_path;

Expand Down Expand Up @@ -305,9 +305,8 @@ namespace INI

for (auto& [key, entry] : *values) {
try {
if (const auto exclusionOpt = detail::parse_exclusion(key.pItem, entry, truncatedPath); exclusionOpt) {
const auto& exclusion = *exclusionOpt;
exclusions.emplace_back(exclusion);
if (const auto group = detail::parse_exclusive_group(key.pItem, entry, truncatedPath); group) {
exclusiveGroups.emplace_back(*group);
continue;
}

Expand Down
20 changes: 10 additions & 10 deletions SPID/src/LookupForms.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "LookupForms.h"
#include "ExclusionGroups.h"
#include "ExclusiveGroups.h"
#include "FormData.h"
#include "KeywordDependencies.h"

Expand Down Expand Up @@ -51,24 +51,24 @@ void LogDistributablesLookup()
buffered_logger::clear();
}

// Lookup exclusion forms too.
// Lookup forms in exclusvie groups too.
// P.S. Lookup process probably should build some sort of cache and reuse already discovered forms
// instead of quering data handler for the same raw FormOrEditorID.
void LookupExclusionGroups(RE::TESDataHandler* const dataHandler)
void LookupExclusiveGroups(RE::TESDataHandler* const dataHandler)
{
Exclusion::Manager::GetSingleton()->LookupExclusions(dataHandler, INI::exclusions);
ExclusiveGroups::Manager::GetSingleton()->LookupExclusiveGroups(dataHandler, INI::exclusiveGroups);
}

void LogExclusionGroupsLookup()
void LogExclusiveGroupsLookup()
{
if (const auto manager = Exclusion::Manager::GetSingleton(); manager) {
if (const auto manager = ExclusiveGroups::Manager::GetSingleton(); manager) {
const auto& groups = manager->GetGroups();

if (!groups.empty()) {
logger::info("{:*^50}", "EXCLUSIONS");
logger::info("{:*^50}", "EXCLUSIVE GROUPS");

for (const auto& [group, forms] : groups) {
logger::info("Adding '{}' exclusion group", group);
logger::info("Adding '{}' exclusive group", group);
for (const auto& form : forms) {
logger::info(" {}", describe(form));
}
Expand All @@ -93,8 +93,8 @@ bool Lookup::LookupForms()
logger::info("Lookup took {}μs / {}ms", timer.duration_μs(), timer.duration_ms());
}

LookupExclusionGroups(dataHandler);
LogExclusionGroupsLookup();
LookupExclusiveGroups(dataHandler);
LogExclusiveGroupsLookup();

return success;
}
Expand Down
4 changes: 2 additions & 2 deletions SPID/src/LookupNPC.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "LookupNPC.h"
#include <ExclusionGroups.h>
#include <ExclusiveGroups.h>

namespace NPC
{
Expand Down Expand Up @@ -185,7 +185,7 @@ namespace NPC

bool Data::HasMutuallyExclusiveForm(RE::TESForm* a_form) const
{
auto excludedForms = Exclusion::Manager::GetSingleton()->MutuallyExclusiveFormsForForm(a_form);
auto excludedForms = ExclusiveGroups::Manager::GetSingleton()->MutuallyExclusiveFormsForForm(a_form);
if (excludedForms.empty()) {
return false;
}
Expand Down

0 comments on commit 4f4f793

Please sign in to comment.