Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improve edid conflict check #1

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions Plugin/src/Misc/Patches/LoadEditorIDs.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ namespace Patches
}

private:
static std::string_view GetFileName(RE::TESForm* a_form)
{
try
{
return a_form->GetFile() ? a_form->GetFile()->GetFilename() : "unknown"sv;
}
catch (const std::exception& e)
{
ERROR("{}", e.what());
return "error"sv;
}
}
static void AddToGameMap(RE::TESForm* a_this, const char* a_editorID)
{
const auto& [map, lock] = RE::TESForm::GetAllFormsByEditorID();
Expand All @@ -45,11 +57,15 @@ namespace Patches
if (*Config::Patches::bEnableEDIDConflictCheck)
{
auto iter = map->find(a_editorID);
if (iter != map->end())
if (iter != map->end() && iter->second->GetFormID() && iter->second->GetFormID() != a_this->GetFormID())
{
auto name = iter->second->GetFile() ? iter->second->GetFile()->GetFilename() : "unknown";
auto name2 = a_this->GetFile() ? a_this->GetFile()->GetFilename() : "unknown";
WARN(
"EditorID Conflict: {:08X} and {:08X} are both {:s}"sv,
"EditorID Conflict: {}:{:08X} and {}:{:08X} are both {:s}"sv,
GetFileName(iter->second),
iter->second->GetFormID(),
GetFileName(a_this),
a_this->GetFormID(),
a_editorID);
return;
Expand Down