Subversion Repositories svn1-original

Rev

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

Rev 353 Rev 354
Line 1500... Line 1500...
1500
                /*
1500
                /*
1501
                **  Ensure we have a valid team
1501
                **  Ensure we have a valid team
1502
                **  Can't award disqualified teams
1502
                **  Can't award disqualified teams
1503
                **  Can't award NE teams unless its a NE award
1503
                **  Can't award NE teams unless its a NE award
1504
                */
1504
                */
1505
                if ( ptr->flags.bad_times )
1505
                if ( ptr->flags.bad_times || ptr->flags.disqualified || ptr->flags.vet_check || !ptr->flags.valid )
1506
                    break;
1506
                    break;
1507
 
1507
 
1508
                if ( ptr->teamclass != config.nonequestrian_class  && ptr->flags.non_equestrian )
1508
                if ( ptr->teamclass != config.nonequestrian_class  && ptr->flags.non_equestrian )
1509
                    break;
1509
                    break;
1510
 
1510
 
Line 1674... Line 1674...
1674
                    /*
1674
                    /*
1675
                    **  Ensure we have a valid team
1675
                    **  Ensure we have a valid team
1676
                    **  Can't award disqualified teams
1676
                    **  Can't award disqualified teams
1677
                    **  Can't award NE teams unless its a NE award
1677
                    **  Can't award NE teams unless its a NE award
1678
                    */
1678
                    */
1679
                    if ( ptr->flags.bad_times )
1679
                    if ( ptr->flags.bad_times || ptr->flags.disqualified || ptr->flags.vet_check || !ptr->flags.valid )
1680
                        break;
1680
                        break;
1681
 
1681
 
1682
                    if ( ptr->teamclass != config.nonequestrian_class  && ptr->flags.non_equestrian )
1682
                    if ( ptr->teamclass != config.nonequestrian_class  && ptr->flags.non_equestrian )
1683
                        break;
1683
                        break;
1684
 
1684
 
Line 2619... Line 2619...
2619
 *      This routine is called to fill a print team_buffer - to allow for
2619
 *      This routine is called to fill a print team_buffer - to allow for
2620
 *      multiple calls to this function ( before the data is used ) a number
2620
 *      multiple calls to this function ( before the data is used ) a number
2621
 *      of static team_buffers are maintained
2621
 *      of static team_buffers are maintained
2622
 *
2622
 *
2623
 *  Parameters:
2623
 *  Parameters:
2624
 *      num         place - if not bad_times
2624
 *      num         place - if a valid time
2625
 *      disq        Disqualified flag
2625
 *      disq        Disqualified flag
2626
 *      time        Time data is based on
2626
 *      time        Time data is based on
2627
 *
2627
 *
2628
 *  Returns:
2628
 *  Returns:
2629
 *      This function returns a pointer to the character string for the
2629
 *      This function returns a pointer to the character string for the
2630
 *      number or a pointer to a bad_times string.
2630
 *      number or a pointer to a status string.
2631
 *
2631
 *
2632
 *========================================================================*/
2632
 *========================================================================*/
2633
 
2633
 
2634
const char       *pi_place( int num, int disq, time_t time )
2634
const char       *pi_place( int num, int disq, time_t time )
2635
{
2635
{
Line 2661... Line 2661...
2661
 *      This routine is called to fill a print team_buffer - to allow for
2661
 *      This routine is called to fill a print team_buffer - to allow for
2662
 *      multiple calls to this function ( before the data is used ) a number
2662
 *      multiple calls to this function ( before the data is used ) a number
2663
 *      of static team_buffers are maintained
2663
 *      of static team_buffers are maintained
2664
 *
2664
 *
2665
 *  Parameters:
2665
 *  Parameters:
2666
 *      num         place - if not bad_times
2666
 *      num         place - if valid
2667
 *      disq        Disqualified flag
2667
 *      disq        Disqualified flag
2668
 *      vflag       Team is vet checked
2668
 *      vflag       Team is vet checked
2669
 *
2669
 *
2670
 *  Returns:
2670
 *  Returns:
2671
 *      This function returns a pointer to the character string for the
2671
 *      This function returns a pointer to the character string for the
2672
 *      number or a pointer to a bad_times string.
2672
 *      number or a pointer to a status string.
2673
 *
2673
 *
2674
 *========================================================================*/
2674
 *========================================================================*/
2675
 
2675
 
2676
const char *pr_place( int num, int disq, bool vflag )
2676
const char *pr_place( int num, int disq, bool vflag )
2677
{
2677
{
Line 2704... Line 2704...
2704
 *      This routine is called to fill a print team_buffer - to allow for
2704
 *      This routine is called to fill a print team_buffer - to allow for
2705
 *      multiple calls to this function ( before the data is used ) a number
2705
 *      multiple calls to this function ( before the data is used ) a number
2706
 *      of static team_buffers are maintained
2706
 *      of static team_buffers are maintained
2707
 *
2707
 *
2708
 *  Parameters:
2708
 *  Parameters:
2709
 *      num         place - if not bad_times
2709
 *      num         place - if valid time
2710
 *      disq        Disqualified flag
2710
 *      disq        Disqualified flag
2711
 *      vflag       Flag VetChecked team
2711
 *      vflag       Flag VetChecked team
2712
 *      flag        Flag NE data
2712
 *      flag        Flag NE data
2713
 *
2713
 *
2714
 *  Returns:
2714
 *  Returns:
2715
 *      This function returns a pointer to the character string for the
2715
 *      This function returns a pointer to the character string for the
2716
 *      number or a pointer to a bad_times string.
2716
 *      number or a pointer to a status string.
2717
 *
2717
 *
2718
 *========================================================================*/
2718
 *========================================================================*/
2719
const char *pn_place( int num, int disq, bool vflag, bool flag )
2719
const char *pn_place( int num, int disq, bool vflag, bool flag )
2720
{
2720
{
2721
    static char store[2][5];                     /* 2 stores for 4 digit numbers */
2721
    static char store[2][5];                     /* 2 stores for 4 digit numbers */
Line 2752... Line 2752...
2752
 *      and the report process can be aborted
2752
 *      and the report process can be aborted
2753
 *
2753
 *
2754
 *  Parameters:
2754
 *  Parameters:
2755
 *      leg             Leg to test
2755
 *      leg             Leg to test
2756
 *      mode            Either end or elapsed times to be tested
2756
 *      mode            Either end or elapsed times to be tested
-
 
2757
 *                          C_END     - Printing in Leg Finishing Time
-
 
2758
 *                          C_DISQUAL - Interim results
-
 
2759
 *                          C_ELAPSED - Elapsed times
2757
 *
2760
 *
2758
 *  Returns:
2761
 *  Returns:
2759
 *      Returns FALSE if the report operation is to be aborted
2762
 *      Returns FALSE if the report operation is to be aborted
2760
 *
2763
 *
2761
 *========================================================================*/
2764
 *========================================================================*/
Line 2783... Line 2786...
2783
            t = ptr->lege;
2786
            t = ptr->lege;
2784
        else
2787
        else
2785
            t = ptr->leg;
2788
            t = ptr->leg;
2786
 
2789
 
2787
 
2790
 
2788
        ptr->flags.bad_times = ptr->flags.disqualified;
2791
        // If the team is duff, then don;t include in Event or Leg Calcs
2789
        if( ! ptr->flags.bad_times )
2792
        if( !ptr->flags.valid || ptr->flags.bad_times || ptr->flags.disqualified)
2790
        {
2793
        {
-
 
2794
            ptr->flags.notInEP = TRUE;
-
 
2795
            ptr->flags.notInLP = TRUE;
-
 
2796
        }
-
 
2797
        else
-
 
2798
        {
-
 
2799
            // If any of the leg times are duff, then don't include the leg Event Calcs
-
 
2800
 
2791
            if( leg <= 0 )
2801
            if( leg <= 0 )
2792
            {
2802
            {
2793
                for( k = 0; k <= config.num_legs; k++ )
2803
                for( k = 0; k <= config.num_legs; k++ )
2794
                {
2804
                {
2795
                    if ( !(config.equestrian_leg && ptr->flags.non_equestrian && config.equestrian_leg == k  ))
2805
                    if ( !(config.equestrian_leg && ptr->flags.non_equestrian && config.equestrian_leg == k  ))
Line 2801... Line 2811...
2801
                bad_leg = t[leg] <= 0;
2811
                bad_leg = t[leg] <= 0;
2802
            }
2812
            }
2803
 
2813
 
2804
            if( bad_leg )
2814
            if( bad_leg )
2805
            {
2815
            {
2806
                ptr->flags.bad_times = TRUE;
2816
                ptr->flags.notInEP = TRUE;
2807
                
2817
                
2808
                if ( ! report_all )
2818
                if ( ! report_all )
2809
                {
2819
                {
2810
                    qDebug( "Team with incorrect time information: %d", ptr->team  );
2820
                    qDebug( "Team with incorrect time information: %d", ptr->team  );
2811
                    bad++;
2821
                    bad++;
Line 3122... Line 3132...
3122
        sort_team_data( i, S_LE, sortWithEq);
3132
        sort_team_data( i, S_LE, sortWithEq);
3123
        for( j = 1, k = 1, q = 1, ptr = sort_data; j <= sort_num; ptr++, j++ )
3133
        for( j = 1, k = 1, q = 1, ptr = sort_data; j <= sort_num; ptr++, j++ )
3124
        {
3134
        {
3125
            if (ptr->isNeData) {
3135
            if (ptr->isNeData) {
3126
                sort_aux[ptr->team].leq_place[i] = q++;
3136
                sort_aux[ptr->team].leq_place[i] = q++;
3127
            }
-
 
3128
            else {
3137
            } else {
3129
 
-
 
3130
                sort_aux[ptr->team].le_place[i] = k++;
3138
                sort_aux[ptr->team].le_place[i] = k++;
3131
            }
3139
            }
3132
        }
3140
        }
3133
 
3141
 
3134
        /*
3142
        /*
Line 3265... Line 3273...
3265
    for( j = 1; j <= sort_num; j++, ptr++ )
3273
    for( j = 1; j <= sort_num; j++, ptr++ )
3266
    {
3274
    {
3267
        ptr->place = j;
3275
        ptr->place = j;
3268
    }
3276
    }
3269
 
3277
 
-
 
3278
    qDebug() << "sort_team_data: Leg:" << leg << ",M:" << mode << ",E:" << withEq;
-
 
3279
    //for( j = 1, ptr = sort_data; j <= sort_num; j++, ptr++ )
-
 
3280
    //{
-
 
3281
    //    qDebug() << "T:" << ptr->team << " Class:" << ptr->teamclass << " V:" << ptr->flags.valid << "NE:" << ptr->isNeData << "B:" << ptr->flags.bad_times <<"D:" << ptr->flags.disqualified <<"V:" << ptr->flags.vet_check << "LP:" << ptr->flags.notInLP << "EP:" << ptr->flags.notInEP <<"F:" << ptr->flags.notInFastest;
-
 
3282
    //}
-
 
3283
 
3270
}
3284
}
3271
 
3285
 
3272
/*========================================================================
3286
/*========================================================================
3273
 *
3287
 *
3274
 *  qsort comparison function
3288
 *  qsort comparison function
Line 3370... Line 3384...
3370
    **
3384
    **
3371
    **  If not sorting within a class (ie Overall), then Non_Equestrian
3385
    **  If not sorting within a class (ie Overall), then Non_Equestrian
3372
    **  is better than a bad time. Places NE before disqualified
3386
    **  is better than a bad time. Places NE before disqualified
3373
    **
3387
    **
3374
    */
3388
    */
-
 
3389
    bool aNoSort = false;
-
 
3390
    bool bNoSort = false;
-
 
3391
 
-
 
3392
    if ( sort_leg != 0 && (sort_mode == S_LC || sort_mode == S_L ) ) {
-
 
3393
        aNoSort = a->flags.notInLP;
-
 
3394
        bNoSort = b->flags.notInLP;
-
 
3395
    }
-
 
3396
 
-
 
3397
    if ( sort_withEquestrian && (sort_mode == S_LC || sort_mode == S_L ) ) {
-
 
3398
        if (a->flags.non_equestrian || a->flags.vet_check)
-
 
3399
            aNoSort = true;
-
 
3400
        if (b->flags.non_equestrian || b->flags.vet_check)
-
 
3401
            bNoSort = true;
-
 
3402
    }
-
 
3403
 
-
 
3404
    if (a->flags.bad_times || a->flags.disqualified || !a->flags.valid)
-
 
3405
        aNoSort = true;
-
 
3406
 
3375
    if( a->flags.bad_times || b->flags.bad_times || ( sort_withEquestrian && a->flags.non_equestrian) || (sort_withEquestrian && b->flags.non_equestrian))  /* Valid data has precedence */
3407
    if (b->flags.bad_times || b->flags.disqualified || !b->flags.valid)
-
 
3408
        bNoSort = true;
-
 
3409
 
-
 
3410
    if ( sort_mode == S_FIN || sort_mode == S_IFIN ) {
-
 
3411
        if (a->flags.vet_check)
-
 
3412
            aNoSort = true;
-
 
3413
        if (b->flags.vet_check)
-
 
3414
            bNoSort = true;
-
 
3415
    }
-
 
3416
 
-
 
3417
    if (aNoSort && bNoSort)
-
 
3418
        return ( a->team - b->team );
-
 
3419
 
-
 
3420
    if (aNoSort || bNoSort)
-
 
3421
        return ( aNoSort ? 1 : -1 );
-
 
3422
 
-
 
3423
    if( sort_withEquestrian && sort_mode != S_FIN && sort_mode != S_IFIN )
3376
    {
3424
    {
3377
        if( a->flags.bad_times && b->flags.bad_times )
3425
        if( a->flags.non_equestrian && b->flags.non_equestrian )
3378
        {
-
 
3379
            return ( a->team - b->team );
-
 
3380
        }
-
 
3381
        else if( a->flags.bad_times || b->flags.bad_times )
-
 
3382
        {
3426
        {
-
 
3427
            /*
-
 
3428
            **  Both are non equestrian
-
 
3429
            **  Let the time sort operate ...
-
 
3430
            */
3383
            return ( a->flags.bad_times ? 1 : -1 );
3431
            //return ( a->team - b->team );
3384
        }
3432
        }
3385
        if( sort_mode != S_FIN && sort_mode != S_IFIN )
3433
        else if( a->flags.non_equestrian || b->flags.non_equestrian )
3386
        {
3434
        {
3387
            if( a->flags.non_equestrian && b->flags.non_equestrian )
-
 
3388
            {
-
 
3389
                /*
-
 
3390
                **  Both are non equestrian
-
 
3391
                **  Let the time sort operate ...
-
 
3392
                */
-
 
3393
                //return ( a->team - b->team );
-
 
3394
            }
-
 
3395
            else
-
 
3396
            {
-
 
3397
                /* One is equestrian */
3435
            /* One is equestrian */
3398
                /* Good times better than NE */
3436
            /* Good times better than NE */
3399
                return ( a->flags.non_equestrian ? 1 : -1 );
3437
            return ( a->flags.non_equestrian ? 1 : -1 );
3400
            }
-
 
3401
        }
3438
        }
3402
    }
3439
    }
3403
 
3440
 
-
 
3441
 
-
 
3442
 
-
 
3443
//    if( a->flags.bad_times || b->flags.bad_times || ( sort_withEquestrian && a->flags.non_equestrian) || (sort_withEquestrian && b->flags.non_equestrian))  /* Valid data has precedence */
-
 
3444
//    {
-
 
3445
//        if( a->flags.bad_times && b->flags.bad_times )
-
 
3446
//        {
-
 
3447
//            return ( a->team - b->team );
-
 
3448
//        }
-
 
3449
//        else if( a->flags.bad_times || b->flags.bad_times )
-
 
3450
//        {
-
 
3451
//            return ( a->flags.bad_times ? 1 : -1 );
-
 
3452
//        }
-
 
3453
//        else if ( sort_leg != 0 && (sort_mode == S_L || sort_mode == S_LC))
-
 
3454
//        {
-
 
3455
//            /* */
-
 
3456
//        }
-
 
3457
//        if( sort_mode != S_FIN && sort_mode != S_IFIN )
-
 
3458
//        {
-
 
3459
//            if( a->flags.non_equestrian && b->flags.non_equestrian )
-
 
3460
//            {
-
 
3461
//                /*
-
 
3462
//                **  Both are non equestrian
-
 
3463
//                **  Let the time sort operate ...
-
 
3464
//                */
-
 
3465
//                //return ( a->team - b->team );
-
 
3466
//            }
-
 
3467
//            else
-
 
3468
//            {
-
 
3469
//                /* One is equestrian */
-
 
3470
//                /* Good times better than NE */
-
 
3471
//                return ( a->flags.non_equestrian ? 1 : -1 );
-
 
3472
//            }
-
 
3473
//        }
-
 
3474
//    }
-
 
3475
 
3404
    /*
3476
    /*
3405
    **  Before we sort on times we must determine which time to
3477
    **  Before we sort on times we must determine which time to
3406
    **  use. Finish time, Leg end times, Leg Elapsed times.
3478
    **  use. Finish time, Leg end times, Leg Elapsed times.
3407
    */
3479
    */
3408
 
3480
 
Line 3477... Line 3549...
3477
 
3549
 
3478
    /*
3550
    /*
3479
     ** If we are ignore Equestrian config then place the Equestrian data last
3551
     ** If we are ignore Equestrian config then place the Equestrian data last
3480
    */
3552
    */
3481
 
3553
 
3482
#if 0
-
 
3483
    if (a->isNeData != b->isNeData) {
-
 
3484
         return ( a->isNeData ? 1 : -1 );
-
 
3485
    }
-
 
3486
#endif
-
 
3487
 
-
 
3488
#if 1
3554
#if 1
3489
    if (sort_withEquestrian) {
3555
    if (sort_withEquestrian) {
3490
        if (a->isNeData != b->isNeData)
3556
        if (a->isNeData != b->isNeData)
3491
            return ( a->isNeData ? 1 : -1 );
3557
            return ( a->isNeData ? 1 : -1 );
3492
    }
3558
    }
Line 3573... Line 3639...
3573
bool load_report_data(void)
3639
bool load_report_data(void)
3574
{
3640
{
3575
 
3641
 
3576
    ty_s_data  *ptr;                             /* pointer to sort data type */
3642
    ty_s_data  *ptr;                             /* pointer to sort data type */
3577
    ty_s_data  *last;
3643
    ty_s_data  *last;
3578
    int         j;
3644
    unsigned    j;
3579
    unsigned    num;
3645
    unsigned    num;
3580
    team_type   team_buf;
3646
    team_type   team_buf;
3581
 
3647
 
3582
    /*
3648
    /*
3583
     * Fetch memory for the data store
3649
     * Fetch memory for the data store
Line 3645... Line 3711...
3645
                ptr->flags = team_buf.flags;
3711
                ptr->flags = team_buf.flags;
3646
 
3712
 
3647
                // Add a few flags to simplify processing
3713
                // Add a few flags to simplify processing
3648
                //  Vetted out teams to be included inthe fastest calcs - except for Equestian Leg
3714
                //  Vetted out teams to be included inthe fastest calcs - except for Equestian Leg
3649
                //  Bodgey teams are not sorted by place - only after all places and then by team number
3715
                //  Bodgey teams are not sorted by place - only after all places and then by team number
-
 
3716
                ptr->flags.notInLP = 0;
3650
                ptr->flags.notInSort = 0;
3717
                ptr->flags.notInEP = 0;
3651
                ptr->flags.notInFastest = 0;
3718
                ptr->flags.notInFastest = 0;
3652
 
3719
 
3653
                if ( ptr->flags.bad_times || ptr->flags.disqualified || !ptr->flags.valid) {
3720
                if ( ptr->flags.bad_times || ptr->flags.disqualified || !ptr->flags.valid) {
-
 
3721
                    ptr->flags.notInLP = 1;
3654
                    ptr->flags.notInSort = 1;
3722
                    ptr->flags.notInEP = 1;
3655
                    ptr->flags.notInFastest = 1;
3723
                    ptr->flags.notInFastest = 1;
3656
                }
3724
                }
3657
 
3725
 
3658
                if (ptr->flags.vet_check) {
3726
                if (ptr->flags.vet_check) {
3659
                    ptr->flags.notInSort = 1;
3727
                    ptr->flags.notInEP = 1;
3660
                }
3728
                }
3661
 
3729
 
3662
//                if (ptr->flags.non_equestrian)
3730
//                if (ptr->flags.non_equestrian)
3663
//                    ptr->flags.disqualified = true;
3731
//                    ptr->flags.disqualified = true;
3664
                if (ptr->flags.vet_check)
3732
//                if (ptr->flags.vet_check)
3665
                    ptr->flags.disqualified = true;
3733
//                    ptr->flags.disqualified = true;
3666
 
3734
 
3667
                ptr++;
3735
                ptr++;
3668
                sort_num++;
3736
                sort_num++;
3669
 
3737
 
3670
 
3738
 
Line 3710... Line 3778...
3710
                }
3778
                }
3711
#endif
3779
#endif
3712
            }
3780
            }
3713
        }
3781
        }
3714
    }
3782
    }
-
 
3783
 
-
 
3784
    // Debug
-
 
3785
    qDebug() << "--- Start ---";
-
 
3786
 
-
 
3787
    sort_team_data( 0, S_L, 1 );
-
 
3788
 
-
 
3789
    for( j = 1, ptr = sort_data; j <= sort_num; j++, ptr++ )
-
 
3790
    {
-
 
3791
        qDebug() << "T:" << ptr->team
-
 
3792
                << "Class:" << ptr->teamclass
-
 
3793
                << "NEData:" << (ptr->isNeData? 1:0)
-
 
3794
                << "iLP:" << (ptr->flags.notInLP ? 1:0)
-
 
3795
                << "iEP:" << (ptr->flags.notInEP ? 1:0)
-
 
3796
                << "iF:" << (ptr->flags.notInFastest ? 1:0)
-
 
3797
                << "Valid:" << (ptr->flags.valid ? 1:0)
-
 
3798
                << "NE:" << (ptr->flags.non_equestrian? 1:0)
-
 
3799
                << "B:" << (ptr->flags.bad_times ? 1 : 0 )
-
 
3800
                << "D:" << (ptr->flags.disqualified ? 1:0 )
-
 
3801
                << "V:" << (ptr->flags.vet_check ? 1:0 )
-
 
3802
                << "LE0:" << ptr->lege[0]
-
 
3803
                << "L0:" << ptr->leg[0]
-
 
3804
                << "LE1:" << ptr->lege[3]
-
 
3805
                ;
-
 
3806
    }
-
 
3807
 
-
 
3808
    qDebug() << "-----------------------------------End---";
3715
    return ( TRUE );
3809
    return ( TRUE );
3716
}
3810
}
3717
 
3811
 
3718
/*========================================================================
3812
/*========================================================================
3719
 *
3813
 *