From 551369a228f3bb0e065ee1b277bc68bd3f69a36d Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Fri, 21 Jun 2024 20:34:14 +0800 Subject: [PATCH] [server] Match `amx_FindNative(...)` --- server/amx/amx.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/server/amx/amx.c b/server/amx/amx.c index e0b3cf0..c1c09a8 100644 --- a/server/amx/amx.c +++ b/server/amx/amx.c @@ -1265,27 +1265,18 @@ int AMXAPI amx_GetNative(AMX *amx, int index, char *funcname) int AMXAPI amx_FindNative(AMX *amx, const char *name, int *index) { - int first,last,mid,result; + int idx,last; char pname[sNAMEMAX+1]; amx_NumNatives(amx, &last); - last--; /* last valid index is 1 less than the number of functions */ - first=0; - /* binary search */ - while (first<=last) { - mid=(first+last)/2; - amx_GetNative(amx, mid, pname); - result=strcmp(pname,name); - if (result>0) { - last=mid-1; - } else if (result<0) { - first=mid+1; - } else { - *index=mid; + /* linear search, the natives table is not sorted alphabetically */ + for (idx=0; idx