Skip to content

Commit 616921b

Browse files
committed
Refresh time from serverinfo on load.
1 parent 883ce7f commit 616921b

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

src/main.qc

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,28 @@ float(float isnew) PipNewPlayer =
283283
return isnew;
284284
};
285285

286+
void() PipRefreshMatchTime =
287+
{
288+
string status = serverkey("status");
289+
if (!strcasecmp(status, "standby") || !strcasecmp(status, "countdown")) {
290+
return;
291+
}
292+
293+
println(status);
294+
295+
float argc = tokenize(status);
296+
if (argc == 3 && argv(1) == "mins" && argv(2) == "left") {
297+
float minutes = stof(argv(0));
298+
match_start_time = time - minutes * 60;
299+
} else {
300+
match_start_time = time;
301+
}
302+
303+
PipResetTimers(match_start_time);
304+
305+
SelectNextCamera();
306+
};
307+
286308
void() CSQC_WorldLoaded =
287309
{
288310
if (autocvar_pip_xray) {
@@ -315,6 +337,8 @@ void() CSQC_WorldLoaded =
315337
if (PipLoadItems()) {
316338
deltalisten("progs/quaddama.mdl", PipPowerupSpawnListener, RSES_NOLERP);
317339
deltalisten("progs/invulner.mdl", PipPowerupSpawnListener, RSES_NOLERP);
340+
341+
PipRefreshMatchTime();
318342
}
319343
};
320344
@@ -324,23 +348,7 @@ void() CSQC_ServerInfoChanged =
324348
return;
325349
}
326350
327-
string status = serverkey("status");
328-
if (!strcasecmp(status, "standby") || !strcasecmp(status, "countdown")) {
329-
return;
330-
}
331-
332-
println(status);
333-
float argc = tokenize(status);
334-
if (argc == 3 && argv(1) == "mins" && argv(2) == "left") {
335-
float minutes = stof(argv(0));
336-
match_start_time = time - minutes * 60;
337-
} else {
338-
match_start_time = time;
339-
}
340-
341-
PipResetTimers(match_start_time);
342-
343-
SelectNextCamera();
351+
PipRefreshMatchTime();
344352
};
345353
346354
void(float vwidth, float vheight, float notmenu) CSQC_UpdateView =

0 commit comments

Comments
 (0)