]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Attempt to fix GetIndexedEntity
authorSamual <samual@xonotic.org>
Fri, 30 Dec 2011 04:31:46 +0000 (23:31 -0500)
committerSamual <samual@xonotic.org>
Fri, 30 Dec 2011 04:31:46 +0000 (23:31 -0500)
qcsrc/server/command/common.qc

index e117e5e09eb8319960ab1a90b8ec9e19249a61ea..17703c7fc0ee1341733b23d3a5bf4ad288c8b738 100644 (file)
@@ -58,32 +58,33 @@ float VerifyClientNumber(float tmp_number)
 entity GetIndexedEntity(float argc, float start_index)
 {
        entity tmp_player, selection;
-       float tmp_number;
+       float tmp_number, index;
        string tmp_string;
        
        next_token = -1;
+       index = start_index;
        
        if(argc > start_index)
        {
-               if(substring(argv(start_index), 0, 1) == "#")
+               if(substring(argv(index), 0, 1) == "#")
                {
-                       tmp_string = substring(argv(start_index), 1, -1);
-                       ++next_token;
+                       tmp_string = substring(argv(index), 1, -1);
+                       ++index;
                        
                        if(tmp_string) // is it all one token? like #1
                        {
                                tmp_number = stof(tmp_string);
                        }
-                       else if(argc > next_token) // no, it's two tokens? # 1
+                       else if(argc > index) // no, it's two tokens? # 1
                        {
-                               tmp_number = stof(argv(next_token));
-                               ++next_token;
+                               tmp_number = stof(argv(index));
+                               ++index;
                        }
                }
                else // maybe it's ONLY a number?
                {
-                       tmp_number = stof(argv(start_index));
-                       ++next_token;
+                       tmp_number = stof(argv(index));
+                       ++index;
                }
                
                if(VerifyClientNumber(tmp_number))
@@ -91,15 +92,16 @@ entity GetIndexedEntity(float argc, float start_index)
                        selection = edict_num(tmp_number); // yes, it was a number
                }
                else // no, maybe it's a name?
-               {
-                       next_token = (start_index + 1);
-                       
+               {                       
                        FOR_EACH_CLIENT(tmp_player)
                                if (strdecolorize(tmp_player.netname) == strdecolorize(argv(start_index)))
                                        selection = tmp_player;
+                                       
+                       index = (start_index + 1);
                }
        }
        
+       next_token = index;
        return selection;
 }