Skip to content

Commit

Permalink
Show accurate elapsed time only when useful
Browse files Browse the repository at this point in the history
  • Loading branch information
timiimit committed Mar 15, 2023
1 parent 2c545fd commit b62540e
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions UT4MasterServer.Web/src/pages/Servers/hooks/use-match.hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,29 @@ export function useMatch() {
ServerAttribute.uuForcedMutators
] as string;
const forcedMutators = forcedMutatorsString?.split(',') ?? [];
const elapsedTimeRaw = response.attributes[
ServerAttribute.elapsedTime
] as number;
const elapsedTimeAccurate = Math.round(
(Date.now() -
(new Date(response.lastUpdated).getTime() - elapsedTimeRaw * 1000)) /
1000
);
return {
id,
name:
customMatchNames[id] ??
(response.attributes[ServerAttribute.serverName] as string),
gameType: response.attributes[ServerAttribute.gameType] as string,
map: response.attributes[ServerAttribute.mapName] as string,
matchState,
matchState: matchState,
matchStateDisplay: matchStateMap[matchState] ?? matchState,
maxPlayers: response.attributes[ServerAttribute.maxPlayers] as number,
playersOnline: response.attributes[
ServerAttribute.playersOnline
] as number,
duration: response.attributes[ServerAttribute.matchDuration] as number,
elapsedTime: Math.round(
(Date.now() -
(new Date(response.lastUpdated).getTime() -
(response.attributes[ServerAttribute.elapsedTime] as number) *
1000)) /
1000
),
elapsedTime: elapsedTimeRaw > 0 ? elapsedTimeAccurate : elapsedTimeRaw,
publicPlayers: response.publicPlayers,
mutators,
gameMode,
Expand Down

0 comments on commit b62540e

Please sign in to comment.