This commit is contained in:
shoopea 2019-06-14 14:44:35 +08:00
parent 8838d459c3
commit a89a6e8511

18
obj.go
View File

@ -599,12 +599,20 @@ func getObjItemID(c string, n string) int64 {
}
func silentGetObjItemID(code string, name string) int64 {
if v, ok := cacheObjItem.Load(code); ok && len(code) > 0 {
item := v.(ChatWarsItem)
log.Printf("Matching item code %s with %s.\n", code, item.Code)
return item.ObjID64
if len(code) > 0 {
if v, ok := cacheObjItem.Load(code); ok {
item := v.(ChatWarsItem)
log.Printf("Matching item code %s with %s.\n", code, item.Code)
return item.ObjID64
}
if ok, _ := regexp.MatchString(`^u[0-9]+`, code); !ok {
return 0
}
}
if v, ok := cacheObjItem.Load(name); ok && len(name) > 0 {
if len(name) == 0 {
return 0
}
if v, ok := cacheObjItem.Load(name); ok {
item := v.(ChatWarsItem)
log.Printf("Matching item name %s with %s.\n", name, item.Name)
return item.ObjID64