Subversion Repositories svn1-original

Rev

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

Rev 375 Rev 379
Line 395... Line 395...
395
 
395
 
396
    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; )
397
    {
397
    {
398
        p_place( ptr++, leg, k++ );
398
        p_place( ptr++, leg, k++ );
399
        p_place( ptr++, leg, k++ );
399
        p_place( ptr++, leg, k++ );
-
 
400
 
400
        print( "|" );
401
        print( "|" );
401
        while( i <= config.max_team && !valid_field( i ) )
402
        while( i <= config.max_team && !valid_field( i ) )
402
            i++;
403
            i++;
403
        p_team( i++, leg );
404
        p_team( i++, leg );
404
        while( i <= config.max_team && !valid_field( i ) )
405
        while( i <= config.max_team && !valid_field( i ) )
Line 766... Line 767...
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;
770
    bool        isNeClass = false;
771
    bool        isNeClass = false;
771
    int         place;
-
 
772
 
-
 
773
 
772
 
774
    ck_data( -1, C_ELAPSED );
773
    ck_data( -1, C_ELAPSED );
775
 
774
 
776
    /*
775
    /*
777
    **  Sort on every thing
776
    **  Sort on every thing
Line 792... Line 791...
792
    print_class_header( -1, TRUE );                     /* Print the header */
791
    print_class_header( -1, TRUE );                     /* Print the header */
793
    sort_team_data( 0, S_L, true );                     /* Re-sort on elapsed time */
792
    sort_team_data( 0, S_L, true );                     /* Re-sort on elapsed time */
794
    lcount = 0;
793
    lcount = 0;
795
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
794
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
796
    {
795
    {
797
        if ( ptr->teamclass == config.nonequestrian_class )
796
        if ( ptr->isNeData )
798
            continue;
797
            continue;
799
 
798
 
800
        g_record( ptr->team, &team_buf );
799
        g_record( ptr->team, &team_buf );
801
 
800
 
802
        /*
801
        /*
803
        ** If this is a NE team then dummy up some of the data that hasn't been stored in team_buf
802
        ** If this is a NE team then dummy up some of the data that hasn't been stored in team_buf
804
        */
803
        */
805
        if (ptr->flags.non_equestrian)
804
        if (ptr->flags.non_equestrian)
806
        {
805
        {
807
            team_buf.leg[0].l_place = sort_aux[ptr->team].leq_place[0];
806
            team_buf.leg[0].l_place = sort_aux[ptr->team].leq_place[0];
808
            team_buf.leg[0].lc_place = sort_aux[ptr->team].lq_place[0];;
807
            team_buf.leg[0].lc_place = sort_aux[ptr->team].lq_place[0];
809
        }
808
        }
810
 
809
 
811
        /*
810
        /*
812
        **  If printing an HTML report then we need to mark
811
        **  If printing an HTML report then we need to mark
813
        **  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
Line 872... Line 871...
872
 
871
 
873
    print_class_stats( -1, TRUE );              /* Print statistics */
872
    print_class_stats( -1, TRUE );              /* Print statistics */
874
    print_legend(-1, 1 );                       /* Print the legend */
873
    print_legend(-1, 1 );                       /* Print the legend */
875
    close_printer();                            /* Close the printer */
874
    close_printer();                            /* Close the printer */
876
 
875
 
877
    /*
876
    /* ------------------ Class Reports
878
     * Now produce a breakdown on a class by class basis 
877
     * Now produce a breakdown on a class by class basis 
879
     * Now print out the class placement information
878
     * Now print out the class placement information
880
     */
879
     */
881
 
880
 
882
    sort_team_data( 0, S_LC, true );           /* Generate class placement data */
881
    sort_team_data( 0, S_LC, true );           /* Generate class placement data */
883
    last_class = -1;                           /* Invalid class to start with */
882
    last_class = -1;                           /* Invalid class to start with */
884
    memset ( class_done, 0, sizeof(class_done));
883
    memset ( class_done, 0, sizeof(class_done));
885
 
884
 
886
    place = 1;
-
 
887
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
885
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
888
    {
886
    {
-
 
887
        short teamClass = ptr->teamclass;
889
        int flags = 0;
888
        isNeClass = false;
-
 
889
 
-
 
890
        /*
-
 
891
        **  Dummy up the psuedo NE data a little bit
-
 
892
        */
-
 
893
        if (ptr->isNeData) {
890
        bool eflags;
894
            isNeClass = true;
-
 
895
            teamClass = config.nonequestrian_class;
-
 
896
        }
-
 
897
 
-
 
898
//qDebug() << "NEtm:" << ptr->team << "," << isNeClass << "," << teamClass;
891
 
899
 
892
        /*
900
        /*
893
        **  Detect a change in the "class"
901
        **  Detect a change in the "class"
894
        **  All data is within the one array of data
902
        **  All data is within the one array of data
895
        **  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
896
        **  The non-equestrian class does this.
904
        **  The non-equestrian class does this.
897
        */
905
        */
898
        if( last_class != ptr->teamclass )
906
        if( last_class != teamClass )
899
        {
907
        {
900
            if( last_class >= 0 )
908
            if( last_class >= 0 )
901
            {
909
            {
902
                print_class_stats( last_class, TRUE );
910
                print_class_stats( last_class, TRUE );
903
                print_legend( last_class, 1 );
911
                print_legend( last_class, 1 );
904
                close_printer();
912
                close_printer();
-
 
913
if (class_done[teamClass]) {
-
 
914
    qDebug() << "ERROR class already processed - order error";
-
 
915
}
-
 
916
                last_class = 0;
905
            }
917
            }
906
 
918
 
907
            /*
-
 
908
            ** Determine if this is the crazy dummy Non-equestrian class
-
 
909
            */
-
 
910
            isNeClass = (ptr->teamclass == config.nonequestrian_class );
919
            report_title = tprintf( "Category results for : %-*s", LEN_CLASS_NAME, teamClass == 0 ? "" : config.team_class[teamClass - 1].full_name );
911
            place = 1;
-
 
912
 
920
 
913
            report_title = tprintf( "Category results for : %-*s", LEN_CLASS_NAME, ptr->teamclass == 0 ? "" : config.team_class[ptr->teamclass - 1].full_name );
-
 
914
 
-
 
915
            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 ) )
916
                continue;
922
                continue;
917
            print_class_header( last_class = ptr->teamclass, TRUE );
923
            print_class_header( last_class = teamClass, TRUE );
918
 
924
 
919
            /*
925
            /*
920
            **  Mark the class as done
926
            **  Mark the class as done
921
            */
927
            */
922
            class_done[ptr->teamclass] = TRUE;
928
            class_done[teamClass] = TRUE;
923
            lcount = 0;
929
            lcount = 0;
-
 
930
            last_class = teamClass;
924
        }
931
        }
925
 
932
 
926
        /*
933
        /*
927
        **  Now read in the team record
934
        **  Now read in the team record
928
        */
935
        */
929
        g_record( ptr->team, &team_buf );
936
        g_record( ptr->team, &team_buf );
930
        flags = ptr->flags.bad_times;
-
 
931
        eflags = (ptr->teamclass != config.nonequestrian_class && ptr->flags.non_equestrian);
-
 
932
 
937
 
933
        /*
938
        /*
934
        ** Dummy up the data for the dummy nonEquestrian Class
939
        ** Dummy up the data for the dummy nonEquestrian Class
935
        ** Its not stored in the team_buf for backwards compatability
940
        ** Its not stored in the team_buf for backwards compatability
936
        */
941
        */
937
        if( isNeClass)
942
        if( isNeClass)
938
        {
943
        {
939
            for( j = 0; j <= config.num_legs; j++ )
944
            for( j = 0; j <= config.num_legs; j++ )
940
            {
945
            {
941
                team_buf.leg[j].lc_place = sort_aux[ptr->team].lq_place[j];
946
                team_buf.leg[j].lc_place = sort_aux[ptr->team].lq_place[j];
942
                team_buf.leg[j].lec_place = sort_aux[ptr->team].leq_place[j];;
947
                team_buf.leg[j].lec_place = sort_aux[ptr->team].leq_place[j];
943
            }
948
            }
944
        }
949
        }
945
        else
950
        else
946
        {
951
        {
947
            if (ptr->flags.non_equestrian)
952
            if (ptr->flags.non_equestrian)
948
            {
953
            {
-
 
954
                //team_buf.leg[0].lc_place = sort_aux[ptr->team].lcq_place[0];
949
                team_buf.leg[0].lc_place =  place++; //sort_aux[ptr->team].lq_place[0];
955
                //team_buf.leg[0].lc_place = sort_aux[ptr->team].lcq_place[0];
950
                team_buf.leg[0].lec_place = sort_aux[ptr->team].leq_place[0];
956
                team_buf.leg[0].lec_place = sort_aux[ptr->team].leq_place[0];
951
                eflags = false;
-
 
952
            }
957
            }
953
        }
958
        }
954
 
959
 
955
 
960
 
956
        /*
961
        /*
Line 973... Line 978...
973
        print( "%4d",  team_buf.numb );
978
        print( "%4d",  team_buf.numb );
974
        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 );
975
 
980
 
976
        for( j = 1; j <= config.num_legs; j++ )
981
        for( j = 1; j <= config.num_legs; j++ )
977
        {
982
        {
978
            bool isEquestrianLeg = (j == config.equestrian_leg && (ptr->teamclass == config.nonequestrian_class || ptr->flags.non_equestrian));
983
            bool isEquestrianLeg = (j == config.equestrian_leg && (ptr->isNeData || ptr->flags.non_equestrian));
979
 
984
 
980
            /*
985
            /*
981
            **  Ensure that non-equestrian leg data is not displayed
986
            **  Ensure that non-equestrian leg data is not displayed
982
            */
987
            */
983
            if ( isEquestrianLeg )
988
            if ( isEquestrianLeg )
Line 990... Line 995...
990
                if ( config.num_legs != 1 ) print( " %4.4s", px_place( j, team_buf.leg[j].lc_place,  false, false, ptr->flags ));
995
                if ( config.num_legs != 1 ) print( " %4.4s", px_place( j, team_buf.leg[j].lc_place,  false, false, ptr->flags ));
991
                if ( config.num_legs != 1 ) print( " %4.4s", px_place( j, team_buf.leg[j].lec_place, true , true, ptr->flags ) );
996
                if ( config.num_legs != 1 ) print( " %4.4s", px_place( j, team_buf.leg[j].lec_place, true , true, ptr->flags ) );
992
                if ( config.num_legs == 1 ) print( " %-*s ", MAX_TM_NAME, team_buf.name );
997
                if ( config.num_legs == 1 ) print( " %-*s ", MAX_TM_NAME, team_buf.name );
993
            }
998
            }
994
        }
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
995
 
1060
 
996
        /*
1061
        /*
997
        **  Print the trailer
1062
        **  Print the trailer
998
        **      - Total time
1063
        **      - Total time
999
        **      - Overall place - with reference to overall place file
1064
        **      - Overall place - with reference to overall place file
Line 1108... Line 1173...
1108
    ptr = sort_data;
1173
    ptr = sort_data;
1109
    sort_team_data( 0, S_TEAM, true );                   /* Re-sort on team number */
1174
    sort_team_data( 0, S_TEAM, true );                   /* Re-sort on team number */
1110
    lcount = 0;
1175
    lcount = 0;
1111
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
1176
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
1112
    {
1177
    {
1113
        if ( ptr->teamclass == config.nonequestrian_class )
1178
        if ( ptr->isNeData )
1114
            continue;
1179
            continue;
1115
 
1180
 
1116
        g_record( ptr->team, &team_buf );
1181
        g_record( ptr->team, &team_buf );
1117
 
1182
 
1118
        /*
1183
        /*
1119
        ** If this is a NE team then dummy up some of the data that hasn't been stored in team_buf
1184
        ** If this is a NE team then dummy up some of the data that hasn't been stored in team_buf
1120
        */
1185
        */
1121
        if (ptr->flags.non_equestrian)
1186
        if (ptr->flags.non_equestrian)
1122
        {
1187
        {
1123
            team_buf.leg[0].l_place = sort_aux[ptr->team].leq_place[0];
1188
            team_buf.leg[0].l_place = sort_aux[ptr->team].leq_place[0];
1124
            team_buf.leg[0].lc_place = sort_aux[ptr->team].lq_place[0];;
1189
            //team_buf.leg[0].lc_place = sort_aux[ptr->team].lcq_place[0];
1125
        }
1190
        }
1126
 
1191
 
1127
        /*
1192
        /*
1128
        **  If printing an HTML report then we need to mark
1193
        **  If printing an HTML report then we need to mark
1129
        **  the entry with a reference so that we can link to it
1194
        **  the entry with a reference so that we can link to it
Line 1179... Line 1244...
1179
        */
1244
        */
1180
       if ( config.num_legs != 1 ) print( "  %-8s ", time_a( ptr->lege[0] ) );
1245
       if ( config.num_legs != 1 ) print( "  %-8s ", time_a( ptr->lege[0] ) );
1181
        
1246
        
1182
        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 );
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 );
1183
        print( "%4.4s", px_place( 0, team_buf.leg[0].lc_place, false, false, ptr->flags ) );
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
 
1184
        if ( report_html == printed && lcount %5 == 4 ) print_underline( FALSE );
1268
        if ( report_html == printed && lcount %5 == 4 ) print_underline( FALSE );
1185
        lcount++;
1269
        lcount++;
1186
        print( "\n" );
1270
        print( "\n" );
1187
    }
1271
    }
1188
 
1272
 
Line 1423... Line 1507...
1423
        //    continue;
1507
        //    continue;
1424
 
1508
 
1425
        if ( j != 1 ) {
1509
        if ( j != 1 ) {
1426
            if (!entryFound) {
1510
            if (!entryFound) {
1427
                print( "\n");
1511
                print( "\n");
1428
                print( "No winners awarded. Non eligable." );
1512
                print( "No winners awarded. Non eligible." );
1429
                if ( report_html == html ) print("<br>");
1513
                if ( report_html == html ) print("<br>");
1430
            }
1514
            }
1431
            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"));
1432
        }
1516
        }
1433
 
1517
 
Line 1493... Line 1577...
1493
                **  Can't award NE teams unless its a NE award
1577
                **  Can't award NE teams unless its a NE award
1494
                */
1578
                */
1495
                if ( ptr->flags.bad_times || ptr->flags.disqualified || ptr->flags.vet_check || !ptr->flags.valid )
1579
                if ( ptr->flags.bad_times || ptr->flags.disqualified || ptr->flags.vet_check || !ptr->flags.valid )
1496
                    break;
1580
                    break;
1497
 
1581
 
1498
                if ( ptr->teamclass != config.nonequestrian_class  && ptr->flags.non_equestrian )
1582
                if ( !ptr->isNeData && ptr->flags.non_equestrian )
1499
                    break;
1583
                    break;
1500
 
1584
 
1501
                /*
1585
                /*
1502
                **  Count the entry
1586
                **  Count the entry
1503
                */
1587
                */
Line 1536... Line 1620...
1536
                {
1620
                {
1537
 
1621
 
1538
                    /*
1622
                    /*
1539
                    **  Skip equestrian leg in the non-equestion display
1623
                    **  Skip equestrian leg in the non-equestion display
1540
                    */
1624
                    */
1541
                    if ( k + 1 == config.equestrian_leg && ptr->teamclass == config.nonequestrian_class)
1625
                    if ( k + 1 == config.equestrian_leg && ptr->isNeData)
1542
                        continue;
1626
                        continue;
1543
 
1627
 
1544
                    print( "\n");
1628
                    print( "\n");
1545
                    print( "    ");
1629
                    print( "    ");
1546
                    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 1576... Line 1660...
1576
        header_done = false;
1660
        header_done = false;
1577
 
1661
 
1578
        /*
1662
        /*
1579
        **  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
1580
        */
1664
        */
1581
        sort_team_data( 0, S_LC_NE, true );      /* Generate class placement data */
1665
        sort_team_data( 0, S_LC_NE, true );     /* Generate class placement data */
1582
        last_class = -1;                   /* Invalid class to start with */
1666
        last_class = -1;                        /* Invalid class to start with */
1583
 
1667
 
1584
        /*
1668
        /*
1585
        **  Only process the Non Equestrian teams in this pass
1669
        **  Only process the Non Equestrian teams in this pass
1586
        */
1670
        */
1587
        print( "\n");
1671
        print( "\n");
Line 1598... Line 1682...
1598
                continue;
1682
                continue;
1599
 
1683
 
1600
            if ( j != 1 ) {
1684
            if ( j != 1 ) {
1601
                if (!entryFound) {
1685
                if (!entryFound) {
1602
                    print( "\n");
1686
                    print( "\n");
1603
                    print( "No winners awarded. Non eligable." );
1687
                    print( "No winners awarded. Non eligible." );
1604
                    if ( report_html == html ) print("<br>");
1688
                    if ( report_html == html ) print("<br>");
1605
                }
1689
                }
1606
                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"));
1607
            }
1691
            }
1608
 
1692
 
Line 1654... Line 1738...
1654
            entryFound = false;
1738
            entryFound = false;
1655
            windex = 0;                     /* Winners done */
1739
            windex = 0;                     /* Winners done */
1656
            unsigned int i;
1740
            unsigned int i;
1657
            for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
1741
            for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
1658
            {
1742
            {
1659
                if ( ptr->teamclass != config.nonequestrian_class ||  ptr->real_teamclass != j )
1743
                if ( !ptr->isNeData )
1660
                {
1744
                    continue;
-
 
1745
 
-
 
1746
                if ( ptr->teamclass != j ) {
1661
                    continue;
1747
                    continue;
1662
                }
1748
                }
-
 
1749
                //qDebug() << "NeTeam0:" <<  ptr->team << "," << ptr->isNeData << "," << ptr->teamclass << "," << j;
1663
 
1750
 
1664
                /*
1751
                /*
1665
                **  Now read in the team record
1752
                **  Now read in the team record
1666
                */
1753
                */
1667
                if( valid_field( ptr->team ) && g_record( ptr->team, &team_buf ) )
1754
                if( valid_field( ptr->team ) && g_record( ptr->team, &team_buf ) )
Line 1672... Line 1759...
1672
                    **  Can't award NE teams unless its a NE award
1759
                    **  Can't award NE teams unless its a NE award
1673
                    */
1760
                    */
1674
                    if ( ptr->flags.bad_times || ptr->flags.disqualified || ptr->flags.vet_check || !ptr->flags.valid )
1761
                    if ( ptr->flags.bad_times || ptr->flags.disqualified || ptr->flags.vet_check || !ptr->flags.valid )
1675
                        break;
1762
                        break;
1676
 
1763
 
1677
                    if ( ptr->teamclass != config.nonequestrian_class  && ptr->flags.non_equestrian )
1764
                    if ( /*!ptr->isNeData &&*/ !ptr->flags.non_equestrian )
1678
                        break;
1765
                        break;
1679
 
1766
 
1680
                    /*
1767
                    /*
1681
                    **  Count the entry
1768
                    **  Count the entry
1682
                    */
1769
                    */
Line 1715... Line 1802...
1715
                    {
1802
                    {
1716
 
1803
 
1717
                        /*
1804
                        /*
1718
                        **  Skip equestrian leg in the non-equestion display
1805
                        **  Skip equestrian leg in the non-equestion display
1719
                        */
1806
                        */
1720
                        if ( k + 1 == config.equestrian_leg && ptr->teamclass == config.nonequestrian_class)
1807
                        if ( k + 1 == config.equestrian_leg && ptr->isNeData)
1721
                            continue;
1808
                            continue;
1722
 
1809
 
1723
                        print( "\n");
1810
                        print( "\n");
1724
                        print( "    ");
1811
                        print( "    ");
1725
                        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 2008... Line 2095...
2008
    ty_s_data  *ptr;
2095
    ty_s_data  *ptr;
2009
    team_type   team_buf;
2096
    team_type   team_buf;
2010
    unsigned    i;
2097
    unsigned    i;
2011
    int         j, last_class;
2098
    int         j, last_class;
2012
    char       *report_title;
2099
    char       *report_title;
-
 
2100
    short       pClass;
2013
 
2101
 
2014
    if ( ! report_all )
2102
    if ( ! report_all )
2015
    {
2103
    {
2016
        ck_data( -1, C_DISQUAL );              /* Check the data - dummy check */
2104
        ck_data( -1, C_DISQUAL );              /* Check the data - dummy check */
2017
    }
2105
    }
Line 2032... Line 2120...
2032
 
2120
 
2033
    ptr = sort_data;
2121
    ptr = sort_data;
2034
    sort_team_data( 0, S_TEAM, true );                   /* Re-sort on team number */
2122
    sort_team_data( 0, S_TEAM, true );                   /* Re-sort on team number */
2035
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
2123
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
2036
    {
2124
    {
2037
        if ( ptr->teamclass == config.nonequestrian_class )
2125
        if ( ptr->isNeData )
2038
            continue;
2126
            continue;
2039
 
2127
 
2040
        g_record( ptr->team, &team_buf );
2128
        g_record( ptr->team, &team_buf );
2041
 
2129
 
2042
        print( "%4d %4.4s %-*s",
2130
        print( "%4d %4.4s %-*s",
Line 2065... Line 2153...
2065
    /*
2153
    /*
2066
     * Now produce a breakdown on a class by class basis 
2154
     * Now produce a breakdown on a class by class basis 
2067
     * Now print out the class placement information
2155
     * Now print out the class placement information
2068
     */
2156
     */
2069
 
2157
 
2070
    sort_team_data( 0, S_CLASS, true );              /* Generate class placement data */
2158
    sort_team_data( 0, S_CLASS, true );             /* Generate class placement data */
2071
    last_class = -1;                             /* Invalid class to start with */
2159
    last_class = -1;                                /* Invalid class to start with */
-
 
2160
    pClass = -1;
2072
 
2161
 
2073
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
2162
    for( ptr = sort_data, i = 0; i < sort_num; i++, ptr++ )
2074
    {
2163
    {
-
 
2164
        if (ptr->isNeData)
-
 
2165
            pClass = config.nonequestrian_class;
-
 
2166
        else
-
 
2167
            pClass = ptr->teamclass;
-
 
2168
 
2075
        /*
2169
        /*
2076
        **  Detect a change in the "class"
2170
        **  Detect a change in the "class"
2077
        **  All data is within the one array of data
2171
        **  All data is within the one array of data
2078
        **  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
2079
        **  The non-equestrian class does this.
2173
        **  The non-equestrian class does this.
2080
        */
2174
        */
2081
        if( last_class != ptr->teamclass )
2175
        if( last_class != pClass )
2082
        {
2176
        {
2083
            if( last_class >= 0 )
2177
            if( last_class >= 0 )
2084
            {
2178
            {
2085
                print_class_stats( last_class, TRUE );
2179
                print_class_stats( last_class, FALSE );
2086
                print_legend(last_class, 1);
2180
                print_legend(last_class, 1);
2087
                close_printer();
2181
                close_printer();
2088
            }
2182
            }
2089
 
2183
 
2090
            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 );
2091
 
2185
 
2092
            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 ) )
2093
                continue;
2187
                continue;
2094
            print_class_header( last_class = ptr->teamclass, FALSE );
2188
            print_class_header( last_class = pClass, FALSE );
2095
        }
2189
        }
2096
 
2190
 
2097
        /*
2191
        /*
2098
        **  Now read in the team record
2192
        **  Now read in the team record
2099
        */
2193
        */
Line 2186... Line 2280...
2186
        csv_print( "%s", "Elapsed Time Number");
2280
        csv_print( "%s", "Elapsed Time Number");
2187
        csv_print( "%s", "Leg Place");
2281
        csv_print( "%s", "Leg Place");
2188
        csv_print( "%s", "Leg End Place");
2282
        csv_print( "%s", "Leg End Place");
2189
        csv_print( "%s", "Leg Class Place");
2283
        csv_print( "%s", "Leg Class Place");
2190
        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
 
2191
        csv_print( "%s", "Manual");
2291
        csv_print( "%s", "Manual");
2192
    }
2292
    }
2193
 
2293
 
2194
    j = 0;
2294
    j = 0;
2195
    csv_print( "%s", "Team Start Time");
2295
    csv_print( "%s", "Team Start Time");
2196
    csv_print( "%s", "Team Start Time Number");
2296
    csv_print( "%s", "Team Start Time Number");
2197
    csv_print( "%s", "Team End Time");
2297
    csv_print( "%s", "Team End Time");
2198
    csv_print( "%s", "Team End Time Number");
2298
    csv_print( "%s", "Team End Time Number");
2199
    csv_print( "%s", "Team Elapsed Time");
2299
    csv_print( "%s", "Team Elapsed Time");
2200
    csv_print( "%s", "Team Elapsed Time Number");
2300
    csv_print( "%s", "Team Elapsed Time Number");
2201
//            csv_print( "%s", team_buf.leg[j].l_place );
-
 
-
 
2301
 
2202
    csv_print( "%s", "Team Leg End Place");
2302
    csv_print( "%s", "Team Leg End Place");
2203
//            csv_print( "%s", team_buf.leg[j].lc_place );
2303
    csv_print( "%s", "Team Event Place");
2204
    csv_print( "%s", "Team Leg Class Place");
2304
    csv_print( "%s", "Team Leg Class Place");
2205
//            csv_print( "%s", team_buf.leg[j].manual );
2305
    csv_print( "%s", "Team Event Class Place");
-
 
2306
 
2206
            
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
 
2207
    csv_print( "%s", "Total Team Age");
2312
    csv_print( "%s", "Total Team Age");
2208
    csv_print( "%s", "Flag:valid Team");
2313
    csv_print( "%s", "Flag:valid Team");
2209
    csv_print( "%s", "Flag:bad_times" );
2314
    csv_print( "%s", "Flag:bad_times" );
2210
    csv_print( "%s", "Flag:disqualified" );
2315
    csv_print( "%s", "Flag:disqualified" );
2211
    csv_print( "%s", "Flag:non_equestrian" );
2316
    csv_print( "%s", "Flag:non_equestrian" );
Line 2267... Line 2372...
2267
                csv_print( "%d", team_buf.leg[j].start );
2372
                csv_print( "%d", team_buf.leg[j].start );
2268
                csv_print( "%s", time_a(team_buf.leg[j].end ));
2373
                csv_print( "%s", time_a(team_buf.leg[j].end ));
2269
                csv_print( "%d", team_buf.leg[j].end );
2374
                csv_print( "%d", team_buf.leg[j].end );
2270
                csv_print( "%s", time_a(team_buf.leg[j].elapsed ));
2375
                csv_print( "%s", time_a(team_buf.leg[j].elapsed ));
2271
                csv_print( "%d", team_buf.leg[j].elapsed );
2376
                csv_print( "%d", team_buf.leg[j].elapsed );
-
 
2377
 
2272
                csv_print( "%d", team_buf.leg[j].l_place );
2378
                csv_print( "%d", team_buf.leg[j].l_place );
2273
                csv_print( "%d", team_buf.leg[j].le_place );
2379
                csv_print( "%d", team_buf.leg[j].le_place );
2274
                csv_print( "%d", team_buf.leg[j].lc_place );
2380
                csv_print( "%d", team_buf.leg[j].lc_place );
2275
                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
 
2276
                csv_print( "%d", team_buf.leg[j].manual );
2389
                csv_print( "%d", team_buf.leg[j].manual );
2277
            }
2390
            }
2278
 
2391
 
2279
            j = 0;
2392
            j = 0;
2280
            csv_print( "%s", time_a(team_buf.leg[j].start ));
2393
            csv_print( "%s", time_a(team_buf.leg[j].start ));
2281
            csv_print( "%d", team_buf.leg[j].start );
2394
            csv_print( "%d", team_buf.leg[j].start );
2282
            csv_print( "%s", time_a(team_buf.leg[j].end ));
2395
            csv_print( "%s", time_a(team_buf.leg[j].end ));
2283
            csv_print( "%d", team_buf.leg[j].end );
2396
            csv_print( "%d", team_buf.leg[j].end );
2284
            csv_print( "%s", time_a(team_buf.leg[j].elapsed ));
2397
            csv_print( "%s", time_a(team_buf.leg[j].elapsed ));
2285
            csv_print( "%d", team_buf.leg[j].elapsed );
2398
            csv_print( "%d", team_buf.leg[j].elapsed );
-
 
2399
 
2286
//            csv_print( "%d", team_buf.leg[j].l_place );
2400
            csv_print( "%d", team_buf.leg[j].l_place );
2287
            csv_print( "%d", team_buf.leg[j].le_place );
2401
            csv_print( "%d", team_buf.leg[j].le_place );
2288
//            csv_print( "%d", team_buf.leg[j].lc_place );
2402
            csv_print( "%d", team_buf.leg[j].lc_place );
2289
            csv_print( "%d", team_buf.leg[j].lec_place );
2403
            csv_print( "%d", team_buf.leg[j].lec_place );
-
 
2404
 
2290
//            csv_print( "%d", team_buf.leg[j].manual );
2405
            csv_print( "%d", sort_aux[team_buf.numb].lq_place[j] );
2291
            
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
 
2292
            csv_print( "%d", age_sum );
2410
            csv_print( "%d", age_sum );
2293
            csv_print( "%d", team_buf.flags.valid );
2411
            csv_print( "%d", team_buf.flags.valid );
2294
            csv_print( "%d", team_buf.flags.bad_times );
2412
            csv_print( "%d", team_buf.flags.bad_times );
2295
            csv_print( "%d", team_buf.flags.disqualified );
2413
            csv_print( "%d", team_buf.flags.disqualified );
2296
            csv_print( "%d", team_buf.flags.non_equestrian );
2414
            csv_print( "%d", team_buf.flags.non_equestrian );
Line 3183... Line 3301...
3183
        **  Then save the teams elapsed place in each leg per class
3301
        **  Then save the teams elapsed place in each leg per class
3184
        */
3302
        */
3185
        sort_team_data( i, S_LC, sortWithEq );
3303
        sort_team_data( i, S_LC, sortWithEq );
3186
        teamclass = -1;
3304
        teamclass = -1;
3187
        teamclassq = -1;
3305
        teamclassq = -1;
-
 
3306
        int ll = -1;
3188
        for( k = 1, j = 1, q = 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++ )
3189
        {
3308
        {
3190
            bool isNe = false;
3309
            bool isNe = false;
3191
            if ( sortWithEq && ptr->teamclass == config.nonequestrian_class  ) {
3310
            if ( sortWithEq && ptr->isNeData  ) {
3192
                if ( !ptr->isNeData)
3311
                if ( !ptr->isNeData)
3193
                    isNe = true;
3312
                    isNe = true;
3194
            }
3313
            }
3195
            else {
3314
            else {
3196
                if (ptr->isNeData)
3315
                if (ptr->isNeData)
Line 3199... Line 3318...
3199
 
3318
 
3200
            // Flag as unplaced NE teams on the EQ leg
3319
            // Flag as unplaced NE teams on the EQ leg
3201
            if (i == 0 || i == config.equestrian_leg) {
3320
            if (i == 0 || i == config.equestrian_leg) {
3202
                if (ptr->flags.bad_times || ptr->flags.disqualified || ptr->flags.vet_check) {
3321
                if (ptr->flags.bad_times || ptr->flags.disqualified || ptr->flags.vet_check) {
3203
                    if (isNe) {
3322
                    if (isNe) {
3204
                        sort_aux[ptr->team].lq_place[i] = -1;
3323
                        sort_aux[ptr->team].lcq_place[i] = -1;
3205
                    } else {
3324
                    } else {
3206
                        sort_aux[ptr->team].lc_place[i] = -1;
3325
                        sort_aux[ptr->team].lc_place[i] = -1;
3207
                    }
3326
                    }
3208
                    continue;
3327
                    continue;
3209
                }
3328
                }
3210
            }
3329
            }
3211
 
3330
 
3212
            if ( i == config.equestrian_leg && ptr->flags.non_equestrian ) {
3331
            if ( i == config.equestrian_leg && ptr->flags.non_equestrian ) {
3213
                if (ptr->isNeData) {
3332
                if (ptr->isNeData) {
3214
                    sort_aux[ptr->team].lq_place[i] = -1;
3333
                    sort_aux[ptr->team].lcq_place[i] = -1;
3215
                } else {
3334
                } else {
3216
                    sort_aux[ptr->team].lc_place[i] = -1;
3335
                    sort_aux[ptr->team].lc_place[i] = -1;
3217
                }
3336
                }
3218
                continue;
3337
                continue;
3219
            }
3338
            }
3220
 
3339
 
3221
            if (isNe) {
3340
            if (ptr->isNeData) {
3222
                if( teamclassq != ptr->teamclass )
3341
                if( teamclassq != ptr->teamclass )
3223
                {
3342
                {
3224
                    q = 1;
3343
                    q = 1;
3225
                    teamclassq = ptr->teamclass;
3344
                    teamclassq = ptr->teamclass;
3226
                }
3345
                }
-
 
3346
//qDebug() << "Team:" << ptr->team << ",Class:" << ptr->teamclass << "," << q;
3227
                sort_aux[ptr->team].lq_place[i] = q++;
3347
                sort_aux[ptr->team].lcq_place[i] = q++;
3228
 
3348
 
3229
            }
3349
            }
3230
            else {
3350
            else {
3231
 
3351
 
3232
                if( teamclass != ptr->teamclass )
3352
                if( teamclass != ptr->teamclass )
3233
                {
3353
                {
3234
                    k = 1;
3354
                    k = 1;
-
 
3355
                    ll = 1;
3235
                    teamclass = ptr->teamclass;
3356
                    teamclass = ptr->teamclass;
3236
                }
3357
                }
-
 
3358
                if (ptr->flags.non_equestrian && sortWithEq)
-
 
3359
                    sort_aux[ptr->team].lc_place[i] = ll++;
-
 
3360
                else
3237
                sort_aux[ptr->team].lc_place[i] = k++;
3361
                    sort_aux[ptr->team].lc_place[i] = k++;
3238
            }
3362
            }
3239
 
3363
 
3240
        }
3364
        }
3241
 
3365
 
3242
        /*
3366
        /*
3243
        **  Sort on end time per class
3367
        **  Sort on end time per class
3244
        **  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
3245
        */
3370
        */
3246
        sort_team_data( i, S_LEC, sortWithEq );
3371
        sort_team_data( i, S_LEC, sortWithEq );
3247
        teamclass = -1;
3372
        teamclass = -1;
3248
        teamclassq = -1;
3373
        teamclassq = -1;
3249
        for( k = 1, j = 1, q = 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++ )
3250
        {
3375
        {
3251
            bool isNe = false;
-
 
3252
            if ( sortWithEq &&  ptr->teamclass == config.nonequestrian_class  ) {
-
 
3253
                if ( !ptr->isNeData)
-
 
3254
                    isNe = true;
-
 
3255
            }
-
 
3256
            else {
-
 
3257
                if (ptr->isNeData)
-
 
3258
                    isNe = true;
-
 
3259
            }
-
 
3260
 
3376
 
3261
            if (i == 0 || i == config.equestrian_leg || sort_afterEquestrianLeg) {
3377
            // All teams with bad data
3262
                if (ptr->flags.bad_times || ptr->flags.disqualified || ptr->flags.vet_check) {
3378
            if (ptr->flags.bad_times || ptr->flags.disqualified ) {
3263
                    if (isNe) {
-
 
3264
                        sort_aux[ptr->team].leq_place[i] = -1;
3379
                sort_aux[ptr->team].lec_place[i] = -1;
3265
                    } else {
-
 
3266
                        sort_aux[ptr->team].lec_place[i] = -1;
3380
                sort_aux[ptr->team].lecq_place[i] = -1;
3267
                    }
-
 
3268
                    continue;
3381
                continue;
3269
                }
-
 
3270
            }
3382
            }
3271
 
3383
 
-
 
3384
            // NE team - the full entry
3272
            // Flag as unplaced NE teams on the EQ leg
3385
            // Flag as unplaced NE teams on the EQ leg
3273
            // Flag as unplaced NE teams after the EQ leg
3386
            // Flag as unplaced NE teams after the EQ leg
3274
            // Flag as unplaced in overall (leg:0) NE teams
3387
            // Flag as unplaced in overall (leg:0) NE teams
3275
            if ( (i == config.equestrian_leg || sort_afterEquestrianLeg || i == 0 ) && ptr->flags.non_equestrian ) {
3388
            if (!ptr->isNeData  && ptr->flags.non_equestrian) {
3276
                if (ptr->isNeData) {
-
 
3277
                    sort_aux[ptr->team].leq_place[i] = -1;
3389
                if (i == 0 || i == config.equestrian_leg || sort_afterEquestrianLeg ) {
3278
                } else {
-
 
3279
                    sort_aux[ptr->team].lec_place[i] = -1;
3390
                    sort_aux[ptr->team].lec_place[i] = -1;
-
 
3391
                    continue;
-
 
3392
 
-
 
3393
                }
-
 
3394
 
-
 
3395
            //  NE Team - the duplicate entry
-
 
3396
            // Flag as unplaced NE teams after the EQ leg
-
 
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
                   }
3280
                }
3413
                }
3281
                continue;
-
 
3282
            }
3414
            }
3283
 
3415
 
-
 
3416
 
3284
            if (isNe) {
3417
            if (ptr->isNeData) {
3285
                if( teamclassq != ptr->teamclass )
3418
                if( teamclassq != ptr->teamclass )
3286
                {
3419
                {
3287
                    q = 1;
3420
                    q = 1;
3288
                    teamclassq = ptr->teamclass;
3421
                    teamclassq = ptr->teamclass;
3289
                }
3422
                }
3290
                sort_aux[ptr->team].leq_place[i] = q++;
3423
                sort_aux[ptr->team].lecq_place[i] = q++;
3291
            }
3424
            }
3292
            else {
3425
            else {
3293
                if( teamclass != ptr->teamclass )
3426
                if( teamclass != ptr->teamclass )
3294
                {
3427
                {
3295
                    k = 1;
3428
                    k = 1;
Line 3301... Line 3434...
3301
        }
3434
        }
3302
    }
3435
    }
3303
 
3436
 
3304
    /*
3437
    /*
3305
    **  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
3306
    */
3441
    */
3307
    for( i = config.min_team; i <= config.max_team; i++ )
3442
    for( i = config.min_team; i <= config.max_team; i++ )
3308
    {
3443
    {
3309
        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 ) )
3310
        {
3445
        {
Line 3402... Line 3537...
3402
    if( sort_mode == S_TEAM )
3537
    if( sort_mode == S_TEAM )
3403
        return ( a->team - b->team );
3538
        return ( a->team - b->team );
3404
 
3539
 
3405
    /*
3540
    /*
3406
    **  Sorting on Class and Team Number
3541
    **  Sorting on Class and Team Number
-
 
3542
    **  Sort NE entries as a class of there own
3407
    */
3543
    */
3408
    if( sort_mode == S_CLASS )
3544
    if( sort_mode == S_CLASS )
3409
    {
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
 
3410
        if( a->teamclass != b->teamclass )
3553
        if( a->teamclass != b->teamclass )
3411
            return ( a->teamclass - b->teamclass );
3554
            return ( a->teamclass - b->teamclass );
3412
        else
3555
        else
3413
            return ( a->team - b->team );
3556
            return ( a->team - b->team );
3414
    }
3557
    }
3415
 
3558
 
3416
    /*
3559
    /*
3417
    **  Sorting within a class
3560
    **  Sorting within a class
3418
    **  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
3419
    */
3564
    */
3420
    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 */
3421
        if (a->teamclass != b->teamclass)
3566
        if ( a->isNeData || b->isNeData) {
3422
            return ( a->teamclass - b->teamclass );
3567
            if ( !(a->isNeData && b->isNeData ) )
3423
    }
-
 
3424
 
-
 
3425
    /*
-
 
3426
    **  Always put the nonequestrian_class at the end
-
 
3427
    **  Simplifies the creation of ordered lists as these
-
 
3428
    **  Entries are not present in the main body
-
 
3429
    */
-
 
3430
    if ( sort_withEquestrian && ( a->teamclass == config.nonequestrian_class ||  b->teamclass == config.nonequestrian_class ))
-
 
3431
    {
-
 
3432
        if ( a->teamclass == config.nonequestrian_class &&  b->teamclass == config.nonequestrian_class )
-
 
3433
        {
-
 
3434
            /*
-
 
3435
            **  Both are non equestrian
-
 
3436
            **      S_LC_NE - Elapsed times per class, with NE sorted by real class
-
 
3437
            **                Only used in awards
3568
                return ( a->isNeData ? 1 : -1 );
3438
            */
-
 
3439
            if (sort_mode == S_LC_NE )
-
 
3440
            {
3569
        } else {
3441
                if ( a->real_teamclass != b->real_teamclass )
3570
            if (a->teamclass != b->teamclass) {
3442
                {
-
 
3443
                    return ( a->real_teamclass - b->real_teamclass );
3571
                return ( a->teamclass - b->teamclass );
3444
                }
-
 
3445
            }
3572
            }
3446
        }
3573
        }
3447
        else
-
 
3448
        {
-
 
3449
            /*
-
 
3450
            **  Only one in non-equestrian
-
 
3451
            **  Place Non-equestrian AFTER equestrian
-
 
3452
            */
-
 
3453
            return ( a->teamclass == config.nonequestrian_class ? 1 : -1 );
-
 
3454
        }
-
 
3455
 
-
 
3456
    }
3574
    }
3457
 
3575
 
3458
 
-
 
3459
    /*
3576
    /*
3460
    **  Now we need to examine the times as we have sorted
3577
    **  Now we need to examine the times as we have sorted
3461
    **  on every thing else.
3578
    **  on every thing else.
3462
    **
3579
    **
3463
    **  If one of the teams has bad_times, then that team is placed
3580
    **  If one of the teams has bad_times, then that team is placed
Line 3601... Line 3718...
3601
      */
3718
      */
3602
      default:
3719
      default:
3603
        return ( 0 );
3720
        return ( 0 );
3604
    }
3721
    }
3605
 
3722
 
-
 
3723
    if (sort_mode != S_LC_NE) {
3606
    /*
3724
    /*
3607
     ** If we are ignore Equestrian config then place the Equestrian data last
3725
     ** If we are ignore Equestrian config then place the Equestrian data last
3608
    */
3726
    */
3609
 
-
 
3610
#if 1
-
 
3611
    if (sort_withEquestrian) {
3727
    if (sort_withEquestrian) {
3612
        if (a->isNeData != b->isNeData)
3728
        if (a->isNeData != b->isNeData)
3613
            return ( a->isNeData ? 1 : -1 );
3729
            return ( a->isNeData ? 1 : -1 );
3614
    }
3730
    }
3615
#endif
3731
 
3616
 
3732
 
3617
    if ( a->team == b->team) {
3733
    if ( a->team == b->team) {
3618
        return ( a->isNeData ? 1 : -1 );
3734
        return ( a->isNeData ? 1 : -1 );
3619
    }
3735
    }
-
 
3736
    }
3620
 
3737
 
3621
    /*
3738
    /*
3622
    **  Finally. Compare the required team times
3739
    **  Finally. Compare the required team times
3623
    */
3740
    */
3624
    if( ta == tb )
3741
    if( ta == tb )
Line 3760... Line 3877...
3760
                    ptr->lege[j] = team_buf.leg[j].elapsed;
3877
                    ptr->lege[j] = team_buf.leg[j].elapsed;
3761
                    ptr->leg[j] = team_buf.leg[j].end;
3878
                    ptr->leg[j] = team_buf.leg[j].end;
3762
                }
3879
                }
3763
                ptr->start = team_buf.leg[0].start;
3880
                ptr->start = team_buf.leg[0].start;
3764
                ptr->teamclass = team_buf.teamclass;
3881
                ptr->teamclass = team_buf.teamclass;
3765
                ptr->real_teamclass = team_buf.teamclass;
-
 
3766
 
-
 
3767
                ptr->flags = team_buf.flags;
3882
                ptr->flags = team_buf.flags;
3768
 
3883
 
3769
                // Add a few flags to simplify processing
3884
                // Add a few flags to simplify processing
3770
                //  Vetted out teams to be included inthe fastest calcs - except for Equestian Leg
3885
                //  Vetted out teams to be included inthe fastest calcs - except for Equestian Leg
3771
                //  Bodgey teams are not sorted by place - only after all places and then by team number
3886
                //  Bodgey teams are not sorted by place - only after all places and then by team number
Line 3811... Line 3926...
3811
                            last->lege[0] = ptr->lege[0] ;
3926
                            last->lege[0] = ptr->lege[0] ;
3812
                        }
3927
                        }
3813
                    }
3928
                    }
3814
 
3929
 
3815
                    last->start = ptr->start = team_buf.leg[0].start;
3930
                    last->start = ptr->start = team_buf.leg[0].start;
3816
                    ptr->teamclass = config.nonequestrian_class;
-
 
3817
                    ptr->real_teamclass = team_buf.teamclass;
3931
                    ptr->teamclass = team_buf.teamclass;
3818
                    ptr->flags = team_buf.flags;
3932
                    ptr->flags = team_buf.flags;
3819
 
3933
 
3820
                    ptr++;
3934
                    ptr++;
3821
                    sort_num++;
3935
                    sort_num++;
3822
                }
3936
                }
3823
#endif
3937
#endif
3824
            }
3938
            }
3825
        }
3939
        }
3826
    }
3940
    }
3827
 
3941
 
-
 
3942
#if 0
3828
    // Debug
3943
    // Debug zzz
3829
//    qDebug() << "--- Start ---";
3944
    qDebug() << "--- Start ---";
3830
 
-
 
3831
//    sort_team_data( 0, S_L, 1 );
3945
    sort_team_data( 0, S_LC, 1 );
3832
 
3946
 
3833
//    for( j = 1, ptr = sort_data; j <= sort_num; j++, ptr++ )
3947
    for( j = 1, ptr = sort_data; j <= sort_num; j++, ptr++ )
3834
//    {
3948
    {
3835
//        qDebug() << "T:" << ptr->team
3949
        qDebug() << "T:" << ptr->team
3836
//                << "Class:" << ptr->teamclass
3950
                << "Class:" << ptr->teamclass
3837
//                << "NEData:" << (ptr->isNeData? 1:0)
3951
                << "NEData:" << (ptr->isNeData? 1:0)
3838
//                << "iLP:" << (ptr->flags.notInLP ? 1:0)
3952
                << "iLP:" << (ptr->flags.notInLP ? 1:0)
3839
//                << "iF:" << (ptr->flags.notInFastest ? 1:0)
3953
                << "iF:" << (ptr->flags.notInFastest ? 1:0)
3840
//                << "Valid:" << (ptr->flags.valid ? 1:0)
3954
                << "Valid:" << (ptr->flags.valid ? 1:0)
3841
//                << "NE:" << (ptr->flags.non_equestrian? 1:0)
3955
                << "NE:" << (ptr->flags.non_equestrian? 1:0)
3842
//                << "B:" << (ptr->flags.bad_times ? 1 : 0 )
3956
                << "B:" << (ptr->flags.bad_times ? 1 : 0 )
3843
//                << "D:" << (ptr->flags.disqualified ? 1:0 )
3957
                << "D:" << (ptr->flags.disqualified ? 1:0 )
3844
//                << "V:" << (ptr->flags.vet_check ? 1:0 )
3958
                << "V:" << (ptr->flags.vet_check ? 1:0 )
3845
//                << "LE0:" << ptr->lege[0]
3959
                << "LE0:" << ptr->lege[0]
3846
//                << "L0:" << ptr->leg[0]
3960
                << "L0:" << ptr->leg[0]
3847
//                << "LE1:" << ptr->lege[3]
3961
                << "LE1:" << ptr->lege[3]
3848
//                ;
3962
                ;
3849
//    }
3963
    }
-
 
3964
    qDebug() << "-----------------------------------End---";
-
 
3965
#endif
3850
 
3966
 
3851
//    qDebug() << "-----------------------------------End---";
-
 
3852
    return ( TRUE );
3967
    return ( TRUE );
3853
}
3968
}
3854
 
3969
 
3855
/*========================================================================
3970
/*========================================================================
3856
 *
3971
 *
Line 3899... Line 4014...
3899
        */
4014
        */
3900
        if (ptr->flags.notInFastest) {
4015
        if (ptr->flags.notInFastest) {
3901
            continue;
4016
            continue;
3902
        }
4017
        }
3903
 
4018
 
3904
        //if( ptr->flags.bad_times || ptr->flags.disqualified  )
4019
        short teamClass = ptr->teamclass;
3905
        //    continue;
-
 
3906
 
4020
 
3907
        /*
4021
 
3908
        **  Ignore non-Equestrian, unless we are processing the psuedo NE class
4022
        /*  Don't include the psuedo NE data items in the calculations (unless processing NE class)
3909
        **  2021: Now allow NE to be considered in the fastest stats
4023
        **  They are duplicates of other data
3910
        */
4024
        */
3911
        //if ( ptr->teamclass != config.nonequestrian_class && ptr->flags.non_equestrian)
4025
        if (j == config.nonequestrian_class) {
-
 
4026
            if ( !ptr->isNeData)
3912
        //    continue;
4027
                continue;
-
 
4028
        }
-
 
4029
 
-
 
4030
        if (ptr->isNeData)
-
 
4031
            teamClass = config.nonequestrian_class;
3913
 
4032
 
3914
 
4033
 
3915
        for( j = 0; j <= config.num_legs; j++ )
4034
        for( j = 0; j <= config.num_legs; j++ )
3916
        {
4035
        {
3917
            if( ptr->lege[j] <= 0 )              /* Ignore bad data */
4036
            if( ptr->lege[j] <= 0 )              /* Ignore bad data */
Line 3930... Line 4049...
3930
            /* If this is the Equestrian Leg and the team is a Non-Equestrian Team, then don't include
4049
            /* If this is the Equestrian Leg and the team is a Non-Equestrian Team, then don't include
3931
            ** it into the stats.
4050
            ** it into the stats.
3932
            **
4051
            **
3933
            ** If this is a NE team then don't consider it to be fastest overall
4052
            ** If this is a NE team then don't consider it to be fastest overall
3934
            */
4053
            */
3935
            if ( ptr->teamclass != config.nonequestrian_class && ptr->flags.non_equestrian &&  (j == config.equestrian_leg || j== 0)) {
4054
            if ( !ptr->isNeData && ptr->flags.non_equestrian &&  (j == config.equestrian_leg || j== 0)) {
3936
                continue;
4055
                continue;
3937
            }
4056
            }
3938
 
4057
 
3939
            /*
4058
            /*
3940
            **  Determine fastest team : overall
4059
            **  Determine fastest team : overall
3941
            **  Ignore the non-equestrian data as this is in the list twice
4060
            **  Ignore the non-equestrian data as this is in the list twice
3942
            */
4061
            */
3943
            if( ( ptr->lege[j] < stats.fast.time[j][0] )
4062
            if( ( ptr->lege[j] < stats.fast.time[j][0] )
3944
                || ( stats.fast.time[j][0] < 0 ) )
4063
                || ( stats.fast.time[j][0] < 0 ) )
3945
            {
4064
            {
3946
                if ( ptr->teamclass != config.nonequestrian_class )
4065
                if ( !ptr->isNeData )
3947
                {
4066
                {
3948
                    stats.fast.team[j][0] = ptr->team;
4067
                    stats.fast.team[j][0] = ptr->team;
3949
                    stats.fast.time[j][0] = ptr->lege[j];
4068
                    stats.fast.time[j][0] = ptr->lege[j];
3950
                }
4069
                }
3951
            }
4070
            }
3952
 
4071
 
3953
            /*
4072
            /*
3954
            **  Determine fastest team : within a class
4073
            **  Determine fastest team : within a class
3955
            */
4074
            */
3956
            if( ( ptr->lege[j] < stats.fast.time[j][ptr->teamclass] )
4075
            if( ( ptr->lege[j] < stats.fast.time[j][teamClass] )
3957
                || stats.fast.time[j][ptr->teamclass] < 0 )
4076
                || stats.fast.time[j][teamClass] < 0 )
3958
            {
4077
            {
3959
                stats.fast.team[j][ptr->teamclass] = ptr->team;
4078
                stats.fast.team[j][teamClass] = ptr->team;
3960
                stats.fast.time[j][ptr->teamclass] = ptr->lege[j];
4079
                stats.fast.time[j][teamClass] = ptr->lege[j];
3961
            }
4080
            }
3962
 
4081
 
3963
            /*
4082
            /*
3964
            **  Sum the end times : overall
4083
            **  Sum the end times : overall
3965
            */
4084
            */
3966
            if ( ptr->teamclass != config.nonequestrian_class )
4085
            if ( !ptr->isNeData )
3967
            {
4086
            {
3968
                stats.average[j][0] += ptr->lege[j];
4087
                stats.average[j][0] += ptr->lege[j];
3969
                stats.team[j][0]++;
4088
                stats.team[j][0]++;
3970
            }
4089
            }
3971
 
4090
 
3972
 
4091
 
3973
            /*
4092
            /*
3974
            **  Sum the end times : within a class
4093
            **  Sum the end times : within a class
3975
            */
4094
            */
3976
            stats.average[j][ptr->teamclass] += ptr->lege[j];
4095
            stats.average[j][teamClass] += ptr->lege[j];
3977
            stats.team[j][ptr->teamclass]++;
4096
            stats.team[j][teamClass]++;
3978
        }
4097
        }
3979
    }
4098
    }
3980
 
4099
 
3981
    /*
4100
    /*
3982
     * Calculate the averages 
4101
     * Calculate the averages