Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Neos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
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
Neos
Commits
57ab45b7
Commit
57ab45b7
authored
Feb 04, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix/name' into 'main'
fix name See merge request
mycard/Neos!97
parents
4bb4fe41
03a19480
Pipeline
#19946
passed with stages
in 5 minutes and 42 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
2 deletions
+21
-2
src/api/ocgcore/ocgAdapter/stoc/stocHsPlayerEnter.ts
src/api/ocgcore/ocgAdapter/stoc/stocHsPlayerEnter.ts
+2
-2
src/api/ocgcore/ocgAdapter/util.ts
src/api/ocgcore/ocgAdapter/util.ts
+19
-0
No files found.
src/api/ocgcore/ocgAdapter/stoc/stocHsPlayerEnter.ts
View file @
57ab45b7
import
{
ygopro
}
from
"
../../idl/ocgcore
"
;
import
{
YgoProPacket
,
StocAdapter
}
from
"
../packet
"
;
import
{
UTF16_BUFFER_MAX_LEN
}
from
"
../util
"
;
import
{
UTF16_BUFFER_MAX_LEN
,
_cutoff_name
}
from
"
../util
"
;
const
UINT8_PER_UINT16
=
2
;
...
...
@@ -24,7 +24,7 @@ export default class HsPlayerEnterAdapter implements StocAdapter {
const
decoder
=
new
TextDecoder
(
"
utf-16
"
);
const
name
=
decoder
.
decode
(
exData
.
slice
(
0
,
UTF16_BUFFER_MAX_LEN
*
UINT8_PER_UINT16
)
_cutoff_name
(
exData
.
slice
(
0
,
UTF16_BUFFER_MAX_LEN
*
UINT8_PER_UINT16
)
)
);
const
dataView
=
new
DataView
(
exData
.
buffer
);
...
...
src/api/ocgcore/ocgAdapter/util.ts
View file @
57ab45b7
...
...
@@ -210,3 +210,22 @@ export function numberToChainFlag(
}
}
}
const
chunkItems
=
<
T
>
(
items
:
T
[])
=>
items
.
reduce
((
chunks
:
T
[][],
item
:
T
,
index
)
=>
{
const
chunk
=
Math
.
floor
(
index
/
2
);
chunks
[
chunk
]
=
([]
as
T
[]).
concat
(
chunks
[
chunk
]
||
[],
item
);
return
chunks
;
},
[]);
export
function
_cutoff_name
(
data
:
Uint8Array
):
Uint8Array
{
let
res
:
number
[]
=
[];
for
(
const
char
of
chunkItems
(
Array
.
from
(
data
)))
{
if
(
!
char
.
every
((
item
)
=>
item
==
0
))
{
res
=
res
.
concat
(
char
);
}
else
{
break
;
}
}
return
Uint8Array
.
from
(
res
);
}
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