Subversion Repositories svn1

Rev

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

Rev 357 Rev 359
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
-
 
24
*       pr_place                - Return place data
23
*       px_place                - Return place data with NE and V indication
25
*       ck_data                 - Check data for bad times
24
*       ck_data                 - Check data for bad times
26
*       srt_place               - Update placing information
25
*       srt_place               - Update placing information
27
*       do_big_sort             - Main sort routine for final data
26
*       do_big_sort             - Main sort routine for final data
28
*       sort                    - Sort in memory buffer
27
*       sort                    - Sort in memory buffer
29
*       sort_comp               - qsort comparison function
28
*       sort_comp               - qsort comparison function
Line 87... Line 86...
87
};
86
};
88
 
87
 
89
int         sort_leg;
88
int         sort_leg;
90
int         sort_mode;
89
int         sort_mode;
91
bool        sort_withEquestrian;
90
bool        sort_withEquestrian;
-
 
91
bool        sort_afterEquestrianLeg;
92
report_type report_html = text;
92
report_type report_html = text;
93
bool        report_all = FALSE;
93
bool        report_all = FALSE;
94
 
94
 
95
/* Parameters used by the sort routine to govern its actions */
95
/* Parameters used by the sort routine to govern its actions */
96
 
96
 
Line 365... Line 365...
365
 
365
 
366
    /*
366
    /*
367
     * Sort the data in finishing order 
367
     * Sort the data in finishing order 
368
     */
368
     */
369
 
369
 
370
    if( ck_data( leg, C_END ) )
-
 
371
        return;                                  /* Check data for this leg */
370
    ck_data( leg, C_END );                      /* Check data for this leg */
372
    sort_team_data( leg, S_FIN, true );         /* Sort the data */
371
    sort_team_data( leg, S_FIN, true );         /* Sort the data */
373
 
372
 
374
 
373
 
375
    /*
374
    /*
376
     * Now print the data on the printer 
375
     * Now print the data on the printer 
Line 472... Line 471...
472
void p_place( ty_s_data * ptr, int leg, unsigned k )
471
void p_place( ty_s_data * ptr, int leg, unsigned k )
473
{
472
{
474
    if( k < sort_num )
473
    if( k < sort_num )
475
    {
474
    {
476
        print( "%4.4s %4d %8s  ",
475
        print( "%4.4s %4d %8s  ",
477
               pr_place( ptr->place, ptr->flags.bad_times ),
476
               px_place(-1, ptr->place, false, false, ptr->flags ),
478
               ptr->team, time_fa( ptr->leg[leg], ptr->flags.disqualified ) );
477
               ptr->team, time_fa( ptr->leg[leg], ptr->flags.disqualified ) );
479
    }
478
    }
480
    else
479
    else
481
    {
480
    {
482
        print( "%20s", "" );
481
        print( "%20s", "" );
Line 518... Line 517...
518
    }
517
    }
519
    if( found )
518
    if( found )
520
    {
519
    {
521
        print( "%4d %4.4s %8s  ",
520
        print( "%4d %4.4s %8s  ",
522
               ptra->team,
521
               ptra->team,
523
               pr_place( ptra->place, ptra->flags.bad_times ),
522
               px_place( -1, ptra->place, false, false, ptra->flags ),
524
               time_fa( ptra->leg[leg], ptra->flags.disqualified ) );
523
               time_fa( ptra->leg[leg], ptra->flags.disqualified ) );
525
    }
524
    }
526
    else
525
    else
527
    {
526
    {
528
        print( "%20s", "" );
527
        print( "%20s", "" );
Line 551... Line 550...
551
 
550
 
552
    /*
551
    /*
553
     * Sort the data in finishing order
552
     * Sort the data in finishing order
554
     */
553
     */
555
 
554
 
556
    if( ck_data( leg, C_ELAPSED ) )
-
 
557
        return;                                  /* Check data for this leg */
555
    ck_data( leg, C_ELAPSED );                      /* Check data for this leg */
558
    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 */
559
 
557
 
560
 
558
 
561
    /*
559
    /*
562
     * Now print the data on the printer
560
     * Now print the data on the printer
563
     */
561
     */
Line 641... Line 639...
641
// *
639
// *
642
// *  Print place information
640
// *  Print place information
643
// *
641
// *
644
// *  Purpose:
642
// *  Purpose:
645
// *      This helper function is called to Print place and elapsed information
643
// *      This helper function is called to Print place and elapsed information
646
// *      in a 20-character field
644
// *      in a 20-character field: Place:Team:ElapsedTime
647
// *
645
// *
648
// *  Parameters:
646
// *  Parameters:
649
// *      ptr         Address of the place data
647
// *      ptr         Address of the place data
650
// *      leg         Leg to print
648
// *      leg         Leg to print
651
// *      k           Current index into sorted array. Simply
649
// *      k           Current index into sorted array. Simply
Line 660... Line 658...
660
void pe_place( ty_s_data * ptr, int leg, unsigned k )
658
void pe_place( ty_s_data * ptr, int leg, unsigned k )
661
{
659
{
662
    if( k < sort_num )
660
    if( k < sort_num )
663
    {
661
    {
664
        print( "%4.4s %4d %8s  ",
662
        print( "%4.4s %4d %8s  ",
665
               pr_place( ptr->place, ptr->flags.bad_times ),
663
               px_place( -1, ptr->place, false, false, ptr->flags ),
666
               ptr->team,
664
               ptr->team,
667
               time_fa( ptr->lege[leg], ptr->flags.disqualified ) );
665
               time_fa( ptr->lege[leg], ptr->flags.disqualified ) );
668
    }
666
    }
669
    else
667
    else
670
    {
668
    {
Line 707... Line 705...
707
    }
705
    }
708
    if( found )
706
    if( found )
709
    {
707
    {
710
        print( "%4d %4.4s %8s  ",
708
        print( "%4d %4.4s %8s  ",
711
               ptra->team,
709
               ptra->team,
712
               pr_place( ptra->place, ptra->flags.bad_times ),
710
               px_place( -1, ptra->place, false, false, ptra->flags ),
713
               time_fa( ptra->lege[leg], ptra->flags.disqualified ) );
711
               time_fa( ptra->lege[leg], ptra->flags.disqualified ) );
714
    }
712
    }
715
    else
713
    else
716
    {
714
    {
717
        print( "%20s", "" );
715
        print( "%20s", "" );
Line 739... Line 737...
739
    /*
737
    /*
740
    **  Generate ALL results with HTML tags
738
    **  Generate ALL results with HTML tags
741
    */
739
    */
742
    report_html = html;
740
    report_html = html;
743
    pri_final();
741
    pri_final();
-
 
742
    pri_final_teamOrder();
-
 
743
 
744
    report_html = printed;
744
    report_html = printed;
745
    pri_final();
745
    pri_final();
-
 
746
    pri_final_teamOrder();
746
    report_html = text;
747
    report_html = text;
747
}
748
}
748
 
749
 
749
 
750
 
750
/*========================================================================
751
/*========================================================================
Line 773... Line 774...
773
    int         lcount;
774
    int         lcount;
774
    bool        isNeClass = false;
775
    bool        isNeClass = false;
775
    int         place;
776
    int         place;
776
 
777
 
777
 
778
 
778
    if( ck_data( -1, C_ELAPSED ) )
779
    ck_data( -1, C_ELAPSED );
779
        return;
780
 
780
    /*
781
    /*
781
    **  Sort on every thing
782
    **  Sort on every thing
782
    **  Then generate all the stats too
783
    **  Then generate all the stats too
783
    */
784
    */
784
    do_big_sort();
785
    do_big_sort();
Line 791... Line 792...
791
        return;
792
        return;
792
 
793
 
793
    /*
794
    /*
794
     * Print out the data 
795
     * Print out the data 
795
     */
796
     */
796
    print_class_header( -1, TRUE );                      /* Print the header */
797
    print_class_header( -1, TRUE );                     /* Print the header */
797
 
-
 
798
    ptr = sort_data;
-
 
799
    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 */
800
    lcount = 0;
799
    lcount = 0;
801
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
800
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
802
    {
801
    {
803
        if ( ptr->teamclass == config.nonequestrian_class )
802
        if ( ptr->teamclass == config.nonequestrian_class )
Line 827... Line 826...
827
        **  Print the basics (Finishing order)
826
        **  Print the basics (Finishing order)
828
        **      - Place within complete field
827
        **      - Place within complete field
829
        **      - Team number - with HTML reference to team file
828
        **      - Team number - with HTML reference to team file
830
        **      - Class
829
        **      - Class
831
        */
830
        */
832
        if ( report_html == printed && lcount %5 == 4 ) print_underline( TRUE );
831
        if ( report_html == printed && lcount % 5 == 4 ) print_underline( TRUE );
833
        print( "%4.4s ", pn_place( team_buf.leg[0].l_place, ptr->flags.bad_times, ptr->flags.non_equestrian ) );
832
        print( "%4.4s ", px_place( 0, team_buf.leg[0].l_place, false, true, ptr->flags ) );
834
        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 );
835
        print( "%4d",  team_buf.numb );
834
        print( "%4d",  team_buf.numb );
836
        if ( report_html == html ) print( "</A>" );
835
        if ( report_html == html ) print( "</A>" );
837
 
836
 
838
        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 844... Line 843...
844
        **      - End place
843
        **      - End place
845
        */
844
        */
846
        for( j = 1; j <= config.num_legs; j++ )
845
        for( j = 1; j <= config.num_legs; j++ )
847
        {
846
        {
848
            bool isEquestrianLeg = (j == config.equestrian_leg && team_buf.flags.non_equestrian);
847
            bool isEquestrianLeg = (j == config.equestrian_leg && team_buf.flags.non_equestrian);
849
            bool afterEquestrianLeg = (team_buf.flags.non_equestrian && j > config.equestrian_leg);
-
 
-
 
848
 
850
            /*
849
            /*
851
            **  Ensure that non-equestrian leg data is not displayed
850
            **  Ensure that non-equestrian leg data is not displayed
852
            */
851
            */
853
            if ( isEquestrianLeg )
852
            if ( isEquestrianLeg )
854
            {
853
            {
855
                print( "  %-8s %4.4s %4.4s", "-- NE --", "NE","NE");
854
                print( "  %-8s %4.4s %4.4s", "-- NE --", "NE","NE");
856
            }
855
            }
857
            else
856
            else
858
            {
857
            {
859
                print( "  %-8s %4.4s %4.4s",
-
 
860
                    time_a( team_buf.leg[j].elapsed ),
858
                print( "  %-8s", time_a( team_buf.leg[j].elapsed ));
861
                    pr_place( team_buf.leg[j].l_place, ptr->flags.bad_times ),
859
                if ( config.num_legs != 1 ) print( " %4.4s",      px_place( j, team_buf.leg[j].l_place, false, false, ptr->flags ));
862
                    pn_place( team_buf.leg[j].le_place,ptr->flags.bad_times, afterEquestrianLeg )
860
                if ( config.num_legs != 1 ) print( " %4.4s",   px_place( j, team_buf.leg[j].le_place,true , true, ptr->flags ));
863
                  );
861
                if ( config.num_legs == 1 ) print( " %-*s ",  MAX_TM_NAME, team_buf.name );
864
            }
862
            }
865
        }
863
        }
866
 
864
 
867
       /*
865
       /*
868
        **  Print the trailer (Finishing order)
866
        **  Print the trailer (Finishing order)
869
        **      - Total time
867
        **      - Total time
870
        **      - Category place - with reference to category file
868
        **      - Category place - with reference to category file
871
        */
869
        */
872
//        print( "  %-8s ",  time_a( team_buf.leg[0].elapsed ) );
-
 
873
        print( "  %-8s ", time_a( ptr->lege[0] ) );
870
        if ( config.num_legs != 1 ) print( "  %-8s ", time_a( ptr->lege[0] ) );
874
        
871
        
875
        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 );
872
        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 );
876
        print( "%-4.4s", pn_place( team_buf.leg[0].lc_place, ptr->flags.bad_times, ptr->flags.non_equestrian && 0 ) );
873
        print( "%4.4s", px_place( 0, team_buf.leg[0].lc_place, false, false, ptr->flags) );
877
        if ( report_html == html ) print( "</A>" );
874
        if ( report_html == html ) print( "</A>" );
878
        if ( report_html == printed && lcount %5 == 4 ) print_underline( FALSE );
875
        if ( report_html == printed && lcount %5 == 4 ) print_underline( FALSE );
879
        lcount++;
876
        lcount++;
880
        print( "\n" );
877
        print( "\n" );
881
    }
878
    }
Line 976... Line 973...
976
        **      - Team number - with HTML reference to team file
973
        **      - Team number - with HTML reference to team file
977
        **      - Class
974
        **      - Class
978
        */
975
        */
979
 
976
 
980
        if ( report_html == printed && lcount %5 == 4 ) print_underline( TRUE );
977
        if ( report_html == printed && lcount %5 == 4 ) print_underline( TRUE );
981
        print( "%4.4s ", pn_place( team_buf.leg[0].lc_place, flags , eflags ) );
978
        print( "%4.4s ", px_place( 0, team_buf.leg[0].lc_place, false, false, ptr->flags) );
982
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "name" ,"html")), team_buf.numb );
979
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "name" ,"html")), team_buf.numb );
983
        print( "%4d",  team_buf.numb );
980
        print( "%4d",  team_buf.numb );
984
        if ( report_html == html ) print( "</A>" );
981
        if ( report_html == html ) print( "</A>" );
985
        print( " %-*s", 3, team_buf.teamclass == 0 ? "" : config.team_class[team_buf.teamclass - 1].abr );
982
        print( " %-*s", 3, team_buf.teamclass == 0 ? "" : config.team_class[team_buf.teamclass - 1].abr );
986
 
983
 
987
        for( j = 1; j <= config.num_legs; j++ )
984
        for( j = 1; j <= config.num_legs; j++ )
988
        {
985
        {
989
            bool isEquestrianLeg = (j == config.equestrian_leg && (ptr->teamclass == config.nonequestrian_class || ptr->flags.non_equestrian));
986
            bool isEquestrianLeg = (j == config.equestrian_leg && (ptr->teamclass == config.nonequestrian_class || ptr->flags.non_equestrian));
990
            bool afterEquestrianLeg = ((ptr->teamclass == config.nonequestrian_class || ptr->flags.non_equestrian) && j > config.equestrian_leg);
-
 
991
 
987
 
992
            /*
988
            /*
993
            **  Ensure that non-equestrian leg data is not displayed
989
            **  Ensure that non-equestrian leg data is not displayed
994
            */
990
            */
995
            if ( isEquestrianLeg )
991
            if ( isEquestrianLeg )
996
            {
992
            {
997
                print( "  %-8s %4.4s %4.4s", "-- NE --", "NE","NE");
993
                print( "  %-8s %4.4s %4.4s", "-- NE --", "NE","NE");
998
            }
994
            }
999
            else
995
            else
1000
            {
996
            {
1001
                print( "  %-8s %4.4s %4.4s", time_a( team_buf.leg[j].elapsed ),
997
                print( "  %-8s", time_a( team_buf.leg[j].elapsed ));
1002
                       pr_place( team_buf.leg[j].lc_place,  flags ),
998
                if ( config.num_legs != 1 ) print( " %4.4s", px_place( j, team_buf.leg[j].lc_place,  false, false, ptr->flags ));
1003
                       pn_place( team_buf.leg[j].lec_place, flags, afterEquestrianLeg ) );
999
                if ( config.num_legs != 1 ) print( " %4.4s", px_place( j, team_buf.leg[j].lec_place, true , true, ptr->flags ) );
-
 
1000
                if ( config.num_legs == 1 ) print( " %-*s ", MAX_TM_NAME, team_buf.name );
1004
            }
1001
            }
1005
        }
1002
        }
1006
 
1003
 
1007
        /*
1004
        /*
1008
        **  Print the trailer
1005
        **  Print the trailer
1009
        **      - Total time
1006
        **      - Total time
1010
        **      - Overall place - with reference to overall place file
1007
        **      - Overall place - with reference to overall place file
1011
        */
1008
        */
1012
        /* print( "  %-8s ", time_a( team_buf.leg[0].elapsed ) ); */
-
 
1013
        print( "  %-8s ", time_a( ptr->lege[0] ) );
1009
        if ( config.num_legs != 1 ) print( "  %-8s ", time_a( ptr->lege[0] ) );
1014
 
1010
 
1015
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "finish" ,"html")), team_buf.numb );
1011
        if ( report_html == html )  print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "finish" ,"html")), team_buf.numb );
1016
        print( "%4.4s", pn_place( team_buf.leg[0].l_place, flags , ptr->flags.non_equestrian));
1012
        print( "%4.4s", px_place( 0, team_buf.leg[0].l_place, false, true, ptr->flags));
1017
        if ( report_html == html ) print( "</A>" );
1013
        if ( report_html == html )  print( "</A>" );
1018
 
1014
 
1019
        if ( report_html == printed && lcount %5 == 4 ) print_underline( FALSE );
1015
        if ( report_html == printed && lcount %5 == 4 ) print_underline( FALSE );
1020
        lcount++;
1016
        lcount++;
1021
        print( "\n" );
1017
        print( "\n" );
1022
    }
1018
    }
Line 1075... Line 1071...
1075
    pri_name_index_body();
1071
    pri_name_index_body();
1076
}
1072
}
1077
 
1073
 
1078
/*========================================================================
1074
/*========================================================================
1079
 *
1075
 *
-
 
1076
 *  Print final results in Team Order
-
 
1077
 *
-
 
1078
 *  Purpose:
-
 
1079
 *      This function is called to Print final results in Team Order
-
 
1080
 *
-
 
1081
 *  Parameters:
-
 
1082
 *      None
-
 
1083
 *
-
 
1084
 *  Returns:
-
 
1085
 *      Nothing
-
 
1086
 *
-
 
1087
 *========================================================================*/
-
 
1088
 
-
 
1089
void pri_final_teamOrder(void)
-
 
1090
{
-
 
1091
    ty_s_data  *ptr;
-
 
1092
    team_type   team_buf;
-
 
1093
    unsigned    i;
-
 
1094
    int         j;
-
 
1095
    int         lcount;
-
 
1096
 
-
 
1097
    ck_data( -1, C_ELAPSED );
-
 
1098
 
-
 
1099
    /*
-
 
1100
    **  Sort on every thing
-
 
1101
    **  Then generate all the stats too
-
 
1102
    */
-
 
1103
    do_big_sort();
-
 
1104
    gen_stats();
-
 
1105
 
-
 
1106
    /*
-
 
1107
     * Now print the data on the printer 
-
 
1108
     */
-
 
1109
    if( !open_printer( "", "team_order", 132, report_html, "Team Order" ) )
-
 
1110
        return;
-
 
1111
 
-
 
1112
    /*
-
 
1113
     * Print out the data 
-
 
1114
     */
-
 
1115
    print_class_header( -1, TRUE );                      /* Print the header */
-
 
1116
 
-
 
1117
    ptr = sort_data;
-
 
1118
    sort_team_data( 0, S_TEAM, true );                   /* Re-sort on team number */
-
 
1119
    lcount = 0;
-
 
1120
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
-
 
1121
    {
-
 
1122
        if ( ptr->teamclass == config.nonequestrian_class )
-
 
1123
            continue;
-
 
1124
 
-
 
1125
        g_record( ptr->team, &team_buf );
-
 
1126
 
-
 
1127
        /*
-
 
1128
        ** If this is a NE team then dummy up some of the data that hasn't been stored in team_buf
-
 
1129
        */
-
 
1130
        if (ptr->flags.non_equestrian)
-
 
1131
        {
-
 
1132
            team_buf.leg[0].l_place = sort_aux[ptr->team].leq_place[0];
-
 
1133
            team_buf.leg[0].lc_place = sort_aux[ptr->team].lq_place[0];;
-
 
1134
        }
-
 
1135
 
-
 
1136
        /*
-
 
1137
        **  If printing an HTML report then we need to mark
-
 
1138
        **  the entry with a reference so that we can link to it
-
 
1139
        */
-
 
1140
        if ( report_html == html )
-
 
1141
        {
-
 
1142
            print( "<A NAME=\"Team_%04d\"></A>",team_buf.numb );
-
 
1143
        }
-
 
1144
 
-
 
1145
        /*
-
 
1146
        **  Print the basics (Finishing order)
-
 
1147
        **      - Place within complete field
-
 
1148
        **      - Team number - with HTML reference to team file
-
 
1149
        **      - Class
-
 
1150
        */
-
 
1151
        if ( report_html == printed && lcount %5 == 4 ) print_underline( TRUE );
-
 
1152
        print( "%4.4s ", px_place( 0, team_buf.leg[0].l_place, false, true, ptr->flags ) );
-
 
1153
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "name" ,"html")), team_buf.numb );
-
 
1154
        print( "%4d",  team_buf.numb );
-
 
1155
        if ( report_html == html ) print( "</A>" );
-
 
1156
 
-
 
1157
        print( " %-*s", 3, team_buf.teamclass == 0 ? "" : config.team_class[team_buf.teamclass - 1].abr );
-
 
1158
 
-
 
1159
        /*
-
 
1160
        **  Print the per-leg data
-
 
1161
        **      - Time
-
 
1162
        **      - Leg place
-
 
1163
        **      - End place
-
 
1164
        */
-
 
1165
        for( j = 1; j <= config.num_legs; j++ )
-
 
1166
        {
-
 
1167
            bool isEquestrianLeg = (j == config.equestrian_leg && team_buf.flags.non_equestrian);
-
 
1168
            /*
-
 
1169
            **  Ensure that non-equestrian leg data is not displayed
-
 
1170
            */
-
 
1171
            if ( isEquestrianLeg )
-
 
1172
            {
-
 
1173
                print( "  %-8s %4.4s %4.4s", "-- NE --", "NE","NE");
-
 
1174
            }
-
 
1175
            else
-
 
1176
            {
-
 
1177
                print( "  %-8s",                     time_a( team_buf.leg[j].elapsed ));
-
 
1178
                if ( config.num_legs != 1 ) print( " %4.4s", px_place(j, team_buf.leg[j].l_place, false, false, ptr->flags ));
-
 
1179
                if ( config.num_legs != 1 ) print( " %4.4s", px_place(j, team_buf.leg[j].le_place,true,  true, ptr->flags ) );
-
 
1180
                if ( config.num_legs == 1 ) print( " %-*s ", MAX_TM_NAME, team_buf.name );
-
 
1181
            }
-
 
1182
        }
-
 
1183
 
-
 
1184
 
-
 
1185
       /*
-
 
1186
        **  Print the trailer (Finishing order)
-
 
1187
        **      - Total time
-
 
1188
        **      - Category place - with reference to category file
-
 
1189
        */
-
 
1190
       if ( config.num_legs != 1 ) print( "  %-8s ", time_a( ptr->lege[0] ) );
-
 
1191
        
-
 
1192
        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 );
-
 
1193
        print( "%4.4s", px_place( 0, team_buf.leg[0].lc_place, false, false, ptr->flags ) );
-
 
1194
        if ( report_html == html ) print( "</A>" );
-
 
1195
        if ( report_html == printed && lcount %5 == 4 ) print_underline( FALSE );
-
 
1196
        lcount++;
-
 
1197
        print( "\n" );
-
 
1198
    }
-
 
1199
 
-
 
1200
    print_class_stats( -1, TRUE );              /* Print statistics */
-
 
1201
    print_legend(-1, 1 );                       /* Print the legend */
-
 
1202
    close_printer();                            /* Close the printer */
-
 
1203
 
-
 
1204
}
-
 
1205
 
-
 
1206
/*========================================================================
-
 
1207
 *
1080
 *  Place to text
1208
 *  Place to text
1081
 *
1209
 *
1082
 *  Purpose:
1210
 *  Purpose:
1083
 *      This function is called to convert a place to text
1211
 *      This function is called to convert a place to text
1084
 *
1212
 *
Line 1271... Line 1399...
1271
    print( "    ");
1399
    print( "    ");
1272
    if ( report_html == html ) print( "<A HREF=\"#%s\">",url_encode("Hall Of Fame"));
1400
    if ( report_html == html ) print( "<A HREF=\"#%s\">",url_encode("Hall Of Fame"));
1273
    print( "%s",  "Hall Of Fame" );
1401
    print( "%s",  "Hall Of Fame" );
1274
    if ( report_html == html ) print( "</A>" );
1402
    if ( report_html == html ) print( "</A>" );
1275
 
1403
 
-
 
1404
    if (config.awardsfilename[0])
-
 
1405
    {
-
 
1406
        print( "\n");
-
 
1407
        print( "    ");
-
 
1408
        if ( report_html == html ) print( "<A HREF=\"#%s\">",url_encode("Additional Awards"));
-
 
1409
        print( "%s",  "Additional Awards" );
-
 
1410
        if ( report_html == html ) print( "</A>" );
-
 
1411
    }
-
 
1412
 
1276
    print( "\n");
1413
    print( "\n");
1277
    print( "    ");
1414
    print( "    ");
1278
    if ( report_html == html ) print( "<A HREF=\"#%s\">",url_encode("FASTEST"));
1415
    if ( report_html == html ) print( "<A HREF=\"#%s\">",url_encode("FASTEST"));
1279
    print( "%s",  "FASTEST" );
1416
    print( "%s",  "FASTEST" );
1280
    if ( report_html == html ) print( "</A>" );
1417
    if ( report_html == html ) print( "</A>" );
Line 1362... Line 1499...
1362
                /*
1499
                /*
1363
                **  Ensure we have a valid team
1500
                **  Ensure we have a valid team
1364
                **  Can't award disqualified teams
1501
                **  Can't award disqualified teams
1365
                **  Can't award NE teams unless its a NE award
1502
                **  Can't award NE teams unless its a NE award
1366
                */
1503
                */
1367
                if ( ptr->flags.bad_times )
1504
                if ( ptr->flags.bad_times || ptr->flags.disqualified || ptr->flags.vet_check || !ptr->flags.valid )
1368
                    break;
1505
                    break;
1369
 
1506
 
1370
                if ( ptr->teamclass != config.nonequestrian_class  && ptr->flags.non_equestrian )
1507
                if ( ptr->teamclass != config.nonequestrian_class  && ptr->flags.non_equestrian )
1371
                    break;
1508
                    break;
1372
 
1509
 
Line 1536... Line 1673...
1536
                    /*
1673
                    /*
1537
                    **  Ensure we have a valid team
1674
                    **  Ensure we have a valid team
1538
                    **  Can't award disqualified teams
1675
                    **  Can't award disqualified teams
1539
                    **  Can't award NE teams unless its a NE award
1676
                    **  Can't award NE teams unless its a NE award
1540
                    */
1677
                    */
1541
                    if ( ptr->flags.bad_times )
1678
                    if ( ptr->flags.bad_times || ptr->flags.disqualified || ptr->flags.vet_check || !ptr->flags.valid )
1542
                        break;
1679
                        break;
1543
 
1680
 
1544
                    if ( ptr->teamclass != config.nonequestrian_class  && ptr->flags.non_equestrian )
1681
                    if ( ptr->teamclass != config.nonequestrian_class  && ptr->flags.non_equestrian )
1545
                        break;
1682
                        break;
1546
 
1683
 
Line 1644... Line 1781...
1644
        qDebug( "There are no new stars for the Hall of Fame");
1781
        qDebug( "There are no new stars for the Hall of Fame");
1645
    }
1782
    }
1646
    if ( report_html == html ) print( "\n");
1783
    if ( report_html == html ) print( "\n");
1647
    if ( report_html == html ) print( "<A HREF=\"#%s\">Awards Index</A>",url_encode("INDEX"));
1784
    if ( report_html == html ) print( "<A HREF=\"#%s\">Awards Index</A>",url_encode("INDEX"));
1648
 
1785
 
-
 
1786
 
-
 
1787
 
-
 
1788
 
-
 
1789
    /*
-
 
1790
    **  Insert additional Awards information
-
 
1791
    */
-
 
1792
    if (config.awardsfilename[0])
-
 
1793
    {
-
 
1794
        print( "\n");
-
 
1795
        if ( report_html == html )
-
 
1796
        {
-
 
1797
            print( "<hr>" );
-
 
1798
            print( "<A name=\"%s\"></A>",url_encode("Additional Awards"));
-
 
1799
        }
-
 
1800
        else
-
 
1801
        {
-
 
1802
            print( "%s\n", solid_line);
-
 
1803
        }
-
 
1804
        print( "%s",  "Additional Awards" );
-
 
1805
        print ("\n");
-
 
1806
 
-
 
1807
        /*
-
 
1808
        **  Read and process the named awards file
-
 
1809
        */
-
 
1810
        FILE       *adfile = NULL;
-
 
1811
        char        line[201];
-
 
1812
 
-
 
1813
        QString name = QmConfig::getAddendemFile(config.awardsfilename);
-
 
1814
        if (! name.isEmpty())
-
 
1815
        {
-
 
1816
            adfile = fopen( qPrintable(name), "rt" );  /* Open the file for reading */
-
 
1817
        }
-
 
1818
 
-
 
1819
 
-
 
1820
        if( adfile )
-
 
1821
        {
-
 
1822
            while( fgets( line, sizeof(line)-1, adfile ) ) {
-
 
1823
                //  Process each line
-
 
1824
                //  Attempt to perform some smart text replacements
-
 
1825
                //  ie: <TeamNumber:63> <TeamName:63><TeamLegName:1:63>
-
 
1826
                print( "%s", line );
-
 
1827
            }
-
 
1828
            fclose(adfile);
-
 
1829
        }
-
 
1830
        else
-
 
1831
        {
-
 
1832
            if ( report_html == html )  print ("<br>");
-
 
1833
            print( "\nThe awards file could not be found: %s\n",  adfile);
-
 
1834
        }
-
 
1835
 
-
 
1836
 
-
 
1837
        if ( report_html == html ) print( "\n");
-
 
1838
        if ( report_html == html ) print( "<A HREF=\"#%s\">Awards Index</A>",url_encode("INDEX"));
-
 
1839
    }
-
 
1840
 
1649
    /*
1841
    /*
1650
    **  Generate the FASTEST information
1842
    **  Generate the FASTEST information
1651
    */
1843
    */
1652
    print( "\n" );
1844
    print( "\n" );
1653
    print( "\n");
1845
    print( "\n");
Line 1729... Line 1921...
1729
    */
1921
    */
1730
    print( "<TABLE border=0 align=center>" );
1922
    print( "<TABLE border=0 align=center>" );
1731
    pri_master_index_entry( "name", "Team list" );
1923
    pri_master_index_entry( "name", "Team list" );
1732
    pri_master_index_entry( "competitor", "Competitor list" );
1924
    pri_master_index_entry( "competitor", "Competitor list" );
1733
    pri_master_index_entry( "finish", "Finishing Order for all Teams" );
1925
    pri_master_index_entry( "finish", "Finishing Order for all Teams" );
-
 
1926
    pri_master_index_entry( "team_order", "All Teams with results" );
1734
    pri_master_index_entry( "awards", "Prizes and Awards" );
1927
    pri_master_index_entry( "awards", "Prizes and Awards" );
1735
    print( "<tr><td>\n" );
1928
    print( "<tr><td>\n" );
1736
 
1929
 
1737
    print( "\n" );
1930
    print( "\n" );
1738
    for( j = 1; j <= config.num_class; j++ )
1931
    for( j = 1; j <= config.num_class; j++ )
Line 1759... Line 1952...
1759
    print( "<TABLE border=0 align=center>" );
1952
    print( "<TABLE border=0 align=center>" );
1760
#if 1
1953
#if 1
1761
    pri_master_index_entry( "name", "Team list" );
1954
    pri_master_index_entry( "name", "Team list" );
1762
    pri_master_index_entry( "competitor", "Competitor list" );
1955
    pri_master_index_entry( "competitor", "Competitor list" );
1763
    pri_master_index_entry( "finish", "Finishing Order for all Teams" );
1956
    pri_master_index_entry( "finish", "Finishing Order for all Teams" );
-
 
1957
    pri_master_index_entry( "team_order", "All Teams with results" );
1764
    pri_master_index_entry( "awards", "Prizes and Awards" );
1958
    pri_master_index_entry( "awards", "Prizes and Awards" );
1765
    print( "<tr><td>\n" );
1959
    print( "<tr><td>\n" );
1766
 
1960
 
1767
    print( "\n" );
1961
    print( "\n" );
1768
    pri_master_index_entry( "summary", "Category Summary" );
1962
    pri_master_index_entry( "summary", "Category Summary" );
Line 1852... Line 2046...
1852
 
2046
 
1853
        g_record( ptr->team, &team_buf );
2047
        g_record( ptr->team, &team_buf );
1854
 
2048
 
1855
        print( "%4d %4.4s %-*s",
2049
        print( "%4d %4.4s %-*s",
1856
               team_buf.numb,
2050
               team_buf.numb,
1857
               pi_place( team_buf.leg[config.num_legs].le_place,
2051
               px_place(-1, team_buf.leg[config.num_legs].le_place, false, false, ptr->flags ),
1858
                         ptr->flags.disqualified, team_buf.leg[0].elapsed ),
-
 
1859
               3,
2052
               3,
1860
               team_buf.teamclass ==
-
 
1861
               0 ? "" : config.team_class[team_buf.teamclass - 1].abr );
2053
               team_buf.teamclass == 0 ? "" : config.team_class[team_buf.teamclass - 1].abr );
-
 
2054
 
1862
        for( j = 1; j <= config.num_legs; j++ )
2055
        for( j = 1; j <= config.num_legs; j++ )
1863
        {
2056
        {
1864
            print( "  %-8s %4.4s %4.4s",
-
 
1865
                   time_fa( team_buf.leg[j].elapsed,
-
 
1866
                            ptr->flags.disqualified ),
-
 
1867
                   pi_place( team_buf.leg[j].l_place, ptr->flags.disqualified,
2057
            print( "  %-8s", time_fa( team_buf.leg[j].elapsed, ptr->flags.disqualified ));
1868
                             team_buf.leg[j].elapsed ),
2058
            if ( config.num_legs != 1 ) print( " %4.4s", px_place(j, team_buf.leg[j].l_place, false, true, ptr->flags ));
1869
                   pi_place( team_buf.leg[j].le_place,
2059
            if ( config.num_legs != 1 ) print( " %4.4s", px_place(j, team_buf.leg[j].le_place, false, true, ptr->flags ));
1870
                             ptr->flags.disqualified,
-
 
1871
                             team_buf.leg[j].elapsed ) );
2060
            if ( config.num_legs == 1 ) print( " %-*s ",     MAX_TM_NAME, team_buf.name );
1872
        }
2061
        }
1873
        print( "  %-8s %4.4s\n",
-
 
-
 
2062
 
1874
               time_fa( team_buf.leg[0].elapsed, ptr->flags.disqualified ),
2063
        if ( config.num_legs != 1 ) print( "  %-8s", time_fa( team_buf.leg[0].elapsed, ptr->flags.disqualified ));
1875
               pi_place( team_buf.leg[config.num_legs].lec_place,
2064
        print( " %4.4s\n", px_place(0, team_buf.leg[config.num_legs].lec_place, false, false, ptr->flags ));
1876
                         ptr->flags.disqualified, team_buf.leg[0].elapsed ) );
-
 
1877
    }
2065
    }
1878
 
2066
 
1879
    print_class_stats( -1, FALSE );             /* Print statistics */
2067
    print_class_stats( -1, FALSE );             /* Print statistics */
1880
    print_legend(-1, 1);                        /* Print the legend */
2068
    print_legend(-1, 1);                        /* Print the legend */
1881
    close_printer();                            /* Close the printer */
2069
    close_printer();                            /* Close the printer */
Line 1917... Line 2105...
1917
        **  Now read in the team record
2105
        **  Now read in the team record
1918
        */
2106
        */
1919
        g_record( ptr->team, &team_buf );
2107
        g_record( ptr->team, &team_buf );
1920
        print( "%4d %4.4s %-*s",
2108
        print( "%4d %4.4s %-*s",
1921
               team_buf.numb,
2109
               team_buf.numb,
1922
               pi_place( team_buf.leg[config.num_legs].lec_place,
2110
               px_place(-1, team_buf.leg[config.num_legs].lec_place, false, false, ptr->flags ),
1923
                         ptr->flags.disqualified, team_buf.leg[0].elapsed ),
-
 
1924
               3,
2111
               3,
1925
               team_buf.teamclass ==
-
 
1926
               0 ? "" : config.team_class[team_buf.teamclass - 1].abr );
2112
               team_buf.teamclass == 0 ? "" : config.team_class[team_buf.teamclass - 1].abr );
-
 
2113
 
1927
        for( j = 1; j <= config.num_legs; j++ )
2114
        for( j = 1; j <= config.num_legs; j++ )
1928
        {
2115
        {
1929
            print( "  %-8s %4.4s %4.4s",
-
 
1930
                   time_fa( team_buf.leg[j].elapsed,
2116
            print( "  %-8s", time_fa( team_buf.leg[j].elapsed, ptr->flags.disqualified ));
1931
                            ptr->flags.disqualified ),
-
 
1932
                   pi_place( team_buf.leg[j].lc_place,
2117
            if ( config.num_legs != 1 ) print( " %4.4s", px_place(j, team_buf.leg[j].lc_place,  false, true, ptr->flags ));
1933
                             ptr->flags.disqualified,
-
 
1934
                             team_buf.leg[j].elapsed ),
-
 
1935
                   pi_place( team_buf.leg[j].lec_place,
2118
            if ( config.num_legs != 1 ) print( " %4.4s", px_place(j, team_buf.leg[j].lec_place, false, true, ptr->flags ));
1936
                             ptr->flags.disqualified,
-
 
1937
                             team_buf.leg[j].elapsed ) );
2119
            if ( config.num_legs == 1 ) print( " %-*s ", MAX_TM_NAME, team_buf.name );
1938
        }
2120
        }
1939
        print( "  %-8s %4.4s\n",
-
 
-
 
2121
 
-
 
2122
 
1940
               time_fa( team_buf.leg[0].elapsed, ptr->flags.disqualified ),
2123
        if ( config.num_legs != 1 ) print( "  %-8s", time_fa( team_buf.leg[0].elapsed, ptr->flags.disqualified ));
1941
               pi_place( team_buf.leg[config.num_legs].le_place,
2124
        print( " %4.4s\n", px_place(0, team_buf.leg[config.num_legs].le_place, false, false, ptr->flags ) );
1942
                         ptr->flags.disqualified, team_buf.leg[0].elapsed ) );
-
 
1943
    }
2125
    }
1944
 
2126
 
1945
    print_class_stats( last_class, FALSE );
2127
    print_class_stats( last_class, FALSE );
1946
    print_legend(last_class, 1);
2128
    print_legend(last_class, 1);
1947
    close_printer();
2129
    close_printer();
Line 2033... Line 2215...
2033
    csv_print( "%s", "Flag:valid Team");
2215
    csv_print( "%s", "Flag:valid Team");
2034
    csv_print( "%s", "Flag:bad_times" );
2216
    csv_print( "%s", "Flag:bad_times" );
2035
    csv_print( "%s", "Flag:disqualified" );
2217
    csv_print( "%s", "Flag:disqualified" );
2036
    csv_print( "%s", "Flag:non_equestrian" );
2218
    csv_print( "%s", "Flag:non_equestrian" );
2037
    csv_print( "%s", "Flag:vet_check" );
2219
    csv_print( "%s", "Flag:vet_check" );
-
 
2220
 
-
 
2221
    // Not available as the data is only in-memory
-
 
2222
    // csv_print( "%s", "Flag:notInFastest" );
-
 
2223
    // csv_print( "%s", "Flag:notInSort" );
-
 
2224
 
2038
    csv_print("\n");
2225
    csv_print("\n");
2039
 
2226
 
2040
 
2227
 
2041
    for( i = config.min_team; i <= config.max_team; i++ )
2228
    for( i = config.min_team; i <= config.max_team; i++ )
2042
    {
2229
    {
Line 2113... Line 2300...
2113
            csv_print( "%d", team_buf.flags.valid );
2300
            csv_print( "%d", team_buf.flags.valid );
2114
            csv_print( "%d", team_buf.flags.bad_times );
2301
            csv_print( "%d", team_buf.flags.bad_times );
2115
            csv_print( "%d", team_buf.flags.disqualified );
2302
            csv_print( "%d", team_buf.flags.disqualified );
2116
            csv_print( "%d", team_buf.flags.non_equestrian );
2303
            csv_print( "%d", team_buf.flags.non_equestrian );
2117
            csv_print( "%d", team_buf.flags.vet_check );
2304
            csv_print( "%d", team_buf.flags.vet_check );
-
 
2305
            // Not available as the data is only in-memory
-
 
2306
            // csv_print( "%d", team_buf.flags.notInFastest );
-
 
2307
            // csv_print( "%d", team_buf.flags.notInSort );
2118
 
2308
 
2119
//How about class placings
2309
//How about class placings
2120
 
2310
 
2121
 
2311
 
2122
            csv_print( "\n" );
2312
            csv_print( "\n" );
Line 2167... Line 2357...
2167
        
2357
        
2168
        report_html = text;
2358
        report_html = text;
2169
    }
2359
    }
2170
 
2360
 
2171
    pri_final();
2361
    pri_final();
-
 
2362
    pri_final_teamOrder();
2172
    pri_final_html();
2363
    pri_final_html();
2173
    pri_csv_data();
2364
    pri_csv_data();
2174
    pri_summary_html();
2365
    pri_summary_html();
2175
    pri_summary();
2366
    pri_summary();
2176
    pri_awards_html();
2367
    pri_awards_html();
2177
    pri_awards();
2368
    pri_awards();
2178
    pri_master_index();
2369
    pri_master_index();
2179
 
2370
 
-
 
2371
    report_html = html;
-
 
2372
    pri_interim();
-
 
2373
    report_html = text;
2180
    pri_interim();
2374
    pri_interim();
2181
 
2375
 
2182
    report_all = FALSE;
2376
    report_all = FALSE;
2183
}
2377
}
2184
 
2378
 
Line 2214... Line 2408...
2214
    **  Now printout the column headings
2408
    **  Now printout the column headings
2215
    **  This is a two line display
2409
    **  This is a two line display
2216
    **
2410
    **
2217
    **  Line-1  Leg names
2411
    **  Line-1  Leg names
2218
    */
2412
    */
-
 
2413
 
-
 
2414
    if (config.num_legs == 1 ) {
-
 
2415
        print( "%-*s", 4, "" );
-
 
2416
        print( "  %-*s", 18, config.leg_name[0] );
-
 
2417
        print( " %-*s", MAX_TM_NAME + 1, "" );
-
 
2418
        print( "%-4s\n", ( teamclass < 0 ) ? "Cat" : "Fin" );
-
 
2419
 
-
 
2420
    } else {
2219
    print( "%-*s %-*s %-*s", 4, "", 4, "", 3, "" );
2421
        print( "%-*s %-*s %-*s", 4, "", 4, "", 3, "" );
2220
    for( j = 1; j <= config.num_legs; j++ )
2422
        for( j = 1; j <= config.num_legs; j++ )
2221
    {
2423
        {
2222
        print_bold( TRUE );
2424
            print_bold( TRUE );
2223
        print( "  %-*s", 18, config.leg_name[j - 1] );
2425
            print( "  %-*s", 18, config.leg_name[j - 1] );
2224
        print_bold( FALSE );
2426
            print_bold( FALSE );
-
 
2427
        }
-
 
2428
        print( "  %-8s %-4s\n", "Total", ( teamclass < 0 ) ? "Cat" : "Fin" );
2225
    }
2429
    }
2226
    print( "  %-8s %-4s\n", "Total", ( teamclass < 0 ) ? "Cat" : "Fin" );
-
 
-
 
2430
 
-
 
2431
 
2227
 
2432
 
2228
 
2433
 
2229
    /*
2434
    /*
2230
    **  Line-2  Details
2435
    **  Line-2  Details
2231
    */
2436
    */
2232
    print_underline( TRUE );
2437
    print_underline( TRUE );
2233
    print( "%-*s %*s %-*s", 4, final ? "Plce" : "Team",
2438
    print( "%-*s %*s %-*s", 4, final ? "Plce" : "Team",
2234
                            4, final ? "Team" : "Plce",
2439
                            4, final ? "Team" : "Plce",
2235
                            3, "Cat" );
2440
                            3, "Cat" );
2236
 
2441
 
2237
    for( j = 1; j <= config.num_legs; j++ )
-
 
2238
        print( "  %-8s %-4s %-4s", "Time", " LP", " EP" );
-
 
2239
 
2442
 
-
 
2443
    if (config.num_legs == 1 ) {
-
 
2444
        print( "  %-8s", "Time" );
-
 
2445
        print( " %-*s", MAX_TM_NAME + 1, "Team Name" );
-
 
2446
        print( "%-4s\n", "Plce" );
-
 
2447
 
-
 
2448
    } else {
-
 
2449
        for( j = 1; j <= config.num_legs; j++ )
-
 
2450
            print( "  %-8s %-4s %-4s", "Time", " LP", " EP" );
2240
    print( "  %-8s %-4s\n", "Time", "Plce" );
2451
        print( "  %-8s %-4s\n", "Time", "Plce" );
-
 
2452
    }
-
 
2453
 
-
 
2454
 
2241
    print_underline( FALSE );
2455
    print_underline( FALSE );
2242
}
2456
}
2243
 
2457
 
2244
/*========================================================================
2458
/*========================================================================
2245
 *
2459
 *
Line 2288... Line 2502...
2288
    {
2502
    {
2289
        print_bold( TRUE );
2503
        print_bold( TRUE );
2290
        print( "%-13s  ", config.leg_name[i - 1] );
2504
        print( "%-13s  ", config.leg_name[i - 1] );
2291
        print_bold( FALSE );
2505
        print_bold( FALSE );
2292
    }
2506
    }
2293
    print( "%-13s  \n", final ? "Total" : "" );
2507
    if ( config.num_legs != 1 ) print( "%-13s  ", final ? "Total" : "" );
-
 
2508
    print( "\n" );
2294
 
2509
 
2295
    /*
2510
    /*
2296
    **  Print the fastest teams for each leg and overall
2511
    **  Print the fastest teams for each leg and overall
2297
    **  Add cross references to the team names for the fastest teams
2512
    **  Add cross references to the team names for the fastest teams
2298
    */
2513
    */
Line 2310... Line 2525...
2310
 
2525
 
2311
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "name" ,"html")), stats.fast.team[j][c] );
2526
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "name" ,"html")), stats.fast.team[j][c] );
2312
        print( "%4d",  stats.fast.team[j][c] );
2527
        print( "%4d",  stats.fast.team[j][c] );
2313
        if ( report_html == html ) print( "</A>" );
2528
        if ( report_html == html ) print( "</A>" );
2314
        print( " %s  ", time_a( stats.fast.time[j][c] ) );
2529
        print( " %s  ", time_a( stats.fast.time[j][c] ) );
-
 
2530
        if ( config.num_legs == 1 ) break;
2315
    }
2531
    }
2316
    print( "\n" );
2532
    print( "\n" );
2317
 
2533
 
2318
    /*
2534
    /*
2319
    **  Print the average time for each leg
2535
    **  Print the average time for each leg
Line 2328... Line 2544...
2328
                j = 0;                           /* Leg-0 last */
2544
                j = 0;                           /* Leg-0 last */
2329
            else
2545
            else
2330
                break;
2546
                break;
2331
        }
2547
        }
2332
        print( "     %s  ", time_a( stats.average[j][c] ) );
2548
        print( "     %s  ", time_a( stats.average[j][c] ) );
-
 
2549
        if ( config.num_legs == 1 ) break;
2333
    }
2550
    }
2334
}
2551
}
2335
 
2552
 
2336
/*========================================================================
2553
/*========================================================================
2337
 *
2554
 *
Line 2369... Line 2586...
2369
 
2586
 
2370
    for( i = 1, count = 0; i <= config.num_class; i++ )
2587
    for( i = 1, count = 0; i <= config.num_class; i++ )
2371
    {
2588
    {
2372
        if (!config.team_class[i - 1].abr[0])
2589
        if (!config.team_class[i - 1].abr[0])
2373
            continue;
2590
            continue;
2374
#if 0
2591
 
2375
        /*
-
 
2376
        **  Skip any non-equestrian class in the legend
-
 
2377
        **  Don't want to tell the general user whats goes on, unless we actually
-
 
2378
        **  creating the non-equestrian report.
-
 
2379
        */
-
 
2380
        if ( class != config.nonequestrian_class  && i == config.nonequestrian_class )
-
 
2381
            continue;
-
 
2382
#endif
-
 
2383
        if ( report_html == html ) print( "<A HREF=\"%s\">",url_encode(p_filename(filebase, config.team_class[i - 1].abr ,"html")) );
2592
        if ( report_html == html ) print( "<A HREF=\"%s\">",url_encode(p_filename(filebase, config.team_class[i - 1].abr ,"html")) );
2384
        print( "%-*s", 3, config.team_class[i - 1].abr );
2593
        print( "%-*s", 3, config.team_class[i - 1].abr );
2385
        if ( report_html == html ) print( "</A>" );
2594
        if ( report_html == html ) print( "</A>" );
2386
        print( " : %-*s  ", LEN_CLASS_NAME, config.team_class[i - 1].full_name );
2595
        print( " : %-*s  ", LEN_CLASS_NAME, config.team_class[i - 1].full_name );
2387
 
2596
 
Line 2427... Line 2636...
2427
    /*
2636
    /*
2428
     * Other comments 
2637
     * Other comments 
2429
     */
2638
     */
2430
    if ( full )
2639
    if ( full )
2431
    {
2640
    {
-
 
2641
        if ( config.num_legs != 1 )  {
-
 
2642
            print( "\n" );
-
 
2643
            if ( report_html ) print_underline(TRUE);
2432
        print( "\nPlace numbers (LP and EP)\n" );
2644
            print( "Place numbers (LP and EP)" );
-
 
2645
            if ( report_html ) print_underline(FALSE);
-
 
2646
            print( "\n" );
2433
        print( "LP - Placing based on elapsed time within the leg.                Cat Plce - Placing within the category.\n" );
2647
            print( "LP - Placing based on elapsed time within the leg.                Cat Plce - Placing within the category.\n" );
2434
        print( "EP - Placing based on accumulated times to the end of that leg.   Fin Plce - Overall placing within the event.\n" );
2648
            print( "EP - Placing based on accumulated times to the end of that leg.   Fin Plce - Overall placing within the event.\n" );
2435
        print( "U  - Placing not available.\n" );
2649
            print( "U  - Placing not available.\n" );
-
 
2650
        } else {
-
 
2651
            print( "\n" );
-
 
2652
            if ( report_html ) print_underline(TRUE);
-
 
2653
            print( "Table Legend" );
-
 
2654
            if ( report_html ) print_underline(FALSE);
-
 
2655
            print( "\n" );
-
 
2656
 
-
 
2657
            print( "Cat Plce - Placing within the category.\n");
-
 
2658
            print ("Fin Plce - Overall placing within the event.\n" );
-
 
2659
            print( "U        - Placing not available.\n" );
-
 
2660
        }
2436
    }
2661
    }
2437
 
2662
 
2438
    /*
2663
    /*
2439
     *  Insert the contents of the config.addendum file
2664
     *  Insert the contents of the config.addendum file
2440
     *  or a defualt message
2665
     *  or a defualt message
Line 2450... Line 2675...
2450
 
2675
 
2451
    if( adfile )
2676
    if( adfile )
2452
    {
2677
    {
2453
        while( fgets( line, sizeof(line)-1, adfile ) )
2678
        while( fgets( line, sizeof(line)-1, adfile ) )
2454
            print( "%s", line );
2679
            print( "%s", line );
-
 
2680
        fclose (adfile);
2455
    }
2681
    }
2456
    else
2682
    else
2457
    {
2683
    {
2458
        print( "\nTiming and Results by\n" );
2684
        print( "\nTiming and Results by\n" );
2459
        print( "Embedded Solutions\n" );
2685
        print( "Embedded Solutions\n" );
2460
    }
2686
    }
2461
}
2687
}
2462
 
2688
 
2463
/*========================================================================
-
 
2464
 *
-
 
2465
 *  Return place data
-
 
2466
 *
-
 
2467
 *  Purpose:
-
 
2468
 *      This function is called to return place data
-
 
2469
 *
-
 
2470
 *      This routine is called to fill a print team_buffer - to allow for
-
 
2471
 *      multiple calls to this function ( before the data is used ) a number
-
 
2472
 *      of static team_buffers are maintained
-
 
2473
 *
-
 
2474
 *  Parameters:
-
 
2475
 *      num         place - if not bad_times
-
 
2476
 *      disq        Disqualified flag
-
 
2477
 *      time        Time data is based on
-
 
2478
 *
-
 
2479
 *  Returns:
-
 
2480
 *      This function returns a pointer to the character string for the
-
 
2481
 *      number or a pointer to a bad_times string.
-
 
2482
 *
-
 
2483
 *========================================================================*/
-
 
2484
 
-
 
2485
const char       *pi_place( int num, int disq, time_t time )
-
 
2486
{
-
 
2487
    static char store[2][5];                     /* 2 stores for 4 digit numbers */
-
 
2488
    static int  i = 0;                           /* Current index into store */
-
 
2489
    static const char *dis = "D";                      /* Disqualified */
-
 
2490
    static const char *non = "-";                      /* Invalid time */
-
 
2491
 
-
 
2492
    if( disq )                                   /* Disqualified team */
-
 
2493
        return ( dis );
-
 
2494
    if( time <= 0 )                              /* Unknown time */
-
 
2495
        return ( non );
-
 
2496
 
-
 
2497
    i++;
-
 
2498
    if( i >= 2 )
-
 
2499
        i = 0;                                   /* Select next entry */
-
 
2500
    sprintf( store[i], "%4d", num );
-
 
2501
    return ( store[i] );
-
 
2502
 
-
 
2503
}
-
 
2504
 
2689
 
2505
/*========================================================================
2690
/*========================================================================
2506
 *
2691
 *
2507
 *  Return place data
2692
 *  Return place data or NE flag
2508
 *
2693
 *
2509
 *  Purpose:
2694
 *  Purpose:
2510
 *      This function is called to Return place data
2695
 *      This function is called to Return place data
2511
 *
2696
 *
2512
 *      This routine is called to fill a print team_buffer - to allow for
2697
 *      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
2698
 *      multiple calls to this function ( before the data is used ) a number
2514
 *      of static team_buffers are maintained
2699
 *      of static team_buffers are maintained
2515
 *
2700
 *
2516
 *  Parameters:
2701
 *  Parameters:
-
 
2702
 *      leg         Leg number being processed or
-
 
2703
 *                  -1: Unplaced on any bad flag
2517
 *      num         place - if not bad_times
2704
 *      num         place - if valid time
-
 
2705
 *      epMode      true:  Event Time Mode - Show V and NE flags
-
 
2706
 *                  false: Leg Time Mode -
-
 
2707
 *      neMode      true: Display NE for NE Teams
-
 
2708
 *                  false: Display data for NE teams
2518
 *      disq        Disqualified flag
2709
 *      flags       Team flags
2519
 *
2710
 *
2520
 *  Returns:
2711
 *  Returns:
2521
 *      This function returns a pointer to the character string for the
2712
 *      This function returns a pointer to the character string for the
2522
 *      number or a pointer to a bad_times string.
2713
 *      number or a pointer to a status string.
2523
 *
2714
 *
2524
 *========================================================================*/
2715
 *========================================================================*/
2525
 
-
 
2526
const char *pr_place( int num, int disq )
2716
const char *px_place( int leg, int num, bool epMode, bool neMode, team_flags flags )
2527
{
2717
{
2528
    static char store[2][5];                     /* 2 stores for 4 digit numbers */
2718
    static char store[2][5];                     /* 2 stores for 4 digit numbers */
2529
    static int  i = 0;                           /* Current index into store */
2719
    static int  i = 0;                           /* Current index into store */
2530
    static const char *dis = "U";
2720
    static const char *dis = "U";
-
 
2721
    static const char *alt = "NE";
-
 
2722
    static const char *vet = "U";
2531
 
2723
 
2532
    if( disq )
2724
    if (flags.bad_times || flags.disqualified || !flags.valid)
2533
        return ( dis );
2725
        return dis;
2534
 
2726
 
2535
    i++;
-
 
2536
    if( i >= 2 )
-
 
2537
        i = 0;                                   /* Select next entry */
-
 
2538
    sprintf( store[i], "%4d", num );
2727
    if (leg == -1 && flags.vet_check )
2539
    return ( store[i] );
2728
        return vet;
2540
 
2729
 
-
 
2730
    if (neMode && flags.non_equestrian && (leg >= config.equestrian_leg || leg == 0))
2541
}
2731
        return alt;
2542
 
2732
 
2543
/*========================================================================
-
 
2544
 *
-
 
2545
 *  Return place data or NE flag
-
 
2546
 *
-
 
2547
 *  Purpose:
-
 
2548
 *      This function is called to Return place data
-
 
2549
 *
-
 
2550
 *      This routine is called to fill a print team_buffer - to allow for
-
 
2551
 *      multiple calls to this function ( before the data is used ) a number
2733
    if (epMode && flags.vet_check && leg >= config.equestrian_leg)
2552
 *      of static team_buffers are maintained
-
 
2553
 *
-
 
2554
 *  Parameters:
-
 
2555
 *      num         place - if not bad_times
-
 
2556
 *      disq        Disqualified flag
-
 
2557
 *      flag        Flag NE data
-
 
2558
 *
-
 
2559
 *  Returns:
2734
        return vet;
2560
 *      This function returns a pointer to the character string for the
-
 
2561
 *      number or a pointer to a bad_times string.
-
 
2562
 *
-
 
2563
 *========================================================================*/
-
 
2564
const char *pn_place( int num, int disq, bool flag )
-
 
2565
{
2735
 
2566
    static char store[2][5];                     /* 2 stores for 4 digit numbers */
-
 
2567
    static int  i = 0;                           /* Current index into store */
2736
    if ( flags.vet_check && (leg == config.equestrian_leg || leg == 0))
2568
    static const char *dis = "U";
2737
        return vet;
2569
    static const char *alt = "NE";
-
 
2570
 
2738
 
2571
    if( disq )
2739
    if (num <= 0)
2572
        return ( dis );
2740
        return dis;
2573
    if (flag)
-
 
2574
        return ( alt );
-
 
2575
 
2741
 
2576
    i++;
2742
    i++;
2577
    if( i >= 2 )
2743
    if( i >= 2 )
2578
        i = 0;                                   /* Select next entry */
2744
        i = 0;                                   /* Select next entry */
2579
    sprintf( store[i], "%4d", num );
2745
    sprintf( store[i], "%4d", num );
Line 2594... Line 2760...
2594
 *      and the report process can be aborted
2760
 *      and the report process can be aborted
2595
 *
2761
 *
2596
 *  Parameters:
2762
 *  Parameters:
2597
 *      leg             Leg to test
2763
 *      leg             Leg to test
2598
 *      mode            Either end or elapsed times to be tested
2764
 *      mode            Either end or elapsed times to be tested
-
 
2765
 *                          C_END     - Printing in Leg Finishing Time
-
 
2766
 *                          C_DISQUAL - Interim results
-
 
2767
 *                          C_ELAPSED - Elapsed times
2599
 *
2768
 *
2600
 *  Returns:
-
 
2601
 *      Returns FALSE if the report operation is to be aborted
-
 
2602
 *
2769
 *
2603
 *========================================================================*/
2770
 *========================================================================*/
2604
 
2771
 
2605
bool ck_data( int leg, int mode )
2772
void ck_data( int leg, int mode )
2606
{
2773
{
2607
    ty_s_data  *ptr;
2774
    ty_s_data  *ptr;
2608
    unsigned    i;
2775
    unsigned    i;
2609
    int         bad = 0;
2776
    int         bad = 0;
2610
    int         k;
2777
    int         k;
Line 2625... Line 2792...
2625
            t = ptr->lege;
2792
            t = ptr->lege;
2626
        else
2793
        else
2627
            t = ptr->leg;
2794
            t = ptr->leg;
2628
 
2795
 
2629
 
2796
 
2630
        ptr->flags.bad_times = ptr->flags.disqualified;
2797
        // If the team is duff, then don;t include in Event or Leg Calcs
2631
        if( ! ptr->flags.bad_times )
2798
        if( !ptr->flags.valid || ptr->flags.bad_times || ptr->flags.disqualified)
2632
        {
2799
        {
-
 
2800
            ptr->flags.notInLP = TRUE;
-
 
2801
        }
-
 
2802
        else
-
 
2803
        {
-
 
2804
            // If any of the leg times are duff, then don't include the leg Event Calcs
-
 
2805
 
2633
            if( leg <= 0 )
2806
            if( leg <= 0 )
2634
            {
2807
            {
2635
                for( k = 0; k <= config.num_legs; k++ )
2808
                for( k = 0; k <= config.num_legs; k++ )
2636
                {
2809
                {
2637
                    if ( !(config.equestrian_leg && ptr->flags.non_equestrian && config.equestrian_leg == k  ))
2810
                    if ( !(config.equestrian_leg && ptr->flags.non_equestrian && config.equestrian_leg == k  ))
Line 2643... Line 2816...
2643
                bad_leg = t[leg] <= 0;
2816
                bad_leg = t[leg] <= 0;
2644
            }
2817
            }
2645
 
2818
 
2646
            if( bad_leg )
2819
            if( bad_leg )
2647
            {
2820
            {
2648
                ptr->flags.bad_times = TRUE;
-
 
2649
                
-
 
2650
                if ( ! report_all )
2821
                if ( ! report_all )
2651
                {
2822
                {
2652
                    qDebug( "Team with incorrect time information: %d", ptr->team  );
2823
                    qDebug( "Team with incorrect time information: %d", ptr->team  );
2653
                    bad++;
2824
                    bad++;
2654
                }
2825
                }
Line 2658... Line 2829...
2658
 
2829
 
2659
    if( bad )
2830
    if( bad )
2660
    {
2831
    {
2661
        qDebug( "%d teams with incorrect times. These have been flagged as unplaced", bad );
2832
        qDebug( "%d teams with incorrect times. These have been flagged as unplaced", bad );
2662
    }
2833
    }
2663
    return ( FALSE );
-
 
2664
}
2834
}
2665
 
2835
 
2666
/*========================================================================
2836
/*========================================================================
2667
 *
2837
 *
2668
 *  Update placing information
2838
 *  Update placing information
Line 2687... Line 2857...
2687
 *
2857
 *
2688
 *========================================================================*/
2858
 *========================================================================*/
2689
 
2859
 
2690
void srt_place(void)
2860
void srt_place(void)
2691
{
2861
{
2692
    if( ck_data( -1, C_ELAPSED ) )
2862
    ck_data( -1, C_ELAPSED );
2693
        return;
-
 
2694
    do_big_sort();
2863
    do_big_sort();
2695
 
2864
 
2696
    /*
2865
    /*
2697
     * Generate the stats
2866
     * Generate the stats
2698
     */
2867
     */
Line 2948... Line 3117...
2948
        sort_team_data( i, S_L, sortWithEq );
3117
        sort_team_data( i, S_L, sortWithEq );
2949
        for( j = 1, k = 1, q = 1, ptr = sort_data; j <= sort_num; ptr++, j++ )
3118
        for( j = 1, k = 1, q = 1, ptr = sort_data; j <= sort_num; ptr++, j++ )
2950
        {
3119
        {
2951
            sort_aux[ptr->team].team = ptr->team;
3120
            sort_aux[ptr->team].team = ptr->team;
2952
 
3121
 
-
 
3122
            if (i == config.equestrian_leg || i == 0) {
-
 
3123
                if (ptr->flags.bad_times || ptr->flags.disqualified || ptr->flags.vet_check) {
-
 
3124
                    if (ptr->isNeData) {
-
 
3125
                        sort_aux[ptr->team].lq_place[i] = -1;
-
 
3126
                    } else {
-
 
3127
                        sort_aux[ptr->team].l_place[i] = -1;
-
 
3128
                    }
-
 
3129
                    continue;
-
 
3130
                }
-
 
3131
            }
-
 
3132
 
-
 
3133
            // Flag as unplaced NE teams on the EQ leg
-
 
3134
            // DO NOT Flag as unplaced in overall (leg:0) NE teams as this is used in the full report
-
 
3135
            if ( (i == config.equestrian_leg /*|| i == 0*/ ) && ptr->flags.non_equestrian ) {
-
 
3136
                if (ptr->isNeData) {
-
 
3137
                    sort_aux[ptr->team].lq_place[i] = -1;
-
 
3138
                } else {
-
 
3139
                    sort_aux[ptr->team].l_place[i] = -1;
-
 
3140
                }
-
 
3141
                continue;
-
 
3142
            }
-
 
3143
 
2953
            if (ptr->isNeData) {
3144
            if (ptr->isNeData) {
2954
                sort_aux[ptr->team].lq_place[i] = q++;
3145
                sort_aux[ptr->team].lq_place[i] = q++;
2955
            } else {
3146
            } else {
2956
                sort_aux[ptr->team].l_place[i] = k++;
3147
                sort_aux[ptr->team].l_place[i] = k++;
2957
            }
3148
            }
Line 2962... Line 3153...
2962
        **  Then save the teams place at the end of each leg
3153
        **  Then save the teams place at the end of each leg
2963
        */
3154
        */
2964
        sort_team_data( i, S_LE, sortWithEq);
3155
        sort_team_data( i, S_LE, sortWithEq);
2965
        for( j = 1, k = 1, q = 1, ptr = sort_data; j <= sort_num; ptr++, j++ )
3156
        for( j = 1, k = 1, q = 1, ptr = sort_data; j <= sort_num; ptr++, j++ )
2966
        {
3157
        {
-
 
3158
            if (i == 0 || i == config.equestrian_leg || sort_afterEquestrianLeg ) {
-
 
3159
                if (ptr->flags.bad_times || ptr->flags.disqualified || ptr->flags.vet_check) {
-
 
3160
                    if (ptr->isNeData) {
-
 
3161
                        sort_aux[ptr->team].leq_place[i] = -1;
-
 
3162
                    } else {
-
 
3163
                        sort_aux[ptr->team].le_place[i] = -1;
-
 
3164
                    }
-
 
3165
                    continue;
-
 
3166
                }
-
 
3167
            }
-
 
3168
 
-
 
3169
            // Flag as unplaced NE teams on the EQ leg
-
 
3170
            // Flag as unplaced NE teams after the EQ leg
-
 
3171
            // Flag as unplaced in overall (leg:0) NE teams
-
 
3172
            if ( (i == config.equestrian_leg || sort_afterEquestrianLeg || i == 0 ) && ptr->flags.non_equestrian ) {
2967
            if (ptr->isNeData) {
3173
                if (ptr->isNeData) {
2968
                sort_aux[ptr->team].leq_place[i] = q++;
3174
                    sort_aux[ptr->team].leq_place[i] = -1;
-
 
3175
                } else {
-
 
3176
                    sort_aux[ptr->team].le_place[i] = -1;
-
 
3177
                }
-
 
3178
                continue;
2969
            }
3179
            }
2970
            else {
-
 
2971
 
3180
 
-
 
3181
            if (ptr->isNeData) {
-
 
3182
                sort_aux[ptr->team].leq_place[i] = q++;
-
 
3183
            } else {
2972
                sort_aux[ptr->team].le_place[i] = k++;
3184
                sort_aux[ptr->team].le_place[i] = k++;
2973
            }
3185
            }
2974
        }
3186
        }
2975
 
3187
 
2976
        /*
3188
        /*
Line 2990... Line 3202...
2990
            else {
3202
            else {
2991
                if (ptr->isNeData)
3203
                if (ptr->isNeData)
2992
                    isNe = true;
3204
                    isNe = true;
2993
            }
3205
            }
2994
 
3206
 
-
 
3207
            // Flag as unplaced NE teams on the EQ leg
-
 
3208
            if (i == 0 || i == config.equestrian_leg) {
-
 
3209
                if (ptr->flags.bad_times || ptr->flags.disqualified || ptr->flags.vet_check) {
-
 
3210
                    if (isNe) {
-
 
3211
                        sort_aux[ptr->team].lq_place[i] = -1;
-
 
3212
                    } else {
-
 
3213
                        sort_aux[ptr->team].lc_place[i] = -1;
-
 
3214
                    }
-
 
3215
                    continue;
-
 
3216
                }
-
 
3217
            }
-
 
3218
 
-
 
3219
            if ( i == config.equestrian_leg && ptr->flags.non_equestrian ) {
-
 
3220
                if (ptr->isNeData) {
-
 
3221
                    sort_aux[ptr->team].lq_place[i] = -1;
-
 
3222
                } else {
-
 
3223
                    sort_aux[ptr->team].lc_place[i] = -1;
-
 
3224
                }
-
 
3225
                continue;
-
 
3226
            }
-
 
3227
 
2995
            if (isNe) {
3228
            if (isNe) {
2996
                if( teamclassq != ptr->teamclass )
3229
                if( teamclassq != ptr->teamclass )
2997
                {
3230
                {
2998
                    q = 1;
3231
                    q = 1;
2999
                    teamclassq = ptr->teamclass;
3232
                    teamclassq = ptr->teamclass;
Line 3008... Line 3241...
3008
                    k = 1;
3241
                    k = 1;
3009
                    teamclass = ptr->teamclass;
3242
                    teamclass = ptr->teamclass;
3010
                }
3243
                }
3011
                sort_aux[ptr->team].lc_place[i] = k++;
3244
                sort_aux[ptr->team].lc_place[i] = k++;
3012
            }
3245
            }
-
 
3246
 
3013
        }
3247
        }
3014
 
3248
 
3015
        /*
3249
        /*
3016
        **  Sort on end time per class
3250
        **  Sort on end time per class
3017
        **  Then save the teams place at the end of each leg per class
3251
        **  Then save the teams place at the end of each leg per class
Line 3029... Line 3263...
3029
            else {
3263
            else {
3030
                if (ptr->isNeData)
3264
                if (ptr->isNeData)
3031
                    isNe = true;
3265
                    isNe = true;
3032
            }
3266
            }
3033
 
3267
 
-
 
3268
            if (i == 0 || i == config.equestrian_leg || sort_afterEquestrianLeg) {
-
 
3269
                if (ptr->flags.bad_times || ptr->flags.disqualified || ptr->flags.vet_check) {
-
 
3270
                    if (isNe) {
-
 
3271
                        sort_aux[ptr->team].leq_place[i] = -1;
-
 
3272
                    } else {
-
 
3273
                        sort_aux[ptr->team].lec_place[i] = -1;
-
 
3274
                    }
-
 
3275
                    continue;
-
 
3276
                }
-
 
3277
            }
-
 
3278
 
-
 
3279
            // Flag as unplaced NE teams on the EQ leg
-
 
3280
            // Flag as unplaced NE teams after the EQ leg
-
 
3281
            // Flag as unplaced in overall (leg:0) NE teams
-
 
3282
            if ( (i == config.equestrian_leg || sort_afterEquestrianLeg || i == 0 ) && ptr->flags.non_equestrian ) {
-
 
3283
                if (ptr->isNeData) {
-
 
3284
                    sort_aux[ptr->team].leq_place[i] = -1;
-
 
3285
                } else {
-
 
3286
                    sort_aux[ptr->team].lec_place[i] = -1;
-
 
3287
                }
-
 
3288
                continue;
-
 
3289
            }
-
 
3290
 
3034
            if (isNe) {
3291
            if (isNe) {
3035
                if( teamclassq != ptr->teamclass )
3292
                if( teamclassq != ptr->teamclass )
3036
                {
3293
                {
3037
                    q = 1;
3294
                    q = 1;
3038
                    teamclassq = ptr->teamclass;
3295
                    teamclassq = ptr->teamclass;
Line 3045... Line 3302...
3045
                    k = 1;
3302
                    k = 1;
3046
                    teamclass = ptr->teamclass;
3303
                    teamclass = ptr->teamclass;
3047
                }
3304
                }
3048
                sort_aux[ptr->team].lec_place[i] = k++;
3305
                sort_aux[ptr->team].lec_place[i] = k++;
3049
            }
3306
            }
-
 
3307
 
3050
        }
3308
        }
3051
    }
3309
    }
3052
 
3310
 
3053
    /*
3311
    /*
3054
    **  Write the place information back to disk for use in the displays
3312
    **  Write the place information back to disk for use in the displays
Line 3093... Line 3351...
3093
    ty_s_data  *ptr;
3351
    ty_s_data  *ptr;
3094
 
3352
 
3095
    sort_leg = leg;                              /* Leg is global for the comparison function */
3353
    sort_leg = leg;                              /* Leg is global for the comparison function */
3096
    sort_mode = mode;                            /* Mode is global for compare function */
3354
    sort_mode = mode;                            /* Mode is global for compare function */
3097
    sort_withEquestrian = withEq;                /* Mode is global for compare function */
3355
    sort_withEquestrian = withEq;                /* Mode is global for compare function */
-
 
3356
    sort_afterEquestrianLeg = ( config.equestrian_leg && leg > config.equestrian_leg);
3098
 
3357
 
3099
    qsort( ( char * ) sort_data, sort_num, sizeof( ty_s_data ), sort_comp );
3358
    qsort( ( char * ) sort_data, sort_num, sizeof( ty_s_data ), sort_comp );
3100
 
3359
 
3101
    /*
3360
    /*
3102
     * Insert "place data" into the sorted data
3361
     * Insert "place data" into the sorted data
Line 3107... Line 3366...
3107
    for( j = 1; j <= sort_num; j++, ptr++ )
3366
    for( j = 1; j <= sort_num; j++, ptr++ )
3108
    {
3367
    {
3109
        ptr->place = j;
3368
        ptr->place = j;
3110
    }
3369
    }
3111
 
3370
 
-
 
3371
    //qDebug() << "sort_team_data: Leg:" << leg << ",M:" << mode << ",E:" << withEq;
-
 
3372
 
-
 
3373
 
3112
}
3374
}
3113
 
3375
 
3114
/*========================================================================
3376
/*========================================================================
3115
 *
3377
 *
3116
 *  qsort comparison function
3378
 *  qsort comparison function
Line 3212... Line 3474...
3212
    **
3474
    **
3213
    **  If not sorting within a class (ie Overall), then Non_Equestrian
3475
    **  If not sorting within a class (ie Overall), then Non_Equestrian
3214
    **  is better than a bad time. Places NE before disqualified
3476
    **  is better than a bad time. Places NE before disqualified
3215
    **
3477
    **
3216
    */
3478
    */
-
 
3479
    bool aNoSort = false;
-
 
3480
    bool bNoSort = false;
-
 
3481
 
-
 
3482
    if ( sort_leg != 0 && (sort_mode == S_LC || sort_mode == S_L ) ) {
-
 
3483
        aNoSort = a->flags.notInLP;
-
 
3484
        bNoSort = b->flags.notInLP;
-
 
3485
    }
-
 
3486
 
-
 
3487
    if ( sort_withEquestrian && (sort_mode == S_LC || sort_mode == S_L ) ) {
-
 
3488
        if (a->flags.vet_check)
-
 
3489
            aNoSort = true;
-
 
3490
        if (b->flags.vet_check)
-
 
3491
            bNoSort = true;
-
 
3492
    }
-
 
3493
 
-
 
3494
    if (a->flags.bad_times || a->flags.disqualified || !a->flags.valid)
-
 
3495
        aNoSort = true;
-
 
3496
 
-
 
3497
    if (b->flags.bad_times || b->flags.disqualified || !b->flags.valid)
-
 
3498
        bNoSort = true;
-
 
3499
 
-
 
3500
    if ( sort_mode == S_FIN || sort_mode == S_IFIN ) {
-
 
3501
        if (a->flags.vet_check)
-
 
3502
            aNoSort = true;
-
 
3503
        if (b->flags.vet_check)
-
 
3504
            bNoSort = true;
-
 
3505
    }
-
 
3506
 
-
 
3507
    // On the Equestrian Leg, vetted out teams are treated as disqualified
3217
    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 */
3508
    if (sort_leg == config.equestrian_leg || (sort_afterEquestrianLeg && ( sort_mode == S_LE || sort_mode == S_LEC))) {
-
 
3509
        if (a->flags.vet_check)
-
 
3510
            aNoSort = true;
-
 
3511
        if (b->flags.vet_check)
-
 
3512
            bNoSort = true;
-
 
3513
    }
-
 
3514
 
-
 
3515
    if (aNoSort && bNoSort)
-
 
3516
        return ( a->team - b->team );
-
 
3517
 
-
 
3518
    if (aNoSort || bNoSort)
-
 
3519
        return ( aNoSort ? 1 : -1 );
-
 
3520
 
-
 
3521
    if( sort_withEquestrian && sort_mode != S_FIN && sort_mode != S_IFIN )
3218
    {
3522
    {
3219
        if( a->flags.bad_times && b->flags.bad_times )
3523
        if( a->flags.non_equestrian && b->flags.non_equestrian )
3220
        {
-
 
3221
            return ( a->team - b->team );
-
 
3222
        }
-
 
3223
        else if( a->flags.bad_times || b->flags.bad_times )
-
 
3224
        {
3524
        {
-
 
3525
            /*
-
 
3526
            **  Both are non equestrian
-
 
3527
            **  Let the time sort operate ...
-
 
3528
            */
3225
            return ( a->flags.bad_times ? 1 : -1 );
3529
            //return ( a->team - b->team );
3226
        }
3530
        }
3227
        if( sort_mode != S_FIN && sort_mode != S_IFIN )
3531
        else if( a->flags.non_equestrian || b->flags.non_equestrian )
3228
        {
3532
        {
3229
            if( a->flags.non_equestrian && b->flags.non_equestrian )
-
 
3230
            {
-
 
3231
                /*
-
 
3232
                **  Both are non equestrian
-
 
3233
                **  Let the time sort operate ...
-
 
3234
                */
-
 
3235
                //return ( a->team - b->team );
-
 
3236
            }
-
 
3237
            else
-
 
3238
            {
-
 
3239
                /* One is equestrian */
3533
            /* One is equestrian */
3240
                /* Good times better than NE */
3534
            /* Good times better than NE */
3241
                return ( a->flags.non_equestrian ? 1 : -1 );
3535
            return ( a->flags.non_equestrian ? 1 : -1 );
3242
            }
-
 
3243
        }
3536
        }
3244
    }
3537
    }
3245
 
3538
 
3246
    /*
3539
    /*
3247
    **  Before we sort on times we must determine which time to
3540
    **  Before we sort on times we must determine which time to
Line 3319... Line 3612...
3319
 
3612
 
3320
    /*
3613
    /*
3321
     ** If we are ignore Equestrian config then place the Equestrian data last
3614
     ** If we are ignore Equestrian config then place the Equestrian data last
3322
    */
3615
    */
3323
 
3616
 
3324
#if 0
-
 
3325
    if (a->isNeData != b->isNeData) {
-
 
3326
         return ( a->isNeData ? 1 : -1 );
-
 
3327
    }
-
 
3328
#endif
-
 
3329
 
-
 
3330
#if 1
3617
#if 1
3331
    if (sort_withEquestrian) {
3618
    if (sort_withEquestrian) {
3332
        if (a->isNeData != b->isNeData)
3619
        if (a->isNeData != b->isNeData)
3333
            return ( a->isNeData ? 1 : -1 );
3620
            return ( a->isNeData ? 1 : -1 );
3334
    }
3621
    }
Line 3415... Line 3702...
3415
bool load_report_data(void)
3702
bool load_report_data(void)
3416
{
3703
{
3417
 
3704
 
3418
    ty_s_data  *ptr;                             /* pointer to sort data type */
3705
    ty_s_data  *ptr;                             /* pointer to sort data type */
3419
    ty_s_data  *last;
3706
    ty_s_data  *last;
3420
    int         j;
3707
    unsigned    j;
3421
    unsigned    num;
3708
    unsigned    num;
3422
    team_type   team_buf;
3709
    team_type   team_buf;
3423
 
3710
 
3424
    /*
3711
    /*
3425
     * Fetch memory for the data store
3712
     * Fetch memory for the data store
Line 3484... Line 3771...
3484
                ptr->teamclass = team_buf.teamclass;
3771
                ptr->teamclass = team_buf.teamclass;
3485
                ptr->real_teamclass = team_buf.teamclass;
3772
                ptr->real_teamclass = team_buf.teamclass;
3486
 
3773
 
3487
                ptr->flags = team_buf.flags;
3774
                ptr->flags = team_buf.flags;
3488
 
3775
 
-
 
3776
                // Add a few flags to simplify processing
-
 
3777
                //  Vetted out teams to be included inthe fastest calcs - except for Equestian Leg
-
 
3778
                //  Bodgey teams are not sorted by place - only after all places and then by team number
3489
//                if (ptr->flags.non_equestrian)
3779
                ptr->flags.notInLP = 0;
3490
//                    ptr->flags.disqualified = true;
3780
                ptr->flags.notInFastest = 0;
-
 
3781
 
-
 
3782
                if ( ptr->flags.bad_times || ptr->flags.disqualified || !ptr->flags.valid) {
3491
                if (ptr->flags.vet_check)
3783
                    ptr->flags.notInLP = 1;
3492
                    ptr->flags.disqualified = true;
3784
                    ptr->flags.notInFastest = 1;
-
 
3785
                }
3493
 
3786
 
3494
                ptr++;
3787
                ptr++;
3495
                sort_num++;
3788
                sort_num++;
3496
 
3789
 
3497
 
3790
 
Line 3508... Line 3801...
3508
                    ptr->isNeData = true;
3801
                    ptr->isNeData = true;
3509
                    ptr->lege[0] = 0;
3802
                    ptr->lege[0] = 0;
3510
 
3803
 
3511
                    for( j = 0; j < MAX_LEGS + 1; j++ )
3804
                    for( j = 0; j < MAX_LEGS + 1; j++ )
3512
                    {
3805
                    {
3513
                        if ( j == config.equestrian_leg )
3806
                        if ( (short)j == config.equestrian_leg )
3514
                        {
3807
                        {
3515
                            last->lege[j] = ptr->lege[j] = 0;
3808
                            last->lege[j] = ptr->lege[j] = 0;
3516
                            if ( config.equestrian_leg > 1 )
3809
                            if ( config.equestrian_leg > 1 )
3517
                                last->leg[j] = ptr->leg[j] = ptr->leg[j-1];
3810
                                last->leg[j] = ptr->leg[j] = ptr->leg[j-1];
3518
                        }
3811
                        }
Line 3528... Line 3821...
3528
 
3821
 
3529
                    last->start = ptr->start = team_buf.leg[0].start;
3822
                    last->start = ptr->start = team_buf.leg[0].start;
3530
                    ptr->teamclass = config.nonequestrian_class;
3823
                    ptr->teamclass = config.nonequestrian_class;
3531
                    ptr->real_teamclass = team_buf.teamclass;
3824
                    ptr->real_teamclass = team_buf.teamclass;
3532
                    ptr->flags = team_buf.flags;
3825
                    ptr->flags = team_buf.flags;
3533
//                    ptr->flags.disqualified = false;
-
 
3534
 
3826
 
3535
                    ptr++;
3827
                    ptr++;
3536
                    sort_num++;
3828
                    sort_num++;
3537
                }
3829
                }
3538
#endif
3830
#endif
3539
            }
3831
            }
3540
        }
3832
        }
3541
    }
3833
    }
-
 
3834
 
-
 
3835
    // Debug
-
 
3836
//    qDebug() << "--- Start ---";
-
 
3837
 
-
 
3838
//    sort_team_data( 0, S_L, 1 );
-
 
3839
 
-
 
3840
//    for( j = 1, ptr = sort_data; j <= sort_num; j++, ptr++ )
-
 
3841
//    {
-
 
3842
//        qDebug() << "T:" << ptr->team
-
 
3843
//                << "Class:" << ptr->teamclass
-
 
3844
//                << "NEData:" << (ptr->isNeData? 1:0)
-
 
3845
//                << "iLP:" << (ptr->flags.notInLP ? 1:0)
-
 
3846
//                << "iF:" << (ptr->flags.notInFastest ? 1:0)
-
 
3847
//                << "Valid:" << (ptr->flags.valid ? 1:0)
-
 
3848
//                << "NE:" << (ptr->flags.non_equestrian? 1:0)
-
 
3849
//                << "B:" << (ptr->flags.bad_times ? 1 : 0 )
-
 
3850
//                << "D:" << (ptr->flags.disqualified ? 1:0 )
-
 
3851
//                << "V:" << (ptr->flags.vet_check ? 1:0 )
-
 
3852
//                << "LE0:" << ptr->lege[0]
-
 
3853
//                << "L0:" << ptr->leg[0]
-
 
3854
//                << "LE1:" << ptr->lege[3]
-
 
3855
//                ;
-
 
3856
//    }
-
 
3857
 
-
 
3858
//    qDebug() << "-----------------------------------End---";
3542
    return ( TRUE );
3859
    return ( TRUE );
3543
}
3860
}
3544
 
3861
 
3545
/*========================================================================
3862
/*========================================================================
3546
 *
3863
 *
Line 3585... Line 3902...
3585
        **  of the data can be trusted.
3902
        **  of the data can be trusted.
3586
        **
3903
        **
3587
        **  If the team has been disqualified, then don't use any
3904
        **  If the team has been disqualified, then don't use any
3588
        **  of the data.
3905
        **  of the data.
3589
        */
3906
        */
3590
        if( ptr->flags.bad_times || ptr->flags.disqualified  )
3907
        if (ptr->flags.notInFastest) {
3591
            continue;
3908
            continue;
-
 
3909
        }
-
 
3910
 
-
 
3911
        //if( ptr->flags.bad_times || ptr->flags.disqualified  )
-
 
3912
        //    continue;
3592
 
3913
 
3593
        /*
3914
        /*
3594
        **  Ignore non-Equestrian, unless we are processing the psuedo NE class
3915
        **  Ignore non-Equestrian, unless we are processing the psuedo NE class
-
 
3916
        **  2021: Now allow NE to be considered in the fastest stats
3595
        */
3917
        */
3596
        if ( ptr->teamclass != config.nonequestrian_class && ptr->flags.non_equestrian)
3918
        //if ( ptr->teamclass != config.nonequestrian_class && ptr->flags.non_equestrian)
3597
            continue;
3919
        //    continue;
3598
 
3920
 
3599
 
3921
 
3600
        for( j = 0; j <= config.num_legs; j++ )
3922
        for( j = 0; j <= config.num_legs; j++ )
3601
        {
3923
        {
3602
            if( ptr->lege[j] <= 0 )              /* Ignore bad data */
3924
            if( ptr->lege[j] <= 0 )              /* Ignore bad data */
3603
                continue;
3925
                continue;
3604
 
3926
 
3605
            /*
3927
            /*
-
 
3928
            ** If this is the Equestrian Leg and the team has been vetted out, then this team cannot
-
 
3929
            ** be included into the stats for this leg
-
 
3930
            **
-
 
3931
            ** If team has been vetted out then don't consider in fastest overall
-
 
3932
            */
-
 
3933
            if ( ptr->flags.vet_check && (j == config.equestrian_leg || j== 0)) {
-
 
3934
                continue;
-
 
3935
            }
-
 
3936
 
-
 
3937
            /* If this is the Equestrian Leg and the team is a Non-Equestrian Team, then don't include
-
 
3938
            ** it into the stats.
-
 
3939
            **
-
 
3940
            ** If this is a NE team then don't consider it to be fastest overall
-
 
3941
            */
-
 
3942
            if ( ptr->teamclass != config.nonequestrian_class && ptr->flags.non_equestrian &&  (j == config.equestrian_leg || j== 0)) {
-
 
3943
                continue;
-
 
3944
            }
-
 
3945
 
-
 
3946
            /*
3606
            **  Determine fastest team : overall
3947
            **  Determine fastest team : overall
3607
            **  Ignore the non-equestrian data as this is in the list twice
3948
            **  Ignore the non-equestrian data as this is in the list twice
3608
            */
3949
            */
3609
            if( ( ptr->lege[j] < stats.fast.time[j][0] )
3950
            if( ( ptr->lege[j] < stats.fast.time[j][0] )
3610
                || ( stats.fast.time[j][0] < 0 ) )
3951
                || ( stats.fast.time[j][0] < 0 ) )