From: Samual Date: Fri, 30 Dec 2011 04:31:46 +0000 (-0500) Subject: Attempt to fix GetIndexedEntity X-Git-Tag: xonotic-v0.6.0~188^2~28^2~22 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=62ec3e65bfa817ac919da6b2b07e610dfdf1694a;p=xonotic%2Fxonotic-data.pk3dir.git Attempt to fix GetIndexedEntity --- diff --git a/qcsrc/server/command/common.qc b/qcsrc/server/command/common.qc index e117e5e09..17703c7fc 100644 --- a/qcsrc/server/command/common.qc +++ b/qcsrc/server/command/common.qc @@ -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; }