DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ SortedInsertDesc()

int ServerBrowserTab::SortedInsertDesc ( GetServersResultRow entry,
ESortType sort_type )
inlineprivate

См. определение в файле ServerBrowserTabPc.c строка 848

849 {
850 array<ref GetServersResultRow> list = m_EntriesSorted[sort_type];
851
852 int i;
853 int index_min = 0;
854 int index_max = list.Count() - 1;
855 int target_index = Math.Floor( index_max / 2 );
856
857 if ( index_max == -1 )
858 {
859 list.Insert( entry );
860 return 0;
861 }
862
863 if ( sort_type == ESortType.HOST )
864 {
865 string entry_value_str = entry.GetValueStr(ESortType.HOST);
866
867 while ( true )
868 {
869 string target_value_str = list[target_index].GetValueStr(ESortType.HOST);
870
871 if ( entry_value_str == target_value_str || ((index_max - index_min) <= 1) )
872 {
873 for ( i = index_min; i <= index_max; i++ )
874 {
875 if ( entry_value_str >= list[i].GetValueStr(ESortType.HOST) )
876 {
877 list.InsertAt( entry, i );
878 return i;
879 }
880 }
881
882 index_max++;
883 list.InsertAt( entry, index_max );
884 return target_index;
885 }
886 else if ( entry_value_str > target_value_str )
887 {
888 index_max = target_index;
889 target_index = Math.Floor( target_index / 2 );
890 }
891 else if ( entry_value_str < target_value_str )
892 {
893 index_min = target_index;
894 target_index += Math.Floor( (index_max - index_min) / 2 );
895 }
896 }
897 }
898 else
899 {
900 int entry_value_int = entry.GetValueInt( sort_type );
901
902 while ( true )
903 {
904 int target_value_int = list[target_index].GetValueInt( sort_type );
905
906 if ( entry_value_int == target_value_int || ((index_max - index_min) <= 1) )
907 {
908 for ( i = index_min; i <= index_max; i++ )
909 {
910 if ( entry_value_int >= list[i].GetValueInt( sort_type ) )
911 {
912 list.InsertAt( entry, i );
913 return i;
914 }
915 }
916
917 index_max++;
918 list.InsertAt( entry, index_max );
919 return target_index;
920 }
921 else if ( entry_value_int > target_value_int )
922 {
923 index_max = target_index;
924 target_index = Math.Floor( target_index / 2 );
925 }
926 else if ( entry_value_int < target_value_int )
927 {
928 index_min = target_index;
929 target_index += Math.Floor( (index_max - index_min) / 2 );
930 }
931 }
932 }
933
934 return target_index;
935 }
ESortType
Определения BiosLobbyService.c:7
ref map< ESortType, ref array< ref GetServersResultRow > > m_EntriesSorted
Определения ServerBrowserTab.c:75
string GetValueStr(ESortType sort_type)
Определения BiosLobbyService.c:221
int GetValueInt(ESortType sort_type)
Определения BiosLobbyService.c:241

Перекрестные ссылки Math::Floor(), GetServersResultRow::GetValueInt(), GetServersResultRow::GetValueStr() и m_EntriesSorted.