npc好友优化

This commit is contained in:
hahwu 2025-04-10 10:04:46 +08:00
parent 8a521a5d43
commit 6c33c83033
4 changed files with 1157 additions and 1120 deletions

View File

@ -196,6 +196,25 @@ func Int(a interface{}) int {
return 0
}
func String(a interface{}) string {
if a == nil {
return ""
}
switch v := a.(type) {
case int:
return strconv.Itoa(v)
case int32:
return strconv.Itoa(int(v))
case int64:
return strconv.Itoa(int(v))
case float64:
return strconv.FormatFloat(v, 'f', -1, 64)
case string:
return v
}
return ""
}
func GobMarshal(data interface{}) ([]byte, error) {
var buf bytes.Buffer
encode := gob.NewEncoder(&buf)

View File

@ -3991,8 +3991,10 @@ func ReqAddNpc(player *Player, buf []byte) error {
FriendMod.SetNpc(int(req.NpcId))
player.PlayMod.save()
FriendListBackData(player)
player.AddLog(int(req.NpcId), friend.LOG_TYPE_FRIEND_BECOME_NPC, GoUtil.String(req.NpcId))
player.PushClientRes(&msg.ResAddNpc{
Code: msg.RES_CODE_SUCCESS,
Code: msg.RES_CODE_SUCCESS,
NpcId: req.NpcId,
})
return nil
}

View File

@ -50,6 +50,7 @@ const (
LOG_TYPE_CHARGE_SEND = 18 // 赠送充值礼物
LOG_TYPE_CHARGE_RECEIVE = 19 // 收到充值礼物
LOG_TYPE_WISH = 20 // 心愿单请求
LOG_TYPE_FRIEND_BECOME_NPC = 21 // npc成为好友
)
const (

File diff suppressed because it is too large Load Diff