MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / Rebuild

Method Rebuild

internal/users/charindex.go:76–95  ·  view source on GitHub ↗

Rebuild clears the index and repopulates it from every user record on disk plus all currently online users. Only active character names are added here; the alt-characters module is responsible for adding alt names after this runs.

()

Source from the content-addressed store, hash-verified

74// the alt-characters module is responsible for adding alt names after this
75// runs.
76func (ci *CharacterIndex) Rebuild() {
77 newMap := make(map[string]int)
78
79 SearchOfflineUsers(func(u *UserRecord) bool {
80 if u.Character != nil && u.Character.Name != "" {
81 newMap[strings.ToLower(u.Character.Name)] = u.UserId
82 }
83 return true
84 })
85
86 for _, u := range GetAllActiveUsers() {
87 if u.Character != nil && u.Character.Name != "" {
88 newMap[strings.ToLower(u.Character.Name)] = u.UserId
89 }
90 }
91
92 ci.mu.Lock()
93 ci.byName = newMap
94 ci.mu.Unlock()
95}

Callers

nothing calls this directly

Calls 4

SearchOfflineUsersFunction · 0.85
GetAllActiveUsersFunction · 0.85
LockMethod · 0.80
UnlockMethod · 0.80

Tested by

no test coverage detected