Raised This Month: $ Target: $400
 0% 

dupes in read_dir


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jtp10181
Veteran Member
Join Date: May 2004
Location: Madison, WI
Old 06-15-2004 , 18:02   dupes in read_dir
Reply With Quote #1

Code:
    while(read_dir("maps",numword,data,63,temp)) {         if((contain(data,".bsp") != -1) && (containi(data,".ztmp") == -1)) {             if(totalmaps >= MAX_MAPS){                 server_print("[AMXX] MAX_MAPS has been exceeded, not all maps are able to load for searching")                 return PLUGIN_HANDLED             }             copy(T_LMaps[totalmaps],31, data)             replace(T_LMaps[totalmaps],31,".bsp","")             totalmaps++         }         numword++     }

this is producing dupes in the array, usually like 10 of each map. One time I noticed the first map was duped 4 times and then after that the rest were 8 times. Really strange. I ONLY is doing this on linux systems as far as I know, have not seen it occur in windows.

Also does anyone have some code I could borrow/look at for sorting an array?
__________________
jtp10181 is offline
Send a message via ICQ to jtp10181 Send a message via AIM to jtp10181 Send a message via MSN to jtp10181 Send a message via Yahoo to jtp10181
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 06-16-2004 , 14:01  
Reply With Quote #2

hmm well: read_dir has a completly different implementation on GCC (thats our standard linux compiler) and on MSVC (our standard windows compiler). Ill check it.

Sorting an array: The probably simpliest (and slowest ;) ) way is bubble sort. The theory is something like this:
Code:
for (i=0;i<max;++i)
{
   for(j=0;j<max;++j)
   {
      if ([ element j+1 < j ])
      {
         [ swap j and j+1 ]
      }
   }
}
I think
__________________
hello, i am pm
PM is offline
jtp10181
Veteran Member
Join Date: May 2004
Location: Madison, WI
Old 06-16-2004 , 14:06  
Reply With Quote #3

yeah i got the sorting worked out

http://forums.alliedmods.net/showthread.php?t=2756

as foir the dupes I added a little check to see if the last thing loaded is the same as the current and to just skip it. should fix the problem for now I hope.
__________________
jtp10181 is offline
Send a message via ICQ to jtp10181 Send a message via AIM to jtp10181 Send a message via MSN to jtp10181 Send a message via Yahoo to jtp10181
jtp10181
Veteran Member
Join Date: May 2004
Location: Madison, WI
Old 06-16-2004 , 14:32  
Reply With Quote #4

I just tried my little thing to look back and skip if its a dupe on a server with 375 maps and it hung for like a full minute when the server started.... i think the number of dupes that it pulls in just keeps growing and growing on linux, it works fine in windows still BTW
__________________
jtp10181 is offline
Send a message via ICQ to jtp10181 Send a message via AIM to jtp10181 Send a message via MSN to jtp10181 Send a message via Yahoo to jtp10181
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 10-17-2004 , 11:07   Re: dupes in read_dir
Reply With Quote #5

Try this:

Code:
       while(numword = read_dir("maps",numword,data,63,temp)) {         if((contain(data,".bsp") != -1) && (containi(data,".ztmp") == -1)) {             if(totalmaps >= MAX_MAPS){                 server_print("[AMXX] MAX_MAPS has been exceeded, not all maps are able to load for searching")                 return PLUGIN_HANDLED             }             copy(T_LMaps[totalmaps],31, data)             replace(T_LMaps[totalmaps],31,".bsp","")             totalmaps++         }     }
You get the idea; let read_dir return the number identifying the next entry instead of incrementing on your own.
__________________
hello, i am pm
PM is offline
jtp10181
Veteran Member
Join Date: May 2004
Location: Madison, WI
Old 10-17-2004 , 11:20  
Reply With Quote #6

omfg I'm dumb.... that works. I think I wrote that code when I was a nub and never noticed how dumb that was
__________________
jtp10181 is offline
Send a message via ICQ to jtp10181 Send a message via AIM to jtp10181 Send a message via MSN to jtp10181 Send a message via Yahoo to jtp10181
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 10-17-2004 , 11:22  
Reply With Quote #7

Quote:
Originally Posted by jtp10181
omfg I'm dumb.... that works. I think I wrote that code when I was a nub and never noticed how dumb that was
Heh I haven't noticed it in your code either.. I'm blind ;)
__________________
hello, i am pm
PM is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 14:50.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode