File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -330,7 +330,17 @@ void TriggerViewModel::PasteFromClipboard()
330330 return ;
331331 }
332332
333- const auto nResult = AppendMemRefChain (ra::util::String::Narrow (sClipboardText ));
333+ std::string sNarrowText = ra::util::String::Narrow (sClipboardText );
334+ if (IsValue () && Conditions ().Count () == 0 && sNarrowText .find (' :' ) == std::string::npos)
335+ {
336+ // if pasting something that looks like a legacy-formatted value into the value editor,
337+ // and the value editor is empty, explicitly add a "M:" so it doesn't get parse as a
338+ // legacy value. this prevents pushing a legacy value with a comparison to the server,
339+ // which can prevent the leaderboard from functioning in rcheevos 12.0 and 12.1.
340+ sNarrowText .insert (0 , " M:" );
341+ }
342+
343+ const auto nResult = AppendMemRefChain (sNarrowText );
334344 if (nResult != RC_OK )
335345 {
336346 if (nResult == RC_MULTIPLE_GROUPS )
Original file line number Diff line number Diff line change @@ -574,6 +574,23 @@ TEST_CLASS(TriggerViewModel_Tests)
574574 Assert::IsTrue (bDialogShown);
575575 }
576576
577+ TEST_METHOD (TestPasteFromClipboardValueWithComparison)
578+ {
579+ TriggerViewModelHarness vmTrigger;
580+ Parse (vmTrigger, " " );
581+ vmTrigger.SetIsValue (true );
582+
583+ vmTrigger.mockClipboard .SetText (L" 0xH1234<100" );
584+ vmTrigger.PasteFromClipboard ();
585+
586+ // the parser will see "0xH1234<100" as a legacy value and truncate it to "0xH1234" for display.
587+ // but the serialized value will still have the "<100" as it was part of the pasted text.
588+ // expect the paste operation to convert it to a non-legacy value
589+
590+ Assert::AreEqual ({ 1U }, vmTrigger.Conditions ().Count ());
591+ Assert::AreEqual (std::string (" M:0xH1234<100" ), vmTrigger.Serialize ());
592+ }
593+
577594 TEST_METHOD (TestPasteFromClipboardInvalidSyntax)
578595 {
579596 TriggerViewModelHarness vmTrigger;
You can’t perform that action at this time.
0 commit comments