Subversion Repositories svn1-original

Rev

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

Rev 95 Rev 162
Line 57... Line 57...
57
 *  Returns:
57
 *  Returns:
58
 *      TRUE - Change made
58
 *      TRUE - Change made
59
 *
59
 *
60
 *========================================================================*/
60
 *========================================================================*/
61
 
61
 
62
void team_update(void)
62
//void team_update(void)
63
{
63
//{
64
    if( !g_tnum( 0, n_lines - 2, "Enter team number" ) )
64
//    if( !g_tnum( 0, n_lines - 2, "Enter team number" ) )
65
        return;                        /* Exit operation */
65
//        return;                        /* Exit operation */
66
 
66
 
67
    /*
67
//    /*
68
     **  Fetch the team record into memory
68
//     **  Fetch the team record into memory
69
     **  If the record does not exist a record with an invalid flag
69
//     **  If the record does not exist a record with an invalid flag
70
     **  will be returned
70
//     **  will be returned
71
     */
71
//     */
-
 
72
 
-
 
73
//    do
-
 
74
//    {
-
 
75
//        clearscreen();
-
 
76
//        g_record( team, &team_buf );
-
 
77
//        d_display( M_TEAM );
-
 
78
//        put_team_record( team, &team_buf );
72
 
79
 
73
    do
-
 
74
    {
-
 
75
        clearscreen();
-
 
76
        g_record( team, &team_buf );
-
 
77
        d_display( M_TEAM );
-
 
78
        put_team_record( team, &team_buf );
-
 
79
 
-
 
80
    } while( g_tnum( 0, n_lines - 2, "Enter next team or RETURN to exit" ) );
80
//    } while( g_tnum( 0, n_lines - 2, "Enter next team or RETURN to exit" ) );
81
}
81
//}
82
 
82
 
83
/*=======================================================================
83
/*=======================================================================
84
 *
84
 *
85
 *  Display team data on the screen
85
 *  Display team data on the screen
86
 *
86
 *
Line 95... Line 95...
95
 *  Returns:
95
 *  Returns:
96
 *      TRUE - Change made
96
 *      TRUE - Change made
97
 *
97
 *
98
 *========================================================================*/
98
 *========================================================================*/
99
 
99
 
100
void team_display(void)
100
//void team_display(void)
101
{
101
//{
102
    if( !g_tnum( 0, n_lines - 2, "Enter team number" ) )
102
//    if( !g_tnum( 0, n_lines - 2, "Enter team number" ) )
103
        return;                        /* Exit operation */
103
//        return;                        /* Exit operation */
104
 
104
 
105
    /*
105
//    /*
106
     * Fetch the team record into memory
106
//     * Fetch the team record into memory
107
     * If the record does not exist a record with an invalid flag
107
//     * If the record does not exist a record with an invalid flag
108
     * will be returned
108
//     * will be returned
109
     */
109
//     */
110
 
110
 
111
    do
111
//    do
112
    {
112
//    {
113
        clearscreen();
113
//        clearscreen();
114
        if( g_record( team, &team_buf ) )
114
//        if( g_record( team, &team_buf ) )
115
            d_display( M_DISPLAY );
115
//            d_display( M_DISPLAY );
116
        else
116
//        else
117
        {
117
//        {
118
            cur( 0, n_lines - 1 );
118
//            cur( 0, n_lines - 1 );
119
            printf( "Team %-1d has not yet been entered", team );
119
//            printf( "Team %-1d has not yet been entered", team );
120
            beep();
120
//            beep();
121
        }
121
//        }
122
    } while( g_tnum( 0, n_lines - 2, "Enter next team or RETURN to exit" ) );
122
//    } while( g_tnum( 0, n_lines - 2, "Enter next team or RETURN to exit" ) );
123
}
123
//}
124
 
124
 
125
/*========================================================================
125
/*========================================================================
126
 *
126
 *
127
 *  Modify team leg times
127
 *  Modify team leg times
128
 *
128
 *
Line 136... Line 136...
136
 *
136
 *
137
 *  Returns:
137
 *  Returns:
138
 *      TRUE - Change made
138
 *      TRUE - Change made
139
 *
139
 *
140
 *========================================================================*/
140
 *========================================================================*/
141
void leg_mods(void)
141
//void leg_mods(void)
142
{
142
//{
143
    if( !g_tnum( 0, n_lines - 2, "Enter team number" ) )
143
//    if( !g_tnum( 0, n_lines - 2, "Enter team number" ) )
144
        return;                        /* Exit operation */
144
//        return;                        /* Exit operation */
145
 
145
 
146
    /*
146
//    /*
147
     **  Fetch the team record into memory
147
//     **  Fetch the team record into memory
148
     ** If the record does not exist a record with an invalid flag
148
//     ** If the record does not exist a record with an invalid flag
149
     ** will be returned
149
//     ** will be returned
150
     */
150
//     */
151
 
151
 
152
    do
152
//    do
153
    {
153
//    {
154
        clearscreen();
154
//        clearscreen();
155
        if( g_record( team, &team_buf ) )
155
//        if( g_record( team, &team_buf ) )
156
        {
156
//        {
157
            set_times( &team_buf );
157
//            set_times( &team_buf );
158
            d_display( M_LEGS );
158
//            d_display( M_LEGS );
159
            put_team_record( team, &team_buf );
159
//            put_team_record( team, &team_buf );
160
        }
160
//        }
161
        else
161
//        else
162
        {
162
//        {
163
            cur( 0, n_lines - 1 );
163
//            cur( 0, n_lines - 1 );
164
            printf( "Team %-1d has not yet been entered", team );
164
//            printf( "Team %-1d has not yet been entered", team );
165
            beep();
165
//            beep();
166
        }
166
//        }
167
    } while( g_tnum( 0, n_lines - 2, "Enter next team or RETURN to exit" ) );
167
//    } while( g_tnum( 0, n_lines - 2, "Enter next team or RETURN to exit" ) );
168
 
168
 
169
}
169
//}
170
 
170
 
171
/*========================================================================
171
/*========================================================================
172
 *
172
 *
173
 *  Display all team information
173
 *  Display all team information
174
 *
174
 *
Line 180... Line 180...
180
 *
180
 *
181
 *  Returns:
181
 *  Returns:
182
 *      Nothing
182
 *      Nothing
183
 *
183
 *
184
 *========================================================================*/
184
 *========================================================================*/
185
void d_display( int operation )
185
//void d_display( int operation )
186
{
186
//{
187
    int         valid = team_buf.flags.valid;
187
//    int         valid = team_buf.flags.valid;
188
    int         opr;
188
//    int         opr;
189
    int         i, j;
189
//    int         i, j;
190
    int         age_sum;
190
//    int         age_sum;
191
 
191
 
192
    /*
192
//    /*
193
     **  Refresh the entire display (using a recursive call)
193
//     **  Refresh the entire display (using a recursive call)
194
     */
194
//     */
195
    if( operation != M_DISPLAY )
195
//    if( operation != M_DISPLAY )
196
        d_display( M_DISPLAY );
196
//        d_display( M_DISPLAY );
197
 
197
 
198
 
198
 
199
    /*
199
//    /*
200
     **  Display the team number
200
//     **  Display the team number
201
     **      This cannot be edited.
201
//     **      This cannot be edited.
202
     */
202
//     */
203
    d_field( 0, 0, "Team number : ", D_NUMBER, 6, &team_buf.numb, TRUE,
203
//    d_field( 0, 0, "Team number : ", D_NUMBER, 6, &team_buf.numb, TRUE,
204
             M_DISPLAY );
204
//             M_DISPLAY );
205
 
205
 
206
    /*
206
//    /*
207
     **  Determine the type of operation required
207
//     **  Determine the type of operation required
208
     **      Update or Display
208
//     **      Update or Display
209
     */
209
//     */
210
    opr = ( operation & M_TEAM ) ? M_UPDATE : M_DISPLAY;
210
//    opr = ( operation & M_TEAM ) ? M_UPDATE : M_DISPLAY;
211
 
211
 
212
    /*
212
//    /*
213
     **  Display / Update the team name
213
//     **  Display / Update the team name
214
     */
214
//     */
215
    do
215
//    do
216
    {
216
//    {
217
        d_field( 20, 0, "Team name : ", D_STRING, MAX_TM_NAME, team_buf.name,
217
//        d_field( 20, 0, "Team name : ", D_STRING, MAX_TM_NAME, team_buf.name,
218
                 valid, opr );
218
//                 valid, opr );
219
        if( abort_flag )
219
//        if( abort_flag )
220
            return;
220
//            return;
221
    } while( ( opr == M_UPDATE ) && ( !strlen( team_buf.name ) ) );
221
//    } while( ( opr == M_UPDATE ) && ( !strlen( team_buf.name ) ) );
222
 
222
 
223
    /*
223
//    /*
224
     **  Display / Update the class
224
//     **  Display / Update the class
225
     */
225
//     */
226
    do
226
//    do
227
    {
227
//    {
228
        d_field( 0, 1, "Class : ", D_CLASS, 1, &team_buf.teamclass, valid, opr );
228
//        d_field( 0, 1, "Class : ", D_CLASS, 1, &team_buf.teamclass, valid, opr );
229
        if( abort_flag )
229
//        if( abort_flag )
230
            return;
230
//            return;
231
    } while( ( opr == M_UPDATE ) && !team_buf.teamclass );
231
//    } while( ( opr == M_UPDATE ) && !team_buf.teamclass );
232
 
232
 
233
    /*
233
//    /*
234
     **  The record is now active
234
//     **  The record is now active
235
     **  It may not be usefull, but it has the start of a valid recird
235
//     **  It may not be usefull, but it has the start of a valid recird
236
     */
236
//     */
237
    if( opr == M_UPDATE )
237
//    if( opr == M_UPDATE )
238
        team_buf.flags.valid = TRUE;
238
//        team_buf.flags.valid = TRUE;
239
 
239
 
240
    /*
240
//    /*
241
     **  Display / Update the country name
241
//     **  Display / Update the country name
242
     */
242
//     */
243
    d_field( 30, 1, "Country :", D_COUNTRY, 4, &team_buf.country, valid,
243
//    d_field( 30, 1, "Country :", D_COUNTRY, 4, &team_buf.country, valid,
244
             opr );
244
//             opr );
245
    if( abort_flag )
245
//    if( abort_flag )
246
        return;
246
//        return;
247
 
247
 
248
    /*
248
//    /*
249
     **  Display / Update the name and sex of each team member
249
//     **  Display / Update the name and sex of each team member
250
     */
250
//     */
251
    age_sum = 0;
251
//    age_sum = 0;
252
    opr = ( operation & M_TEAM ) ? M_UPDATE : M_DISPLAY;
252
//    opr = ( operation & M_TEAM ) ? M_UPDATE : M_DISPLAY;
253
    for( i = 0; i < MAX_MEMB; i++ )
253
//    for( i = 0; i < MAX_MEMB; i++ )
254
    {
254
//    {
255
        d_field( 0, 3 + i, "Name : ", D_STRING, MAX_PERSON_NAME,
255
//        d_field( 0, 3 + i, "Name : ", D_STRING, MAX_PERSON_NAME,
256
                 team_buf.members[i].name, valid, opr );
256
//                 team_buf.members[i].name, valid, opr );
257
        if( abort_flag )
257
//        if( abort_flag )
258
            return;
258
//            return;
259
 
259
 
260
        d_field( MAX_PERSON_NAME + 10, 3 + i, "Sex : ", D_SEX, 0,
260
//        d_field( MAX_PERSON_NAME + 10, 3 + i, "Sex : ", D_SEX, 0,
261
                 &team_buf.members[i].sex, valid, opr );
261
//                 &team_buf.members[i].sex, valid, opr );
262
        if( abort_flag )
262
//        if( abort_flag )
263
            return;
263
//            return;
264
 
264
 
265
        d_field( MAX_PERSON_NAME + 25, 3 + i, "Age : ", D_AGE, 3,
265
//        d_field( MAX_PERSON_NAME + 25, 3 + i, "Age : ", D_AGE, 3,
266
                 &team_buf.members[i].age, valid, opr );
266
//                 &team_buf.members[i].age, valid, opr );
267
        if( abort_flag )
267
//        if( abort_flag )
268
            return;
268
//            return;
269
 
269
 
270
        /*
270
//        /*
271
        **  Sum ages
271
//        **  Sum ages
272
        **  -1 indicates invalid age
272
//        **  -1 indicates invalid age
273
        */
273
//        */
274
        if ( age_sum >= 0 )
274
//        if ( age_sum >= 0 )
275
        {
275
//        {
276
            ushort age = team_buf.members[i].age;
276
//            ushort age = team_buf.members[i].age;
277
            if ( age > 0 && age < 255 )
277
//            if ( age > 0 && age < 255 )
278
            {
278
//            {
279
                age_sum += age;
279
//                age_sum += age;
280
            }
280
//            }
281
            else
281
//            else
282
            {
282
//            {
283
                age_sum = -1;
283
//                age_sum = -1;
284
            }
284
//            }
285
        }
285
//        }
286
 
286
 
287
    }
287
//    }
288
 
288
 
289
    /*
289
//    /*
290
     **  Display / Update the leg informarion for each configured leg
290
//     **  Display / Update the leg informarion for each configured leg
291
     */
291
//     */
292
    for( j = 1; j <= config.num_legs; j++, i++ )
292
//    for( j = 1; j <= config.num_legs; j++, i++ )
293
    {
293
//    {
294
        d_leg( 4 + i, j, &team_buf.leg[j], valid, operation );
294
//        d_leg( 4 + i, j, &team_buf.leg[j], valid, operation );
295
        if( abort_flag )
295
//        if( abort_flag )
296
        {
296
//        {
297
            i += config.num_legs - j + 1;
297
//            i += config.num_legs - j + 1;
298
            break;
298
//            break;
299
        }
299
//        }
300
    }
300
//    }
301
 
301
 
302
    /*
302
//    /*
303
     **  Display the summary information
303
//     **  Display the summary information
304
     **      For the team
304
//     **      For the team
305
     **      Event and class placing information
305
//     **      Event and class placing information
306
     **      Total age
306
//     **      Total age
307
     */
307
//     */
308
    d_leg( 4 + i, 0, &team_buf.leg[0], valid, M_DISPLAY );
308
//    d_leg( 4 + i, 0, &team_buf.leg[0], valid, M_DISPLAY );
309
 
309
 
310
    d_field( 0, 6 + i, "Event placing : ", D_NUMBER, 1,
310
//    d_field( 0, 6 + i, "Event placing : ", D_NUMBER, 1,
311
             &team_buf.leg[0].le_place, valid, M_DISPLAY );
311
//             &team_buf.leg[0].le_place, valid, M_DISPLAY );
312
    d_field( 20, 6 + i, "Class placing : ", D_NUMBER, 1,
312
//    d_field( 20, 6 + i, "Class placing : ", D_NUMBER, 1,
313
             &team_buf.leg[0].lec_place, valid, M_DISPLAY );
313
//             &team_buf.leg[0].lec_place, valid, M_DISPLAY );
314
    d_field( 40, 6 + i, "Total Age : ", D_STRING, 5,
314
//    d_field( 40, 6 + i, "Total Age : ", D_STRING, 5,
315
             age_a(age_sum), valid, M_DISPLAY );
315
//             age_a(age_sum), valid, M_DISPLAY );
316
             
316
             
317
 
317
 
318
    if( team_buf.flags.non_equestrian )
318
//    if( team_buf.flags.non_equestrian )
319
        d_field( 0, 7 + i, "Non-Equestrian", D_NULL, 1, 0, valid, M_DISPLAY );
319
//        d_field( 0, 7 + i, "Non-Equestrian", D_NULL, 1, 0, valid, M_DISPLAY );
320
    else if( team_buf.flags.disqualified )
320
//    else if( team_buf.flags.disqualified )
321
        d_field( 0, 7 + i, "Disqualified", D_NULL, 1, 0, valid, M_DISPLAY );
321
//        d_field( 0, 7 + i, "Disqualified", D_NULL, 1, 0, valid, M_DISPLAY );
322
 
322
 
323
}
323
//}
324
 
324
 
325
/*========================================================================
325
/*========================================================================
326
 *
326
 *
327
 *  Display / Update leg time information
327
 *  Display / Update leg time information
328
 *
328
 *
Line 339... Line 339...
339
 *
339
 *
340
 *  Returns:
340
 *  Returns:
341
 *      Nothing
341
 *      Nothing
342
 *
342
 *
343
 *========================================================================*/
343
 *========================================================================*/
344
void d_leg( int y, int leg, leg_type * data, int valid, int operation )
344
//void d_leg( int y, int leg, leg_type * data, int valid, int operation )
345
{
345
//{
346
    int         i;
346
//    int         i;
347
    int         oprs, oprf;
347
//    int         oprs, oprf;
348
 
348
 
349
    /*
349
//    /*
350
     **  Display the field header
350
//     **  Display the field header
351
     */
351
//     */
352
    if( operation == M_DISPLAY )
352
//    if( operation == M_DISPLAY )
353
    {
353
//    {
354
        if( leg != 0 )
354
//        if( leg != 0 )
355
        {
355
//        {
356
            d_field( 0, y, "Leg ", D_NUMBER, 1, &leg, TRUE, M_DISPLAY );
356
//            d_field( 0, y, "Leg ", D_NUMBER, 1, &leg, TRUE, M_DISPLAY );
357
            d_field( 7, y, "", D_STRING, MAX_LEG_NAME,
357
//            d_field( 7, y, "", D_STRING, MAX_LEG_NAME,
358
                     config.leg_name[leg - 1], TRUE, M_DISPLAY );
358
//                     config.leg_name[leg - 1], TRUE, M_DISPLAY );
359
        }
359
//        }
360
        else
360
//        else
361
            d_field( 0, y, "Overall team times", D_STRING, 0, "", TRUE, M_DISPLAY );
361
//            d_field( 0, y, "Overall team times", D_STRING, 0, "", TRUE, M_DISPLAY );
362
    }
362
//    }
363
 
363
 
364
    /*
364
//    /*
365
     **  If we are doing an update,. then ensure that all the team times
365
//     **  If we are doing an update,. then ensure that all the team times
366
     **  have been tested
366
//     **  have been tested
367
     */
367
//     */
368
 
368
 
369
    if( operation & M_ALL )
369
//    if( operation & M_ALL )
370
        test_times( &team_buf, 0 );              /* Set up all team times */
370
//        test_times( &team_buf, 0 );              /* Set up all team times */
371
 
371
 
372
    oprs = ( ( parallel_legs )
372
//    oprs = ( ( parallel_legs )
373
             || ( operation & M_ALEGS )
373
//             || ( operation & M_ALEGS )
374
             || ( operation & M_LEGS ) ) ? M_UPDATE : M_DISPLAY;
374
//             || ( operation & M_LEGS ) ) ? M_UPDATE : M_DISPLAY;
375
 
375
 
376
    oprf = ( operation & M_LEGS ) ? M_UPDATE : M_DISPLAY;
376
//    oprf = ( operation & M_LEGS ) ? M_UPDATE : M_DISPLAY;
377
 
377
 
378
    /*
378
//    /*
379
     **  if start time edited then flag as manual entry
379
//     **  if start time edited then flag as manual entry
380
     **  redo calculations and refresh screen with new information
380
//     **  redo calculations and refresh screen with new information
381
     */
381
//     */
382
 
382
 
383
    if( d_field
383
//    if( d_field
384
        ( 25, y, data->manual ? "MS " : " S ", D_TIME, 8, &data->start, valid,
384
//        ( 25, y, data->manual ? "MS " : " S ", D_TIME, 8, &data->start, valid,
385
          oprs ) )
385
//          oprs ) )
386
    {
386
//    {
387
        data->manual = TRUE;
387
//        data->manual = TRUE;
388
        test_times( &team_buf, 0 );
388
//        test_times( &team_buf, 0 );
389
        for( i = leg; i <= config.num_legs; i++ )
389
//        for( i = leg; i <= config.num_legs; i++ )
390
            d_leg( y + i - leg, i, &team_buf.leg[i], valid, M_DISPLAY );
390
//            d_leg( y + i - leg, i, &team_buf.leg[i], valid, M_DISPLAY );
391
        d_leg( y + i - leg, 0, &team_buf.leg[0], valid, M_DISPLAY );
391
//        d_leg( y + i - leg, 0, &team_buf.leg[0], valid, M_DISPLAY );
392
    }
392
//    }
393
 
393
 
394
    /*
394
//    /*
395
     **  If time changed then redo calcs and refresh screen
395
//     **  If time changed then redo calcs and refresh screen
396
     */
396
//     */
397
    if( d_field( 37, y, "F ", D_TIME, 8, &data->end, valid, oprf ) )
397
//    if( d_field( 37, y, "F ", D_TIME, 8, &data->end, valid, oprf ) )
398
    {
398
//    {
399
        set_times( &team_buf );
399
//        set_times( &team_buf );
400
        test_times( &team_buf, 0 );
400
//        test_times( &team_buf, 0 );
401
        for( i = leg; i <= config.num_legs; i++ )
401
//        for( i = leg; i <= config.num_legs; i++ )
402
            d_leg( y + i - leg, i, &team_buf.leg[i], valid, M_DISPLAY );
402
//            d_leg( y + i - leg, i, &team_buf.leg[i], valid, M_DISPLAY );
403
        d_leg( y + i - leg, 0, &team_buf.leg[0], valid, M_DISPLAY );
403
//        d_leg( y + i - leg, 0, &team_buf.leg[0], valid, M_DISPLAY );
404
    }
404
//    }
405
 
405
 
406
    d_field( 48, y, "E ", D_TIME, 8, &data->elapsed, valid, M_DISPLAY );
406
//    d_field( 48, y, "E ", D_TIME, 8, &data->elapsed, valid, M_DISPLAY );
407
    if( leg == 0 )
407
//    if( leg == 0 )
408
    {
408
//    {
409
        d_field( 60, y, "", D_STRING, 10,
409
//        d_field( 60, y, "", D_STRING, 10,
410
                 ( team_buf.flags.bad_times ==
410
//                 ( team_buf.flags.bad_times ==
411
                   TRUE ) ? "Incomplete" : "          ", valid, M_DISPLAY );
411
//                   TRUE ) ? "Incomplete" : "          ", valid, M_DISPLAY );
412
    }
412
//    }
413
    else
413
//    else
414
    {
414
//    {
415
        d_field( 60, y, "", D_NUMBER, 4, &data->le_place, valid, M_DISPLAY );
415
//        d_field( 60, y, "", D_NUMBER, 4, &data->le_place, valid, M_DISPLAY );
416
        d_field( 65, y, "", D_NUMBER, 4, &data->l_place, valid, M_DISPLAY );
416
//        d_field( 65, y, "", D_NUMBER, 4, &data->l_place, valid, M_DISPLAY );
417
        d_field( 70, y, "", D_NUMBER, 4, &data->lec_place, valid, M_DISPLAY );
417
//        d_field( 70, y, "", D_NUMBER, 4, &data->lec_place, valid, M_DISPLAY );
418
        d_field( 75, y, "", D_NUMBER, 4, &data->lc_place, valid, M_DISPLAY );
418
//        d_field( 75, y, "", D_NUMBER, 4, &data->lc_place, valid, M_DISPLAY );
419
    }
419
//    }
420
}
420
//}
421
 
421
 
422
/*========================================================================
422
/*========================================================================
423
 *
423
 *
424
 *  Display / Update simple time information
424
 *  Display / Update simple time information
425
 *
425
 *
Line 435... Line 435...
435
 *
435
 *
436
 *  Returns:
436
 *  Returns:
437
 *      Nothing
437
 *      Nothing
438
 *
438
 *
439
 *========================================================================*/
439
 *========================================================================*/
440
void d_time( int x, int y, const char *prompt, time_t *data, int valid )
440
//void d_time( int x, int y, const char *prompt, time_t *data, int valid )
441
{
441
//{
442
        d_field( x, y, prompt, D_TIME, 8, ( char * ) data, valid, M_DISPLAY );
442
//        d_field( x, y, prompt, D_TIME, 8, ( char * ) data, valid, M_DISPLAY );
443
        d_field( x, y, prompt, D_TIME, 8, ( char * ) data, valid, M_UPDATE );
443
//        d_field( x, y, prompt, D_TIME, 8, ( char * ) data, valid, M_UPDATE );
444
}
444
//}
445
 
445
 
446
/*========================================================================
446
/*========================================================================
447
 *
447
 *
448
 *  Display / Update field on the screen
448
 *  Display / Update field on the screen
449
 *
449
 *
Line 468... Line 468...
468
 *
468
 *
469
 *  Returns:
469
 *  Returns:
470
 *      TRUE - Change has been made
470
 *      TRUE - Change has been made
471
 *
471
 *
472
 *========================================================================*/
472
 *========================================================================*/
473
bool d_field( int x,
473
//bool d_field( int x,
474
              int y,
474
//              int y,
475
              const char *prompt,
475
//              const char *prompt,
476
              int type, int length, const void *data, int valid, int operation )
476
//              int type, int length, const void *data, int valid, int operation )
477
{
477
//{
478
    time_t      t;
478
//    time_t      t;
479
    int         i;
479
//    int         i;
480
    sex_type    s;
480
//    sex_type    s;
481
    int         change = 0;
481
//    int         change = 0;
482
    int         idata;
482
//    int         idata;
483
 
483
 
484
    /*
484
//    /*
485
     **  Position the cursor and display the field title
485
//     **  Position the cursor and display the field title
486
     */
486
//     */
487
    cur( x, y );
487
//    cur( x, y );
488
    printf( "%s", prompt );
488
//    printf( "%s", prompt );
489
 
489
 
490
    /*
490
//    /*
491
     **  If the ABORT flag is set then DISPLAY the field
491
//     **  If the ABORT flag is set then DISPLAY the field
492
     */
492
//     */
493
    if( abort_flag )
493
//    if( abort_flag )
494
        operation = M_DISPLAY;
494
//        operation = M_DISPLAY;
495
 
495
 
496
    /*
496
//    /*
497
     **  Display the current field value
497
//     **  Display the current field value
498
     **      Only if the data field is valid
498
//     **      Only if the data field is valid
499
     **      Only if the M_DISPLAY operation is requested
499
//     **      Only if the M_DISPLAY operation is requested
500
     */
500
//     */
501
    if( valid && ( operation == M_DISPLAY ) )
501
//    if( valid && ( operation == M_DISPLAY ) )
502
    {
502
//    {
503
        switch ( type )
503
//        switch ( type )
504
        {
504
//        {
505
        case D_STRING:
505
//        case D_STRING:
506
        case D_USTRING:
506
//        case D_USTRING:
507
            printf( "%-*.*s", length, length, (char *)data );
507
//            printf( "%-*.*s", length, length, (char *)data );
508
            break;
508
//            break;
509
 
509
 
510
        case D_NUMBER:
510
//        case D_NUMBER:
511
            printf( "%-*d", length, *( short * ) data );
511
//            printf( "%-*d", length, *( short * ) data );
512
            break;
512
//            break;
513
 
513
 
514
        case D_SEX:
514
//        case D_SEX:
515
            if( *( sex_type * ) data != unknown )
515
//            if( *( sex_type * ) data != unknown )
516
                printf( "%s",
516
//                printf( "%s",
517
                        ( *( sex_type * ) data ==
517
//                        ( *( sex_type * ) data ==
518
                          male ) ? "Male" : "Female" );
518
//                          male ) ? "Male" : "Female" );
519
            break;
519
//            break;
520
 
520
 
521
        case D_TIME:
521
//        case D_TIME:
522
            printf( "%s", time_a( *( time_t * ) data ) );
522
//            printf( "%s", time_a( *( time_t * ) data ) );
523
            break;
523
//            break;
524
 
524
 
525
        case D_CLASS:
525
//        case D_CLASS:
526
            if( *( short * ) data > 0 )
526
//            if( *( short * ) data > 0 )
527
            {
527
//            {
528
                printf( "%2.2s", config.team_class[( *( int * ) data ) - 1].abr );
528
//                printf( "%2.2s", config.team_class[( *( int * ) data ) - 1].abr );
529
                printf( "  %-*.*s", LEN_CLASS_NAME, LEN_CLASS_NAME,
529
//                printf( "  %-*.*s", LEN_CLASS_NAME, LEN_CLASS_NAME,
530
                        config.team_class[( *( int * ) data ) - 1].full_name );
530
//                        config.team_class[( *( int * ) data ) - 1].full_name );
531
            }
531
//            }
532
            break;
532
//            break;
533
 
533
 
534
        case D_COUNTRY:
534
//        case D_COUNTRY:
535
            if( *( short * ) data > 0 )
535
//            if( *( short * ) data > 0 )
536
            {
536
//            {
537
                printf( "%4.4s",
537
//                printf( "%4.4s",
538
                        config.country_name[( *( int * ) data ) - 1].abr );
538
//                        config.country_name[( *( int * ) data ) - 1].abr );
539
                printf( "  %-*.*s", LEN_CNTRY_NAME, LEN_CNTRY_NAME,
539
//                printf( "  %-*.*s", LEN_CNTRY_NAME, LEN_CNTRY_NAME,
540
                        config.country_name[( *( int * ) data ) -
540
//                        config.country_name[( *( int * ) data ) -
541
                                            1].full_name );
541
//                                            1].full_name );
542
            }
542
//            }
543
            break;
543
//            break;
544
 
544
 
545
        case D_AGE:
545
//        case D_AGE:
546
            if( *( uchar * ) data > 0 )
546
//            if( *( uchar * ) data > 0 )
547
            {
547
//            {
548
                printf( "%-*d", length, *( uchar * ) data );
548
//                printf( "%-*d", length, *( uchar * ) data );
549
            }
549
//            }
550
            break;
550
//            break;
551
            
551
            
552
 
552
 
553
        case D_NULL:
553
//        case D_NULL:
554
            break;
554
//            break;
555
 
555
 
556
        default:
556
//        default:
557
            printf( "Unknown data type" );
557
//            printf( "Unknown data type" );
558
            break;
558
//            break;
559
        }
559
//        }
560
    }
560
//    }
561
 
561
 
562
    /*
562
//    /*
563
     **  If updating the field then extract the required information
563
//     **  If updating the field then extract the required information
564
     */
564
//     */
565
    if( operation == M_UPDATE )
565
//    if( operation == M_UPDATE )
566
    {
566
//    {
567
        switch ( type )
567
//        switch ( type )
568
        {
568
//        {
569
        case D_STRING:
569
//        case D_STRING:
570
            change = ( getstring( length, (char *)data, Alphanum ) );
570
//            change = ( getstring( length, (char *)data, Alphanum ) );
571
            break;
571
//            break;
572
 
572
 
573
        case D_USTRING:
573
//        case D_USTRING:
574
            change = ( getstring( length, (char *)data, AlphnumUpper ) );
574
//            change = ( getstring( length, (char *)data, AlphnumUpper ) );
575
            break;
575
//            break;
576
 
576
 
577
        case D_NUMBER:
577
//        case D_NUMBER:
578
            idata = *(short *)data;
578
//            idata = *(short *)data;
579
            change = getnum( length, &idata );
579
//            change = getnum( length, &idata );
580
            if ( change )
580
//            if ( change )
581
                *( short *)data = idata;
581
//                *( short *)data = idata;
582
            break;
582
//            break;
583
 
583
 
584
        case D_SEX:
584
//        case D_SEX:
585
            if( ( s = getsex() ) != unknown )
585
//            if( ( s = getsex() ) != unknown )
586
            {
586
//            {
587
                change = ( *( sex_type * ) data != s );
587
//                change = ( *( sex_type * ) data != s );
588
                *( sex_type * ) data = s;
588
//                *( sex_type * ) data = s;
589
            }
589
//            }
590
            break;
590
//            break;
591
 
591
 
592
        case D_TIME:
592
//        case D_TIME:
593
            if( ( t = get_time(*( time_t * ) data) ) >= 0 )
593
//            if( ( t = get_time(*( time_t * ) data) ) >= 0 )
594
            {
594
//            {
595
                change = ( *( time_t * ) data != t );
595
//                change = ( *( time_t * ) data != t );
596
                *( time_t * ) data = t;
596
//                *( time_t * ) data = t;
597
            }
597
//            }
598
            break;
598
//            break;
599
 
599
 
600
        case D_CLASS:
600
//        case D_CLASS:
601
            if( ( i = getclass() ) != 0 )
601
//            if( ( i = getclass() ) != 0 )
602
            {
602
//            {
603
                change = *( short * ) data != i;
603
//                change = *( short * ) data != i;
604
                *( short * ) data = i;
604
//                *( short * ) data = i;
605
            }
605
//            }
606
            break;
606
//            break;
607
 
607
 
608
        case D_COUNTRY:
608
//        case D_COUNTRY:
609
            if( ( i = getcountry() ) != 0 )
609
//            if( ( i = getcountry() ) != 0 )
610
            {
610
//            {
611
                change = *( short * ) data != i;
611
//                change = *( short * ) data != i;
612
                *( short * ) data = i;
612
//                *( short * ) data = i;
613
            }
613
//            }
614
            break;
614
//            break;
615
 
615
 
616
        case D_AGE:
616
//        case D_AGE:
617
            idata = *(uchar *)data;
617
//            idata = *(uchar *)data;
618
            change = getnum( length, &idata );
618
//            change = getnum( length, &idata );
619
            if ( change )
619
//            if ( change )
620
                *( uchar *)data = idata;
620
//                *( uchar *)data = idata;
621
            break;
621
//            break;
622
            
622
            
623
 
623
 
624
        case D_NULL:
624
//        case D_NULL:
625
            break;
625
//            break;
626
 
626
 
627
        default:
627
//        default:
628
            printf( "Unknown data type" );
628
//            printf( "Unknown data type" );
629
            break;
629
//            break;
630
        }
630
//        }
631
 
631
 
632
        /*
632
//        /*
633
         **  Having accepted the input now DISPLAY the data (once again)
633
//         **  Having accepted the input now DISPLAY the data (once again)
634
         **      Done to allow aborted field to re-display original values
634
//         **      Done to allow aborted field to re-display original values
635
         */
635
//         */
636
        d_field( x, y, prompt, type, length, data, TRUE, M_DISPLAY );
636
//        d_field( x, y, prompt, type, length, data, TRUE, M_DISPLAY );
637
    }
637
//    }
638
    return ( change );
638
//    return ( change );
639
}
639
//}
640
 
640
 
641
/*========================================================================
641
/*========================================================================
642
 *
642
 *
643
 *  Get a team number from the operator
643
 *  Get a team number from the operator
644
 *
644
 *
Line 657... Line 657...
657
 *
657
 *
658
 *  Returns:
658
 *  Returns:
659
 *      TRUE    : Number OK
659
 *      TRUE    : Number OK
660
 *
660
 *
661
 *========================================================================*/
661
 *========================================================================*/
662
bool g_tnum( int x, int y, const char *prompt )
662
//bool g_tnum( int x, int y, const char *prompt )
663
{
663
//{
664
    int         new_team = 0;                   /* team number that will be input */
664
//    int         new_team = 0;                   /* team number that will be input */
665
 
665
 
666
    while( TRUE )
666
//    while( TRUE )
667
    {
667
//    {
668
        team = 0;
668
//        team = 0;
669
        abort_flag = FALSE;
669
//        abort_flag = FALSE;
670
        cur( x, y );
670
//        cur( x, y );
671
        printf( "%s : ", prompt );
671
//        printf( "%s : ", prompt );
672
        console_clreol();
672
//        //console_clreol();
673
        if( !getnum( 6, &new_team ) )
673
//        if( !getnum( 6, &new_team ) )
674
            return ( FALSE );                    /* No input */
674
//            return ( FALSE );                    /* No input */
675
 
675
 
676
        /*
676
//        /*
677
         * verify that the team number is within the allowed numbers 
677
//         * verify that the team number is within the allowed numbers
678
         */
678
//         */
679
 
679
 
680
        if( !valid_field( new_team ) )
680
//        if( !valid_field( new_team ) )
681
        {
681
//        {
682
            beep();
682
//            beep();
683
            printf( "\nTeam %-1d is not valid", new_team );
683
//            printf( "\nTeam %-1d is not valid", new_team );
684
            continue;
684
//            continue;
685
        }
685
//        }
686
        team = new_team;
686
//        team = new_team;
687
        return ( TRUE );
687
//        return ( TRUE );
688
    }
688
//    }
689
}
689
//}
690
 
690
 
691
/*========================================================================
691
/*========================================================================
692
 *
692
 *
693
 *  Read a team record from disk
693
 *  Read a team record from disk
694
 *
694
 *
Line 818... Line 818...
818
    {
818
    {
819
        /*
819
        /*
820
         * file does not exist - create it 
820
         * file does not exist - create it 
821
         */
821
         */
822
        printf( "The team data file does not exist.\n" );
822
        printf( "The team data file does not exist.\n" );
823
        if( getyes( "Create the data file" ) )
823
//        if( getyes( "Create the data file" ) )
824
        {
824
//        {
825
            team_fd = creat( datfile, 0664 );
825
//            team_fd = creat( datfile, 0664 );
826
            if( team_fd > 0 )
826
//            if( team_fd > 0 )
827
            {
827
//            {
828
                close( team_fd );                /* Close th file */
828
//                close( team_fd );                /* Close th file */
829
                team_fd = open( datfile, OPEN_RW, 644 );
829
//                team_fd = open( datfile, OPEN_RW, 644 );
830
                if( team_fd < 0 )
830
//                if( team_fd < 0 )
831
                    perror( "Team datafile" );
831
//                    perror( "Team datafile" );
832
            }
832
//            }
833
        }
833
//        }
834
    }
834
    }
835
    return ( team_fd >= 0 );
835
    return ( team_fd >= 0 );
836
}
836
}
837
 
837
 
838
/*========================================================================
838
/*========================================================================