home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2006 April / Gamestar_83_2006-04_dvd.iso / Dema / demowot_english.exe / Script / Source / IterateInOrder.sma < prev    next >
Text File  |  2005-03-11  |  961b  |  52 lines

  1. #include "script.inc"
  2. #define ARRAY_MAXLENGTH        50
  3.  
  4.  
  5.  
  6. stock ItFillArray( Selector[], DrID:Array[], MaxLength )
  7. {
  8.     static StringArray[ARRAY_MAXLENGTH][STRID_MAX_LENGTH];
  9.  
  10.     new DrID:Entity;
  11.     new Length = 0;
  12.     
  13.     new Iterator:i = Iterate( Selector );
  14.     while( ItNext(i))
  15.         PutInArrayOrdered( ItEntity(i), Array, &Length );
  16.     ItStop(i);
  17. }
  18.  
  19.  
  20.  
  21. stock PutInArrayOrdered( DrID:Entity, DrID:Array, &Length ) // Binaris kereses, majd beszuras
  22. {
  23.     new LowerLimit = 0;
  24.     new UpperLimit = Length;
  25.     new i;
  26.     
  27.     new CurrentName[STRID_MAX_LENGTH];
  28.     GetPropertyString( Entity, "StringID", STRID_MAX_LENGTH, CurrentName );
  29.     
  30.     do {
  31.         i = ( UpperLimit + LowerLimit ) / 2;
  32.         if( CompareString( CurrentName, StringArray[i] ) >= 0 ) {
  33.             LowerLimit = i;
  34.         } else {
  35.             UpperLimit = i;
  36.         }
  37.     } while( ( abs( i - LowerLimit ) > 1 ) && ( abs( i - UpperLimit ) > 1 ) ); // Ha mar elertuk a hatart, abbahagyjuk
  38.  
  39.     Array[i] = 
  40.     
  41.     
  42.  
  43.     Length++;
  44. }
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.