aboutsummaryrefslogtreecommitdiff
path: root/internal/engine
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-09-18 17:48:26 -0400
committerhistoria <[not public]>2026-09-18 17:48:26 -0400
commit8fe9e3c3fef0049df82281a62afe35dda516dfe2 (patch)
treedd269f2c0710f334e19f00a191260ebc46284a90 /internal/engine
parent194164a77eb4f2479b94c19e6f0e1278ab608781 (diff)
downloadthehouseoficarus-8fe9e3c3fef0049df82281a62afe35dda516dfe2.tar.gz
fix: close combat ghost, admin traversal, login throttle, journal double-pay, and quality/economy gaps
Diffstat (limited to 'internal/engine')
-rw-r--r--internal/engine/tick.go11
-rw-r--r--internal/engine/tick_values_test.go20
2 files changed, 31 insertions, 0 deletions
diff --git a/internal/engine/tick.go b/internal/engine/tick.go
index 68dd54f..8c64cdd 100644
--- a/internal/engine/tick.go
+++ b/internal/engine/tick.go
@@ -4,6 +4,7 @@ package engine
import (
"math/rand"
+ "reflect"
"sort"
"sync"
"time"
@@ -171,6 +172,16 @@ func ValuesEqual(a, b any) bool {
if aok && bok {
return ai == bi
}
+ // == panics when both operands share an uncomparable dynamic type (a
+ // YAML list or map used as a flag value). Fall back to DeepEqual so a
+ // tick system cannot panic on authored content.
+ ta, tb := reflect.TypeOf(a), reflect.TypeOf(b)
+ if ta != tb {
+ return false
+ }
+ if ta != nil && !ta.Comparable() {
+ return reflect.DeepEqual(a, b)
+ }
return a == b
}
diff --git a/internal/engine/tick_values_test.go b/internal/engine/tick_values_test.go
new file mode 100644
index 0000000..4c704bb
--- /dev/null
+++ b/internal/engine/tick_values_test.go
@@ -0,0 +1,20 @@
+package engine
+
+import "testing"
+
+// TestValuesEqualUncomparableDoesNotPanic: a YAML list/map flag value must not
+// panic a tick system when compared (== panics on uncomparable dynamic types).
+func TestValuesEqualUncomparableDoesNotPanic(t *testing.T) {
+ if !ValuesEqual([]any{1, 2}, []any{1, 2}) {
+ t.Fatal("equal slices should compare equal")
+ }
+ if ValuesEqual([]any{1, 2}, []any{1, 3}) {
+ t.Fatal("different slices should not compare equal")
+ }
+ if !ValuesEqual(map[string]any{"x": 1}, map[string]any{"x": 1}) {
+ t.Fatal("equal maps should compare equal")
+ }
+ if ValuesEqual(map[string]any{"x": 1}, map[string]any{"x": 2}) {
+ t.Fatal("different maps should not compare equal")
+ }
+}