mirror of
https://github.com/CPunch/gopenfusion.git
synced 2025-04-29 14:50:21 +00:00
Compare commits
No commits in common. "79f68187bf31060040da73c6c51887782cd705c5" and "0a28dbcc3e2d220f9d350e01652b70fdc4d47351" have entirely different histories.
79f68187bf
...
0a28dbcc3e
@ -19,7 +19,6 @@ import (
|
|||||||
type DummyPeer struct {
|
type DummyPeer struct {
|
||||||
Recv chan *cnet.PacketEvent
|
Recv chan *cnet.PacketEvent
|
||||||
Peer *cnet.Peer
|
Peer *cnet.Peer
|
||||||
is *is.I
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MakeDummyPeer creates a new dummy peer and returns it
|
// MakeDummyPeer creates a new dummy peer and returns it
|
||||||
@ -33,21 +32,21 @@ func MakeDummyPeer(ctx context.Context, is *is.I, port int) *DummyPeer {
|
|||||||
peer.Handler(recv)
|
peer.Handler(recv)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return &DummyPeer{Recv: recv, Peer: peer, is: is}
|
return &DummyPeer{Recv: recv, Peer: peer}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SendAndRecv sends a packet (sID & out), waits for the expected response (rID) and decodes it into in
|
// SendAndRecv sends a packet (sID & out), waits for the expected response (rID) and decodes it into in
|
||||||
func (dp *DummyPeer) SendAndRecv(sID, rID uint32, out, in interface{}) {
|
func (dp *DummyPeer) SendAndRecv(is *is.I, sID, rID uint32, out, in interface{}) {
|
||||||
// send out packet
|
// send out packet
|
||||||
err := dp.Peer.Send(sID, out)
|
err := dp.Peer.Send(sID, out)
|
||||||
dp.is.NoErr(err) // peer.Send() should not return an error
|
is.NoErr(err) // peer.Send() should not return an error
|
||||||
|
|
||||||
// receive response
|
// receive response
|
||||||
evnt := <-dp.Recv
|
evnt := <-dp.Recv
|
||||||
defer protocol.PutBuffer(evnt.Pkt)
|
defer protocol.PutBuffer(evnt.Pkt)
|
||||||
|
|
||||||
dp.is.Equal(evnt.PktID, rID) // should receive expected type
|
is.Equal(evnt.PktID, rID) // should receive expected type
|
||||||
dp.is.NoErr(protocol.NewPacket(evnt.Pkt).Decode(in)) // packet.Decode() should not return an error
|
is.NoErr(protocol.NewPacket(evnt.Pkt).Decode(in)) // packet.Decode() should not return an error
|
||||||
}
|
}
|
||||||
|
|
||||||
// Kill closes the peer's connection
|
// Kill closes the peer's connection
|
||||||
|
@ -87,7 +87,7 @@ func TestLoginSuccSequence(t *testing.T) {
|
|||||||
|
|
||||||
// send login request (this should create an account)
|
// send login request (this should create an account)
|
||||||
var resp protocol.SP_LS2CL_REP_LOGIN_SUCC
|
var resp protocol.SP_LS2CL_REP_LOGIN_SUCC
|
||||||
dummy.SendAndRecv(protocol.P_CL2LS_REQ_LOGIN, protocol.P_LS2CL_REP_LOGIN_SUCC,
|
dummy.SendAndRecv(is, protocol.P_CL2LS_REQ_LOGIN, protocol.P_LS2CL_REP_LOGIN_SUCC,
|
||||||
protocol.SP_CL2LS_REQ_LOGIN{
|
protocol.SP_CL2LS_REQ_LOGIN{
|
||||||
SzID: "testLoginSequence",
|
SzID: "testLoginSequence",
|
||||||
SzPassword: "test",
|
SzPassword: "test",
|
||||||
@ -113,7 +113,7 @@ func TestLoginFailSequence(t *testing.T) {
|
|||||||
|
|
||||||
// send login request (this should not create an account)
|
// send login request (this should not create an account)
|
||||||
var resp protocol.SP_LS2CL_REP_LOGIN_FAIL
|
var resp protocol.SP_LS2CL_REP_LOGIN_FAIL
|
||||||
dummy.SendAndRecv(protocol.P_CL2LS_REQ_LOGIN, protocol.P_LS2CL_REP_LOGIN_FAIL,
|
dummy.SendAndRecv(is, protocol.P_CL2LS_REQ_LOGIN, protocol.P_LS2CL_REP_LOGIN_FAIL,
|
||||||
protocol.SP_CL2LS_REQ_LOGIN{
|
protocol.SP_CL2LS_REQ_LOGIN{
|
||||||
SzID: "",
|
SzID: "",
|
||||||
SzPassword: "",
|
SzPassword: "",
|
||||||
@ -135,7 +135,7 @@ func TestCharacterSequence(t *testing.T) {
|
|||||||
|
|
||||||
// send login request (this should create an account)
|
// send login request (this should create an account)
|
||||||
var resp protocol.SP_LS2CL_REP_LOGIN_SUCC
|
var resp protocol.SP_LS2CL_REP_LOGIN_SUCC
|
||||||
dummy.SendAndRecv(protocol.P_CL2LS_REQ_LOGIN, protocol.P_LS2CL_REP_LOGIN_SUCC,
|
dummy.SendAndRecv(is, protocol.P_CL2LS_REQ_LOGIN, protocol.P_LS2CL_REP_LOGIN_SUCC,
|
||||||
protocol.SP_CL2LS_REQ_LOGIN{
|
protocol.SP_CL2LS_REQ_LOGIN{
|
||||||
SzID: "testCharacterSequence",
|
SzID: "testCharacterSequence",
|
||||||
SzPassword: "test",
|
SzPassword: "test",
|
||||||
@ -159,7 +159,7 @@ func TestCharacterSequence(t *testing.T) {
|
|||||||
|
|
||||||
// send character name check request
|
// send character name check request
|
||||||
var charResp protocol.SP_LS2CL_REP_SAVE_CHAR_NAME_SUCC
|
var charResp protocol.SP_LS2CL_REP_SAVE_CHAR_NAME_SUCC
|
||||||
dummy.SendAndRecv(protocol.P_CL2LS_REQ_SAVE_CHAR_NAME, protocol.P_LS2CL_REP_SAVE_CHAR_NAME_SUCC,
|
dummy.SendAndRecv(is, protocol.P_CL2LS_REQ_SAVE_CHAR_NAME, protocol.P_LS2CL_REP_SAVE_CHAR_NAME_SUCC,
|
||||||
protocol.SP_CL2LS_REQ_SAVE_CHAR_NAME{
|
protocol.SP_CL2LS_REQ_SAVE_CHAR_NAME{
|
||||||
ISlotNum: 1,
|
ISlotNum: 1,
|
||||||
IGender: 1,
|
IGender: 1,
|
||||||
@ -180,7 +180,7 @@ func TestCharacterSequence(t *testing.T) {
|
|||||||
charCreate := testCharCreate
|
charCreate := testCharCreate
|
||||||
charCreate.PCStyle.IPC_UID = charResp.IPC_UID
|
charCreate.PCStyle.IPC_UID = charResp.IPC_UID
|
||||||
var charCreateResp protocol.SP_LS2CL_REP_CHAR_CREATE_SUCC
|
var charCreateResp protocol.SP_LS2CL_REP_CHAR_CREATE_SUCC
|
||||||
dummy.SendAndRecv(protocol.P_CL2LS_REQ_CHAR_CREATE, protocol.P_LS2CL_REP_CHAR_CREATE_SUCC,
|
dummy.SendAndRecv(is, protocol.P_CL2LS_REQ_CHAR_CREATE, protocol.P_LS2CL_REP_CHAR_CREATE_SUCC,
|
||||||
charCreate, &charCreateResp)
|
charCreate, &charCreateResp)
|
||||||
|
|
||||||
// verify response
|
// verify response
|
||||||
|
@ -18,8 +18,7 @@ func (server *ShardServer) LoadNPCs() {
|
|||||||
|
|
||||||
data, err := os.ReadFile(config.GetTDataPath() + "/NPCs.json")
|
data, err := os.ReadFile(config.GetTDataPath() + "/NPCs.json")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Warning: failed to load NPCs: %v", err)
|
panic(err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// yes, we have to do it this way so our NPCs IDs will be incremented and unique
|
// yes, we have to do it this way so our NPCs IDs will be incremented and unique
|
||||||
|
Loading…
x
Reference in New Issue
Block a user