Skip to content

Commit 428928d

Browse files
Fixed unreachable code in MutatorList.SkipInstanceSave (#410)
This PR removes unreachable code in the SaveEqualityChecker implementation and its associated usage in room instance saving, addressing compilation issues with "go vet". Removed the SaveEqualityChecker interface from internal/rooms/save_and_load.go. Eliminated unreachable code in MutatorList.SkipInstanceSave in internal/mutators/mutators.go.
1 parent 09d4607 commit 428928d

File tree

2 files changed

+0
-38
lines changed

2 files changed

+0
-38
lines changed

internal/mutators/mutators.go

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -43,34 +43,6 @@ type Mutator struct {
4343
DespawnedRound uint64 `yaml:"despawnedround,omitempty"` // Track when it decayed to nothing.
4444
}
4545

46-
// This is a special function used for when room instance data is saved
47-
// It handles checking for special equality cases that the normal reflect.DeepEqual() doesn't handle the way we want.
48-
func (m MutatorList) SkipInstanceSave(other any) bool {
49-
return false
50-
m2, ok := other.(MutatorList)
51-
if !ok {
52-
return false
53-
}
54-
55-
if len(m) != len(m2) { // length different?
56-
return false
57-
}
58-
59-
for i, _ := range m {
60-
61-
if m[i].MutatorId != m2[i].MutatorId {
62-
return false
63-
}
64-
65-
if m[i].Removable() != m2[i].Removable() {
66-
return false
67-
}
68-
69-
}
70-
71-
return true
72-
}
73-
7446
type TextModifier struct {
7547
Behavior TextBehavior `yaml:"behavior,omitempty"` // prepend, append or replace?
7648
Text string `yaml:"text,omitempty"` // The text that will be injected somehow

internal/rooms/save_and_load.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,6 @@ func SaveRoomTemplate(roomTpl Room) error {
236236
return nil
237237
}
238238

239-
type SaveEqualityChecker interface {
240-
SkipInstanceSave(other any) bool // Should we skip due to everything looking the same?
241-
}
242-
243239
// See: D. SAVING ROOMS INSTANCES
244240
func SaveRoomInstance(r Room) error {
245241

@@ -276,12 +272,6 @@ func SaveRoomInstance(r Room) error {
276272
rVal2 := rVal.Field(i)
277273
tplVal2 := tplVal.Field(i)
278274

279-
if iface, ok := rVal2.Interface().(SaveEqualityChecker); ok {
280-
if iface.SkipInstanceSave(tplVal2.Interface()) {
281-
continue
282-
}
283-
}
284-
285275
if reflect.DeepEqual(rVal2.Interface(), tplVal2.Interface()) {
286276
continue
287277
}

0 commit comments

Comments
 (0)