‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
array_shared.gsc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #using scripts\shared\array_shared;
4 #using scripts\shared\flag_shared;
5 #using scripts\shared\flagsys_shared;
6 #using scripts\shared\util_shared;
7 
8 #insert scripts\shared\shared.gsh;
9 
10 #namespace array;
11 
15 function filter( &‪array, b_keep_keys, func_filter, arg1, arg2, arg3, arg4, arg5 )
16 {
17  ‪a_new = [];
18 
19  foreach ( key, val in ‪array )
20  {
21  if ( ‪util::single_func( self, func_filter, val, arg1, arg2, arg3, arg4, arg5 ) )
22  {
23  if ( IsString( key ) || IsWeapon( key ) )
24  {
25  // by default, string and weapon object keys are kept
26  if ( isdefined( b_keep_keys ) && !b_keep_keys )
27  {
28  ‪a_new[ ‪a_new.size ] = val;
29  }
30  else
31  {
32  ‪a_new[ key ] = val;
33  }
34  }
35  else
36  {
37  // by default, int keys are not kept
38  if ( ‪IS_TRUE( b_keep_keys ) )
39  {
40  ‪a_new[ key ] = val;
41  }
42  else
43  {
44  ‪a_new[ ‪a_new.size ] = val;
45  }
46  }
47  }
48  }
49 
50  return ‪a_new;
51 }
52 
56 function remove_dead( &‪array, b_keep_keys )
57 {
58  return filter( ‪array, b_keep_keys, &_filter_dead );
59 }
60 
61 function ‪_filter_undefined( val )
62 {
63  return isdefined( val );
64 }
65 
69 function ‪remove_undefined( &‪array, b_keep_keys )
70 {
71  return filter( ‪array, b_keep_keys, &‪_filter_undefined );
72 }
73 
74 // This function crashes if called but seems like it should work and would be useful
75 function ‪cleanup( &‪array, b_keep_empty_arrays = false )
76 {
77  a_keys = GetArrayKeys( ‪array );
78 
79  for ( i = a_keys.size - 1; i >= 0; i-- )
80  {
81  key = a_keys[ i ];
82 
83  if ( IsArray( ‪array[ key ] ) && ‪array[ key ].size )
84  {
85  ‪cleanup( ‪array[ key ], b_keep_empty_arrays );
86  }
87  else if ( !isdefined( ‪array[ key ] )
88  || ( !b_keep_empty_arrays && IsArray( ‪array[ key ] ) && !‪array[ key ].size ) )
89  {
90  ArrayRemoveIndex( ‪array, key );
91  }
92  }
93 }
94 
98 function filter_classname( &‪array, b_keep_keys, str_classname )
99 {
100  return filter( ‪array, b_keep_keys, &_filter_classname, str_classname );
101 }
102 
103 function get_touching( &‪array, b_keep_keys )
104 {
105  return filter( ‪array, b_keep_keys, &IsTouching );
106 }
107 
119 function ‪remove_index( ‪array, index, b_keep_keys )
120 {
121  ‪a_new = [];
122 
123  foreach ( key, val in ‪array )
124  {
125  if( key == index )
126  {
127  continue;
128  }
129  else
130  {
131  if ( ‪IS_TRUE( b_keep_keys ) )
132  {
133  ‪a_new[ key ] = val;
134  }
135  else
136  {
137  ‪a_new[ ‪a_new.size ] = val;
138  }
139  }
140  }
141 
142  return ‪a_new;
143 }
144 
154 function delete_all( &‪array, is_struct )
155 {
156  foreach ( ent in ‪array )
157  {
158  if ( isdefined( ent ) )
159  {
160  if ( ‪IS_TRUE( is_struct ) )
161  {
162  ent ‪struct::delete();
163  }
164  else if ( isdefined( ent.__vtable ) )
165  {
166  ‪DELETE( ent ); // class
167  }
168  else
169  {
170  ent Delete();
171  }
172  }
173  }
174 }
175 
186 function notify_all( &‪array, str_notify )
187 {
188  foreach ( elem in ‪array )
189  {
190  elem notify( str_notify );
191  }
192 }
193 
211 function thread_all( &entities, func, arg1, arg2, arg3, arg4, arg5, arg6 )
212 {
213  Assert( isdefined( entities ), "Undefined entity array passed to array::thread_all" );
214  Assert( isdefined( func ), "Undefined function passed to array::thread_all" );
215 
216  if ( IsArray( entities ) )
217  {
218  if ( isdefined( arg6 ) )
219  {
220  foreach ( ent in entities )
221  {
222  ent thread [[ func ]]( arg1, arg2, arg3, arg4, arg5, arg6 );
223  }
224  }
225  else if ( isdefined( arg5 ) )
226  {
227  foreach ( ent in entities )
228  {
229  ent thread [[ func ]]( arg1, arg2, arg3, arg4, arg5 );
230  }
231  }
232  else if ( isdefined( arg4 ) )
233  {
234  foreach ( ent in entities )
235  {
236  ent thread [[ func ]]( arg1, arg2, arg3, arg4 );
237  }
238  }
239  else if ( isdefined( arg3 ) )
240  {
241  foreach ( ent in entities )
242  {
243  ent thread [[ func ]]( arg1, arg2, arg3 );
244  }
245  }
246  else if ( isdefined( arg2 ) )
247  {
248  foreach ( ent in entities )
249  {
250  ent thread [[ func ]]( arg1, arg2 );
251  }
252  }
253  else if ( isdefined( arg1 ) )
254  {
255  foreach ( ent in entities )
256  {
257  ent thread [[ func ]]( arg1 );
258  }
259  }
260  else
261  {
262  foreach ( ent in entities )
263  {
264  ent thread [[ func ]]();
265  }
266  }
267  }
268  else
269  {
270  ‪util::single_thread( entities, func, arg1, arg2, arg3, arg4, arg5, arg6 );
271  }
272 }
273 
290 function thread_all_ents( &entities, func, arg1, arg2, arg3, arg4, arg5 )
291 {
292  Assert( isdefined( entities ), "Undefined entity array passed to util::array_ent_thread" );
293  Assert( isdefined( func ), "Undefined function passed to util::array_ent_thread" );
294 
295  if ( IsArray( entities ) )
296  {
297  if ( entities.size )
298  {
299  keys = GetArrayKeys( entities );
300  for ( i = 0; i < keys.size; i++ )
301  {
302  ‪util::single_thread( self, func, entities[keys[i]], arg1, arg2, arg3, arg4, arg5 );
303  }
304  }
305  }
306  else
307  {
308  ‪util::single_thread( self, func, entities, arg1, arg2, arg3, arg4, arg5 );
309  }
310 }
311 
329 function run_all( &entities, func, arg1, arg2, arg3, arg4, arg5, arg6 )
330 {
331  Assert( isdefined( entities ), "Undefined entity array passed to array::run_all" );
332  Assert( isdefined( func ), "Undefined function passed to array::run_all" );
333 
334  if ( IsArray( entities ) )
335  {
336  if ( isdefined( arg6 ) )
337  {
338  foreach ( ent in entities )
339  {
340  ent [[ func ]]( arg1, arg2, arg3, arg4, arg5, arg6 );
341  }
342  }
343  else if ( isdefined( arg5 ) )
344  {
345  foreach ( ent in entities )
346  {
347  ent [[ func ]]( arg1, arg2, arg3, arg4, arg5 );
348  }
349  }
350  else if ( isdefined( arg4 ) )
351  {
352  foreach ( ent in entities )
353  {
354  ent [[ func ]]( arg1, arg2, arg3, arg4 );
355  }
356  }
357  else if ( isdefined( arg3 ) )
358  {
359  foreach ( ent in entities )
360  {
361  ent [[ func ]]( arg1, arg2, arg3 );
362  }
363  }
364  else if ( isdefined( arg2 ) )
365  {
366  foreach ( ent in entities )
367  {
368  ent [[ func ]]( arg1, arg2 );
369  }
370  }
371  else if ( isdefined( arg1 ) )
372  {
373  foreach ( ent in entities )
374  {
375  ent [[ func ]]( arg1 );
376  }
377  }
378  else
379  {
380  foreach ( ent in entities )
381  {
382  ent [[ func ]]();
383  }
384  }
385  }
386  else
387  {
388  ‪util::single_func( entities, func, arg1, arg2, arg3, arg4, arg5, arg6 );
389  }
390 }
391 
403 function exclude( ‪array, array_exclude )// returns "array" minus all members of array_exclude
404 {
405  newarray = ‪array;
406 
407  if ( IsArray( array_exclude ) )
408  {
409  foreach ( exclude_item in array_exclude )
410  {
411  ArrayRemoveValue( newarray, exclude_item );
412  }
413  }
414  else
415  {
416  ArrayRemoveValue( newarray, array_exclude );
417  }
418 
419  return newarray;
420 }
421 
434 function ‪add( &‪array, item, allow_dupes = true )
435 {
436  if ( isdefined( item ) )
437  {
438  if ( allow_dupes || !IsInArray( ‪array, item ) )
439  {
440  ‪array[ ‪array.size ] = item;
441  }
442  }
443 }
444 
457 function add_sorted( &‪array, item, allow_dupes = true )
458 {
459  if ( isdefined( item ) )
460  {
461  if ( allow_dupes || !IsInArray( ‪array, item ) )
462  {
463  for ( i = 0; i <= ‪array.size; i++ )
464  {
465  if ( ( i == ‪array.size ) || ( item <= ‪array[i] ) )
466  {
467  ArrayInsert( ‪array, item, i );
468  break;
469  }
470  }
471  }
472  }
473 }
474 
486 function ‪wait_till( &‪array, notifies, n_timeout )
487 {
488  ‪TIMEOUT( n_timeout );
489 
490  s_tracker = SpawnStruct();
491  s_tracker._wait_count = 0;
492 
493  foreach ( ent in ‪array )
494  {
495  if ( isdefined( ent ) )
496  {
497  ent thread ‪util::timeout( n_timeout, &‪util::_waitlogic, s_tracker, notifies );
498  }
499  }
500 
501  if ( s_tracker._wait_count > 0 )
502  {
503  s_tracker waittill( "waitlogic_finished" );
504  }
505 }
506 
519 function wait_till_match( &‪array, str_notify, str_match, n_timeout )
520 {
521  ‪TIMEOUT( n_timeout );
522 
523  s_tracker = SpawnStruct();
524  s_tracker._array_wait_count = 0;
525 
526  foreach ( ent in ‪array )
527  {
528  if ( isdefined( ent ) )
529  {
530  s_tracker._array_wait_count++;
531  ent thread ‪util::timeout( n_timeout, &_waitlogic_match, s_tracker, str_notify, str_match );
532  ent thread ‪util::timeout( n_timeout, &_waitlogic_death, s_tracker );
533  }
534  }
535 
536  if ( s_tracker._array_wait_count > 0 )
537  {
538  s_tracker waittill( "array_wait" );
539  }
540 }
541 
542 function _waitlogic_match( s_tracker, str_notify, str_match )
543 {
544  self endon( "death" );
545  self waittillmatch( str_notify, str_match );
546  update_waitlogic_tracker( s_tracker );
547 }
548 
549 function _waitlogic_death( s_tracker )
550 {
551  self waittill( "death" );
552  update_waitlogic_tracker( s_tracker );
553 }
554 
555 function update_waitlogic_tracker( s_tracker )
556 {
557  s_tracker._array_wait_count--;
558  if ( s_tracker._array_wait_count == 0 )
559  {
560  s_tracker notify( "array_wait" );
561  }
562 }
563 
567 function flag_wait( &‪array, str_flag )
568 {
569  do
570  {
571  recheck = false;
572 
573  for ( i = 0; i < ‪array.size; i++ )
574  {
575  ent = ‪array[ i ];
576 
577  if ( isdefined( ent ) && !ent ‪flag::get( str_flag ) )
578  {
579  ent ‪util::waittill_either( "death", str_flag );
580  recheck = true;
581  break;
582  }
583  }
584  }
585  while ( recheck );
586 }
587 
591 function flagsys_wait( &‪array, str_flag )
592 {
593  do
594  {
595  recheck = false;
596 
597  for ( i = 0; i < ‪array.size; i++ )
598  {
599  ent = ‪array[ i ];
600 
601  if ( isdefined( ent ) && !ent ‪flagsys::get( str_flag ) )
602  {
603  ent ‪util::waittill_either( "death", str_flag );
604  recheck = true;
605  break;
606  }
607  }
608  }
609  while ( recheck );
610 }
611 
612 
616 function flagsys_wait_any_flag( &‪array, ... )
617 {
618  do
619  {
620  recheck = false;
621 
622  for ( i = 0; i < ‪array.size; i++ )
623  {
624  ent = ‪array[i];
625 
626  if ( isdefined( ent ) )
627  {
628  b_flag_set = false;
629  foreach ( str_flag in vararg )
630  {
631  if ( ent ‪flagsys::get( str_flag ) )
632  {
633  b_flag_set = true;
634  break;
635  }
636  }
637 
638  if ( !b_flag_set )
639  {
640  ent ‪util::waittill_any_array( vararg );
641  recheck = true;
642  }
643  }
644  }
645  } while( recheck );
646 }
647 
651 function flagsys_wait_any( &‪array, str_flag )
652 {
653  foreach ( ent in ‪array )
654  {
655  if ( ent ‪flagsys::get( str_flag ) )
656  {
657  return ent;
658  }
659  }
660 
661  wait_any( ‪array, str_flag );
662 }
663 
667 function flag_wait_clear( &‪array, str_flag )
668 {
669  do
670  {
671  recheck = false;
672 
673  for ( i = 0; i < ‪array.size; i++ )
674  {
675  ent = ‪array[i];
676  if ( ent ‪flag::get( str_flag ) )
677  {
678  ent waittill( str_flag );
679  recheck = true;
680  }
681  }
682  } while( recheck );
683 }
684 
688 function flagsys_wait_clear( &‪array, str_flag, n_timeout )
689 {
690  ‪TIMEOUT( n_timeout );
691 
692  do
693  {
694  recheck = false;
695 
696  for ( i = 0; i < ‪array.size; i++ )
697  {
698  ent = ‪array[i];
699  if ( IsDefined( ent ) && ent ‪flagsys::get( str_flag ) )
700  {
701  ent waittill( str_flag );
702  recheck = true;
703  }
704  }
705  } while( recheck );
706 }
707 
719 function wait_any( ‪array, msg, n_timeout )
720 {
721  ‪TIMEOUT( n_timeout );
722 
723  s_tracker = SpawnStruct();
724 
725  foreach ( ent in ‪array )
726  {
727  if ( isdefined( ent ) )
728  {
729  level thread ‪util::timeout( n_timeout, &_waitlogic2, s_tracker, ent, msg );
730  }
731  }
732 
733  s_tracker endon( "array_wait" );
734 
735  ‪wait_till( ‪array, "death" );
736 }
737 
738 function _waitlogic2( s_tracker, ent, msg )
739 {
740  s_tracker endon( "array_wait" );
741 
742  if( msg != "death" )
743  {
744  ent endon( "death" );
745  }
746 
747  ent ‪util::waittill_any_array( msg );
748  s_tracker notify( "array_wait" );
749 }
750 
751 function flag_wait_any( ‪array, str_flag )
752 {
753  self endon( "death" );
754 
755  foreach ( ent in ‪array )
756  {
757  if ( ent ‪flag::get( str_flag ) )
758  {
759  return ent;
760  }
761  }
762 
763  wait_any( ‪array, str_flag );
764 }
765 
775 function random( ‪array )
776 {
777  if ( ‪array.size > 0 )
778  {
779  keys = GetArrayKeys( ‪array );
780  return ‪array[ keys[RandomInt( keys.size )] ];
781  }
782 }
783 
793 function randomize( ‪array )
794 {
795  for ( i = 0; i < ‪array.size; i++ )
796  {
797  j = RandomInt( ‪array.size );
798  temp = ‪array[ i ];
799  ‪array[ i ] = ‪array[ j ];
800  ‪array[ j ] = temp;
801  }
802 
803  return ‪array;
804 }
805 
814 function clamp_size( ‪array, n_size )
815 {
816  ‪a_ret = [];
817  for ( i = 0; i < n_size; i++ )
818  {
819  ‪a_ret[ i ] = ‪array[ i ];
820  }
821 
822  return ‪a_ret;
823 }
824 
835 function ‪reverse( ‪array )
836 {
837  a_array2 = [];
838  for ( i = ‪array.size - 1; i >= 0; i-- )
839  {
840  a_array2[ a_array2.size ] = ‪array[ i ];
841  }
842 
843  return a_array2;
844 }
845 
849 function remove_keys( ‪array )
850 {
851  ‪a_new = [];
852 
853  foreach ( _, val in ‪array )
854  {
855  if ( isdefined( val ) )
856  {
857  ‪a_new[ ‪a_new.size ] = val;
858  }
859  }
860 
861  return ‪a_new;
862 }
863 
867 function swap( &‪array, index1, index2 )
868 {
869  temp = ‪array[ index1 ];
870  ‪array[ index1 ] = ‪array[ index2 ];
871  ‪array[ index2 ] = temp;
872 }
873 
874 function pop( &‪array, index, b_keep_keys = true )
875 {
876  if ( ‪array.size > 0 )
877  {
878  if ( !isdefined( index ) )
879  {
880  keys = GetArrayKeys( ‪array );
881  index = keys[ 0 ];
882  }
883 
884  if ( isdefined( ‪array[index] ) )
885  {
886  ret = ‪array[ index ];
887 
888  ArrayRemoveIndex( ‪array, index, b_keep_keys );
889 
890  return ret;
891  }
892  }
893 }
894 
895 function pop_front( &‪array, b_keep_keys = true )
896 {
897  keys = GetArrayKeys( ‪array );
898  index = keys[ keys.size - 1 ];
899  return pop( ‪array, index, b_keep_keys );
900 }
901 
902 function push( &‪array, val, index )
903 {
904  if ( !isdefined( index ) )
905  {
906  // use max free integer as index
907  index = 0;
908  foreach ( key in GetArrayKeys( ‪array ) )
909  {
910  if ( IsInt( key ) && ( key >= index ) )
911  {
912  index = key + 1;
913  }
914  }
915  }
916 
917  ArrayInsert( ‪array, val, index );
918 }
919 
920 function push_front( &‪array, val )
921 {
922  push( ‪array, val, 0 );
923 }
924 
937 function get_closest( org, &‪array, dist )
938 {
939  assert( 0, "Deprecated function. Use 'ArrayGetClosest' instead." );
940 }
941 
954 function get_farthest( org, &‪array, dist = undefined )
955 {
956  assert( 0, "Deprecated function. Use 'ArrayGetFarthest' instead." );
957 }
958 
959 function closerFunc( dist1, dist2 )
960 {
961  return dist1 >= dist2;
962 }
963 
964 function fartherFunc( dist1, dist2 )
965 {
966  return dist1 <= dist2;
967 }
968 
980 function get_all_farthest( org, &‪array, a_exclude, n_max, n_maxdist )
981 {
982  ‪DEFAULT( n_max, ‪array.size );
983 
984  ‪a_ret = exclude( ‪array, a_exclude );
985 
986  if ( isdefined( n_maxdist ) )
987  {
988  ‪a_ret = ArraySort( ‪a_ret, org, false, n_max, n_maxdist );
989  }
990  else
991  {
992  ‪a_ret = ArraySort( ‪a_ret, org, false, n_max );
993  }
994 
995  return ‪a_ret;
996 }
997 
1010 function get_all_closest( org, &‪array, a_exclude, n_max, n_maxdist )
1011 {
1012  ‪DEFAULT( n_max, ‪array.size );
1013 
1014  ‪a_ret = exclude( ‪array, a_exclude );
1015 
1016  if ( isdefined( n_maxdist ) )
1017  {
1018  ‪a_ret = ArraySort( ‪a_ret, org, true, n_max, n_maxdist );
1019  }
1020  else
1021  {
1022  ‪a_ret = ArraySort( ‪a_ret, org, true, n_max );
1023  }
1024 
1025  return ‪a_ret;
1026 }
1027 
1028 function alphabetize( &‪array )
1029 {
1030  return sort_by_value( ‪array, true );
1031 }
1032 
1044 //Use ArraySort for distance based sorting of entities
1045 function sort_by_value( &‪array, b_lowest_first = false )
1046 {
1047  return merge_sort( ‪array, &_sort_by_value_compare_func, b_lowest_first );
1048 }
1049 
1050 function _sort_by_value_compare_func( val1, val2, b_lowest_first )
1051 {
1052  if ( b_lowest_first )
1053  {
1054  return val1 < val2;
1055  }
1056  else
1057  {
1058  return val1 > val2;
1059  }
1060 }
1061 
1073 //Use ArraySort for distance based sorting of entities
1074 function sort_by_script_int( &‪a_ents, b_lowest_first = false )
1075 {
1076  return merge_sort( ‪a_ents, &_sort_by_script_int_compare_func, b_lowest_first );
1077 }
1078 
1079 function _sort_by_script_int_compare_func( e1, e2, b_lowest_first )
1080 {
1081  if ( b_lowest_first )
1082  {
1083  return e1.script_int < e2.script_int;
1084  }
1085  else
1086  {
1087  return e1.script_int > e2.script_int;
1088  }
1089 }
1090 
1091 function merge_sort( &current_list, func_sort, param )
1092 {
1093  if ( current_list.size <= 1 )
1094  {
1095  return current_list;
1096  }
1097 
1098  left = [];
1099  right = [];
1100 
1101  middle = current_list.size / 2;
1102 
1103  for ( x = 0; x < middle; x++ )
1104  {
1105  ‪ARRAY_ADD( left, current_list[ x ] );
1106  }
1107 
1108  for ( ; x < current_list.size; x++ )
1109  {
1110  ‪ARRAY_ADD( right, current_list[ x ] );
1111  }
1112 
1113  left = merge_sort( left, func_sort, param );
1114  right = merge_sort( right, func_sort, param );
1115 
1116  ‪result = merge( left, right, func_sort, param );
1117 
1118  return ‪result;
1119 }
1120 
1121 function merge( left, right, func_sort, param )
1122 {
1123  ‪result = [];
1124 
1125  li = 0;
1126  ri = 0;
1127  while ( li < left.size && ri < right.size )
1128  {
1129  b_result = undefined;
1130 
1131  if ( isdefined( param ) )
1132  {
1133  b_result = [[ func_sort ]]( left[ li ], right[ ri ], param );
1134  }
1135  else
1136  {
1137  b_result = [[ func_sort ]]( left[ li ], right[ ri ] );
1138  }
1139 
1140  if ( b_result )
1141  {
1142  ‪result[ ‪result.size ] = left[ li ];
1143  li++;
1144  }
1145  else
1146  {
1147  ‪result[ ‪result.size ] = right[ ri ];
1148  ri++;
1149  }
1150  }
1151 
1152  while ( li < left.size )
1153  {
1154  ‪result[ ‪result.size ] = left[ li ];
1155  li++;
1156  }
1157 
1158  while ( ri < right.size )
1159  {
1160  ‪result[ ‪result.size ] = right[ ri ];
1161  ri++;
1162  }
1163 
1164  return ‪result;
1165 }
1166 
1180 function insertion_sort( &‪a, compareFunc, val )
1181 {
1182  if (!IsDefined(‪a))
1183  {
1184  ‪a=[];
1185  ‪a[0]=val;
1186  return ;
1187  }
1188 
1189  for (i=0;i<‪a.size;i++)
1190  {
1191  if ([[compareFunc]](‪a[i],val)<=0)
1192  {
1193  ArrayInsert(‪a,val,i);
1194  return ;
1195  }
1196  }
1197  ‪a[‪a.size]=val;
1198 }
1199 
1215 function spread_all( &entities, func, arg1, arg2, arg3, arg4, arg5 )
1216 {
1217  Assert( isdefined( entities ), "Undefined entity array passed to array::spread_all_ents" );
1218  Assert( isdefined( func ), "Undefined function passed to array::spread_all_ents" );
1219 
1220  if ( IsArray( entities ) )
1221  {
1222  foreach ( ent in entities )
1223  {
1224  if( isdefined(ent) )
1225  {
1226  ‪util::single_thread( ent, func, arg1, arg2, arg3, arg4, arg5 );
1227  }
1228  ‪WAIT_ABOUT( .1 );
1229  }
1230  }
1231  else
1232  {
1233  ‪util::single_thread( entities, func, arg1, arg2, arg3, arg4, arg5 );
1234  ‪WAIT_ABOUT( .1 );
1235  }
1236 }
1237 
1248 function wait_till_touching( &‪a_ents, e_volume )
1249 {
1250  while ( !is_touching( ‪a_ents, e_volume ) )
1251  {
1252  wait 0.05;
1253  }
1254 }
1255 
1266 function is_touching( &‪a_ents, e_volume )
1267 {
1268  foreach ( e_ent in ‪a_ents )
1269  {
1270  if ( !e_ent IsTouching( e_volume ) )
1271  {
1272  return false;
1273  }
1274  }
1275 
1276  return true;
1277 }
1278 
1288 function contains( array_or_val, value )
1289 {
1290  if ( isArray ( array_or_val ) )
1291  {
1292  foreach( element in array_or_val )
1293  {
1294  if ( element === value )
1295  {
1296  return true;
1297  }
1298  }
1299 
1300  return false;
1301  }
1302 
1303  return array_or_val === value;
1304 }
1305 
1309 
1310 function _filter_dead( val )
1311 {
1312  return IsAlive( val );
1313 }
1314 
1315 function _filter_classname( val, arg )
1316 {
1317  return IsSubStr( val.classname, arg );
1318 }
1319 
1320 // Quick Sort - pass it an array it will come back sorted
1321 function quickSort(‪array, compare_func)
1322 {
1323  return quickSortMid(‪array, 0, ‪array.size -1, compare_func);
1324 }
1325 
1326 function quickSortMid(‪array, start, ‪end, compare_func)
1327 {
1328  i = start;
1329  k = ‪end;
1330 
1331  if(!IsDefined(compare_func))
1332  compare_func = &quickSort_compare;
1333 
1334  if (‪end - start >= 1)
1335  {
1336  pivot = ‪array[start];
1337 
1338  while (k > i)
1339  {
1340  while ( [[ compare_func ]](‪array[i], pivot) && i <= end && k > i)
1341  i++;
1342  while ( ![[ compare_func ]](‪array[k], pivot) && k >= start && k >= i)
1343  k--;
1344  if (k > i)
1345  swap(‪array, i, k);
1346  }
1347  swap(‪array, start, k);
1348  ‪array = quickSortMid(‪array, start, k - 1, compare_func);
1349  ‪array = quickSortMid(‪array, k + 1, ‪end, compare_func);
1350  }
1351  else
1352  return ‪array;
1353 
1354  return ‪array;
1355 }
1356 
1357 function quicksort_compare(left, right)
1358 {
1359  return left<=right;
1360 }
‪timeout
‪function timeout(n_time, func, arg1, arg2, arg3, arg4, arg5, arg6)
Definition: util_shared.csc:762
‪cleanup
‪function cleanup(test_name, cleanup_dvar_name, cleanup_func)
Definition: _vehicle.gsc:948
‪waittill_any_array
‪function waittill_any_array(a_notifies)
Definition: util_shared.csc:392
‪remove_index
‪function remove_index(array, index, b_keep_keys)
Definition: array_shared.gsc:119
‪waittill_either
‪function waittill_either(msg1, msg2)
Definition: util_shared.gsc:303
‪IS_TRUE
‪#define IS_TRUE(__a)
Definition: shared.gsh:251
‪get
‪function get(kvp_value, kvp_key="targetname")
Definition: struct.csc:13
‪a
‪function add_remove_list a
Definition: util_shared.csc:906
‪reverse
‪function reverse()
Definition: traps_shared.gsc:1071
‪add
‪function add(entity, dyingplayer, team, timeout)
Definition: _deathicons.gsc:43
‪DEFAULT
‪#define DEFAULT(__var, __default)
Definition: shared.gsh:270
‪array
‪function filter array
Definition: array_shared.gsc:16
‪end
‪function end(final)
Definition: _killcam.gsc:511
‪TIMEOUT
‪#define TIMEOUT(__t)
Definition: shared.gsh:218
‪ARRAY_ADD
‪#define ARRAY_ADD(__array, __item)
Definition: shared.gsh:304
‪DELETE
‪#define DELETE(__obj)
Definition: shared.gsh:444
‪remove_undefined
‪function remove_undefined(array, b_keep_keys)
Definition: array_shared.csc:56
‪wait_till
‪function wait_till(str_flag)
Definition: flag_shared.csc:189
‪_filter_undefined
‪function _filter_undefined(val)
Definition: array_shared.gsc:61
‪WAIT_ABOUT
‪#define WAIT_ABOUT(__time)
Definition: shared.gsh:436
‪a_ents
‪function _query_ents_by_substring_helper a_ents
Definition: util_shared.gsc:3334
‪_waitlogic
‪function _waitlogic(s_tracker, notifies)
Definition: util_shared.csc:182
‪single_thread
‪function single_thread(entity, func, arg1, arg2, arg3, arg4, arg5, arg6)
Definition: util_shared.csc:699
‪result
‪function result(death, attacker, mod, weapon)
Definition: _zm_aat_blast_furnace.gsc:46
‪single_func
‪function single_func(entity, func, arg1, arg2, arg3, arg4, arg5, arg6)
Definition: util_shared.csc:563
‪delete
‪function delete()
Definition: struct.csc:2
‪a_new
‪return a_new
Definition: array_shared.gsc:50
‪a_ret
‪return a_ret
Definition: util_shared.gsc:3330