summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-01-18 22:22:39 +0100
committerThomas White <taw@physics.org>2020-01-18 22:22:39 +0100
commitc078ba9c9f63f623665b69bce99f7c633c201a1a (patch)
tree9ea56c4e7c813964485a9e801ebf6ad01df377c2
parent82b7108e025973caafa75c998862324eacc26838 (diff)
Fix GLITCH_BACK
-rw-r--r--glitchyclock.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/glitchyclock.c b/glitchyclock.c
index 8b3ca90..2a960fc 100644
--- a/glitchyclock.c
+++ b/glitchyclock.c
@@ -193,19 +193,23 @@ static gboolean draw_sig(GtkWidget *widget, cairo_t *cr, struct glitchyclock *gc
}
if ( cues[gc->cue].type == GLITCH_BACK ) {
- glitch = 1;
- duty = 0.5 + seconds_elapsed / 4;
- if ( duty > 1.0 ) {
- duty = 1.0;
- if ( !gc->flag ) {
- gc->base_minutes += cues[gc->cue].parameter;
- gc->base_hours += gc->base_minutes / 60;
- gc->base_minutes = gc->base_minutes % 60;
- gc->base_hours = gc->base_hours % 24;
+ if ( !gc->flag ) {
+ duty = 0.5 + seconds_elapsed / 4;
+ glitch = 1;
+ if ( duty > 1.0 ) {
+ duty = 1.0;
+ gc->real_time_last_reset += cues[gc->cue].parameter * 60;
+
+ /* The real_time_elapsed will now probably be
+ * negative (unless the clock glitched back by
+ * less than real_time_elapsed). To avoid
+ * negative numbers appearing, go back a whole
+ * day. Yes, I'm a dirty cheat. */
+ gc->real_time_last_reset -= 24*60*60;
gc->flag = 1;
- } else {
- glitch = 0;
}
+ } else {
+ glitch = 0;
}
}