Skip to content
Open
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
6 changes: 3 additions & 3 deletions src/SampSharp.GameMode/SAMP/Commands/CommandsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ private static IEnumerable<string> GetCommandGroupPaths(MethodInfo method)
public ICommand GetCommandForText(BasePlayer player, string commandText)
{
ICommand candidate = null;
var isFullMath = false;
var isFullMatch = false;
var candidateLength = 0;

foreach (var command in _commands)
Expand All @@ -227,9 +227,9 @@ public ICommand GetCommandForText(BasePlayer player, string commandText)
{
case CommandCallableResponse.True:

if (candidateLength < matchedNameLength || candidateLength == matchedNameLength && !isFullMath)
if (candidateLength < matchedNameLength || candidateLength == matchedNameLength && !isFullMatch)
{
isFullMath = true;
isFullMatch = true;
candidateLength = matchedNameLength;
candidate = command;
}
Expand Down
2 changes: 1 addition & 1 deletion src/SampSharp.GameMode/SAMP/Commands/DefaultCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public virtual CommandCallableResponse CanInvoke(BasePlayer player, string comma
if (!name.Matches(commandText, IsCaseIgnored)) continue;

matchedNameLength = name.Length;
commandText = commandText.Substring(name.Length);
commandText = commandText.Substring(name.Length).Trim();
var result = GetArguments(commandText, out _, out var argumentsLength);
matchedNameLength += argumentsLength;
return result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ public EnumType()
/// </returns>
public bool Parse(ref string commandText, out object output, bool isNullable)
{
var text = commandText.TrimStart();
commandText = commandText.TrimStart();
output = null;

if (string.IsNullOrEmpty(text))
if (string.IsNullOrEmpty(commandText))
return false;

var word = text.Split(' ').First();
var word = commandText.Split(' ').First();
var lowerWord = word.ToLower();

// find all candiates containing the input word, case insensitive.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ public class FloatType : ICommandParameterType
/// </returns>
public bool Parse(ref string commandText, out object output, bool isNullable)
{
var text = commandText.TrimStart();
commandText = commandText.TrimStart();
output = null;

if (string.IsNullOrEmpty(text))
if (string.IsNullOrEmpty(commandText))
return false;

var word = text.Split(' ').First();
var word = commandText.Split(' ').First();

// Unify input culture.
var preProcessedWord = word;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ public class IntegerType : ICommandParameterType
/// </returns>
public bool Parse(ref string commandText, out object output, bool isNullable)
{
var text = commandText.TrimStart();
commandText = commandText.TrimStart();
output = null;

if (string.IsNullOrEmpty(text))
if (string.IsNullOrEmpty(commandText))
return false;


var word = text.Split(' ').First();
var word = commandText.Split(' ').First();


// Regular base 10 numbers (eg. 14143)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ public NullableEnumType()
/// </returns>
public bool Parse(ref string commandText, out object output, bool isNullable)
{
var text = commandText.TrimStart();
commandText = commandText.TrimStart();
output = null;

if (string.IsNullOrEmpty(text))
if (string.IsNullOrEmpty(commandText))
return false;

var word = text.Split(' ').First();
var word = commandText.Split(' ').First();
var lowerWord = word.ToLower();

// find all candiates containing the input word, case insensitive.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ public class PlayerType : ICommandParameterType
/// </returns>
public bool Parse(ref string commandText, out object output, bool isNullable)
{
var text = commandText.TrimStart();
commandText = commandText.TrimStart();
output = null;

if (string.IsNullOrEmpty(text))
if (string.IsNullOrEmpty(commandText))
return false;

var word = text.Split(' ').First();
var word = commandText.Split(' ').First();

// find a player with a matching id.
if (int.TryParse(word, NumberStyles.Integer, CultureInfo.InvariantCulture, out var id))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ public class TextType : ICommandParameterType
/// </returns>
public bool Parse(ref string commandText, out object output, bool isNullable)
{
var text = commandText.Trim();
commandText = commandText.Trim();

if (string.IsNullOrEmpty(text))
if (string.IsNullOrEmpty(commandText))
{
output = null;
return false;
}

output = text;
output = commandText;
commandText = string.Empty;
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ public class VehicleType : ICommandParameterType
/// </returns>
public bool Parse(ref string commandText, out object output, bool isNullable)
{
var text = commandText.TrimStart();
commandText = commandText.TrimStart();
output = null;

if (string.IsNullOrEmpty(text))
if (string.IsNullOrEmpty(commandText))
return false;

var word = text.Split(' ').First();
var word = commandText.Split(' ').First();

// find a vehicle with a matching id.
if (!int.TryParse(word, NumberStyles.Integer, CultureInfo.InvariantCulture, out var id))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ public class WordType : ICommandParameterType
/// </returns>
public bool Parse(ref string commandText, out object output, bool isNullable)
{
var text = commandText.TrimStart();
commandText = commandText.TrimStart();

if (string.IsNullOrEmpty(text))
if (string.IsNullOrEmpty(commandText))
{
output = null;
return false;
}

var word = text.Split(' ').First();
var word = commandText.Split(' ').First();

commandText = commandText.Substring(word.Length).TrimStart(' ');

Expand Down