Skip to content

Commit 3cad8d1

Browse files
committed
#3 that fixes the inactive timer problem - watcherThread was exitting on a reboot timeout, so subsequent games did nothing
1 parent 05cd2ef commit 3cad8d1

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

src/game.zig

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,14 @@ fn watcherThread(self: *Self) void {
9898
var expiry_time = self.expiry_time;
9999
const state = self.state;
100100
self.game_mutex.unlock();
101+
const t = std.time.timestamp();
101102

102103
if (state != .init) {
103-
if (std.time.timestamp() > expiry_time) {
104+
if (t > expiry_time) {
104105
std.log.debug("Waited too long", .{});
105106
if (state == .winner) {
106107
self.reboot();
107-
return;
108+
continue;
108109
}
109110

110111
self.game_mutex.lock();
@@ -205,8 +206,8 @@ fn clock(self: *Self, stream: std.net.Stream) !void {
205206
var remaining = self.expiry_time - std.time.timestamp();
206207
if (self.state == .running and remaining > 0) {
207208
try stream.writer().print("data: {d} seconds remaining ...\n\n", .{remaining});
208-
} else {
209-
try w.writeAll("data: 🕑\n\n");
209+
// } else {
210+
// try w.writeAll("data: 🕑\n\n");
210211
}
211212
}
212213

src/html/index.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@
4646
Player <span id="player" hx-swap-oob="true">
4747
</div>
4848

49-
<div>
50-
<input class="blue-button" type="button" value="Enable Audio" onclick="yourTurnAudio.play()">
51-
</div>
52-
5349
<script>
5450
// define some audio snippets
5551
const yourTurnAudio = new Audio("audio/your-turn.mp3")

src/html/login/login-form-end.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
</ul>
22
</div>
3+
4+
<div>
5+
<input class="blue-button" type="button" value="Enable Audio" onclick="yourTurnAudio.play()">
6+
</div>

src/html/setup/setup_game.x.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,8 @@
3535
<span id="nuke-value">{[nuke]}</span>
3636
<label for="nuke">% Chance to set us up the Bomb ?</label>
3737
</div>
38+
<div>
39+
<input class="blue-button" type="button" value="Enable Audio" onclick="yourTurnAudio.play()">
40+
</div>
3841
<button class="green-button">Start</button>
3942
</form>

0 commit comments

Comments
 (0)