test
This commit is contained in:
parent
d96c8efc54
commit
12f0048f70
38
obj.go
38
obj.go
@ -158,8 +158,8 @@ func addObjCastle(logo string, name string) (int64, error) {
|
||||
}
|
||||
|
||||
func getObjCastleID(s string) int64 {
|
||||
var c *ChatWarsCastle
|
||||
c, _ = cacheObjCastle.Load(s)
|
||||
v, _ = cacheObjCastle.Load(s)
|
||||
c := v.(ChatWarsCastle)
|
||||
return c.ObjID64
|
||||
}
|
||||
|
||||
@ -170,7 +170,7 @@ func loadObjCastle() error {
|
||||
name string
|
||||
)
|
||||
|
||||
cacheObjCastle = new(sync.Map)
|
||||
cacheObjCastle = new(*sync.Map)
|
||||
|
||||
castles, err := db.Query(`SELECT oc.obj_id, oc.logo, oc.name FROM obj_castle oc;`)
|
||||
if err != nil {
|
||||
@ -244,17 +244,17 @@ func addObjGuild(tag string, name string) (int64, error) {
|
||||
}
|
||||
|
||||
func getObjGuildID(s string) int64 {
|
||||
var g *ChatWarsGuild
|
||||
if g, ok := cacheObjGuild.Load(s); ok {
|
||||
if v, ok := cacheObjGuild.Load(s); ok {
|
||||
g := v.(ChatWarsGuild)
|
||||
return g.ObjID64
|
||||
} else {
|
||||
objID64, err := addObjGuild(s, ``)
|
||||
logOnError(err, "getObjGuildID")
|
||||
n := new(ChatWarsGuild)
|
||||
n.ObjID64 = objID64
|
||||
n.Tag = s
|
||||
n.Name = ``
|
||||
cacheObjGuild.Store(s, *n)
|
||||
g := new(ChatWarsGuild)
|
||||
g.ObjID64 = objID64
|
||||
g.Tag = s
|
||||
g.Name = ``
|
||||
cacheObjGuild.Store(s, *g)
|
||||
return objID64
|
||||
}
|
||||
}
|
||||
@ -266,7 +266,7 @@ func loadObjGuild() error {
|
||||
name string
|
||||
)
|
||||
|
||||
cacheObjGuild = new(sync.Map)
|
||||
cacheObjGuild = new(*sync.Map)
|
||||
|
||||
guilds, err := db.Query(`SELECT og.obj_id, og.tag, og.name FROM obj_guild og;`)
|
||||
if err != nil {
|
||||
@ -339,16 +339,16 @@ func addObjUser(name string) (int64, error) {
|
||||
}
|
||||
|
||||
func getObjUserID(s string) int64 {
|
||||
var u *ChatWarsUser
|
||||
if u, ok := cacheObjUser.Load(s); ok {
|
||||
return u.ObjID64
|
||||
if v, ok := cacheObjUser.Load(s); ok {
|
||||
u := v.(ChatWarsUser)
|
||||
return n.ObjID64
|
||||
} else {
|
||||
objID64, err := addObjUser(s)
|
||||
logOnError(err, "getObjUserID")
|
||||
n := new(ChatWarsUser)
|
||||
n.ObjID64 = objID64
|
||||
n.Name = s
|
||||
cacheObjUser.Store(s, *n)
|
||||
u := new(ChatWarsUser)
|
||||
u.ObjID64 = objID64
|
||||
u.Name = s
|
||||
cacheObjUser.Store(s, *u)
|
||||
return objID64
|
||||
}
|
||||
}
|
||||
@ -359,7 +359,7 @@ func loadObjUser() error {
|
||||
name string
|
||||
)
|
||||
|
||||
cacheObjUser = new(sync.Map)
|
||||
cacheObjUser = new(*sync.Map)
|
||||
|
||||
users, err := db.Query(`SELECT ou.obj_id, ou.name FROM obj_user ou;`)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user