fCraft.CommandReader.Next C# (CSharp) Method

Next() private method

private Next ( ) : string
return string
        public string Next() {
            for( ; Offset < RawMessage.Length; Offset++ ) {
                int t, j;
                if( RawMessage[Offset] == '"' ) {
                    j = Offset + 1;
                    for( ; j < RawMessage.Length && RawMessage[j] != '"'; j++ ) {}
                    t = Offset;
                    Offset = j;
                    return RawMessage.Substring( t + 1, Offset - t - 1 );
                } else if( RawMessage[Offset] != ' ' ) {
                    j = Offset;
                    for( ; j < RawMessage.Length && RawMessage[j] != ' '; j++ ) {}
                    t = Offset;
                    Offset = j;
                    return RawMessage.Substring( t, Offset - t );
                }
            }
            return null;
        }

Usage Example

		public static void SetParamIteration(Player p, CommandReader cmd)
		{
			string strParam = cmd.Next();
			if (string.IsNullOrWhiteSpace(strParam))
			{
				p.Message("Error: missing param variable name");
				return;
			}

			strParam = strParam.ToLower();

			try
			{
				CheckParamVar(strParam);

				double from = ReadDoubleParam(cmd, "lower bound");
				double to = ReadDoubleParam(cmd, "upper bound");
				double step = ReadDoubleParam(cmd, "step");

				if (step == 0 ||
				    (to - from)/step < 0)
					throw new ArgumentException("wrong iteration bounds/step combination");

				p.Message("Iteration for " + strParam + " from " + from + " to " + to + " with step " + step + ". " +
				          ((to - from)/step + 1) + " steps.");

				GetPlayerParametrizationParamsStorage(p)[VarNameToIdx(strParam[0])] = new double[] {from, to, step};
			}
			catch (Exception e)
			{
				p.Message("Error: " + e.Message);
			}
		}
All Usage Examples Of fCraft.CommandReader::Next