[CF-Devel] Suspicious code in common/object.c
   
   
   crossfire-devel at archives.real-time.com
   
   
   crossfire-devel at archives.real-time.com
       
   
   
   
   Sun May 16 23:15:20 CDT 2004
   
   
   
    
    
  
    
    Andreas Kirschbaum wrote:
>
     
      I think the function get_search_arr() in common/object.c does not work
     
     >
     
      correctly: it should return a permutation of [0..48] but the result
     
     >
     
      nearly always contains more than one 0 value.
     
     >
     
     
     >
     
      For example: If the statement "tmp=(RANDOM()%(5-i+1))+1" at the end of
     
     >
     
      the function (for the range i=1..4) always evaluates to "tmp=1", the
     
     >
     
      result is search_nums[1..4]={1,2,3,0}. This is not correct because it
     
     >
     
      should be a permutation of {1,2,3,4}.
     
     >
     
     
     >
     
     
     >
     
      To fix this issue, I would like to replace the function with:
     
     
  That looks fine.  Note that the efficiency/correctness of get_search_arr isn't 
really critical - it is basically so that the monsters don't always favor the 
same directions.
  However, I agree your function is much clearer, and should replace what is 
there now.
_______________________________________________
crossfire-devel mailing list
     
     crossfire-devel at lists.real-time.com
     
     
     https://mailman.real-time.com/mailman/listinfo/crossfire-devel
     
     
    
    
    
    
   
   
    
    
    More information about the crossfire
mailing list