mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 18:15:28 -04:00
Simplify argument counting in CommandReader, fix help command duplicating 'unrecognised command' message.
This commit is contained in:
parent
138420c538
commit
b3e87d8fb1
@ -61,7 +61,7 @@ namespace ClassicalSharp.Commands {
|
||||
|
||||
public bool NextOf<T>( out T value, TryParseFunc<T> parser ) {
|
||||
bool success = parser( Next(), out value );
|
||||
if( !success ) value = default( T);
|
||||
if( !success ) value = default( T );
|
||||
return success;
|
||||
}
|
||||
|
||||
@ -76,29 +76,23 @@ namespace ClassicalSharp.Commands {
|
||||
}
|
||||
|
||||
public int RemainingArgs {
|
||||
get {
|
||||
int count = 0;
|
||||
int pos = curOffset;
|
||||
while( MoveNext() ) {
|
||||
count++;
|
||||
}
|
||||
curOffset = pos;
|
||||
return count;
|
||||
}
|
||||
get { return CountArgsFrom( curOffset ); }
|
||||
}
|
||||
|
||||
public int TotalArgs {
|
||||
get {
|
||||
get { return CountArgsFrom( firstArgOffset ); }
|
||||
}
|
||||
|
||||
int CountArgsFrom( int startOffset ) {
|
||||
int count = 0;
|
||||
int pos = curOffset;
|
||||
curOffset = firstArgOffset;
|
||||
curOffset = startOffset;
|
||||
while( MoveNext() ) {
|
||||
count++;
|
||||
}
|
||||
curOffset = pos;
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset() {
|
||||
curOffset = firstArgOffset;
|
||||
|
@ -125,9 +125,7 @@ namespace ClassicalSharp.Commands {
|
||||
Window.AddChat( "&e/client: &cYou didn't specify a command to get help with." );
|
||||
} else {
|
||||
Command cmd = Window.CommandManager.GetMatchingCommand( commandName );
|
||||
if( cmd == null ) {
|
||||
Window.AddChat( "&e/client: Unrecognised command: \"&f" + commandName + "&e\"." );
|
||||
} else {
|
||||
if( cmd != null ) {
|
||||
string[] help = cmd.Help;
|
||||
for( int i = 0; i < help.Length; i++ ) {
|
||||
Window.AddChat( help[i] );
|
||||
|
Loading…
x
Reference in New Issue
Block a user