Skip to content
This repository was archived by the owner on Nov 26, 2023. It is now read-only.

Commit e61ebd4

Browse files
committed
fix ticks
1 parent 57b3fa1 commit e61ebd4

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"webpack-dev-server": "^4.7.4"
5252
},
5353
"dependencies": {
54-
"@demostf/parser-worker": "0.1",
54+
"@demostf/parser-worker": "0.1.1",
5555
"promise-polyfill": "^8.2.1",
5656
"react": "^17.0.2",
5757
"react-dom": "^17.0.2",

src/Analyse/Analyser.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export class Analyser extends React.Component<AnalyseProps, {}> {
111111
if (props.isStored && window.location.hash) {
112112
const parsed = parseInt(window.location.hash.substr(1), 10);
113113
if (('#' + parsed) === window.location.hash) {
114-
this.state.tick = Math.floor(parsed / 2);
114+
this.state.tick = Math.floor(parsed);
115115
} else {
116116
this.joinSession(window.location.hash.substr(1));
117117
}
@@ -271,15 +271,15 @@ export class Analyser extends React.Component<AnalyseProps, {}> {
271271

272272
private setHash = debounce(250, (tick) => {
273273
if (!this.session && this.props.isStored) {
274-
history.replaceState('', '', '#' + tick * 2);
274+
history.replaceState('', '', '#' + tick);
275275
}
276276
});
277277

278278
animFrame(timestamp) {
279-
const timePassed = timestamp - this.playStartTime;
280-
const targetTick = this.playStartTick + (Math.round(timePassed * this.intervalPerTick * 2));
279+
const timePassed = (timestamp - this.playStartTime) / 1000;
280+
const targetTick = this.playStartTick + (Math.round(timePassed / this.intervalPerTick));
281281
this.lastFrameTime = timestamp;
282-
if (targetTick >= (this.parser.demo.tickCount - 1)) {
282+
if (targetTick >= (this.parser.demo.tick - 1)) {
283283
this.pause();
284284
}
285285
this.setHash(this.state.tick);
@@ -330,7 +330,7 @@ export class Analyser extends React.Component<AnalyseProps, {}> {
330330
players={players} kills={kills}/>
331331
</div>
332332
<div className="time-control"
333-
title={`${tickToTime(this.state.tick)} (tick ${this.state.tick * 2})`}>
333+
title={`${tickToTime(this.state.tick, this.intervalPerTick)} (tick ${this.state.tick})`}>
334334
<input className="play-pause-button" type="button"
335335
onClick={this.togglePlay.bind(this)}
336336
value={playButtonText}
@@ -347,7 +347,7 @@ export class Analyser extends React.Component<AnalyseProps, {}> {
347347
}
348348
}
349349

350-
function tickToTime(tick: number): string {
351-
let seconds = Math.floor(tick / 33);
350+
function tickToTime(tick: number, intervalPerTick: number): string {
351+
let seconds = Math.floor(tick * intervalPerTick);
352352
return `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, '0')}`;
353353
}

src/Analyse/Render/SpecHUD.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface SpecHUDProps {
1212
}
1313

1414
export function SpecHUD({tick, parser, players, kills}: SpecHUDProps) {
15+
// console.log(tick);
1516
return (<div className="spechud">
1617
<KillFeed tick={tick} kills={kills} players={players}/>
1718
<PlayersSpec players={players}/>

0 commit comments

Comments
 (0)