Subversion Repositories svn1-original

Rev

Rev 335 | Rev 337 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 335 Rev 336
Line 86... Line 86...
86
    "Eleventh"
86
    "Eleventh"
87
};
87
};
88
 
88
 
89
int         sort_leg;
89
int         sort_leg;
90
int         sort_mode;
90
int         sort_mode;
-
 
91
bool        sort_withEquestrian;
91
report_type report_html = text;
92
report_type report_html = text;
92
bool        report_all = FALSE;
93
bool        report_all = FALSE;
93
 
94
 
94
/* Parameters used by the sort routine to govern its actions */
95
/* Parameters used by the sort routine to govern its actions */
95
 
96
 
Line 101... Line 102...
101
#define S_TEAM  6                                /* Sort on team order */
102
#define S_TEAM  6                                /* Sort on team order */
102
#define S_CLASS 7                                /* Sort on class/team order */
103
#define S_CLASS 7                                /* Sort on class/team order */
103
#define S_LC_NE 8                                /* Elapsed times per class, with NE sorted by real class */
104
#define S_LC_NE 8                                /* Elapsed times per class, with NE sorted by real class */
104
#define S_IFIN  9                                /* Sort on elapsed time at given leg */
105
#define S_IFIN  9                                /* Sort on elapsed time at given leg */
105
 
106
 
-
 
107
 
106
/*
108
/*
107
**  Various checking modes
109
**  Various checking modes
108
*/
110
*/
109
#define C_ELAPSED   1                            /* Check elapsed times */
111
#define C_ELAPSED   1                            /* Check elapsed times */
110
#define C_END       2                            /* Check end times */
112
#define C_END       2                            /* Check end times */
Line 365... Line 367...
365
     * Sort the data in finishing order 
367
     * Sort the data in finishing order 
366
     */
368
     */
367
 
369
 
368
    if( ck_data( leg, C_END ) )
370
    if( ck_data( leg, C_END ) )
369
        return;                                  /* Check data for this leg */
371
        return;                                  /* Check data for this leg */
370
    sort_team_data( leg, S_FIN );                /* Sort the data */
372
    sort_team_data( leg, S_FIN, true );         /* Sort the data */
371
 
373
 
372
 
374
 
373
    /*
375
    /*
374
     * Now print the data on the printer 
376
     * Now print the data on the printer 
375
     */
377
     */
Line 551... Line 553...
551
     * Sort the data in finishing order
553
     * Sort the data in finishing order
552
     */
554
     */
553
 
555
 
554
    if( ck_data( leg, C_ELAPSED ) )
556
    if( ck_data( leg, C_ELAPSED ) )
555
        return;                                  /* Check data for this leg */
557
        return;                                  /* Check data for this leg */
556
    sort_team_data( leg, S_IFIN );               /* Sort the data on elapsed time */
558
    sort_team_data( leg, S_IFIN, true );               /* Sort the data on elapsed time */
557
 
559
 
558
 
560
 
559
    /*
561
    /*
560
     * Now print the data on the printer
562
     * Now print the data on the printer
561
     */
563
     */
Line 789... Line 791...
789
     * Print out the data 
791
     * Print out the data 
790
     */
792
     */
791
    print_class_header( -1, TRUE );                      /* Print the header */
793
    print_class_header( -1, TRUE );                      /* Print the header */
792
 
794
 
793
    ptr = sort_data;
795
    ptr = sort_data;
794
    sort_team_data( 0, S_L );                     /* Re-sort on elapsed time */
796
    sort_team_data( 0, S_L, true );                     /* Re-sort on elapsed time */
795
    lcount = 0;
797
    lcount = 0;
796
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
798
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
797
    {
799
    {
798
        if ( ptr->teamclass == config.nonequestrian_class )
800
        if ( ptr->teamclass == config.nonequestrian_class )
799
            continue;
801
            continue;
Line 829... Line 831...
829
        **      - Leg place
831
        **      - Leg place
830
        **      - End place
832
        **      - End place
831
        */
833
        */
832
        for( j = 1; j <= config.num_legs; j++ )
834
        for( j = 1; j <= config.num_legs; j++ )
833
        {
835
        {
-
 
836
            bool isEquestrianLeg = (j == config.equestrian_leg && team_buf.flags.non_equestrian);
-
 
837
            bool afterEquestrianLeg = (team_buf.flags.non_equestrian && j > config.equestrian_leg);
834
            /*
838
            /*
835
            **  Ensure that non-equestrian leg data is not displayed
839
            **  Ensure that non-equestrian leg data is not displayed
836
            */
840
            */
837
            if ( j == config.equestrian_leg && team_buf.flags.non_equestrian )
841
            if ( isEquestrianLeg )
838
            {
842
            {
839
                print( "  %-8s %4.4s %4.4s", "-- NE --", "NE","NE");
843
                print( "  %-8s %4.4s %4.4s", "-- NE --", "NE","NE");
840
            }
844
            }
841
            else
845
            else
842
            {
846
            {
843
                print( "  %-8s %4.4s %4.4s",
847
                print( "  %-8s %4.4s %4.4s",
844
                    time_a( team_buf.leg[j].elapsed ),
848
                    time_a( team_buf.leg[j].elapsed ),
845
                    pr_place( team_buf.leg[j].l_place, ptr->flags.bad_times || ptr->flags.non_equestrian ),
849
                    pr_place( team_buf.leg[j].l_place, ptr->flags.bad_times ),
846
                    pr_place( team_buf.leg[j].le_place,ptr->flags.bad_times || ptr->flags.non_equestrian )
850
                    pn_place( team_buf.leg[j].le_place,ptr->flags.bad_times, afterEquestrianLeg )
847
                  );
851
                  );
848
            }
852
            }
849
        }
853
        }
850
 
854
 
851
       /*
855
       /*
Line 871... Line 875...
871
    /*
875
    /*
872
     * Now produce a breakdown on a class by class basis 
876
     * Now produce a breakdown on a class by class basis 
873
     * Now print out the class placement information
877
     * Now print out the class placement information
874
     */
878
     */
875
 
879
 
876
    sort_team_data( 0, S_LC );                 /* Generate class placement data */
880
    sort_team_data( 0, S_LC, true );                 /* Generate class placement data */
877
    last_class = -1;                           /* Invalid class to start with */
881
    last_class = -1;                           /* Invalid class to start with */
878
    memset ( class_done, 0, sizeof(class_done));
882
    memset ( class_done, 0, sizeof(class_done));
879
 
883
 
880
 
884
 
881
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
885
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
882
    {
886
    {
883
        int flags = 0;
887
        int flags = 0;
-
 
888
        int rflags = 0;
884
 
889
 
885
        /*
890
        /*
886
        **  Detect a change in the "class"
891
        **  Detect a change in the "class"
887
        **  All data is within the one array of data
892
        **  All data is within the one array of data
888
        **  Use the in-memory class as this MAY differ from that stored
893
        **  Use the in-memory class as this MAY differ from that stored
Line 912... Line 917...
912
 
917
 
913
        /*
918
        /*
914
        **  Now read in the team record
919
        **  Now read in the team record
915
        */
920
        */
916
        g_record( ptr->team, &team_buf );
921
        g_record( ptr->team, &team_buf );
917
        flags = ptr->flags.bad_times;
922
        rflags = flags = ptr->flags.bad_times;
918
        if ( ptr->teamclass != config.nonequestrian_class )
923
        if ( ptr->teamclass != config.nonequestrian_class )
919
        {
924
        {
920
            flags |= ptr->flags.non_equestrian;
925
            rflags |= ptr->flags.non_equestrian;
921
        }
926
        }
922
 
927
 
923
        /*
928
        /*
924
        **  If printing an HTML report then we need to mark
929
        **  If printing an HTML report then we need to mark
925
        **  the entry with a reference so that we can link to it
930
        **  the entry with a reference so that we can link to it
Line 933... Line 938...
933
        **      - Team number - with HTML reference to team file
938
        **      - Team number - with HTML reference to team file
934
        **      - Class
939
        **      - Class
935
        */
940
        */
936
 
941
 
937
        if ( report_html == printed && lcount %5 == 4 ) print_underline( TRUE );
942
        if ( report_html == printed && lcount %5 == 4 ) print_underline( TRUE );
938
        print( "%4.4s ", pr_place( team_buf.leg[0].lc_place, flags ) );
943
        print( "%4.4s ", pr_place( team_buf.leg[0].lc_place, rflags ) );
939
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "name" ,"html")), team_buf.numb );
944
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "name" ,"html")), team_buf.numb );
940
        print( "%4d",  team_buf.numb );
945
        print( "%4d",  team_buf.numb );
941
        if ( report_html == html ) print( "</A>" );
946
        if ( report_html == html ) print( "</A>" );
942
        print( " %-*s", 3, team_buf.teamclass == 0 ? "" : config.team_class[team_buf.teamclass - 1].abr );
947
        print( " %-*s", 3, team_buf.teamclass == 0 ? "" : config.team_class[team_buf.teamclass - 1].abr );
943
 
948
 
944
        for( j = 1; j <= config.num_legs; j++ )
949
        for( j = 1; j <= config.num_legs; j++ )
945
        {
950
        {
-
 
951
            bool isEquestrianLeg = (j == config.equestrian_leg && (ptr->teamclass == config.nonequestrian_class || ptr->flags.non_equestrian));
-
 
952
            bool afterEquestrianLeg = ((ptr->teamclass == config.nonequestrian_class || ptr->flags.non_equestrian) && j > config.equestrian_leg);
-
 
953
 
946
            /*
954
            /*
947
            **  Ensure that non-equestrian leg data is not displayed
955
            **  Ensure that non-equestrian leg data is not displayed
948
            */
956
            */
949
            if ( j == config.equestrian_leg && (ptr->teamclass == config.nonequestrian_class || ptr->flags.non_equestrian) )
957
            if ( isEquestrianLeg )
950
            {
958
            {
951
                print( "  %-8s %4.4s %4.4s", "-- NE --", "NE","NE");
959
                print( "  %-8s %4.4s %4.4s", "-- NE --", "NE","NE");
952
            }
960
            }
953
            else
961
            else
954
            {
962
            {
955
                print( "  %-8s %4.4s %4.4s", time_a( team_buf.leg[j].elapsed ),
963
                print( "  %-8s %4.4s %4.4s", time_a( team_buf.leg[j].elapsed ),
956
                       pr_place( team_buf.leg[j].lc_place,  flags ),
964
                       pr_place( team_buf.leg[j].lc_place,  flags ),
957
                       pr_place( team_buf.leg[j].lec_place, flags ) );
965
                       pn_place( team_buf.leg[j].lec_place, flags, afterEquestrianLeg ) );
958
            }
966
            }
959
        }
967
        }
960
 
968
 
961
        /*
969
        /*
962
        **  Print the trailer
970
        **  Print the trailer
Line 965... Line 973...
965
        */
973
        */
966
        /* print( "  %-8s ", time_a( team_buf.leg[0].elapsed ) ); */
974
        /* print( "  %-8s ", time_a( team_buf.leg[0].elapsed ) ); */
967
        print( "  %-8s ", time_a( ptr->lege[0] ) );
975
        print( "  %-8s ", time_a( ptr->lege[0] ) );
968
 
976
 
969
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "finish" ,"html")), team_buf.numb );
977
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "finish" ,"html")), team_buf.numb );
970
        print( "%4.4s", pr_place( team_buf.leg[0].l_place, flags || (ptr->teamclass == config.nonequestrian_class)));
978
        print( "%4.4s", pr_place( team_buf.leg[0].l_place, rflags || (ptr->teamclass == config.nonequestrian_class)));
971
        if ( report_html == html ) print( "</A>" );
979
        if ( report_html == html ) print( "</A>" );
972
 
980
 
973
        if ( report_html == printed && lcount %5 == 4 ) print_underline( FALSE );
981
        if ( report_html == printed && lcount %5 == 4 ) print_underline( FALSE );
974
        lcount++;
982
        lcount++;
975
        print( "\n" );
983
        print( "\n" );
Line 1234... Line 1242...
1234
    if ( report_html == html ) print( "</A>" );
1242
    if ( report_html == html ) print( "</A>" );
1235
 
1243
 
1236
    /*
1244
    /*
1237
    **  Sort the data by class
1245
    **  Sort the data by class
1238
    */
1246
    */
1239
    sort_team_data( 0, S_LC );     /* Generate class placement data */
1247
    sort_team_data( 0, S_LC, true );     /* Generate class placement data */
1240
    last_class = -1;                /* Invalid class to start with */
1248
    last_class = -1;                /* Invalid class to start with */
1241
 
1249
 
1242
    /*
1250
    /*
1243
    **  Process each category
1251
    **  Process each category
1244
    */
1252
    */
Line 1403... Line 1411...
1403
        header_done = false;
1411
        header_done = false;
1404
 
1412
 
1405
        /*
1413
        /*
1406
        **  Sort the data by class with NE data sorted by real class
1414
        **  Sort the data by class with NE data sorted by real class
1407
        */
1415
        */
1408
        sort_team_data( 0, S_LC_NE );      /* Generate class placement data */
1416
        sort_team_data( 0, S_LC_NE, true );      /* Generate class placement data */
1409
        last_class = -1;                   /* Invalid class to start with */
1417
        last_class = -1;                   /* Invalid class to start with */
1410
 
1418
 
1411
        /*
1419
        /*
1412
        **  Only process the Non Equestrian teams in this pass
1420
        **  Only process the Non Equestrian teams in this pass
1413
        */
1421
        */
Line 1796... Line 1804...
1796
     * Print out the data 
1804
     * Print out the data 
1797
     */
1805
     */
1798
    print_class_header( -1, FALSE );                     /* Print the header */
1806
    print_class_header( -1, FALSE );                     /* Print the header */
1799
 
1807
 
1800
    ptr = sort_data;
1808
    ptr = sort_data;
1801
    sort_team_data( 0, S_TEAM );                   /* Re-sort on team number */
1809
    sort_team_data( 0, S_TEAM, true );                   /* Re-sort on team number */
1802
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
1810
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
1803
    {
1811
    {
1804
        if ( ptr->teamclass == config.nonequestrian_class )
1812
        if ( ptr->teamclass == config.nonequestrian_class )
1805
            continue;
1813
            continue;
1806
 
1814
 
Line 1838... Line 1846...
1838
    /*
1846
    /*
1839
     * Now produce a breakdown on a class by class basis 
1847
     * Now produce a breakdown on a class by class basis 
1840
     * Now print out the class placement information
1848
     * Now print out the class placement information
1841
     */
1849
     */
1842
 
1850
 
1843
    sort_team_data( 0, S_CLASS );              /* Generate class placement data */
1851
    sort_team_data( 0, S_CLASS, true );              /* Generate class placement data */
1844
    last_class = -1;                             /* Invalid class to start with */
1852
    last_class = -1;                             /* Invalid class to start with */
1845
 
1853
 
1846
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
1854
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
1847
    {
1855
    {
1848
        /*
1856
        /*
Line 2494... Line 2502...
2494
 
2502
 
2495
}
2503
}
2496
 
2504
 
2497
/*========================================================================
2505
/*========================================================================
2498
 *
2506
 *
-
 
2507
 *  Return place data or NE flag
-
 
2508
 *
-
 
2509
 *  Purpose:
-
 
2510
 *      This function is called to Return place data
-
 
2511
 *
-
 
2512
 *      This routine is called to fill a print team_buffer - to allow for
-
 
2513
 *      multiple calls to this function ( before the data is used ) a number
-
 
2514
 *      of static team_buffers are maintained
-
 
2515
 *
-
 
2516
 *  Parameters:
-
 
2517
 *      num         place - if not bad_times
-
 
2518
 *      disq        Disqualified flag
-
 
2519
 *      flag        Flag NE data
-
 
2520
 *
-
 
2521
 *  Returns:
-
 
2522
 *      This function returns a pointer to the character string for the
-
 
2523
 *      number or a pointer to a bad_times string.
-
 
2524
 *
-
 
2525
 *========================================================================*/
-
 
2526
const char *pn_place( int num, int disq, bool flag )
-
 
2527
{
-
 
2528
    static char store[2][5];                     /* 2 stores for 4 digit numbers */
-
 
2529
    static int  i = 0;                           /* Current index into store */
-
 
2530
    static const char *dis = "U";
-
 
2531
    static const char *alt = "NE";
-
 
2532
 
-
 
2533
    if( disq )
-
 
2534
        return ( dis );
-
 
2535
    if (flag)
-
 
2536
        return ( alt );
-
 
2537
 
-
 
2538
    i++;
-
 
2539
    if( i >= 2 )
-
 
2540
        i = 0;                                   /* Select next entry */
-
 
2541
    sprintf( store[i], "%4d", num );
-
 
2542
    return ( store[i] );
-
 
2543
 
-
 
2544
}
-
 
2545
 
-
 
2546
/*========================================================================
-
 
2547
 *
2499
 *  Check data for bad times
2548
 *  Check data for bad times
2500
 *
2549
 *
2501
 *  Purpose:
2550
 *  Purpose:
2502
 *      This function is called to Check data for bad times
2551
 *      This function is called to Check data for bad times
2503
 *      Scan the sort data structure and locate entries that have incorrect
2552
 *      Scan the sort data structure and locate entries that have incorrect
Line 2849... Line 2898...
2849
    int         teamclass;                           /* Current class */
2898
    int         teamclass;                           /* Current class */
2850
    team_type   team_buf;
2899
    team_type   team_buf;
2851
 
2900
 
2852
    for( i = 0; i <= config.num_legs; i++ )
2901
    for( i = 0; i <= config.num_legs; i++ )
2853
    {
2902
    {
-
 
2903
        bool sortWithEq =  (i == 0);
2854
        /*
2904
        /*
2855
        **  Sort on leg elapsed time
2905
        **  Sort on leg elapsed time
2856
        **  Then save the teams elapsed place in each leg
2906
        **  Then save the teams elapsed place in each leg
2857
        */
2907
        */
2858
        sort_team_data( i, S_L );
2908
        sort_team_data( i, S_L, sortWithEq );
2859
        for( j = 1, k = 1, ptr = sort_data; j <= sort_num; ptr++, j++ )
2909
        for( j = 1, k = 1, ptr = sort_data; j <= sort_num; ptr++, j++ )
2860
        {
2910
        {
2861
            if ( ptr->teamclass == config.nonequestrian_class )
2911
            if (ptr->isNeData)
2862
                continue;
2912
                continue;
-
 
2913
//            if ( ptr->teamclass == config.nonequestrian_class && i == config.equestrian_leg )
2863
            
2914
//                continue;
-
 
2915
 
2864
            sort_aux[ptr->team].l_place[i] = k++;
2916
            sort_aux[ptr->team].l_place[i] = k++;
2865
            sort_aux[ptr->team].team = ptr->team;
2917
            sort_aux[ptr->team].team = ptr->team;
2866
        }
2918
        }
2867
 
2919
 
2868
        /*
2920
        /*
2869
        **  Sort on leg end time
2921
        **  Sort on leg end time
2870
        **  Then save the teams place at the end of each leg
2922
        **  Then save the teams place at the end of each leg
2871
        */
2923
        */
2872
        sort_team_data( i, S_LE );
2924
        sort_team_data( i, S_LE, sortWithEq);
2873
        for( j = 1, k = 1, ptr = sort_data; j <= sort_num; ptr++, j++ )
2925
        for( j = 1, k = 1, ptr = sort_data; j <= sort_num; ptr++, j++ )
2874
        {
2926
        {
2875
            if ( ptr->teamclass == config.nonequestrian_class )
2927
            if (ptr->isNeData)
2876
                continue;
2928
                continue;
-
 
2929
 
-
 
2930
            //if ( ptr->teamclass == config.nonequestrian_class && i == config.equestrian_leg )
-
 
2931
            //    continue;
2877
            
2932
            
2878
            sort_aux[ptr->team].le_place[i] = k++;
2933
            sort_aux[ptr->team].le_place[i] = k++;
2879
        }
2934
        }
2880
 
2935
 
2881
        /*
2936
        /*
2882
        **  Sort on elapsed time per class
2937
        **  Sort on elapsed time per class
2883
        **  The save the teams elapsed place in each leg per class
2938
        **  The save the teams elapsed place in each leg per class
2884
        */
2939
        */
2885
        sort_team_data( i, S_LC );
2940
        sort_team_data( i, S_LC, sortWithEq );
2886
        teamclass = -1;
2941
        teamclass = -1;
2887
        for( k = 1, j = 1, ptr = sort_data; j <= sort_num; j++, ptr++ )
2942
        for( k = 1, j = 1, ptr = sort_data; j <= sort_num; j++, ptr++ )
2888
        {
2943
        {
-
 
2944
            if ( sortWithEq && ptr->teamclass == config.nonequestrian_class  ) {
-
 
2945
                if ( !ptr->isNeData)
-
 
2946
                    continue;
-
 
2947
            }
-
 
2948
            else {
-
 
2949
                if (ptr->isNeData)
-
 
2950
                    continue;
-
 
2951
            }
-
 
2952
 
2889
            if( teamclass != ptr->teamclass )
2953
            if( teamclass != ptr->teamclass )
2890
            {
2954
            {
2891
                k = 1;
2955
                k = 1;
2892
                teamclass = ptr->teamclass;
2956
                teamclass = ptr->teamclass;
2893
            }
2957
            }
Line 2896... Line 2960...
2896
 
2960
 
2897
        /*
2961
        /*
2898
        **  Sort on end time per class
2962
        **  Sort on end time per class
2899
        **  Then save the teams place at the end of each leg per class
2963
        **  Then save the teams place at the end of each leg per class
2900
        */
2964
        */
2901
        sort_team_data( i, S_LEC );
2965
        sort_team_data( i, S_LEC, sortWithEq );
2902
        teamclass = -1;
2966
        teamclass = -1;
2903
        for( k = 1, j = 1, ptr = sort_data; j <= sort_num; j++, ptr++ )
2967
        for( k = 1, j = 1, ptr = sort_data; j <= sort_num; j++, ptr++ )
2904
        {
2968
        {
-
 
2969
            if ( sortWithEq &&  ptr->teamclass == config.nonequestrian_class  ) {
-
 
2970
                if ( !ptr->isNeData)
-
 
2971
                    continue;
-
 
2972
            }
-
 
2973
            else {
-
 
2974
                if (ptr->isNeData)
-
 
2975
                    continue;
-
 
2976
            }
-
 
2977
 
2905
            if( teamclass != ptr->teamclass )
2978
            if( teamclass != ptr->teamclass )
2906
            {
2979
            {
2907
                k = 1;
2980
                k = 1;
2908
                teamclass = ptr->teamclass;
2981
                teamclass = ptr->teamclass;
2909
            }
2982
            }
Line 2938... Line 3011...
2938
 *      This function is called to Sort in memory buffer
3011
 *      This function is called to Sort in memory buffer
2939
 *
3012
 *
2940
 *  Parameters:
3013
 *  Parameters:
2941
 *      leg         Requested leg
3014
 *      leg         Requested leg
2942
 *      mode        Defines the sort mode
3015
 *      mode        Defines the sort mode
-
 
3016
 *      withEq      Sort with equestrian data (True=Normal)
2943
 *
3017
 *
2944
 *  Returns:
3018
 *  Returns:
2945
 *      Nothing
3019
 *      Nothing
2946
 *
3020
 *
2947
 *========================================================================*/
3021
 *========================================================================*/
2948
 
3022
 
2949
void sort_team_data( int leg, int mode )
3023
void sort_team_data( int leg, int mode, bool withEq )
2950
{
3024
{
2951
 
3025
 
2952
    unsigned    j;
3026
    unsigned    j;
2953
    ty_s_data  *ptr;
3027
    ty_s_data  *ptr;
2954
 
3028
 
2955
    sort_leg = leg;                              /* Leg is global for the comparison function */
3029
    sort_leg = leg;                              /* Leg is global for the comparison function */
2956
    sort_mode = mode;                            /* Mode is global for compare function */
3030
    sort_mode = mode;                            /* Mode is global for compare function */
-
 
3031
    sort_withEquestrian = withEq;                /* Mode is global for compare function */
2957
 
3032
 
2958
    qsort( ( char * ) sort_data, sort_num, sizeof( ty_s_data ), sort_comp );
3033
    qsort( ( char * ) sort_data, sort_num, sizeof( ty_s_data ), sort_comp );
2959
 
3034
 
2960
    /*
3035
    /*
2961
     * Insert "place data" into the sorted data
3036
     * Insert "place data" into the sorted data
Line 3019... Line 3094...
3019
 
3094
 
3020
    /*
3095
    /*
3021
    **  Sorting within a class
3096
    **  Sorting within a class
3022
    **  First sort on the class
3097
    **  First sort on the class
3023
    */
3098
    */
3024
    if( sort_mode == S_LEC || sort_mode == S_LC || sort_mode == S_LC_NE )   /* Sort within a class */
3099
    if( sort_mode == S_LEC || sort_mode == S_LC || sort_mode == S_LC_NE ) {  /* Sort within a class */
3025
        if( a->teamclass != b->teamclass )
3100
        if (a->teamclass != b->teamclass)
3026
            return ( a->teamclass - b->teamclass );
3101
            return ( a->teamclass - b->teamclass );
-
 
3102
    }
3027
 
3103
 
3028
    /*
3104
    /*
3029
    **  Always put the nonequestrian_class at the end
3105
    **  Always put the nonequestrian_class at the end
3030
    **  Simplifies the creation of ordered lists as these
3106
    **  Simplifies the creation of ordered lists as these
3031
    **  Entries are not present in the main body
3107
    **  Entries are not present in the main body
3032
    */
3108
    */
3033
    if ( a->teamclass == config.nonequestrian_class ||  b->teamclass == config.nonequestrian_class )
3109
    if ( sort_withEquestrian && ( a->teamclass == config.nonequestrian_class ||  b->teamclass == config.nonequestrian_class ))
3034
    {
3110
    {
3035
        if ( a->teamclass == config.nonequestrian_class &&  b->teamclass == config.nonequestrian_class )
3111
        if ( a->teamclass == config.nonequestrian_class &&  b->teamclass == config.nonequestrian_class )
3036
        {
3112
        {
3037
            /*
3113
            /*
3038
            **  Both are non equestrian
3114
            **  Both are non equestrian
Line 3056... Line 3132...
3056
            return ( a->teamclass == config.nonequestrian_class ? 1 : -1 );
3132
            return ( a->teamclass == config.nonequestrian_class ? 1 : -1 );
3057
        }
3133
        }
3058
 
3134
 
3059
    }
3135
    }
3060
 
3136
 
-
 
3137
 
3061
    /*
3138
    /*
3062
    **  Now we need to examine the times as we have sorted
3139
    **  Now we need to examine the times as we have sorted
3063
    **  on every thing else.
3140
    **  on every thing else.
3064
    **
3141
    **
3065
    **  If one of the teams has bad_times, then that team is placed
3142
    **  If one of the teams has bad_times, then that team is placed
Line 3069... Line 3146...
3069
    **
3146
    **
3070
    **  If not sorting within a class (ie Overall), then Non_Equestrian
3147
    **  If not sorting within a class (ie Overall), then Non_Equestrian
3071
    **  is better than a bad time. Places NE before disqualified
3148
    **  is better than a bad time. Places NE before disqualified
3072
    **
3149
    **
3073
    */
3150
    */
3074
    if( a->flags.bad_times || b->flags.bad_times || a->flags.non_equestrian || b->flags.non_equestrian)  /* Valid data has precedence */
3151
    if( a->flags.bad_times || b->flags.bad_times || ( sort_withEquestrian && a->flags.non_equestrian) || (sort_withEquestrian && b->flags.non_equestrian))  /* Valid data has precedence */
3075
    {
3152
    {
3076
        if( a->flags.bad_times && b->flags.bad_times )
3153
        if( a->flags.bad_times && b->flags.bad_times )
3077
        {
3154
        {
3078
            return ( a->team - b->team );
3155
            return ( a->team - b->team );
3079
        }
3156
        }
Line 3173... Line 3250...
3173
      default:
3250
      default:
3174
        return ( 0 );
3251
        return ( 0 );
3175
    }
3252
    }
3176
 
3253
 
3177
    /*
3254
    /*
-
 
3255
     ** If we are ignore Equestrian config then place the Equestrian data last
-
 
3256
    */
-
 
3257
 
-
 
3258
#if 0
-
 
3259
    if (a->isNeData != b->isNeData) {
-
 
3260
         return ( a->isNeData ? 1 : -1 );
-
 
3261
    }
-
 
3262
#endif
-
 
3263
 
-
 
3264
#if 1
-
 
3265
    if (sort_withEquestrian) {
-
 
3266
        if (a->isNeData != b->isNeData)
-
 
3267
            return ( a->isNeData ? 1 : -1 );
-
 
3268
    }
-
 
3269
#endif
-
 
3270
 
-
 
3271
    if ( a->team == b->team) {
-
 
3272
        return ( a->isNeData ? 1 : -1 );
-
 
3273
    }
-
 
3274
 
-
 
3275
    /*
3178
    **  Finally. Compare the required team times
3276
    **  Finally. Compare the required team times
3179
    */
3277
    */
3180
    if( ta == tb )
3278
    if( ta == tb )
3181
        return ( a->team - b->team );
3279
        return ( a->team - b->team );
3182
    if( ( ta > 0 ) && ( tb > 0 ) )
3280
    if( ( ta > 0 ) && ( tb > 0 ) )
Line 3308... Line 3406...
3308
            g_record( team, &team_buf );
3406
            g_record( team, &team_buf );
3309
            if( team_buf.flags.valid )
3407
            if( team_buf.flags.valid )
3310
            {
3408
            {
3311
                last = ptr;
3409
                last = ptr;
3312
                ptr->team = team;
3410
                ptr->team = team;
-
 
3411
                ptr->isNeData = false;
3313
                for( j = 0; j < MAX_LEGS + 1; j++ )
3412
                for( j = 0; j < MAX_LEGS + 1; j++ )
3314
                {
3413
                {
3315
                    ptr->lege[j] = team_buf.leg[j].elapsed;
3414
                    ptr->lege[j] = team_buf.leg[j].elapsed;
3316
                    ptr->leg[j] = team_buf.leg[j].end;
3415
                    ptr->leg[j] = team_buf.leg[j].end;
3317
                }
3416
                }
3318
                ptr->start = team_buf.leg[0].start;
3417
                ptr->start = team_buf.leg[0].start;
3319
                ptr->teamclass = team_buf.teamclass;
3418
                ptr->teamclass = team_buf.teamclass;
3320
                ptr->real_teamclass = team_buf.teamclass;
3419
                ptr->real_teamclass = team_buf.teamclass;
3321
 
3420
 
3322
                ptr->flags = team_buf.flags;
3421
                ptr->flags = team_buf.flags;
-
 
3422
 
3323
//                if (ptr->flags.non_equestrian)
3423
//                if (ptr->flags.non_equestrian)
3324
//                    ptr->flags.disqualified = true;
3424
//                    ptr->flags.disqualified = true;
3325
                if (ptr->flags.vet_check)
3425
                if (ptr->flags.vet_check)
3326
                    ptr->flags.disqualified = true;
3426
                    ptr->flags.disqualified = true;
3327
 
3427
 
Line 3337... Line 3437...
3337
                */
3437
                */
3338
#if 1
3438
#if 1
3339
                if ( config.nonequestrian_class && team_buf.flags.non_equestrian )
3439
                if ( config.nonequestrian_class && team_buf.flags.non_equestrian )
3340
                {
3440
                {
3341
                    ptr->team = team;
3441
                    ptr->team = team;
-
 
3442
                    ptr->isNeData = true;
3342
                    ptr->lege[0] = 0;
3443
                    ptr->lege[0] = 0;
3343
 
3444
 
3344
                    for( j = 0; j < MAX_LEGS + 1; j++ )
3445
                    for( j = 0; j < MAX_LEGS + 1; j++ )
3345
                    {
3446
                    {
3346
                        if ( j == config.equestrian_leg )
3447
                        if ( j == config.equestrian_leg )