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

Function GetUniqueUserId

internal/users/users.go:661–697  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

659}
660
661func GetUniqueUserId() int {
662
663 // if highestUserId is zero, loop through users and get real highest.
664
665 highestUserId := 0
666
667 idx := GetUserIndex()
668 if idx.Exists() {
669
670 highestUserId = idx.GetHighestUserId()
671
672 } else {
673
674 // Check all user id's of offline users
675 SearchOfflineUsers(func(u *UserRecord) bool {
676
677 if u.UserId > highestUserId {
678 highestUserId = u.UserId
679 }
680
681 return true
682 })
683
684 // Check all user id's of online users
685 for _, u := range GetAllActiveUsers() {
686 if u.UserId > highestUserId {
687 highestUserId = u.UserId
688 }
689 }
690
691 }
692
693 // Increment the highestUserId before returning a new one
694 highestUserId += 1
695
696 return highestUserId
697}
698
699// DeleteUser permanently removes a user record, their YAML file, and all index
700// entries. It refuses to delete a user that is currently online.

Callers 1

CreateUserFunction · 0.85

Calls 5

GetUserIndexFunction · 0.85
SearchOfflineUsersFunction · 0.85
GetAllActiveUsersFunction · 0.85
GetHighestUserIdMethod · 0.80
ExistsMethod · 0.45

Tested by

no test coverage detected