Skip to content

Commit

Permalink
fixed realtime ticks
Browse files Browse the repository at this point in the history
  • Loading branch information
PrototypeESBU committed May 27, 2024
1 parent f56ec53 commit 86b645a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
9 changes: 8 additions & 1 deletion system/src/apps/LightSourceTrackerSD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ export default class LightSourceTrackerSD extends Application {
// we only run the timer on the GM instance
if (!game.user.isGM) return;

// set default state for flag
await game.user.setFlag("shadowdark", "primaryGM", false);

// Now we can actually start properly
shadowdark.log("Light Tracker starting");

Expand Down Expand Up @@ -484,7 +487,7 @@ export default class LightSourceTrackerSD extends Application {
}

async onUpdateWorldTime(worldTime, worldDelta) {
if (!(this._isEnabled() && shadowdark.utils.isPrimaryGM())) return;
if (!(this._isEnabled() && game.user.isGM)) return;
if (this.updatingLightSources) return;

const updateSecs = game.settings.get(
Expand All @@ -505,6 +508,10 @@ export default class LightSourceTrackerSD extends Application {

this.lastUpdate = worldTime;

if (!shadowdark.utils.isPrimaryGM()) {
this.render(false);
return;
}
shadowdark.log("Updating light sources");

try {
Expand Down
5 changes: 4 additions & 1 deletion system/src/apps/RealTimeSD.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ export default class RealTimeSD {
return;
}
if (this.isPaused()) return;
game.time.advance(this.updateIntervalMs / 1000);
console.log(shadowdark.utils.isPrimaryGM());
if (shadowdark.utils.isPrimaryGM()) {
game.time.advance(this.updateIntervalMs / 1000);
}
}
}
1 change: 0 additions & 1 deletion system/src/hooks/light-source-tracker.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export const LightSourceTrackerHooks = {
const lst = game.shadowdark.lightSourceTracker;

if (game.user.isGM) {
game.user.setFlag("shadowdark", "primaryGM", false);
game.shadowdark.lightSourceTracker.start();
Hooks.on("deleteActor", lst._deleteActorHook.bind(lst));
Hooks.on("deleteItem", lst._deleteItemHook.bind(lst));
Expand Down

0 comments on commit 86b645a

Please sign in to comment.