Subversion Repositories svn1-original

Rev

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

Rev 354 Rev 355
Line 18... Line 18...
18
*       pri_final               - Print final results
18
*       pri_final               - Print final results
19
*       pri_interim             - Print interim results
19
*       pri_interim             - Print interim results
20
*       print_class_header      - Print a class header
20
*       print_class_header      - Print a class header
21
*       print_class_stats       - Generate the class stats
21
*       print_class_stats       - Generate the class stats
22
*       print_legend            - Print the legend
22
*       print_legend            - Print the legend
23
*       pi_place                - Return place data (Interim processing)
-
 
24
*       pr_place                - Return place data
-
 
25
*       pn_place                - Return place data with NE indication
23
*       px_place                - Return place data with NE and V indication
26
*       ck_data                 - Check data for bad times
24
*       ck_data                 - Check data for bad times
27
*       srt_place               - Update placing information
25
*       srt_place               - Update placing information
28
*       do_big_sort             - Main sort routine for final data
26
*       do_big_sort             - Main sort routine for final data
29
*       sort                    - Sort in memory buffer
27
*       sort                    - Sort in memory buffer
30
*       sort_comp               - qsort comparison function
28
*       sort_comp               - qsort comparison function
Line 88... Line 86...
88
};
86
};
89
 
87
 
90
int         sort_leg;
88
int         sort_leg;
91
int         sort_mode;
89
int         sort_mode;
92
bool        sort_withEquestrian;
90
bool        sort_withEquestrian;
-
 
91
bool        sort_afterEquestrianLeg;
93
report_type report_html = text;
92
report_type report_html = text;
94
bool        report_all = FALSE;
93
bool        report_all = FALSE;
95
 
94
 
96
/* Parameters used by the sort routine to govern its actions */
95
/* Parameters used by the sort routine to govern its actions */
97
 
96
 
Line 366... Line 365...
366
 
365
 
367
    /*
366
    /*
368
     * Sort the data in finishing order 
367
     * Sort the data in finishing order 
369
     */
368
     */
370
 
369
 
371
    if( ck_data( leg, C_END ) )
-
 
372
        return;                                  /* Check data for this leg */
370
    ck_data( leg, C_END );                      /* Check data for this leg */
373
    sort_team_data( leg, S_FIN, true );         /* Sort the data */
371
    sort_team_data( leg, S_FIN, true );         /* Sort the data */
374
 
372
 
375
 
373
 
376
    /*
374
    /*
377
     * Now print the data on the printer 
375
     * Now print the data on the printer 
Line 473... Line 471...
473
void p_place( ty_s_data * ptr, int leg, unsigned k )
471
void p_place( ty_s_data * ptr, int leg, unsigned k )
474
{
472
{
475
    if( k < sort_num )
473
    if( k < sort_num )
476
    {
474
    {
477
        print( "%4.4s %4d %8s  ",
475
        print( "%4.4s %4d %8s  ",
478
               pr_place( ptr->place, ptr->flags.bad_times, ptr->flags.vet_check && (leg == 0) ),
476
               px_place(-1, ptr->place, false, false, ptr->flags ),
479
               ptr->team, time_fa( ptr->leg[leg], ptr->flags.disqualified ) );
477
               ptr->team, time_fa( ptr->leg[leg], ptr->flags.disqualified ) );
480
    }
478
    }
481
    else
479
    else
482
    {
480
    {
483
        print( "%20s", "" );
481
        print( "%20s", "" );
Line 519... Line 517...
519
    }
517
    }
520
    if( found )
518
    if( found )
521
    {
519
    {
522
        print( "%4d %4.4s %8s  ",
520
        print( "%4d %4.4s %8s  ",
523
               ptra->team,
521
               ptra->team,
524
               pr_place( ptra->place, ptra->flags.bad_times, ptra->flags.vet_check && (leg == 0) ),
522
               px_place( -1, ptra->place, false, false, ptra->flags ),
525
               time_fa( ptra->leg[leg], ptra->flags.disqualified ) );
523
               time_fa( ptra->leg[leg], ptra->flags.disqualified ) );
526
    }
524
    }
527
    else
525
    else
528
    {
526
    {
529
        print( "%20s", "" );
527
        print( "%20s", "" );
Line 552... Line 550...
552
 
550
 
553
    /*
551
    /*
554
     * Sort the data in finishing order
552
     * Sort the data in finishing order
555
     */
553
     */
556
 
554
 
557
    if( ck_data( leg, C_ELAPSED ) )
-
 
558
        return;                                     /* Check data for this leg */
555
    ck_data( leg, C_ELAPSED );                      /* Check data for this leg */
559
    sort_team_data( leg, S_IFIN, true );            /* Sort the data on elapsed time */
556
    sort_team_data( leg, S_IFIN, true );            /* Sort the data on elapsed time */
560
 
557
 
561
 
558
 
562
    /*
559
    /*
563
     * Now print the data on the printer
560
     * Now print the data on the printer
Line 661... Line 658...
661
void pe_place( ty_s_data * ptr, int leg, unsigned k )
658
void pe_place( ty_s_data * ptr, int leg, unsigned k )
662
{
659
{
663
    if( k < sort_num )
660
    if( k < sort_num )
664
    {
661
    {
665
        print( "%4.4s %4d %8s  ",
662
        print( "%4.4s %4d %8s  ",
666
               pr_place( ptr->place, ptr->flags.bad_times, ptr->flags.vet_check && (leg == 0) ),
663
               px_place( -1, ptr->place, false, false, ptr->flags ),
667
               ptr->team,
664
               ptr->team,
668
               time_fa( ptr->lege[leg], ptr->flags.disqualified ) );
665
               time_fa( ptr->lege[leg], ptr->flags.disqualified ) );
669
    }
666
    }
670
    else
667
    else
671
    {
668
    {
Line 708... Line 705...
708
    }
705
    }
709
    if( found )
706
    if( found )
710
    {
707
    {
711
        print( "%4d %4.4s %8s  ",
708
        print( "%4d %4.4s %8s  ",
712
               ptra->team,
709
               ptra->team,
713
               pr_place( ptra->place, ptra->flags.bad_times, ptra->flags.vet_check && (leg == 0) ),
710
               px_place( -1, ptra->place, false, false, ptra->flags ),
714
               time_fa( ptra->lege[leg], ptra->flags.disqualified ) );
711
               time_fa( ptra->lege[leg], ptra->flags.disqualified ) );
715
    }
712
    }
716
    else
713
    else
717
    {
714
    {
718
        print( "%20s", "" );
715
        print( "%20s", "" );
Line 777... Line 774...
777
    int         lcount;
774
    int         lcount;
778
    bool        isNeClass = false;
775
    bool        isNeClass = false;
779
    int         place;
776
    int         place;
780
 
777
 
781
 
778
 
782
    if( ck_data( -1, C_ELAPSED ) )
779
    ck_data( -1, C_ELAPSED );
783
        return;
780
 
784
    /*
781
    /*
785
    **  Sort on every thing
782
    **  Sort on every thing
786
    **  Then generate all the stats too
783
    **  Then generate all the stats too
787
    */
784
    */
788
    do_big_sort();
785
    do_big_sort();
Line 795... Line 792...
795
        return;
792
        return;
796
 
793
 
797
    /*
794
    /*
798
     * Print out the data 
795
     * Print out the data 
799
     */
796
     */
800
    print_class_header( -1, TRUE );                      /* Print the header */
797
    print_class_header( -1, TRUE );                     /* Print the header */
801
 
-
 
802
    ptr = sort_data;
-
 
803
    sort_team_data( 0, S_L, true );                     /* Re-sort on elapsed time */
798
    sort_team_data( 0, S_L, true );                     /* Re-sort on elapsed time */
804
    lcount = 0;
799
    lcount = 0;
805
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
800
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
806
    {
801
    {
807
        if ( ptr->teamclass == config.nonequestrian_class )
802
        if ( ptr->teamclass == config.nonequestrian_class )
Line 832... Line 827...
832
        **      - Place within complete field
827
        **      - Place within complete field
833
        **      - Team number - with HTML reference to team file
828
        **      - Team number - with HTML reference to team file
834
        **      - Class
829
        **      - Class
835
        */
830
        */
836
        if ( report_html == printed && lcount % 5 == 4 ) print_underline( TRUE );
831
        if ( report_html == printed && lcount % 5 == 4 ) print_underline( TRUE );
837
        print( "%4.4s ", pn_place( team_buf.leg[0].l_place, ptr->flags.bad_times, ptr->flags.vet_check, ptr->flags.non_equestrian ) );
832
        print( "%4.4s ", px_place( 0, team_buf.leg[0].l_place, false, true, ptr->flags ) );
838
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "name" ,"html")), team_buf.numb );
833
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "name" ,"html")), team_buf.numb );
839
        print( "%4d",  team_buf.numb );
834
        print( "%4d",  team_buf.numb );
840
        if ( report_html == html ) print( "</A>" );
835
        if ( report_html == html ) print( "</A>" );
841
 
836
 
842
        print( " %-*s", 3, team_buf.teamclass == 0 ? "" : config.team_class[team_buf.teamclass - 1].abr );
837
        print( " %-*s", 3, team_buf.teamclass == 0 ? "" : config.team_class[team_buf.teamclass - 1].abr );
Line 848... Line 843...
848
        **      - End place
843
        **      - End place
849
        */
844
        */
850
        for( j = 1; j <= config.num_legs; j++ )
845
        for( j = 1; j <= config.num_legs; j++ )
851
        {
846
        {
852
            bool isEquestrianLeg = (j == config.equestrian_leg && team_buf.flags.non_equestrian);
847
            bool isEquestrianLeg = (j == config.equestrian_leg && team_buf.flags.non_equestrian);
853
            bool afterEquestrianLeg = (team_buf.flags.non_equestrian && j > config.equestrian_leg);
-
 
-
 
848
 
854
            /*
849
            /*
855
            **  Ensure that non-equestrian leg data is not displayed
850
            **  Ensure that non-equestrian leg data is not displayed
856
            */
851
            */
857
            if ( isEquestrianLeg )
852
            if ( isEquestrianLeg )
858
            {
853
            {
Line 860... Line 855...
860
            }
855
            }
861
            else
856
            else
862
            {
857
            {
863
                print( "  %-8s %4.4s %4.4s",
858
                print( "  %-8s %4.4s %4.4s",
864
                    time_a( team_buf.leg[j].elapsed ),
859
                    time_a( team_buf.leg[j].elapsed ),
865
                    pr_place( team_buf.leg[j].l_place, ptr->flags.bad_times, ptr->flags.vet_check && (j == 0) ),
860
                    px_place( j, team_buf.leg[j].l_place, false, false, ptr->flags ),
866
                    pn_place( team_buf.leg[j].le_place,ptr->flags.bad_times, ptr->flags.vet_check && (j == 0), afterEquestrianLeg )
861
                    px_place( j, team_buf.leg[j].le_place,true , true, ptr->flags )
867
                  );
862
                  );
868
            }
863
            }
869
        }
864
        }
870
 
865
 
871
       /*
866
       /*
Line 875... Line 870...
875
        */
870
        */
876
//        print( "  %-8s ",  time_a( team_buf.leg[0].elapsed ) );
871
//        print( "  %-8s ",  time_a( team_buf.leg[0].elapsed ) );
877
        print( "  %-8s ", time_a( ptr->lege[0] ) );
872
        print( "  %-8s ", time_a( ptr->lege[0] ) );
878
        
873
        
879
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">",url_encode(p_filename(filebase, config.team_class[team_buf.teamclass - 1].abr ,"html")), team_buf.numb );
874
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">",url_encode(p_filename(filebase, config.team_class[team_buf.teamclass - 1].abr ,"html")), team_buf.numb );
880
        print( "%-4.4s", pn_place( team_buf.leg[0].lc_place, ptr->flags.bad_times, ptr->flags.vet_check, ptr->flags.non_equestrian && 0 ) );
875
        print( "%-4.4s", px_place( 0, team_buf.leg[0].lc_place, false, false, ptr->flags) );
881
        if ( report_html == html ) print( "</A>" );
876
        if ( report_html == html ) print( "</A>" );
882
        if ( report_html == printed && lcount %5 == 4 ) print_underline( FALSE );
877
        if ( report_html == printed && lcount %5 == 4 ) print_underline( FALSE );
883
        lcount++;
878
        lcount++;
884
        print( "\n" );
879
        print( "\n" );
885
    }
880
    }
Line 980... Line 975...
980
        **      - Team number - with HTML reference to team file
975
        **      - Team number - with HTML reference to team file
981
        **      - Class
976
        **      - Class
982
        */
977
        */
983
 
978
 
984
        if ( report_html == printed && lcount %5 == 4 ) print_underline( TRUE );
979
        if ( report_html == printed && lcount %5 == 4 ) print_underline( TRUE );
985
        print( "%4.4s ", pn_place( team_buf.leg[0].lc_place, flags , ptr->flags.vet_check, eflags ) );
980
        print( "%4.4s ", px_place( 0, team_buf.leg[0].lc_place, false, false, ptr->flags) );
986
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "name" ,"html")), team_buf.numb );
981
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "name" ,"html")), team_buf.numb );
987
        print( "%4d",  team_buf.numb );
982
        print( "%4d",  team_buf.numb );
988
        if ( report_html == html ) print( "</A>" );
983
        if ( report_html == html ) print( "</A>" );
989
        print( " %-*s", 3, team_buf.teamclass == 0 ? "" : config.team_class[team_buf.teamclass - 1].abr );
984
        print( " %-*s", 3, team_buf.teamclass == 0 ? "" : config.team_class[team_buf.teamclass - 1].abr );
990
 
985
 
991
        for( j = 1; j <= config.num_legs; j++ )
986
        for( j = 1; j <= config.num_legs; j++ )
992
        {
987
        {
993
            bool isEquestrianLeg = (j == config.equestrian_leg && (ptr->teamclass == config.nonequestrian_class || ptr->flags.non_equestrian));
988
            bool isEquestrianLeg = (j == config.equestrian_leg && (ptr->teamclass == config.nonequestrian_class || ptr->flags.non_equestrian));
994
            bool afterEquestrianLeg = ((ptr->teamclass == config.nonequestrian_class || ptr->flags.non_equestrian) && j > config.equestrian_leg);
-
 
995
 
989
 
996
            /*
990
            /*
997
            **  Ensure that non-equestrian leg data is not displayed
991
            **  Ensure that non-equestrian leg data is not displayed
998
            */
992
            */
999
            if ( isEquestrianLeg )
993
            if ( isEquestrianLeg )
Line 1001... Line 995...
1001
                print( "  %-8s %4.4s %4.4s", "-- NE --", "NE","NE");
995
                print( "  %-8s %4.4s %4.4s", "-- NE --", "NE","NE");
1002
            }
996
            }
1003
            else
997
            else
1004
            {
998
            {
1005
                print( "  %-8s %4.4s %4.4s", time_a( team_buf.leg[j].elapsed ),
999
                print( "  %-8s %4.4s %4.4s", time_a( team_buf.leg[j].elapsed ),
1006
                       pr_place( team_buf.leg[j].lc_place,  flags, ptr->flags.vet_check && (j == 0) ),
1000
                       px_place( j, team_buf.leg[j].lc_place,  false, false, ptr->flags ),
1007
                       pn_place( team_buf.leg[j].lec_place, flags, ptr->flags.vet_check && (j == 0), afterEquestrianLeg ) );
1001
                       px_place( j, team_buf.leg[j].lec_place, true , true, ptr->flags ) );
1008
            }
1002
            }
1009
        }
1003
        }
1010
 
1004
 
1011
        /*
1005
        /*
1012
        **  Print the trailer
1006
        **  Print the trailer
Line 1015... Line 1009...
1015
        */
1009
        */
1016
        /* print( "  %-8s ", time_a( team_buf.leg[0].elapsed ) ); */
1010
        /* print( "  %-8s ", time_a( team_buf.leg[0].elapsed ) ); */
1017
        print( "  %-8s ", time_a( ptr->lege[0] ) );
1011
        print( "  %-8s ", time_a( ptr->lege[0] ) );
1018
 
1012
 
1019
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "finish" ,"html")), team_buf.numb );
1013
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "finish" ,"html")), team_buf.numb );
1020
        print( "%4.4s", pn_place( team_buf.leg[0].l_place, flags , ptr->flags.vet_check, ptr->flags.non_equestrian));
1014
        print( "%4.4s", px_place( 0, team_buf.leg[0].l_place, false, true, ptr->flags));
1021
        if ( report_html == html ) print( "</A>" );
1015
        if ( report_html == html ) print( "</A>" );
1022
 
1016
 
1023
        if ( report_html == printed && lcount %5 == 4 ) print_underline( FALSE );
1017
        if ( report_html == printed && lcount %5 == 4 ) print_underline( FALSE );
1024
        lcount++;
1018
        lcount++;
1025
        print( "\n" );
1019
        print( "\n" );
Line 1079... Line 1073...
1079
    pri_name_index_body();
1073
    pri_name_index_body();
1080
}
1074
}
1081
 
1075
 
1082
/*========================================================================
1076
/*========================================================================
1083
 *
1077
 *
1084
 *  Print final results
1078
 *  Print final results in Team Order
1085
 *
1079
 *
1086
 *  Purpose:
1080
 *  Purpose:
1087
 *      This function is called to Print final results in Team Order
1081
 *      This function is called to Print final results in Team Order
1088
 *
1082
 *
1089
 *  Parameters:
1083
 *  Parameters:
Line 1100... Line 1094...
1100
    team_type   team_buf;
1094
    team_type   team_buf;
1101
    unsigned    i;
1095
    unsigned    i;
1102
    int         j;
1096
    int         j;
1103
    int         lcount;
1097
    int         lcount;
1104
 
1098
 
1105
    if( ck_data( -1, C_ELAPSED ) )
1099
    ck_data( -1, C_ELAPSED );
1106
        return;
1100
 
1107
    /*
1101
    /*
1108
    **  Sort on every thing
1102
    **  Sort on every thing
1109
    **  Then generate all the stats too
1103
    **  Then generate all the stats too
1110
    */
1104
    */
1111
    do_big_sort();
1105
    do_big_sort();
Line 1155... Line 1149...
1155
        **      - Place within complete field
1149
        **      - Place within complete field
1156
        **      - Team number - with HTML reference to team file
1150
        **      - Team number - with HTML reference to team file
1157
        **      - Class
1151
        **      - Class
1158
        */
1152
        */
1159
        if ( report_html == printed && lcount %5 == 4 ) print_underline( TRUE );
1153
        if ( report_html == printed && lcount %5 == 4 ) print_underline( TRUE );
1160
        print( "%4.4s ", pn_place( team_buf.leg[0].l_place, ptr->flags.bad_times, ptr->flags.vet_check, ptr->flags.non_equestrian ) );
1154
        print( "%4.4s ", px_place( 0, team_buf.leg[0].l_place, false, true, ptr->flags ) );
1161
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "name" ,"html")), team_buf.numb );
1155
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "name" ,"html")), team_buf.numb );
1162
        print( "%4d",  team_buf.numb );
1156
        print( "%4d",  team_buf.numb );
1163
        if ( report_html == html ) print( "</A>" );
1157
        if ( report_html == html ) print( "</A>" );
1164
 
1158
 
1165
        print( " %-*s", 3, team_buf.teamclass == 0 ? "" : config.team_class[team_buf.teamclass - 1].abr );
1159
        print( " %-*s", 3, team_buf.teamclass == 0 ? "" : config.team_class[team_buf.teamclass - 1].abr );
Line 1171... Line 1165...
1171
        **      - End place
1165
        **      - End place
1172
        */
1166
        */
1173
        for( j = 1; j <= config.num_legs; j++ )
1167
        for( j = 1; j <= config.num_legs; j++ )
1174
        {
1168
        {
1175
            bool isEquestrianLeg = (j == config.equestrian_leg && team_buf.flags.non_equestrian);
1169
            bool isEquestrianLeg = (j == config.equestrian_leg && team_buf.flags.non_equestrian);
1176
            bool afterEquestrianLeg = (team_buf.flags.non_equestrian && j > config.equestrian_leg);
-
 
1177
            /*
1170
            /*
1178
            **  Ensure that non-equestrian leg data is not displayed
1171
            **  Ensure that non-equestrian leg data is not displayed
1179
            */
1172
            */
1180
            if ( isEquestrianLeg )
1173
            if ( isEquestrianLeg )
1181
            {
1174
            {
Line 1183... Line 1176...
1183
            }
1176
            }
1184
            else
1177
            else
1185
            {
1178
            {
1186
                print( "  %-8s %4.4s %4.4s",
1179
                print( "  %-8s %4.4s %4.4s",
1187
                    time_a( team_buf.leg[j].elapsed ),
1180
                    time_a( team_buf.leg[j].elapsed ),
1188
                    pr_place( team_buf.leg[j].l_place, ptr->flags.bad_times, ptr->flags.vet_check && (j == 0) ),
1181
                    px_place(j, team_buf.leg[j].l_place, false, false, ptr->flags ),
1189
                    pn_place( team_buf.leg[j].le_place,ptr->flags.bad_times, ptr->flags.vet_check && (j == 0), afterEquestrianLeg )
1182
                    px_place(j, team_buf.leg[j].le_place,true,  true, ptr->flags )
1190
                  );
1183
                  );
1191
            }
1184
            }
1192
        }
1185
        }
1193
 
1186
 
1194
       /*
1187
       /*
Line 1198... Line 1191...
1198
        */
1191
        */
1199
//        print( "  %-8s ",  time_a( team_buf.leg[0].elapsed ) );
1192
//        print( "  %-8s ",  time_a( team_buf.leg[0].elapsed ) );
1200
        print( "  %-8s ", time_a( ptr->lege[0] ) );
1193
        print( "  %-8s ", time_a( ptr->lege[0] ) );
1201
        
1194
        
1202
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">",url_encode(p_filename(filebase, config.team_class[team_buf.teamclass - 1].abr ,"html")), team_buf.numb );
1195
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">",url_encode(p_filename(filebase, config.team_class[team_buf.teamclass - 1].abr ,"html")), team_buf.numb );
1203
        print( "%-4.4s", pn_place( team_buf.leg[0].lc_place, ptr->flags.bad_times, ptr->flags.vet_check, ptr->flags.non_equestrian && 0 ) );
1196
        print( "%-4.4s", px_place( 0, team_buf.leg[0].lc_place, false, false, ptr->flags ) );
1204
        if ( report_html == html ) print( "</A>" );
1197
        if ( report_html == html ) print( "</A>" );
1205
        if ( report_html == printed && lcount %5 == 4 ) print_underline( FALSE );
1198
        if ( report_html == printed && lcount %5 == 4 ) print_underline( FALSE );
1206
        lcount++;
1199
        lcount++;
1207
        print( "\n" );
1200
        print( "\n" );
1208
    }
1201
    }
Line 1992... Line 1985...
1992
 
1985
 
1993
        g_record( ptr->team, &team_buf );
1986
        g_record( ptr->team, &team_buf );
1994
 
1987
 
1995
        print( "%4d %4.4s %-*s",
1988
        print( "%4d %4.4s %-*s",
1996
               team_buf.numb,
1989
               team_buf.numb,
1997
               pi_place( team_buf.leg[config.num_legs].le_place,
1990
               px_place(-1, team_buf.leg[config.num_legs].le_place, false, false, ptr->flags ),
1998
                         ptr->flags.disqualified, team_buf.leg[0].elapsed ),
-
 
1999
               3,
1991
               3,
2000
               team_buf.teamclass ==
-
 
2001
               0 ? "" : config.team_class[team_buf.teamclass - 1].abr );
1992
               team_buf.teamclass == 0 ? "" : config.team_class[team_buf.teamclass - 1].abr );
-
 
1993
 
2002
        for( j = 1; j <= config.num_legs; j++ )
1994
        for( j = 1; j <= config.num_legs; j++ )
2003
        {
1995
        {
2004
            print( "  %-8s %4.4s %4.4s",
1996
            print( "  %-8s %4.4s %4.4s",
2005
                   time_fa( team_buf.leg[j].elapsed,
1997
                   time_fa( team_buf.leg[j].elapsed, ptr->flags.disqualified ),
2006
                            ptr->flags.disqualified ),
-
 
2007
                   pi_place( team_buf.leg[j].l_place, ptr->flags.disqualified,
1998
                   px_place(j, team_buf.leg[j].l_place, false, true, ptr->flags ),
2008
                             team_buf.leg[j].elapsed ),
-
 
2009
                   pi_place( team_buf.leg[j].le_place,
1999
                   px_place(j, team_buf.leg[j].le_place, false, true, ptr->flags )
2010
                             ptr->flags.disqualified,
2000
                   );
2011
                             team_buf.leg[j].elapsed ) );
-
 
2012
        }
2001
        }
2013
        print( "  %-8s %4.4s\n",
2002
        print( "  %-8s %4.4s\n",
2014
               time_fa( team_buf.leg[0].elapsed, ptr->flags.disqualified ),
2003
               time_fa( team_buf.leg[0].elapsed, ptr->flags.disqualified ),
2015
               pi_place( team_buf.leg[config.num_legs].lec_place,
2004
               px_place(0, team_buf.leg[config.num_legs].lec_place, false, false, ptr->flags )
2016
                         ptr->flags.disqualified, team_buf.leg[0].elapsed ) );
2005
               );
2017
    }
2006
    }
2018
 
2007
 
2019
    print_class_stats( -1, FALSE );             /* Print statistics */
2008
    print_class_stats( -1, FALSE );             /* Print statistics */
2020
    print_legend(-1, 1);                        /* Print the legend */
2009
    print_legend(-1, 1);                        /* Print the legend */
2021
    close_printer();                            /* Close the printer */
2010
    close_printer();                            /* Close the printer */
Line 2057... Line 2046...
2057
        **  Now read in the team record
2046
        **  Now read in the team record
2058
        */
2047
        */
2059
        g_record( ptr->team, &team_buf );
2048
        g_record( ptr->team, &team_buf );
2060
        print( "%4d %4.4s %-*s",
2049
        print( "%4d %4.4s %-*s",
2061
               team_buf.numb,
2050
               team_buf.numb,
2062
               pi_place( team_buf.leg[config.num_legs].lec_place,
2051
               px_place(-1, team_buf.leg[config.num_legs].lec_place, false, false, ptr->flags ),
2063
                         ptr->flags.disqualified, team_buf.leg[0].elapsed ),
-
 
2064
               3,
2052
               3,
2065
               team_buf.teamclass ==
-
 
2066
               0 ? "" : config.team_class[team_buf.teamclass - 1].abr );
2053
               team_buf.teamclass == 0 ? "" : config.team_class[team_buf.teamclass - 1].abr );
-
 
2054
 
2067
        for( j = 1; j <= config.num_legs; j++ )
2055
        for( j = 1; j <= config.num_legs; j++ )
2068
        {
2056
        {
2069
            print( "  %-8s %4.4s %4.4s",
2057
            print( "  %-8s %4.4s %4.4s",
2070
                   time_fa( team_buf.leg[j].elapsed,
2058
                   time_fa( team_buf.leg[j].elapsed, ptr->flags.disqualified ),
2071
                            ptr->flags.disqualified ),
-
 
2072
                   pi_place( team_buf.leg[j].lc_place,
2059
                   px_place(j, team_buf.leg[j].lc_place,  false, true, ptr->flags ),
2073
                             ptr->flags.disqualified,
-
 
2074
                             team_buf.leg[j].elapsed ),
-
 
2075
                   pi_place( team_buf.leg[j].lec_place,
2060
                   px_place(j, team_buf.leg[j].lec_place, false, true, ptr->flags ) );
2076
                             ptr->flags.disqualified,
-
 
2077
                             team_buf.leg[j].elapsed ) );
-
 
2078
        }
2061
        }
2079
        print( "  %-8s %4.4s\n",
2062
        print( "  %-8s %4.4s\n",
2080
               time_fa( team_buf.leg[0].elapsed, ptr->flags.disqualified ),
2063
               time_fa( team_buf.leg[0].elapsed, ptr->flags.disqualified ),
2081
               pi_place( team_buf.leg[config.num_legs].le_place,
2064
               px_place(0, team_buf.leg[config.num_legs].le_place, false, false, ptr->flags ) );
2082
                         ptr->flags.disqualified, team_buf.leg[0].elapsed ) );
-
 
2083
    }
2065
    }
2084
 
2066
 
2085
    print_class_stats( last_class, FALSE );
2067
    print_class_stats( last_class, FALSE );
2086
    print_legend(last_class, 1);
2068
    print_legend(last_class, 1);
2087
    close_printer();
2069
    close_printer();
Line 2324... Line 2306...
2324
    pri_summary();
2306
    pri_summary();
2325
    pri_awards_html();
2307
    pri_awards_html();
2326
    pri_awards();
2308
    pri_awards();
2327
    pri_master_index();
2309
    pri_master_index();
2328
 
2310
 
-
 
2311
    report_html = html;
-
 
2312
    pri_interim();
-
 
2313
    report_html = text;
2329
    pri_interim();
2314
    pri_interim();
2330
 
2315
 
2331
    report_all = FALSE;
2316
    report_all = FALSE;
2332
}
2317
}
2333
 
2318
 
Line 2518... Line 2503...
2518
 
2503
 
2519
    for( i = 1, count = 0; i <= config.num_class; i++ )
2504
    for( i = 1, count = 0; i <= config.num_class; i++ )
2520
    {
2505
    {
2521
        if (!config.team_class[i - 1].abr[0])
2506
        if (!config.team_class[i - 1].abr[0])
2522
            continue;
2507
            continue;
2523
#if 0
2508
 
2524
        /*
-
 
2525
        **  Skip any non-equestrian class in the legend
-
 
2526
        **  Don't want to tell the general user whats goes on, unless we actually
-
 
2527
        **  creating the non-equestrian report.
-
 
2528
        */
-
 
2529
        if ( class != config.nonequestrian_class  && i == config.nonequestrian_class )
-
 
2530
            continue;
-
 
2531
#endif
-
 
2532
        if ( report_html == html ) print( "<A HREF=\"%s\">",url_encode(p_filename(filebase, config.team_class[i - 1].abr ,"html")) );
2509
        if ( report_html == html ) print( "<A HREF=\"%s\">",url_encode(p_filename(filebase, config.team_class[i - 1].abr ,"html")) );
2533
        print( "%-*s", 3, config.team_class[i - 1].abr );
2510
        print( "%-*s", 3, config.team_class[i - 1].abr );
2534
        if ( report_html == html ) print( "</A>" );
2511
        if ( report_html == html ) print( "</A>" );
2535
        print( " : %-*s  ", LEN_CLASS_NAME, config.team_class[i - 1].full_name );
2512
        print( " : %-*s  ", LEN_CLASS_NAME, config.team_class[i - 1].full_name );
2536
 
2513
 
Line 2607... Line 2584...
2607
        print( "\nTiming and Results by\n" );
2584
        print( "\nTiming and Results by\n" );
2608
        print( "Embedded Solutions\n" );
2585
        print( "Embedded Solutions\n" );
2609
    }
2586
    }
2610
}
2587
}
2611
 
2588
 
2612
/*========================================================================
-
 
2613
 *
-
 
2614
 *  Return place data
-
 
2615
 *
-
 
2616
 *  Purpose:
-
 
2617
 *      This function is called to return place data
-
 
2618
 *
-
 
2619
 *      This routine is called to fill a print team_buffer - to allow for
-
 
2620
 *      multiple calls to this function ( before the data is used ) a number
-
 
2621
 *      of static team_buffers are maintained
-
 
2622
 *
-
 
2623
 *  Parameters:
-
 
2624
 *      num         place - if a valid time
-
 
2625
 *      disq        Disqualified flag
-
 
2626
 *      time        Time data is based on
-
 
2627
 *
-
 
2628
 *  Returns:
-
 
2629
 *      This function returns a pointer to the character string for the
-
 
2630
 *      number or a pointer to a status string.
-
 
2631
 *
-
 
2632
 *========================================================================*/
-
 
2633
 
-
 
2634
const char       *pi_place( int num, int disq, time_t time )
-
 
2635
{
-
 
2636
    static char store[2][5];                     /* 2 stores for 4 digit numbers */
-
 
2637
    static int  i = 0;                           /* Current index into store */
-
 
2638
    static const char *dis = "D";                /* Disqualified */
-
 
2639
    static const char *non = "-";                /* Invalid time */
-
 
2640
 
-
 
2641
    if( disq )                                   /* Disqualified team */
-
 
2642
        return ( dis );
-
 
2643
    if( time <= 0 )                              /* Unknown time */
-
 
2644
        return ( non );
-
 
2645
 
-
 
2646
    i++;
-
 
2647
    if( i >= 2 )
-
 
2648
        i = 0;                                   /* Select next entry */
-
 
2649
    sprintf( store[i], "%4d", num );
-
 
2650
    return ( store[i] );
-
 
2651
 
-
 
2652
}
-
 
2653
 
2589
 
2654
/*========================================================================
2590
/*========================================================================
2655
 *
2591
 *
2656
 *  Return place data
2592
 *  Return place data or NE flag
2657
 *
2593
 *
2658
 *  Purpose:
2594
 *  Purpose:
2659
 *      This function is called to Return place data
2595
 *      This function is called to Return place data
2660
 *
2596
 *
2661
 *      This routine is called to fill a print team_buffer - to allow for
2597
 *      This routine is called to fill a print team_buffer - to allow for
2662
 *      multiple calls to this function ( before the data is used ) a number
2598
 *      multiple calls to this function ( before the data is used ) a number
2663
 *      of static team_buffers are maintained
2599
 *      of static team_buffers are maintained
2664
 *
2600
 *
2665
 *  Parameters:
2601
 *  Parameters:
-
 
2602
 *      leg         Leg number being processed or
-
 
2603
 *                  -1: Unplaced on any bad flag
2666
 *      num         place - if valid
2604
 *      num         place - if valid time
-
 
2605
 *      epMode      true:  Event Time Mode - Show V and NE flags
2667
 *      disq        Disqualified flag
2606
 *                  false: Leg Time Mode -
-
 
2607
 *      neMode      true: Display NE for NE Teams
-
 
2608
 *                  false: Display data for NE teams
2668
 *      vflag       Team is vet checked
2609
 *      flags       Team flags
2669
 *
2610
 *
2670
 *  Returns:
2611
 *  Returns:
2671
 *      This function returns a pointer to the character string for the
2612
 *      This function returns a pointer to the character string for the
2672
 *      number or a pointer to a status string.
2613
 *      number or a pointer to a status string.
2673
 *
2614
 *
2674
 *========================================================================*/
2615
 *========================================================================*/
2675
 
-
 
2676
const char *pr_place( int num, int disq, bool vflag )
2616
const char *px_place( int leg, int num, bool epMode, bool neMode, team_flags flags )
2677
{
2617
{
2678
    static char store[2][5];                     /* 2 stores for 4 digit numbers */
2618
    static char store[2][5];                     /* 2 stores for 4 digit numbers */
2679
    static int  i = 0;                           /* Current index into store */
2619
    static int  i = 0;                           /* Current index into store */
2680
    static const char *dis = "U";
2620
    static const char *dis = "U";
-
 
2621
    static const char *alt = "NE";
2681
    static const char *vet = "V";
2622
    static const char *vet = "V";
2682
 
2623
 
2683
    if (vflag)
2624
    if (flags.bad_times || flags.disqualified || !flags.valid)
2684
        return (vet);
2625
        return dis;
2685
 
2626
 
2686
    if( disq )
2627
    if (leg == -1 && flags.vet_check )
2687
        return ( dis );
2628
        return vet;
2688
 
2629
 
2689
    i++;
-
 
2690
    if( i >= 2 )
-
 
2691
        i = 0;                                   /* Select next entry */
2630
    if (neMode && flags.non_equestrian && (leg >= config.equestrian_leg || leg == 0))
2692
    sprintf( store[i], "%4d", num );
-
 
2693
    return ( store[i] );
2631
        return alt;
2694
 
2632
 
-
 
2633
    if (epMode && flags.vet_check && leg >= config.equestrian_leg)
2695
}
2634
        return vet;
2696
 
2635
 
2697
/*========================================================================
-
 
2698
 *
-
 
2699
 *  Return place data or NE flag
-
 
2700
 *
-
 
2701
 *  Purpose:
-
 
2702
 *      This function is called to Return place data
-
 
2703
 *
-
 
2704
 *      This routine is called to fill a print team_buffer - to allow for
-
 
2705
 *      multiple calls to this function ( before the data is used ) a number
2636
    if ( flags.vet_check && (leg == config.equestrian_leg || leg == 0))
2706
 *      of static team_buffers are maintained
-
 
2707
 *
-
 
2708
 *  Parameters:
-
 
2709
 *      num         place - if valid time
-
 
2710
 *      disq        Disqualified flag
-
 
2711
 *      vflag       Flag VetChecked team
-
 
2712
 *      flag        Flag NE data
-
 
2713
 *
-
 
2714
 *  Returns:
2637
        return vet;
2715
 *      This function returns a pointer to the character string for the
-
 
2716
 *      number or a pointer to a status string.
-
 
2717
 *
-
 
2718
 *========================================================================*/
-
 
2719
const char *pn_place( int num, int disq, bool vflag, bool flag )
-
 
2720
{
-
 
2721
    static char store[2][5];                     /* 2 stores for 4 digit numbers */
-
 
2722
    static int  i = 0;                           /* Current index into store */
-
 
2723
    static const char *dis = "U";
-
 
2724
    static const char *alt = "NE";
-
 
2725
    static const char *vet = "V";
-
 
2726
 
2638
 
2727
    if (vflag)
-
 
2728
        return (vet);
-
 
2729
    if( disq )
2639
    if (num <= 0)
2730
        return ( dis );
2640
        return dis;
2731
    if (flag)
-
 
2732
        return ( alt );
-
 
2733
 
2641
 
2734
    i++;
2642
    i++;
2735
    if( i >= 2 )
2643
    if( i >= 2 )
2736
        i = 0;                                   /* Select next entry */
2644
        i = 0;                                   /* Select next entry */
2737
    sprintf( store[i], "%4d", num );
2645
    sprintf( store[i], "%4d", num );
Line 2756... Line 2664...
2756
 *      mode            Either end or elapsed times to be tested
2664
 *      mode            Either end or elapsed times to be tested
2757
 *                          C_END     - Printing in Leg Finishing Time
2665
 *                          C_END     - Printing in Leg Finishing Time
2758
 *                          C_DISQUAL - Interim results
2666
 *                          C_DISQUAL - Interim results
2759
 *                          C_ELAPSED - Elapsed times
2667
 *                          C_ELAPSED - Elapsed times
2760
 *
2668
 *
2761
 *  Returns:
-
 
2762
 *      Returns FALSE if the report operation is to be aborted
-
 
2763
 *
2669
 *
2764
 *========================================================================*/
2670
 *========================================================================*/
2765
 
2671
 
2766
bool ck_data( int leg, int mode )
2672
void ck_data( int leg, int mode )
2767
{
2673
{
2768
    ty_s_data  *ptr;
2674
    ty_s_data  *ptr;
2769
    unsigned    i;
2675
    unsigned    i;
2770
    int         bad = 0;
2676
    int         bad = 0;
2771
    int         k;
2677
    int         k;
Line 2789... Line 2695...
2789
 
2695
 
2790
 
2696
 
2791
        // If the team is duff, then don;t include in Event or Leg Calcs
2697
        // If the team is duff, then don;t include in Event or Leg Calcs
2792
        if( !ptr->flags.valid || ptr->flags.bad_times || ptr->flags.disqualified)
2698
        if( !ptr->flags.valid || ptr->flags.bad_times || ptr->flags.disqualified)
2793
        {
2699
        {
2794
            ptr->flags.notInEP = TRUE;
-
 
2795
            ptr->flags.notInLP = TRUE;
2700
            ptr->flags.notInLP = TRUE;
2796
        }
2701
        }
2797
        else
2702
        else
2798
        {
2703
        {
2799
            // If any of the leg times are duff, then don't include the leg Event Calcs
2704
            // If any of the leg times are duff, then don't include the leg Event Calcs
Line 2811... Line 2716...
2811
                bad_leg = t[leg] <= 0;
2716
                bad_leg = t[leg] <= 0;
2812
            }
2717
            }
2813
 
2718
 
2814
            if( bad_leg )
2719
            if( bad_leg )
2815
            {
2720
            {
2816
                ptr->flags.notInEP = TRUE;
-
 
2817
                
-
 
2818
                if ( ! report_all )
2721
                if ( ! report_all )
2819
                {
2722
                {
2820
                    qDebug( "Team with incorrect time information: %d", ptr->team  );
2723
                    qDebug( "Team with incorrect time information: %d", ptr->team  );
2821
                    bad++;
2724
                    bad++;
2822
                }
2725
                }
Line 2826... Line 2729...
2826
 
2729
 
2827
    if( bad )
2730
    if( bad )
2828
    {
2731
    {
2829
        qDebug( "%d teams with incorrect times. These have been flagged as unplaced", bad );
2732
        qDebug( "%d teams with incorrect times. These have been flagged as unplaced", bad );
2830
    }
2733
    }
2831
    return ( FALSE );
-
 
2832
}
2734
}
2833
 
2735
 
2834
/*========================================================================
2736
/*========================================================================
2835
 *
2737
 *
2836
 *  Update placing information
2738
 *  Update placing information
Line 2855... Line 2757...
2855
 *
2757
 *
2856
 *========================================================================*/
2758
 *========================================================================*/
2857
 
2759
 
2858
void srt_place(void)
2760
void srt_place(void)
2859
{
2761
{
2860
    if( ck_data( -1, C_ELAPSED ) )
2762
    ck_data( -1, C_ELAPSED );
2861
        return;
-
 
2862
    do_big_sort();
2763
    do_big_sort();
2863
 
2764
 
2864
    /*
2765
    /*
2865
     * Generate the stats
2766
     * Generate the stats
2866
     */
2767
     */
Line 3116... Line 3017...
3116
        sort_team_data( i, S_L, sortWithEq );
3017
        sort_team_data( i, S_L, sortWithEq );
3117
        for( j = 1, k = 1, q = 1, ptr = sort_data; j <= sort_num; ptr++, j++ )
3018
        for( j = 1, k = 1, q = 1, ptr = sort_data; j <= sort_num; ptr++, j++ )
3118
        {
3019
        {
3119
            sort_aux[ptr->team].team = ptr->team;
3020
            sort_aux[ptr->team].team = ptr->team;
3120
 
3021
 
-
 
3022
            if (i == config.equestrian_leg || i == 0) {
-
 
3023
                if (ptr->flags.bad_times || ptr->flags.disqualified || ptr->flags.vet_check) {
-
 
3024
                    if (ptr->isNeData) {
-
 
3025
                        sort_aux[ptr->team].lq_place[i] = -1;
-
 
3026
                    } else {
-
 
3027
                        sort_aux[ptr->team].l_place[i] = -1;
-
 
3028
                    }
-
 
3029
                    continue;
-
 
3030
                }
-
 
3031
            }
-
 
3032
 
-
 
3033
            // Flag as unplaced NE teams on the EQ leg
-
 
3034
            // Flag as unplaced in overall (leg:0) NE teams
-
 
3035
            if ( (i == config.equestrian_leg || i == 0 ) && ptr->flags.non_equestrian ) {
-
 
3036
                if (ptr->isNeData) {
-
 
3037
                    sort_aux[ptr->team].lq_place[i] = -1;
-
 
3038
                } else {
-
 
3039
                    sort_aux[ptr->team].l_place[i] = -1;
-
 
3040
                }
-
 
3041
                continue;
-
 
3042
            }
-
 
3043
 
3121
            if (ptr->isNeData) {
3044
            if (ptr->isNeData) {
3122
                sort_aux[ptr->team].lq_place[i] = q++;
3045
                sort_aux[ptr->team].lq_place[i] = q++;
3123
            } else {
3046
            } else {
3124
                sort_aux[ptr->team].l_place[i] = k++;
3047
                sort_aux[ptr->team].l_place[i] = k++;
3125
            }
3048
            }
Line 3130... Line 3053...
3130
        **  Then save the teams place at the end of each leg
3053
        **  Then save the teams place at the end of each leg
3131
        */
3054
        */
3132
        sort_team_data( i, S_LE, sortWithEq);
3055
        sort_team_data( i, S_LE, sortWithEq);
3133
        for( j = 1, k = 1, q = 1, ptr = sort_data; j <= sort_num; ptr++, j++ )
3056
        for( j = 1, k = 1, q = 1, ptr = sort_data; j <= sort_num; ptr++, j++ )
3134
        {
3057
        {
-
 
3058
            if (i == 0 || i == config.equestrian_leg || sort_afterEquestrianLeg ) {
-
 
3059
                if (ptr->flags.bad_times || ptr->flags.disqualified || ptr->flags.vet_check) {
-
 
3060
                    if (ptr->isNeData) {
-
 
3061
                        sort_aux[ptr->team].leq_place[i] = -1;
-
 
3062
                    } else {
-
 
3063
                        sort_aux[ptr->team].le_place[i] = -1;
-
 
3064
                    }
-
 
3065
                    continue;
-
 
3066
                }
-
 
3067
            }
-
 
3068
 
-
 
3069
            // Flag as unplaced NE teams on the EQ leg
-
 
3070
            // Flag as unplaced NE teams after the EQ leg
-
 
3071
            // Flag as unplaced in overall (leg:0) NE teams
-
 
3072
            if ( (i == config.equestrian_leg || sort_afterEquestrianLeg || i == 0 ) && ptr->flags.non_equestrian ) {
-
 
3073
                if (ptr->isNeData) {
-
 
3074
                    sort_aux[ptr->team].leq_place[i] = -1;
-
 
3075
                } else {
-
 
3076
                    sort_aux[ptr->team].le_place[i] = -1;
-
 
3077
                }
-
 
3078
                continue;
-
 
3079
            }
-
 
3080
 
3135
            if (ptr->isNeData) {
3081
            if (ptr->isNeData) {
3136
                sort_aux[ptr->team].leq_place[i] = q++;
3082
                sort_aux[ptr->team].leq_place[i] = q++;
3137
            } else {
3083
            } else {
3138
                sort_aux[ptr->team].le_place[i] = k++;
3084
                sort_aux[ptr->team].le_place[i] = k++;
3139
            }
3085
            }
Line 3156... Line 3102...
3156
            else {
3102
            else {
3157
                if (ptr->isNeData)
3103
                if (ptr->isNeData)
3158
                    isNe = true;
3104
                    isNe = true;
3159
            }
3105
            }
3160
 
3106
 
-
 
3107
            // Flag as unplaced NE teams on the EQ leg
-
 
3108
            if (i == 0 || i == config.equestrian_leg) {
-
 
3109
                if (ptr->flags.bad_times || ptr->flags.disqualified || ptr->flags.vet_check) {
-
 
3110
                    if (isNe) {
-
 
3111
                        sort_aux[ptr->team].lq_place[i] = -1;
-
 
3112
                    } else {
-
 
3113
                        sort_aux[ptr->team].lc_place[i] = -1;
-
 
3114
                    }
-
 
3115
                    continue;
-
 
3116
                }
-
 
3117
            }
-
 
3118
 
-
 
3119
            if ( i == config.equestrian_leg && ptr->flags.non_equestrian ) {
-
 
3120
                if (ptr->isNeData) {
-
 
3121
                    sort_aux[ptr->team].lq_place[i] = -1;
-
 
3122
                } else {
-
 
3123
                    sort_aux[ptr->team].lc_place[i] = -1;
-
 
3124
                }
-
 
3125
                continue;
-
 
3126
            }
-
 
3127
 
3161
            if (isNe) {
3128
            if (isNe) {
3162
                if( teamclassq != ptr->teamclass )
3129
                if( teamclassq != ptr->teamclass )
3163
                {
3130
                {
3164
                    q = 1;
3131
                    q = 1;
3165
                    teamclassq = ptr->teamclass;
3132
                    teamclassq = ptr->teamclass;
Line 3174... Line 3141...
3174
                    k = 1;
3141
                    k = 1;
3175
                    teamclass = ptr->teamclass;
3142
                    teamclass = ptr->teamclass;
3176
                }
3143
                }
3177
                sort_aux[ptr->team].lc_place[i] = k++;
3144
                sort_aux[ptr->team].lc_place[i] = k++;
3178
            }
3145
            }
-
 
3146
 
3179
        }
3147
        }
3180
 
3148
 
3181
        /*
3149
        /*
3182
        **  Sort on end time per class
3150
        **  Sort on end time per class
3183
        **  Then save the teams place at the end of each leg per class
3151
        **  Then save the teams place at the end of each leg per class
Line 3195... Line 3163...
3195
            else {
3163
            else {
3196
                if (ptr->isNeData)
3164
                if (ptr->isNeData)
3197
                    isNe = true;
3165
                    isNe = true;
3198
            }
3166
            }
3199
 
3167
 
-
 
3168
            if (i == 0 || i == config.equestrian_leg || sort_afterEquestrianLeg) {
-
 
3169
                if (ptr->flags.bad_times || ptr->flags.disqualified || ptr->flags.vet_check) {
-
 
3170
                    if (isNe) {
-
 
3171
                        sort_aux[ptr->team].leq_place[i] = -1;
-
 
3172
                    } else {
-
 
3173
                        sort_aux[ptr->team].lec_place[i] = -1;
-
 
3174
                    }
-
 
3175
                    continue;
-
 
3176
                }
-
 
3177
            }
-
 
3178
 
-
 
3179
            // Flag as unplaced NE teams on the EQ leg
-
 
3180
            // Flag as unplaced NE teams after the EQ leg
-
 
3181
            // Flag as unplaced in overall (leg:0) NE teams
-
 
3182
            if ( (i == config.equestrian_leg || sort_afterEquestrianLeg || i == 0 ) && ptr->flags.non_equestrian ) {
-
 
3183
                if (ptr->isNeData) {
-
 
3184
                    sort_aux[ptr->team].leq_place[i] = -1;
-
 
3185
                } else {
-
 
3186
                    sort_aux[ptr->team].lec_place[i] = -1;
-
 
3187
                }
-
 
3188
                continue;
-
 
3189
            }
-
 
3190
 
3200
            if (isNe) {
3191
            if (isNe) {
3201
                if( teamclassq != ptr->teamclass )
3192
                if( teamclassq != ptr->teamclass )
3202
                {
3193
                {
3203
                    q = 1;
3194
                    q = 1;
3204
                    teamclassq = ptr->teamclass;
3195
                    teamclassq = ptr->teamclass;
Line 3211... Line 3202...
3211
                    k = 1;
3202
                    k = 1;
3212
                    teamclass = ptr->teamclass;
3203
                    teamclass = ptr->teamclass;
3213
                }
3204
                }
3214
                sort_aux[ptr->team].lec_place[i] = k++;
3205
                sort_aux[ptr->team].lec_place[i] = k++;
3215
            }
3206
            }
-
 
3207
 
3216
        }
3208
        }
3217
    }
3209
    }
3218
 
3210
 
3219
    /*
3211
    /*
3220
    **  Write the place information back to disk for use in the displays
3212
    **  Write the place information back to disk for use in the displays
Line 3259... Line 3251...
3259
    ty_s_data  *ptr;
3251
    ty_s_data  *ptr;
3260
 
3252
 
3261
    sort_leg = leg;                              /* Leg is global for the comparison function */
3253
    sort_leg = leg;                              /* Leg is global for the comparison function */
3262
    sort_mode = mode;                            /* Mode is global for compare function */
3254
    sort_mode = mode;                            /* Mode is global for compare function */
3263
    sort_withEquestrian = withEq;                /* Mode is global for compare function */
3255
    sort_withEquestrian = withEq;                /* Mode is global for compare function */
-
 
3256
    sort_afterEquestrianLeg = ( config.equestrian_leg && leg > config.equestrian_leg);
3264
 
3257
 
3265
    qsort( ( char * ) sort_data, sort_num, sizeof( ty_s_data ), sort_comp );
3258
    qsort( ( char * ) sort_data, sort_num, sizeof( ty_s_data ), sort_comp );
3266
 
3259
 
3267
    /*
3260
    /*
3268
     * Insert "place data" into the sorted data
3261
     * Insert "place data" into the sorted data
Line 3273... Line 3266...
3273
    for( j = 1; j <= sort_num; j++, ptr++ )
3266
    for( j = 1; j <= sort_num; j++, ptr++ )
3274
    {
3267
    {
3275
        ptr->place = j;
3268
        ptr->place = j;
3276
    }
3269
    }
3277
 
3270
 
3278
    qDebug() << "sort_team_data: Leg:" << leg << ",M:" << mode << ",E:" << withEq;
3271
    //qDebug() << "sort_team_data: Leg:" << leg << ",M:" << mode << ",E:" << withEq;
3279
    //for( j = 1, ptr = sort_data; j <= sort_num; j++, ptr++ )
-
 
3280
    //{
-
 
3281
    //    qDebug() << "T:" << ptr->team << " Class:" << ptr->teamclass << " V:" << ptr->flags.valid << "NE:" << ptr->isNeData << "B:" << ptr->flags.bad_times <<"D:" << ptr->flags.disqualified <<"V:" << ptr->flags.vet_check << "LP:" << ptr->flags.notInLP << "EP:" << ptr->flags.notInEP <<"F:" << ptr->flags.notInFastest;
3272
 
3282
    //}
-
 
3283
 
3273
 
3284
}
3274
}
3285
 
3275
 
3286
/*========================================================================
3276
/*========================================================================
3287
 *
3277
 *
Line 3393... Line 3383...
3393
        aNoSort = a->flags.notInLP;
3383
        aNoSort = a->flags.notInLP;
3394
        bNoSort = b->flags.notInLP;
3384
        bNoSort = b->flags.notInLP;
3395
    }
3385
    }
3396
 
3386
 
3397
    if ( sort_withEquestrian && (sort_mode == S_LC || sort_mode == S_L ) ) {
3387
    if ( sort_withEquestrian && (sort_mode == S_LC || sort_mode == S_L ) ) {
3398
        if (a->flags.non_equestrian || a->flags.vet_check)
3388
        if (a->flags.vet_check)
3399
            aNoSort = true;
3389
            aNoSort = true;
3400
        if (b->flags.non_equestrian || b->flags.vet_check)
3390
        if (b->flags.vet_check)
3401
            bNoSort = true;
3391
            bNoSort = true;
3402
    }
3392
    }
3403
 
3393
 
3404
    if (a->flags.bad_times || a->flags.disqualified || !a->flags.valid)
3394
    if (a->flags.bad_times || a->flags.disqualified || !a->flags.valid)
3405
        aNoSort = true;
3395
        aNoSort = true;
Line 3412... Line 3402...
3412
            aNoSort = true;
3402
            aNoSort = true;
3413
        if (b->flags.vet_check)
3403
        if (b->flags.vet_check)
3414
            bNoSort = true;
3404
            bNoSort = true;
3415
    }
3405
    }
3416
 
3406
 
-
 
3407
    // On the Equestrian Leg, vetted out teams are treated as disqualified
-
 
3408
    if (sort_leg == config.equestrian_leg || (sort_afterEquestrianLeg && ( sort_mode == S_LE || sort_mode == S_LEC))) {
-
 
3409
        if (a->flags.vet_check)
-
 
3410
            aNoSort = true;
-
 
3411
        if (b->flags.vet_check)
-
 
3412
            bNoSort = true;
-
 
3413
    }
-
 
3414
 
3417
    if (aNoSort && bNoSort)
3415
    if (aNoSort && bNoSort)
3418
        return ( a->team - b->team );
3416
        return ( a->team - b->team );
3419
 
3417
 
3420
    if (aNoSort || bNoSort)
3418
    if (aNoSort || bNoSort)
3421
        return ( aNoSort ? 1 : -1 );
3419
        return ( aNoSort ? 1 : -1 );
Line 3436... Line 3434...
3436
            /* Good times better than NE */
3434
            /* Good times better than NE */
3437
            return ( a->flags.non_equestrian ? 1 : -1 );
3435
            return ( a->flags.non_equestrian ? 1 : -1 );
3438
        }
3436
        }
3439
    }
3437
    }
3440
 
3438
 
3441
 
-
 
3442
 
-
 
3443
//    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 */
-
 
3444
//    {
-
 
3445
//        if( a->flags.bad_times && b->flags.bad_times )
-
 
3446
//        {
-
 
3447
//            return ( a->team - b->team );
-
 
3448
//        }
-
 
3449
//        else if( a->flags.bad_times || b->flags.bad_times )
-
 
3450
//        {
-
 
3451
//            return ( a->flags.bad_times ? 1 : -1 );
-
 
3452
//        }
-
 
3453
//        else if ( sort_leg != 0 && (sort_mode == S_L || sort_mode == S_LC))
-
 
3454
//        {
-
 
3455
//            /* */
-
 
3456
//        }
-
 
3457
//        if( sort_mode != S_FIN && sort_mode != S_IFIN )
-
 
3458
//        {
-
 
3459
//            if( a->flags.non_equestrian && b->flags.non_equestrian )
-
 
3460
//            {
-
 
3461
//                /*
-
 
3462
//                **  Both are non equestrian
-
 
3463
//                **  Let the time sort operate ...
-
 
3464
//                */
-
 
3465
//                //return ( a->team - b->team );
-
 
3466
//            }
-
 
3467
//            else
-
 
3468
//            {
-
 
3469
//                /* One is equestrian */
-
 
3470
//                /* Good times better than NE */
-
 
3471
//                return ( a->flags.non_equestrian ? 1 : -1 );
-
 
3472
//            }
-
 
3473
//        }
-
 
3474
//    }
-
 
3475
 
-
 
3476
    /*
3439
    /*
3477
    **  Before we sort on times we must determine which time to
3440
    **  Before we sort on times we must determine which time to
3478
    **  use. Finish time, Leg end times, Leg Elapsed times.
3441
    **  use. Finish time, Leg end times, Leg Elapsed times.
3479
    */
3442
    */
3480
 
3443
 
Line 3712... Line 3675...
3712
 
3675
 
3713
                // Add a few flags to simplify processing
3676
                // Add a few flags to simplify processing
3714
                //  Vetted out teams to be included inthe fastest calcs - except for Equestian Leg
3677
                //  Vetted out teams to be included inthe fastest calcs - except for Equestian Leg
3715
                //  Bodgey teams are not sorted by place - only after all places and then by team number
3678
                //  Bodgey teams are not sorted by place - only after all places and then by team number
3716
                ptr->flags.notInLP = 0;
3679
                ptr->flags.notInLP = 0;
3717
                ptr->flags.notInEP = 0;
-
 
3718
                ptr->flags.notInFastest = 0;
3680
                ptr->flags.notInFastest = 0;
3719
 
3681
 
3720
                if ( ptr->flags.bad_times || ptr->flags.disqualified || !ptr->flags.valid) {
3682
                if ( ptr->flags.bad_times || ptr->flags.disqualified || !ptr->flags.valid) {
3721
                    ptr->flags.notInLP = 1;
3683
                    ptr->flags.notInLP = 1;
3722
                    ptr->flags.notInEP = 1;
-
 
3723
                    ptr->flags.notInFastest = 1;
3684
                    ptr->flags.notInFastest = 1;
3724
                }
3685
                }
3725
 
3686
 
3726
                if (ptr->flags.vet_check) {
-
 
3727
                    ptr->flags.notInEP = 1;
-
 
3728
                }
-
 
3729
 
-
 
3730
//                if (ptr->flags.non_equestrian)
-
 
3731
//                    ptr->flags.disqualified = true;
-
 
3732
//                if (ptr->flags.vet_check)
-
 
3733
//                    ptr->flags.disqualified = true;
-
 
3734
 
-
 
3735
                ptr++;
3687
                ptr++;
3736
                sort_num++;
3688
                sort_num++;
3737
 
3689
 
3738
 
3690
 
3739
                /*
3691
                /*
Line 3749... Line 3701...
3749
                    ptr->isNeData = true;
3701
                    ptr->isNeData = true;
3750
                    ptr->lege[0] = 0;
3702
                    ptr->lege[0] = 0;
3751
 
3703
 
3752
                    for( j = 0; j < MAX_LEGS + 1; j++ )
3704
                    for( j = 0; j < MAX_LEGS + 1; j++ )
3753
                    {
3705
                    {
3754
                        if ( j == config.equestrian_leg )
3706
                        if ( (short)j == config.equestrian_leg )
3755
                        {
3707
                        {
3756
                            last->lege[j] = ptr->lege[j] = 0;
3708
                            last->lege[j] = ptr->lege[j] = 0;
3757
                            if ( config.equestrian_leg > 1 )
3709
                            if ( config.equestrian_leg > 1 )
3758
                                last->leg[j] = ptr->leg[j] = ptr->leg[j-1];
3710
                                last->leg[j] = ptr->leg[j] = ptr->leg[j-1];
3759
                        }
3711
                        }
Line 3769... Line 3721...
3769
 
3721
 
3770
                    last->start = ptr->start = team_buf.leg[0].start;
3722
                    last->start = ptr->start = team_buf.leg[0].start;
3771
                    ptr->teamclass = config.nonequestrian_class;
3723
                    ptr->teamclass = config.nonequestrian_class;
3772
                    ptr->real_teamclass = team_buf.teamclass;
3724
                    ptr->real_teamclass = team_buf.teamclass;
3773
                    ptr->flags = team_buf.flags;
3725
                    ptr->flags = team_buf.flags;
3774
//                    ptr->flags.disqualified = false;
-
 
3775
 
3726
 
3776
                    ptr++;
3727
                    ptr++;
3777
                    sort_num++;
3728
                    sort_num++;
3778
                }
3729
                }
3779
#endif
3730
#endif
3780
            }
3731
            }
3781
        }
3732
        }
3782
    }
3733
    }
3783
 
3734
 
3784
    // Debug
3735
    // Debug
3785
    qDebug() << "--- Start ---";
3736
//    qDebug() << "--- Start ---";
3786
 
3737
 
3787
    sort_team_data( 0, S_L, 1 );
3738
//    sort_team_data( 0, S_L, 1 );
3788
 
3739
 
3789
    for( j = 1, ptr = sort_data; j <= sort_num; j++, ptr++ )
3740
//    for( j = 1, ptr = sort_data; j <= sort_num; j++, ptr++ )
3790
    {
3741
//    {
3791
        qDebug() << "T:" << ptr->team
3742
//        qDebug() << "T:" << ptr->team
3792
                << "Class:" << ptr->teamclass
3743
//                << "Class:" << ptr->teamclass
3793
                << "NEData:" << (ptr->isNeData? 1:0)
3744
//                << "NEData:" << (ptr->isNeData? 1:0)
3794
                << "iLP:" << (ptr->flags.notInLP ? 1:0)
3745
//                << "iLP:" << (ptr->flags.notInLP ? 1:0)
3795
                << "iEP:" << (ptr->flags.notInEP ? 1:0)
-
 
3796
                << "iF:" << (ptr->flags.notInFastest ? 1:0)
3746
//                << "iF:" << (ptr->flags.notInFastest ? 1:0)
3797
                << "Valid:" << (ptr->flags.valid ? 1:0)
3747
//                << "Valid:" << (ptr->flags.valid ? 1:0)
3798
                << "NE:" << (ptr->flags.non_equestrian? 1:0)
3748
//                << "NE:" << (ptr->flags.non_equestrian? 1:0)
3799
                << "B:" << (ptr->flags.bad_times ? 1 : 0 )
3749
//                << "B:" << (ptr->flags.bad_times ? 1 : 0 )
3800
                << "D:" << (ptr->flags.disqualified ? 1:0 )
3750
//                << "D:" << (ptr->flags.disqualified ? 1:0 )
3801
                << "V:" << (ptr->flags.vet_check ? 1:0 )
3751
//                << "V:" << (ptr->flags.vet_check ? 1:0 )
3802
                << "LE0:" << ptr->lege[0]
3752
//                << "LE0:" << ptr->lege[0]
3803
                << "L0:" << ptr->leg[0]
3753
//                << "L0:" << ptr->leg[0]
3804
                << "LE1:" << ptr->lege[3]
3754
//                << "LE1:" << ptr->lege[3]
3805
                ;
3755
//                ;
3806
    }
3756
//    }
3807
 
3757
 
3808
    qDebug() << "-----------------------------------End---";
3758
//    qDebug() << "-----------------------------------End---";
3809
    return ( TRUE );
3759
    return ( TRUE );
3810
}
3760
}
3811
 
3761
 
3812
/*========================================================================
3762
/*========================================================================
3813
 *
3763
 *