Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-proxy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
ygopro-proxy
Commits
8029316a
Commit
8029316a
authored
Sep 11, 2022
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add transformPlayerInfo and go fmt
parent
26b17b7d
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
67 additions
and
49 deletions
+67
-49
DarkNeos/transform.go
DarkNeos/transform.go
+67
-49
No files found.
DarkNeos/transform.go
View file @
8029316a
...
@@ -8,7 +8,7 @@ import (
...
@@ -8,7 +8,7 @@ import (
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/proto"
)
)
const
FILLING_TOKEN
uint16
=
0xcccc
;
const
FILLING_TOKEN
uint16
=
0xcccc
const
UTF16_BUFFER_MAX_LEN
int
=
20
const
UTF16_BUFFER_MAX_LEN
int
=
20
const
(
const
(
...
@@ -26,7 +26,9 @@ func Transform(src []byte, tranformType int) ([]byte, error) {
...
@@ -26,7 +26,9 @@ func Transform(src []byte, tranformType int) ([]byte, error) {
switch
message
.
Msg
.
(
type
)
{
switch
message
.
Msg
.
(
type
)
{
case
*
(
ygopropb
.
YgoCtosMsg_CtosPlayerInfo
)
:
case
*
(
ygopropb
.
YgoCtosMsg_CtosPlayerInfo
)
:
return
TransformPlayerInfo
(
message
.
GetCtosPlayerInfo
()),
nil
return
transformPlayerInfo
(
message
.
GetCtosPlayerInfo
()),
nil
case
*
(
ygopropb
.
YgoCtosMsg_CtosJoinGame
)
:
return
transformJoinGame
(
message
.
GetCtosJoinGame
()),
nil
default
:
default
:
return
nil
,
errors
.
New
(
"Unhandled YgoCtosMsg type"
)
return
nil
,
errors
.
New
(
"Unhandled YgoCtosMsg type"
)
}
}
...
@@ -37,13 +39,26 @@ func Transform(src []byte, tranformType int) ([]byte, error) {
...
@@ -37,13 +39,26 @@ func Transform(src []byte, tranformType int) ([]byte, error) {
}
}
}
}
func
transformPlayerInfo
(
pb
*
ygopropb
.
CtosPlayerInfo
)
[]
byte
{
buf
:=
strToUtf16Buffer
(
pb
.
Name
)
func
TransformPlayerInfo
(
pb
*
ygopropb
.
CtosPlayerInfo
)
[]
byte
{
return
uint16BufToByteBuf
(
buf
)
info
:=
strToUtf16Buffer
(
pb
.
Name
)
return
uint16BufToByteBuf
(
info
)
}
}
func
transformJoinGame
(
pb
*
ygopropb
.
CtosJoinGame
)
[]
byte
{
buf
:=
make
([]
byte
,
0
)
version
:=
uint16
(
pb
.
Version
)
buf
=
append
(
buf
,
byte
(
version
),
byte
(
pb
.
Version
>>
8
),
0
,
0
)
buf
=
append
(
buf
,
byte
(
pb
.
Gameid
),
byte
(
pb
.
Gameid
>>
8
),
byte
(
pb
.
Gameid
>>
16
),
byte
(
pb
.
Gameid
>>
24
))
for
_
,
v
:=
range
uint16BufToByteBuf
(
strToUtf16Buffer
(
pb
.
Passwd
))
{
buf
=
append
(
buf
,
v
)
}
return
buf
}
func
strToUtf16Buffer
(
s
string
)
[]
uint16
{
func
strToUtf16Buffer
(
s
string
)
[]
uint16
{
b
:=
make
([]
uint16
,
UTF16_BUFFER_MAX_LEN
,
UTF16_BUFFER_MAX_LEN
)
b
:=
make
([]
uint16
,
UTF16_BUFFER_MAX_LEN
,
UTF16_BUFFER_MAX_LEN
)
...
@@ -58,20 +73,23 @@ func strToUtf16Buffer(s string) []uint16 {
...
@@ -58,20 +73,23 @@ func strToUtf16Buffer(s string) []uint16 {
if
i
<
UTF16_BUFFER_MAX_LEN
{
if
i
<
UTF16_BUFFER_MAX_LEN
{
b
[
i
]
=
v
b
[
i
]
=
v
if
i
==
len
(
s_utf16
)
-
1
&&
i
<
len
(
b
)
-
1
{
if
i
==
len
(
s_utf16
)
-
1
&&
i
<
len
(
b
)
-
1
{
b
[
i
+
1
]
=
0
b
[
i
+
1
]
=
0
}
}
else
{
break
}
}
}
else
{
break
}
}
}
return
b
return
b
}
}
func
uint16BufToByteBuf
(
u16_b
[]
uint16
)
[]
byte
{
func
uint16BufToByteBuf
(
u16_b
[]
uint16
)
[]
byte
{
b
:=
make
([]
byte
,
0
,
len
(
u16_b
)
*
2
)
b
:=
make
([]
byte
,
0
,
len
(
u16_b
)
*
2
)
for
_
,
v
:=
range
u16_b
{
for
_
,
v
:=
range
u16_b
{
b
=
append
(
b
,
byte
(
v
>>
8
),
byte
(
v
))
// little endian
b
=
append
(
b
,
byte
(
v
),
byte
(
v
>>
8
))
}
}
return
b
return
b
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment