Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro
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
YGOPRO-520DIY
ygopro
Commits
9e22a70e
Commit
9e22a70e
authored
Jun 17, 2025
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rework using GetEnvironmentStringsW
parent
92971179
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
13 deletions
+23
-13
gframe/game.cpp
gframe/game.cpp
+23
-13
No files found.
gframe/game.cpp
View file @
9e22a70e
...
...
@@ -2547,25 +2547,35 @@ void Game::SetCursor(irr::gui::ECURSOR_ICON icon) {
}
void
Game
::
InjectEnvToRegistry
(
intptr_t
pduel
)
{
#ifdef _WIN32
auto
env_strings
=
GetEnvironmentStringsA
();
if
(
!
env_
strings
)
return
;
LPWCH
env_block
=
GetEnvironmentStringsW
();
if
(
!
env_
block
)
return
;
const
std
::
string
prefix
=
"YGOPRO_ENV_"
;
for
(
auto
*
var
=
env_strings
;
*
var
;
var
+=
strlen
(
var
)
+
1
)
{
std
::
string
entry
(
var
);
if
(
entry
.
compare
(
0
,
prefix
.
size
(),
prefix
)
==
0
)
{
auto
eq_pos
=
entry
.
find
(
'='
);
if
(
eq_pos
==
std
::
string
::
npos
)
continue
;
const
wchar_t
*
prefix
=
L"YGOPRO_ENV_"
;
const
size_t
prefix_len
=
wcslen
(
prefix
);
std
::
string
name
=
entry
.
substr
(
0
,
eq_pos
);
std
::
string
value
=
entry
.
substr
(
eq_pos
+
1
);
for
(
LPWCH
var
=
env_block
;
*
var
!=
L'\0'
;
)
{
// 是 YGOPRO_ENV_ 开头
if
(
wcsncmp
(
var
,
prefix
,
prefix_len
)
==
0
)
{
const
wchar_t
*
equal_pos
=
wcschr
(
var
,
L'='
);
if
(
equal_pos
&&
equal_pos
>
var
+
prefix_len
)
{
// 拆 key 和 value(UTF-16)
std
::
wstring
key_w
(
var
+
prefix_len
,
equal_pos
);
// foo
std
::
wstring
value_w
(
equal_pos
+
1
);
// bar
std
::
string
key
=
"env_"
+
name
.
substr
(
prefix
.
size
());
set_registry_value
(
pduel
,
key
.
c_str
(),
value
.
c_str
());
char
key_utf8
[
256
]{};
char
value_utf8
[
1024
]{};
// 转成 UTF-8:key = env_foo
BufferIO
::
EncodeUTF8
((
L"env_"
+
key_w
).
c_str
(),
key_utf8
);
BufferIO
::
EncodeUTF8
(
value_w
.
c_str
(),
value_utf8
);
set_registry_value
(
pduel
,
key_utf8
,
value_utf8
);
}
}
var
+=
wcslen
(
var
)
+
1
;
}
FreeEnvironmentStrings
A
(
env_strings
);
FreeEnvironmentStrings
W
(
env_block
);
#else
const
std
::
string
prefix
=
"YGOPRO_ENV_"
;
for
(
char
**
env
=
environ
;
*
env
!=
nullptr
;
++
env
)
{
...
...
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