aboutsummaryrefslogtreecommitdiff
path: root/internal/world/world.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/world/world.go')
-rw-r--r--internal/world/world.go18
1 files changed, 5 insertions, 13 deletions
diff --git a/internal/world/world.go b/internal/world/world.go
index e2d12ba..ac5345e 100644
--- a/internal/world/world.go
+++ b/internal/world/world.go
@@ -192,7 +192,7 @@ func (w *World) FindObjInstances(roomID int, name string) []ObjState {
defer w.mu.Unlock()
var out []ObjState
lower := strings.ToLower(name)
- for key, st := range w.objStates {
+ for _, st := range w.objStates {
if st.RoomID != roomID {
continue
}
@@ -210,7 +210,6 @@ func (w *World) FindObjInstances(roomID int, name string) []ObjState {
SharedTimer: st.SharedTimer,
Quality: st.Quality,
})
- _ = key
}
sort.Slice(out, func(i, j int) bool {
if out[i].DefID != out[j].DefID {
@@ -225,14 +224,11 @@ func wordMatchesObj(lower, defID, objName string) bool {
if WordPrefixMatch(lower, objName) {
return true
}
- nameWords := strings.Fields(strings.ToLower(objName))
inputWords := strings.Fields(strings.ToLower(lower))
- // Check defID as whole (bidirectional)
if strings.HasPrefix(strings.ToLower(defID), lower) || strings.HasPrefix(lower, strings.ToLower(defID)) {
return true
}
- // Check each defID part (split by underscore) against each input word (bidirectional)
for _, part := range strings.Split(defID, "_") {
for _, iw := range inputWords {
pl := strings.ToLower(part)
@@ -241,42 +237,38 @@ func wordMatchesObj(lower, defID, objName string) bool {
}
}
}
- _ = nameWords
return false
}
func (w *World) SetObjName(roomID int, defID string, name string) {
w.mu.Lock()
defer w.mu.Unlock()
- for key, st := range w.objStates {
+ for _, st := range w.objStates {
if st.RoomID == roomID && st.DefID == defID {
st.Name = name
}
- _ = key
}
}
func (w *World) SetObjWander(roomID int, defID string, rooms []int, interval int) {
w.mu.Lock()
defer w.mu.Unlock()
- for key, st := range w.objStates {
+ for _, st := range w.objStates {
if st.RoomID == roomID && st.DefID == defID {
st.WanderRooms = rooms
st.WanderInterval = interval
}
- _ = key
}
}
-func (w *World) SetObjSharedDeplete(roomID int, defID string, max int) {
+func (w *World) SetObjDepleteTimer(roomID int, defID string, max int) {
w.mu.Lock()
defer w.mu.Unlock()
- for key, st := range w.objStates {
+ for _, st := range w.objStates {
if st.RoomID == roomID && st.DefID == defID && st.SharedMax == 0 {
st.SharedMax = max
st.SharedTimer = max
}
- _ = key
}
}