@@ -119,15 +119,15 @@ static void race_update_pacemaker(void);
119
119
static void race_clear_pacemaker (void );
120
120
static void race_init_capture (void );
121
121
static void race_save_position (void );
122
- static void race_finish_capture (qbool store , char * filename );
122
+ static void race_finish_capture (qbool store );
123
123
static void race_pacemaker_race_start (void );
124
124
static void race_remove_pacemaker_indicator (void );
125
125
static void race_make_active_racer (gedict_t * r , gedict_t * s );
126
126
static qbool race_end (gedict_t * racer , qbool valid , qbool complete );
127
127
static char * race_position_string (int position );
128
128
static qbool race_simultaneous (void );
129
129
static void race_update_closest_positions (void );
130
- static void race_match_round_end (char * demoFileName );
130
+ static void race_match_round_end (void );
131
131
132
132
void StatsToFile ();
133
133
@@ -160,15 +160,15 @@ static int get_server_port ( void )
160
160
return i ;
161
161
}
162
162
163
- static const char * race_top_filename ( void )
163
+ static const char * race_filename ( const char * extension )
164
164
{
165
165
static char filename [128 ];
166
166
167
167
if (cvar ("k_race_times_per_port" )) {
168
- snprintf (filename , sizeof (filename ), "race/race[%s_r%02d]-w%1ds%1d_%d.top " , g_globalvars .mapname , race .active_route , race .weapon , race .falsestart , get_server_port ());
168
+ snprintf (filename , sizeof (filename ), "race/race[%s_r%02d]-w%1ds%1d_%d.%s " , g_globalvars .mapname , race .active_route , race .weapon , race .falsestart , get_server_port (), extension );
169
169
}
170
170
else {
171
- snprintf (filename , sizeof (filename ), "race/race[%s_r%02d]-w%1ds%1d.top " , g_globalvars .mapname , race .active_route , race .weapon , race .falsestart );
171
+ snprintf (filename , sizeof (filename ), "race/race[%s_r%02d]-w%1ds%1d.%s " , g_globalvars .mapname , race .active_route , race .weapon , race .falsestart , extension );
172
172
}
173
173
174
174
return filename ;
@@ -1115,6 +1115,7 @@ static void race_over(void)
1115
1115
{
1116
1116
char demoFileName [MAX_OSPATH ];
1117
1117
int i , timeposition , nameposition ;
1118
+ int best_time_position = 1000 ;
1118
1119
char * pos ;
1119
1120
gedict_t * racer = NULL ;
1120
1121
qbool keep_demo = false;
@@ -1262,7 +1263,8 @@ static void race_over(void)
1262
1263
race_position_string (timeposition + 1 )
1263
1264
);
1264
1265
1265
- keep_demo |= timeposition == 0 || !blocked_record ;
1266
+ best_time_position = min (timeposition , best_time_position );
1267
+ keep_demo |= !blocked_record ;
1266
1268
}
1267
1269
}
1268
1270
else {
@@ -1279,11 +1281,11 @@ static void race_over(void)
1279
1281
}
1280
1282
1281
1283
if (race_match_started ()) {
1282
- race_match_round_end (demoFileName );
1284
+ race_match_round_end ();
1283
1285
}
1284
1286
else {
1285
1287
// Continue match with next run
1286
- race_finish_capture (keep_demo , demoFileName );
1288
+ race_finish_capture (best_time_position == 0 && ! blocked_record );
1287
1289
race_start (!keep_demo , "" );
1288
1290
}
1289
1291
}
@@ -2736,7 +2738,7 @@ qbool race_load_route( int route )
2736
2738
read_topscores ();
2737
2739
2738
2740
if (!strnull (cvar_string ("cs_address" ))) {
2739
- localcmd ("\nsv_web_postfile ServerApi/UploadTopFile \"\" %s\n" , race_top_filename ( ));
2741
+ localcmd ("\nsv_web_postfile ServerApi/UploadTopFile \"\" %s\n" , race_filename ( "top" ));
2740
2742
trap_executecmd ();
2741
2743
}
2742
2744
@@ -2908,7 +2910,7 @@ void write_topscores( void )
2908
2910
if ( !race .active_route )
2909
2911
return ;
2910
2912
2911
- race_fwopen ("%s" , race_top_filename ( ));
2913
+ race_fwopen ("%s" , race_filename ( "top" ));
2912
2914
if ( race_fhandle < 0 )
2913
2915
return ;
2914
2916
@@ -2972,7 +2974,7 @@ void read_topscores( void )
2972
2974
if ( !race .active_route )
2973
2975
return ;
2974
2976
2975
- race_fropen ("%s" , race_top_filename ( ));
2977
+ race_fropen ("%s" , race_filename ( "top" ));
2976
2978
if ( race_fhandle >= 0 )
2977
2979
{
2978
2980
race_fgets ( line , MAX_TXTLEN );
@@ -3550,29 +3552,13 @@ void race_pacemaker(void)
3550
3552
}
3551
3553
else {
3552
3554
position = 0 ;
3553
- if (trap_CmdArgc () == 2 ) {
3554
- position = atoi (buffer );
3555
-
3556
- if (position == 0 && buffer [0 ] != '0' ) {
3557
- G_sprint (self , PRINT_HIGH , "Unknown pacemaker command '%s'.\n" , buffer );
3558
- return ;
3559
- }
3560
-
3561
- -- position ;
3562
- }
3563
-
3564
- if (position < 0 || position >= sizeof (race .records ) / sizeof (race .records [0 ]) || race .records [position ].time >= RACE_INVALID_RECORD_TIME )
3565
- {
3566
- G_sprint (self , PRINT_HIGH , "No race record #%2d.\n" , position + 1 );
3567
- return ;
3568
- }
3569
3555
}
3570
3556
3571
3557
// Try and load
3572
- race_fropen ("race/%s.pos " , race . records [ position ]. demoname );
3558
+ race_fropen ("%s " , race_filename ( "pos" ) );
3573
3559
if (race_fhandle < 0 )
3574
3560
{
3575
- G_sprint (self , PRINT_HIGH , "Unable to load positions for record #%2d .\n" , position + 1 );
3561
+ G_sprint (self , PRINT_HIGH , "Unable to load pacemaker record.\n" , position + 1 );
3576
3562
return ;
3577
3563
}
3578
3564
@@ -3763,13 +3749,13 @@ static void race_init_capture(void)
3763
3749
}
3764
3750
}
3765
3751
3766
- static void race_finish_capture (qbool store , char * filename )
3752
+ static void race_finish_capture (qbool store )
3767
3753
{
3768
3754
// Multi-racing: only store positions for those setting a record?
3769
3755
gedict_t * racer ;
3770
3756
3771
3757
if (store && race .race_recording ) {
3772
- race_fwopen ("race/%s.pos " , filename );
3758
+ race_fwopen ("%s " , race_filename ( "pos" ) );
3773
3759
race_fprintf ("version %d\n" , POS_FILE_VERSION );
3774
3760
3775
3761
for (racer = world ; (racer = race_find_race_participants (racer )); /**/ ) {
@@ -4519,7 +4505,7 @@ void race_switch_usermode(const char* displayName, int players_per_team)
4519
4505
}
4520
4506
4521
4507
// Return true if new countdown should be started
4522
- static void race_match_round_end (char * demoFileName )
4508
+ static void race_match_round_end (void )
4523
4509
{
4524
4510
gedict_t * racer ;
4525
4511
@@ -4581,7 +4567,7 @@ static void race_match_round_end(char* demoFileName)
4581
4567
}
4582
4568
else {
4583
4569
// We have a winner, end the race
4584
- race_finish_capture (true, demoFileName );
4570
+ race_finish_capture (false );
4585
4571
EndMatch (false);
4586
4572
return ;
4587
4573
}
@@ -4595,7 +4581,7 @@ static void race_match_round_end(char* demoFileName)
4595
4581
if (system -> round_max_diff && rounds_remaining * system -> round_max_diff < sc ) {
4596
4582
// We have winner, end the race
4597
4583
G_bprint (PRINT_HIGH , "%d points (%d rounds) available... ending match\n" , rounds_remaining * system -> round_max_diff , rounds_remaining );
4598
- race_finish_capture (true, demoFileName );
4584
+ race_finish_capture (false );
4599
4585
EndMatch (false);
4600
4586
return ;
4601
4587
}
0 commit comments