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
36 changes: 34 additions & 2 deletions Source/Data/CodeNote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,14 @@ private void SetNote(string note)

if (Summary.IndexOfAny(new[] { '=', ':' }) != -1)
ExtractValuesFromSummary();

// if we found a size, stop looking for a size/pointer
if (Size != FieldSize.None)
break;
}

if (line.Length >= 4) // nBit is smallest parsable note
if (line.Length >= 4 && // nBit is smallest parsable note
Size == FieldSize.None)
{
var lower = line.ToString().ToLower();
if (!lower.Contains("pointer"))
Expand All @@ -108,7 +113,7 @@ private void SetNote(string note)
}

// if we found a size, stop looking for a size/pointer
if (Size != FieldSize.None)
if (Size != FieldSize.None && !String.IsNullOrEmpty(Summary))
break;
}
} while (tokenizer.NextChar != '\0');
Expand Down Expand Up @@ -659,6 +664,12 @@ private static bool IsValue(Token token)

private void CheckValue(Token clause)
{
int prefixIndex = 0;
while (prefixIndex < clause.Length && !Char.IsLetterOrDigit(clause[prefixIndex]) && clause[prefixIndex] != '[')
prefixIndex++;
if (prefixIndex > 0)
clause = clause.SubToken(prefixIndex);

var separatorLength = 1;
var separator = clause.IndexOf('=');

Expand All @@ -673,6 +684,27 @@ private void CheckValue(Token clause)
separatorLength = 2;
}

if (separator == -1)
{
// only match dash if no other separators were found. it could be definine a range
var dash = clause.IndexOf(" - ");
if (dash != -1)
{
separator = dash;
separatorLength = 3;
}
}

if (separator == -1 && clause.Length > 4 && clause[0] == '[')
{
var endMeta = clause.IndexOf(']');
if (endMeta != -1)
{
clause = clause.SubToken(1);
separator = endMeta - 1;
}
}

if (separator != -1)
{
var left = clause.SubToken(0, separator).Trim();
Expand Down
5 changes: 5 additions & 0 deletions Source/Parser/AchievementScriptInterpreter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ internal static InterpreterScope GetGlobalScope()
}
private static InterpreterScope _globalScope;

public static bool IsReservedFunctionName(string functionName)
{
return (GetGlobalScope().GetFunction(functionName) != null);
}

/// <summary>
/// Gets the error message generated by the script if processing failed.
/// </summary>
Expand Down
3 changes: 3 additions & 0 deletions Source/Parser/PublishedAssets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public PublishedAssets(string filename, IFileSystemService fileSystemService)

public int GameId { get; private set; }

public int ConsoleId { get; private set; }

/// <summary>
/// Gets the title of the associated game.
/// </summary>
Expand Down Expand Up @@ -96,6 +98,7 @@ private void Read()

var publishedData = new JsonObject(stream);
Title = publishedData.GetField("Title").StringValue;
ConsoleId = publishedData.GetField("ConsoleID").IntegerValue ?? 0;

var sets = publishedData.GetField("Sets");
if (sets.Type == JsonFieldType.ObjectArray)
Expand Down
26 changes: 23 additions & 3 deletions Source/Parser/ScriptBuilderContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public ScriptBuilderContext()
NumberFormat = NumberFormat.Decimal;
WrapWidth = Int32.MaxValue;
Indent = 0;
_aliases = new Dictionary<string, string>();
_aliases = new List<KeyValuePair<string, string>>();
}

public NumberFormat NumberFormat { get; set; }
Expand Down Expand Up @@ -47,11 +47,31 @@ public ScriptBuilderContext Clone()
private Requirement _lastAndNext;
private int _remainingWidth;

private Dictionary<string, string> _aliases;
private List<KeyValuePair<string, string>> _aliases;

public void AddAlias(string memoryReference, string alias)
{
_aliases[memoryReference] = alias;
for (int i = 0; i < _aliases.Count; i++)
{
if (_aliases[i].Key == memoryReference)
{
_aliases[i] = new KeyValuePair<string, string>(memoryReference, alias);
return;
}
}

_aliases.Add(new KeyValuePair<string, string>(memoryReference, alias));
}

public string GetAliasDefinition(string alias)
{
foreach (var kvp in _aliases)
{
if (kvp.Value == alias)
return kvp.Key;
}

return null;
}

public override string ToString()
Expand Down
2 changes: 2 additions & 0 deletions Source/ViewModels/GameViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ private class NavigationItem
private bool _disableNavigationCapture = false;

internal int GameId { get; private set; }
internal int ConsoleId { get; private set; }
internal string RACacheDirectory { get; private set; }
internal Dictionary<uint, CodeNote> Notes { get; private set; }
internal SerializationContext SerializationContext { get; set; }
Expand Down Expand Up @@ -666,6 +667,7 @@ private void ReadPublished()
_publishedSets.AddRange(publishedAssets.Sets);
_publishedRichPresence = publishedAssets.RichPresence;
Title = publishedAssets.Title;
ConsoleId = publishedAssets.ConsoleId;

_logger.WriteVerbose(String.Format("Identified {0} core achievements ({1} points)", coreCount, corePoints));
_logger.WriteVerbose(String.Format("Identified {0} unofficial achievements ({1} points)", unofficialCount, unofficialPoints));
Expand Down
Loading
Loading