Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
MDPro3
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
JQY
MDPro3
Commits
c2dcb501
Commit
c2dcb501
authored
Jan 02, 2026
by
SherryChaos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update mycard u16Secret
parent
d18d30e8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
7 deletions
+63
-7
Assets/Scripts/MDPro3/Net/MyCard.cs
Assets/Scripts/MDPro3/Net/MyCard.cs
+57
-6
Assets/Scripts/MDPro3/UI/SelectionButton/SelectionToggle_Watch.cs
...cripts/MDPro3/UI/SelectionButton/SelectionToggle_Watch.cs
+6
-1
No files found.
Assets/Scripts/MDPro3/Net/MyCard.cs
View file @
c2dcb501
...
...
@@ -389,19 +389,19 @@ namespace MDPro3.Net
JoinPrivate
=
5
,
}
public
static
string
GetJoinRoomPassword
(
MyCardRoomOptions
options
,
string
roomId
,
int
userId
,
bool
_private
=
false
)
public
static
async
UniTask
<
string
>
GetJoinRoomPassword
(
MyCardRoomOptions
options
,
string
roomId
,
int
userId
,
bool
_private
=
false
)
{
byte
[]
optionsBuffer
=
new
byte
[
6
];
optionsBuffer
[
1
]
=
(
byte
)((
_private
?
(
int
)
RoomAction
.
JoinPrivate
:
(
int
)
RoomAction
.
JoinPublic
)
<<
4
);
EncryptBuffer
(
optionsBuffer
,
userId
);
await
EncryptBuffer
(
optionsBuffer
);
string
base64String
=
Convert
.
ToBase64String
(
optionsBuffer
);
return
base64String
+
roomId
;
}
public
static
string
GetCreateRoomPasswd
(
MyCardRoomOptions
options
,
string
roomID
,
int
userId
,
bool
_private
=
false
)
public
static
async
Task
<
string
>
GetCreateRoomPasswd
(
MyCardRoomOptions
options
,
string
roomID
,
int
userId
,
bool
_private
=
false
)
{
byte
[]
optionsBuffer
=
new
byte
[
6
];
optionsBuffer
[
1
]
=
(
byte
)(((
byte
)(
_private
?
RoomAction
.
CreatePrivate
:
RoomAction
.
CreatePublic
)
<<
4
)
|
(
byte
)(
options
.
duel_rule
<<
1
)
|
(
options
.
auto_death
?
0x1
:
0
));
...
...
@@ -410,13 +410,13 @@ namespace MDPro3.Net
WriteUInt16LE
(
optionsBuffer
,
3
,
(
ushort
)
options
.
start_lp
);
optionsBuffer
[
5
]
=
(
byte
)(((
byte
)
options
.
start_hand
<<
4
)
|
options
.
draw_count
);
EncryptBuffer
(
optionsBuffer
,
userId
);
await
EncryptBuffer
(
optionsBuffer
);
string
base64String
=
Convert
.
ToBase64String
(
optionsBuffer
);
return
base64String
+
roomID
;
}
private
static
void
EncryptBuffer
(
byte
[]
buffer
,
int
external_id
)
private
static
async
UniTask
EncryptBuffer
(
byte
[]
buffer
)
{
int
checksum
=
0
;
...
...
@@ -427,7 +427,8 @@ namespace MDPro3.Net
buffer
[
0
]
=
(
byte
)(
checksum
&
0xff
);
int
secret
=
(
external_id
%
65535
)
+
1
;
var
u16Secret
=
await
GetUserU16SecretAsync
();
int
secret
=
u16Secret
%
65535
+
1
;
for
(
int
i
=
0
;
i
<
buffer
.
Length
;
i
+=
2
)
{
...
...
@@ -453,6 +454,56 @@ namespace MDPro3.Net
buffer
[
offset
+
1
]
=
(
byte
)((
value
>>
8
)
&
0xff
);
}
[
Serializable
]
private
class
AuthResponse
{
public
int
u16Secret
;
}
private
static
async
UniTask
<
int
>
GetUserU16SecretAsync
()
{
static
void
Bad
(
string
message
)
{
MessageManager
.
Cast
(
InterString
.
Get
(
"MyCard: 获取用户密钥失败。请重新登录。([?])"
,
message
));
throw
new
Exception
(
$"Get U16 secret failed:
{
message
}
"
);
}
if
(
account
==
null
)
Bad
(
"No account info"
);
if
(
string
.
IsNullOrEmpty
(
account
.
token
))
Bad
(
"no token"
);
var
token
=
account
.
token
;
var
url
=
authUrl
;
using
var
request
=
UnityWebRequest
.
Get
(
url
);
request
.
SetRequestHeader
(
"Authorization"
,
$"Bearer
{
token
}
"
);
request
.
SetRequestHeader
(
"Content-Type"
,
"application/json"
);
await
request
.
SendWebRequest
();
if
(
request
.
result
!=
UnityWebRequest
.
Result
.
Success
)
{
Bad
(
request
.
error
);
return
0
;
}
try
{
var
jsonResponse
=
request
.
downloadHandler
.
text
;
var
authInfo
=
JsonUtility
.
FromJson
<
AuthResponse
>(
jsonResponse
);
if
(
authInfo
==
null
||
authInfo
.
u16Secret
==
0
)
{
Bad
(
"no secret or invalid response"
);
return
0
;
}
return
authInfo
.
u16Secret
;
}
catch
(
Exception
e
)
{
Bad
(
e
.
ToString
());
return
0
;
}
}
#
endregion
}
...
...
Assets/Scripts/MDPro3/UI/SelectionButton/SelectionToggle_Watch.cs
View file @
c2dcb501
...
...
@@ -52,7 +52,12 @@ namespace MDPro3.UI
{
AudioManager
.
PlaySE
(
"SE_MENU_DECIDE"
);
base
.
CallSubmitEvent
();
var
password
=
MyCard
.
GetJoinRoomPassword
(
options
,
roomId
,
MyCard
.
account
.
user
.
id
);
_
=
WaitPasswordToJoin
();
}
private
async
UniTask
WaitPasswordToJoin
()
{
var
password
=
await
MyCard
.
GetJoinRoomPassword
(
options
,
roomId
,
MyCard
.
account
.
user
.
id
);
TcpHelper
.
LinkStart
(
MyCard
.
duelUrl
,
MyCard
.
account
.
user
.
username
,
MyCard
.
athleticPort
.
ToString
(),
password
,
false
,
null
);
}
...
...
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