Subversion Repositories svn1

Rev

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

Rev 131 Rev 133
Line 30... Line 30...
30
*           21-May-90   MV      now able to set start time and generate
30
*           21-May-90   MV      now able to set start time and generate
31
*                               a printed report for any leg
31
*                               a printed report for any leg
32
*   00.0    27/01/95    DDP     Tidies up the program and formatted the file
32
*   00.0    27/01/95    DDP     Tidies up the program and formatted the file
33
*
33
*
34
**************************************************************************/
34
**************************************************************************/
35
 
-
 
-
 
35
#include    "QDebug"
36
#include    "consts.h"
36
#include    "consts.h"
37
#include    "structs.h"
37
#include    "structs.h"
38
#include    "proto.h"
38
#include    "proto.h"
39
 
39
 
40
#if defined(HI_TECH_C) || defined(__TURBOC__)
-
 
41
#include    <alloc.h>
-
 
42
#endif
-
 
43
 
-
 
44
menu_table  leg_menu[] = {
-
 
45
    { '1', "Set start time from category", leg_start },
-
 
46
    { '2', "Clear all leg times", leg_ini },
-
 
47
    { '3', "Reset team information", tm_init },
-
 
48
    { '4', "Generate dummy team names", tm_gen },
-
 
49
    //{ '5', "Set calculated leg start", tm_lgs },
-
 
50
    //{ '6', "Set ordered incremental leg start", tm_lgs1 },
-
 
51
    //{ '7', "Set staggered start time", tm_staggered },
-
 
52
    //{ '8', "Set fixed start time", tm_fixedstart },
-
 
53
    { '9', "Clear single leg start times", tm_clearleg },
-
 
54
    { 'q', "Return to main menu", 0 },
-
 
55
    { '\0' }
-
 
56
};
-
 
57
 
-
 
58
/*========================================================================
-
 
59
 *
-
 
60
 *  Menu: Setup leg times
-
 
61
 *
-
 
62
 *  Purpose:
-
 
63
 *      This function is called to produce the menu that will
-
 
64
 *      setup leg times
-
 
65
 *
-
 
66
 *  Parameters:
-
 
67
 *      None
-
 
68
 *
-
 
69
 *  Returns:
-
 
70
 *      Nothing
-
 
71
 *
-
 
72
 *========================================================================*/
-
 
73
 
-
 
74
void set_legs(void)
-
 
75
{
-
 
76
    do_menu( "Leg time setup", "Select option", leg_menu );
-
 
77
}
-
 
78
 
-
 
79
/*========================================================================
40
/*========================================================================
80
 *
41
 *
81
 *  Set up the leg start times for leg
42
 *  Set up the leg start times for leg
82
 *
43
 *
83
 *  Purpose:
44
 *  Purpose:
Line 104... Line 65...
104
    **  Read existing data into memory
65
    **  Read existing data into memory
105
    */
66
    */
106
    data = ( t_legs * ) calloc( ( unsigned ) ( config.max_team - config.min_team + 2 ), sizeof( t_legs ) ); /* Fetch memory */
67
    data = ( t_legs * ) calloc( ( unsigned ) ( config.max_team - config.min_team + 2 ), sizeof( t_legs ) ); /* Fetch memory */
107
    if( !data )
68
    if( !data )
108
    {
69
    {
109
        printf( "\nNo memory for report\n" );
70
        qDebug( "No memory for report" );
110
        return;
71
        return;
111
    }
72
    }
112
 
73
 
113
    /*
74
    /*
114
     * Extract the required data from the data base
75
     * Extract the required data from the data base
Line 150... Line 111...
150
 
111
 
151
            set_times( &team_buf );
112
            set_times( &team_buf );
152
            test_times( &team_buf, 0 );
113
            test_times( &team_buf, 0 );
153
            put_team_record( dptr->numb, &team_buf );
114
            put_team_record( dptr->numb, &team_buf );
154
        }
115
        }
155
 
-
 
156
        if( i % 10 == 0 )
-
 
157
        {
-
 
158
            cur( 0, 8 );
-
 
159
            printf( "Upto entry %d", i );
-
 
160
            flush_out();
-
 
161
        }
-
 
162
    }
116
    }
163
 
117
 
164
    /*
118
    /*
165
    **  Release the data
119
    **  Release the data
166
    */
120
    */
167
    free( data );
121
    free( data );
168
 
122
 
169
    if( report_it )
123
    if( report_it )
170
        legs_start_report(9, leg);
124
        legs_start_report(leg);
171
 
125
 
172
    if ( clear_it )
126
    if ( clear_it )
173
        tm_clearleg_specified( leg, TRUE, 10 );
127
        tm_clearleg_specified( leg, TRUE);
174
}
128
}
175
 
129
 
176
/*========================================================================
130
/*========================================================================
177
 *
131
 *
178
 *  Set up the leg start times for leg
132
 *  Set up the leg start times for leg
Line 210... Line 164...
210
 
164
 
211
            set_times( &team_buf );
165
            set_times( &team_buf );
212
            test_times( &team_buf, 0 );
166
            test_times( &team_buf, 0 );
213
            put_team_record( team, &team_buf );
167
            put_team_record( team, &team_buf );
214
        }
168
        }
215
 
-
 
216
        if( team % 10 == 0 )
-
 
217
        {
-
 
218
 
-
 
219
            printf( "Upto team %d", team );
-
 
220
            flush_out();
-
 
221
        }
-
 
222
        team++;
169
        team++;
223
    }
170
    }
224
 
171
 
225
    if( report_it )
172
    if( report_it )
226
        legs_start_report(0, leg);
173
        legs_start_report(leg);
227
 
174
 
228
    if ( clear_it )
175
    if ( clear_it )
229
        tm_clearleg_specified( leg, TRUE, 0 );
176
        tm_clearleg_specified( leg, TRUE);
230
}
177
}
231
 
178
 
232
/*========================================================================
179
/*========================================================================
233
 *
180
 *
234
 *  Set up the leg start times
181
 *  Set up the leg start times
Line 246... Line 193...
246
 
193
 
247
void leg_start(void)
194
void leg_start(void)
248
{
195
{
249
 
196
 
250
    team = config.min_team;                      /* Team we are working with */
197
    team = config.min_team;                      /* Team we are working with */
251
//    cur( 0, 5 );
-
 
252
//    printf( "Setting start times for all valid teams from %-d to %-d \n",
-
 
253
//            config.min_team, config.max_team );
-
 
254
//    if( !getyes( "Continue operation" ) )
-
 
255
//        return;
-
 
256
 
-
 
257
    while( team <= config.max_team )
198
    while( team <= config.max_team )
258
    {
199
    {
259
        if( valid_field( team ) )
200
        if( valid_field( team ) )
260
        {
201
        {
261
            ( void ) g_record( team, &team_buf );
202
            ( void ) g_record( team, &team_buf );
Line 273... Line 214...
273
            team_buf.leg[0].manual = FALSE;
214
            team_buf.leg[0].manual = FALSE;
274
            set_times( &team_buf );
215
            set_times( &team_buf );
275
            test_times( &team_buf, 0 );
216
            test_times( &team_buf, 0 );
276
            put_team_record( team, &team_buf );
217
            put_team_record( team, &team_buf );
277
        }
218
        }
278
        if( team % 10 == 0 )
-
 
279
        {
-
 
280
            cur( 0, 8 );
-
 
281
            printf( "Upto team %d", team );
-
 
282
            flush_out();
-
 
283
        }
-
 
284
        team++;
219
        team++;
285
    }
220
    }
286
}
221
}
287
 
222
 
288
/*========================================================================
223
/*========================================================================
Line 301... Line 236...
301
 *
236
 *
302
 *========================================================================*/
237
 *========================================================================*/
303
 
238
 
304
void tm_fixedstart(int leg, time_t starttime, bool report_it, bool clear_it)
239
void tm_fixedstart(int leg, time_t starttime, bool report_it, bool clear_it)
305
{
240
{
306
    int         line = 5;                        /* Current line */
241
    team = config.min_team;                      /* Team we are working with */
307
 
-
 
308
    while( team <= config.max_team )
242
    while( team <= config.max_team )
309
    {
243
    {
310
        if( valid_field( team ) )
244
        if( valid_field( team ) )
311
        {
245
        {
312
            g_record( team, &team_buf );
246
            g_record( team, &team_buf );
Line 320... Line 254...
320
 
254
 
321
            set_times( &team_buf );
255
            set_times( &team_buf );
322
            test_times( &team_buf, 0 );
256
            test_times( &team_buf, 0 );
323
            put_team_record( team, &team_buf );
257
            put_team_record( team, &team_buf );
324
        }
258
        }
325
 
-
 
326
        if( team % 10 == 0 )
-
 
327
        {
-
 
328
            cur( 0, 8 );
-
 
329
            printf( "Upto team %d", team );
-
 
330
            flush_out();
-
 
331
        }
-
 
332
        team++;
259
        team++;
333
    }
260
    }
334
    
261
    
335
    if( report_it )
262
    if( report_it )
336
        legs_start_report(++line, leg);
263
        legs_start_report(leg);
337
 
264
 
338
    if ( clear_it )
265
    if ( clear_it )
339
        tm_clearleg_specified( leg, TRUE, ++line );
266
        tm_clearleg_specified( leg, TRUE );
340
}
267
}
341
 
268
 
342
/*========================================================================
269
/*========================================================================
343
 *
270
 *
344
 *  Set a staggered start time for a specific leg
271
 *  Set a staggered start time for a specific leg
Line 355... Line 282...
355
 *
282
 *
356
 *========================================================================*/
283
 *========================================================================*/
357
 
284
 
358
void tm_staggered(int leg, time_t starttime, time_t delta, bool report_it, bool clear_it )
285
void tm_staggered(int leg, time_t starttime, time_t delta, bool report_it, bool clear_it )
359
{
286
{
360
    int         line = 5;                        /* Current line */
287
    team = config.min_team;                      /* Team we are working with */
361
    
-
 
362
    while( team <= config.max_team )
288
    while( team <= config.max_team )
363
    {
289
    {
364
        if( valid_field( team ) )
290
        if( valid_field( team ) )
365
        {
291
        {
366
            g_record( team, &team_buf );
292
            g_record( team, &team_buf );
Line 375... Line 301...
375
 
301
 
376
            set_times( &team_buf );
302
            set_times( &team_buf );
377
            test_times( &team_buf, 0 );
303
            test_times( &team_buf, 0 );
378
            put_team_record( team, &team_buf );
304
            put_team_record( team, &team_buf );
379
        }
305
        }
380
 
-
 
381
        if( team % 10 == 0 )
-
 
382
        {
-
 
383
            cur( 0, 9 );
-
 
384
            printf( "Upto team %d", team );
-
 
385
            flush_out();
-
 
386
        }
-
 
387
        team++;
306
        team++;
388
    }
307
    }
389
    
308
    
390
    if( report_it )
309
    if( report_it )
391
        legs_start_report(++line, leg);
310
        legs_start_report(leg);
392
 
311
 
393
    if ( clear_it )
312
    if ( clear_it )
394
        tm_clearleg_specified( leg, TRUE,  ++line );
313
        tm_clearleg_specified( leg, TRUE );
395
}
-
 
396
 
-
 
397
/*========================================================================
-
 
398
 *
-
 
399
 *  Clear start times on a specific leg
-
 
400
 *
-
 
401
 *  Purpose:
-
 
402
 *      This function is called to clear start times on a specifc leg
-
 
403
 *
-
 
404
 *  Parameters:
-
 
405
 *      None
-
 
406
 *
-
 
407
 *  Returns:
-
 
408
 *      Nothing
-
 
409
 *
-
 
410
 *========================================================================*/
-
 
411
 
-
 
412
void tm_clearleg(void)
-
 
413
{
-
 
414
 
-
 
415
    cur( 0, 5 );
-
 
416
    while( TRUE )
-
 
417
    {
-
 
418
        leg = 0;
-
 
419
        d_field( 0, 5, "Enter leg to clear start time :", D_NUMBER, 1,
-
 
420
                 ( char * ) &leg, TRUE, M_UPDATE );
-
 
421
        if( leg == 0 )
-
 
422
            return;                              /* Null leg - just exit */
-
 
423
        if( leg <= config.num_legs )             /* Valid leg number - Exit loop */
-
 
424
            break;
-
 
425
        beep();                                /* Make a noise and wait for valid number */
-
 
426
    }
-
 
427
 
-
 
428
 
-
 
429
    cur( 0, 5 );
-
 
430
    printf
-
 
431
        ( "Setting start times for all valid teams from %-d to %-d for leg %d\n",
-
 
432
          config.min_team, config.max_team, leg );
-
 
433
    if( !getyes( "Continue operation" ) )
-
 
434
        return;
-
 
435
 
-
 
436
    tm_clearleg_specified( leg, FALSE, 6 );
-
 
437
}
314
}
438
 
315
 
439
/*========================================================================
316
/*========================================================================
440
 *
317
 *
441
 *  Clear start times on a specific leg
318
 *  Clear start times on a specific leg
Line 444... Line 321...
444
 *      This function is called to clear start times on a specifc leg
321
 *      This function is called to clear start times on a specifc leg
445
 *
322
 *
446
 *  Parameters:
323
 *  Parameters:
447
 *      cleg                - Leg to clear
324
 *      cleg                - Leg to clear
448
 *      manual              - Force manual, else leave alone
325
 *      manual              - Force manual, else leave alone
449
 *      line                - Current display line number
-
 
450
 *
326
 *
451
 *  Returns:
327
 *  Returns:
452
 *      Nothing
328
 *      Nothing
453
 *
329
 *
454
 *========================================================================*/
330
 *========================================================================*/
455
 
331
 
456
void tm_clearleg_specified(int cleg, bool manual, int line)
332
void tm_clearleg_specified(int cleg, bool manual)
457
{
333
{
458
 
334
 
459
    /*
335
    /*
460
    **  Validate the users argument
336
    **  Validate the users argument
461
    */
337
    */
Line 476... Line 352...
476
            
352
            
477
            set_times( &team_buf );
353
            set_times( &team_buf );
478
            test_times( &team_buf, 0 );
354
            test_times( &team_buf, 0 );
479
            put_team_record( team, &team_buf );
355
            put_team_record( team, &team_buf );
480
        }
356
        }
481
        if( team % 10 == 0 )
-
 
482
        {
-
 
483
            cur( 0, line );
-
 
484
            printf( "Upto team %d", team );
-
 
485
            flush_out();
-
 
486
        }
-
 
487
        team++;
357
        team++;
488
    }
358
    }
489
}
359
}
490
 
360
 
491
 
361
 
Line 534... Line 404...
534
            team_buf.leg[1].start = team_buf.leg[0].start;
404
            team_buf.leg[1].start = team_buf.leg[0].start;
535
            team_buf.flags.disqualified = FALSE;
405
            team_buf.flags.disqualified = FALSE;
536
            team_buf.flags.non_equestrian = FALSE;
406
            team_buf.flags.non_equestrian = FALSE;
537
            put_team_record( team, &team_buf );
407
            put_team_record( team, &team_buf );
538
        }
408
        }
539
        if( team % 10 == 0 )
-
 
540
        {
-
 
541
            cur( 0, 8 );
-
 
542
            printf( "Upto team %d", team );
-
 
543
            flush_out();
-
 
544
        }
-
 
545
        team++;
409
        team++;
546
    }
410
    }
547
}
411
}
548
 
412
 
549
/*========================================================================
413
/*========================================================================
Line 569... Line 433...
569
        if( valid_field( team ) )
433
        if( valid_field( team ) )
570
        {
434
        {
571
            clr_team( team, &team_buf );
435
            clr_team( team, &team_buf );
572
            put_team_record( team, &team_buf );
436
            put_team_record( team, &team_buf );
573
        }
437
        }
574
        if( team % 10 == 0 )
-
 
575
        {
-
 
576
            cur( 0, 8 );
-
 
577
            printf( "Upto team %d", team );
-
 
578
            flush_out();
-
 
579
        }
-
 
580
        team++;
438
        team++;
581
    }
439
    }
582
}
440
}
583
 
441
 
584
/*========================================================================
442
/*========================================================================
Line 608... Line 466...
608
            team_buf.flags.valid = TRUE;
466
            team_buf.flags.valid = TRUE;
609
            sprintf( team_buf.name, "Team - %4.4d", team );
467
            sprintf( team_buf.name, "Team - %4.4d", team );
610
            team_buf.teamclass = 1;                  /* Set default class */
468
            team_buf.teamclass = 1;                  /* Set default class */
611
            put_team_record( team, &team_buf );
469
            put_team_record( team, &team_buf );
612
        }
470
        }
613
        if( team % 10 == 0 )
-
 
614
        {
-
 
615
            cur( 0, 8 );
-
 
616
            printf( "Upto team %d", team );
-
 
617
            flush_out();
-
 
618
        }
-
 
619
        team++;
471
        team++;
620
    }
472
    }
621
}
473
}
622
 
474
 
623
 
475
 
Line 635... Line 487...
635
 *  Returns:
487
 *  Returns:
636
 *      Nothing
488
 *      Nothing
637
 *
489
 *
638
 *========================================================================*/
490
 *========================================================================*/
639
 
491
 
640
void legs_start_report(int line, int leg)
492
void legs_start_report(int leg)
641
{
493
{
642
    int         i;
494
    int         i;
643
    t_legs     *data;                            /* Address of table */
495
    t_legs     *data;                            /* Address of table */
644
    t_legs     *dptr;                            /* Moving pointer */
496
    t_legs     *dptr;                            /* Moving pointer */
645
    int         last_team;
497
    int         last_team;
646
    int         num_records = 0;                 /* Number of records in array */
498
    int         num_records = 0;                 /* Number of records in array */
647
    char        l_s[40];                         /* Name of start time file */
499
    char        l_s[40];                         /* Name of start time file */
648
 
500
 
649
    cur( 0, line );
-
 
650
    printf( "Generating Starters report for Leg-%d", leg );
501
    printf( "Generating Starters report for Leg-%d", leg );
651
 
502
 
652
    data = ( t_legs * ) calloc( ( unsigned ) ( config.max_team - config.min_team + 2 ), sizeof( t_legs ) ); /* Fetch memory */
503
    data = ( t_legs * ) calloc( ( unsigned ) ( config.max_team - config.min_team + 2 ), sizeof( t_legs ) ); /* Fetch memory */
653
 
504
 
654
    if( !data )
505
    if( !data )
655
    {
506
    {
656
        printf( "\nNo memory for report\n" );
507
        qDebug( "No memory for report" );
657
        return;
508
        return;
658
    }
509
    }
659
 
510
 
660
    /*
511
    /*
661
     * Extract the required data from the data base
512
     * Extract the required data from the data base