From 62ec3e65bfa817ac919da6b2b07e610dfdf1694a Mon Sep 17 00:00:00 2001 From: Samual Date: Thu, 29 Dec 2011 23:31:46 -0500 Subject: [PATCH] Attempt to fix GetIndexedEntity --- qcsrc/server/command/common.qc | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) 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; } -- 2.39.2