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
e2d19979
Commit
e2d19979
authored
Jun 25, 2025
by
xiaoye
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
14c5632c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
26 deletions
+69
-26
gframe/data_manager.cpp
gframe/data_manager.cpp
+55
-21
gframe/data_manager.h
gframe/data_manager.h
+5
-4
gframe/game.cpp
gframe/game.cpp
+9
-1
No files found.
gframe/data_manager.cpp
View file @
e2d19979
...
...
@@ -179,6 +179,7 @@ void DataManager::ReadStringConfLine(const char* linebuf) {
}
}
bool
DataManager
::
LoadServerList
(
const
char
*
file
)
{
_serverStrings
.
emplace_back
(
L"清空"
,
L""
);
FILE
*
fp
=
myfopen
(
file
,
"r"
);
if
(
!
fp
)
return
false
;
...
...
@@ -190,6 +191,8 @@ bool DataManager::LoadServerList(const char* file) {
return
true
;
}
bool
DataManager
::
LoadServerList
(
const
wchar_t
*
file
)
{
if
(
_serverStrings
.
empty
())
_serverStrings
.
emplace_back
(
L"清空"
,
L""
);
FILE
*
fp
=
mywfopen
(
file
,
"r"
);
if
(
!
fp
)
return
false
;
...
...
@@ -201,6 +204,8 @@ bool DataManager::LoadServerList(const wchar_t* file) {
return
true
;
}
bool
DataManager
::
LoadServerList
(
irr
::
io
::
IReadFile
*
reader
)
{
if
(
_serverStrings
.
empty
())
_serverStrings
.
emplace_back
(
L"清空"
,
L""
);
char
ch
{};
std
::
string
linebuf
;
while
(
reader
->
read
(
&
ch
,
1
))
{
...
...
@@ -218,8 +223,6 @@ bool DataManager::LoadServerList(irr::io::IReadFile* reader) {
void
DataManager
::
ReadServerConfLine
(
const
char
*
linebuf
)
{
if
(
strchr
(
linebuf
,
'|'
)
==
nullptr
)
return
;
if
(
_serverStrings
.
empty
())
_serverStrings
.
emplace_back
(
L"清空"
,
L""
);
char
*
buffer
=
const_cast
<
char
*>
(
linebuf
);
buffer
[
strcspn
(
buffer
,
"
\n
"
)]
=
'\0'
;
char
*
separator
=
strchr
(
buffer
,
'|'
);
...
...
@@ -240,6 +243,7 @@ void DataManager::ReadServerConfLine(const char* linebuf) {
it
->
second
=
ip
;
else
_serverStrings
.
emplace_back
(
name
,
ip
);
}
}
}
...
...
@@ -252,6 +256,7 @@ bool DataManager::LoadINI(const char* file) {
ReadINI
(
linebuf
);
}
std
::
fclose
(
fp
);
InsertServerList
();
return
true
;
}
bool
DataManager
::
LoadINI
(
const
wchar_t
*
file
)
{
...
...
@@ -263,6 +268,7 @@ bool DataManager::LoadINI(const wchar_t* file) {
ReadINI
(
linebuf
);
}
std
::
fclose
(
fp
);
InsertServerList
();
return
true
;
}
bool
DataManager
::
LoadINI
(
irr
::
io
::
IReadFile
*
reader
)
{
...
...
@@ -278,32 +284,60 @@ bool DataManager::LoadINI(irr::io::IReadFile* reader) {
}
}
reader
->
drop
();
InsertServerList
();
return
true
;
}
void
DataManager
::
ReadINI
(
const
char
*
linebuf
)
{
iniPort
=
GetINIValue
(
linebuf
,
"ServerPort = "
);
iniHost
=
GetINIValue
(
linebuf
,
"ServerHost = "
);
iniName
=
GetINIValue
(
linebuf
,
"ServerName = "
);
if
(
iniName
!=
""
&&
iniHost
!=
""
)
{
std
::
string
combined
=
std
::
string
(
iniName
)
+
'|'
+
iniHost
;
if
(
iniPort
!=
""
)
combined
+=
':'
+
iniPort
;
const
char
*
result
=
combined
.
c_str
();
ReadServerConfLine
(
result
);
}
}
const
char
*
GetINIValue
(
const
char
*
line
,
const
char
*
key
)
{
if
(
!
line
||
!
key
)
return
""
;
const
wchar_t
*
name
=
GetINIValue
(
linebuf
,
"ServerName = "
);
const
wchar_t
*
host
=
GetINIValue
(
linebuf
,
"ServerHost = "
);
const
wchar_t
*
port
=
GetINIValue
(
linebuf
,
"ServerPort = "
);
if
(
name
!=
L""
)
iniName
=
name
;
if
(
host
!=
L""
)
iniHost
=
host
;
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
""
;
if
(
!
keyPos
)
return
L
""
;
const
char
*
valStart
=
keyPos
+
strlen
(
key
);
while
(
*
valStart
==
' '
)
valStart
++
;
while
(
*
valStart
==
' '
)
valStart
++
;
const
char
*
valEnd
=
valStart
;
while
(
*
valEnd
&&
*
valEnd
!=
'\n'
&&
*
valEnd
!=
'\r'
)
while
(
*
valEnd
&&
*
valEnd
!=
'\n'
&&
*
valEnd
!=
'\r'
)
{
valEnd
++
;
return
std
::
string
(
valStart
,
valEnd
).
c_str
();
}
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""
;
}
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
];
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
;
}
);
if
(
it
!=
_serverStrings
.
end
())
it
->
second
=
ip
;
else
_serverStrings
.
emplace_back
(
name
,
ip
);
delete
[]
buffer
;
}
iniName
==
L""
;
iniHost
==
L""
;
iniPort
==
L""
;
}
bool
DataManager
::
Error
(
sqlite3
*
pDB
,
sqlite3_stmt
*
pStmt
)
{
std
::
snprintf
(
errmsg
,
sizeof
errmsg
,
"%s"
,
sqlite3_errmsg
(
pDB
));
...
...
gframe/data_manager.h
View file @
e2d19979
...
...
@@ -58,7 +58,8 @@ public:
bool
LoadINI
(
const
wchar_t
*
file
);
bool
LoadINI
(
irr
::
io
::
IReadFile
*
reader
);
void
ReadINI
(
const
char
*
linebuf
);
const
char
*
GetINIValue
(
const
char
*
line
,
const
char
*
key
);
const
wchar_t
*
GetINIValue
(
const
char
*
line
,
const
char
*
key
);
void
InsertServerList
();
bool
Error
(
sqlite3
*
pDB
,
sqlite3_stmt
*
pStmt
=
nullptr
);
code_pointer
GetCodePointer
(
unsigned
int
code
)
const
;
...
...
@@ -114,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
char
*
iniName
;
const
char
*
iniHost
;
const
char
*
iniPort
;
const
wchar_t
*
iniName
;
const
wchar_t
*
iniHost
;
const
wchar_t
*
iniPort
;
};
extern
DataManager
dataManager
;
...
...
gframe/game.cpp
View file @
e2d19979
...
...
@@ -1266,6 +1266,10 @@ void Game::LoadExpansions(const wchar_t* expansions_path) {
}
return
;
}
if
(
IsExtension
(
name
,
L".ini"
))
{
dataManager
.
LoadINI
(
fpath
);
server_list_changed
=
true
;
}
if
(
IsExtension
(
name
,
L".zip"
)
||
IsExtension
(
name
,
L".ypk"
))
{
#ifdef _WIN32
DataManager
::
FileSystem
->
addFileArchive
(
fpath
,
true
,
false
,
irr
::
io
::
EFAT_ZIP
);
...
...
@@ -1304,7 +1308,7 @@ void Game::LoadExpansions(const wchar_t* expansions_path) {
if
(
!
std
::
wcscmp
(
fname
,
L"lflist.conf"
))
{
deckManager
.
LoadLFListSingle
(
reader
,
true
);
lflist_changed
=
true
;
}
}
else
if
(
!
std
::
wcscmp
(
fname
,
L"server.conf"
))
{
}
else
if
(
!
std
::
wcscmp
(
fname
,
L"server.conf"
))
{
dataManager
.
LoadServerList
(
reader
);
server_list_changed
=
true
;
}
else
{
...
...
@@ -1312,6 +1316,10 @@ void Game::LoadExpansions(const wchar_t* expansions_path) {
}
continue
;
}
if
(
IsExtension
(
name
,
L".ini"
))
{
dataManager
.
LoadINI
(
createReader
());
server_list_changed
=
true
;
}
if
(
!
mywcsncasecmp
(
fname
,
L"pack/"
,
5
)
&&
IsExtension
(
fname
,
L".ydk"
))
{
deckBuilder
.
expansionPacks
.
push_back
(
fname
);
continue
;
...
...
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