bug优化

This commit is contained in:
hahwu 2025-08-21 14:59:24 +08:00
parent c7c082aeaf
commit 7bf27c66b4
2 changed files with 27 additions and 4 deletions

View File

@ -431,12 +431,12 @@ func GetDressPart(Id int) int {
return gamedata.GetIntValue(data, "IPart")
}
func GetDressName(Id int) int {
func GetDressName(Id int) string {
data, err := gamedata.GetDataByIntKey(CFG_PLAYROOM_DRESS, Id)
if err != nil {
return 0
return ""
}
return gamedata.GetIntValue(data, "Name")
return gamedata.GetStringValue(data, "Name")
}
func GetUnlockNeed(Type int) int {

View File

@ -128,7 +128,7 @@ func GetIntValue(a interface{}, key string) int {
if v == nil {
return 0
}
return int(v.(float64))
return Int(v)
}
return 0
}
@ -214,3 +214,26 @@ func GetDataByIntKey(cfgname string, key int) (map[string]interface{}, error) {
}
return make(map[string]interface{}), errors.New("not found")
}
func Int(a interface{}) int {
if a == nil {
return 0
}
switch v := a.(type) {
case int:
return v
case int32:
return int(v)
case int64:
return int(v)
case float64:
return int(v)
case string:
r, err := strconv.Atoi(v)
if err != nil {
return 0
}
return r
}
return 0
}