another fix for item cache

This commit is contained in:
shoopea 2019-08-23 18:37:33 +08:00
parent 0ae4c729bc
commit 47a017b40a

6
obj.go
View File

@ -775,6 +775,7 @@ func getSilentObjItemID(code string, name string) int64 {
func loadObjItem() error { func loadObjItem() error {
var ( var (
id int64 id int64
type_id int64
intl_id string intl_id string
name string name string
weight int weight int
@ -788,19 +789,20 @@ func loadObjItem() error {
cacheObjItemId = make(map[int64]ChatWarsItem) cacheObjItemId = make(map[int64]ChatWarsItem)
muxObjItemId.Unlock() muxObjItemId.Unlock()
items, err := db.Query(`SELECT oi.obj_id, oi.intl_id, obn.name, oi.weight FROM obj_item oi, obj_name obn WHERE obn.obj_id = oi.obj_id AND obn.priority = 0;`) items, err := db.Query(`SELECT oi.obj_id, o.obj_sub_type_id, oi.intl_id, obn.name, oi.weight FROM obj o, obj_item oi, obj_name obn WHERE o.id = oi.obj_id AND obn.obj_id = oi.obj_id AND obn.priority = 0;`)
if err != nil { if err != nil {
return err return err
} }
defer items.Close() defer items.Close()
for items.Next() { for items.Next() {
err = items.Scan(&id, &intl_id, &name, &weight) err = items.Scan(&id, &type_id, &intl_id, &name, &weight)
if err != nil { if err != nil {
return err return err
} }
c := new(ChatWarsItem) c := new(ChatWarsItem)
c.ObjID64 = id c.ObjID64 = id
c.ItemTypeID = type_id
c.Code = intl_id c.Code = intl_id
c.Name = name c.Name = name
c.Weight = weight c.Weight = weight