Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions src/ui/viewmodels/TriggerConditionViewModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "data\util\IndirectNoteResolver.hh"

#include "services\AchievementLogicSerializer.hh"
#include "services\AchievementRuntime.hh"
#include "services\IConfiguration.hh"
#include "services\ServiceLocator.hh"

Expand Down Expand Up @@ -637,8 +636,9 @@ const rc_condition_t* TriggerConditionViewModel::GetFirstCondition() const
}
else
{
Expects(pGroup->m_pConditionSet != nullptr);
pFirstCondition = pGroup->m_pConditionSet->conditions;
auto* pCondSet = pGroup->GetConditionSet(pTriggerViewModel->IsValue());
Expects(pCondSet != nullptr);
pFirstCondition = pCondSet->conditions;
}

return pFirstCondition;
Expand Down Expand Up @@ -688,7 +688,7 @@ ra::data::ByteAddress TriggerConditionViewModel::GetIndirectAddress(ra::data::By
if (pCondition)
{
auto& pCodeNotes = ra::services::ServiceLocator::Get<ra::context::IGameContext>().MemoryNotes();
ra::data::util::IndirectNoteResolver pIndirectNoteResolver(pCodeNotes);
const ra::data::util::IndirectNoteResolver pIndirectNoteResolver(pCodeNotes);
std::vector<ra::data::util::IndirectNoteResolver::Node> vParentChain;

const auto* pOperand1 = rc_condition_get_real_operand1(pCondition);
Expand Down
30 changes: 30 additions & 0 deletions tests/ui/viewmodels/AssetEditorViewModel_Tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2495,6 +2495,36 @@ TEST_CLASS(AssetEditorViewModel_Tests)
editor.SetSelectedLeaderboardPart(AssetEditorViewModel::LeaderboardPart::Submit);
Assert::AreEqual({ 0 }, editor.Trigger().Conditions().Count());
}

TEST_METHOD(TestPasteAndModifyIncompleteComparison)
{
AssetEditorViewModelHarness editor;

// create an achievement and hook it up to a runtime structure that will hold the trigger definition
struct rc_client_achievement_info_t achievement_info;
memset(&achievement_info, 0, sizeof(achievement_info));
AchievementModel achievement;
achievement.CreateServerCheckpoint();
achievement.CreateLocalCheckpoint();
achievement.SetLocalAchievementInfo(achievement_info);
editor.LoadAsset(&achievement);

// paste an invalid trigger definition so that runtime structure has a null pointer
ra::services::mocks::MockClipboard mockClipboard;
mockClipboard.SetText(L"I:0xX0004_M:0xX0008");
editor.Trigger().PasteFromClipboard();

Assert::IsTrue(editor.HasAssetValidationError());
Assert::AreEqual(std::wstring(L"Invalid operator"), editor.GetAssetValidationError());

// modify the condition so the serialized trigger changes and the condset gets discarded
editor.Trigger().Conditions().GetItemAt(0)->SetSourceValue(0x000045);

// make sure the condset gets rebuilt by the tooltip code
const auto* pCondition = editor.Trigger().Conditions().GetItemAt(1);
Assert::AreEqual(std::wstring(L"0x0008 (indirect $0x0045+0x08)\r\n[No memory note]"),
pCondition->GetTooltip(TriggerConditionViewModel::SourceValueProperty));
}
};

} // namespace tests
Expand Down
Loading