]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Separate GetFilteredNumber and GetFilteredEntity
authorSamual <samual@xonotic.org>
Sat, 17 Dec 2011 20:21:12 +0000 (15:21 -0500)
committerSamual <samual@xonotic.org>
Sat, 17 Dec 2011 20:21:12 +0000 (15:21 -0500)
qcsrc/server/command/common.qc
qcsrc/server/command/vote.qc

index 05302c8a15cb2924c5211cfac9d6dbd7bccdd2a8..679e49888848fc963f1c4906267ee11784a536a8 100644 (file)
@@ -19,29 +19,39 @@ string GetCallerName(entity caller)
                return ((autocvar_sv_adminnick != "") ? autocvar_sv_adminnick : autocvar_hostname);
 }
 
-// find a player which matches the input string, and return their entity number
-float GetFilteredNumber(string input)
+entity GetFilteredEntity(string input)
 {
        entity tmp_player, selection;
-       float output, matches;
+       float tmp_number;
        
-       // check and see if we can get a number from input like "#3" or "3" 
        if(substring(input, 0, 1) == "#")
-               output = stof(substring(input, 1, -1));
+               tmp_number = stof(substring(input, 1, -1));
+       else
+               tmp_number = stof(input);
+       
+       if(tmp_number)
+       {
+               selection = edict_num(tmp_number);
+       }
        else
-               output = stof(input);
-               
-       // if we can't, check and see if we can match the input to the netname of any player in the game
-       if not(output) 
        {
                FOR_EACH_CLIENT(tmp_player)
                        if (strdecolorize(tmp_player.netname) == strdecolorize(input))
                                selection = tmp_player;
-
-               if (selection) { output = num_for_edict(selection); }
        }
-               
-       print(strcat("input: ", input, ", output: ", ftos(output), ",\n"));
+       
+       return selection;
+}
+
+// find a player which matches the input string, and return their entity number
+float GetFilteredNumber(string input)
+{
+       entity selection = GetFilteredEntity(input);
+       float output;
+       
+       if(selection) { output = num_for_edict(selection); }
+
+       print(strcat("input: ", input, ", output: ", ftos(output), ",\n")); // todo remove after done debugging
        return output;
 }
 
index 2a5676a028ab94c063ca3fca7e87c7225b21e40d..66fd049f08fca1ad7e8dbbc700cd47e9e3632dc5 100644 (file)
@@ -448,7 +448,6 @@ string VoteCommand_extractcommand(string input, float startpos, float argc)
        else
                output = substring(input, argv_start_index(startpos), argv_end_index(-1) - argv_start_index(startpos));
                
-       print("VoteCommand_parse: '", output, "'. \n");
        return output;
 }