fix initialization for int64 CWItems map

This commit is contained in:
shoopea 2019-08-21 12:04:56 +08:00
parent 92eeda481d
commit 12cdb9c87a

6
obj.go
View File

@ -681,7 +681,7 @@ func addObjItem(code string, name string, itemTypeID64 int64, weight int, exchan
cacheObjItem[name] = *c
muxObjItemId.Lock()
cacheObjItemId[objId] = *c
cacheObjItemId[c.ObjID64] = *c
defer muxObjItemId.Unlock()
return objId, nil
@ -783,6 +783,10 @@ func loadObjItem() error {
cacheObjItem = make(map[string]ChatWarsItem)
muxObjItem.Unlock()
muxObjItemId.Lock()
cacheObjItemId = make(map[int64]ChatWarsItem)
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;`)
if err != nil {
return err