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

View File

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

View File

@ -3,7 +3,6 @@ package shard
import ( import (
"fmt" "fmt"
"log" "log"
"time"
"github.com/CPunch/gopenfusion/core/entity" "github.com/CPunch/gopenfusion/core/entity"
"github.com/CPunch/gopenfusion/core/protocol" "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{ resp := &protocol.SP_FE2CL_REP_PC_ENTER_SUCC{
IID: int32(plr.PlayerID), IID: int32(plr.PlayerID),
PCLoadData2CL: plr.ToPCLoadData2CL(), PCLoadData2CL: plr.ToPCLoadData2CL(),
UiSvrTime: uint64(time.Now().Unix()), UiSvrTime: protocol.GetTime(),
} }
// setup peer // setup peer

View File

@ -1,8 +1,6 @@
package shard package shard
import ( import (
"time"
"github.com/CPunch/gopenfusion/core/entity" "github.com/CPunch/gopenfusion/core/entity"
"github.com/CPunch/gopenfusion/core/protocol" "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{ 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, IX: move.IX,
IY: move.IY, IY: move.IY,
IZ: move.IZ, IZ: move.IZ,
@ -43,7 +41,7 @@ func (server *ShardServer) playerMove(peer *protocol.CNPeer, pkt protocol.Packet
CKeyValue: move.CKeyValue, CKeyValue: move.CKeyValue,
ISpeed: move.ISpeed, ISpeed: move.ISpeed,
IID: int32(plr.PlayerID), 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{ 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, IX: stop.IX,
IY: stop.IY, IY: stop.IY,
IZ: stop.IZ, IZ: stop.IZ,
IID: int32(plr.PlayerID), 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{ 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, IX: jump.IX,
IY: jump.IY, IY: jump.IY,
IZ: jump.IZ, IZ: jump.IZ,
@ -99,6 +97,6 @@ func (server *ShardServer) playerJump(peer *protocol.CNPeer, pkt protocol.Packet
CKeyValue: jump.CKeyValue, CKeyValue: jump.CKeyValue,
ISpeed: jump.ISpeed, ISpeed: jump.ISpeed,
IID: int32(plr.PlayerID), IID: int32(plr.PlayerID),
ISvrTime: uint64(time.Now().Unix()), ISvrTime: protocol.GetTime(),
}) })
} }