Skip to content

Commit

Permalink
Merge pull request #97 from pavledev/master
Browse files Browse the repository at this point in the history
Fix exception that occurs when player menu is opened again after rest…
  • Loading branch information
OrfeasZ authored Mar 18, 2024
2 parents 855cc14 + 019a5c1 commit 38bef54
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
2 changes: 2 additions & 0 deletions Mods/DebugMod/Src/DebugMod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1284,6 +1284,8 @@ DEFINE_PLUGIN_DETOUR(DebugMod, void, OnClearScene, ZEntitySceneContext* th, bool
DisableTrackCam();
m_TrackCamActive = false;

m_GlobalOutfitKit = nullptr;

return HookResult<void>(HookAction::Continue());
}

Expand Down
2 changes: 2 additions & 0 deletions Mods/DebugMod/Src/DebugMod.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ class DebugMod : public IPluginInterface

ZHM5CrippleBox* m_Hm5CrippleBox = nullptr;

TEntityRef<ZGlobalOutfitKit>* m_GlobalOutfitKit;

private:
ZActor* m_NPCTracked = nullptr;
bool m_TrackCamActive = false;
Expand Down
37 changes: 18 additions & 19 deletions Mods/DebugMod/Src/UI/PlayerBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ void DebugMod::DrawPlayerBox(bool p_HasFocus)
ImGui::SetNextWindowPos(ImVec2(ImGui::GetItemRectMin().x, ImGui::GetItemRectMax().y));
ImGui::SetNextWindowSize(ImVec2(ImGui::GetItemRectSize().x, 300));

static TEntityRef<ZGlobalOutfitKit>* s_GlobalOutfitKit = nullptr;
static char s_CurrentCharacterSetIndex[3] { "0" };
static const char* s_CurrentcharSetCharacterType = "HeroA";
static const char* s_CurrentcharSetCharacterType2 = "HeroA";
Expand All @@ -66,8 +65,8 @@ void DebugMod::DrawPlayerBox(bool p_HasFocus)
{
for (auto it = s_ContentKitManager->m_repositoryGlobalOutfitKits.begin(); it != s_ContentKitManager->m_repositoryGlobalOutfitKits.end(); ++it)
{
TEntityRef<ZGlobalOutfitKit>* s_GlobalOutfitKit2 = &it->second;
const char* s_OutfitName2 = s_GlobalOutfitKit2->m_pInterfaceRef->m_sCommonName.c_str();
TEntityRef<ZGlobalOutfitKit>* s_GlobalOutfitKit = &it->second;
const char* s_OutfitName2 = s_GlobalOutfitKit->m_pInterfaceRef->m_sCommonName.c_str();

if (!strstr(s_OutfitName2, s_OutfitName))
{
Expand All @@ -81,7 +80,7 @@ void DebugMod::DrawPlayerBox(bool p_HasFocus)

EquipOutfit(it->second, std::stoi(s_CurrentCharacterSetIndex), s_CurrentcharSetCharacterType, std::stoi(s_CurrentOutfitVariationIndex), s_LocalHitman.m_pInterfaceRef);

s_GlobalOutfitKit = s_GlobalOutfitKit2;
m_GlobalOutfitKit = s_GlobalOutfitKit;
}
}

Expand All @@ -98,9 +97,9 @@ void DebugMod::DrawPlayerBox(bool p_HasFocus)

if (ImGui::BeginCombo("##CharacterSetIndex", s_CurrentCharacterSetIndex))
{
if (s_GlobalOutfitKit)
if (m_GlobalOutfitKit)
{
for (size_t i = 0; i < s_GlobalOutfitKit->m_pInterfaceRef->m_aCharSets.size(); ++i)
for (size_t i = 0; i < m_GlobalOutfitKit->m_pInterfaceRef->m_aCharSets.size(); ++i)
{
std::string s_CharacterSetIndex = std::to_string(i);
const bool s_IsSelected = s_CurrentCharacterSetIndex == s_CharacterSetIndex.c_str();
Expand All @@ -109,9 +108,9 @@ void DebugMod::DrawPlayerBox(bool p_HasFocus)
{
strcpy_s(s_CurrentCharacterSetIndex, s_CharacterSetIndex.c_str());

if (s_GlobalOutfitKit)
if (m_GlobalOutfitKit)
{
EquipOutfit(*s_GlobalOutfitKit, std::stoi(s_CurrentCharacterSetIndex), s_CurrentcharSetCharacterType, std::stoi(s_CurrentOutfitVariationIndex), s_LocalHitman.m_pInterfaceRef);
EquipOutfit(*m_GlobalOutfitKit, std::stoi(s_CurrentCharacterSetIndex), s_CurrentcharSetCharacterType, std::stoi(s_CurrentOutfitVariationIndex), s_LocalHitman.m_pInterfaceRef);
}
}
}
Expand All @@ -125,7 +124,7 @@ void DebugMod::DrawPlayerBox(bool p_HasFocus)

if (ImGui::BeginCombo("##CharSetCharacterType", s_CurrentcharSetCharacterType))
{
if (s_GlobalOutfitKit)
if (m_GlobalOutfitKit)
{
for (size_t i = 0; i < 3; ++i)
{
Expand All @@ -135,9 +134,9 @@ void DebugMod::DrawPlayerBox(bool p_HasFocus)
{
s_CurrentcharSetCharacterType = m_CharSetCharacterTypes[i];

if (s_GlobalOutfitKit)
if (m_GlobalOutfitKit)
{
EquipOutfit(*s_GlobalOutfitKit, std::stoi(s_CurrentCharacterSetIndex), s_CurrentcharSetCharacterType, std::stoi(s_CurrentOutfitVariationIndex), s_LocalHitman.m_pInterfaceRef);
EquipOutfit(*m_GlobalOutfitKit, std::stoi(s_CurrentCharacterSetIndex), s_CurrentcharSetCharacterType, std::stoi(s_CurrentOutfitVariationIndex), s_LocalHitman.m_pInterfaceRef);
}
}
}
Expand All @@ -151,10 +150,10 @@ void DebugMod::DrawPlayerBox(bool p_HasFocus)

if (ImGui::BeginCombo("##OutfitVariation", s_CurrentOutfitVariationIndex))
{
if (s_GlobalOutfitKit)
if (m_GlobalOutfitKit)
{
const unsigned int s_CurrentCharacterSetIndex2 = std::stoi(s_CurrentCharacterSetIndex);
const size_t s_VariationCount = s_GlobalOutfitKit->m_pInterfaceRef->m_aCharSets[s_CurrentCharacterSetIndex2].m_pInterfaceRef->m_aCharacters[0].m_pInterfaceRef->m_aVariations.size();
const size_t s_VariationCount = m_GlobalOutfitKit->m_pInterfaceRef->m_aCharSets[s_CurrentCharacterSetIndex2].m_pInterfaceRef->m_aCharacters[0].m_pInterfaceRef->m_aVariations.size();

for (size_t i = 0; i < s_VariationCount; ++i)
{
Expand All @@ -165,9 +164,9 @@ void DebugMod::DrawPlayerBox(bool p_HasFocus)
{
strcpy_s(s_CurrentOutfitVariationIndex, s_OutfitVariationIndex.c_str());

if (s_GlobalOutfitKit)
if (m_GlobalOutfitKit)
{
EquipOutfit(*s_GlobalOutfitKit, std::stoi(s_CurrentCharacterSetIndex), s_CurrentcharSetCharacterType, std::stoi(s_CurrentOutfitVariationIndex), s_LocalHitman.m_pInterfaceRef);
EquipOutfit(*m_GlobalOutfitKit, std::stoi(s_CurrentCharacterSetIndex), s_CurrentcharSetCharacterType, std::stoi(s_CurrentOutfitVariationIndex), s_LocalHitman.m_pInterfaceRef);
}
}
}
Expand All @@ -176,10 +175,10 @@ void DebugMod::DrawPlayerBox(bool p_HasFocus)
ImGui::EndCombo();
}

if (s_GlobalOutfitKit)
if (m_GlobalOutfitKit)
{
ImGui::Checkbox("Weapons Allowed", &s_GlobalOutfitKit->m_pInterfaceRef->m_bWeaponsAllowed);
ImGui::Checkbox("Authority Figure", &s_GlobalOutfitKit->m_pInterfaceRef->m_bAuthorityFigure);
ImGui::Checkbox("Weapons Allowed", &m_GlobalOutfitKit->m_pInterfaceRef->m_bWeaponsAllowed);
ImGui::Checkbox("Authority Figure", &m_GlobalOutfitKit->m_pInterfaceRef->m_bAuthorityFigure);
}

ImGui::Separator();
Expand Down Expand Up @@ -232,7 +231,7 @@ void DebugMod::DrawPlayerBox(bool p_HasFocus)

if (ImGui::BeginCombo("##CharSetCharacterType2", s_CurrentcharSetCharacterType2))
{
if (s_GlobalOutfitKit)
if (m_GlobalOutfitKit)
{
for (size_t i = 0; i < 3; ++i)
{
Expand Down

0 comments on commit 38bef54

Please sign in to comment.