fix(go): repair migration wire contracts and runtime lifecycle; document incomplete port
This commit is contained in:
1 parent
e43a310617
commit
32e47014b5
35 files changed
+16826
-438
No files matched your search
+47
-22
@@ -1,7 +1,6 @@
|
||||
package protocol
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
@@ -25,9 +24,9 @@ func EncodeServerTime(clientUnixTime float64) []byte {
|
||||
// Format (Inline): [I32 patchVersion (0)] [0xFF marker] [Int7 count (0)]
|
||||
func EncodePatchCheck() []byte {
|
||||
w := NewUxWriter()
|
||||
w.I32(0) // patchVersion
|
||||
w.U8(0xFF) // list marker
|
||||
w.Int7(0) // empty list
|
||||
w.I32(0) // patchVersion
|
||||
w.U8(0xFF) // list marker
|
||||
w.Int7(0) // empty list
|
||||
return w.Bytes()
|
||||
}
|
||||
|
||||
@@ -40,7 +39,7 @@ func EncodeEmptyList() []byte {
|
||||
}
|
||||
|
||||
// EncodeCheckAccount encodes CheckAccountResult.
|
||||
func EncodeCheckAccount(accountId, userName, token string, aid, serverId int, pid uint64) []byte {
|
||||
func EncodeCheckAccount(accountId, userName, token, displayName string, aid, serverId int, pid uint64) []byte {
|
||||
loginData := map[string]interface{}{
|
||||
"code": 200,
|
||||
"subcode": 0,
|
||||
@@ -52,7 +51,7 @@ func EncodeCheckAccount(accountId, userName, token string, aid, serverId int, pi
|
||||
"pid": pid,
|
||||
"player_id": fmt.Sprintf("%d", pid),
|
||||
"role_id": fmt.Sprintf("%d", pid),
|
||||
"role_name": "辰宿",
|
||||
"role_name": displayName,
|
||||
"server_id": fmt.Sprintf("%d", serverId),
|
||||
"host_id": serverId,
|
||||
"username": userName,
|
||||
@@ -144,10 +143,10 @@ func EncodeEnterScene(pid uint64, raidId uint32, instanceId uint64, universeId u
|
||||
// SectorControlIds (empty list)
|
||||
w.U8(0xFF).Int7(0)
|
||||
w.U32(0) // DynamicLayerId
|
||||
// LoadingType (Complex 0xFF: Type, Members list, Ripple)
|
||||
w.U8(0xFF).U32(0).U8(0xFF).Int7(0).Bool(false)
|
||||
// LinkSimpleInfo (Complex 0xFF: Id, Mode, DeviceLevel, Tag, PublicEventId, LastPublicEventTime, HostPid)
|
||||
w.U8(0xFF).U32(0).U32(0).U32(1).U32(0).U32(0).U64(0).U64(0)
|
||||
// LoadingType (TypeMark 1: byte Type, Int32 Members list, Ripple)
|
||||
w.U8(1).U8(0).U8(0xFF).I32(0).Bool(false)
|
||||
// LinkSimpleInfo (TypeMark 1: U64 Id, three bytes, U32 event/time, U64 host)
|
||||
w.U8(1).U64(0).U8(0).U8(1).U8(0).U32(0).U32(0).U64(0)
|
||||
// DataLayerIndices (empty list)
|
||||
w.U8(0xFF).Int7(0)
|
||||
w.Bool(false) // Seamless
|
||||
@@ -230,7 +229,7 @@ func EncodeRaidBattleUnitSpirit(unitId uint64, templateId uint32, posX, posY, po
|
||||
w.U8(0).U32(0)
|
||||
|
||||
// GroundData (MoveActionGroundData Complex 0xFF)
|
||||
w.U8(0xFF).U32(0).U64(0).U32(0)
|
||||
w.U8(0xFF).U8(0).U64(0).U8(0)
|
||||
// LocalPos (UXVector3)
|
||||
w.F32(0).F32(0).F32(0)
|
||||
|
||||
@@ -244,17 +243,43 @@ func EncodePlayerInfo(templatePath string, aid int, pid uint64, accountId, name
|
||||
return nil, err
|
||||
}
|
||||
|
||||
res := make([]byte, len(data))
|
||||
copy(res, data)
|
||||
|
||||
// Patch Aid at offset 4 (4 bytes)
|
||||
if len(res) > 8 {
|
||||
binary.LittleEndian.PutUint32(res[4:8], uint32(aid))
|
||||
// PlayerClientInfo: complex marker, Config buffer (Int7), InfoLogin marker,
|
||||
// Aid, Pid, AccountId, Name. String lengths may change; preserve the rest verbatim.
|
||||
r := NewUxReader(data)
|
||||
mark, err := r.U8()
|
||||
if err != nil || mark != 0xff {
|
||||
return nil, fmt.Errorf("invalid PlayerClientInfo marker")
|
||||
}
|
||||
// Patch Pid at offset 8 (8 bytes)
|
||||
if len(res) > 16 {
|
||||
binary.LittleEndian.PutUint64(res[8:16], pid)
|
||||
mark, err = r.U8()
|
||||
if err != nil || mark != 0xff {
|
||||
return nil, fmt.Errorf("invalid Config buffer marker")
|
||||
}
|
||||
|
||||
return res, nil
|
||||
n, err := r.Int7()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, err = r.Bytes(n); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mark, err = r.U8()
|
||||
if err != nil || mark != 0xff {
|
||||
return nil, fmt.Errorf("invalid InfoLogin marker")
|
||||
}
|
||||
prefixEnd := r.Position()
|
||||
if _, err = r.I32(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, err = r.U64(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, err = r.UxString(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if _, err = r.UxString(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
w := NewUxWriter()
|
||||
w.Raw(data[:prefixEnd]).I32(int32(aid)).U64(pid).UxString(accountId).UxString(name)
|
||||
w.Raw(data[r.Position():])
|
||||
return w.Bytes(), nil
|
||||
}
|
||||
Reference in new issue
Block a user