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