test craft

This commit is contained in:
shoopea 2020-01-26 16:39:32 +08:00
parent a889309879
commit 1d0d0c9a01

21
item.go
View File

@ -189,6 +189,26 @@ func setObjItemWeight(objID64 int64, weight int64) error {
return nil
}
func setObjItemCraft(objID64 int64, cmd string, mana int64) error {
log.Printf("setObjItemCraft[%d] : %s - %d\n", objID64, cmd, mana)
stmt, err := db.Prepare(`INSERT INTO obj_craft_item (obj_id, cmd, mana)
VALUES (?, ?, ?)
ON DUPLICATE KEY UPDATE cmd = ?, mana = ?;`)
logOnError(err, "setObjItemCraft : prepare update obj_craft_item")
if err != nil {
return err
}
defer stmt.Close()
_, err = stmt.Exec(objID64, cmd, mana, cmd, mana)
logOnError(err, fmt.Sprintf("setObjItemCraft : update obj_craft_item(%d)", objID64))
if err != nil {
return err
}
return nil
}
func loadObjItem() error {
var (
obj_id int64
@ -296,6 +316,7 @@ func loadObjItem() error {
for _, i := range cacheObjItem {
if objItems[i].Craft != nil {
log.Printf("loadObjItem : %s : loading craft for %s.\n", objItems[i].Code, objItems[i].Names[0])
setObjItemCraft(objItems[i].ObjID64, objItems[i].Craft.Command, objItems[i].Craft.Mana)
}
}