Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro for rd
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 for rd
Commits
0554ebeb
Commit
0554ebeb
authored
Jun 26, 2025
by
xiaoye
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
从 const wchar_t* 改为 std::wstring
parent
811d74a9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
65 deletions
+57
-65
gframe/data_manager.cpp
gframe/data_manager.cpp
+50
-49
gframe/data_manager.h
gframe/data_manager.h
+5
-5
gframe/game.cpp
gframe/game.cpp
+1
-1
gframe/menu_handler.cpp
gframe/menu_handler.cpp
+1
-10
No files found.
gframe/data_manager.cpp
View file @
0554ebeb
...
...
@@ -222,30 +222,25 @@ bool DataManager::LoadServerList(irr::io::IReadFile* reader) {
return
true
;
}
void
DataManager
::
ReadServerConfLine
(
const
char
*
linebuf
)
{
if
(
strchr
(
linebuf
,
'|'
)
==
nullptr
)
return
;
char
*
buffer
=
const_cast
<
char
*>
(
linebuf
);
buffer
[
strcspn
(
buffer
,
"
\n
"
)]
=
'\0'
;
char
*
separator
=
strchr
(
buffer
,
'|'
);
if
(
separator
!=
NULL
)
{
char
*
separator
=
strchr
(
buffer
,
'|'
);
if
(
separator
!=
nullptr
)
{
*
separator
=
'\0'
;
wchar_t
wname
[
256
]
;
wchar_t
wip
[
256
];
std
::
wstring
name
,
ip
;
wchar_t
w
name
[
256
],
w
ip
[
256
];
if
(
mbstowcs
(
wname
,
buffer
,
256
)
!=
(
size_t
)
-
1
&&
mbstowcs
(
wip
,
separator
+
1
,
256
)
!=
(
size_t
)
-
1
)
{
wchar_t
*
name
=
new
wchar_t
[
256
];
wchar_t
*
ip
=
new
wchar_t
[
256
];
wcscpy
(
name
,
wname
);
wcscpy
(
ip
,
wip
);
auto
it
=
std
::
find_if
(
_serverStrings
.
begin
(),
_serverStrings
.
end
(),
[
name
](
const
auto
&
pair
)
{
return
wcscmp
(
pair
.
first
,
name
)
==
0
;
}
);
if
(
it
!=
_serverStrings
.
end
())
it
->
second
=
ip
;
else
_serverStrings
.
emplace_back
(
name
,
ip
);
ip
=
wip
;
name
=
wname
;
}
auto
it
=
std
::
find_if
(
_serverStrings
.
begin
(),
_serverStrings
.
end
(),
[
name
](
const
auto
&
pair
)
{
return
pair
.
first
==
name
;
}
);
if
(
it
!=
_serverStrings
.
end
())
it
->
second
=
ip
;
else
_serverStrings
.
emplace_back
(
name
,
ip
);
}
}
bool
DataManager
::
LoadINI
(
const
char
*
file
)
{
...
...
@@ -289,9 +284,9 @@ bool DataManager::LoadINI(irr::io::IReadFile* reader) {
return
true
;
}
void
DataManager
::
ReadINI
(
const
char
*
linebuf
)
{
const
wchar_t
*
name
=
GetINIValue
(
linebuf
,
"ServerName = "
);
const
wchar_t
*
host
=
GetINIValue
(
linebuf
,
"ServerHost = "
);
const
wchar_t
*
port
=
GetINIValue
(
linebuf
,
"ServerPort = "
);
std
::
wstring
name
=
GetINIValue
(
linebuf
,
"ServerName = "
);
std
::
wstring
host
=
GetINIValue
(
linebuf
,
"ServerHost = "
);
std
::
wstring
port
=
GetINIValue
(
linebuf
,
"ServerPort = "
);
if
(
name
!=
L""
)
iniName
=
name
;
if
(
host
!=
L""
)
...
...
@@ -299,45 +294,51 @@ void DataManager::ReadINI(const char* linebuf) {
if
(
port
!=
L""
)
iniPort
=
port
;
}
const
wchar_t
*
DataManager
::
GetINIValue
(
const
char
*
line
,
const
char
*
key
)
{
if
(
!
line
||
!
key
)
return
L""
;
const
char
*
keyPos
=
strstr
(
line
,
key
);
if
(
!
keyPos
)
return
L""
;
const
char
*
valStart
=
keyPos
+
strlen
(
key
);
while
(
*
valStart
==
' '
)
valStart
++
;
const
char
*
valEnd
=
valStart
;
while
(
*
valEnd
&&
*
valEnd
!=
'\n'
&&
*
valEnd
!=
'\r'
)
{
valEnd
++
;
}
wchar_t
value
[
256
];
if
(
mbstowcs
(
value
,
std
::
string
(
valStart
,
valEnd
).
c_str
(),
256
)
!=
(
size_t
)
-
1
)
{
wchar_t
*
result
=
new
wchar_t
[
256
];
wcscpy
(
result
,
value
);
return
result
;
}
return
L""
;
std
::
wstring
DataManager
::
GetINIValue
(
const
char
*
line
,
const
char
*
key
)
{
if
(
!
line
||
!
key
)
{
return
L""
;
}
const
char
*
keyPos
=
strstr
(
line
,
key
);
if
(
!
keyPos
)
{
return
L""
;
}
const
char
*
valStart
=
keyPos
+
strlen
(
key
);
while
(
*
valStart
==
' '
)
valStart
++
;
const
char
*
valEnd
=
valStart
;
while
(
*
valEnd
&&
*
valEnd
!=
'\n'
&&
*
valEnd
!=
'\r'
)
valEnd
++
;
if
(
valStart
==
valEnd
)
return
L""
;
std
::
string
narrowStr
(
valStart
,
valEnd
);
if
(
narrowStr
.
empty
())
return
L""
;
size_t
requiredSize
=
mbstowcs
(
nullptr
,
narrowStr
.
c_str
(),
0
);
if
(
requiredSize
==
(
size_t
)
-
1
)
return
L""
;
std
::
wstring
wideStr
(
requiredSize
+
1
,
L'\0'
);
mbstowcs
(
&
wideStr
[
0
],
narrowStr
.
c_str
(),
requiredSize
+
1
);
wideStr
.
resize
(
requiredSize
);
return
wideStr
;
}
void
DataManager
::
InsertServerList
()
{
if
(
iniName
!=
L""
&&
iniHost
!=
L""
)
{
const
wchar_t
*
ip
=
iniHost
;
const
wchar_t
*
name
=
iniName
;
size_t
len
=
wcslen
(
iniHost
)
+
wcslen
(
iniPort
)
+
2
;
wchar_t
*
buffer
=
new
wchar_t
[
len
];
std
::
wstring
ip
=
iniHost
;
std
::
wstring
name
=
iniName
;
if
(
iniPort
!=
L""
)
{
std
::
swprintf
(
buffer
,
len
,
L"%s:%s"
,
iniHost
,
iniPort
);
ip
=
buffer
;
}
auto
it
=
std
::
find_if
(
_serverStrings
.
begin
(),
_serverStrings
.
end
(),
[
name
](
const
auto
&
pair
)
{
return
wcscmp
(
pair
.
first
,
name
)
==
0
;
}
[
name
](
const
auto
&
pair
)
{
return
pair
.
first
==
name
;
}
);
if
(
it
!=
_serverStrings
.
end
())
it
->
second
=
ip
;
else
_serverStrings
.
emplace_back
(
name
,
ip
);
}
iniName
==
L""
;
iniHost
==
L""
;
iniPort
==
L""
;
iniName
.
clear
()
;
iniHost
.
clear
()
;
iniPort
.
clear
()
;
}
bool
DataManager
::
Error
(
sqlite3
*
pDB
,
sqlite3_stmt
*
pStmt
)
{
std
::
snprintf
(
errmsg
,
sizeof
errmsg
,
"%s"
,
sqlite3_errmsg
(
pDB
));
...
...
gframe/data_manager.h
View file @
0554ebeb
...
...
@@ -58,7 +58,7 @@ public:
bool
LoadINI
(
const
wchar_t
*
file
);
bool
LoadINI
(
irr
::
io
::
IReadFile
*
reader
);
void
ReadINI
(
const
char
*
linebuf
);
const
wchar_t
*
GetINIValue
(
const
char
*
line
,
const
char
*
key
);
std
::
wstring
GetINIValue
(
const
char
*
line
,
const
char
*
key
);
void
InsertServerList
();
bool
Error
(
sqlite3
*
pDB
,
sqlite3_stmt
*
pStmt
=
nullptr
);
...
...
@@ -90,7 +90,7 @@ public:
std
::
unordered_map
<
unsigned
int
,
std
::
wstring
>
_victoryStrings
;
std
::
unordered_map
<
unsigned
int
,
std
::
wstring
>
_setnameStrings
;
std
::
unordered_map
<
unsigned
int
,
std
::
wstring
>
_sysStrings
;
std
::
vector
<
std
::
pair
<
const
wchar_t
*
,
const
wchar_t
*
>>
_serverStrings
;
std
::
vector
<
std
::
pair
<
std
::
wstring
,
std
::
wstring
>>
_serverStrings
;
char
errmsg
[
512
]{};
static
unsigned
char
scriptBuffer
[
0x100000
];
...
...
@@ -115,9 +115,9 @@ private:
std
::
unordered_map
<
unsigned
int
,
CardDataC
>
_datas
;
std
::
unordered_map
<
unsigned
int
,
CardString
>
_strings
;
std
::
unordered_map
<
unsigned
int
,
std
::
vector
<
uint16_t
>>
extra_setcode
;
const
wchar_t
*
iniName
;
const
wchar_t
*
iniHost
;
const
wchar_t
*
iniPort
;
std
::
wstring
iniName
;
std
::
wstring
iniHost
;
std
::
wstring
iniPort
;
};
extern
DataManager
dataManager
;
...
...
gframe/game.cpp
View file @
0554ebeb
...
...
@@ -1528,7 +1528,7 @@ void Game::RefreshBot() {
void
Game
::
RefreshServerList
()
{
lstServerList
->
clear
();
for
(
const
auto
&
pair
:
dataManager
.
_serverStrings
)
{
const
wchar_t
*
key
=
pair
.
first
;
const
wchar_t
*
key
=
pair
.
first
.
c_str
()
;
lstServerList
->
addItem
(
key
);
}
}
...
...
gframe/menu_handler.cpp
View file @
0554ebeb
...
...
@@ -492,16 +492,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
}
case
BUTTON_SERVER_SELECTED
:
{
int
sel
=
mainGame
->
lstServerList
->
getSelected
();
if
(
sel
==
-
1
)
wcscpy
(
mainGame
->
gameConf
.
lasthost
,
L""
);
else
{
const
wchar_t
*
key
=
mainGame
->
lstServerList
->
getListItem
(
sel
);
auto
it
=
std
::
find_if
(
dataManager
.
_serverStrings
.
begin
(),
dataManager
.
_serverStrings
.
end
(),
[
key
](
const
auto
&
pair
)
{
return
wcscmp
(
pair
.
first
,
key
)
==
0
;
}
);
wcscpy
(
mainGame
->
gameConf
.
lasthost
,
it
==
dataManager
.
_serverStrings
.
end
()
?
L""
:
it
->
second
);
}
wcscpy
(
mainGame
->
gameConf
.
lasthost
,
sel
==
-
1
?
L""
:
dataManager
.
_serverStrings
[
sel
].
second
.
c_str
());
wchar_t
buf
[
256
];
myswprintf
(
buf
,
L"%s"
,
mainGame
->
gameConf
.
lasthost
);
mainGame
->
ebJoinHost
->
setText
(
buf
);
...
...
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