fixed sent server time

This commit is contained in:
CPunch 2023-06-25 18:29:31 -05:00
parent 8f00a0c492
commit c09a6cfd25
4 changed files with 13 additions and 12 deletions

View File

@ -6,6 +6,7 @@ import (
"io"
"log"
"net"
"time"
"github.com/CPunch/gopenfusion/core/protocol/pool"
)
@ -28,6 +29,10 @@ type CNPeer struct {
alive bool
}
func GetTime() uint64 {
return uint64(time.Now().UnixMilli())
}
func NewCNPeer(eRecv chan *Event, conn net.Conn) *CNPeer {
return &CNPeer{
conn: conn,

View File

@ -5,7 +5,6 @@ import (
"fmt"
"log"
"math/rand"
"time"
"github.com/CPunch/gopenfusion/config"
"github.com/CPunch/gopenfusion/core/db"
@ -34,7 +33,7 @@ func (server *LoginServer) AcceptLogin(peer *protocol.CNPeer, SzID string, IClie
ISlotNum: ISlotNum,
IPaymentFlag: 1,
IOpenBetaFlag: 0,
UiSvrTime: uint64(time.Now().Unix()),
UiSvrTime: protocol.GetTime(),
}
if err := peer.Send(protocol.P_LS2CL_REP_LOGIN_SUCC, resp); err != nil {

View File

@ -3,7 +3,6 @@ package shard
import (
"fmt"
"log"
"time"
"github.com/CPunch/gopenfusion/core/entity"
"github.com/CPunch/gopenfusion/core/protocol"
@ -47,7 +46,7 @@ func (server *ShardServer) RequestEnter(peer *protocol.CNPeer, pkt protocol.Pack
resp := &protocol.SP_FE2CL_REP_PC_ENTER_SUCC{
IID: int32(plr.PlayerID),
PCLoadData2CL: plr.ToPCLoadData2CL(),
UiSvrTime: uint64(time.Now().Unix()),
UiSvrTime: protocol.GetTime(),
}
// setup peer

View File

@ -1,8 +1,6 @@
package shard
import (
"time"
"github.com/CPunch/gopenfusion/core/entity"
"github.com/CPunch/gopenfusion/core/protocol"
)
@ -32,7 +30,7 @@ func (server *ShardServer) playerMove(peer *protocol.CNPeer, pkt protocol.Packet
}
return server.sendOthersPacket(plr, protocol.P_FE2CL_PC_MOVE, protocol.SP_FE2CL_PC_MOVE{
ICliTime: uint64(time.Now().Unix()),
ICliTime: move.ICliTime,
IX: move.IX,
IY: move.IY,
IZ: move.IZ,
@ -43,7 +41,7 @@ func (server *ShardServer) playerMove(peer *protocol.CNPeer, pkt protocol.Packet
CKeyValue: move.CKeyValue,
ISpeed: move.ISpeed,
IID: int32(plr.PlayerID),
ISvrTime: uint64(time.Now().Unix()),
ISvrTime: protocol.GetTime(),
})
}
@ -63,12 +61,12 @@ func (server *ShardServer) playerStop(peer *protocol.CNPeer, pkt protocol.Packet
}
return server.sendOthersPacket(plr, protocol.P_FE2CL_PC_STOP, protocol.SP_FE2CL_PC_STOP{
ICliTime: uint64(time.Now().Unix()),
ICliTime: stop.ICliTime,
IX: stop.IX,
IY: stop.IY,
IZ: stop.IZ,
IID: int32(plr.PlayerID),
ISvrTime: uint64(time.Now().Unix()),
ISvrTime: protocol.GetTime(),
})
}
@ -88,7 +86,7 @@ func (server *ShardServer) playerJump(peer *protocol.CNPeer, pkt protocol.Packet
}
return server.sendOthersPacket(plr, protocol.P_FE2CL_PC_JUMP, protocol.SP_FE2CL_PC_JUMP{
ICliTime: uint64(time.Now().Unix()),
ICliTime: jump.ICliTime,
IX: jump.IX,
IY: jump.IY,
IZ: jump.IZ,
@ -99,6 +97,6 @@ func (server *ShardServer) playerJump(peer *protocol.CNPeer, pkt protocol.Packet
CKeyValue: jump.CKeyValue,
ISpeed: jump.ISpeed,
IID: int32(plr.PlayerID),
ISvrTime: uint64(time.Now().Unix()),
ISvrTime: protocol.GetTime(),
})
}