Skip to content

Commit

Permalink
Fix GetReferencesOfObject for Bytecode version 15
Browse files Browse the repository at this point in the history
Move check for language to only be done on bytecode version 16 and up.
See https://github.com/UnderminersTeam/UndertaleModTool/wiki/Bytecode-version-differences.
Fixes UnderminersTeam#1946.
  • Loading branch information
zivmaor committed Oct 8, 2024
1 parent caf0412 commit 60515b1
Showing 1 changed file with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -560,15 +560,6 @@ IEnumerable<object[]> GetExtnFunctions()
outDict["Game options constants"] = new object[] { new GeneralInfoEditor(data.GeneralInfo, data.Options, data.Language) };
}
if (types.Contains(typeof(UndertaleLanguage)))
{
bool langsMatches = data.Language.EntryIDs.Contains(obj)
|| data.Language.Languages.Any(x => x.Name == obj || x.Region == obj
|| x.Entries.Contains(obj));
if (langsMatches)
outDict["Languages"] = new object[] { new GeneralInfoEditor(data.GeneralInfo, data.Options, data.Language) };
}
if (types.Contains(typeof(UndertalePath)))
{
var paths = data.Paths.Where(x => x.Name == obj);
Expand Down Expand Up @@ -632,6 +623,28 @@ IEnumerable<object[]> GetExtnFunctions()
}
},
new PredicateForVersion()
{
// Bytecode version 16
Version = (16, uint.MaxValue, uint.MaxValue),
Predicate = (objSrc, types, checkOne) =>
{
if (!types.Contains(typeof(UndertaleLanguage)))
return null;
if (objSrc is not UndertaleString obj)
return null;
bool langsMatches = data.Language.EntryIDs.Contains(obj)
|| data.Language.Languages.Any(x => x.Name == obj || x.Region == obj
|| x.Entries.Contains(obj));
if (langsMatches)
return new() { { "Languages", new object[] { new GeneralInfoEditor(data.GeneralInfo, data.Options, data.Language) } } };
else
return null;
}
},
new PredicateForVersion()
{
Version = (2, 0, 0),
Predicate = (objSrc, types, checkOne) =>
Expand Down

0 comments on commit 60515b1

Please sign in to comment.