Subversion Repositories svn1

Rev

Rev 228 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 228 Rev 380
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 55... Line 54...
55
#include    "structs.h"
54
#include    "structs.h"
56
#include    "proto.h"
55
#include    "proto.h"
57
#include    "mainwindow.h"
56
#include    "mainwindow.h"
58
 
57
 
59
void pri_awards_html(void);
58
void pri_awards_html(void);
-
 
59
void pri_summary_html(void);
60
void pri_awards(void);
60
void pri_awards(void);
61
void pri_master_index(void);
61
void pri_master_index(void);
62
char *placing ( int place );
62
char *placing ( int place );
63
void pri_name_index(void);
63
void pri_name_index(void);
64
void pri_name_index_body( void );
64
void pri_name_index_body( void );
Line 85... Line 85...
85
    "Eleventh"
85
    "Eleventh"
86
};
86
};
87
 
87
 
88
int         sort_leg;
88
int         sort_leg;
89
int         sort_mode;
89
int         sort_mode;
-
 
90
bool        sort_withEquestrian;
-
 
91
bool        sort_afterEquestrianLeg;
90
report_type report_html = text;
92
report_type report_html = text;
91
bool        report_all = FALSE;
93
bool        report_all = FALSE;
92
 
94
 
93
/* Parameters used by the sort routine to govern its actions */
95
/* Parameters used by the sort routine to govern its actions */
94
 
96
 
Line 98... Line 100...
98
#define S_LEC   4                                /* Leg end time per class */
100
#define S_LEC   4                                /* Leg end time per class */
99
#define S_FIN   5                                /* Sort on finish time at given leg */
101
#define S_FIN   5                                /* Sort on finish time at given leg */
100
#define S_TEAM  6                                /* Sort on team order */
102
#define S_TEAM  6                                /* Sort on team order */
101
#define S_CLASS 7                                /* Sort on class/team order */
103
#define S_CLASS 7                                /* Sort on class/team order */
102
#define S_LC_NE 8                                /* Elapsed times per class, with NE sorted by real class */
104
#define S_LC_NE 8                                /* Elapsed times per class, with NE sorted by real class */
-
 
105
#define S_IFIN  9                                /* Sort on elapsed time at given leg */
-
 
106
 
103
 
107
 
104
/*
108
/*
105
**  Various checking modes
109
**  Various checking modes
106
*/
110
*/
107
#define C_ELAPSED   1                            /* Check elapsed times */
111
#define C_ELAPSED   1                            /* Check elapsed times */
Line 181... Line 185...
181
            **      - Team number - with Xref back to full result
185
            **      - Team number - with Xref back to full result
182
            **      - Full team name
186
            **      - Full team name
183
            **      - Full categoray name - with Xref to category results
187
            **      - Full categoray name - with Xref to category results
184
            **      - Country name
188
            **      - Country name
185
            */
189
            */
186
            if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "finish" ,"html")), team_buf.numb );
190
            if ( report_html == html ) setHref( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "finish" ,"html")), team_buf.numb );
187
            print( "%4d",       team_buf.numb );
191
            print( "%4d",       team_buf.numb );
188
            if ( report_html == html ) print( "</A>" );
-
 
189
 
192
 
190
            print( " %-*s ",     MAX_TM_NAME, team_buf.name );
193
            print( " %-*s ",     MAX_TM_NAME, team_buf.name );
191
 
194
 
192
            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 );
195
            if ( report_html == html ) setHref( "<A HREF=\"%s#Team_%04d\">",url_encode(p_filename(filebase, config.team_class[team_buf.teamclass - 1].abr ,"html")), team_buf.numb );
193
            print( "%-*s",     LEN_CLASS_NAME, team_buf.teamclass == 0 ? "" : config.team_class[team_buf.teamclass - 1].full_name );
196
            print( "%-*s",     LEN_CLASS_NAME, team_buf.teamclass == 0 ? "" : config.team_class[team_buf.teamclass - 1].full_name );
194
            if ( report_html == html ) print( "</A>" );
-
 
195
 
197
 
196
            print( " %-*s",     config.num_countries == 0 ? 1 : LEN_CNTRY_NAME,
198
            print( " %-*s",     config.num_countries == 0 ? 1 : LEN_CNTRY_NAME,
197
                                config.num_countries == 0
199
                                config.num_countries == 0
198
                                || team_buf.country ==
200
                                || team_buf.country ==
199
                                0 ? "" : config.country_name[team_buf.country - 1].full_name );
201
                                0 ? "" : config.country_name[team_buf.country - 1].full_name );
Line 299... Line 301...
299
     * Print out the header
301
     * Print out the header
300
     */
302
     */
301
    print( "\n" );
303
    print( "\n" );
302
 
304
 
303
    print_underline( TRUE );
305
    print_underline( TRUE );
304
    print( "%-*s %-*s %-*s %-*s", MAX_TM_NAME + 5, "Competitor name",
306
    print( "%-*s %*s %*s %-*s", MAX_TM_NAME + 5, "Competitor name",
305
               6, "Leg",
307
               6, "Leg",
306
               5, "Team",
308
               5, "Team",
307
               LEN_CLASS_NAME, "Category"
309
               LEN_CLASS_NAME, "Category"
308
               );
310
               );
309
    print_underline( FALSE ) ;
311
    print_underline( FALSE ) ;
Line 313... Line 315...
313
    for( k = 1; k <= sort_num_data; k++, ptr++ )
315
    for( k = 1; k <= sort_num_data; k++, ptr++ )
314
    {
316
    {
315
        print( "%-*s", MAX_TM_NAME + 5, ptr->name );
317
        print( "%-*s", MAX_TM_NAME + 5, ptr->name );
316
        print( " " );
318
        print( " " );
317
        
319
        
318
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "finish" ,"html")), ptr->team );
320
        if ( report_html == html ) setHref( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "finish" ,"html")), ptr->team );
319
        print( "%-*d", 6, ptr->leg + 1 );
321
        print( "%*d", 6, ptr->leg + 1 );
320
        if ( report_html == html ) print( "</A>" );
-
 
321
        print( " " );
322
        print( " " );
322
 
323
 
323
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "name" ,"html")), ptr->team );
324
        if ( report_html == html ) setHref( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "name" ,"html")), ptr->team );
324
        print( "%-*d", 5, ptr->team );
325
        print( "%*d", 5, ptr->team );
325
        if ( report_html == html ) print( "</A>" );
-
 
326
        print( " " );
326
        print( " " );
327
 
327
 
328
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">",(p_filename(filebase, config.team_class[ptr->teamclass - 1].abr ,"html")), ptr->team );
328
        if ( report_html == html ) setHref( "<A HREF=\"%s#Team_%04d\">",(p_filename(filebase, config.team_class[ptr->teamclass - 1].abr ,"html")), ptr->team );
329
        print( "%-*s", LEN_CLASS_NAME, ptr->teamclass == 0 ? "" : config.team_class[ptr->teamclass - 1].abr );
329
        print( "%-*s", LEN_CLASS_NAME, ptr->teamclass == 0 ? "" : config.team_class[ptr->teamclass - 1].abr );
330
        if ( report_html == html ) print( "</A>" );
-
 
331
        print( " " );
330
        print( " " );
332
 
331
 
333
        if ( ptr->multi ) print( "* ");
332
        if ( ptr->multi ) print( "* ");
334
        print( "\n" );
333
        print( "\n" );
335
    }
334
    }
Line 361... Line 360...
361
 
360
 
362
    /*
361
    /*
363
     * Sort the data in finishing order 
362
     * Sort the data in finishing order 
364
     */
363
     */
365
 
364
 
366
    if( ck_data( leg, C_END ) )
-
 
367
        return;                                  /* Check data for this leg */
365
    ck_data( leg, C_END );                      /* Check data for this leg */
368
    sort_team_data( leg, S_FIN );                /* Sort the data */
366
    sort_team_data( leg, S_FIN, true );         /* Sort the data */
369
 
367
 
370
 
368
 
371
    /*
369
    /*
372
     * Now print the data on the printer 
370
     * Now print the data on the printer 
373
     */
371
     */
Line 397... Line 395...
397
 
395
 
398
    for( ptr = sort_data, k = 0, i = config.min_team; i <= config.max_team; )
396
    for( ptr = sort_data, k = 0, i = config.min_team; i <= config.max_team; )
399
    {
397
    {
400
        p_place( ptr++, leg, k++ );
398
        p_place( ptr++, leg, k++ );
401
        p_place( ptr++, leg, k++ );
399
        p_place( ptr++, leg, k++ );
-
 
400
 
402
        print( "|" );
401
        print( "|" );
403
        while( i <= config.max_team && !valid_field( i ) )
402
        while( i <= config.max_team && !valid_field( i ) )
404
            i++;
403
            i++;
405
        p_team( i++, leg );
404
        p_team( i++, leg );
406
        while( i <= config.max_team && !valid_field( i ) )
405
        while( i <= config.max_team && !valid_field( i ) )
Line 468... Line 467...
468
void p_place( ty_s_data * ptr, int leg, unsigned k )
467
void p_place( ty_s_data * ptr, int leg, unsigned k )
469
{
468
{
470
    if( k < sort_num )
469
    if( k < sort_num )
471
    {
470
    {
472
        print( "%4.4s %4d %8s  ",
471
        print( "%4.4s %4d %8s  ",
473
               pr_place( ptr->place, ptr->flags.bad_times ),
472
               px_place(-1, ptr->place, false, false, ptr->flags ),
474
               ptr->team, time_fa( ptr->leg[leg], ptr->flags.disqualified ) );
473
               ptr->team, time_fa( ptr->leg[leg], ptr->flags.disqualified ) );
475
    }
474
    }
476
    else
475
    else
477
    {
476
    {
478
        print( "%20s", "" );
477
        print( "%20s", "" );
Line 514... Line 513...
514
    }
513
    }
515
    if( found )
514
    if( found )
516
    {
515
    {
517
        print( "%4d %4.4s %8s  ",
516
        print( "%4d %4.4s %8s  ",
518
               ptra->team,
517
               ptra->team,
519
               pr_place( ptra->place, ptra->flags.bad_times ),
518
               px_place( -1, ptra->place, false, false, ptra->flags ),
520
               time_fa( ptra->leg[leg], ptra->flags.disqualified ) );
519
               time_fa( ptra->leg[leg], ptra->flags.disqualified ) );
521
    }
520
    }
522
    else
521
    else
523
    {
522
    {
524
        print( "%20s", "" );
523
        print( "%20s", "" );
Line 547... Line 546...
547
 
546
 
548
    /*
547
    /*
549
     * Sort the data in finishing order
548
     * Sort the data in finishing order
550
     */
549
     */
551
 
550
 
552
    if( ck_data( leg, C_ELAPSED ) )
-
 
553
        return;                                  /* Check data for this leg */
551
    ck_data( leg, C_ELAPSED );                      /* Check data for this leg */
554
    sort_team_data( leg, S_L );                  /* Sort the data on elapsed time */
552
    sort_team_data( leg, S_IFIN, true );            /* Sort the data on elapsed time */
555
 
553
 
556
 
554
 
557
    /*
555
    /*
558
     * Now print the data on the printer
556
     * Now print the data on the printer
559
     */
557
     */
Line 637... Line 635...
637
// *
635
// *
638
// *  Print place information
636
// *  Print place information
639
// *
637
// *
640
// *  Purpose:
638
// *  Purpose:
641
// *      This helper function is called to Print place and elapsed information
639
// *      This helper function is called to Print place and elapsed information
642
// *      in a 20-character field
640
// *      in a 20-character field: Place:Team:ElapsedTime
643
// *
641
// *
644
// *  Parameters:
642
// *  Parameters:
645
// *      ptr         Address of the place data
643
// *      ptr         Address of the place data
646
// *      leg         Leg to print
644
// *      leg         Leg to print
647
// *      k           Current index into sorted array. Simply
645
// *      k           Current index into sorted array. Simply
Line 656... Line 654...
656
void pe_place( ty_s_data * ptr, int leg, unsigned k )
654
void pe_place( ty_s_data * ptr, int leg, unsigned k )
657
{
655
{
658
    if( k < sort_num )
656
    if( k < sort_num )
659
    {
657
    {
660
        print( "%4.4s %4d %8s  ",
658
        print( "%4.4s %4d %8s  ",
661
               pr_place( ptr->place, ptr->flags.bad_times ),
659
               px_place( -1, ptr->place, false, false, ptr->flags ),
662
               ptr->team,
660
               ptr->team,
663
               time_fa( ptr->lege[leg], ptr->flags.disqualified ) );
661
               time_fa( ptr->lege[leg], ptr->flags.disqualified ) );
664
    }
662
    }
665
    else
663
    else
666
    {
664
    {
Line 703... Line 701...
703
    }
701
    }
704
    if( found )
702
    if( found )
705
    {
703
    {
706
        print( "%4d %4.4s %8s  ",
704
        print( "%4d %4.4s %8s  ",
707
               ptra->team,
705
               ptra->team,
708
               pr_place( ptra->place, ptra->flags.bad_times ),
706
               px_place( -1, ptra->place, false, false, ptra->flags ),
709
               time_fa( ptra->lege[leg], ptra->flags.disqualified ) );
707
               time_fa( ptra->lege[leg], ptra->flags.disqualified ) );
710
    }
708
    }
711
    else
709
    else
712
    {
710
    {
713
        print( "%20s", "" );
711
        print( "%20s", "" );
Line 735... Line 733...
735
    /*
733
    /*
736
    **  Generate ALL results with HTML tags
734
    **  Generate ALL results with HTML tags
737
    */
735
    */
738
    report_html = html;
736
    report_html = html;
739
    pri_final();
737
    pri_final();
-
 
738
    pri_final_teamOrder();
-
 
739
 
740
    report_html = printed;
740
    report_html = printed;
741
    pri_final();
741
    pri_final();
-
 
742
    pri_final_teamOrder();
742
    report_html = text;
743
    report_html = text;
743
}
744
}
744
 
745
 
745
 
746
 
746
/*========================================================================
747
/*========================================================================
Line 765... Line 766...
765
    unsigned    i;
766
    unsigned    i;
766
    int         j, last_class;
767
    int         j, last_class;
767
    char        *report_title;
768
    char        *report_title;
768
    bool        class_done[MAX_CLASS+1];
769
    bool        class_done[MAX_CLASS+1];
769
    int         lcount;
770
    int         lcount;
-
 
771
    bool        isNeClass = false;
-
 
772
 
-
 
773
    ck_data( -1, C_ELAPSED );
770
 
774
 
771
    if( ck_data( -1, C_ELAPSED ) )
-
 
772
        return;
-
 
773
    /*
775
    /*
774
    **  Sort on every thing
776
    **  Sort on every thing
775
    **  Then generate all the stats too
777
    **  Then generate all the stats too
776
    */
778
    */
777
    do_big_sort();
779
    do_big_sort();
Line 784... Line 786...
784
        return;
786
        return;
785
 
787
 
786
    /*
788
    /*
787
     * Print out the data 
789
     * Print out the data 
788
     */
790
     */
789
    print_class_header( -1, TRUE );                      /* Print the header */
791
    print_class_header( -1, TRUE );                     /* Print the header */
790
 
-
 
791
    ptr = sort_data;
-
 
792
    sort_team_data( 0, S_L );                     /* Re-sort on elapsed time */
792
    sort_team_data( 0, S_L, true );                     /* Re-sort on elapsed time */
793
    lcount = 0;
793
    lcount = 0;
794
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
794
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
795
    {
795
    {
796
        if ( ptr->teamclass == config.nonequestrian_class )
796
        if ( ptr->isNeData )
797
            continue;
797
            continue;
798
 
798
 
799
        g_record( ptr->team, &team_buf );
799
        g_record( ptr->team, &team_buf );
800
 
800
 
801
        /*
801
        /*
-
 
802
        ** If this is a NE team then dummy up some of the data that hasn't been stored in team_buf
-
 
803
        */
-
 
804
        if (ptr->flags.non_equestrian)
-
 
805
        {
-
 
806
            team_buf.leg[0].l_place = sort_aux[ptr->team].leq_place[0];
-
 
807
            team_buf.leg[0].lc_place = sort_aux[ptr->team].lq_place[0];
-
 
808
        }
-
 
809
 
-
 
810
        /*
802
        **  If printing an HTML report then we need to mark
811
        **  If printing an HTML report then we need to mark
803
        **  the entry with a reference so that we can link to it
812
        **  the entry with a reference so that we can link to it
804
        */
813
        */
805
        if ( report_html == html )
814
        if ( report_html == html )
806
        {
815
        {
Line 811... Line 820...
811
        **  Print the basics (Finishing order)
820
        **  Print the basics (Finishing order)
812
        **      - Place within complete field
821
        **      - Place within complete field
813
        **      - Team number - with HTML reference to team file
822
        **      - Team number - with HTML reference to team file
814
        **      - Class
823
        **      - Class
815
        */
824
        */
816
        if ( report_html == printed && lcount %5 == 4 ) print_underline( TRUE );
825
        if ( report_html == printed && lcount % 5 == 4 ) print_underline( TRUE );
817
        print( "%4.4s ", pr_place( team_buf.leg[0].l_place, ptr->flags.bad_times ) );
826
        print( "%4.4s ", px_place( 0, team_buf.leg[0].l_place, false, true, ptr->flags ) );
818
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "name" ,"html")), team_buf.numb );
827
        if ( report_html == html ) setHref( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "name" ,"html")), team_buf.numb );
819
        print( "%4d",  team_buf.numb );
828
        print( "%4d",  team_buf.numb );
820
        if ( report_html == html ) print( "</A>" );
-
 
821
 
829
 
822
        print( " %-*s", 3, team_buf.teamclass == 0 ? "" : config.team_class[team_buf.teamclass - 1].abr );
830
        print( " %-*s", 3, team_buf.teamclass == 0 ? "" : config.team_class[team_buf.teamclass - 1].abr );
823
 
831
 
824
        /*
832
        /*
825
        **  Print the per-leg data
833
        **  Print the per-leg data
Line 827... Line 835...
827
        **      - Leg place
835
        **      - Leg place
828
        **      - End place
836
        **      - End place
829
        */
837
        */
830
        for( j = 1; j <= config.num_legs; j++ )
838
        for( j = 1; j <= config.num_legs; j++ )
831
        {
839
        {
-
 
840
            bool isEquestrianLeg = (j == config.equestrian_leg && team_buf.flags.non_equestrian);
-
 
841
 
832
            /*
842
            /*
833
            **  Ensure that non-equestrian leg data is not displayed
843
            **  Ensure that non-equestrian leg data is not displayed
834
            */
844
            */
835
            if ( j == config.equestrian_leg && team_buf.flags.non_equestrian )
845
            if ( isEquestrianLeg )
836
            {
846
            {
837
                print( "  %-8s %4.4s %4.4s", "-- NE --", "NE","NE");
847
                print( "  %-8s %4.4s %4.4s", "-- NE --", "NE","NE");
838
            }
848
            }
839
            else
849
            else
840
            {
850
            {
841
                print( "  %-8s %4.4s %4.4s",
-
 
842
                    time_a( team_buf.leg[j].elapsed ),
851
                print( "  %-8s", time_a( team_buf.leg[j].elapsed ));
843
                    pr_place( team_buf.leg[j].l_place, ptr->flags.bad_times ),
852
                if ( config.num_legs != 1 ) print( " %4.4s",      px_place( j, team_buf.leg[j].l_place, false, false, ptr->flags ));
844
                    pr_place( team_buf.leg[j].le_place,ptr->flags.bad_times )
853
                if ( config.num_legs != 1 ) print( " %4.4s",   px_place( j, team_buf.leg[j].le_place,true , true, ptr->flags ));
845
                  );
854
                if ( config.num_legs == 1 ) print( " %-*s ",  MAX_TM_NAME, team_buf.name );
846
            }
855
            }
847
        }
856
        }
848
 
857
 
849
       /*
858
       /*
850
        **  Print the trailer (Finishing order)
859
        **  Print the trailer (Finishing order)
851
        **      - Total time
860
        **      - Total time
852
        **      - Category place - with reference to category file
861
        **      - Category place - with reference to category file
853
        */
862
        */
854
//        print( "  %-8s ",  time_a( team_buf.leg[0].elapsed ) );
-
 
855
        print( "  %-8s ", time_a( ptr->lege[0] ) );
863
        if ( config.num_legs != 1 ) print( "  %-8s ", time_a( ptr->lege[0] ) );
856
        
864
        
857
        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 );
865
        if ( report_html == html ) setHref( "<A HREF=\"%s#Team_%04d\">",url_encode(p_filename(filebase, config.team_class[team_buf.teamclass - 1].abr ,"html")), team_buf.numb );
858
        print( "%-4.4s", pr_place_ne( team_buf.leg[0].lc_place, ptr->flags.bad_times, ptr->flags.non_equestrian ) );
866
        print( "%4.4s", px_place( 0, team_buf.leg[0].lc_place, false, false, ptr->flags) );
859
        if ( report_html == html ) print( "</A>" );
-
 
860
        if ( report_html == printed && lcount %5 == 4 ) print_underline( FALSE );
867
        if ( report_html == printed && lcount %5 == 4 ) print_underline( FALSE );
861
        lcount++;
868
        lcount++;
862
        print( "\n" );
869
        print( "\n" );
863
    }
870
    }
864
 
871
 
865
    print_class_stats( -1, TRUE );              /* Print statistics */
872
    print_class_stats( -1, TRUE );              /* Print statistics */
866
    print_legend(-1, 1 );                       /* Print the legend */
873
    print_legend(-1, 1 );                       /* Print the legend */
867
    close_printer();                            /* Close the printer */
874
    close_printer();                            /* Close the printer */
868
 
875
 
869
    /*
876
    /* ------------------ Class Reports
870
     * Now produce a breakdown on a class by class basis 
877
     * Now produce a breakdown on a class by class basis 
871
     * Now print out the class placement information
878
     * Now print out the class placement information
872
     */
879
     */
873
 
880
 
874
    sort_team_data( 0, S_LC );                 /* Generate class placement data */
881
    sort_team_data( 0, S_LC, true );           /* Generate class placement data */
875
    last_class = -1;                           /* Invalid class to start with */
882
    last_class = -1;                           /* Invalid class to start with */
876
    memset ( class_done, 0, sizeof(class_done));
883
    memset ( class_done, 0, sizeof(class_done));
877
 
884
 
878
 
-
 
879
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
885
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
880
    {
886
    {
-
 
887
        short teamClass = ptr->teamclass;
-
 
888
        isNeClass = false;
-
 
889
 
-
 
890
        /*
-
 
891
        **  Dummy up the psuedo NE data a little bit
-
 
892
        */
-
 
893
        if (ptr->isNeData) {
-
 
894
            isNeClass = true;
-
 
895
            teamClass = config.nonequestrian_class;
-
 
896
        }
-
 
897
 
-
 
898
//qDebug() << "NEtm:" << ptr->team << "," << isNeClass << "," << teamClass;
-
 
899
 
881
        /*
900
        /*
882
        **  Detect a change in the "class"
901
        **  Detect a change in the "class"
883
        **  All data is within the one array of data
902
        **  All data is within the one array of data
884
        **  Use the in-memory class as this MAY differ from that stored
903
        **  Use the in-memory class as this MAY differ from that stored
885
        **  The non-equestrian class does this.
904
        **  The non-equestrian class does this.
886
        */
905
        */
887
        if( last_class != ptr->teamclass )
906
        if( last_class != teamClass )
888
        {
907
        {
889
            if( last_class >= 0 )
908
            if( last_class >= 0 )
890
            {
909
            {
891
                print_class_stats( last_class, TRUE );
910
                print_class_stats( last_class, TRUE );
892
                print_legend( last_class, 1 );
911
                print_legend( last_class, 1 );
893
                close_printer();
912
                close_printer();
-
 
913
if (class_done[teamClass]) {
-
 
914
    qDebug() << "ERROR class already processed - order error";
-
 
915
}
-
 
916
                last_class = 0;
894
            }
917
            }
895
 
918
 
896
            report_title = tprintf( "Category results for : %-*s", LEN_CLASS_NAME, ptr->teamclass == 0 ? "" : config.team_class[ptr->teamclass - 1].full_name );
919
            report_title = tprintf( "Category results for : %-*s", LEN_CLASS_NAME, teamClass == 0 ? "" : config.team_class[teamClass - 1].full_name );
897
 
920
 
898
            if( !open_printer( "", config.team_class[ptr->teamclass - 1].abr, 132, report_html, report_title ) )
921
            if( !open_printer( "", config.team_class[teamClass - 1].abr, 132, report_html, report_title ) )
899
                continue;
922
                continue;
900
            print_class_header( last_class = ptr->teamclass, TRUE );
923
            print_class_header( last_class = teamClass, TRUE );
901
 
924
 
902
            /*
925
            /*
903
            **  Mark the class as done
926
            **  Mark the class as done
904
            */
927
            */
905
            class_done[ptr->teamclass] = TRUE;
928
            class_done[teamClass] = TRUE;
906
            lcount = 0;
929
            lcount = 0;
-
 
930
            last_class = teamClass;
907
        }
931
        }
908
 
932
 
909
        /*
933
        /*
910
        **  Now read in the team record
934
        **  Now read in the team record
911
        */
935
        */
912
        g_record( ptr->team, &team_buf );
936
        g_record( ptr->team, &team_buf );
913
 
937
 
914
        /*
938
        /*
-
 
939
        ** Dummy up the data for the dummy nonEquestrian Class
-
 
940
        ** Its not stored in the team_buf for backwards compatability
-
 
941
        */
-
 
942
        if( isNeClass)
-
 
943
        {
-
 
944
            for( j = 0; j <= config.num_legs; j++ )
-
 
945
            {
-
 
946
                team_buf.leg[j].lc_place = sort_aux[ptr->team].lq_place[j];
-
 
947
                team_buf.leg[j].lec_place = sort_aux[ptr->team].leq_place[j];
-
 
948
            }
-
 
949
        }
-
 
950
        else
-
 
951
        {
-
 
952
            if (ptr->flags.non_equestrian)
-
 
953
            {
-
 
954
                //team_buf.leg[0].lc_place = sort_aux[ptr->team].lcq_place[0];
-
 
955
                //team_buf.leg[0].lc_place = sort_aux[ptr->team].lcq_place[0];
-
 
956
                team_buf.leg[0].lec_place = sort_aux[ptr->team].leq_place[0];
-
 
957
            }
-
 
958
        }
-
 
959
 
-
 
960
 
-
 
961
        /*
915
        **  If printing an HTML report then we need to mark
962
        **  If printing an HTML report then we need to mark
916
        **  the entry with a reference so that we can link to it
963
        **  the entry with a reference so that we can link to it
917
        */
964
        */
918
        if ( report_html == html )
965
        if ( report_html == html )
919
            print( "<A NAME=\"Team_%04d\"></A>",team_buf.numb );
966
            print( "<A NAME=\"Team_%04d\"></A>",team_buf.numb );
Line 924... Line 971...
924
        **      - Team number - with HTML reference to team file
971
        **      - Team number - with HTML reference to team file
925
        **      - Class
972
        **      - Class
926
        */
973
        */
927
 
974
 
928
        if ( report_html == printed && lcount %5 == 4 ) print_underline( TRUE );
975
        if ( report_html == printed && lcount %5 == 4 ) print_underline( TRUE );
929
        print( "%4.4s ", pr_place( team_buf.leg[0].lc_place, ptr->flags.bad_times ) );
976
        print( "%4.4s ", px_place( 0, team_buf.leg[0].lc_place, false, false, ptr->flags) );
930
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "name" ,"html")), team_buf.numb );
977
        if ( report_html == html ) setHref( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "name" ,"html")), team_buf.numb );
931
        print( "%4d",  team_buf.numb );
978
        print( "%4d",  team_buf.numb );
932
        if ( report_html == html ) print( "</A>" );
-
 
933
        print( " %-*s", 3, team_buf.teamclass == 0 ? "" : config.team_class[team_buf.teamclass - 1].abr );
979
        print( " %-*s", 3, team_buf.teamclass == 0 ? "" : config.team_class[team_buf.teamclass - 1].abr );
934
 
980
 
935
        for( j = 1; j <= config.num_legs; j++ )
981
        for( j = 1; j <= config.num_legs; j++ )
936
        {
982
        {
-
 
983
            bool isEquestrianLeg = (j == config.equestrian_leg && (ptr->isNeData || ptr->flags.non_equestrian));
-
 
984
 
937
            /*
985
            /*
938
            **  Ensure that non-equestrian leg data is not displayed
986
            **  Ensure that non-equestrian leg data is not displayed
939
            */
987
            */
940
            if ( j == config.equestrian_leg && (ptr->teamclass == config.nonequestrian_class || ptr->flags.non_equestrian) )
988
            if ( isEquestrianLeg )
941
            {
989
            {
942
                print( "  %-8s %4.4s %4.4s", "-- NE --", "NE","NE");
990
                print( "  %-8s %4.4s %4.4s", "-- NE --", "NE","NE");
943
            }
991
            }
944
            else
992
            else
945
            {
993
            {
946
                print( "  %-8s %4.4s %4.4s", time_a( team_buf.leg[j].elapsed ),
994
                print( "  %-8s", time_a( team_buf.leg[j].elapsed ));
947
                       pr_place( team_buf.leg[j].lc_place,  ptr->flags.bad_times ),
995
                if ( config.num_legs != 1 ) print( " %4.4s", px_place( j, team_buf.leg[j].lc_place,  false, false, ptr->flags ));
948
                       pr_place( team_buf.leg[j].lec_place, ptr->flags.bad_times ) );
996
                if ( config.num_legs != 1 ) print( " %4.4s", px_place( j, team_buf.leg[j].lec_place, true , true, ptr->flags ) );
-
 
997
                if ( config.num_legs == 1 ) print( " %-*s ", MAX_TM_NAME, team_buf.name );
949
            }
998
            }
950
        }
999
        }
-
 
1000
#if 0
-
 
1001
        // zzz
-
 
1002
        print (" --");
-
 
1003
 
-
 
1004
        print (",%4.4d", sort_aux[ptr->team].l_place[0]);
-
 
1005
        print (" %4.4d", sort_aux[ptr->team].l_place[1]);
-
 
1006
        print (" %4.4d", sort_aux[ptr->team].l_place[2]);
-
 
1007
        print (" %4.4d", sort_aux[ptr->team].l_place[3]);
-
 
1008
        print (" %4.4d", sort_aux[ptr->team].l_place[4]);
-
 
1009
        print (" %4.4d", sort_aux[ptr->team].l_place[5]);
-
 
1010
 
-
 
1011
        print (",%4.4d", sort_aux[ptr->team].le_place[0]);
-
 
1012
        print (" %4.4d", sort_aux[ptr->team].le_place[1]);
-
 
1013
        print (" %4.4d", sort_aux[ptr->team].le_place[2]);
-
 
1014
        print (" %4.4d", sort_aux[ptr->team].le_place[3]);
-
 
1015
        print (" %4.4d", sort_aux[ptr->team].le_place[4]);
-
 
1016
        print (" %4.4d", sort_aux[ptr->team].le_place[5]);
-
 
1017
 
-
 
1018
        print (",%4.4d", sort_aux[ptr->team].lc_place[0]);
-
 
1019
        print (" %4.4d", sort_aux[ptr->team].lc_place[1]);
-
 
1020
        print (" %4.4d", sort_aux[ptr->team].lc_place[2]);
-
 
1021
        print (" %4.4d", sort_aux[ptr->team].lc_place[3]);
-
 
1022
        print (" %4.4d", sort_aux[ptr->team].lc_place[4]);
-
 
1023
        print (" %4.4d", sort_aux[ptr->team].lc_place[5]);
-
 
1024
 
-
 
1025
        print (",%4.4d", sort_aux[ptr->team].lec_place[0]);
-
 
1026
        print (" %4.4d", sort_aux[ptr->team].lec_place[1]);
-
 
1027
        print (" %4.4d", sort_aux[ptr->team].lec_place[2]);
-
 
1028
        print (" %4.4d", sort_aux[ptr->team].lec_place[3]);
-
 
1029
        print (" %4.4d", sort_aux[ptr->team].lec_place[4]);
-
 
1030
        print (" %4.4d", sort_aux[ptr->team].lec_place[5]);
-
 
1031
 
-
 
1032
        print (",%4.4d", sort_aux[ptr->team].lq_place[0]);
-
 
1033
        print (" %4.4d", sort_aux[ptr->team].lq_place[1]);
-
 
1034
        print (" %4.4d", sort_aux[ptr->team].lq_place[2]);
-
 
1035
        print (" %4.4d", sort_aux[ptr->team].lq_place[3]);
-
 
1036
        print (" %4.4d", sort_aux[ptr->team].lq_place[4]);
-
 
1037
        print (" %4.4d", sort_aux[ptr->team].lq_place[5]);
-
 
1038
 
-
 
1039
        print (",%4.4d", sort_aux[ptr->team].leq_place[0]);
-
 
1040
        print (" %4.4d", sort_aux[ptr->team].leq_place[1]);
-
 
1041
        print (" %4.4d", sort_aux[ptr->team].leq_place[2]);
-
 
1042
        print (" %4.4d", sort_aux[ptr->team].leq_place[3]);
-
 
1043
        print (" %4.4d", sort_aux[ptr->team].leq_place[4]);
-
 
1044
        print (" %4.4d", sort_aux[ptr->team].leq_place[5]);
-
 
1045
 
-
 
1046
        print (",[%4.4d", sort_aux[ptr->team].lcq_place[0]);
-
 
1047
        print (" %4.4d", sort_aux[ptr->team].lcq_place[1]);
-
 
1048
        print (" %4.4d", sort_aux[ptr->team].lcq_place[2]);
-
 
1049
        print (" %4.4d", sort_aux[ptr->team].lcq_place[3]);
-
 
1050
        print (" %4.4d", sort_aux[ptr->team].lcq_place[4]);
-
 
1051
        print (" %4.4d]", sort_aux[ptr->team].lcq_place[5]);
-
 
1052
 
-
 
1053
        print (",%4.4d", sort_aux[ptr->team].lecq_place[0]);
-
 
1054
        print (" %4.4d", sort_aux[ptr->team].lecq_place[1]);
-
 
1055
        print (" %4.4d", sort_aux[ptr->team].lecq_place[2]);
-
 
1056
        print (" %4.4d", sort_aux[ptr->team].lecq_place[3]);
-
 
1057
        print (" %4.4d", sort_aux[ptr->team].lecq_place[4]);
-
 
1058
        print (" %4.4d", sort_aux[ptr->team].lecq_place[5]);
-
 
1059
#endif
951
 
1060
 
952
        /*
1061
        /*
953
        **  Print the trailer
1062
        **  Print the trailer
954
        **      - Total time
1063
        **      - Total time
955
        **      - Overall place - with reference to overall place file
1064
        **      - Overall place - with reference to overall place file
956
        */
1065
        */
957
        /* print( "  %-8s ", time_a( team_buf.leg[0].elapsed ) ); */
-
 
958
        print( "  %-8s ", time_a( ptr->lege[0] ) );
1066
        if ( config.num_legs != 1 ) print( "  %-8s ", time_a( ptr->lege[0] ) );
959
 
1067
 
960
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "finish" ,"html")), team_buf.numb );
1068
        if ( report_html == html )  setHref( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "finish" ,"html")), team_buf.numb );
961
        print( "%4.4s", pr_place( team_buf.leg[0].l_place, ptr->flags.bad_times || (ptr->teamclass == config.nonequestrian_class)));
1069
        print( "%4.4s", px_place( 0, team_buf.leg[0].l_place, false, true, ptr->flags));
962
        if ( report_html == html ) print( "</A>" );
-
 
963
 
1070
 
964
        if ( report_html == printed && lcount %5 == 4 ) print_underline( FALSE );
1071
        if ( report_html == printed && lcount %5 == 4 ) print_underline( FALSE );
965
        lcount++;
1072
        lcount++;
966
        print( "\n" );
1073
        print( "\n" );
967
    }
1074
    }
Line 973... Line 1080...
973
    /*
1080
    /*
974
    **  Pickup missed classes and create a report
1081
    **  Pickup missed classes and create a report
975
    */
1082
    */
976
    for( j = 1; j <= config.num_class; j++ )
1083
    for( j = 1; j <= config.num_class; j++ )
977
    {
1084
    {
978
        if ( class_done[j] )
1085
        if ( class_done[j] || !config.team_class[j-1].abr[0] )
979
        {
1086
        {
980
            continue;
1087
            continue;
981
        }
1088
        }
982
 
-
 
983
        report_title = tprintf( "Category results for : %-*s", LEN_CLASS_NAME, config.team_class[j - 1].full_name );
1089
        report_title = tprintf( "Category results for : %-*s", LEN_CLASS_NAME, config.team_class[j - 1].full_name );
984
        
1090
        
985
        if( !open_printer( "", config.team_class[j - 1].abr, 132, report_html, report_title ) )
1091
        if( !open_printer( "", config.team_class[j - 1].abr, 132, report_html, report_title ) )
986
            continue;
1092
            continue;
987
        print_class_header( j-1, TRUE );
1093
        print_class_header( j-1, TRUE );
Line 994... Line 1100...
994
    /*
1100
    /*
995
    **  If we are generating an HTML report then we need to create the file
1101
    **  If we are generating an HTML report then we need to create the file
996
    **  that contains all the team names - the assumption is that this data
1102
    **  that contains all the team names - the assumption is that this data
997
    **  is available
1103
    **  is available
998
    */
1104
    */
999
    if ( report_html )
1105
    if ( report_html == html || report_html == printed)
1000
    {
1106
    {
1001
        pri_team();
1107
        pri_team();
1002
    }
1108
    }
1003
 
1109
 
1004
    /*
1110
    /*
1005
    **  Generate the awards report.
1111
    **  Generate the awards report.
1006
    **  This is only available as an HTML report
1112
    **  This is only available as an HTML report
1007
    */
1113
    */
1008
    if ( report_html )
1114
    if ( report_html == html || report_html == printed)
1009
    {
1115
    {
1010
        pri_awards_html();
1116
        pri_awards_html();
1011
    }
1117
    }
1012
 
1118
 
1013
    /*
1119
    /*
1014
    **  Generate the master index page
1120
    **  Generate the master index page
1015
    */
1121
    */
1016
    if ( report_html )
1122
    if ( report_html == html )
1017
    {
1123
    {
1018
        pri_master_index();
1124
        pri_master_index();
1019
    }
1125
    }
1020
 
1126
 
1021
    pri_name_index_body();
1127
    pri_name_index_body();
1022
}
1128
}
1023
 
1129
 
1024
/*========================================================================
1130
/*========================================================================
1025
 *
1131
 *
-
 
1132
 *  Print final results in Team Order
-
 
1133
 *
-
 
1134
 *  Purpose:
-
 
1135
 *      This function is called to Print final results in Team Order
-
 
1136
 *
-
 
1137
 *  Parameters:
-
 
1138
 *      None
-
 
1139
 *
-
 
1140
 *  Returns:
-
 
1141
 *      Nothing
-
 
1142
 *
-
 
1143
 *========================================================================*/
-
 
1144
 
-
 
1145
void pri_final_teamOrder(void)
-
 
1146
{
-
 
1147
    ty_s_data  *ptr;
-
 
1148
    team_type   team_buf;
-
 
1149
    unsigned    i;
-
 
1150
    int         j;
-
 
1151
    int         lcount;
-
 
1152
 
-
 
1153
    ck_data( -1, C_ELAPSED );
-
 
1154
 
-
 
1155
    /*
-
 
1156
    **  Sort on every thing
-
 
1157
    **  Then generate all the stats too
-
 
1158
    */
-
 
1159
    do_big_sort();
-
 
1160
    gen_stats();
-
 
1161
 
-
 
1162
    /*
-
 
1163
     * Now print the data on the printer 
-
 
1164
     */
-
 
1165
    if( !open_printer( "", "team_order", 132, report_html, "Team Order" ) )
-
 
1166
        return;
-
 
1167
 
-
 
1168
    /*
-
 
1169
     * Print out the data 
-
 
1170
     */
-
 
1171
    print_class_header( -1, TRUE );                      /* Print the header */
-
 
1172
 
-
 
1173
    ptr = sort_data;
-
 
1174
    sort_team_data( 0, S_TEAM, true );                   /* Re-sort on team number */
-
 
1175
    lcount = 0;
-
 
1176
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
-
 
1177
    {
-
 
1178
        if ( ptr->isNeData )
-
 
1179
            continue;
-
 
1180
 
-
 
1181
        g_record( ptr->team, &team_buf );
-
 
1182
 
-
 
1183
        /*
-
 
1184
        ** If this is a NE team then dummy up some of the data that hasn't been stored in team_buf
-
 
1185
        */
-
 
1186
        if (ptr->flags.non_equestrian)
-
 
1187
        {
-
 
1188
            team_buf.leg[0].l_place = sort_aux[ptr->team].leq_place[0];
-
 
1189
            //team_buf.leg[0].lc_place = sort_aux[ptr->team].lcq_place[0];
-
 
1190
        }
-
 
1191
 
-
 
1192
        /*
-
 
1193
        **  If printing an HTML report then we need to mark
-
 
1194
        **  the entry with a reference so that we can link to it
-
 
1195
        */
-
 
1196
        if ( report_html == html )
-
 
1197
        {
-
 
1198
            print( "<A NAME=\"Team_%04d\"></A>",team_buf.numb );
-
 
1199
        }
-
 
1200
 
-
 
1201
        /*
-
 
1202
        **  Print the basics (Finishing order)
-
 
1203
        **      - Place within complete field
-
 
1204
        **      - Team number - with HTML reference to team file
-
 
1205
        **      - Class
-
 
1206
        */
-
 
1207
        if ( report_html == printed && lcount %5 == 4 ) print_underline( TRUE );
-
 
1208
        print( "%4.4s ", px_place( 0, team_buf.leg[0].l_place, false, true, ptr->flags ) );
-
 
1209
        if ( report_html == html ) setHref( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "name" ,"html")), team_buf.numb );
-
 
1210
        print( "%4d",  team_buf.numb );
-
 
1211
 
-
 
1212
        print( " %-*s", 3, team_buf.teamclass == 0 ? "" : config.team_class[team_buf.teamclass - 1].abr );
-
 
1213
 
-
 
1214
        /*
-
 
1215
        **  Print the per-leg data
-
 
1216
        **      - Time
-
 
1217
        **      - Leg place
-
 
1218
        **      - End place
-
 
1219
        */
-
 
1220
        for( j = 1; j <= config.num_legs; j++ )
-
 
1221
        {
-
 
1222
            bool isEquestrianLeg = (j == config.equestrian_leg && team_buf.flags.non_equestrian);
-
 
1223
            /*
-
 
1224
            **  Ensure that non-equestrian leg data is not displayed
-
 
1225
            */
-
 
1226
            if ( isEquestrianLeg )
-
 
1227
            {
-
 
1228
                print( "  %-8s %4.4s %4.4s", "-- NE --", "NE","NE");
-
 
1229
            }
-
 
1230
            else
-
 
1231
            {
-
 
1232
                print( "  %-8s",                     time_a( team_buf.leg[j].elapsed ));
-
 
1233
                if ( config.num_legs != 1 ) print( " %4.4s", px_place(j, team_buf.leg[j].l_place, false, false, ptr->flags ));
-
 
1234
                if ( config.num_legs != 1 ) print( " %4.4s", px_place(j, team_buf.leg[j].le_place,true,  true, ptr->flags ) );
-
 
1235
                if ( config.num_legs == 1 ) print( " %-*s ", MAX_TM_NAME, team_buf.name );
-
 
1236
            }
-
 
1237
        }
-
 
1238
 
-
 
1239
 
-
 
1240
       /*
-
 
1241
        **  Print the trailer (Finishing order)
-
 
1242
        **      - Total time
-
 
1243
        **      - Category place - with reference to category file
-
 
1244
        */
-
 
1245
       if ( config.num_legs != 1 ) print( "  %-8s ", time_a( ptr->lege[0] ) );
-
 
1246
        
-
 
1247
        if ( report_html == html ) setHref( "<A HREF=\"%s#Team_%04d\">",url_encode(p_filename(filebase, config.team_class[team_buf.teamclass - 1].abr ,"html")), team_buf.numb );
-
 
1248
        print( "%4.4s", px_place( 0, team_buf.leg[0].lc_place, false, false, ptr->flags ) );
-
 
1249
 
-
 
1250
//print (" --");
-
 
1251
//print (" %4.4d", sort_aux[ptr->team].lq_place[0]);
-
 
1252
//print (" %4.4d", sort_aux[ptr->team].leq_place[0]);
-
 
1253
//print (" %4.4d", sort_aux[ptr->team].lcq_place[0]);
-
 
1254
//print (" ,%4.4d", sort_aux[ptr->team].lec_place[0]);
-
 
1255
//print (" %4.4d", sort_aux[ptr->team].lec_place[1]);
-
 
1256
//print (" %4.4d", sort_aux[ptr->team].lec_place[2]);
-
 
1257
//print (" %4.4d", sort_aux[ptr->team].lec_place[3]);
-
 
1258
//print (" %4.4d", sort_aux[ptr->team].lec_place[4]);
-
 
1259
//print (" %4.4d", sort_aux[ptr->team].lec_place[5]);
-
 
1260
//print (" ,%4.4d", sort_aux[ptr->team].lecq_place[0]);
-
 
1261
//print (" %4.4d", sort_aux[ptr->team].lecq_place[1]);
-
 
1262
//print (" %4.4d", sort_aux[ptr->team].lecq_place[2]);
-
 
1263
//print (" %4.4d", sort_aux[ptr->team].lecq_place[3]);
-
 
1264
//print (" %4.4d", sort_aux[ptr->team].lecq_place[4]);
-
 
1265
//print (" %4.4d", sort_aux[ptr->team].lecq_place[5]);
-
 
1266
 
-
 
1267
 
-
 
1268
        if ( report_html == printed && lcount %5 == 4 ) print_underline( FALSE );
-
 
1269
        lcount++;
-
 
1270
        print( "\n" );
-
 
1271
    }
-
 
1272
 
-
 
1273
    print_class_stats( -1, TRUE );              /* Print statistics */
-
 
1274
    print_legend(-1, 1 );                       /* Print the legend */
-
 
1275
    close_printer();                            /* Close the printer */
-
 
1276
 
-
 
1277
}
-
 
1278
 
-
 
1279
/*========================================================================
-
 
1280
 *
1026
 *  Place to text
1281
 *  Place to text
1027
 *
1282
 *
1028
 *  Purpose:
1283
 *  Purpose:
1029
 *      This function is called to convert a place to text
1284
 *      This function is called to convert a place to text
1030
 *
1285
 *
Line 1066... Line 1321...
1066
    /*
1321
    /*
1067
    **  Generate ALL results with HTML tags
1322
    **  Generate ALL results with HTML tags
1068
    */
1323
    */
1069
    report_html = html;
1324
    report_html = html;
1070
    pri_awards();
1325
    pri_awards();
-
 
1326
    report_html = printed;
-
 
1327
    pri_awards();
1071
    report_html = saved;
1328
    report_html = saved;
1072
}
1329
}
1073
 
1330
 
1074
/*========================================================================
1331
/*========================================================================
1075
 *
1332
 *
Line 1095... Line 1352...
1095
    int winmax;
1352
    int winmax;
1096
    ty_s_data  *ptr;
1353
    ty_s_data  *ptr;
1097
    team_type   team_buf;
1354
    team_type   team_buf;
1098
    int         last_class;
1355
    int         last_class;
1099
    char    solid_line[100];
1356
    char    solid_line[100];
-
 
1357
    bool header_done = false;
-
 
1358
    bool entryFound;
-
 
1359
 
1100
 
1360
 
1101
    /*
1361
    /*
1102
    **  Calculate Summary information
1362
    **  Calculate Summary information
1103
    **  Should cache the data
1363
    **  Should cache the data
1104
    */
1364
    */
Line 1119... Line 1379...
1119
    if ( report_html == html )
1379
    if ( report_html == html )
1120
    {
1380
    {
1121
        print( "<hr>" );
1381
        print( "<hr>" );
1122
        print( "<A NAME=\"%s\"></A>",url_encode("INDEX"));
1382
        print( "<A NAME=\"%s\"></A>",url_encode("INDEX"));
1123
    }
1383
    }
1124
    print( "Award Categories");
1384
    print( "Award Categories - Full Event");
1125
 
1385
 
1126
    for( j = 1; j <= config.num_class; j++ )
1386
    for( j = 1; j <= config.num_class; j++ )
1127
    {
1387
    {
1128
        /*
1388
        /*
1129
        **  Header for the class
1389
        **  Header for the class
1130
        */
1390
        */
-
 
1391
        if (!config.team_class[j - 1].abr[0])
-
 
1392
            continue;
1131
        if ( config.class_winners[j-1] <= 0 )
1393
        if (config.class_winners[j - 1] <= 0) 
1132
            continue;
1394
            continue;
1133
 
1395
 
1134
        winmax = config.class_winners[j-1];
1396
        winmax = config.class_winners[j-1];
1135
        {
1397
        {
1136
            int valid =   sdata.teamclass[j].valid;
1398
            int valid =   sdata.teamclass[j].valid_ev;
1137
            if ( valid < winmax )
1399
            if ( valid < winmax )
1138
                winmax = valid;
1400
                winmax = valid;
1139
        }
1401
        }
1140
 
1402
 
1141
        print( "\n");
1403
        print( "\n");
1142
        print( "    ");
1404
        print( "    ");
1143
        if ( report_html == html ) print( "<A HREF=\"#%s\">",url_encode(config.team_class[j-1].full_name));
1405
        if ( report_html == html ) setHref( "<A HREF=\"#%s\">",url_encode(config.team_class[j-1].full_name));
1144
        print( "%s",  tprintf( "%-*s", LEN_CLASS_NAME ,config.team_class[j-1].full_name ));
1406
        print( "%s",  tprintf( "%-*s", LEN_CLASS_NAME ,config.team_class[j-1].full_name ));
1145
        if ( report_html == html ) print( "</A>" );
-
 
1146
        print( "  %3d Awards", winmax );
1407
        print( "  %3d Awards", winmax );
1147
        if ( config.class_winners[j-1] != winmax )
1408
        if ( config.class_winners[j-1] != winmax )
1148
            print( " from a maximum of %3d", config.class_winners[j-1] );
1409
            print( " from a maximum of %3d", config.class_winners[j-1] );
-
 
1410
    }
-
 
1411
 
-
 
1412
    /*
-
 
1413
    **  NE Award Categories
-
 
1414
    */
-
 
1415
    if ( config.class_ne_winners_by_class )
-
 
1416
    {
-
 
1417
        print( "\n");
-
 
1418
        print( "Award Categories - Non Equestrian");
1149
 
1419
 
-
 
1420
        for( j = 1; j <= config.num_class; j++ )
-
 
1421
        {
-
 
1422
            /*
-
 
1423
            **  Header for the class
-
 
1424
            */
-
 
1425
            if (!config.team_class[j - 1].abr[0])
-
 
1426
                continue;
-
 
1427
            if ( config.class_ne_winners[j-1] <= 0 )
-
 
1428
                continue;
-
 
1429
 
-
 
1430
            winmax = config.class_ne_winners[j-1];
-
 
1431
            {
-
 
1432
                int valid =   sdata.teamclass[j].valid_ne;
-
 
1433
                if ( valid < winmax )
-
 
1434
                    winmax = valid;
-
 
1435
            }
-
 
1436
 
-
 
1437
            print( "\n");
-
 
1438
            print( "    ");
-
 
1439
            if ( report_html == html ) setHref( "<A HREF=\"#%s_NE\">",url_encode(config.team_class[j-1].full_name));
-
 
1440
            print( "%s",  tprintf( "%-*s", LEN_CLASS_NAME ,config.team_class[j-1].full_name ));
-
 
1441
            print( "  %3d Awards", winmax );
-
 
1442
            if ( config.class_ne_winners[j-1] != winmax )
-
 
1443
                print( " from a maximum of %3d", config.class_ne_winners[j-1] );
-
 
1444
        }
1150
    }
1445
    }
1151
 
1446
 
1152
    /*
1447
    /*
1153
    **  Manual entries
1448
    **  Manual entries
1154
    */
1449
    */
-
 
1450
    print( "\n");
-
 
1451
    print( "Miscellaneous");
-
 
1452
 
-
 
1453
        print( "\n");
-
 
1454
        print( "    ");
-
 
1455
        if ( report_html == html ) setHref( "<A HREF=\"#%s_by_cat\">",url_encode("Full Event"));
-
 
1456
        print( "%s",  tprintf( "%-*s", LEN_CLASS_NAME ,"Full Event"));
-
 
1457
        print (" by Category");
-
 
1458
    
1155
    if ( config.class_ne_winners_by_class )
1459
    if ( config.class_ne_winners_by_class )
1156
    {
1460
    {
1157
        print( "\n");
1461
        print( "\n");
1158
        print( "    ");
1462
        print( "    ");
1159
        if ( report_html == html ) print( "<A HREF=\"#%s_by_cat\">",url_encode(config.team_class[config.nonequestrian_class-1].full_name));
1463
        if ( report_html == html ) setHref( "<A HREF=\"#%s_by_cat\">",url_encode(config.team_class[config.nonequestrian_class-1].full_name));
1160
        print( "%s",  tprintf( "%-*s", LEN_CLASS_NAME ,config.team_class[config.nonequestrian_class-1].full_name ));
1464
        print( "%s",  tprintf( "%-*s", LEN_CLASS_NAME ,config.team_class[config.nonequestrian_class-1].full_name ));
1161
        if ( report_html == html ) print( "</A>" );
-
 
1162
        print (" by Category");
1465
        print (" by Category");
1163
    }
1466
    }
1164
 
1467
 
1165
 
1468
 
1166
    print( "\n");
1469
    print( "\n");
1167
    print( "    ");
1470
    print( "    ");
1168
    if ( report_html == html ) print( "<A HREF=\"#%s\">",url_encode("Hall Of Fame"));
1471
    if ( report_html == html ) setHref( "<A HREF=\"#%s\">",url_encode("Hall Of Fame"));
1169
    print( "%s",  "Hall Of Fame" );
1472
    print( "%s",  "Hall Of Fame" );
-
 
1473
 
-
 
1474
    if (config.awardsfilename[0])
-
 
1475
    {
-
 
1476
        print( "\n");
-
 
1477
        print( "    ");
-
 
1478
        if ( report_html == html ) setHref( "<A HREF=\"#%s\">",url_encode("Additional Awards"));
1170
    if ( report_html == html ) print( "</A>" );
1479
        print( "%s",  "Additional Awards" );
-
 
1480
    }
1171
 
1481
 
1172
    print( "\n");
1482
    print( "\n");
1173
    print( "    ");
1483
    print( "    ");
1174
    if ( report_html == html ) print( "<A HREF=\"#%s\">",url_encode("FASTEST"));
1484
    if ( report_html == html ) setHref( "<A HREF=\"#%s\">",url_encode("FASTEST"));
1175
    print( "%s",  "FASTEST" );
1485
    print( "%s",  "FASTEST" );
1176
    if ( report_html == html ) print( "</A>" );
-
 
1177
 
1486
 
1178
    /*
1487
    /*  ---------------------------- Awards for Teams ----
1179
    **  Sort the data by class
1488
    **  Sort the data by class
1180
    */
1489
    */
1181
    sort_team_data( 0, S_LC );     /* Generate class placement data */
1490
    sort_team_data( 0, S_LC, true );     /* Generate class placement data */
1182
    last_class = -1;                /* Invalid class to start with */
1491
    last_class = -1;                     /* Invalid class to start with */
1183
 
1492
 
1184
    /*
1493
    /*
1185
    **  Process each category
1494
    **  Process each category
1186
    */
1495
    */
1187
    print( "\n");
1496
    print( "\n");
-
 
1497
    entryFound = false;
1188
    for( j = 1; ; j++ )
1498
    for( j = 1; ; j++ )
1189
    {
1499
    {
-
 
1500
        if (!config.team_class[j - 1].abr[0])
-
 
1501
            continue;
-
 
1502
 
1190
        /*
1503
        /*
1191
        **  Tail for previous entry
1504
        **  Tail for previous entry
1192
        */
1505
        */
1193
        //if ( config.class_ne_winners_by_class && j == config.nonequestrian_class )
1506
        //if ( config.class_ne_winners_by_class && j == config.nonequestrian_class )
1194
        //    continue;
1507
        //    continue;
1195
 
1508
 
1196
        if ( j != 1 )
1509
        if ( j != 1 ) {
-
 
1510
            if (!entryFound) {
-
 
1511
                print( "\n");
-
 
1512
                print( "No winners awarded. Non eligible." );
-
 
1513
                if ( report_html == html ) print("<br>");
-
 
1514
            }
1197
            if ( report_html == html ) print( "<A HREF=\"#%s\">Awards Index</A>",url_encode("INDEX"));
1515
            if ( report_html == html ) print( "<A HREF=\"#%s\">Awards Index</A>",url_encode("INDEX"));
-
 
1516
        }
1198
 
1517
 
1199
        if ( j > config.num_class  )
1518
        if ( j > config.num_class  )
1200
            break;
1519
            break;
1201
 
1520
 
1202
        /*
1521
        /*
Line 1204... Line 1523...
1204
        */
1523
        */
1205
        print( "\n");
1524
        print( "\n");
1206
        if ( report_html == html )
1525
        if ( report_html == html )
1207
        {
1526
        {
1208
            print( "<hr>" );
1527
            print( "<hr>" );
-
 
1528
 
-
 
1529
            if ( !header_done )
-
 
1530
            {
-
 
1531
                header_done = true;
-
 
1532
                if ( report_html == html )
-
 
1533
                {
-
 
1534
                    print( "<A name=\"%s_by_cat\"></A>",url_encode("Full Event"));
-
 
1535
                }
-
 
1536
            }
-
 
1537
 
1209
            print( "<A name=\"%s\"></A>",url_encode(config.team_class[j-1].full_name));
1538
            print( "<A name=\"%s\"></A>",url_encode(config.team_class[j-1].full_name));
1210
        }
1539
        }
1211
        else
1540
        else
1212
        {
1541
        {
1213
            print( "%s\n", solid_line);
1542
            print( "%s\n", solid_line);
1214
        }
1543
        }
1215
        print( "Category: ");
1544
        print( "Category: ");
1216
        if ( report_html == html ) print( "<A HREF=\"%s\">",url_encode(p_filename(filebase, config.team_class[j - 1].abr ,"html")));
1545
        if ( report_html == html ) setHref( "<A HREF=\"%s\">",url_encode(p_filename(filebase, config.team_class[j - 1].abr ,"html")));
1217
        print( "%s",  config.team_class[j-1].full_name );
1546
        print( "%s",  config.team_class[j-1].full_name );
1218
        if ( report_html == html ) print( "</A>" );
-
 
1219
 
1547
 
1220
        if ( config.class_winners[j-1] <= 0 )
1548
        if ( config.class_winners[j-1] <= 0 )
1221
        {
1549
        {
1222
            print( "\n");
1550
            print( "\n");
1223
            print( "No winners awarded" );
1551
            print( "No winners awarded" );
-
 
1552
            if ( report_html == html ) print("<br>");
1224
            continue;
1553
            continue;
1225
        }
1554
        }
1226
 
1555
 
1227
        /*
1556
        /*
1228
        **  Enties for 'n' the best teams as configured
1557
        **  Enties for 'n' the best teams as configured
1229
        */
1558
        */
1230
        windex = 0;                     /* Winners done */
1559
        windex = 0;                     /* Winners done */
-
 
1560
        entryFound = false;
1231
        unsigned int i;
1561
        unsigned int i;
1232
        for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
1562
        for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
1233
        {
1563
        {
1234
            if ( ptr->teamclass != j )
1564
            if ( ptr->teamclass != j )
1235
            {
1565
            {
Line 1244... Line 1574...
1244
                /*
1574
                /*
1245
                **  Ensure we have a valid team
1575
                **  Ensure we have a valid team
1246
                **  Can't award disqualified teams
1576
                **  Can't award disqualified teams
1247
                **  Can't award NE teams unless its a NE award
1577
                **  Can't award NE teams unless its a NE award
1248
                */
1578
                */
1249
                if ( ptr->flags.bad_times )
1579
                if ( ptr->flags.bad_times || ptr->flags.disqualified || ptr->flags.vet_check || !ptr->flags.valid )
1250
                    break;
1580
                    break;
1251
 
1581
 
1252
                if ( ptr->teamclass != config.nonequestrian_class  && ptr->flags.non_equestrian )
1582
                if ( !ptr->isNeData && ptr->flags.non_equestrian )
1253
                    break;
1583
                    break;
1254
 
1584
 
1255
                /*
1585
                /*
1256
                **  Count the entry
1586
                **  Count the entry
1257
                */
1587
                */
1258
                windex++;
1588
                windex++;
-
 
1589
                entryFound = true;
1259
 
1590
 
1260
                /*
1591
                /*
1261
                **  If printing an HTML report then we need to mark
1592
                **  If printing an HTML report then we need to mark
1262
                **  the entry with a reference so that we can link to it
1593
                **  the entry with a reference so that we can link to it
1263
                */
1594
                */
Line 1275... Line 1606...
1275
                **      - Full categoray name
1606
                **      - Full categoray name
1276
                */
1607
                */
1277
                print( "%s", placing(windex) );
1608
                print( "%s", placing(windex) );
1278
 
1609
 
1279
                print( "  Team Name: ");
1610
                print( "  Team Name: ");
1280
                if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "name" ,"html")), team_buf.numb );
1611
                if ( report_html == html ) setHref( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "name" ,"html")), team_buf.numb );
1281
                print( "%-*s ",     MAX_TM_NAME, team_buf.name );
1612
                print( "%-*s ",     MAX_TM_NAME, team_buf.name );
1282
                    if ( report_html == html ) print( "</A>" );
-
 
1283
 
1613
 
1284
                print( "  Number: ");
1614
                print( "  Number: ");
1285
                if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "finish" ,"html")), team_buf.numb );
1615
                if ( report_html == html ) setHref( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "finish" ,"html")), team_buf.numb );
1286
                print( "%4d",       team_buf.numb );
1616
                print( "%4d",       team_buf.numb );
1287
                if ( report_html == html ) print( "</A>" );
-
 
1288
 
1617
 
1289
 
1618
 
1290
                for( k = 0; k < MAX_MEMB; k++ )
1619
                for( k = 0; k < MAX_MEMB; k++ )
1291
                {
1620
                {
1292
 
1621
 
1293
                    /*
1622
                    /*
1294
                    **  Skip equestrian leg in the non-equestion display
1623
                    **  Skip equestrian leg in the non-equestion display
1295
                    */
1624
                    */
1296
                    if ( k + 1 == config.equestrian_leg && ptr->teamclass == config.nonequestrian_class)
1625
                    if ( k + 1 == config.equestrian_leg && ptr->isNeData)
1297
                        continue;
1626
                        continue;
1298
 
1627
 
1299
                    print( "\n");
1628
                    print( "\n");
1300
                    print( "    ");
1629
                    print( "    ");
1301
                    print( "%-*s", MAX_PERSON_NAME, config.leg_name[k] ? config.leg_name[k] : "Competitor"  );
1630
                    print( "%-*s", MAX_PERSON_NAME, config.leg_name[k] ? config.leg_name[k] : "Competitor"  );
Line 1326... Line 1655...
1326
    /*
1655
    /*
1327
    ** Non Equestrian winners by category
1656
    ** Non Equestrian winners by category
1328
    */
1657
    */
1329
    if ( config.class_ne_winners_by_class)
1658
    if ( config.class_ne_winners_by_class)
1330
    {
1659
    {
1331
        bool header_done = false;
1660
        header_done = false;
1332
 
1661
 
1333
        /*
1662
        /*
1334
        **  Sort the data by class with NE data sorted by real class
1663
        **  Sort the data by class with NE data sorted by real class
1335
        */
1664
        */
1336
        sort_team_data( 0, S_LC_NE );      /* Generate class placement data */
1665
        sort_team_data( 0, S_LC_NE, true );     /* Generate class placement data */
1337
        last_class = -1;                   /* Invalid class to start with */
1666
        last_class = -1;                        /* Invalid class to start with */
1338
 
1667
 
1339
        /*
1668
        /*
1340
        **  Only process the Non Equestrian teams in this pass
1669
        **  Only process the Non Equestrian teams in this pass
1341
        */
1670
        */
1342
        print( "\n");
1671
        print( "\n");
-
 
1672
        entryFound = false;
1343
        for( j = 1; ; j++ )
1673
        for( j = 1; ; j++ )
1344
        {
1674
        {
-
 
1675
            if (!config.team_class[j - 1].abr[0])
-
 
1676
                continue;
-
 
1677
 
1345
            /*
1678
            /*
1346
            **  Tail for previous entry
1679
            **  Tail for previous entry
1347
            */
1680
            */
1348
            if ( j == config.nonequestrian_class)
1681
            if ( j == config.nonequestrian_class)
1349
                continue;
1682
                continue;
1350
 
1683
 
1351
            if ( j != 1 )
1684
            if ( j != 1 ) {
-
 
1685
                if (!entryFound) {
-
 
1686
                    print( "\n");
-
 
1687
                    print( "No winners awarded. Non eligible." );
-
 
1688
                    if ( report_html == html ) print("<br>");
-
 
1689
                }
1352
                if ( report_html == html ) print( "<A HREF=\"#%s\">Awards Index</A>",url_encode("INDEX"));
1690
                if ( report_html == html ) print( "<A HREF=\"#%s\">Awards Index</A>",url_encode("INDEX"));
-
 
1691
            }
1353
 
1692
 
1354
            if ( j > config.num_class  )
1693
            if ( j > config.num_class  )
1355
                break;
1694
                break;
1356
 
1695
 
1357
            /*
1696
            /*
Line 1368... Line 1707...
1368
 
1707
 
1369
            print( "\n");
1708
            print( "\n");
1370
            if ( report_html == html )
1709
            if ( report_html == html )
1371
            {
1710
            {
1372
                print( "<hr>" );
1711
                print( "<hr>" );
1373
                print( "<A name=\"%s\"></A>",url_encode(config.team_class[j-1].full_name));
1712
                print( "<A name=\"%s_NE\"></A>",url_encode(config.team_class[j-1].full_name));
1374
            }
1713
            }
1375
            else
1714
            else
1376
            {
1715
            {
1377
                print( "%s\n", solid_line);
1716
                print( "%s\n", solid_line);
1378
            }
1717
            }
1379
            print( "Category: ");
1718
            print( "Category: ");
1380
            if ( report_html == html ) print( "<A HREF=\"%s\">",url_encode(p_filename(filebase, config.team_class[config.nonequestrian_class - 1].abr ,"html")));
1719
            if ( report_html == html ) setHref( "<A HREF=\"%s\">",url_encode(p_filename(filebase, config.team_class[config.nonequestrian_class - 1].abr ,"html")));
1381
            print( "%s",  config.team_class[config.nonequestrian_class-1].full_name );
1720
            print( "%s",  config.team_class[config.nonequestrian_class-1].full_name );
1382
            if ( report_html == html ) print( "</A>" );
-
 
1383
 
1721
 
1384
            print (" :: ");
1722
            print (" :: ");
1385
 
1723
 
1386
            if ( report_html == html ) print( "<A HREF=\"%s\">",url_encode(p_filename(filebase, config.team_class[j - 1].abr ,"html")));
1724
            if ( report_html == html ) setHref( "<A HREF=\"%s\">",url_encode(p_filename(filebase, config.team_class[j - 1].abr ,"html")));
1387
            print( "%s",  config.team_class[j-1].full_name );
1725
            print( "%s",  config.team_class[j-1].full_name );
1388
            if ( report_html == html ) print( "</A>" );
-
 
1389
 
1726
 
1390
            if ( config.class_ne_winners[j-1] <= 0 )
1727
            if ( config.class_ne_winners[j-1] <= 0 )
1391
            {
1728
            {
1392
                print( "\n");
1729
                print( "\n");
1393
                print( "No winners awarded" );
1730
                print( "No winners awarded" );
Line 1396... Line 1733...
1396
            }
1733
            }
1397
 
1734
 
1398
            /*
1735
            /*
1399
            **  Enties for 'n' the best teams as configured
1736
            **  Enties for 'n' the best teams as configured
1400
            */
1737
            */
-
 
1738
            entryFound = false;
1401
            windex = 0;                     /* Winners done */
1739
            windex = 0;                     /* Winners done */
1402
            unsigned int i;
1740
            unsigned int i;
1403
            for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
1741
            for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
1404
            {
1742
            {
1405
                if ( ptr->teamclass != config.nonequestrian_class ||  ptr->real_teamclass != j )
1743
                if ( !ptr->isNeData )
1406
                {
1744
                    continue;
-
 
1745
 
-
 
1746
                if ( ptr->teamclass != j ) {
1407
                    continue;
1747
                    continue;
1408
                }
1748
                }
-
 
1749
                //qDebug() << "NeTeam0:" <<  ptr->team << "," << ptr->isNeData << "," << ptr->teamclass << "," << j;
1409
 
1750
 
1410
                /*
1751
                /*
1411
                **  Now read in the team record
1752
                **  Now read in the team record
1412
                */
1753
                */
1413
                if( valid_field( ptr->team ) && g_record( ptr->team, &team_buf ) )
1754
                if( valid_field( ptr->team ) && g_record( ptr->team, &team_buf ) )
Line 1415... Line 1756...
1415
                    /*
1756
                    /*
1416
                    **  Ensure we have a valid team
1757
                    **  Ensure we have a valid team
1417
                    **  Can't award disqualified teams
1758
                    **  Can't award disqualified teams
1418
                    **  Can't award NE teams unless its a NE award
1759
                    **  Can't award NE teams unless its a NE award
1419
                    */
1760
                    */
1420
                    if ( ptr->flags.bad_times )
1761
                    if ( ptr->flags.bad_times || ptr->flags.disqualified || ptr->flags.vet_check || !ptr->flags.valid )
1421
                        break;
1762
                        break;
1422
 
1763
 
1423
                    if ( ptr->teamclass != config.nonequestrian_class  && ptr->flags.non_equestrian )
1764
                    if ( /*!ptr->isNeData &&*/ !ptr->flags.non_equestrian )
1424
                        break;
1765
                        break;
1425
 
1766
 
1426
                    /*
1767
                    /*
1427
                    **  Count the entry
1768
                    **  Count the entry
1428
                    */
1769
                    */
1429
                    windex++;
1770
                    windex++;
-
 
1771
                    entryFound = true;
1430
 
1772
 
1431
                    /*
1773
                    /*
1432
                    **  If printing an HTML report then we need to mark
1774
                    **  If printing an HTML report then we need to mark
1433
                    **  the entry with a reference so that we can link to it
1775
                    **  the entry with a reference so that we can link to it
1434
                    */
1776
                    */
Line 1446... Line 1788...
1446
                    **      - Full categoray name
1788
                    **      - Full categoray name
1447
                    */
1789
                    */
1448
                    print( "%s", placing(windex) );
1790
                    print( "%s", placing(windex) );
1449
 
1791
 
1450
                    print( "  Team Name: ");
1792
                    print( "  Team Name: ");
1451
                    if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "name" ,"html")), team_buf.numb );
1793
                    if ( report_html == html ) setHref( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "name" ,"html")), team_buf.numb );
1452
                    print( "%-*s ",     MAX_TM_NAME, team_buf.name );
1794
                    print( "%-*s ",     MAX_TM_NAME, team_buf.name );
1453
                        if ( report_html == html ) print( "</A>" );
-
 
1454
 
1795
 
1455
                    print( "  Number: ");
1796
                    print( "  Number: ");
1456
                    if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "finish" ,"html")), team_buf.numb );
1797
                    if ( report_html == html ) setHref( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "finish" ,"html")), team_buf.numb );
1457
                    print( "%4d",       team_buf.numb );
1798
                    print( "%4d",       team_buf.numb );
1458
                    if ( report_html == html ) print( "</A>" );
-
 
1459
 
1799
 
1460
 
1800
 
1461
                    for( k = 0; k < MAX_MEMB; k++ )
1801
                    for( k = 0; k < MAX_MEMB; k++ )
1462
                    {
1802
                    {
1463
 
1803
 
1464
                        /*
1804
                        /*
1465
                        **  Skip equestrian leg in the non-equestion display
1805
                        **  Skip equestrian leg in the non-equestion display
1466
                        */
1806
                        */
1467
                        if ( k + 1 == config.equestrian_leg && ptr->teamclass == config.nonequestrian_class)
1807
                        if ( k + 1 == config.equestrian_leg && ptr->isNeData)
1468
                            continue;
1808
                            continue;
1469
 
1809
 
1470
                        print( "\n");
1810
                        print( "\n");
1471
                        print( "    ");
1811
                        print( "    ");
1472
                        print( "%-*s", MAX_PERSON_NAME, config.leg_name[k] ? config.leg_name[k] : "Competitor"  );
1812
                        print( "%-*s", MAX_PERSON_NAME, config.leg_name[k] ? config.leg_name[k] : "Competitor"  );
Line 1523... Line 1863...
1523
        qDebug( "There are no new stars for the Hall of Fame");
1863
        qDebug( "There are no new stars for the Hall of Fame");
1524
    }
1864
    }
1525
    if ( report_html == html ) print( "\n");
1865
    if ( report_html == html ) print( "\n");
1526
    if ( report_html == html ) print( "<A HREF=\"#%s\">Awards Index</A>",url_encode("INDEX"));
1866
    if ( report_html == html ) print( "<A HREF=\"#%s\">Awards Index</A>",url_encode("INDEX"));
1527
 
1867
 
-
 
1868
 
-
 
1869
 
-
 
1870
 
-
 
1871
    /*
-
 
1872
    **  Insert additional Awards information
-
 
1873
    */
-
 
1874
    if (config.awardsfilename[0])
-
 
1875
    {
-
 
1876
        print( "\n");
-
 
1877
        if ( report_html == html )
-
 
1878
        {
-
 
1879
            print( "<hr>" );
-
 
1880
            print( "<A name=\"%s\"></A>",url_encode("Additional Awards"));
-
 
1881
        }
-
 
1882
        else
-
 
1883
        {
-
 
1884
            print( "%s\n", solid_line);
-
 
1885
        }
-
 
1886
        print( "%s",  "Additional Awards" );
-
 
1887
        print ("\n");
-
 
1888
 
-
 
1889
        /*
-
 
1890
        **  Read and process the named awards file
-
 
1891
        */
-
 
1892
        FILE       *adfile = NULL;
-
 
1893
        char        line[201];
-
 
1894
 
-
 
1895
        QString name = QmConfig::getAddendemFile(config.awardsfilename);
-
 
1896
        if (! name.isEmpty())
-
 
1897
        {
-
 
1898
            adfile = fopen( qPrintable(name), "rt" );  /* Open the file for reading */
-
 
1899
        }
-
 
1900
 
-
 
1901
 
-
 
1902
        if( adfile )
-
 
1903
        {
-
 
1904
            while( fgets( line, sizeof(line)-1, adfile ) ) {
-
 
1905
                //  Process each line
-
 
1906
                //  Attempt to perform some smart text replacements
-
 
1907
                //  ie: <TeamNumber:63> <TeamName:63><TeamLegName:1:63>
-
 
1908
                print( "%s", line );
-
 
1909
            }
-
 
1910
            fclose(adfile);
-
 
1911
        }
-
 
1912
        else
-
 
1913
        {
-
 
1914
            if ( report_html == html )  print ("<br>");
-
 
1915
            print( "\nThe awards file could not be found: %s\n",  adfile);
-
 
1916
        }
-
 
1917
 
-
 
1918
 
-
 
1919
        if ( report_html == html ) print( "\n");
-
 
1920
        if ( report_html == html ) print( "<A HREF=\"#%s\">Awards Index</A>",url_encode("INDEX"));
-
 
1921
    }
-
 
1922
 
1528
    /*
1923
    /*
1529
    **  Generate the FASTEST information
1924
    **  Generate the FASTEST information
1530
    */
1925
    */
1531
    print( "\n" );
1926
    print( "\n" );
1532
    print( "\n");
1927
    print( "\n");
Line 1552... Line 1947...
1552
        g_record( stats.fast.team[i][0], &team_buf );
1947
        g_record( stats.fast.team[i][0], &team_buf );
1553
 
1948
 
1554
        print( "\n");
1949
        print( "\n");
1555
        print( "    %-13s ", config.leg_name[i - 1] );
1950
        print( "    %-13s ", config.leg_name[i - 1] );
1556
        print( "  Name: ");
1951
        print( "  Name: ");
1557
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "name" ,"html")), team_buf.numb );
1952
        if ( report_html == html ) setHref( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "name" ,"html")), team_buf.numb );
1558
        print( "%-*s", MAX_PERSON_NAME, team_buf.members[i-1].name );
1953
        print( "%-*s", MAX_PERSON_NAME, team_buf.members[i-1].name );
1559
        if ( report_html == html ) print( "</A>" );
-
 
1560
        print( "  Team :");
1954
        print( "  Team:");
1561
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "finish" ,"html")), team_buf.numb );
1955
        if ( report_html == html ) setHref( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "finish" ,"html")), team_buf.numb );
1562
        print( "%4d" , stats.fast.team[i][0] );
1956
        print( "%4d" , stats.fast.team[i][0] );
1563
        if ( report_html == html ) print( "</A> " );
-
 
1564
        print( "Time:%s ", time_a( stats.fast.time[i][0] ) );
1957
        print( "  Time:%s ", time_a( stats.fast.time[i][0] ) );
1565
 
1958
 
1566
    }
1959
    }
1567
 
1960
 
1568
    if ( report_html == html ) print( "\n");
1961
    if ( report_html == html ) print( "\n");
1569
    if ( report_html == html ) print( "<A HREF=\"#%s\">Awards Index</A>",url_encode("INDEX"));
1962
    if ( report_html == html ) print( "<A HREF=\"#%s\">Awards Index</A>",url_encode("INDEX"));
Line 1608... Line 2001...
1608
    */
2001
    */
1609
    print( "<TABLE border=0 align=center>" );
2002
    print( "<TABLE border=0 align=center>" );
1610
    pri_master_index_entry( "name", "Team list" );
2003
    pri_master_index_entry( "name", "Team list" );
1611
    pri_master_index_entry( "competitor", "Competitor list" );
2004
    pri_master_index_entry( "competitor", "Competitor list" );
1612
    pri_master_index_entry( "finish", "Finishing Order for all Teams" );
2005
    pri_master_index_entry( "finish", "Finishing Order for all Teams" );
-
 
2006
    pri_master_index_entry( "team_order", "All Teams with results" );
1613
    pri_master_index_entry( "awards", "Prizes and Awards" );
2007
    pri_master_index_entry( "awards", "Prizes and Awards" );
1614
    print( "<tr><td>\n" );
2008
    print( "<tr><td>\n" );
1615
 
2009
 
1616
    print( "\n" );
2010
    print( "\n" );
1617
    for( j = 1; j <= config.num_class; j++ )
2011
    for( j = 1; j <= config.num_class; j++ )
1618
    {
2012
    {
-
 
2013
        if (!config.team_class[j - 1].abr[0])
-
 
2014
            continue;
1619
        pri_master_index_entry( config.team_class[j - 1].abr, tprintf("Category Results for: %s", config.team_class[j-1].full_name) );
2015
        pri_master_index_entry( config.team_class[j - 1].abr, tprintf("Category Results for: %s", config.team_class[j-1].full_name) );
1620
    }
2016
    }
1621
        
2017
        
1622
    print( "</TABLE>" );
2018
    print( "</TABLE>" );
1623
 
2019
 
Line 1636... Line 2032...
1636
    print( "<TABLE border=0 align=center>" );
2032
    print( "<TABLE border=0 align=center>" );
1637
#if 1
2033
#if 1
1638
    pri_master_index_entry( "name", "Team list" );
2034
    pri_master_index_entry( "name", "Team list" );
1639
    pri_master_index_entry( "competitor", "Competitor list" );
2035
    pri_master_index_entry( "competitor", "Competitor list" );
1640
    pri_master_index_entry( "finish", "Finishing Order for all Teams" );
2036
    pri_master_index_entry( "finish", "Finishing Order for all Teams" );
-
 
2037
    pri_master_index_entry( "team_order", "All Teams with results" );
1641
    pri_master_index_entry( "awards", "Prizes and Awards" );
2038
    pri_master_index_entry( "awards", "Prizes and Awards" );
1642
    print( "<tr><td>\n" );
2039
    print( "<tr><td>\n" );
1643
 
2040
 
1644
    print( "\n" );
2041
    print( "\n" );
-
 
2042
    pri_master_index_entry( "summary", "Category Summary" );
1645
    for( j = 1; j <= config.num_class; j++ )
2043
    for( j = 1; j <= config.num_class; j++ )
1646
    {
2044
    {
-
 
2045
        if (!config.team_class[j - 1].abr[0])
-
 
2046
            continue;
1647
        pri_master_index_entry( config.team_class[j - 1].abr, tprintf("Category Results for: %s", config.team_class[j-1].full_name) );
2047
        pri_master_index_entry( config.team_class[j - 1].abr, tprintf("Category Results for: %s", config.team_class[j-1].full_name) );
1648
    }
2048
    }
1649
#endif
2049
#endif
1650
    print( "<tr><td>\n" );
2050
    print( "<tr><td>\n" );
1651
 
2051
 
Line 1668... Line 2068...
1668
 
2068
 
1669
    close_printer();
2069
    close_printer();
1670
    /*
2070
    /*
1671
     ** Tell the main system about this new report
2071
     ** Tell the main system about this new report
1672
     */
2072
     */
1673
    MainWindow::registerReport(getPrinterFile(), "Master Index");
2073
    MainWindow::registerReport(getPrinterFile(), "Master Leg Index");
1674
    
2074
    
1675
}
2075
}
1676
 
2076
 
1677
 
2077
 
1678
/*========================================================================
2078
/*========================================================================
Line 1695... Line 2095...
1695
    ty_s_data  *ptr;
2095
    ty_s_data  *ptr;
1696
    team_type   team_buf;
2096
    team_type   team_buf;
1697
    unsigned    i;
2097
    unsigned    i;
1698
    int         j, last_class;
2098
    int         j, last_class;
1699
    char       *report_title;
2099
    char       *report_title;
-
 
2100
    short       pClass;
1700
 
2101
 
1701
    if ( ! report_all )
2102
    if ( ! report_all )
1702
    {
2103
    {
1703
        ck_data( -1, C_DISQUAL );              /* Check the data - dummy check */
2104
        ck_data( -1, C_DISQUAL );              /* Check the data - dummy check */
1704
    }
2105
    }
Line 1716... Line 2117...
1716
     * Print out the data 
2117
     * Print out the data 
1717
     */
2118
     */
1718
    print_class_header( -1, FALSE );                     /* Print the header */
2119
    print_class_header( -1, FALSE );                     /* Print the header */
1719
 
2120
 
1720
    ptr = sort_data;
2121
    ptr = sort_data;
1721
    sort_team_data( 0, S_TEAM );                   /* Re-sort on team number */
2122
    sort_team_data( 0, S_TEAM, true );                   /* Re-sort on team number */
1722
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
2123
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
1723
    {
2124
    {
1724
        if ( ptr->teamclass == config.nonequestrian_class )
2125
        if ( ptr->isNeData )
1725
            continue;
2126
            continue;
1726
 
2127
 
1727
        g_record( ptr->team, &team_buf );
2128
        g_record( ptr->team, &team_buf );
1728
 
2129
 
1729
        print( "%4d %4.4s %-*s",
2130
        print( "%4d %4.4s %-*s",
1730
               team_buf.numb,
2131
               team_buf.numb,
1731
               pi_place( team_buf.leg[config.num_legs].le_place,
2132
               px_place(-1, team_buf.leg[config.num_legs].le_place, false, false, ptr->flags ),
1732
                         ptr->flags.disqualified, team_buf.leg[0].elapsed ),
-
 
1733
               3,
2133
               3,
1734
               team_buf.teamclass ==
-
 
1735
               0 ? "" : config.team_class[team_buf.teamclass - 1].abr );
2134
               team_buf.teamclass == 0 ? "" : config.team_class[team_buf.teamclass - 1].abr );
-
 
2135
 
1736
        for( j = 1; j <= config.num_legs; j++ )
2136
        for( j = 1; j <= config.num_legs; j++ )
1737
        {
2137
        {
1738
            print( "  %-8s %4.4s %4.4s",
-
 
1739
                   time_fa( team_buf.leg[j].elapsed,
-
 
1740
                            ptr->flags.disqualified ),
-
 
1741
                   pi_place( team_buf.leg[j].l_place, ptr->flags.disqualified,
2138
            print( "  %-8s", time_fa( team_buf.leg[j].elapsed, ptr->flags.disqualified ));
1742
                             team_buf.leg[j].elapsed ),
2139
            if ( config.num_legs != 1 ) print( " %4.4s", px_place(j, team_buf.leg[j].l_place, false, true, ptr->flags ));
1743
                   pi_place( team_buf.leg[j].le_place,
2140
            if ( config.num_legs != 1 ) print( " %4.4s", px_place(j, team_buf.leg[j].le_place, false, true, ptr->flags ));
1744
                             ptr->flags.disqualified,
-
 
1745
                             team_buf.leg[j].elapsed ) );
2141
            if ( config.num_legs == 1 ) print( " %-*s ",     MAX_TM_NAME, team_buf.name );
1746
        }
2142
        }
1747
        print( "  %-8s %4.4s\n",
-
 
-
 
2143
 
1748
               time_fa( team_buf.leg[0].elapsed, ptr->flags.disqualified ),
2144
        if ( config.num_legs != 1 ) print( "  %-8s", time_fa( team_buf.leg[0].elapsed, ptr->flags.disqualified ));
1749
               pi_place( team_buf.leg[config.num_legs].lec_place,
2145
        print( " %4.4s\n", px_place(0, team_buf.leg[config.num_legs].lec_place, false, false, ptr->flags ));
1750
                         ptr->flags.disqualified, team_buf.leg[0].elapsed ) );
-
 
1751
    }
2146
    }
1752
 
2147
 
1753
    print_class_stats( -1, FALSE );             /* Print statistics */
2148
    print_class_stats( -1, FALSE );             /* Print statistics */
1754
    print_legend(-1, 1);                        /* Print the legend */
2149
    print_legend(-1, 1);                        /* Print the legend */
1755
    close_printer();                            /* Close the printer */
2150
    close_printer();                            /* Close the printer */
Line 1758... Line 2153...
1758
    /*
2153
    /*
1759
     * Now produce a breakdown on a class by class basis 
2154
     * Now produce a breakdown on a class by class basis 
1760
     * Now print out the class placement information
2155
     * Now print out the class placement information
1761
     */
2156
     */
1762
 
2157
 
1763
    sort_team_data( 0, S_CLASS );              /* Generate class placement data */
2158
    sort_team_data( 0, S_CLASS, true );             /* Generate class placement data */
1764
    last_class = -1;                             /* Invalid class to start with */
2159
    last_class = -1;                                /* Invalid class to start with */
-
 
2160
    pClass = -1;
1765
 
2161
 
1766
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
2162
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
1767
    {
2163
    {
-
 
2164
        if (ptr->isNeData)
-
 
2165
            pClass = config.nonequestrian_class;
-
 
2166
        else
-
 
2167
            pClass = ptr->teamclass;
-
 
2168
 
1768
        /*
2169
        /*
1769
        **  Detect a change in the "class"
2170
        **  Detect a change in the "class"
1770
        **  All data is within the one array of data
2171
        **  All data is within the one array of data
1771
        **  Use the in-memory class as this MAY differ from that stored
2172
        **  Use the in-memory class as this MAY differ from that stored
1772
        **  The non-equestrian class does this.
2173
        **  The non-equestrian class does this.
1773
        */
2174
        */
1774
        if( last_class != ptr->teamclass )
2175
        if( last_class != pClass )
1775
        {
2176
        {
1776
            if( last_class >= 0 )
2177
            if( last_class >= 0 )
1777
            {
2178
            {
1778
                print_class_stats( last_class, TRUE );
2179
                print_class_stats( last_class, FALSE );
1779
                print_legend(last_class, 1);
2180
                print_legend(last_class, 1);
1780
                close_printer();
2181
                close_printer();
1781
            }
2182
            }
1782
 
2183
 
1783
            report_title = tprintf( "Interim Category results for : %-*s", LEN_CLASS_NAME, team_buf.teamclass == 0 ? "" : config.team_class[ptr->teamclass - 1].full_name );
2184
            report_title = tprintf( "Interim Category results for : %-*s", LEN_CLASS_NAME, pClass == 0 ? "" : config.team_class[pClass - 1].full_name );
1784
 
2185
 
1785
            if( !open_printer( "", tprintf( "i%2s", config.team_class[ptr->teamclass - 1].abr ), 132, report_html, report_title ) )
2186
            if( !open_printer( "", tprintf( "i%2s", config.team_class[pClass - 1].abr ), 132, report_html, report_title ) )
1786
                continue;
2187
                continue;
1787
            print_class_header( last_class = ptr->teamclass, FALSE );
2188
            print_class_header( last_class = pClass, FALSE );
1788
        }
2189
        }
1789
 
2190
 
1790
        /*
2191
        /*
1791
        **  Now read in the team record
2192
        **  Now read in the team record
1792
        */
2193
        */
1793
        g_record( ptr->team, &team_buf );
2194
        g_record( ptr->team, &team_buf );
1794
        print( "%4d %4.4s %-*s",
2195
        print( "%4d %4.4s %-*s",
1795
               team_buf.numb,
2196
               team_buf.numb,
1796
               pi_place( team_buf.leg[config.num_legs].lec_place,
2197
               px_place(-1, team_buf.leg[config.num_legs].lec_place, false, false, ptr->flags ),
1797
                         ptr->flags.disqualified, team_buf.leg[0].elapsed ),
-
 
1798
               3,
2198
               3,
1799
               team_buf.teamclass ==
-
 
1800
               0 ? "" : config.team_class[team_buf.teamclass - 1].abr );
2199
               team_buf.teamclass == 0 ? "" : config.team_class[team_buf.teamclass - 1].abr );
-
 
2200
 
1801
        for( j = 1; j <= config.num_legs; j++ )
2201
        for( j = 1; j <= config.num_legs; j++ )
1802
        {
2202
        {
1803
            print( "  %-8s %4.4s %4.4s",
-
 
1804
                   time_fa( team_buf.leg[j].elapsed,
2203
            print( "  %-8s", time_fa( team_buf.leg[j].elapsed, ptr->flags.disqualified ));
1805
                            ptr->flags.disqualified ),
-
 
1806
                   pi_place( team_buf.leg[j].lc_place,
2204
            if ( config.num_legs != 1 ) print( " %4.4s", px_place(j, team_buf.leg[j].lc_place,  false, true, ptr->flags ));
1807
                             ptr->flags.disqualified,
-
 
1808
                             team_buf.leg[j].elapsed ),
-
 
1809
                   pi_place( team_buf.leg[j].lec_place,
2205
            if ( config.num_legs != 1 ) print( " %4.4s", px_place(j, team_buf.leg[j].lec_place, false, true, ptr->flags ));
1810
                             ptr->flags.disqualified,
-
 
1811
                             team_buf.leg[j].elapsed ) );
2206
            if ( config.num_legs == 1 ) print( " %-*s ", MAX_TM_NAME, team_buf.name );
1812
        }
2207
        }
1813
        print( "  %-8s %4.4s\n",
-
 
-
 
2208
 
-
 
2209
 
1814
               time_fa( team_buf.leg[0].elapsed, ptr->flags.disqualified ),
2210
        if ( config.num_legs != 1 ) print( "  %-8s", time_fa( team_buf.leg[0].elapsed, ptr->flags.disqualified ));
1815
               pi_place( team_buf.leg[config.num_legs].le_place,
2211
        print( " %4.4s\n", px_place(0, team_buf.leg[config.num_legs].le_place, false, false, ptr->flags ) );
1816
                         ptr->flags.disqualified, team_buf.leg[0].elapsed ) );
-
 
1817
    }
2212
    }
1818
 
2213
 
1819
    print_class_stats( last_class, FALSE );
2214
    print_class_stats( last_class, FALSE );
1820
    print_legend(last_class, 1);
2215
    print_legend(last_class, 1);
1821
    close_printer();
2216
    close_printer();
Line 1885... Line 2280...
1885
        csv_print( "%s", "Elapsed Time Number");
2280
        csv_print( "%s", "Elapsed Time Number");
1886
        csv_print( "%s", "Leg Place");
2281
        csv_print( "%s", "Leg Place");
1887
        csv_print( "%s", "Leg End Place");
2282
        csv_print( "%s", "Leg End Place");
1888
        csv_print( "%s", "Leg Class Place");
2283
        csv_print( "%s", "Leg Class Place");
1889
        csv_print( "%s", "Leg End Class Place");
2284
        csv_print( "%s", "Leg End Class Place");
-
 
2285
 
-
 
2286
        csv_print( "%s", "NE Leg Place");
-
 
2287
        csv_print( "%s", "NE Leg End Place");
-
 
2288
        csv_print( "%s", "NE Leg Class Place");
-
 
2289
        csv_print( "%s", "NE Leg End Class Place");
-
 
2290
 
1890
        csv_print( "%s", "Manual");
2291
        csv_print( "%s", "Manual");
1891
    }
2292
    }
1892
 
2293
 
1893
    j = 0;
2294
    j = 0;
1894
    csv_print( "%s", "Team Start Time");
2295
    csv_print( "%s", "Team Start Time");
1895
    csv_print( "%s", "Team Start Time Number");
2296
    csv_print( "%s", "Team Start Time Number");
1896
    csv_print( "%s", "Team End Time");
2297
    csv_print( "%s", "Team End Time");
1897
    csv_print( "%s", "Team End Time Number");
2298
    csv_print( "%s", "Team End Time Number");
1898
    csv_print( "%s", "Team Elapsed Time");
2299
    csv_print( "%s", "Team Elapsed Time");
1899
    csv_print( "%s", "Team Elapsed Time Number");
2300
    csv_print( "%s", "Team Elapsed Time Number");
1900
//            csv_print( "%s", team_buf.leg[j].l_place );
-
 
-
 
2301
 
1901
    csv_print( "%s", "Team Leg End Place");
2302
    csv_print( "%s", "Team Leg End Place");
1902
//            csv_print( "%s", team_buf.leg[j].lc_place );
2303
    csv_print( "%s", "Team Event Place");
1903
    csv_print( "%s", "Team Leg Class Place");
2304
    csv_print( "%s", "Team Leg Class Place");
1904
//            csv_print( "%s", team_buf.leg[j].manual );
2305
    csv_print( "%s", "Team Event Class Place");
-
 
2306
 
1905
            
2307
    csv_print( "%s", "NE Team Leg End Place");
-
 
2308
    csv_print( "%s", "NE Team Event Place");
-
 
2309
    csv_print( "%s", "NE Team Leg Class Place");
-
 
2310
    csv_print( "%s", "NE Team Event Class Place");
-
 
2311
 
1906
    csv_print( "%s", "Total Team Age");
2312
    csv_print( "%s", "Total Team Age");
1907
    csv_print( "%s", "Flag:valid Team");
2313
    csv_print( "%s", "Flag:valid Team");
1908
    csv_print( "%s", "Flag:bad_times" );
2314
    csv_print( "%s", "Flag:bad_times" );
1909
    csv_print( "%s", "Flag:disqualified" );
2315
    csv_print( "%s", "Flag:disqualified" );
1910
    csv_print( "%s", "Flag:non_equestrian" );
2316
    csv_print( "%s", "Flag:non_equestrian" );
-
 
2317
    csv_print( "%s", "Flag:vet_check" );
-
 
2318
 
-
 
2319
    // Not available as the data is only in-memory
-
 
2320
    // csv_print( "%s", "Flag:notInFastest" );
-
 
2321
    // csv_print( "%s", "Flag:notInSort" );
-
 
2322
 
1911
    csv_print("\n");
2323
    csv_print("\n");
1912
 
2324
 
1913
 
2325
 
1914
    for( i = config.min_team; i <= config.max_team; i++ )
2326
    for( i = config.min_team; i <= config.max_team; i++ )
1915
    {
2327
    {
Line 1960... Line 2372...
1960
                csv_print( "%d", team_buf.leg[j].start );
2372
                csv_print( "%d", team_buf.leg[j].start );
1961
                csv_print( "%s", time_a(team_buf.leg[j].end ));
2373
                csv_print( "%s", time_a(team_buf.leg[j].end ));
1962
                csv_print( "%d", team_buf.leg[j].end );
2374
                csv_print( "%d", team_buf.leg[j].end );
1963
                csv_print( "%s", time_a(team_buf.leg[j].elapsed ));
2375
                csv_print( "%s", time_a(team_buf.leg[j].elapsed ));
1964
                csv_print( "%d", team_buf.leg[j].elapsed );
2376
                csv_print( "%d", team_buf.leg[j].elapsed );
-
 
2377
 
1965
                csv_print( "%d", team_buf.leg[j].l_place );
2378
                csv_print( "%d", team_buf.leg[j].l_place );
1966
                csv_print( "%d", team_buf.leg[j].le_place );
2379
                csv_print( "%d", team_buf.leg[j].le_place );
1967
                csv_print( "%d", team_buf.leg[j].lc_place );
2380
                csv_print( "%d", team_buf.leg[j].lc_place );
1968
                csv_print( "%d", team_buf.leg[j].lec_place );
2381
                csv_print( "%d", team_buf.leg[j].lec_place );
-
 
2382
 
-
 
2383
                csv_print( "%d", sort_aux[team_buf.numb].lq_place[j] );
-
 
2384
                csv_print( "%d", sort_aux[team_buf.numb].leq_place[j] );
-
 
2385
                csv_print( "%d", sort_aux[team_buf.numb].lcq_place[j] );
-
 
2386
                csv_print( "%d", sort_aux[team_buf.numb].lecq_place[j] );
-
 
2387
 
-
 
2388
 
1969
                csv_print( "%d", team_buf.leg[j].manual );
2389
                csv_print( "%d", team_buf.leg[j].manual );
1970
            }
2390
            }
1971
 
2391
 
1972
            j = 0;
2392
            j = 0;
1973
            csv_print( "%s", time_a(team_buf.leg[j].start ));
2393
            csv_print( "%s", time_a(team_buf.leg[j].start ));
1974
            csv_print( "%d", team_buf.leg[j].start );
2394
            csv_print( "%d", team_buf.leg[j].start );
1975
            csv_print( "%s", time_a(team_buf.leg[j].end ));
2395
            csv_print( "%s", time_a(team_buf.leg[j].end ));
1976
            csv_print( "%d", team_buf.leg[j].end );
2396
            csv_print( "%d", team_buf.leg[j].end );
1977
            csv_print( "%s", time_a(team_buf.leg[j].elapsed ));
2397
            csv_print( "%s", time_a(team_buf.leg[j].elapsed ));
1978
            csv_print( "%d", team_buf.leg[j].elapsed );
2398
            csv_print( "%d", team_buf.leg[j].elapsed );
-
 
2399
 
1979
//            csv_print( "%d", team_buf.leg[j].l_place );
2400
            csv_print( "%d", team_buf.leg[j].l_place );
1980
            csv_print( "%d", team_buf.leg[j].le_place );
2401
            csv_print( "%d", team_buf.leg[j].le_place );
1981
//            csv_print( "%d", team_buf.leg[j].lc_place );
2402
            csv_print( "%d", team_buf.leg[j].lc_place );
1982
            csv_print( "%d", team_buf.leg[j].lec_place );
2403
            csv_print( "%d", team_buf.leg[j].lec_place );
-
 
2404
 
1983
//            csv_print( "%d", team_buf.leg[j].manual );
2405
            csv_print( "%d", sort_aux[team_buf.numb].lq_place[j] );
1984
            
2406
            csv_print( "%d", sort_aux[team_buf.numb].leq_place[j] );
-
 
2407
            csv_print( "%d", sort_aux[team_buf.numb].lcq_place[j] );
-
 
2408
            csv_print( "%d", sort_aux[team_buf.numb].lecq_place[j] );
-
 
2409
 
1985
            csv_print( "%d", age_sum );
2410
            csv_print( "%d", age_sum );
1986
            csv_print( "%d", team_buf.flags.valid );
2411
            csv_print( "%d", team_buf.flags.valid );
1987
            csv_print( "%d", team_buf.flags.bad_times );
2412
            csv_print( "%d", team_buf.flags.bad_times );
1988
            csv_print( "%d", team_buf.flags.disqualified );
2413
            csv_print( "%d", team_buf.flags.disqualified );
1989
            csv_print( "%d", team_buf.flags.non_equestrian );
2414
            csv_print( "%d", team_buf.flags.non_equestrian );
-
 
2415
            csv_print( "%d", team_buf.flags.vet_check );
-
 
2416
            // Not available as the data is only in-memory
-
 
2417
            // csv_print( "%d", team_buf.flags.notInFastest );
-
 
2418
            // csv_print( "%d", team_buf.flags.notInSort );
1990
 
2419
 
1991
//How about class placings
2420
//How about class placings
1992
 
2421
 
1993
 
2422
 
1994
            csv_print( "\n" );
2423
            csv_print( "\n" );
Line 2028... Line 2457...
2028
        pri_eleg_body ( leg );
2457
        pri_eleg_body ( leg );
2029
        
2458
        
2030
        report_html = html;
2459
        report_html = html;
2031
        
2460
        
2032
        pri_leg_body ( leg );
2461
        pri_leg_body ( leg );
-
 
2462
        pri_eleg_body ( leg );
-
 
2463
 
-
 
2464
        //report_html = printed;
-
 
2465
        //
-
 
2466
        //pri_leg_body ( leg );
2033
        pri_eleg_body ( leg );        
2467
        //pri_eleg_body ( leg );        
2034
        
2468
        
2035
        report_html = text;
2469
        report_html = text;
2036
    }
2470
    }
2037
 
2471
 
2038
    pri_final();
2472
    pri_final();
-
 
2473
    pri_final_teamOrder();
2039
    pri_final_html();
2474
    pri_final_html();
2040
    pri_csv_data();
2475
    pri_csv_data();
-
 
2476
    pri_summary_html();
2041
    pri_summary();
2477
    pri_summary();
2042
    pri_awards_html();
2478
    pri_awards_html();
2043
    pri_awards();
2479
    pri_awards();
2044
    pri_master_index();
2480
    pri_master_index();
2045
 
2481
 
-
 
2482
    report_html = html;
-
 
2483
    pri_interim();
-
 
2484
    report_html = text;
2046
    pri_interim();
2485
    pri_interim();
2047
 
2486
 
2048
    report_all = FALSE;
2487
    report_all = FALSE;
2049
}
2488
}
2050
 
2489
 
Line 2080... Line 2519...
2080
    **  Now printout the column headings
2519
    **  Now printout the column headings
2081
    **  This is a two line display
2520
    **  This is a two line display
2082
    **
2521
    **
2083
    **  Line-1  Leg names
2522
    **  Line-1  Leg names
2084
    */
2523
    */
-
 
2524
 
-
 
2525
    if (config.num_legs == 1 ) {
-
 
2526
        print( "%-*s", 4, "" );
-
 
2527
        print( "  %-*s", 18, config.leg_name[0] );
-
 
2528
        print( " %-*s", MAX_TM_NAME + 1, "" );
-
 
2529
        print( "%-4s\n", ( teamclass < 0 ) ? "Cat" : "Fin" );
-
 
2530
 
-
 
2531
    } else {
2085
    print( "%-*s %-*s %-*s", 4, "", 4, "", 3, "" );
2532
        print( "%-*s %-*s %-*s", 4, "", 4, "", 3, "" );
2086
    for( j = 1; j <= config.num_legs; j++ )
2533
        for( j = 1; j <= config.num_legs; j++ )
2087
    {
2534
        {
2088
        print_bold( TRUE );
2535
            print_bold( TRUE );
2089
        print( "  %-*s", 18, config.leg_name[j - 1] );
2536
            print( "  %-*s", 18, config.leg_name[j - 1] );
2090
        print_bold( FALSE );
2537
            print_bold( FALSE );
-
 
2538
        }
-
 
2539
        print( "  %-8s %-4s\n", "Total", ( teamclass < 0 ) ? "Cat" : "Fin" );
2091
    }
2540
    }
2092
    print( "  %-8s %-4s\n", "Total", ( teamclass < 0 ) ? "Cat" : "Fin" );
-
 
-
 
2541
 
-
 
2542
 
2093
 
2543
 
2094
 
2544
 
2095
    /*
2545
    /*
2096
    **  Line-2  Details
2546
    **  Line-2  Details
2097
    */
2547
    */
2098
    print_underline( TRUE );
2548
    print_underline( TRUE );
2099
    print( "%-*s %*s %-*s", 4, final ? "Plce" : "Team",
2549
    print( "%-*s %*s %-*s", 4, final ? "Plce" : "Team",
2100
                            4, final ? "Team" : "Plce",
2550
                            4, final ? "Team" : "Plce",
2101
                            3, "Cat" );
2551
                            3, "Cat" );
2102
 
2552
 
2103
    for( j = 1; j <= config.num_legs; j++ )
-
 
2104
        print( "  %-8s %-4s %-4s", "Time", " LP", " EP" );
-
 
2105
 
2553
 
-
 
2554
    if (config.num_legs == 1 ) {
-
 
2555
        print( "  %-8s", "Time" );
-
 
2556
        print( " %-*s", MAX_TM_NAME + 1, "Team Name" );
-
 
2557
        print( "%4s\n", "Plce" );
-
 
2558
 
-
 
2559
    } else {
-
 
2560
        for( j = 1; j <= config.num_legs; j++ )
-
 
2561
            print( "  %-8s %4s %4s", "Time", "LP", "EP" );
2106
    print( "  %-8s %-4s\n", "Time", "Plce" );
2562
        print( "  %-8s %4s\n", "Time", "Plce" );
-
 
2563
    }
-
 
2564
 
-
 
2565
 
2107
    print_underline( FALSE );
2566
    print_underline( FALSE );
2108
}
2567
}
2109
 
2568
 
2110
/*========================================================================
2569
/*========================================================================
2111
 *
2570
 *
Line 2154... Line 2613...
2154
    {
2613
    {
2155
        print_bold( TRUE );
2614
        print_bold( TRUE );
2156
        print( "%-13s  ", config.leg_name[i - 1] );
2615
        print( "%-13s  ", config.leg_name[i - 1] );
2157
        print_bold( FALSE );
2616
        print_bold( FALSE );
2158
    }
2617
    }
-
 
2618
    if ( config.num_legs != 1 ) {
-
 
2619
        print_bold( TRUE );
2159
    print( "%-13s  \n", final ? "Total" : "" );
2620
        print( "%-13s  ", final ? "Total" : "" );
-
 
2621
        print_bold( FALSE );
-
 
2622
    }
-
 
2623
    print( "\n" );
2160
 
2624
 
2161
    /*
2625
    /*
2162
    **  Print the fastest teams for each leg and overall
2626
    **  Print the fastest teams for each leg and overall
2163
    **  Add cross references to the team names for the fastest teams
2627
    **  Add cross references to the team names for the fastest teams
2164
    */
2628
    */
Line 2172... Line 2636...
2172
                j = 0;                           /* Leg-0 last */
2636
                j = 0;                           /* Leg-0 last */
2173
            else
2637
            else
2174
                break;
2638
                break;
2175
        }
2639
        }
2176
 
2640
 
2177
        if ( report_html == html ) print( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "name" ,"html")), stats.fast.team[j][c] );
2641
        if ( report_html == html ) setHref( "<A HREF=\"%s#Team_%04d\">", url_encode(p_filename(filebase, "name" ,"html")), stats.fast.team[j][c] );
2178
        print( "%4d",  stats.fast.team[j][c] );
2642
        print( "%4d",  stats.fast.team[j][c] );
2179
        if ( report_html == html ) print( "</A>" );
-
 
2180
        print( " %s  ", time_a( stats.fast.time[j][c] ) );
2643
        print( " %s  ", time_a( stats.fast.time[j][c] ) );
-
 
2644
        if ( config.num_legs == 1 ) break;
2181
    }
2645
    }
2182
    print( "\n" );
2646
    print( "\n" );
2183
 
2647
 
2184
    /*
2648
    /*
2185
    **  Print the average time for each leg
2649
    **  Print the average time for each leg
Line 2194... Line 2658...
2194
                j = 0;                           /* Leg-0 last */
2658
                j = 0;                           /* Leg-0 last */
2195
            else
2659
            else
2196
                break;
2660
                break;
2197
        }
2661
        }
2198
        print( "     %s  ", time_a( stats.average[j][c] ) );
2662
        print( "     %s  ", time_a( stats.average[j][c] ) );
-
 
2663
        if ( config.num_legs == 1 ) break;
2199
    }
2664
    }
2200
}
2665
}
2201
 
2666
 
2202
/*========================================================================
2667
/*========================================================================
2203
 *
2668
 *
Line 2233... Line 2698...
2233
    print( "\n" );
2698
    print( "\n" );
2234
 
2699
 
2235
 
2700
 
2236
    for( i = 1, count = 0; i <= config.num_class; i++ )
2701
    for( i = 1, count = 0; i <= config.num_class; i++ )
2237
    {
2702
    {
2238
#if 0
-
 
2239
        /*
-
 
2240
        **  Skip any non-equestrian class in the legend
2703
        if (!config.team_class[i - 1].abr[0])
2241
        **  Don't want to tell the general user whats goes on, unless we actually
-
 
2242
        **  creating the non-equestrian report.
-
 
2243
        */
-
 
2244
        if ( class != config.nonequestrian_class  && i == config.nonequestrian_class )
-
 
2245
            continue;
2704
            continue;
2246
#endif
2705
 
2247
        if ( report_html == html ) print( "<A HREF=\"%s\">",url_encode(p_filename(filebase, config.team_class[i - 1].abr ,"html")) );
2706
        if ( report_html == html ) setHref( "<A HREF=\"%s\">",url_encode(p_filename(filebase, config.team_class[i - 1].abr ,"html")) );
2248
        print( "%-*s", 3, config.team_class[i - 1].abr );
2707
        print( "%-*s", 3, config.team_class[i - 1].abr );
2249
        if ( report_html == html ) print( "</A>" );
-
 
2250
        print( " : %-*s  ", LEN_CLASS_NAME, config.team_class[i - 1].full_name );
2708
        print( " : %-*s  ", LEN_CLASS_NAME, config.team_class[i - 1].full_name );
2251
 
2709
 
2252
        if( !( ++count % 5 ) )
2710
        if( !( ++count % 5 ) )
2253
            print( "\n" );
2711
            print( "\n" );
2254
    }
2712
    }
Line 2256... Line 2714...
2256
    /*
2714
    /*
2257
    **  Add link to the finish order report
2715
    **  Add link to the finish order report
2258
    */
2716
    */
2259
    if ( report_html == html )
2717
    if ( report_html == html )
2260
    {
2718
    {
2261
        print( "<A HREF=\"%s\">", url_encode(p_filename(filebase, "finish" ,"html")) );
2719
        setHref( "<A HREF=\"%s\">", url_encode(p_filename(filebase, "finish" ,"html")) );
2262
        print( "%-*s", 3, "All" );
2720
        print( "%-*s", 3, "All" );
2263
        print( "</A>" );
-
 
2264
        print( " : %-*s  ", LEN_CLASS_NAME, "Finishing Order" );
2721
        print( " : %-*s  ", LEN_CLASS_NAME, "Finishing Order" );
2265
    }
2722
    }
2266
 
2723
 
2267
    /*
2724
    /*
2268
    **  Country data - if countries have been defined
2725
    **  Country data - if countries have been defined
Line 2291... Line 2748...
2291
    /*
2748
    /*
2292
     * Other comments 
2749
     * Other comments 
2293
     */
2750
     */
2294
    if ( full )
2751
    if ( full )
2295
    {
2752
    {
-
 
2753
        if ( config.num_legs != 1 )  {
-
 
2754
            print( "\n" );
-
 
2755
            if ( report_html ) print_underline(TRUE);
2296
        print( "\nPlace numbers (LP and EP)\n" );
2756
            print( "Place numbers (LP and EP)" );
-
 
2757
            if ( report_html ) print_underline(FALSE);
-
 
2758
            print( "\n" );
2297
        print( "LP - Placing based on elapsed time within the leg.                Cat Plce - Placing within the category.\n" );
2759
            print( "LP - Placing based on elapsed time within the leg.                Cat Plce - Placing within the category.\n" );
2298
        print( "EP - Placing based on accumulated times to the end of that leg.   Fin Plce - Overall placing within the event.\n" );
2760
            print( "EP - Placing based on accumulated times to the end of that leg.   Fin Plce - Overall placing within the event.\n" );
2299
        print( "U  - Placing not available.\n" );
2761
            print( "U  - Placing not available.\n" );
-
 
2762
        } else {
-
 
2763
            print( "\n" );
-
 
2764
            if ( report_html ) print_underline(TRUE);
-
 
2765
            print( "Table Legend" );
-
 
2766
            if ( report_html ) print_underline(FALSE);
-
 
2767
            print( "\n" );
-
 
2768
 
-
 
2769
            print( "Cat Plce - Placing within the category.\n");
-
 
2770
            print ("Fin Plce - Overall placing within the event.\n" );
-
 
2771
            print( "U        - Placing not available.\n" );
-
 
2772
        }
2300
    }
2773
    }
2301
 
2774
 
2302
    /*
2775
    /*
2303
     *  Insert the contents of the config.addendum file
2776
     *  Insert the contents of the config.addendum file
2304
     *  or a defualt message
2777
     *  or a defualt message
2305
     */
2778
     */
2306
    if( config.addendum[0] )
2779
    if( config.addendum[0] )
2307
    {
2780
    {
2308
        const char *name = QmConfig::getAddendemFile(config.addendum);
2781
        QString name = QmConfig::getAddendemFile(config.addendum);
2309
        if (name)
2782
        if (! name.isEmpty())
-
 
2783
        {
2310
            adfile = fopen( name, "rt" );  /* Open the file for reading */
2784
            adfile = fopen( qPrintable(name), "rt" );  /* Open the file for reading */
-
 
2785
        }
2311
    }
2786
    }
2312
 
2787
 
2313
    if( adfile )
2788
    if( adfile )
2314
    {
2789
    {
2315
        while( fgets( line, sizeof(line)-1, adfile ) )
2790
        while( fgets( line, sizeof(line)-1, adfile ) )
2316
            print( "%s", line );
2791
            print( "%s", line );
-
 
2792
        fclose (adfile);
2317
    }
2793
    }
2318
    else
2794
    else
2319
    {
2795
    {
2320
        print( "\nTiming and Results by\n" );
2796
        print( "\nTiming and Results by\n" );
2321
        print( "Embedded Solutions\n" );
2797
        print( "Embedded Solutions\n" );
2322
    }
2798
    }
2323
}
2799
}
2324
 
2800
 
2325
/*========================================================================
-
 
2326
 *
-
 
2327
 *  Return place data
-
 
2328
 *
-
 
2329
 *  Purpose:
-
 
2330
 *      This function is called to return place data
-
 
2331
 *
-
 
2332
 *      This routine is called to fill a print team_buffer - to allow for
-
 
2333
 *      multiple calls to this function ( before the data is used ) a number
-
 
2334
 *      of static team_buffers are maintained
-
 
2335
 *
-
 
2336
 *  Parameters:
-
 
2337
 *      num         place - if not bad_times
-
 
2338
 *      disq        Disqualified flag
-
 
2339
 *      time        Time data is based on
-
 
2340
 *
-
 
2341
 *  Returns:
-
 
2342
 *      This function returns a pointer to the character string for the
-
 
2343
 *      number or a pointer to a bad_times string.
-
 
2344
 *
-
 
2345
 *========================================================================*/
-
 
2346
 
-
 
2347
const char       *pi_place( int num, int disq, time_t time )
-
 
2348
{
-
 
2349
    static char store[2][5];                     /* 2 stores for 4 digit numbers */
-
 
2350
    static int  i = 0;                           /* Current index into store */
-
 
2351
    static const char *dis = "D";                      /* Disqualified */
-
 
2352
    static const char *non = "-";                      /* Invalid time */
-
 
2353
 
-
 
2354
    if( disq )                                   /* Disqualified team */
-
 
2355
        return ( dis );
-
 
2356
    if( time <= 0 )                              /* Unknown time */
-
 
2357
        return ( non );
-
 
2358
 
-
 
2359
    i++;
-
 
2360
    if( i >= 2 )
-
 
2361
        i = 0;                                   /* Select next entry */
-
 
2362
    sprintf( store[i], "%4d", num );
-
 
2363
    return ( store[i] );
-
 
2364
 
-
 
2365
}
-
 
2366
 
2801
 
2367
/*========================================================================
2802
/*========================================================================
2368
 *
2803
 *
2369
 *  Return place data
2804
 *  Return place data or NE flag
2370
 *
2805
 *
2371
 *  Purpose:
2806
 *  Purpose:
2372
 *      This function is called to Return place data
2807
 *      This function is called to Return place data
2373
 *
2808
 *
2374
 *      This routine is called to fill a print team_buffer - to allow for
2809
 *      This routine is called to fill a print team_buffer - to allow for
2375
 *      multiple calls to this function ( before the data is used ) a number
2810
 *      multiple calls to this function ( before the data is used ) a number
2376
 *      of static team_buffers are maintained
2811
 *      of static team_buffers are maintained
2377
 *
2812
 *
2378
 *  Parameters:
2813
 *  Parameters:
-
 
2814
 *      leg         Leg number being processed or
-
 
2815
 *                  -1: Unplaced on any bad flag
2379
 *      num         place - if not bad_times
2816
 *      num         place - if valid time
-
 
2817
 *      epMode      true:  Event Time Mode - Show V and NE flags
-
 
2818
 *                  false: Leg Time Mode -
-
 
2819
 *      neMode      true: Display NE for NE Teams
-
 
2820
 *                  false: Display data for NE teams
2380
 *      disq        Disqualified flag
2821
 *      flags       Team flags
2381
 *
2822
 *
2382
 *  Returns:
2823
 *  Returns:
2383
 *      This function returns a pointer to the character string for the
2824
 *      This function returns a pointer to the character string for the
2384
 *      number or a pointer to a bad_times string.
2825
 *      number or a pointer to a status string.
2385
 *
2826
 *
2386
 *========================================================================*/
2827
 *========================================================================*/
2387
 
-
 
2388
const char *pr_place( int num, int disq )
2828
const char *px_place( int leg, int num, bool epMode, bool neMode, team_flags flags )
2389
{
2829
{
2390
    static char store[2][5];                     /* 2 stores for 4 digit numbers */
2830
    static char store[2][5];                     /* 2 stores for 4 digit numbers */
2391
    static int  i = 0;                           /* Current index into store */
2831
    static int  i = 0;                           /* Current index into store */
2392
    static const char *dis = "U";
2832
    static const char *dis = "U";
-
 
2833
    static const char *alt = "NE";
-
 
2834
    static const char *vet = "U";
2393
 
2835
 
2394
    if( disq )
2836
    if (flags.bad_times || flags.disqualified || !flags.valid)
2395
        return ( dis );
2837
        return dis;
2396
 
2838
 
2397
    i++;
-
 
2398
    if( i >= 2 )
-
 
2399
        i = 0;                                   /* Select next entry */
-
 
2400
    sprintf( store[i], "%4d", num );
2839
    if (leg == -1 && flags.vet_check )
2401
    return ( store[i] );
2840
        return vet;
2402
 
2841
 
-
 
2842
    if (neMode && flags.non_equestrian && (leg >= config.equestrian_leg || leg == 0))
2403
}
2843
        return alt;
2404
 
2844
 
2405
/*========================================================================
-
 
2406
 *
-
 
2407
 *  Return place data
-
 
2408
 *
-
 
2409
 *  Purpose:
-
 
2410
 *      This function is called to Return place data
-
 
2411
 *
-
 
2412
 *      This routine is called to fill a print team_buffer - to allow for
-
 
2413
 *      multiple calls to this function ( before the data is used ) a number
-
 
2414
 *      of static team_buffers are maintained
-
 
2415
 *
-
 
2416
 *  Parameters:
-
 
2417
 *      num         place - if not bad_times
-
 
2418
 *      disq        Disqualified flag
-
 
2419
 *      ne          Non Equestrian Flag
2845
    if (epMode && flags.vet_check && leg >= config.equestrian_leg)
2420
 *
-
 
2421
 *  Returns:
2846
        return vet;
2422
 *      This function returns a pointer to the character string for the
-
 
2423
 *      number or a pointer to a bad_times string.
-
 
2424
 *
-
 
2425
 *========================================================================*/
-
 
2426
 
2847
 
2427
const char *pr_place_ne( int num, int disq, int ne )
-
 
2428
{
-
 
2429
    static char store[2][5];                     /* 2 stores for 4 digit numbers */
-
 
2430
    static int  i = 0;                           /* Current index into store */
2848
    if ( flags.vet_check && (leg == config.equestrian_leg || leg == 0))
2431
    static const char *dis = "U";
2849
        return vet;
2432
 
2850
 
2433
    if( disq && ! ne )
2851
    if (num <= 0)
2434
         return ( dis );
2852
        return dis;
2435
 
2853
 
-
 
2854
    i++;
2436
    if( ++i >= 2 )
2855
    if( i >= 2 )
2437
        i = 0;                                   /* Select next entry */
2856
        i = 0;                                   /* Select next entry */
2438
    sprintf( store[i], "%4d", num );
2857
    sprintf( store[i], "%4d", num );
2439
    return ( store[i] );
2858
    return ( store[i] );
2440
 
2859
 
2441
}
2860
}
Line 2453... Line 2872...
2453
 *      and the report process can be aborted
2872
 *      and the report process can be aborted
2454
 *
2873
 *
2455
 *  Parameters:
2874
 *  Parameters:
2456
 *      leg             Leg to test
2875
 *      leg             Leg to test
2457
 *      mode            Either end or elapsed times to be tested
2876
 *      mode            Either end or elapsed times to be tested
-
 
2877
 *                          C_END     - Printing in Leg Finishing Time
-
 
2878
 *                          C_DISQUAL - Interim results
-
 
2879
 *                          C_ELAPSED - Elapsed times
2458
 *
2880
 *
2459
 *  Returns:
-
 
2460
 *      Returns FALSE if the report operation is to be aborted
-
 
2461
 *
2881
 *
2462
 *========================================================================*/
2882
 *========================================================================*/
2463
 
2883
 
2464
bool ck_data( int leg, int mode )
2884
void ck_data( int leg, int mode )
2465
{
2885
{
2466
    ty_s_data  *ptr;
2886
    ty_s_data  *ptr;
2467
    unsigned    i;
2887
    unsigned    i;
2468
    int         bad = 0;
2888
    int         bad = 0;
2469
    int         k;
2889
    int         k;
Line 2484... Line 2904...
2484
            t = ptr->lege;
2904
            t = ptr->lege;
2485
        else
2905
        else
2486
            t = ptr->leg;
2906
            t = ptr->leg;
2487
 
2907
 
2488
 
2908
 
2489
        if ( leg >= 0 )
2909
        // If the team is duff, then don;t include in Event or Leg Calcs
-
 
2910
        if( !ptr->flags.valid || ptr->flags.bad_times || ptr->flags.disqualified)
2490
        {
2911
        {
2491
            ptr->flags.bad_times = (ptr->flags.disqualified && ! ptr->flags.non_equestrian );
2912
            ptr->flags.notInLP = TRUE;
2492
        }
2913
        }
2493
        else
2914
        else
2494
        {
2915
        {
2495
            ptr->flags.bad_times = ptr->flags.disqualified /*|| ptr->flags.non_equestrian */;
2916
            // If any of the leg times are duff, then don't include the leg Event Calcs
2496
        }
-
 
2497
 
2917
 
2498
        if( ! ptr->flags.bad_times )
-
 
2499
        {
-
 
2500
            if( leg <= 0 )
2918
            if( leg <= 0 )
2501
            {
2919
            {
2502
                for( k = 0; k <= config.num_legs; k++ )
2920
                for( k = 0; k <= config.num_legs; k++ )
2503
                {
2921
                {
2504
                    if ( !(config.equestrian_leg && ptr->flags.non_equestrian && config.equestrian_leg == k  ))
2922
                    if ( !(config.equestrian_leg && ptr->flags.non_equestrian && config.equestrian_leg == k  ))
Line 2510... Line 2928...
2510
                bad_leg = t[leg] <= 0;
2928
                bad_leg = t[leg] <= 0;
2511
            }
2929
            }
2512
 
2930
 
2513
            if( bad_leg )
2931
            if( bad_leg )
2514
            {
2932
            {
2515
                ptr->flags.bad_times = TRUE;
-
 
2516
                
-
 
2517
                if ( ! report_all )
2933
                if ( ! report_all )
2518
                {
2934
                {
2519
                    printf( "Team with incorrect time information: %d", ptr->team  );
2935
                    qDebug( "Team with incorrect time information: %d", ptr->team  );
2520
                    bad++;
2936
                    bad++;
2521
                }
2937
                }
2522
            }
2938
            }
2523
        }
2939
        }
2524
    }
2940
    }
2525
 
2941
 
2526
    if( bad )
2942
    if( bad )
2527
    {
2943
    {
2528
        printf( "%d teams with incorrect times. These have been flagged as unplaced", bad );
2944
        qDebug( "%d teams with incorrect times. These have been flagged as unplaced", bad );
2529
    }
2945
    }
2530
    return ( FALSE );
-
 
2531
}
2946
}
2532
 
2947
 
2533
/*========================================================================
2948
/*========================================================================
2534
 *
2949
 *
2535
 *  Update placing information
2950
 *  Update placing information
Line 2554... Line 2969...
2554
 *
2969
 *
2555
 *========================================================================*/
2970
 *========================================================================*/
2556
 
2971
 
2557
void srt_place(void)
2972
void srt_place(void)
2558
{
2973
{
2559
    if( ck_data( -1, C_ELAPSED ) )
2974
    ck_data( -1, C_ELAPSED );
2560
        return;
-
 
2561
    do_big_sort();
2975
    do_big_sort();
2562
 
2976
 
2563
    /*
2977
    /*
2564
     * Generate the stats
2978
     * Generate the stats
2565
     */
2979
     */
Line 2599... Line 3013...
2599
    for( i = config.min_team; i <= config.max_team; i++ )
3013
    for( i = config.min_team; i <= config.max_team; i++ )
2600
    {
3014
    {
2601
        if( valid_field( i ) && g_record( i, &team_buf ) )
3015
        if( valid_field( i ) && g_record( i, &team_buf ) )
2602
        {
3016
        {
2603
            bool valid = true;
3017
            bool valid = true;
-
 
3018
            bool valid_ne = true;
2604
 
3019
 
2605
            if ( team_buf.flags.disqualified )
3020
            if ( team_buf.flags.disqualified )
2606
            {
3021
            {
2607
                ptr->teamclass[team_buf.teamclass].disqualified++;
3022
                ptr->teamclass[team_buf.teamclass].disqualified++;
2608
                ptr->total.disqualified++;
3023
                ptr->total.disqualified++;
2609
                valid = false;
3024
                valid = false;
2610
 
-
 
-
 
3025
                valid_ne = false;
2611
            }
3026
            }
2612
 
3027
 
2613
            if ( team_buf.flags.vet_check )
3028
            if ( team_buf.flags.vet_check )
2614
            {
3029
            {
2615
                ptr->teamclass[team_buf.teamclass].vet_check++;
3030
                ptr->teamclass[team_buf.teamclass].vet_check++;
2616
                ptr->total.vet_check++;
3031
                ptr->total.vet_check++;
2617
                valid = false;
3032
                valid = false;
-
 
3033
                valid_ne = false;
2618
            }
3034
            }
2619
 
3035
 
2620
            if ( config.nonequestrian_class && team_buf.flags.non_equestrian )
3036
            if ( config.nonequestrian_class && team_buf.flags.non_equestrian )
2621
            {
3037
            {
2622
                ptr->teamclass[team_buf.teamclass].non_equestrian++;
3038
                ptr->teamclass[team_buf.teamclass].non_equestrian++;
2623
                ptr->total.non_equestrian++;
3039
                ptr->total.non_equestrian++;
2624
                valid = false;
3040
                valid = false;
2625
            }
3041
            }
-
 
3042
            else
-
 
3043
            {
-
 
3044
                valid_ne = false;
-
 
3045
            }
2626
 
3046
 
2627
            ptr->total.total++;
3047
            ptr->total.total++;
2628
            ptr->teamclass[team_buf.teamclass].total++;
3048
            ptr->teamclass[team_buf.teamclass].total++;
2629
            if ( valid )
3049
            if ( valid )
2630
            {
3050
            {
2631
                ptr->total.valid++;
3051
                ptr->total.valid++;
2632
                ptr->teamclass[team_buf.teamclass].valid++;
3052
                ptr->teamclass[team_buf.teamclass].valid++;
-
 
3053
 
-
 
3054
                if ( ! team_buf.flags.bad_times )
-
 
3055
                {
-
 
3056
                    ptr->total.valid_ev++;
-
 
3057
                    ptr->teamclass[team_buf.teamclass].valid_ev++;
-
 
3058
                }
-
 
3059
            }
-
 
3060
 
-
 
3061
            if ( valid_ne )
-
 
3062
            {
-
 
3063
                if ( ! team_buf.flags.bad_times )
-
 
3064
                {
-
 
3065
                    ptr->total.valid_ne++;
-
 
3066
                    ptr->teamclass[team_buf.teamclass].valid_ne++;
-
 
3067
                }
2633
            }
3068
            }
2634
        }
3069
        }
2635
    }
3070
    }
2636
 
3071
 
2637
    /*
3072
    /*
Line 2645... Line 3080...
2645
    }
3080
    }
2646
}
3081
}
2647
 
3082
 
2648
/*========================================================================
3083
/*========================================================================
2649
 *
3084
 *
-
 
3085
 *  Print summary results
-
 
3086
 *
-
 
3087
 *  Purpose:
-
 
3088
 *      This function is called to Print summary results
-
 
3089
 *      Keep the page to 80 cols, so that it can be pronted on A4
-
 
3090
 *
-
 
3091
 *  Parameters:
-
 
3092
 *      None
-
 
3093
 *
-
 
3094
 *  Returns:
-
 
3095
 *      Nothing
-
 
3096
 *
-
 
3097
 *========================================================================*/
-
 
3098
void pri_summary_html(void)
-
 
3099
{
-
 
3100
    report_type saved = report_html;
-
 
3101
    /*
-
 
3102
    **  Generate ALL results with HTML tags
-
 
3103
    */
-
 
3104
    report_html = html;
-
 
3105
    pri_summary();
-
 
3106
    report_html = printed;
-
 
3107
    pri_summary();
-
 
3108
    report_html = saved;
-
 
3109
}
-
 
3110
 
-
 
3111
/*========================================================================
-
 
3112
 *
2650
 *  Print summary information
3113
 *  Print summary information
2651
 *
3114
 *
2652
 *  Purpose:
3115
 *  Purpose:
2653
 *      This function is called to print summary information
3116
 *      This function is called to print summary information
2654
 *
3117
 *
Line 2664... Line 3127...
2664
{
3127
{
2665
 
3128
 
2666
    t_class_summary data;
3129
    t_class_summary data;
2667
    int         i;
3130
    int         i;
2668
 
3131
 
2669
    if( !open_printer( "", "summary", 132, text, "Summary Information" ) )
3132
    if( !open_printer( "", "summary", 80, report_html, "Summary Information" ) )
2670
        return;
3133
        return;
2671
    
3134
    
2672
    calc_class_summary( & data );
3135
    calc_class_summary( & data );
2673
 
3136
 
2674
 
3137
 
2675
    /*
3138
    /*
2676
    **  Display summary stats
3139
    **  Display summary stats
2677
    */
3140
    */
2678
 
3141
 
2679
    print( "%*s : %-7s %-7s%-7s\n", LEN_CLASS_NAME,
3142
    print( "%*s : %-7s %-7s %-7s %-7s %-7s %-7s %-7s\n",
2680
                                      "Category",
3143
                                      LEN_CLASS_NAME, "Category",
2681
                                      "Total",
3144
                                      "Total",
-
 
3145
                                      "Valid",
2682
                                      "Disq",
3146
                                      "Disq",
2683
                                      "NonEq" );
3147
                                      "NonEq",
-
 
3148
                                      "VetChk",
-
 
3149
                                      "CompEv",
-
 
3150
                                      "CompNe"
-
 
3151
                                       );
2684
 
3152
 
2685
    for( i = 0; i < config.num_class; i++ )
3153
    for( i = 0; i < config.num_class; i++ )
2686
    {
3154
    {
-
 
3155
        if (!config.team_class[i].abr[0])
-
 
3156
            continue;
2687
        /*
3157
        /*
2688
        **  The non-equestrian leg does not have any data
3158
        **  The non-equestrian leg does not have any data
2689
        **  Supress the display
3159
        **  Suppress the display
2690
        */
3160
        */
2691
        if ( config.nonequestrian_class == i+1  )
3161
        if ( config.nonequestrian_class == i+1  )
2692
            continue;
3162
            continue;
2693
 
3163
 
2694
        print( "%*s : %-7d %-7d %-7d\n", LEN_CLASS_NAME,
3164
        if ( report_html == html ) setHref( "<A HREF=\"%s\">",url_encode(p_filename(filebase, config.team_class[i].abr ,"html")) );
2695
                                          config.team_class[i].full_name,
3165
        print( "%*s ", LEN_CLASS_NAME, config.team_class[i].full_name );
-
 
3166
 
-
 
3167
        print( ": %-7d %-7d %-7d %-7d %-7d %-7d %-7d\n",
2696
                                          data.teamclass[i+1].total,
3168
                                          data.teamclass[i+1].total,
-
 
3169
                                          data.teamclass[i+1].valid,
2697
                                          data.teamclass[i+1].disqualified,
3170
                                          data.teamclass[i+1].disqualified,
2698
                                          data.teamclass[i+1].non_equestrian );
3171
                                          data.teamclass[i+1].non_equestrian,
-
 
3172
                                          data.teamclass[i+1].vet_check,
-
 
3173
                                          data.teamclass[i+1].valid_ev,
-
 
3174
                                          data.teamclass[i+1].valid_ne
-
 
3175
                                          );
2699
    }
3176
    }
2700
 
3177
 
2701
    print( "\n" );
3178
    print( "\n" );
2702
    print( "%*s : %-7d %-7d %-7d\n", LEN_CLASS_NAME,
3179
    print( "%*s : %-7d %-7d %-7d%-7d %-7d %-7d %-7d\n",
2703
                                      "Totals",
3180
                                      LEN_CLASS_NAME, "Totals",
2704
                                      data.total.total,
3181
                                      data.total.total,
-
 
3182
                                      data.total.valid,
2705
                                      data.total.disqualified,
3183
                                      data.total.disqualified,
2706
                                      data.total.non_equestrian );
3184
                                      data.total.non_equestrian,
-
 
3185
                                      data.total.vet_check,
-
 
3186
                                      data.total.valid_ev,
-
 
3187
                                      data.total.valid_ne
-
 
3188
                                      );
2707
 
3189
 
2708
    close_printer();
3190
    close_printer();
2709
}
3191
}
2710
 
3192
 
2711
 
3193
 
Line 2726... Line 3208...
2726
 *
3208
 *
2727
 *========================================================================*/
3209
 *========================================================================*/
2728
 
3210
 
2729
void do_big_sort(void)
3211
void do_big_sort(void)
2730
{
3212
{
2731
    int         i, k;                            /* Looooopy things */
3213
    int         i, k, q;                             /* Looooopy things */
2732
    unsigned    j;
3214
    unsigned    j;
2733
    ty_s_data  *ptr;                             /* Pointer to sort data */
3215
    ty_s_data  *ptr;                                 /* Pointer to sort data */
2734
    int         teamclass;                           /* Current class */
3216
    int         teamclass;                           /* Current class */
-
 
3217
    int         teamclassq;                          /* Current class */
2735
    team_type   team_buf;
3218
    team_type   team_buf;
2736
 
3219
 
2737
    for( i = 0; i <= config.num_legs; i++ )
3220
    for( i = 0; i <= config.num_legs; i++ )
2738
    {
3221
    {
-
 
3222
        bool sortWithEq =  (i == 0);
-
 
3223
 
2739
        /*
3224
        /*
2740
        **  Sort on leg elapsed time
3225
        **  Sort on leg elapsed time
2741
        **  Then save the teams elapsed place in each leg
3226
        **  Then save the teams elapsed place in each leg
2742
        */
3227
        */
2743
        sort_team_data( i, S_L );
3228
        sort_team_data( i, S_L, sortWithEq );
2744
        for( j = 1, k = 1, ptr = sort_data; j <= sort_num; ptr++, j++ )
3229
        for( j = 1, k = 1, q = 1, ptr = sort_data; j <= sort_num; ptr++, j++ )
2745
        {
3230
        {
2746
            if ( ptr->teamclass == config.nonequestrian_class )
-
 
2747
                continue;
-
 
2748
            
-
 
2749
            sort_aux[ptr->team].l_place[i] = k++;
-
 
2750
            sort_aux[ptr->team].team = ptr->team;
3231
            sort_aux[ptr->team].team = ptr->team;
-
 
3232
 
-
 
3233
            if (i == config.equestrian_leg || i == 0) {
-
 
3234
                if (ptr->flags.bad_times || ptr->flags.disqualified || ptr->flags.vet_check) {
-
 
3235
                    if (ptr->isNeData) {
-
 
3236
                        sort_aux[ptr->team].lq_place[i] = -1;
-
 
3237
                    } else {
-
 
3238
                        sort_aux[ptr->team].l_place[i] = -1;
-
 
3239
                    }
-
 
3240
                    continue;
-
 
3241
                }
-
 
3242
            }
-
 
3243
 
-
 
3244
            // Flag as unplaced NE teams on the EQ leg
-
 
3245
            // DO NOT Flag as unplaced in overall (leg:0) NE teams as this is used in the full report
-
 
3246
            if ( (i == config.equestrian_leg /*|| i == 0*/ ) && ptr->flags.non_equestrian ) {
-
 
3247
                if (ptr->isNeData) {
-
 
3248
                    sort_aux[ptr->team].lq_place[i] = -1;
-
 
3249
                } else {
-
 
3250
                    sort_aux[ptr->team].l_place[i] = -1;
-
 
3251
                }
-
 
3252
                continue;
-
 
3253
            }
-
 
3254
 
-
 
3255
            if (ptr->isNeData) {
-
 
3256
                sort_aux[ptr->team].lq_place[i] = q++;
-
 
3257
            } else {
-
 
3258
                sort_aux[ptr->team].l_place[i] = k++;
-
 
3259
            }
2751
        }
3260
        }
2752
 
3261
 
2753
        /*
3262
        /*
2754
        **  Sort on leg end time
3263
        **  Sort on leg end time
2755
        **  Then save the teams place at the end of each leg
3264
        **  Then save the teams place at the end of each leg
2756
        */
3265
        */
2757
        sort_team_data( i, S_LE );
3266
        sort_team_data( i, S_LE, sortWithEq);
2758
        for( j = 1, k = 1, ptr = sort_data; j <= sort_num; ptr++, j++ )
3267
        for( j = 1, k = 1, q = 1, ptr = sort_data; j <= sort_num; ptr++, j++ )
2759
        {
3268
        {
2760
            if ( ptr->teamclass == config.nonequestrian_class )
3269
            if (i == 0 || i == config.equestrian_leg || sort_afterEquestrianLeg ) {
-
 
3270
                if (ptr->flags.bad_times || ptr->flags.disqualified || ptr->flags.vet_check) {
-
 
3271
                    if (ptr->isNeData) {
-
 
3272
                        sort_aux[ptr->team].leq_place[i] = -1;
-
 
3273
                    } else {
-
 
3274
                        sort_aux[ptr->team].le_place[i] = -1;
-
 
3275
                    }
-
 
3276
                    continue;
-
 
3277
                }
-
 
3278
            }
-
 
3279
 
-
 
3280
            // Flag as unplaced NE teams on the EQ leg
-
 
3281
            // Flag as unplaced NE teams after the EQ leg
-
 
3282
            // Flag as unplaced in overall (leg:0) NE teams
-
 
3283
            if ( (i == config.equestrian_leg || sort_afterEquestrianLeg || i == 0 ) && ptr->flags.non_equestrian ) {
-
 
3284
                if (ptr->isNeData) {
-
 
3285
                    sort_aux[ptr->team].leq_place[i] = -1;
-
 
3286
                } else {
-
 
3287
                    sort_aux[ptr->team].le_place[i] = -1;
-
 
3288
                }
2761
                continue;
3289
                continue;
2762
            
3290
            }
-
 
3291
 
-
 
3292
            if (ptr->isNeData) {
-
 
3293
                sort_aux[ptr->team].leq_place[i] = q++;
-
 
3294
            } else {
2763
            sort_aux[ptr->team].le_place[i] = k++;
3295
                sort_aux[ptr->team].le_place[i] = k++;
-
 
3296
            }
2764
        }
3297
        }
2765
 
3298
 
2766
        /*
3299
        /*
2767
        **  Sort on elapsed time per class
3300
        **  Sort on elapsed time per class
2768
        **  The save the teams elapsed place in each leg per class
3301
        **  Then save the teams elapsed place in each leg per class
2769
        */
3302
        */
2770
        sort_team_data( i, S_LC );
3303
        sort_team_data( i, S_LC, sortWithEq );
2771
        teamclass = -1;
3304
        teamclass = -1;
-
 
3305
        teamclassq = -1;
-
 
3306
        int ll = -1;
2772
        for( k = 1, j = 1, ptr = sort_data; j <= sort_num; j++, ptr++ )
3307
        for( k = 1, j = 1, q = 1, ptr = sort_data; j <= sort_num; j++, ptr++ )
2773
        {
3308
        {
-
 
3309
            bool isNe = false;
2774
            if( teamclass != ptr->teamclass )
3310
            if ( sortWithEq && ptr->isNeData  ) {
-
 
3311
                if ( !ptr->isNeData)
-
 
3312
                    isNe = true;
-
 
3313
            }
-
 
3314
            else {
-
 
3315
                if (ptr->isNeData)
-
 
3316
                    isNe = true;
2775
            {
3317
            }
-
 
3318
 
-
 
3319
            // Flag as unplaced NE teams on the EQ leg
-
 
3320
            if (i == 0 || i == config.equestrian_leg) {
-
 
3321
                if (ptr->flags.bad_times || ptr->flags.disqualified || ptr->flags.vet_check) {
-
 
3322
                    if (isNe) {
-
 
3323
                        sort_aux[ptr->team].lcq_place[i] = -1;
-
 
3324
                    } else {
-
 
3325
                        sort_aux[ptr->team].lc_place[i] = -1;
2776
                k = 1;
3326
                    }
-
 
3327
                    continue;
-
 
3328
                }
-
 
3329
            }
-
 
3330
 
-
 
3331
            if ( i == config.equestrian_leg && ptr->flags.non_equestrian ) {
2777
                teamclass = ptr->teamclass;
3332
                if (ptr->isNeData) {
-
 
3333
                    sort_aux[ptr->team].lcq_place[i] = -1;
-
 
3334
                } else {
-
 
3335
                    sort_aux[ptr->team].lc_place[i] = -1;
-
 
3336
                }
-
 
3337
                continue;
2778
            }
3338
            }
-
 
3339
 
-
 
3340
            if (ptr->isNeData) {
-
 
3341
                if( teamclassq != ptr->teamclass )
-
 
3342
                {
-
 
3343
                    q = 1;
-
 
3344
                    teamclassq = ptr->teamclass;
-
 
3345
                }
-
 
3346
//qDebug() << "Team:" << ptr->team << ",Class:" << ptr->teamclass << "," << q;
2779
            sort_aux[ptr->team].lc_place[i] = k++;
3347
                sort_aux[ptr->team].lcq_place[i] = q++;
-
 
3348
 
-
 
3349
            }
-
 
3350
            else {
-
 
3351
 
-
 
3352
                if( teamclass != ptr->teamclass )
-
 
3353
                {
-
 
3354
                    k = 1;
-
 
3355
                    ll = 1;
-
 
3356
                    teamclass = ptr->teamclass;
-
 
3357
                }
-
 
3358
                if (ptr->flags.non_equestrian && sortWithEq)
-
 
3359
                    sort_aux[ptr->team].lc_place[i] = ll++;
-
 
3360
                else
-
 
3361
                    sort_aux[ptr->team].lc_place[i] = k++;
-
 
3362
            }
-
 
3363
 
2780
        }
3364
        }
2781
 
3365
 
2782
        /*
3366
        /*
2783
        **  Sort on end time per class
3367
        **  Sort on end time per class
2784
        **  Then save the teams place at the end of each leg per class
3368
        **  Then save the teams place at the end of each leg per class
-
 
3369
        **  Suuport NE teams as well Equestrian Teams
2785
        */
3370
        */
2786
        sort_team_data( i, S_LEC );
3371
        sort_team_data( i, S_LEC, sortWithEq );
2787
        teamclass = -1;
3372
        teamclass = -1;
-
 
3373
        teamclassq = -1;
2788
        for( k = 1, j = 1, ptr = sort_data; j <= sort_num; j++, ptr++ )
3374
        for( k = 1, j = 1, q = 1, ptr = sort_data; j <= sort_num; j++, ptr++ )
2789
        {
3375
        {
-
 
3376
 
2790
            if( teamclass != ptr->teamclass )
3377
            // All teams with bad data
-
 
3378
            if (ptr->flags.bad_times || ptr->flags.disqualified ) {
-
 
3379
                sort_aux[ptr->team].lec_place[i] = -1;
-
 
3380
                sort_aux[ptr->team].lecq_place[i] = -1;
-
 
3381
                continue;
2791
            {
3382
            }
-
 
3383
 
-
 
3384
            // NE team - the full entry
-
 
3385
            // Flag as unplaced NE teams on the EQ leg
-
 
3386
            // Flag as unplaced NE teams after the EQ leg
-
 
3387
            // Flag as unplaced in overall (leg:0) NE teams
-
 
3388
            if (!ptr->isNeData  && ptr->flags.non_equestrian) {
-
 
3389
                if (i == 0 || i == config.equestrian_leg || sort_afterEquestrianLeg ) {
-
 
3390
                    sort_aux[ptr->team].lec_place[i] = -1;
-
 
3391
                    continue;
-
 
3392
 
2792
                k = 1;
3393
                }
-
 
3394
 
-
 
3395
            //  NE Team - the duplicate entry
-
 
3396
            // Flag as unplaced NE teams after the EQ leg
2793
                teamclass = ptr->teamclass;
3397
            } else if ( ptr->isNeData ) {
-
 
3398
                if ( i == config.equestrian_leg) {
-
 
3399
                    sort_aux[ptr->team].lecq_place[i] = -1;
-
 
3400
                    continue;
-
 
3401
                }
-
 
3402
 
-
 
3403
                // EQ Team
-
 
3404
                // Flag as unplaced vetted teams on the EQ leg
-
 
3405
                // Flag as unplaced vetted teams after the EQ leg
-
 
3406
                // Flag as unplaced in overall (leg:0) vetted teams
-
 
3407
            } else {
-
 
3408
                if (i == 0 || i == config.equestrian_leg || sort_afterEquestrianLeg ) {
-
 
3409
                   if ( ptr->flags.vet_check) {
-
 
3410
                       sort_aux[ptr->team].lec_place[i] = -1;
-
 
3411
                       continue;
-
 
3412
                   }
-
 
3413
                }
2794
            }
3414
            }
-
 
3415
 
-
 
3416
 
-
 
3417
            if (ptr->isNeData) {
-
 
3418
                if( teamclassq != ptr->teamclass )
-
 
3419
                {
-
 
3420
                    q = 1;
-
 
3421
                    teamclassq = ptr->teamclass;
-
 
3422
                }
-
 
3423
                sort_aux[ptr->team].lecq_place[i] = q++;
-
 
3424
            }
-
 
3425
            else {
-
 
3426
                if( teamclass != ptr->teamclass )
-
 
3427
                {
-
 
3428
                    k = 1;
-
 
3429
                    teamclass = ptr->teamclass;
-
 
3430
                }
2795
            sort_aux[ptr->team].lec_place[i] = k++;
3431
                sort_aux[ptr->team].lec_place[i] = k++;
-
 
3432
            }
-
 
3433
 
2796
        }
3434
        }
2797
    }
3435
    }
2798
 
3436
 
2799
    /*
3437
    /*
2800
    **  Write the place information back to disk for use in the displays
3438
    **  Write the place information back to disk for use in the displays
-
 
3439
    **  For backwards compatability we havn't saved all the data.
-
 
3440
    **      The NE specific data has not been saved, but is held in memory for report generation
2801
    */
3441
    */
2802
    for( i = config.min_team; i <= config.max_team; i++ )
3442
    for( i = config.min_team; i <= config.max_team; i++ )
2803
    {
3443
    {
2804
        if( sort_aux[i].team && valid_field( i ) && g_record( i, &team_buf ) )
3444
        if( sort_aux[i].team && valid_field( i ) && g_record( i, &team_buf ) )
2805
        {
3445
        {
Line 2823... Line 3463...
2823
 *      This function is called to Sort in memory buffer
3463
 *      This function is called to Sort in memory buffer
2824
 *
3464
 *
2825
 *  Parameters:
3465
 *  Parameters:
2826
 *      leg         Requested leg
3466
 *      leg         Requested leg
2827
 *      mode        Defines the sort mode
3467
 *      mode        Defines the sort mode
-
 
3468
 *      withEq      Sort with equestrian data (True=Normal)
2828
 *
3469
 *
2829
 *  Returns:
3470
 *  Returns:
2830
 *      Nothing
3471
 *      Nothing
2831
 *
3472
 *
2832
 *========================================================================*/
3473
 *========================================================================*/
2833
 
3474
 
2834
void sort_team_data( int leg, int mode )
3475
void sort_team_data( int leg, int mode, bool withEq )
2835
{
3476
{
2836
 
3477
 
2837
    unsigned    j;
3478
    unsigned    j;
2838
    ty_s_data  *ptr;
3479
    ty_s_data  *ptr;
2839
 
3480
 
2840
    sort_leg = leg;                              /* Leg is global for the comparison function */
3481
    sort_leg = leg;                              /* Leg is global for the comparison function */
2841
    sort_mode = mode;                            /* Mode is global for compare function */
3482
    sort_mode = mode;                            /* Mode is global for compare function */
-
 
3483
    sort_withEquestrian = withEq;                /* Mode is global for compare function */
-
 
3484
    sort_afterEquestrianLeg = ( config.equestrian_leg && leg > config.equestrian_leg);
2842
 
3485
 
2843
    qsort( ( char * ) sort_data, sort_num, sizeof( ty_s_data ), sort_comp );
3486
    qsort( ( char * ) sort_data, sort_num, sizeof( ty_s_data ), sort_comp );
2844
 
3487
 
2845
    /*
3488
    /*
2846
     * Insert "place data" into the sorted data
3489
     * Insert "place data" into the sorted data
2847
     * This simply the index into the array of data - after its been
3490
     * This simply the index into the array of data - after its been
2848
     * sorted.
3491
     * sorted.
2849
     */
3492
     */
2850
    ptr = sort_data;
3493
    ptr = sort_data;
2851
    for( j = 1; j <= sort_num; j++, ptr++ )
3494
    for( j = 1; j <= sort_num; j++, ptr++ )
-
 
3495
    {
2852
        ptr->place = j;
3496
        ptr->place = j;
-
 
3497
    }
-
 
3498
 
-
 
3499
    //qDebug() << "sort_team_data: Leg:" << leg << ",M:" << mode << ",E:" << withEq;
-
 
3500
 
2853
 
3501
 
2854
}
3502
}
2855
 
3503
 
2856
/*========================================================================
3504
/*========================================================================
2857
 *
3505
 *
Line 2864... Line 3512...
2864
 *      a       - 1st record
3512
 *      a       - 1st record
2865
 *      b       - 2nd record
3513
 *      b       - 2nd record
2866
 *
3514
 *
2867
 *  Returns:
3515
 *  Returns:
2868
 *      value to qsort
3516
 *      value to qsort
-
 
3517
 *      Return negative if 'a' is less than 'b',
-
 
3518
 *             zero if 'a' == 'b'
-
 
3519
 *             positive if 'a' > 'b'
2869
 *
3520
 *
2870
 *========================================================================*/
3521
 *========================================================================*/
2871
 
3522
 
2872
int sort_comp( const void * aa, const void * bb )
3523
int sort_comp( const void * aa, const void * bb )
2873
{
3524
{
Line 2886... Line 3537...
2886
    if( sort_mode == S_TEAM )
3537
    if( sort_mode == S_TEAM )
2887
        return ( a->team - b->team );
3538
        return ( a->team - b->team );
2888
 
3539
 
2889
    /*
3540
    /*
2890
    **  Sorting on Class and Team Number
3541
    **  Sorting on Class and Team Number
-
 
3542
    **  Sort NE entries as a class of there own
2891
    */
3543
    */
2892
    if( sort_mode == S_CLASS )
3544
    if( sort_mode == S_CLASS )
2893
    {
3545
    {
-
 
3546
        if ( a->isNeData || b->isNeData) {
-
 
3547
            if ( a->isNeData && b->isNeData)
-
 
3548
                return ( a->team - b->team );
-
 
3549
            else
-
 
3550
                return ( a->isNeData ? 1 : -1 );
-
 
3551
        }
-
 
3552
 
2894
        if( a->teamclass != b->teamclass )
3553
        if( a->teamclass != b->teamclass )
2895
            return ( a->teamclass - b->teamclass );
3554
            return ( a->teamclass - b->teamclass );
2896
        else
3555
        else
2897
            return ( a->team - b->team );
3556
            return ( a->team - b->team );
2898
    }
3557
    }
2899
 
3558
 
2900
    /*
3559
    /*
2901
    **  Sorting within a class
3560
    **  Sorting within a class
2902
    **  First sort on the class
3561
    **  First sort on the class
-
 
3562
    **      Always put the NE entries last as this will simplify processing
-
 
3563
    **      Compare NE entries against NE entries and EQ entries againstEQ entries
2903
    */
3564
    */
2904
    if( sort_mode == S_LEC || sort_mode == S_LC || sort_mode == S_LC_NE )   /* Sort within a class */
3565
    if( sort_mode == S_LEC || sort_mode == S_LC /*|| sort_mode == S_LC_NE*/ ) {  /* Sort within a class */
2905
        if( a->teamclass != b->teamclass )
3566
        if ( a->isNeData || b->isNeData) {
2906
            return ( a->teamclass - b->teamclass );
3567
            if ( !(a->isNeData && b->isNeData ) )
2907
 
-
 
2908
#if 1
-
 
2909
    /*
-
 
2910
    **  Always put the nonequestrian_class at the end
-
 
2911
    **  Simplifies the creation of ordered lists as these
-
 
2912
    **  Entries are not present in the main body
-
 
2913
    */
-
 
2914
    if ( a->teamclass == config.nonequestrian_class ||  b->teamclass == config.nonequestrian_class )
-
 
2915
    {
-
 
2916
        if ( a->teamclass == config.nonequestrian_class &&  b->teamclass == config.nonequestrian_class )
-
 
2917
        {
-
 
2918
            if (sort_mode == S_LC_NE )
3568
                return ( a->isNeData ? 1 : -1 );
2919
            {
3569
        } else {
2920
                if ( a->real_teamclass != b->real_teamclass )
3570
            if (a->teamclass != b->teamclass) {
2921
                {
-
 
2922
                    return ( a->real_teamclass - b->real_teamclass );
3571
                return ( a->teamclass - b->teamclass );
2923
                }
-
 
2924
            }
3572
            }
2925
        }
3573
        }
2926
        else
-
 
2927
        {
-
 
2928
            return ( a->teamclass == config.nonequestrian_class ? 1 : -1 );
-
 
2929
        }
-
 
2930
 
-
 
2931
    }
3574
    }
2932
#endif
-
 
2933
 
3575
 
2934
    /*
3576
    /*
2935
    **  Now we need to examine the times as we have sorted
3577
    **  Now we need to examine the times as we have sorted
2936
    **  on every thing else.
3578
    **  on every thing else.
2937
    **
3579
    **
Line 2941... Line 3583...
2941
    **  team number
3583
    **  team number
2942
    **
3584
    **
2943
    **  If not sorting within a class (ie Overall), then Non_Equestrian
3585
    **  If not sorting within a class (ie Overall), then Non_Equestrian
2944
    **  is better than a bad time. Places NE before disqualified
3586
    **  is better than a bad time. Places NE before disqualified
2945
    **
3587
    **
2946
    **
-
 
2947
    **  Note: NE also have bad_times set
-
 
2948
    */
3588
    */
2949
#if 1
-
 
2950
    if( a->flags.bad_times || b->flags.bad_times )  /* Valid data has precedence */
-
 
2951
    {
-
 
2952
        if( a->flags.bad_times && b->flags.bad_times )
-
 
2953
        {
-
 
2954
            if( a->flags.non_equestrian || b->flags.non_equestrian )
-
 
2955
            {
-
 
2956
                if( a->flags.non_equestrian && b->flags.non_equestrian )
-
 
2957
                {
-
 
2958
                    /*
-
 
2959
                    **  Both are non equestrian
-
 
2960
                    **  Let the time sort operate ...
-
 
2961
                    */
3589
    bool aNoSort = false;
2962
                    //return ( a->team - b->team );
-
 
2963
                }
-
 
2964
                else
3590
    bool bNoSort = false;
2965
                {
-
 
2966
                    /* One is equestrian */
-
 
2967
                    /* Good times better than NE */
-
 
-
 
3591
 
2968
                    return ( a->flags.non_equestrian ? -1 : 1 );
3592
    if ( sort_leg != 0 && (sort_mode == S_LC || sort_mode == S_L ) ) {
2969
                }
-
 
2970
            }
-
 
2971
            else
-
 
2972
            {
-
 
2973
                /* Neither is equestrian */
-
 
2974
                return ( a->team - b->team );
3593
        aNoSort = a->flags.notInLP;
2975
            }
-
 
2976
        }
-
 
2977
        else
-
 
2978
            return ( a->flags.bad_times ? 1 : -1 );
3594
        bNoSort = b->flags.notInLP;
2979
    }
3595
    }
2980
#else
3596
 
2981
    if( a->flags.bad_times || b->flags.bad_times )  /* Valid data has precedence */
3597
    if ( sort_withEquestrian && (sort_mode == S_LC || sort_mode == S_L ) ) {
2982
    {
-
 
2983
        if( a->flags.bad_times && b->flags.bad_times )
3598
        if (a->flags.vet_check)
2984
            return ( a->team - b->team );
3599
            aNoSort = true;
2985
        else
3600
        if (b->flags.vet_check)
2986
            return ( a->flags.bad_times ? 1 : -1 );
3601
            bNoSort = true;
2987
    }
3602
    }
2988
 
3603
 
-
 
3604
    if (a->flags.bad_times || a->flags.disqualified || !a->flags.valid)
-
 
3605
        aNoSort = true;
-
 
3606
 
-
 
3607
    if (b->flags.bad_times || b->flags.disqualified || !b->flags.valid)
-
 
3608
        bNoSort = true;
-
 
3609
 
-
 
3610
    if ( sort_mode == S_FIN || sort_mode == S_IFIN ) {
-
 
3611
        if (a->flags.vet_check)
-
 
3612
            aNoSort = true;
-
 
3613
        if (b->flags.vet_check)
-
 
3614
            bNoSort = true;
2989
    /*
3615
    }
-
 
3616
 
2990
    **  Not sorting within a class ie: Overall
3617
    if (sort_mode == S_IFIN ) {
-
 
3618
        if (a->isNeData)
-
 
3619
            aNoSort = true;
-
 
3620
        if (b->isNeData)
-
 
3621
            bNoSort = true;
-
 
3622
    }
-
 
3623
 
2991
    **  Non-Equestrian is at the end, so that it doesn't get counted in the
3624
    // On the Equestrian Leg, vetted out teams are treated as disqualified
-
 
3625
    if (sort_leg == config.equestrian_leg || (sort_afterEquestrianLeg && ( sort_mode == S_LE || sort_mode == S_LEC))) {
-
 
3626
        if (a->flags.vet_check)
-
 
3627
            aNoSort = true;
-
 
3628
        if (b->flags.vet_check)
2992
    **  finishing order
3629
            bNoSort = true;
2993
    */
3630
    }
-
 
3631
 
-
 
3632
    if (aNoSort && bNoSort)
-
 
3633
        return ( a->team - b->team );
-
 
3634
 
-
 
3635
    if (aNoSort || bNoSort)
-
 
3636
        return ( aNoSort ? 1 : -1 );
-
 
3637
 
2994
    if( sort_mode == S_LE || sort_mode == S_L )     /* Sort NOT within a class */
3638
    if( sort_withEquestrian && sort_mode != S_FIN && sort_mode != S_IFIN )
2995
    {
3639
    {
2996
        if( a->flags.non_equestrian || b->flags.non_equestrian )
3640
        if( a->flags.non_equestrian && b->flags.non_equestrian )
2997
        {
3641
        {
-
 
3642
            /*
2998
            if( a->flags.non_equestrian && b->flags.non_equestrian )
3643
            **  Both are non equestrian
-
 
3644
            **  Let the time sort operate ...
-
 
3645
            */
2999
                return ( a->team - b->team );
3646
            //return ( a->team - b->team );
-
 
3647
        }
-
 
3648
        else if( a->flags.non_equestrian || b->flags.non_equestrian )
3000
            else
3649
        {
-
 
3650
            /* One is equestrian */
-
 
3651
            /* Good times better than NE */
3001
                return ( a->flags.non_equestrian ? 1 : -1 );
3652
            return ( a->flags.non_equestrian ? 1 : -1 );
3002
        }
3653
        }
3003
    }
3654
    }
3004
#endif
-
 
3005
 
3655
 
3006
    /*
3656
    /*
3007
    **  Before we sort on times we must determine which time to
3657
    **  Before we sort on times we must determine which time to
3008
    **  use. Finish time, Leg end times, Leg Elapsed times.
3658
    **  use. Finish time, Leg end times, Leg Elapsed times.
3009
    */
3659
    */
Line 3063... Line 3713...
3063
      **    Sort on Elapsed times
3713
      **    Sort on Elapsed times
3064
      */
3714
      */
3065
      case S_LC_NE:
3715
      case S_LC_NE:
3066
      case S_LC:
3716
      case S_LC:
3067
      case S_L:
3717
      case S_L:
-
 
3718
      case S_IFIN:
3068
        ta = a->lege[sort_leg];
3719
        ta = a->lege[sort_leg];
3069
        tb = b->lege[sort_leg];
3720
        tb = b->lege[sort_leg];
3070
        break;
3721
        break;
3071
 
3722
 
3072
      /*
3723
      /*
Line 3074... Line 3725...
3074
      */
3725
      */
3075
      default:
3726
      default:
3076
        return ( 0 );
3727
        return ( 0 );
3077
    }
3728
    }
3078
 
3729
 
-
 
3730
    if (sort_mode != S_LC_NE) {
-
 
3731
        /*
-
 
3732
         ** If we are ignore Equestrian config then place the Equestrian data last
-
 
3733
        */
-
 
3734
        if (sort_withEquestrian) {
-
 
3735
            if (a->isNeData != b->isNeData)
-
 
3736
                return ( a->isNeData ? 1 : -1 );
-
 
3737
        }
-
 
3738
 
-
 
3739
        if ( a->team == b->team) {
-
 
3740
            return ( a->isNeData ? 1 : -1 );
-
 
3741
        }
-
 
3742
    }
-
 
3743
 
3079
    /*
3744
    /*
3080
    **  Finally. Compare the required team times
3745
    **  Finally. Compare the required team times
3081
    */
3746
    */
3082
    if( ta == tb )
3747
    if( ta == tb )
3083
        return ( a->team - b->team );
3748
        return ( a->team - b->team );
Line 3153... Line 3818...
3153
bool load_report_data(void)
3818
bool load_report_data(void)
3154
{
3819
{
3155
 
3820
 
3156
    ty_s_data  *ptr;                             /* pointer to sort data type */
3821
    ty_s_data  *ptr;                             /* pointer to sort data type */
3157
    ty_s_data  *last;
3822
    ty_s_data  *last;
3158
    int         j;
3823
    unsigned    j;
3159
    unsigned    num;
3824
    unsigned    num;
3160
    team_type   team_buf;
3825
    team_type   team_buf;
3161
 
3826
 
3162
    /*
3827
    /*
3163
     * Fetch memory for the data store
3828
     * Fetch memory for the data store
Line 3178... Line 3843...
3178
    */
3843
    */
3179
    num = config.max_team - config.min_team + 1 ;
3844
    num = config.max_team - config.min_team + 1 ;
3180
 
3845
 
3181
    /*
3846
    /*
3182
    **  Allow for non-equestrian teams - since some of the data is loaded twice
3847
    **  Allow for non-equestrian teams - since some of the data is loaded twice
3183
    **  Take a guess that at most 1/2 the teams will be non-equestrian
3848
    **  OLD: Take a guess that at most 1/2 the teams will be non-equestrian
-
 
3849
    **  NEW: Memory is cheap. Assume all teams could be non-equestrian
3184
    */
3850
    */
-
 
3851
    // OLD: num = num * 3 / 2;
3185
    num = num * 3 / 2;
3852
    num = num * 2;
3186
 
3853
 
3187
    sort_data = ( ty_s_data * ) calloc ( num , sizeof( ty_s_data ) );
3854
    sort_data = ( ty_s_data * ) calloc ( num , sizeof( ty_s_data ) );
3188
    sort_aux = ( ty_s_aux * ) calloc( num + 1, sizeof( ty_s_aux ) );
3855
    sort_aux = ( ty_s_aux * ) calloc( num + 1, sizeof( ty_s_aux ) );
3189
 
3856
 
3190
    if( sort_data == 0 || sort_aux == 0 )
3857
    if( sort_data == 0 || sort_aux == 0 )
Line 3208... Line 3875...
3208
            g_record( team, &team_buf );
3875
            g_record( team, &team_buf );
3209
            if( team_buf.flags.valid )
3876
            if( team_buf.flags.valid )
3210
            {
3877
            {
3211
                last = ptr;
3878
                last = ptr;
3212
                ptr->team = team;
3879
                ptr->team = team;
-
 
3880
                ptr->isNeData = false;
3213
                for( j = 0; j < MAX_LEGS + 1; j++ )
3881
                for( j = 0; j < MAX_LEGS + 1; j++ )
3214
                {
3882
                {
3215
                    ptr->lege[j] = team_buf.leg[j].elapsed;
3883
                    ptr->lege[j] = team_buf.leg[j].elapsed;
3216
                    ptr->leg[j] = team_buf.leg[j].end;
3884
                    ptr->leg[j] = team_buf.leg[j].end;
3217
                }
3885
                }
3218
                ptr->start = team_buf.leg[0].start;
3886
                ptr->start = team_buf.leg[0].start;
3219
                ptr->teamclass = team_buf.teamclass;
3887
                ptr->teamclass = team_buf.teamclass;
3220
                ptr->real_teamclass = team_buf.teamclass;
-
 
3221
 
-
 
3222
                ptr->flags = team_buf.flags;
3888
                ptr->flags = team_buf.flags;
-
 
3889
 
-
 
3890
                // Add a few flags to simplify processing
-
 
3891
                //  Vetted out teams to be included inthe fastest calcs - except for Equestian Leg
-
 
3892
                //  Bodgey teams are not sorted by place - only after all places and then by team number
3223
                if (ptr->flags.non_equestrian)
3893
                ptr->flags.notInLP = 0;
3224
                    ptr->flags.disqualified = true;
3894
                ptr->flags.notInFastest = 0;
-
 
3895
 
-
 
3896
                if ( ptr->flags.bad_times || ptr->flags.disqualified || !ptr->flags.valid) {
3225
                if (ptr->flags.vet_check)
3897
                    ptr->flags.notInLP = 1;
3226
                    ptr->flags.disqualified = true;
3898
                    ptr->flags.notInFastest = 1;
-
 
3899
                }
-
 
3900
 
3227
                ptr++;
3901
                ptr++;
3228
                sort_num++;
3902
                sort_num++;
3229
 
3903
 
-
 
3904
 
3230
                /*
3905
                /*
3231
                **  If non-equestrian support is enabled then
3906
                **  If non-equestrian support is enabled then
3232
                **  duplicate and modify data for the non-equestrian teams
3907
                **  duplicate and modify data for the non-equestrian teams
3233
                **      - Change the class
3908
                **      - Change the class
3234
                **      - Modify the leg time
3909
                **      - Modify the leg time
3235
                */
3910
                */
3236
#if 1
3911
#if 1
3237
                if ( config.nonequestrian_class && team_buf.flags.non_equestrian )
3912
                if ( config.nonequestrian_class && team_buf.flags.non_equestrian )
3238
                {
3913
                {
3239
                    ptr->team = team;
3914
                    ptr->team = team;
-
 
3915
                    ptr->isNeData = true;
3240
                    ptr->lege[0] = 0;
3916
                    ptr->lege[0] = 0;
3241
 
3917
 
3242
                    for( j = 0; j < MAX_LEGS + 1; j++ )
3918
                    for( j = 0; j < MAX_LEGS + 1; j++ )
3243
                    {
3919
                    {
3244
                        if ( j == config.equestrian_leg )
3920
                        if ( (short)j == config.equestrian_leg )
3245
                        {
3921
                        {
3246
                            last->lege[j] = ptr->lege[j] = 0;
3922
                            last->lege[j] = ptr->lege[j] = 0;
3247
                            if ( config.equestrian_leg > 1 )
3923
                            if ( config.equestrian_leg > 1 )
3248
                                last->leg[j] = ptr->leg[j] = ptr->leg[j-1];
3924
                                last->leg[j] = ptr->leg[j] = ptr->leg[j-1];
3249
                        }
3925
                        }
Line 3256... Line 3932...
3256
                            last->lege[0] = ptr->lege[0] ;
3932
                            last->lege[0] = ptr->lege[0] ;
3257
                        }
3933
                        }
3258
                    }
3934
                    }
3259
 
3935
 
3260
                    last->start = ptr->start = team_buf.leg[0].start;
3936
                    last->start = ptr->start = team_buf.leg[0].start;
3261
                    ptr->teamclass = config.nonequestrian_class;
-
 
3262
                    ptr->real_teamclass = team_buf.teamclass;
3937
                    ptr->teamclass = team_buf.teamclass;
3263
                    ptr->flags = team_buf.flags;
3938
                    ptr->flags = team_buf.flags;
3264
                    ptr->flags.disqualified = false;
-
 
3265
 
-
 
3266
 
3939
 
3267
                    ptr++;
3940
                    ptr++;
3268
                    sort_num++;
3941
                    sort_num++;
3269
                }
3942
                }
3270
#endif
3943
#endif
3271
            }
3944
            }
3272
        }
3945
        }
3273
    }
3946
    }
-
 
3947
 
-
 
3948
#if 0
-
 
3949
    // Debug zzz
-
 
3950
    qDebug() << "--- Start ---";
-
 
3951
    sort_team_data( 0, S_LC, 1 );
-
 
3952
 
-
 
3953
    for( j = 1, ptr = sort_data; j <= sort_num; j++, ptr++ )
-
 
3954
    {
-
 
3955
        qDebug() << "T:" << ptr->team
-
 
3956
                << "Class:" << ptr->teamclass
-
 
3957
                << "NEData:" << (ptr->isNeData? 1:0)
-
 
3958
                << "iLP:" << (ptr->flags.notInLP ? 1:0)
-
 
3959
                << "iF:" << (ptr->flags.notInFastest ? 1:0)
-
 
3960
                << "Valid:" << (ptr->flags.valid ? 1:0)
-
 
3961
                << "NE:" << (ptr->flags.non_equestrian? 1:0)
-
 
3962
                << "B:" << (ptr->flags.bad_times ? 1 : 0 )
-
 
3963
                << "D:" << (ptr->flags.disqualified ? 1:0 )
-
 
3964
                << "V:" << (ptr->flags.vet_check ? 1:0 )
-
 
3965
                << "LE0:" << ptr->lege[0]
-
 
3966
                << "L0:" << ptr->leg[0]
-
 
3967
                << "LE1:" << ptr->lege[3]
-
 
3968
                ;
-
 
3969
    }
-
 
3970
    qDebug() << "-----------------------------------End---";
-
 
3971
#endif
-
 
3972
 
3274
    return ( TRUE );
3973
    return ( TRUE );
3275
}
3974
}
3276
 
3975
 
3277
/*========================================================================
3976
/*========================================================================
3278
 *
3977
 *
Line 3317... Line 4016...
3317
        **  of the data can be trusted.
4016
        **  of the data can be trusted.
3318
        **
4017
        **
3319
        **  If the team has been disqualified, then don't use any
4018
        **  If the team has been disqualified, then don't use any
3320
        **  of the data.
4019
        **  of the data.
3321
        */
4020
        */
3322
        if( ptr->flags.bad_times || ptr->flags.disqualified )
4021
        if (ptr->flags.notInFastest) {
3323
            continue;
4022
            continue;
-
 
4023
        }
-
 
4024
 
-
 
4025
        short teamClass = ptr->teamclass;
-
 
4026
 
-
 
4027
 
-
 
4028
        /*  Don't include the psuedo NE data items in the calculations (unless processing NE class)
-
 
4029
        **  They are duplicates of other data
-
 
4030
        */
-
 
4031
        if (j == config.nonequestrian_class) {
-
 
4032
            if ( !ptr->isNeData)
-
 
4033
                continue;
-
 
4034
        }
-
 
4035
 
-
 
4036
        if (ptr->isNeData)
-
 
4037
            teamClass = config.nonequestrian_class;
-
 
4038
 
3324
 
4039
 
3325
        for( j = 0; j <= config.num_legs; j++ )
4040
        for( j = 0; j <= config.num_legs; j++ )
3326
        {
4041
        {
3327
            if( ptr->lege[j] <= 0 )              /* Ignore bad data */
4042
            if( ptr->lege[j] <= 0 )              /* Ignore bad data */
3328
                continue;
4043
                continue;
3329
 
4044
 
3330
            /*
4045
            /*
-
 
4046
            ** If this is the Equestrian Leg and the team has been vetted out, then this team cannot
-
 
4047
            ** be included into the stats for this leg
-
 
4048
            **
-
 
4049
            ** If team has been vetted out then don't consider in fastest overall
-
 
4050
            */
-
 
4051
            if ( ptr->flags.vet_check && (j == config.equestrian_leg || j== 0)) {
-
 
4052
                continue;
-
 
4053
            }
-
 
4054
 
-
 
4055
            /* If this is the Equestrian Leg and the team is a Non-Equestrian Team, then don't include
-
 
4056
            ** it into the stats.
-
 
4057
            **
-
 
4058
            ** If this is a NE team then don't consider it to be fastest overall
-
 
4059
            */
-
 
4060
            if ( !ptr->isNeData && ptr->flags.non_equestrian &&  (j == config.equestrian_leg || j== 0)) {
-
 
4061
                continue;
-
 
4062
            }
-
 
4063
 
-
 
4064
            /*
3331
            **  Determine fastest team : overall
4065
            **  Determine fastest team : overall
3332
            **  Ignore the non-equestrian data as this is in the list twice
4066
            **  Ignore the non-equestrian data as this is in the list twice
3333
            */
4067
            */
3334
            if( ( ptr->lege[j] < stats.fast.time[j][0] )
4068
            if( ( ptr->lege[j] < stats.fast.time[j][0] )
3335
                || ( stats.fast.time[j][0] < 0 ) )
4069
                || ( stats.fast.time[j][0] < 0 ) )
3336
            {
4070
            {
3337
                if ( ptr->teamclass != config.nonequestrian_class )
4071
                if ( !ptr->isNeData )
3338
                {
4072
                {
3339
                    stats.fast.team[j][0] = ptr->team;
4073
                    stats.fast.team[j][0] = ptr->team;
3340
                    stats.fast.time[j][0] = ptr->lege[j];
4074
                    stats.fast.time[j][0] = ptr->lege[j];
3341
                }
4075
                }
3342
            }
4076
            }
3343
 
4077
 
3344
            /*
4078
            /*
3345
            **  Determine fastest team : within a class
4079
            **  Determine fastest team : within a class
3346
            */
4080
            */
3347
            if( ( ptr->lege[j] < stats.fast.time[j][ptr->teamclass] )
4081
            if( ( ptr->lege[j] < stats.fast.time[j][teamClass] )
3348
                || stats.fast.time[j][ptr->teamclass] < 0 )
4082
                || stats.fast.time[j][teamClass] < 0 )
3349
            {
4083
            {
3350
                stats.fast.team[j][ptr->teamclass] = ptr->team;
4084
                stats.fast.team[j][teamClass] = ptr->team;
3351
                stats.fast.time[j][ptr->teamclass] = ptr->lege[j];
4085
                stats.fast.time[j][teamClass] = ptr->lege[j];
3352
            }
4086
            }
3353
 
4087
 
3354
            /*
4088
            /*
3355
            **  Sum the end times : overall
4089
            **  Sum the end times : overall
3356
            */
4090
            */
3357
            if ( ptr->teamclass != config.nonequestrian_class )
4091
            if ( !ptr->isNeData )
3358
            {
4092
            {
3359
                stats.average[j][0] += ptr->lege[j];
4093
                stats.average[j][0] += ptr->lege[j];
3360
                stats.team[j][0]++;
4094
                stats.team[j][0]++;
3361
            }
4095
            }
3362
 
4096
 
3363
 
4097
 
3364
            /*
4098
            /*
3365
            **  Sum the end times : within a class
4099
            **  Sum the end times : within a class
3366
            */
4100
            */
3367
            stats.average[j][ptr->teamclass] += ptr->lege[j];
4101
            stats.average[j][teamClass] += ptr->lege[j];
3368
            stats.team[j][ptr->teamclass]++;
4102
            stats.team[j][teamClass]++;
3369
        }
4103
        }
3370
    }
4104
    }
3371
 
4105
 
3372
    /*
4106
    /*
3373
     * Calculate the averages
4107
     * Calculate the averages 
-
 
4108
     *      Can ignore that fact that some categories don't exists
-
 
4109
     *      The results will be -1
3374
     */
4110
     */
3375
    for( k = 0; k <= config.num_legs; k++ )
4111
    for( k = 0; k <= config.num_legs; k++ )
3376
    {
4112
    {
3377
        for( j = 0; j <= config.num_class; j++ )
4113
        for( j = 0; j <= config.num_class; j++ )
3378
        {
4114
        {