Subversion Repositories svn1-original

Rev

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

Rev 150 Rev 162
Line 46... Line 46...
46
char        confile[20];                         /* Name of the config file */
46
char        confile[20];                         /* Name of the config file */
47
char        datfile[20];                         /* Name of the data file */
47
char        datfile[20];                         /* Name of the data file */
48
char        filebase[20];                        /* Event file name base */
48
char        filebase[20];                        /* Event file name base */
49
 
49
 
50
MARA_CFG    config;                              /* Working configuration */
50
MARA_CFG    config;                              /* Working configuration */
51
MARA_CFG    newcfg;                              /* Play configuration */
51
//MARA_CFG    newcfg;                              /* Play configuration */
52
 
52
 
53
t_class_summary class_summary;                   /* Class summary data */
53
//t_class_summary class_summary;                   /* Class summary data */
54
 
54
 
55
menu_table  cnf_menu[] = {
55
//menu_table  cnf_menu[] = {
56
    {'1', "Display current configuration", display_config},
56
//    {'1', "Display current configuration", display_config},
57
    {'2', "Alter configuration", ( void ( * )( void ) ) define_config},
57
//    {'2', "Alter configuration", ( void ( * )( void ) ) define_config},
58
    {'3', "Display category configuration", display_class},
58
//    {'3', "Display category configuration", display_class},
59
    {'4', "Alter category configuration", ( void ( * )( void ) ) define_class},
59
//    {'4', "Alter category configuration", ( void ( * )( void ) ) define_class},
60
    {'5', "Display country list", display_country},
60
//    {'5', "Display country list", display_country},
61
    {'6', "Alter country list", define_country},
61
//    {'6', "Alter country list", define_country},
62
    {'7', "Display winners list", display_winners},
62
//    {'7', "Display winners list", display_winners},
63
    {'8', "Alter winners list",  ( void ( * )( void ) ) define_winners},
63
//    {'8', "Alter winners list",  ( void ( * )( void ) ) define_winners},
64
    {'q', "Return to main menu", 0},
64
//    {'q', "Return to main menu", 0},
65
    {'\0'}
65
//    {'\0'}
66
};
66
//};
67
 
67
 
68
/*========================================================================
68
/*========================================================================
69
 *
69
 *
70
 *  Read in the configuration file
70
 *  Read in the configuration file
71
 *
71
 *
Line 97... Line 97...
97
    if ( fcon )
97
    if ( fcon )
98
        fclose( fcon );
98
        fclose( fcon );
99
 
99
 
100
    if( mode )
100
    if( mode )
101
    {
101
    {
102
        if( fcon )
102
//        if( fcon )
103
        {
103
//        {
104
            printf( "Configuration file already exists\n" );
104
//            printf( "Configuration file already exists\n" );
105
            ok = FALSE;
105
//            ok = FALSE;
106
        }
106
//        }
107
        else
107
//        else
108
        {
108
//        {
109
            ok = define_config(  );              /* Generate the configuration */
109
//            ok = define_config(  );              /* Generate the configuration */
110
            if( ok )
110
//            if( ok )
111
                ok = define_class(  );
111
//                ok = define_class(  );
112
        }
112
//        }
113
    }
113
    }
114
    else if( fcon )
114
    else if( fcon )
115
        ok = rd_config(  );                      /* read in the existing config */
115
        ok = rd_config(  );                      /* read in the existing config */
116
    else
116
    else
117
    {
117
    {
Line 129... Line 129...
129
    }
129
    }
130
    config.nonequestrian_class = lookup_class( config.nonequestrian_class_abr, &config );
130
    config.nonequestrian_class = lookup_class( config.nonequestrian_class_abr, &config );
131
    return ( ok );
131
    return ( ok );
132
}
132
}
133
 
133
 
134
/*========================================================================
134
///*========================================================================
135
 *
135
// *
136
 *  Configuration Menu
136
// *  Configuration Menu
137
 *
137
// *
138
 *  Purpose:
138
// *  Purpose:
139
 *      This function is called to display the configuartion menu
139
// *      This function is called to display the configuartion menu
140
 *
140
// *
141
 *  Parameters:
141
// *  Parameters:
142
 *      None
142
// *      None
143
 *
143
// *
144
 *  Returns:
144
// *  Returns:
145
 *      Nothing
145
// *      Nothing
146
 *
146
// *
147
 *========================================================================*/
147
// *========================================================================*/
148
 
148
 
149
void conf_menu( void )
149
//void conf_menu( void )
150
{
150
//{
151
    do_menu( "Event configuration", "Select option", cnf_menu );
151
//    do_menu( "Event configuration", "Select option", cnf_menu );
152
}
152
//}
153
 
153
 
154
/*========================================================================
154
/*========================================================================
155
 *
155
 *
156
 *  Alter the configuration file
156
 *  Alter the configuration file
157
 *
157
 *
Line 165... Line 165...
165
 *      TRUE    - Configuration changed
165
 *      TRUE    - Configuration changed
166
 *      FALSE   - Configuration not changed
166
 *      FALSE   - Configuration not changed
167
 *
167
 *
168
 *========================================================================*/
168
 *========================================================================*/
169
 
169
 
170
bool define_config( void )
170
//bool define_config( void )
171
{
171
//{
172
    int         i, j;
172
//    int         i, j;
173
    int         error;
173
//    int         error;
174
    bool        changed = FALSE;
174
//    bool        changed = FALSE;
175
    int         num_teams;
175
//    int         num_teams;
-
 
176
 
-
 
177
//    /*
-
 
178
//     **  Copy working configuration into a temp structure for
-
 
179
//     **  use within the function
-
 
180
//     */
-
 
181
//    newcfg = config;
-
 
182
 
-
 
183
//    do
-
 
184
//    {
-
 
185
//        error = 0;
-
 
186
//        num_teams = 0;
-
 
187
//        d_config( &newcfg, M_UPDATE );
-
 
188
//        printf( "\n" );
-
 
189
 
-
 
190
//        compact( newcfg.event_name );               /* Rip of leading white_space */
-
 
191
//        for( i = 0; i < MAX_LEGS; i++ )
-
 
192
//            compact( newcfg.leg_name[i] );
-
 
193
//        compact( newcfg.addendum );
-
 
194
//        compact( newcfg.datafilename );
-
 
195
 
-
 
196
//        /*
-
 
197
//         * Do all sorts of consistency tests on the data
-
 
198
//         * Firstly - calculate the number of legs. Justify the data in the array
-
 
199
//         */
-
 
200
 
-
 
201
//        newcfg.num_legs = 0;
-
 
202
//        for( i = 0; i < MAX_LEGS; i++ )
-
 
203
//            if( newcfg.leg_name[i][0] )
-
 
204
//                newcfg.num_legs++;
-
 
205
//        for( i = newcfg.num_legs; i < MAX_LEGS; i++ )
-
 
206
//            if( newcfg.leg_name[i][0] )
-
 
207
//            {
-
 
208
//                printf( "Configuration error: Missing leg\n" );
-
 
209
//                error++;
-
 
210
//            }
-
 
211
 
-
 
212
 
-
 
213
//        /*
-
 
214
//         * Now do the team numbering stuff
-
 
215
//         */
-
 
216
 
-
 
217
//        for( i = 0; i < MAX_TMS_SPLIT; i++ )
-
 
218
//        {
-
 
219
//            if( newcfg.t_def[i].start == 0 && newcfg.t_def[i].end == 0 )
-
 
220
//                continue;
-
 
221
//            if( newcfg.t_def[i].start > newcfg.t_def[i].end )
-
 
222
//            {
-
 
223
//                printf
-
 
224
//                    ( "Team definition error : End greater than start. %d to %d\n",
-
 
225
//                      newcfg.t_def[i].start, newcfg.t_def[i].end );
-
 
226
//                error++;
-
 
227
//            }
-
 
228
//            for( j = 0; j < i; j++ )
-
 
229
//            {
-
 
230
//                if( ( newcfg.t_def[i].start >= newcfg.t_def[j].start
-
 
231
//                      && newcfg.t_def[i].start <= newcfg.t_def[j].end )
-
 
232
//                    || ( newcfg.t_def[i].end >= newcfg.t_def[j].start
-
 
233
//                         && newcfg.t_def[i].end <= newcfg.t_def[j].end ) )
-
 
234
//                {
-
 
235
//                    printf
-
 
236
//                        ( "Team definition error : Overlapping definition. %d to %d\n",
-
 
237
//                          newcfg.t_def[i].start, newcfg.t_def[i].end );
-
 
238
//                    error++;
-
 
239
//                }
-
 
240
//            }
-
 
241
//        }
-
 
242
 
-
 
243
//        /*
-
 
244
//         * Determine the number of team splits
-
 
245
//         * There may be blank entries - these will be removed by sorting the array
-
 
246
//         */
-
 
247
//        qsort( ( char * ) newcfg.t_def, MAX_TMS_SPLIT, sizeof( *newcfg.t_def ), f_comp_int );
-
 
248
//        for( newcfg.num_teams = 0; newcfg.num_teams < MAX_TMS_SPLIT; newcfg.num_teams++ )
-
 
249
//            if( !newcfg.t_def[newcfg.num_teams].start )
-
 
250
//                break;
-
 
251
 
-
 
252
//        newcfg.min_team = newcfg.t_def[0].start;
-
 
253
//        newcfg.max_team = newcfg.t_def[newcfg.num_teams - 1].end;
-
 
254
 
-
 
255
//        /*
-
 
256
//         **  Limit the number of entrants
-
 
257
//         */
-
 
258
//        for( i = 0; i < MAX_TMS_SPLIT; i++ )
-
 
259
//        {
-
 
260
//            if( newcfg.t_def[i].start )
-
 
261
//            {
-
 
262
//                num_teams += newcfg.t_def[i].end - newcfg.t_def[i].start + 1;
-
 
263
//            }
-
 
264
//        }
-
 
265
//#if defined(LIMIT_TEAMS) && (LIMIT_TEAMS > 0)
-
 
266
//        if( num_teams > LIMIT_TEAMS )
-
 
267
//        {
-
 
268
//            printf( "Maximum number of teams exceeded - reduce number of teams\n" );
-
 
269
//            error++;
-
 
270
//        }
-
 
271
//#endif
-
 
272
 
-
 
273
//#if defined (HI_TECH_C) || defined (__TURBOC__)
-
 
274
 
-
 
275
//        /*
-
 
276
//         * Ensure that the number of teams allocated can fit within available
-
 
277
//         * Memory space. Ie: Can we malloc the report data structures
-
 
278
//         */
-
 
279
//        {
-
 
280
//            long        sz;
-
 
281
 
-
 
282
//            sz = sizeof( ty_s_data ) > sizeof( ty_s_aux ) ?
-
 
283
//                sizeof( ty_s_data ) : sizeof( ty_s_aux );
-
 
284
//            if( sz * ( newcfg.max_team - newcfg.min_team + 2 ) > ( 1024L * 64L ) )
-
 
285
//            {
-
 
286
//                printf( "Too many teams: Reduce team spread.\n" );
-
 
287
//                error++;
-
 
288
//            }
-
 
289
//        }
-
 
290
//#endif
-
 
291
 
-
 
292
//        /*
-
 
293
//         **  Ensure the non-equestrian class and the equestrian leg are valid
-
 
294
//         */
-
 
295
//        if( newcfg.equestrian_leg )
-
 
296
//        {
-
 
297
//            if( newcfg.equestrian_leg > newcfg.num_legs )
-
 
298
//            {
-
 
299
//                printf( "Invalid non-equestrian leg number.\n" );
-
 
300
//                error++;
-
 
301
//            }
-
 
302
 
-
 
303
//            /*
-
 
304
//             **  Ensure that the entered non-equestrian class name does exist
-
 
305
//             */
-
 
306
//            newcfg.nonequestrian_class = lookup_class( newcfg.nonequestrian_class_abr, &newcfg );
-
 
307
//            if( newcfg.nonequestrian_class == 0 )
-
 
308
//                printf( "WARNING: Non-equestrian class not found\n" );
-
 
309
//        }
-
 
310
 
-
 
311
//        abort_flag = FALSE;
-
 
312
//        if( error )
-
 
313
//        {
-
 
314
//            printf( "Configuration error - error must be corrected\n" );
-
 
315
//            printf( "Any key to continue " );
-
 
316
//            ( void ) getinp(  );
-
 
317
//            continue;
-
 
318
//        }
-
 
319
//        else
-
 
320
//        {
-
 
321
//            printf( "Install configuration (Y)es, (D)iscard, (E)dit again :" );
-
 
322
//            switch ( getfnc( "*YDEA" ) )
-
 
323
//            {
-
 
324
//            case 'Y':
-
 
325
//                error = ( newcfg.num_legs == 0 || newcfg.num_teams == 0 );
-
 
326
//                if( error )
-
 
327
//                    printf( "\nConfiguration not installed. No legs or teams defined\n" );
-
 
328
//                else
-
 
329
//                {
-
 
330
//                    config = newcfg;
-
 
331
//                    wt_config(  );               /* Write out the data */
-
 
332
//                    changed = TRUE;
-
 
333
//                }
-
 
334
//                break;
-
 
335
 
-
 
336
//            case 'D':
-
 
337
//                break;
-
 
338
 
-
 
339
//            default:
-
 
340
//                error = TRUE;
-
 
341
//                break;
-
 
342
//            }
-
 
343
//        }
-
 
344
//    }
-
 
345
//    while( error );
176
 
346
 
177
    /*
-
 
178
     **  Copy working configuration into a temp structure for
-
 
179
     **  use within the function
-
 
180
     */
-
 
181
    newcfg = config;
-
 
182
 
-
 
183
    do
-
 
184
    {
-
 
185
        error = 0;
-
 
186
        num_teams = 0;
-
 
187
        d_config( &newcfg, M_UPDATE );
-
 
188
        printf( "\n" );
-
 
189
 
-
 
190
        compact( newcfg.event_name );               /* Rip of leading white_space */
-
 
191
        for( i = 0; i < MAX_LEGS; i++ )
-
 
192
            compact( newcfg.leg_name[i] );
-
 
193
        compact( newcfg.addendum );
-
 
194
        compact( newcfg.datafilename );
-
 
195
 
-
 
196
        /*
-
 
197
         * Do all sorts of consistency tests on the data 
-
 
198
         * Firstly - calculate the number of legs. Justify the data in the array
-
 
199
         */
-
 
200
 
-
 
201
        newcfg.num_legs = 0;
-
 
202
        for( i = 0; i < MAX_LEGS; i++ )
-
 
203
            if( newcfg.leg_name[i][0] )
-
 
204
                newcfg.num_legs++;
-
 
205
        for( i = newcfg.num_legs; i < MAX_LEGS; i++ )
-
 
206
            if( newcfg.leg_name[i][0] )
-
 
207
            {
-
 
208
                printf( "Configuration error: Missing leg\n" );
-
 
209
                error++;
-
 
210
            }
-
 
211
 
-
 
212
 
-
 
213
        /*
-
 
214
         * Now do the team numbering stuff 
-
 
215
         */
-
 
216
 
-
 
217
        for( i = 0; i < MAX_TMS_SPLIT; i++ )
-
 
218
        {
-
 
219
            if( newcfg.t_def[i].start == 0 && newcfg.t_def[i].end == 0 )
-
 
220
                continue;
-
 
221
            if( newcfg.t_def[i].start > newcfg.t_def[i].end )
-
 
222
            {
-
 
223
                printf
-
 
224
                    ( "Team definition error : End greater than start. %d to %d\n",
-
 
225
                      newcfg.t_def[i].start, newcfg.t_def[i].end );
-
 
226
                error++;
-
 
227
            }
-
 
228
            for( j = 0; j < i; j++ )
-
 
229
            {
-
 
230
                if( ( newcfg.t_def[i].start >= newcfg.t_def[j].start
-
 
231
                      && newcfg.t_def[i].start <= newcfg.t_def[j].end )
-
 
232
                    || ( newcfg.t_def[i].end >= newcfg.t_def[j].start
-
 
233
                         && newcfg.t_def[i].end <= newcfg.t_def[j].end ) )
-
 
234
                {
-
 
235
                    printf
-
 
236
                        ( "Team definition error : Overlapping definition. %d to %d\n",
-
 
237
                          newcfg.t_def[i].start, newcfg.t_def[i].end );
-
 
238
                    error++;
-
 
239
                }
-
 
240
            }
-
 
241
        }
-
 
242
 
-
 
243
        /*
-
 
244
         * Determine the number of team splits
-
 
245
         * There may be blank entries - these will be removed by sorting the array
-
 
246
         */
-
 
247
        qsort( ( char * ) newcfg.t_def, MAX_TMS_SPLIT, sizeof( *newcfg.t_def ), f_comp_int );
-
 
248
        for( newcfg.num_teams = 0; newcfg.num_teams < MAX_TMS_SPLIT; newcfg.num_teams++ )
-
 
249
            if( !newcfg.t_def[newcfg.num_teams].start )
-
 
250
                break;
-
 
251
 
-
 
252
        newcfg.min_team = newcfg.t_def[0].start;
-
 
253
        newcfg.max_team = newcfg.t_def[newcfg.num_teams - 1].end;
-
 
254
 
-
 
255
        /*
-
 
256
         **  Limit the number of entrants
-
 
257
         */
-
 
258
        for( i = 0; i < MAX_TMS_SPLIT; i++ )
-
 
259
        {
-
 
260
            if( newcfg.t_def[i].start )
-
 
261
            {
-
 
262
                num_teams += newcfg.t_def[i].end - newcfg.t_def[i].start + 1;
-
 
263
            }
-
 
264
        }
-
 
265
#if defined(LIMIT_TEAMS) && (LIMIT_TEAMS > 0)
-
 
266
        if( num_teams > LIMIT_TEAMS )
-
 
267
        {
-
 
268
            printf( "Maximum number of teams exceeded - reduce number of teams\n" );
-
 
269
            error++;
-
 
270
        }
-
 
271
#endif
-
 
272
 
-
 
273
#if defined (HI_TECH_C) || defined (__TURBOC__)
-
 
274
 
-
 
275
        /*
-
 
276
         * Ensure that the number of teams allocated can fit within available
-
 
277
         * Memory space. Ie: Can we malloc the report data structures
-
 
278
         */
-
 
279
        {
-
 
280
            long        sz;
-
 
281
 
-
 
282
            sz = sizeof( ty_s_data ) > sizeof( ty_s_aux ) ?
-
 
283
                sizeof( ty_s_data ) : sizeof( ty_s_aux );
-
 
284
            if( sz * ( newcfg.max_team - newcfg.min_team + 2 ) > ( 1024L * 64L ) )
-
 
285
            {
-
 
286
                printf( "Too many teams: Reduce team spread.\n" );
-
 
287
                error++;
-
 
288
            }
-
 
289
        }
-
 
290
#endif
-
 
291
 
-
 
292
        /*
-
 
293
         **  Ensure the non-equestrian class and the equestrian leg are valid
-
 
294
         */
-
 
295
        if( newcfg.equestrian_leg )
-
 
296
        {
-
 
297
            if( newcfg.equestrian_leg > newcfg.num_legs )
-
 
298
            {
-
 
299
                printf( "Invalid non-equestrian leg number.\n" );
-
 
300
                error++;
-
 
301
            }
-
 
302
 
-
 
303
            /*
-
 
304
             **  Ensure that the entered non-equestrian class name does exist
-
 
305
             */
-
 
306
            newcfg.nonequestrian_class = lookup_class( newcfg.nonequestrian_class_abr, &newcfg );
-
 
307
            if( newcfg.nonequestrian_class == 0 )
-
 
308
                printf( "WARNING: Non-equestrian class not found\n" );
-
 
309
        }
-
 
310
 
-
 
311
        abort_flag = FALSE;
-
 
312
        if( error )
-
 
313
        {
-
 
314
            printf( "Configuration error - error must be corrected\n" );
-
 
315
            printf( "Any key to continue " );
-
 
316
            ( void ) getinp(  );
-
 
317
            continue;
-
 
318
        }
-
 
319
        else
-
 
320
        {
-
 
321
            printf( "Install configuration (Y)es, (D)iscard, (E)dit again :" );
-
 
322
            switch ( getfnc( "*YDEA" ) )
-
 
323
            {
-
 
324
            case 'Y':
-
 
325
                error = ( newcfg.num_legs == 0 || newcfg.num_teams == 0 );
-
 
326
                if( error )
-
 
327
                    printf( "\nConfiguration not installed. No legs or teams defined\n" );
-
 
328
                else
-
 
329
                {
-
 
330
                    config = newcfg;
-
 
331
                    wt_config(  );               /* Write out the data */
-
 
332
                    changed = TRUE;
-
 
333
                }
-
 
334
                break;
-
 
335
 
-
 
336
            case 'D':
-
 
337
                break;
-
 
338
 
-
 
339
            default:
-
 
340
                error = TRUE;
-
 
341
                break;
-
 
342
            }
-
 
343
        }
-
 
344
    }
-
 
345
    while( error );
-
 
346
 
-
 
347
    return ( changed );
347
//    return ( changed );
348
}
348
//}
349
 
349
 
350
 
350
 
351
/*========================================================================
351
/*========================================================================
352
 *
352
 *
353
 *  Display the marathon configuration
353
 *  Display the marathon configuration
Line 361... Line 361...
361
 *  Returns:
361
 *  Returns:
362
 *      Nothing
362
 *      Nothing
363
 *
363
 *
364
 *========================================================================*/
364
 *========================================================================*/
365
 
365
 
366
void display_config( void )
366
//void display_config( void )
367
{
367
//{
368
    d_config( &config, M_DISPLAY );
368
//    d_config( &config, M_DISPLAY );
369
 
369
 
370
    cur( 0, n_lines - 1 );
370
//    cur( 0, n_lines - 1 );
371
    printf( "Any key to return to main menu :" );
371
//    printf( "Any key to return to main menu :" );
372
    getinp(  );
372
//    getinp(  );
373
}
373
//}
374
 
374
 
375
 
375
 
376
/*========================================================================
376
/*========================================================================
377
 *
377
 *
378
 *  Display the class information
378
 *  Display the class information
Line 386... Line 386...
386
 *  Returns:
386
 *  Returns:
387
 *      Nothing
387
 *      Nothing
388
 *
388
 *
389
 *========================================================================*/
389
 *========================================================================*/
390
 
390
 
391
void display_class( void )
391
//void display_class( void )
392
{
392
//{
393
    d_class( &config, M_DISPLAY );
393
//    d_class( &config, M_DISPLAY );
394
 
394
 
395
    cur( 0, n_lines - 1 );
395
//    cur( 0, n_lines - 1 );
396
    printf( "Any key to continue :" );
396
//    printf( "Any key to continue :" );
397
    getinp(  );
397
//    getinp(  );
398
}
398
//}
399
 
399
 
400
/*========================================================================
400
/*========================================================================
401
 *
401
 *
402
 *  Update the class information
402
 *  Update the class information
403
 *
403
 *
Line 410... Line 410...
410
 *  Returns:
410
 *  Returns:
411
 *      Nothing
411
 *      Nothing
412
 *
412
 *
413
 *========================================================================*/
413
 *========================================================================*/
414
 
414
 
415
bool define_class( void )
415
//bool define_class( void )
416
{
416
//{
417
    int         error;
417
//    int         error;
418
    int         i;
418
//    int         i;
419
    bool        changed = FALSE;
419
//    bool        changed = FALSE;
420
 
420
 
421
    /*
421
//    /*
422
     **  Copy working configuration into a temp structure for
422
//     **  Copy working configuration into a temp structure for
423
     **  use within the function
423
//     **  use within the function
424
     */
424
//     */
425
    newcfg = config;
425
//    newcfg = config;
426
 
426
 
427
    do
427
//    do
428
    {
428
//    {
429
        error = 0;
429
//        error = 0;
430
        d_class( &newcfg, M_UPDATE );
430
//        d_class( &newcfg, M_UPDATE );
431
        printf( "\n" );
431
//        printf( "\n" );
432
 
432
 
433
        /*
433
//        /*
434
         **  Now do the Class definitions
434
//         **  Now do the Class definitions
435
         */
435
//         */
436
        for( i = 0; i < MAX_CLASS; i++ )
436
//        for( i = 0; i < MAX_CLASS; i++ )
437
        {
437
//        {
438
            compact( newcfg.team_class[i].abr );
438
//            compact( newcfg.team_class[i].abr );
439
            compact( newcfg.team_class[i].full_name );
439
//            compact( newcfg.team_class[i].full_name );
440
        }
440
//        }
441
 
441
 
442
        for( i = 0; i < MAX_CLASS; i++ )
442
//        for( i = 0; i < MAX_CLASS; i++ )
443
        {
443
//        {
444
            if( ( newcfg.team_class[i].abr[0] == '\0' ) != ( newcfg.team_class[i].full_name[0] == '\0' ) )
444
//            if( ( newcfg.team_class[i].abr[0] == '\0' ) != ( newcfg.team_class[i].full_name[0] == '\0' ) )
445
            {
445
//            {
446
                printf( "Configuration error. Class without description\n" );
446
//                printf( "Configuration error. Class without description\n" );
447
                error++;
447
//                error++;
448
            }
448
//            }
449
            if( newcfg.team_class[i].abr[0] != '\0' && newcfg.team_class[i].start < 0L )
449
//            if( newcfg.team_class[i].abr[0] != '\0' && newcfg.team_class[i].start < 0L )
450
            {
450
//            {
451
                printf( "Configuration error. Bad start time on class\n" );
451
//                printf( "Configuration error. Bad start time on class\n" );
452
                error++;
452
//                error++;
453
            }
453
//            }
454
        }
454
//        }
455
 
455
 
456
        newcfg.num_class = 0;
456
//        newcfg.num_class = 0;
457
        for( i = 0; i < MAX_CLASS; i++ )
457
//        for( i = 0; i < MAX_CLASS; i++ )
458
            if( newcfg.team_class[i].full_name[0] )
458
//            if( newcfg.team_class[i].full_name[0] )
459
                newcfg.num_class++;
459
//                newcfg.num_class++;
460
 
460
 
461
        for( i = newcfg.num_class; i < MAX_CLASS; i++ )
461
//        for( i = newcfg.num_class; i < MAX_CLASS; i++ )
462
            if( newcfg.team_class[i].full_name[0] )
462
//            if( newcfg.team_class[i].full_name[0] )
463
            {
463
//            {
464
                printf( "Configuration error: Missing Class name. Gaps not allowed\n" );
464
//                printf( "Configuration error: Missing Class name. Gaps not allowed\n" );
465
                error++;
465
//                error++;
466
            }
466
//            }
467
 
467
 
468
        if( newcfg.num_class == 0 )
468
//        if( newcfg.num_class == 0 )
469
        {
469
//        {
470
            printf( "Error: No categories defined\n" );
470
//            printf( "Error: No categories defined\n" );
471
            error++;
471
//            error++;
472
        }
472
//        }
473
 
473
 
474
        newcfg.nonequestrian_class = lookup_class( newcfg.nonequestrian_class_abr, &newcfg );
474
//        newcfg.nonequestrian_class = lookup_class( newcfg.nonequestrian_class_abr, &newcfg );
475
        if( newcfg.equestrian_leg && newcfg.nonequestrian_class == 0 )
475
//        if( newcfg.equestrian_leg && newcfg.nonequestrian_class == 0 )
476
            printf( "WARNING: Non-equestrian class not found\n" );
476
//            printf( "WARNING: Non-equestrian class not found\n" );
477
 
477
 
478
        abort_flag = FALSE;
478
//        abort_flag = FALSE;
479
        if( error )
479
//        if( error )
480
        {
480
//        {
481
            printf( "Any key to continue " );
481
//            printf( "Any key to continue " );
482
            getinp(  );
482
//            getinp(  );
483
        }
483
//        }
484
        else
484
//        else
485
        {
485
//        {
486
            printf( "Install configuration (Y)es, (D)iscard, (E)dit again :" );
486
//            printf( "Install configuration (Y)es, (D)iscard, (E)dit again :" );
487
            switch ( getfnc( "*YDEA" ) )
487
//            switch ( getfnc( "*YDEA" ) )
488
            {
488
//            {
489
            case 'Y':
489
//            case 'Y':
490
                config = newcfg;
490
//                config = newcfg;
491
                wt_config(  );
491
//                wt_config(  );
492
                changed = TRUE;
492
//                changed = TRUE;
493
                break;
493
//                break;
494
 
494
 
495
            case 'D':
495
//            case 'D':
496
                break;
496
//                break;
497
 
497
 
498
            default:
498
//            default:
499
                error = TRUE;
499
//                error = TRUE;
500
                break;
500
//                break;
501
            }
501
//            }
502
        }
502
//        }
503
    } while( error && ! abort_flag );
503
//    } while( error && ! abort_flag );
504
    return ( changed );
504
//    return ( changed );
505
}
505
//}
506
 
506
 
507
/*========================================================================
507
/*========================================================================
508
 *
508
 *
509
 *  Update the class information
509
 *  Update the class information
510
 *
510
 *
Line 521... Line 521...
521
 *  Returns:
521
 *  Returns:
522
 *      Nothing
522
 *      Nothing
523
 *
523
 *
524
 *========================================================================*/
524
 *========================================================================*/
525
 
525
 
526
void d_class( MARA_CFG * config, int operation )
526
//void d_class( MARA_CFG * config, int operation )
527
{
527
//{
528
    int         i, j, k;
528
//    int         i, j, k;
529
    int         maxitr;                          /* Max number of definitions during update */
529
//    int         maxitr;                          /* Max number of definitions during update */
530
    int         opr;
530
//    int         opr;
531
 
531
 
532
    abort_flag = FALSE;
532
//    abort_flag = FALSE;
533
    if( operation == M_UPDATE )
533
//    if( operation == M_UPDATE )
534
    {
534
//    {
535
        opr = M_UPDATE;
535
//        opr = M_UPDATE;
536
        d_class( config, M_PREDISPLAY );         /* Force display before update */
536
//        d_class( config, M_PREDISPLAY );         /* Force display before update */
537
    }
537
//    }
538
    else
538
//    else
539
    {
539
//    {
540
        opr = M_DISPLAY;
540
//        opr = M_DISPLAY;
541
        clearscreen(  );
541
//        clearscreen(  );
542
    }
542
//    }
543
 
543
 
544
    i = 0;                                       /* Set line 0 */
544
//    i = 0;                                       /* Set line 0 */
545
    d_field( 0, i++, "Category definitions", D_NULL, 0, ( char * ) 0, TRUE, M_DISPLAY );
545
//    d_field( 0, i++, "Category definitions", D_NULL, 0, ( char * ) 0, TRUE, M_DISPLAY );
546
    i++;
546
//    i++;
547
 
547
 
548
    maxitr = ( operation == M_DISPLAY ) ? config->num_class : MAX_CLASS;
548
//    maxitr = ( operation == M_DISPLAY ) ? config->num_class : MAX_CLASS;
549
 
549
 
550
    for( j = 0, k = 0; j < maxitr; j++ )
550
//    for( j = 0, k = 0; j < maxitr; j++ )
551
    {
551
//    {
552
        bool        non_equestrian = FALSE;
552
//        bool        non_equestrian = FALSE;
553
 
553
 
554
        d_field( 0 + k, i, "Cat:", D_USTRING, 2, ( char * ) config->team_class[j].abr, TRUE, opr );
554
//        d_field( 0 + k, i, "Cat:", D_USTRING, 2, ( char * ) config->team_class[j].abr, TRUE, opr );
555
 
555
 
556
        if( ( config->team_class[j].abr[0] == config->nonequestrian_class_abr[0] )
556
//        if( ( config->team_class[j].abr[0] == config->nonequestrian_class_abr[0] )
557
            && ( config->team_class[j].abr[1] == config->nonequestrian_class_abr[1] ) )
557
//            && ( config->team_class[j].abr[1] == config->nonequestrian_class_abr[1] ) )
558
        {
558
//        {
559
            non_equestrian = TRUE;
559
//            non_equestrian = TRUE;
560
        }
560
//        }
561
 
561
 
562
        d_field( 8 + k, i, ":", D_STRING, LEN_CLASS_NAME,
562
//        d_field( 8 + k, i, ":", D_STRING, LEN_CLASS_NAME,
563
                 config->team_class[j].full_name, TRUE, opr );
563
//                 config->team_class[j].full_name, TRUE, opr );
564
 
564
 
565
        if( !non_equestrian )
565
//        if( !non_equestrian )
566
            d_field( LEN_CLASS_NAME + 10 + k, i, "Start:", D_TIME, 8,
566
//            d_field( LEN_CLASS_NAME + 10 + k, i, "Start:", D_TIME, 8,
567
                     ( char * ) &config->team_class[j].start, TRUE, opr );
567
//                     ( char * ) &config->team_class[j].start, TRUE, opr );
568
 
568
 
569
        /*
569
//        /*
570
         **  Step to next column or row
570
//         **  Step to next column or row
571
         */
571
//         */
572
        k += 40;
572
//        k += 40;
573
        if( !( ( j + 1 ) % 2 ) )
573
//        if( !( ( j + 1 ) % 2 ) )
574
        {
574
//        {
575
            k = 0;
575
//            k = 0;
576
            i++;
576
//            i++;
577
        }
577
//        }
578
    }
578
//    }
579
}
579
//}
580
 
580
 
581
/*========================================================================
581
/*========================================================================
582
 *
582
 *
583
 *  Configuration Update and Display
583
 *  Configuration Update and Display
584
 *
584
 *
Line 591... Line 591...
591
 *  Returns:
591
 *  Returns:
592
 *      Nothing
592
 *      Nothing
593
 *
593
 *
594
 *========================================================================*/
594
 *========================================================================*/
595
 
595
 
596
void d_config( MARA_CFG * config, int operation )
596
//void d_config( MARA_CFG * config, int operation )
597
{
597
//{
598
    int         i, j, k;
598
//    int         i, j, k;
599
    int         maxitr;                          /* Max number of definitions during update */
599
//    int         maxitr;                          /* Max number of definitions during update */
600
    int         opr;
600
//    int         opr;
601
 
601
 
602
    abort_flag = FALSE;
602
//    abort_flag = FALSE;
603
    if( operation == M_UPDATE )
603
//    if( operation == M_UPDATE )
604
    {
604
//    {
605
        opr = M_UPDATE;
605
//        opr = M_UPDATE;
606
        d_config( config, M_PREDISPLAY );        /* Force display before update */
606
//        d_config( config, M_PREDISPLAY );        /* Force display before update */
607
    }
607
//    }
608
    else
608
//    else
609
    {
609
//    {
610
        opr = M_DISPLAY;
610
//        opr = M_DISPLAY;
611
        clearscreen(  );
611
//        clearscreen(  );
612
    }
612
//    }
613
    i = 0;                                       /* Set line 0 */
613
//    i = 0;                                       /* Set line 0 */
614
 
614
 
615
    d_field( 0, i++, "Marathon configuration", D_NULL, 0, ( char * ) 0, TRUE, M_DISPLAY );
615
//    d_field( 0, i++, "Marathon configuration", D_NULL, 0, ( char * ) 0, TRUE, M_DISPLAY );
616
    d_field( 0, ++i, "Name: ", D_STRING, MAX_EVENT_NAME, config->event_name, TRUE, opr );
616
//    d_field( 0, ++i, "Name: ", D_STRING, MAX_EVENT_NAME, config->event_name, TRUE, opr );
617
 
617
 
618
    /*
618
//    /*
619
     * display the leg names 
619
//     * display the leg names
620
     */
620
//     */
621
 
621
 
622
    i += 2;
622
//    i += 2;
623
    maxitr = ( operation == M_DISPLAY ) ? config->num_legs : MAX_LEGS;
623
//    maxitr = ( operation == M_DISPLAY ) ? config->num_legs : MAX_LEGS;
624
    for( j = 1; j <= maxitr; j++, i++ )
624
//    for( j = 1; j <= maxitr; j++, i++ )
625
    {
625
//    {
626
        d_field( 0, i, "Leg ", D_NUMBER, 1, ( char * ) &j, TRUE, M_DISPLAY );
626
//        d_field( 0, i, "Leg ", D_NUMBER, 1, ( char * ) &j, TRUE, M_DISPLAY );
627
        d_field( 6, i, ": ", D_STRING, MAX_LEG_NAME, config->leg_name[j - 1], TRUE, opr );
627
//        d_field( 6, i, ": ", D_STRING, MAX_LEG_NAME, config->leg_name[j - 1], TRUE, opr );
628
    }
628
//    }
629
    abort_flag = FALSE;                          /* Trap aborts at the next field */
629
//    abort_flag = FALSE;                          /* Trap aborts at the next field */
630
 
630
 
631
 
631
 
632
    /*
632
//    /*
633
     * Display the team break definitions 
633
//     * Display the team break definitions
634
     */
634
//     */
635
 
635
 
636
    i++;
636
//    i++;
637
 
637
 
638
    d_field( 0, i++, "Valid team numbers are in the following ranges", D_NULL,
638
//    d_field( 0, i++, "Valid team numbers are in the following ranges", D_NULL,
639
             0, ( char * ) 0, TRUE, M_DISPLAY );
639
//             0, ( char * ) 0, TRUE, M_DISPLAY );
640
 
640
 
641
    maxitr = ( operation == M_DISPLAY ) ? config->num_teams : MAX_TMS_SPLIT;
641
//    maxitr = ( operation == M_DISPLAY ) ? config->num_teams : MAX_TMS_SPLIT;
642
    for( k = 0, j = 0; j < maxitr; j++ )
642
//    for( k = 0, j = 0; j < maxitr; j++ )
643
    {
643
//    {
644
        d_field( k + 0, i, "From ", D_NUMBER, 4, ( char * ) &config->t_def[j].start, TRUE, opr );
644
//        d_field( k + 0, i, "From ", D_NUMBER, 4, ( char * ) &config->t_def[j].start, TRUE, opr );
645
        d_field( k + 9, i, " to ", D_NUMBER, 4, ( char * ) &config->t_def[j].end, TRUE, opr );
645
//        d_field( k + 9, i, " to ", D_NUMBER, 4, ( char * ) &config->t_def[j].end, TRUE, opr );
646
        k += 20;
646
//        k += 20;
647
        if( !( ( j + 1 ) % 4 ) )
647
//        if( !( ( j + 1 ) % 4 ) )
648
        {
648
//        {
649
            k = 0;
649
//            k = 0;
650
            i++;
650
//            i++;
651
        }
651
//        }
652
    }
652
//    }
653
 
653
 
654
    /*
654
//    /*
655
     * Name of legend config->addendum file 
655
//     * Name of legend config->addendum file
656
     */
656
//     */
657
 
657
 
658
    abort_flag = FALSE;
658
//    abort_flag = FALSE;
659
    i++;
659
//    i++;
660
    d_field( 0, i++, "Legend addendum file :", D_STRING,
660
//    d_field( 0, i++, "Legend addendum file :", D_STRING,
661
             ( int ) sizeof( config->addendum ) - 1, ( char * ) config->addendum, TRUE, opr );
661
//             ( int ) sizeof( config->addendum ) - 1, ( char * ) config->addendum, TRUE, opr );
662
 
662
 
663
    /*
663
//    /*
664
     * Name of the alternate data file 
664
//     * Name of the alternate data file
665
     */
665
//     */
666
    d_field( 0, i++, "Data filename :", D_STRING,
666
//    d_field( 0, i++, "Data filename :", D_STRING,
667
             ( int ) sizeof( config->datafilename ) - 1,
667
//             ( int ) sizeof( config->datafilename ) - 1,
668
             ( char * ) config->datafilename, TRUE, opr );
668
//             ( char * ) config->datafilename, TRUE, opr );
669
 
669
 
670
    /*
670
//    /*
671
     **  Non-equestrian configuration information
671
//     **  Non-equestrian configuration information
672
     */
672
//     */
673
    abort_flag = FALSE;
673
//    abort_flag = FALSE;
674
    i++;
674
//    i++;
675
    d_field( 0, i++, "Equestrian Leg :", D_NUMBER, 1, ( char * ) &config->equestrian_leg, TRUE, opr );
675
//    d_field( 0, i++, "Equestrian Leg :", D_NUMBER, 1, ( char * ) &config->equestrian_leg, TRUE, opr );
676
    d_field( 0, i++, "Non-Equestrian Category :", D_USTRING,
676
//    d_field( 0, i++, "Non-Equestrian Category :", D_USTRING,
677
             ( int ) sizeof( config->nonequestrian_class_abr ) - 1,
677
//             ( int ) sizeof( config->nonequestrian_class_abr ) - 1,
678
             ( char * ) config->nonequestrian_class_abr, TRUE, opr );
678
//             ( char * ) config->nonequestrian_class_abr, TRUE, opr );
679
 
679
 
680
    /*
680
//    /*
681
    **  Print control
681
//    **  Print control
682
    */
682
//    */
683
    abort_flag = FALSE;
683
//    abort_flag = FALSE;
684
    i++;
684
//    i++;
685
    d_field(  0, i,   "Lines Per Page :", D_NUMBER, 3, ( char * ) &config->lines_per_page, TRUE, opr );
685
//    d_field(  0, i,   "Lines Per Page :", D_NUMBER, 3, ( char * ) &config->lines_per_page, TRUE, opr );
686
    d_field( 30, i++, "Perf Skip :", D_NUMBER, 1, ( char * ) &config->perf_skip, TRUE, opr );
686
//    d_field( 30, i++, "Perf Skip :", D_NUMBER, 1, ( char * ) &config->perf_skip, TRUE, opr );
687
}
687
//}
688
 
688
 
689
/*========================================================================
689
/*========================================================================
690
 *
690
 *
691
 *  Display the current country list
691
 *  Display the current country list
692
 *
692
 *
Line 699... Line 699...
699
 *  Returns:
699
 *  Returns:
700
 *      Nothing
700
 *      Nothing
701
 *
701
 *
702
 *========================================================================*/
702
 *========================================================================*/
703
 
703
 
704
void display_country( void )
704
//void display_country( void )
705
{
705
//{
706
    d_cntry( &config, M_DISPLAY );
706
//    d_cntry( &config, M_DISPLAY );
707
 
707
 
708
    cur( 0, n_lines - 1 );
708
//    cur( 0, n_lines - 1 );
709
    printf( "Any key to return to main menu :" );
709
//    printf( "Any key to return to main menu :" );
710
    ( void ) getinp(  );
710
//    ( void ) getinp(  );
711
}
711
//}
712
 
712
 
713
/*========================================================================
713
/*========================================================================
714
 *
714
 *
715
 *  Define a new entry in the county list
715
 *  Define a new entry in the county list
716
 *
716
 *
Line 723... Line 723...
723
 *  Returns:
723
 *  Returns:
724
 *      Nothing
724
 *      Nothing
725
 *
725
 *
726
 *========================================================================*/
726
 *========================================================================*/
727
 
727
 
728
void define_country( void )
728
//void define_country( void )
729
{
729
//{
730
    int         error;
730
//    int         error;
731
    ty_t_country *ptr;
731
//    ty_t_country *ptr;
732
    int         i;
732
//    int         i;
733
 
733
 
734
    /*
734
//    /*
735
     **  Copy working configuration into a temp structure for
735
//     **  Copy working configuration into a temp structure for
736
     **  use within the function
736
//     **  use within the function
737
     */
737
//     */
738
    newcfg = config;
738
//    newcfg = config;
739
 
739
 
740
    do
740
//    do
741
    {
741
//    {
742
        error = 0;
742
//        error = 0;
743
        newcfg.num_countries = 0;
743
//        newcfg.num_countries = 0;
744
 
744
 
745
        /*
745
//        /*
746
         * Get the operator to update the screen 
746
//         * Get the operator to update the screen
747
         */
747
//         */
748
 
748
 
749
        d_cntry( &newcfg, M_UPDATE );               /* Update the country data */
749
//        d_cntry( &newcfg, M_UPDATE );               /* Update the country data */
750
        printf( "\n" );
750
//        printf( "\n" );
751
 
751
 
752
        /*
752
//        /*
753
         * Now check the data that has been entered. 
753
//         * Now check the data that has been entered.
754
         */
754
//         */
755
 
755
 
756
        ptr = newcfg.country_name;
756
//        ptr = newcfg.country_name;
757
        for( i = 0; i < MAX_COUNTRY; i++, ptr++ )
757
//        for( i = 0; i < MAX_COUNTRY; i++, ptr++ )
758
        {
758
//        {
759
            compact( ptr->abr );
759
//            compact( ptr->abr );
760
            compact( ptr->full_name );
760
//            compact( ptr->full_name );
761
            if( ( ptr->abr[0] == '\0' ) != ( ptr->full_name[0] == '\0' ) )
761
//            if( ( ptr->abr[0] == '\0' ) != ( ptr->full_name[0] == '\0' ) )
762
            {
762
//            {
763
                error++;
763
//                error++;
764
                printf( "Missing field\n" );
764
//                printf( "Missing field\n" );
765
            }
765
//            }
766
            if( ptr->abr[0] )
766
//            if( ptr->abr[0] )
767
                newcfg.num_countries++;
767
//                newcfg.num_countries++;
768
        }
768
//        }
769
 
769
 
770
        if( error )
770
//        if( error )
771
        {
771
//        {
772
            printf( "Configuration error - error must be corrected\n" );
772
//            printf( "Configuration error - error must be corrected\n" );
773
            printf( "Any key to continue " );
773
//            printf( "Any key to continue " );
774
            ( void ) getinp(  );
774
//            ( void ) getinp(  );
775
        }
775
//        }
776
        else
776
//        else
777
        {
777
//        {
778
            printf( "Install configuration (Y)es, (D)iscard, (E)dit again :" );
778
//            printf( "Install configuration (Y)es, (D)iscard, (E)dit again :" );
779
            switch ( getfnc( "*YDEA" ) )
779
//            switch ( getfnc( "*YDEA" ) )
780
            {
780
//            {
781
            case 'Y':
781
//            case 'Y':
782
                config = newcfg;
782
//                config = newcfg;
783
                wt_config(  );                   /* Write out the data */
783
//                wt_config(  );                   /* Write out the data */
784
                break;
784
//                break;
785
 
785
 
786
            case 'D':
786
//            case 'D':
787
                break;
787
//                break;
788
 
788
 
789
            default:
789
//            default:
790
                error = TRUE;
790
//                error = TRUE;
791
                break;
791
//                break;
792
            }
792
//            }
793
        }
793
//        }
794
    } while( error );
794
//    } while( error );
795
    return;
795
//    return;
796
}
796
//}
797
 
797
 
798
 
798
 
799
/*========================================================================
799
/*========================================================================
800
 *
800
 *
801
 *  Display / Update Country list
801
 *  Display / Update Country list
Line 809... Line 809...
809
 *  Returns:
809
 *  Returns:
810
 *      Nothing
810
 *      Nothing
811
 *
811
 *
812
 *========================================================================*/
812
 *========================================================================*/
813
 
813
 
814
void d_cntry( MARA_CFG * config, int operation )
814
//void d_cntry( MARA_CFG * config, int operation )
815
{
815
//{
816
    int         i, j, k;
816
//    int         i, j, k;
817
    int         opr;
817
//    int         opr;
818
 
818
 
819
    abort_flag = FALSE;
819
//    abort_flag = FALSE;
820
    if( operation == M_UPDATE )
820
//    if( operation == M_UPDATE )
821
    {
821
//    {
822
        opr = M_UPDATE;
822
//        opr = M_UPDATE;
823
        d_cntry( config, M_PREDISPLAY );         /* Force display before update */
823
//        d_cntry( config, M_PREDISPLAY );         /* Force display before update */
824
    }
824
//    }
825
    else
825
//    else
826
    {
826
//    {
827
        opr = M_DISPLAY;
827
//        opr = M_DISPLAY;
828
        clearscreen(  );
828
//        clearscreen(  );
829
    }
829
//    }
830
    i = 0;                                       /* Set line 0 */
830
//    i = 0;                                       /* Set line 0 */
831
 
831
 
832
    d_field( 0, i++, "Country classifications", D_NULL, 0, ( char * ) 0, TRUE, M_DISPLAY );
832
//    d_field( 0, i++, "Country classifications", D_NULL, 0, ( char * ) 0, TRUE, M_DISPLAY );
833
 
833
 
834
    /*
834
//    /*
835
     * Display the country names 
835
//     * Display the country names
836
     */
836
//     */
837
 
837
 
838
    i++;
838
//    i++;
839
 
839
 
840
    for( j = 0, k = 0; j < MAX_COUNTRY; j++ )
840
//    for( j = 0, k = 0; j < MAX_COUNTRY; j++ )
841
    {
841
//    {
842
        d_field( 0 + k, i, "Country: ", D_STRING, 4,
842
//        d_field( 0 + k, i, "Country: ", D_STRING, 4,
843
                 ( char * ) config->country_name[j].abr, TRUE, opr );
843
//                 ( char * ) config->country_name[j].abr, TRUE, opr );
844
        d_field( 13 + k, i, ": ", D_STRING, LEN_CNTRY_NAME,
844
//        d_field( 13 + k, i, ": ", D_STRING, LEN_CNTRY_NAME,
845
                 config->country_name[j].full_name, TRUE, opr );
845
//                 config->country_name[j].full_name, TRUE, opr );
846
 
846
 
847
        k += 40;
847
//        k += 40;
848
        if( !( ( j + 1 ) % 2 ) )
848
//        if( !( ( j + 1 ) % 2 ) )
849
        {
849
//        {
850
            k = 0;
850
//            k = 0;
851
            i++;
851
//            i++;
852
        }
852
//        }
853
    }
853
//    }
854
}
854
//}
855
 
855
 
856
/*========================================================================
856
/*========================================================================
857
 *
857
 *
858
 *  Display the Winners List
858
 *  Display the Winners List
859
 *
859
 *
Line 866... Line 866...
866
 *  Returns:
866
 *  Returns:
867
 *      Nothing
867
 *      Nothing
868
 *
868
 *
869
 *========================================================================*/
869
 *========================================================================*/
870
 
870
 
871
void display_winners( void )
871
//void display_winners( void )
872
{
872
//{
873
    calc_class_summary( & class_summary );
873
//    calc_class_summary( & class_summary );
874
    d_winners( &config, M_DISPLAY );
874
//    d_winners( &config, M_DISPLAY );
875
 
875
 
876
    cur( 0, n_lines - 1 );
876
//    cur( 0, n_lines - 1 );
877
    printf( "Any key to return to main menu :" );
877
//    printf( "Any key to return to main menu :" );
878
    ( void ) getinp(  );
878
//    ( void ) getinp(  );
879
}
879
//}
880
 
880
 
881
/*========================================================================
881
/*========================================================================
882
 *
882
 *
883
 *  Update the winners information
883
 *  Update the winners information
884
 *
884
 *
Line 891... Line 891...
891
 *  Returns:
891
 *  Returns:
892
 *      Nothing
892
 *      Nothing
893
 *
893
 *
894
 *========================================================================*/
894
 *========================================================================*/
895
 
895
 
896
bool define_winners( void )
896
//bool define_winners( void )
897
{
897
//{
898
    int         error;
898
//    int         error;
899
    int         i;
899
//    int         i;
900
    bool        changed = FALSE;
900
//    bool        changed = FALSE;
901
 
901
 
902
    /*
902
//    /*
903
    **  Update the class summary info to give the user a hint
903
//    **  Update the class summary info to give the user a hint
904
    */
904
//    */
905
    calc_class_summary( & class_summary );
905
//    calc_class_summary( & class_summary );
906
 
906
 
907
    /*
907
//    /*
908
     **  Copy working configuration into a temp structure for
908
//     **  Copy working configuration into a temp structure for
909
     **  use within the function
909
//     **  use within the function
910
     */
910
//     */
911
    newcfg = config;
911
//    newcfg = config;
912
 
912
 
913
    /*
913
//    /*
914
    **  Edit and sanity test the cnfig data until the user is happy
914
//    **  Edit and sanity test the cnfig data until the user is happy
915
    **  with it - or is ready to discard it.
915
//    **  with it - or is ready to discard it.
916
    */
916
//    */
917
    do
917
//    do
918
    {
918
//    {
919
        error = 0;
919
//        error = 0;
920
        d_winners ( &newcfg, M_UPDATE );
920
//        d_winners ( &newcfg, M_UPDATE );
921
        printf( "\n" );
921
//        printf( "\n" );
922
 
922
 
923
        /*
923
//        /*
924
        **  Sanity test of the data
924
//        **  Sanity test of the data
925
        */
925
//        */
926
        for( i = 0; i < MAX_CLASS; i++ )
926
//        for( i = 0; i < MAX_CLASS; i++ )
927
        {
927
//        {
928
            if( newcfg.team_class[i].abr[0] != '\0' && newcfg.class_winners[i] == 0 )
928
//            if( newcfg.team_class[i].abr[0] != '\0' && newcfg.class_winners[i] == 0 )
929
            {
929
//            {
930
                printf( "  Warning: Class without winners: %s\n", newcfg.team_class[i].abr );
930
//                printf( "  Warning: Class without winners: %s\n", newcfg.team_class[i].abr );
931
            }
931
//            }
932
 
932
 
933
            if ( newcfg.class_winners[i] > class_summary.teamclass[i+1].total )
933
//            if ( newcfg.class_winners[i] > class_summary.teamclass[i+1].total )
934
            {
934
//            {
935
                printf( "  Warning: Num winners greater than those in class: %s\n", newcfg.team_class[i].abr );
935
//                printf( "  Warning: Num winners greater than those in class: %s\n", newcfg.team_class[i].abr );
936
            }
936
//            }
937
        }
937
//        }
938
 
938
 
939
 
939
 
940
        newcfg.num_fame = 0;
940
//        newcfg.num_fame = 0;
941
        for( i = 0; i < MAX_FAME; i++ )
941
//        for( i = 0; i < MAX_FAME; i++ )
942
            if( newcfg.hall_fame[i][0] )
942
//            if( newcfg.hall_fame[i][0] )
943
                newcfg.num_fame++;
943
//                newcfg.num_fame++;
944
 
944
 
945
        for( i = newcfg.num_fame; i < MAX_FAME; i++ )
945
//        for( i = newcfg.num_fame; i < MAX_FAME; i++ )
946
            if( newcfg.hall_fame[i][0] )
946
//            if( newcfg.hall_fame[i][0] )
947
            {
947
//            {
948
                printf( "Configuration error: Missing Fame name. Gaps not allowed\n" );
948
//                printf( "Configuration error: Missing Fame name. Gaps not allowed\n" );
949
                error++;
949
//                error++;
950
                break;
950
//                break;
951
            }
951
//            }
952
 
952
 
953
        abort_flag = FALSE;
953
//        abort_flag = FALSE;
954
        if( error )
954
//        if( error )
955
        {
955
//        {
956
            printf( "Any key to continue " );
956
//            printf( "Any key to continue " );
957
            getinp(  );
957
//            getinp(  );
958
        }
958
//        }
959
        else
959
//        else
960
        {
960
//        {
961
            printf( "Install configuration (Y)es, (D)iscard, (E)dit again :" );
961
//            printf( "Install configuration (Y)es, (D)iscard, (E)dit again :" );
962
            switch ( getfnc( "*YDEA" ) )
962
//            switch ( getfnc( "*YDEA" ) )
963
            {
963
//            {
964
            case 'Y':
964
//            case 'Y':
965
                config = newcfg;
965
//                config = newcfg;
966
                wt_config(  );
966
//                wt_config(  );
967
                changed = TRUE;
967
//                changed = TRUE;
968
                break;
968
//                break;
969
 
969
 
970
            case 'D':
970
//            case 'D':
971
                break;
971
//                break;
972
 
972
 
973
            default:
973
//            default:
974
                error = TRUE;
974
//                error = TRUE;
975
                break;
975
//                break;
976
            }
976
//            }
977
        }
977
//        }
978
    } while( error && ! abort_flag );
978
//    } while( error && ! abort_flag );
979
    return ( changed );
979
//    return ( changed );
980
}
980
//}
981
 
981
 
982
 
982
 
983
/*========================================================================
983
/*========================================================================
984
 *
984
 *
985
 *  Display / Update winners list
985
 *  Display / Update winners list
Line 993... Line 993...
993
 *  Returns:
993
 *  Returns:
994
 *      Nothing
994
 *      Nothing
995
 *
995
 *
996
 *========================================================================*/
996
 *========================================================================*/
997
 
997
 
998
void d_winners( MARA_CFG * config, int operation )
998
//void d_winners( MARA_CFG * config, int operation )
999
{
999
//{
1000
    int         i, j, k;
1000
//    int         i, j, k;
1001
    int         maxitr;                          /* Max number of definitions during update */
1001
//    int         maxitr;                          /* Max number of definitions during update */
1002
    int         opr;
1002
//    int         opr;
1003
 
1003
 
1004
    abort_flag = FALSE;
1004
//    abort_flag = FALSE;
1005
    if( operation == M_UPDATE )
1005
//    if( operation == M_UPDATE )
1006
    {
1006
//    {
1007
        opr = M_UPDATE;
1007
//        opr = M_UPDATE;
1008
        d_winners( config, M_PREDISPLAY );         /* Force display before update */
1008
//        d_winners( config, M_PREDISPLAY );         /* Force display before update */
1009
    }
1009
//    }
1010
    else
1010
//    else
1011
    {
1011
//    {
1012
        opr = M_DISPLAY;
1012
//        opr = M_DISPLAY;
1013
        clearscreen(  );
1013
//        clearscreen(  );
1014
    }
1014
//    }
1015
 
1015
 
1016
    i = 0;                                       /* Set line 0 */
1016
//    i = 0;                                       /* Set line 0 */
1017
    d_field( 0, i++, "Winner definitions", D_NULL, 0, ( char * ) 0, TRUE, M_DISPLAY );
1017
//    d_field( 0, i++, "Winner definitions", D_NULL, 0, ( char * ) 0, TRUE, M_DISPLAY );
1018
    i++;
1018
//    i++;
1019
 
1019
 
1020
    maxitr = config->num_class;
1020
//    maxitr = config->num_class;
1021
 
1021
 
1022
    for( j = 0, k = 0; j < maxitr; j++ )
1022
//    for( j = 0, k = 0; j < maxitr; j++ )
1023
    {
1023
//    {
1024
        d_field( 0 + k, i, "Cat:", D_USTRING, 2, ( char * ) config->team_class[j].abr, TRUE, M_DISPLAY );
1024
//        d_field( 0 + k, i, "Cat:", D_USTRING, 2, ( char * ) config->team_class[j].abr, TRUE, M_DISPLAY );
1025
 
1025
 
1026
        d_field( 7 + k, i, ":", D_STRING, LEN_CLASS_NAME,
1026
//        d_field( 7 + k, i, ":", D_STRING, LEN_CLASS_NAME,
1027
                 config->team_class[j].full_name, TRUE, M_DISPLAY );
1027
//                 config->team_class[j].full_name, TRUE, M_DISPLAY );
1028
 
1028
 
1029
        d_field( LEN_CLASS_NAME + 9 + k, i, "Num:", D_NUMBER, 3,
1029
//        d_field( LEN_CLASS_NAME + 9 + k, i, "Num:", D_NUMBER, 3,
1030
                     ( char * ) &class_summary.teamclass[j+1].total, TRUE, M_DISPLAY );
1030
//                     ( char * ) &class_summary.teamclass[j+1].total, TRUE, M_DISPLAY );
1031
 
1031
 
1032
        d_field( LEN_CLASS_NAME + 9 + 7 + k, i, "Win:", D_NUMBER, 3,
1032
//        d_field( LEN_CLASS_NAME + 9 + 7 + k, i, "Win:", D_NUMBER, 3,
1033
                     ( char * ) &config->class_winners[j], TRUE, opr );
1033
//                     ( char * ) &config->class_winners[j], TRUE, opr );
1034
 
1034
 
1035
        /*
1035
//        /*
1036
         **  Step to next column or row
1036
//         **  Step to next column or row
1037
         */
1037
//         */
1038
        k += 40;
1038
//        k += 40;
1039
        if( !( ( j + 1 ) % 2 ) )
1039
//        if( !( ( j + 1 ) % 2 ) )
1040
        {
1040
//        {
1041
            k = 0;
1041
//            k = 0;
1042
            i++;
1042
//            i++;
1043
        }
1043
//        }
1044
    }
1044
//    }
1045
 
1045
 
1046
    abort_flag =  FALSE;
1046
//    abort_flag =  FALSE;
1047
    i += 2;
1047
//    i += 2;
1048
    d_field( 0, i++, "Hall of Fame", D_NULL, 0, ( char * ) 0, TRUE, M_DISPLAY );
1048
//    d_field( 0, i++, "Hall of Fame", D_NULL, 0, ( char * ) 0, TRUE, M_DISPLAY );
1049
    for( j = 0, k = 0; j < MAX_FAME; j++ )
1049
//    for( j = 0, k = 0; j < MAX_FAME; j++ )
1050
    {
1050
//    {
1051
        d_field( k, i, "Name : ", D_STRING, MAX_PERSON_NAME,
1051
//        d_field( k, i, "Name : ", D_STRING, MAX_PERSON_NAME,
1052
                 &config->hall_fame[j], TRUE, opr );
1052
//                 &config->hall_fame[j], TRUE, opr );
1053
        k += 40;
1053
//        k += 40;
1054
        if( !( ( j + 1 ) % 2 ) )
1054
//        if( !( ( j + 1 ) % 2 ) )
1055
        {
1055
//        {
1056
            k = 0;
1056
//            k = 0;
1057
            i++;
1057
//            i++;
1058
        }
1058
//        }
1059
    }
1059
//    }
1060
}
1060
//}
1061
 
1061
 
1062
 
1062
 
1063
/*========================================================================
1063
/*========================================================================
1064
 *
1064
 *
1065
 *  Read in the configuration file
1065
 *  Read in the configuration file