Merge branch 'develop' into sdk
This commit is contained in:
commit
e4d063a1fb
@ -211,7 +211,7 @@ func GobUnmarshal(data []byte, obj interface{}) error {
|
||||
}
|
||||
|
||||
func GetServerIdByUid(uid int) int {
|
||||
return int(uid / 100000)
|
||||
return int((uid % 100000000) / 100000)
|
||||
}
|
||||
|
||||
func CreateOrderSn(uid int) string {
|
||||
|
||||
@ -120,6 +120,7 @@ func SendServerMsg(m *msg.Msg, serverId int) error {
|
||||
return err
|
||||
}
|
||||
v.(network.Agent).WriteMsg(data)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("server %d not online", serverId)
|
||||
}
|
||||
|
||||
@ -29,6 +29,7 @@ type ChampshipData struct {
|
||||
PreGroupInfo map[int]int // 锦标赛分组信息 备份
|
||||
Robot map[int]*ChampshipRobot // 机器人
|
||||
PreRobot map[int]*ChampshipRobot // 机器人 备份
|
||||
ZeroTime int64
|
||||
}
|
||||
|
||||
type ChampshipRank struct {
|
||||
@ -87,6 +88,9 @@ func (c *ChampshipMgr) Init() {
|
||||
|
||||
Now := GoUtil.Now()
|
||||
ZeroTime := GoUtil.ZeroTimestamp()
|
||||
if c.getData().ZeroTime != ZeroTime {
|
||||
c.ZeroUpdate(&msg.Msg{})
|
||||
}
|
||||
Remain := Now - ZeroTime
|
||||
Remain1 := 1800 - Remain%1800
|
||||
|
||||
@ -101,6 +105,7 @@ func (c *ChampshipMgr) Init() {
|
||||
Type: msg.HANDLE_TYPE_CHAMPSHIP_AI,
|
||||
})
|
||||
})
|
||||
|
||||
c.mDispatr.AfterFunc(time.Duration(GoUtil.NextZeroTimestampDuration())*time.Second, func() {
|
||||
c.Send(&msg.Msg{
|
||||
Type: msg.SERVER_ZERO_UPDATE,
|
||||
@ -116,6 +121,7 @@ func (c *ChampshipMgr) NotifyAll(m *msg.Msg) (interface{}, error) {
|
||||
}
|
||||
|
||||
func (c *ChampshipMgr) ZeroUpdate(m *msg.Msg) (interface{}, error) {
|
||||
c.getData().ZeroTime = GoUtil.ZeroTimestamp()
|
||||
c.getData().PreRank = c.getData().Rank
|
||||
c.getData().PreRobot = c.getData().Robot
|
||||
c.getData().PreGroupInfo = c.getData().GroupInfo
|
||||
|
||||
@ -110,10 +110,12 @@ func FriendMgrSend(m *msg.Msg) error {
|
||||
err := mergeCluster.SendServerMsg(m, ToServer)
|
||||
if err != nil { // 区服不在线
|
||||
G_GameLogicPtr.FriendMgrSend(m)
|
||||
log.Debug("send to server %d error : %s\n", ToServer, err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
log.Debug("send to server %d success, %d", ToServer, conf.Server.ServerID)
|
||||
G_GameLogicPtr.FriendMgrSend(m)
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -102,9 +102,9 @@ func (gl *GameLogic) ZeroFlush() {
|
||||
})
|
||||
var a1 = []interface{}{gl.DailyTaskTimestamp}
|
||||
GoUtil.CallEvent(MergeConst.Notify_Daily_Renew, a1)
|
||||
gl.RankMgrSend(MsgMod.MSG_ZERO_UPDATE) // 零点更新排行榜
|
||||
gl.ChampshipMgrSend(MsgMod.MSG_ZERO_UPDATE) // 零点更新锦标赛
|
||||
gl.VarMgrSend(MsgMod.MSG_ZERO_UPDATE) // 零点更新变量
|
||||
// gl.RankMgrSend(MsgMod.MSG_ZERO_UPDATE) // 零点更新排行榜
|
||||
// gl.ChampshipMgrSend(MsgMod.MSG_ZERO_UPDATE) // 零点更新锦标赛
|
||||
// gl.VarMgrSend(MsgMod.MSG_ZERO_UPDATE) // 零点更新变量
|
||||
gl.NotifyAll(MsgMod.MSG_ZERO_UPDATE)
|
||||
gl.CreateDailyLogFile()
|
||||
log.Debug("Server ZeroFlush")
|
||||
|
||||
@ -88,7 +88,7 @@ func (p *PlayerChessData) UpdatePlayerChessData(player *Player, buf []byte) erro
|
||||
for _, v := range update.MChessHandle {
|
||||
HandleStr += fmt.Sprintf("%v-%v-%v,", v.Id, v.ChessId, v.Type)
|
||||
}
|
||||
log.Debug("棋子数据不一致, %v===%v===%v===%v", HandleStr, LastMap, p.Data.MChessData, player.PlayMod.getChessMod().GetChessList())
|
||||
log.Debug("棋子数据不一致, %v===%v===%v===%v", update.MChessHandle, LastMap, p.Data.MChessData, player.PlayMod.getChessMod().GetChessList())
|
||||
player.SendErrClienRes(res)
|
||||
return fmt.Errorf("棋子数据不一致")
|
||||
}
|
||||
|
||||
@ -694,7 +694,7 @@ func GetRecommendPlayer(p *Player, Num int) []int {
|
||||
if v.Uid == int(p.M_DwUin) {
|
||||
continue
|
||||
}
|
||||
if FriendMod.CheckApply(v.Uid) {
|
||||
if FriendMod.CheckSendApply(v.Uid) {
|
||||
continue
|
||||
}
|
||||
if FriendMod.CheckFriend(v.Uid) {
|
||||
@ -704,6 +704,9 @@ func GetRecommendPlayer(p *Player, Num int) []int {
|
||||
if GoUtil.Now()-PlayerSimpleData.Loginout > 86400 {
|
||||
continue
|
||||
}
|
||||
if PlayerSimpleData.Level < 4 {
|
||||
continue
|
||||
}
|
||||
PlayerList1 = append(PlayerList1, v.Uid)
|
||||
}
|
||||
if len(PlayerList1) == 0 {
|
||||
|
||||
@ -1311,13 +1311,28 @@ func ReqApplyFriend(args []interface{}) error {
|
||||
req := &msg.ReqApplyFriend{}
|
||||
proto.Unmarshal(buf, req)
|
||||
Uid := int(req.Uid)
|
||||
FriendMod := player.PlayMod.getFriendMod()
|
||||
if FriendMod.CheckFriend(Uid) {
|
||||
player.SendErrClienRes(&msg.ResApplyFriend{
|
||||
Code: msg.RES_CODE_FAIL,
|
||||
Msg: "already friend",
|
||||
})
|
||||
return fmt.Errorf("already friend")
|
||||
}
|
||||
if FriendMod.AddSendApply(Uid) {
|
||||
player.SendErrClienRes(&msg.ResApplyFriend{
|
||||
Code: msg.RES_CODE_FAIL,
|
||||
Msg: "already apply",
|
||||
})
|
||||
return fmt.Errorf("already apply")
|
||||
}
|
||||
m := &MsqMod.Msg{
|
||||
Type: MsqMod.HANDLE_TYPE_APPLY,
|
||||
From: int(player.M_DwUin),
|
||||
To: Uid,
|
||||
SendT: GoUtil.Now(),
|
||||
}
|
||||
G_GameLogicPtr.FriendMgrSend(m)
|
||||
FriendMgrSend(m)
|
||||
player.PushClientRes(&msg.ResApplyFriend{
|
||||
Code: msg.RES_CODE_SUCCESS,
|
||||
})
|
||||
@ -1348,7 +1363,7 @@ func ReqAgreeFriend(args []interface{}) error {
|
||||
To: Uid,
|
||||
SendT: GoUtil.Now(),
|
||||
}
|
||||
G_GameLogicPtr.FriendMgrSend(m)
|
||||
FriendMgrSend(m)
|
||||
FriendMod.AddFriend(Uid)
|
||||
player.PlayMod.save()
|
||||
player.PushClientRes(&msg.ResAgreeFriend{
|
||||
@ -1373,7 +1388,7 @@ func ReqDelFriend(args []interface{}) error {
|
||||
To: Uid,
|
||||
SendT: GoUtil.Now(),
|
||||
}
|
||||
G_GameLogicPtr.FriendMgrSend(m)
|
||||
FriendMgrSend(m)
|
||||
FriendMod := player.PlayMod.getFriendMod()
|
||||
FriendMod.DelFriend(Uid)
|
||||
player.PlayMod.save()
|
||||
@ -1408,7 +1423,7 @@ func ReqRefuseFriend(args []interface{}) error {
|
||||
To: Uid,
|
||||
SendT: GoUtil.Now(),
|
||||
}
|
||||
G_GameLogicPtr.FriendMgrSend(m)
|
||||
FriendMgrSend(m)
|
||||
FriendApplyBackData(player)
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -2,8 +2,10 @@ package game
|
||||
|
||||
import (
|
||||
"encoding/gob"
|
||||
"server/GoUtil"
|
||||
"server/game/mod/card"
|
||||
"server/game/mod/msg"
|
||||
"time"
|
||||
)
|
||||
|
||||
type VarMgr struct {
|
||||
@ -11,7 +13,8 @@ type VarMgr struct {
|
||||
}
|
||||
|
||||
type VarData struct {
|
||||
Var map[string]interface{}
|
||||
Var map[string]interface{}
|
||||
ZeroTime int64
|
||||
}
|
||||
|
||||
const (
|
||||
@ -26,25 +29,22 @@ func (f *VarMgr) Init() {
|
||||
}
|
||||
// 注册处理函数
|
||||
f.init()
|
||||
f.initData()
|
||||
f.RegisterHandler(msg.SERVER_ZERO_UPDATE, f.ZeroUpdate)
|
||||
}
|
||||
|
||||
func (f *VarMgr) initData() {
|
||||
if f.getData().Var == nil {
|
||||
f.getData().Var = make(map[string]interface{})
|
||||
}
|
||||
GoldCard := f.GetVar(VAR_GOLD_CARD)
|
||||
if GoldCard == nil { // 随机生成两个金卡
|
||||
Card1, Card2 := card.RankGoldCard()
|
||||
f.SetVar(VAR_GOLD_CARD, &VarGoldCard{
|
||||
Four: Card1,
|
||||
Five: Card2,
|
||||
})
|
||||
if f.getData().ZeroTime == GoUtil.ZeroTimestamp() {
|
||||
f.ZeroUpdate(&msg.Msg{})
|
||||
}
|
||||
f.RegisterHandler(msg.SERVER_ZERO_UPDATE, f.ZeroUpdate)
|
||||
f.mDispatr.AfterFunc(time.Duration(GoUtil.NextZeroTimestampDuration())*time.Second, func() {
|
||||
f.Send(&msg.Msg{
|
||||
Type: msg.SERVER_ZERO_UPDATE,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func (f *VarMgr) ZeroUpdate(m *msg.Msg) (interface{}, error) {
|
||||
f.getData().ZeroTime = GoUtil.ZeroTimestamp()
|
||||
// 随机生成两个金卡
|
||||
Card1, Card2 := card.RankGoldCard()
|
||||
f.SetVar(VAR_GOLD_CARD, &VarGoldCard{
|
||||
|
||||
@ -9,6 +9,7 @@ import (
|
||||
type FriendMod struct {
|
||||
FriendList map[int]struct{} // 好友列表
|
||||
ApplyList map[int]int64 // 请求列表
|
||||
SendApply map[int]int64 // 发送的申请
|
||||
Card map[string]*card.CardInfo // 收到的申请交换
|
||||
Log []*LogInfo // 日志
|
||||
AutoId int
|
||||
@ -55,6 +56,9 @@ func (f *FriendMod) InitData() {
|
||||
if f.Card == nil {
|
||||
f.Card = make(map[string]*card.CardInfo)
|
||||
}
|
||||
if f.SendApply == nil {
|
||||
f.SendApply = make(map[int]int64)
|
||||
}
|
||||
}
|
||||
|
||||
func (f *FriendMod) AddFriend(id int) {
|
||||
@ -106,12 +110,28 @@ func (f *FriendMod) GetFriendList() []int {
|
||||
return list
|
||||
}
|
||||
|
||||
// 收到申请
|
||||
func (f *FriendMod) AddFriendApply(Uid int) {
|
||||
f.ApplyList[Uid] = GoUtil.Now()
|
||||
}
|
||||
|
||||
// 发送申请
|
||||
func (f *FriendMod) AddSendApply(Uid int) bool {
|
||||
if _, ok := f.SendApply[Uid]; ok {
|
||||
return true
|
||||
}
|
||||
f.SendApply[Uid] = GoUtil.Now()
|
||||
return false
|
||||
}
|
||||
|
||||
func (f *FriendMod) CheckSendApply(Id int) bool {
|
||||
_, ok := f.SendApply[Id]
|
||||
return ok
|
||||
}
|
||||
|
||||
func (f *FriendMod) AgreeApply(UId int) {
|
||||
f.AddFriend(UId)
|
||||
delete(f.SendApply, UId)
|
||||
delete(f.ApplyList, UId)
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user