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
nanahira
ygopro
Commits
a65a474b
Commit
a65a474b
authored
Jun 27, 2025
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
patches
parent
02e1ddae
Pipeline
#38141
failed with stages
in 3 minutes and 50 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
81 additions
and
94 deletions
+81
-94
gframe/data_manager.cpp
gframe/data_manager.cpp
+52
-63
gframe/data_manager.h
gframe/data_manager.h
+4
-4
gframe/duelclient.cpp
gframe/duelclient.cpp
+1
-0
gframe/game.cpp
gframe/game.cpp
+12
-12
gframe/game.h
gframe/game.h
+2
-4
gframe/menu_handler.cpp
gframe/menu_handler.cpp
+10
-11
No files found.
gframe/data_manager.cpp
View file @
a65a474b
...
...
@@ -179,8 +179,6 @@ void DataManager::ReadStringConfLine(const char* linebuf) {
}
}
bool
DataManager
::
LoadServerList
(
const
char
*
file
)
{
if
(
_serverStrings
.
empty
())
_serverStrings
.
emplace_back
(
GetSysString
(
1304
),
L""
);
FILE
*
fp
=
myfopen
(
file
,
"r"
);
if
(
!
fp
)
return
false
;
...
...
@@ -192,8 +190,6 @@ bool DataManager::LoadServerList(const char* file) {
return
true
;
}
bool
DataManager
::
LoadServerList
(
const
wchar_t
*
file
)
{
if
(
_serverStrings
.
empty
())
_serverStrings
.
emplace_back
(
GetSysString
(
1304
),
L""
);
FILE
*
fp
=
mywfopen
(
file
,
"r"
);
if
(
!
fp
)
return
false
;
...
...
@@ -205,8 +201,6 @@ bool DataManager::LoadServerList(const wchar_t* file) {
return
true
;
}
bool
DataManager
::
LoadServerList
(
irr
::
io
::
IReadFile
*
reader
)
{
if
(
_serverStrings
.
empty
())
_serverStrings
.
emplace_back
(
GetSysString
(
1304
),
L""
);
char
ch
{};
std
::
string
linebuf
;
while
(
reader
->
read
(
&
ch
,
1
))
{
...
...
@@ -222,52 +216,59 @@ bool DataManager::LoadServerList(irr::io::IReadFile* reader) {
return
true
;
}
void
DataManager
::
ReadServerConfLine
(
const
char
*
linebuf
)
{
char
*
buffer
=
const_cast
<
char
*>
(
linebuf
);
char
buffer
[
1024
];
std
::
strncpy
(
buffer
,
linebuf
,
sizeof
(
buffer
)
-
1
);
buffer
[
sizeof
(
buffer
)
-
1
]
=
'\0'
;
buffer
[
strcspn
(
buffer
,
"
\n
"
)]
=
'\0'
;
char
*
separator
=
strchr
(
buffer
,
'|'
);
if
(
separator
!=
nullptr
)
{
*
separator
=
'\0'
;
std
::
wstring
name
,
ip
;
wchar_t
wname
[
256
],
wip
[
256
];
if
(
mbstowcs
(
wname
,
buffer
,
256
)
!=
(
size_t
)
-
1
&&
mbstowcs
(
wip
,
separator
+
1
,
256
)
!=
(
size_t
)
-
1
)
{
ip
=
wip
;
name
=
wname
;
char
*
sep1
=
std
::
strchr
(
buffer
,
'|'
);
if
(
sep1
!=
nullptr
)
{
*
sep1
=
'\0'
;
char
*
addrPart
=
sep1
+
1
;
wchar_t
wname
[
256
],
wip
[
512
];
// read the server name
BufferIO
::
DecodeUTF8
(
buffer
,
wname
);
// replace the first '|' with ':'
char
*
sep2
=
std
::
strchr
(
addrPart
,
'|'
);
if
(
sep2
)
{
*
sep2
=
':'
;
}
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
);
BufferIO
::
DecodeUTF8
(
addrPart
,
wip
);
_serverStrings
.
emplace_back
(
wname
,
wip
);
}
}
bool
DataManager
::
Load
INI
(
const
char
*
file
)
{
bool
DataManager
::
Load
CorresSrvIni
(
const
char
*
file
)
{
FILE
*
fp
=
myfopen
(
file
,
"r"
);
if
(
!
fp
)
return
false
;
char
linebuf
[
TEXT_LINE_SIZE
]{};
while
(
std
::
fgets
(
linebuf
,
sizeof
linebuf
,
fp
))
{
Read
INI
(
linebuf
);
Read
CorresSrvIniLine
(
linebuf
);
}
std
::
fclose
(
fp
);
InsertServerList
();
return
true
;
}
bool
DataManager
::
Load
INI
(
const
wchar_t
*
file
)
{
bool
DataManager
::
Load
CorresSrvIni
(
const
wchar_t
*
file
)
{
FILE
*
fp
=
mywfopen
(
file
,
"r"
);
if
(
!
fp
)
return
false
;
char
linebuf
[
TEXT_LINE_SIZE
]{};
while
(
std
::
fgets
(
linebuf
,
sizeof
linebuf
,
fp
))
{
Read
INI
(
linebuf
);
Read
CorresSrvIniLine
(
linebuf
);
}
std
::
fclose
(
fp
);
InsertServerList
();
return
true
;
}
bool
DataManager
::
Load
INI
(
irr
::
io
::
IReadFile
*
reader
)
{
bool
DataManager
::
Load
CorresSrvIni
(
irr
::
io
::
IReadFile
*
reader
)
{
char
ch
{};
std
::
string
linebuf
;
while
(
reader
->
read
(
&
ch
,
1
))
{
...
...
@@ -275,7 +276,7 @@ bool DataManager::LoadINI(irr::io::IReadFile* reader) {
break
;
linebuf
.
push_back
(
ch
);
if
(
ch
==
'\n'
||
linebuf
.
size
()
>=
TEXT_LINE_SIZE
-
1
)
{
Read
INI
(
linebuf
.
data
());
Read
CorresSrvIniLine
(
linebuf
.
data
());
linebuf
.
clear
();
}
}
...
...
@@ -283,7 +284,7 @@ bool DataManager::LoadINI(irr::io::IReadFile* reader) {
InsertServerList
();
return
true
;
}
void
DataManager
::
Read
INI
(
const
char
*
linebuf
)
{
void
DataManager
::
Read
CorresSrvIniLine
(
const
char
*
linebuf
)
{
std
::
wstring
name
=
GetINIValue
(
linebuf
,
"ServerName = "
);
std
::
wstring
host
=
GetINIValue
(
linebuf
,
"ServerHost = "
);
std
::
wstring
port
=
GetINIValue
(
linebuf
,
"ServerPort = "
);
...
...
@@ -295,48 +296,36 @@ void DataManager::ReadINI(const char* linebuf) {
iniPort
=
port
;
}
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
;
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""
;
wchar_t
wbuf
[
1024
];
BufferIO
::
DecodeUTF8
(
narrowStr
.
c_str
(),
wbuf
);
return
wbuf
;
}
void
DataManager
::
InsertServerList
()
{
if
(
iniName
!=
L""
&&
iniHost
!=
L""
)
{
std
::
wstring
ip
=
iniHost
;
std
::
wstring
name
=
iniName
;
if
(
iniPort
!=
L""
)
{
ip
+=
L":"
;
ip
+=
iniPort
;
}
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
);
_serverStrings
.
emplace_back
(
iniName
,
ip
);
}
iniName
.
clear
();
iniHost
.
clear
();
...
...
gframe/data_manager.h
View file @
a65a474b
...
...
@@ -54,10 +54,10 @@ public:
bool
LoadServerList
(
const
wchar_t
*
file
);
bool
LoadServerList
(
irr
::
io
::
IReadFile
*
reader
);
void
ReadServerConfLine
(
const
char
*
linebuf
);
bool
Load
INI
(
const
char
*
file
);
bool
Load
INI
(
const
wchar_t
*
file
);
bool
Load
INI
(
irr
::
io
::
IReadFile
*
reader
);
void
Read
INI
(
const
char
*
linebuf
);
bool
Load
CorresSrvIni
(
const
char
*
file
);
bool
Load
CorresSrvIni
(
const
wchar_t
*
file
);
bool
Load
CorresSrvIni
(
irr
::
io
::
IReadFile
*
reader
);
void
Read
CorresSrvIniLine
(
const
char
*
linebuf
);
std
::
wstring
GetINIValue
(
const
char
*
line
,
const
char
*
key
);
void
InsertServerList
();
bool
Error
(
sqlite3
*
pDB
,
sqlite3_stmt
*
pStmt
=
nullptr
);
...
...
gframe/duelclient.cpp
View file @
a65a474b
...
...
@@ -622,6 +622,7 @@ void DuelClient::HandleSTOCPacketLan(unsigned char* data, int len) {
mainGame
->
cbDeckSelect
->
setEnabled
(
true
);
mainGame
->
HideElement
(
mainGame
->
wCreateHost
);
mainGame
->
HideElement
(
mainGame
->
wLanWindow
);
mainGame
->
HideElement
(
mainGame
->
wServerList
);
mainGame
->
HideElement
(
mainGame
->
wSinglePlay
);
mainGame
->
ShowElement
(
mainGame
->
wHostPrepare
);
mainGame
->
ResizeChatInputWindow
();
...
...
gframe/game.cpp
View file @
a65a474b
...
...
@@ -124,7 +124,7 @@ bool Game::Initialize() {
ErrorLog
(
"Failed to load strings!"
);
return
false
;
}
dataManager
.
LoadServerList
(
GetLocaleDir
(
"server.conf"
));
dataManager
.
LoadServerList
(
GetLocaleDir
(
"server
s
.conf"
));
dataManager
.
LoadDB
(
L"specials/special.cdb"
);
env
=
device
->
getGUIEnvironment
();
numFont
=
irr
::
gui
::
CGUITTFont
::
createTTFont
(
env
,
gameConf
.
numfont
,
16
);
...
...
@@ -236,8 +236,8 @@ bool Game::Initialize() {
editbox_list
.
push_back
(
ebNickName
);
lstHostList
=
env
->
addListBox
(
irr
::
core
::
rect
<
irr
::
s32
>
(
10
,
60
,
570
,
320
),
wLanWindow
,
LISTBOX_LAN_HOST
,
true
);
lstHostList
->
setItemHeight
(
18
);
btnLanRefresh
=
env
->
addButton
(
irr
::
core
::
rect
<
irr
::
s32
>
(
1
70
,
325
,
27
0
,
350
),
wLanWindow
,
BUTTON_LAN_REFRESH
,
dataManager
.
GetSysString
(
1217
));
btnServerList
=
env
->
addButton
(
irr
::
core
::
rect
<
irr
::
s32
>
(
310
,
325
,
41
0
,
350
),
wLanWindow
,
BUTTON_SERVER_LIST
,
dataManager
.
GetSysString
(
1239
));
btnLanRefresh
=
env
->
addButton
(
irr
::
core
::
rect
<
irr
::
s32
>
(
1
50
,
325
,
25
0
,
350
),
wLanWindow
,
BUTTON_LAN_REFRESH
,
dataManager
.
GetSysString
(
1217
));
btnServerList
=
env
->
addButton
(
irr
::
core
::
rect
<
irr
::
s32
>
(
280
,
325
,
38
0
,
350
),
wLanWindow
,
BUTTON_SERVER_LIST
,
dataManager
.
GetSysString
(
1239
));
env
->
addStaticText
(
dataManager
.
GetSysString
(
1221
),
irr
::
core
::
rect
<
irr
::
s32
>
(
10
,
360
,
220
,
380
),
false
,
false
,
wLanWindow
);
ebJoinHost
=
env
->
addEditBox
(
gameConf
.
lasthost
,
irr
::
core
::
rect
<
irr
::
s32
>
(
110
,
355
,
420
,
380
),
true
,
wLanWindow
);
ebJoinHost
->
setTextAlignment
(
irr
::
gui
::
EGUIA_CENTER
,
irr
::
gui
::
EGUIA_CENTER
);
...
...
@@ -369,8 +369,7 @@ bool Game::Initialize() {
lstServerList
=
env
->
addListBox
(
irr
::
core
::
rect
<
irr
::
s32
>
(
10
,
20
,
290
,
270
),
wServerList
,
LISTBOX_SERVER_LIST
,
true
);
lstServerList
->
setItemHeight
(
18
);
RefreshServerList
();
btnServerSelected
=
env
->
addButton
(
irr
::
core
::
rect
<
irr
::
s32
>
(
30
,
280
,
130
,
310
),
wServerList
,
BUTTON_SERVER_SELECTED
,
dataManager
.
GetSysString
(
1211
));
btnServerCancel
=
env
->
addButton
(
irr
::
core
::
rect
<
irr
::
s32
>
(
170
,
280
,
270
,
310
),
wServerList
,
BUTTON_SERVER_CANCEL
,
dataManager
.
GetSysString
(
1212
));
btnServerReturn
=
env
->
addButton
(
irr
::
core
::
rect
<
irr
::
s32
>
(
100
,
280
,
200
,
310
),
wServerList
,
BUTTON_SERVER_RETURN
,
dataManager
.
GetSysString
(
1210
));
//img
wCardImg
=
env
->
addStaticText
(
L""
,
irr
::
core
::
rect
<
irr
::
s32
>
(
1
,
1
,
1
+
CARD_IMG_WIDTH
+
20
,
1
+
CARD_IMG_HEIGHT
+
18
),
true
,
false
,
0
,
-
1
,
true
);
wCardImg
->
setBackgroundColor
(
0xc0c0c0c0
);
...
...
@@ -1258,7 +1257,7 @@ void Game::LoadExpansions(const wchar_t* expansions_path) {
if
(
!
std
::
wcscmp
(
name
,
L"lflist.conf"
))
{
deckManager
.
LoadLFListSingle
(
fpath
,
true
);
lflist_changed
=
true
;
}
else
if
(
!
std
::
wcscmp
(
name
,
L"server.conf"
))
{
}
else
if
(
!
std
::
wcscmp
(
name
,
L"server
s
.conf"
))
{
dataManager
.
LoadServerList
(
fpath
);
server_list_changed
=
true
;
}
else
{
...
...
@@ -1266,9 +1265,10 @@ void Game::LoadExpansions(const wchar_t* expansions_path) {
}
return
;
}
if
(
IsExtension
(
name
,
L".ini"
))
{
dataManager
.
LoadINI
(
fpath
);
server_list_changed
=
true
;
if
(
!
std
::
wcscmp
(
name
,
L"corres_srv.ini"
))
{
dataManager
.
LoadCorresSrvIni
(
fpath
);
server_list_changed
=
true
;
return
;
}
if
(
IsExtension
(
name
,
L".zip"
)
||
IsExtension
(
name
,
L".ypk"
))
{
#ifdef _WIN32
...
...
@@ -1308,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
s
.conf"
))
{
dataManager
.
LoadServerList
(
reader
);
server_list_changed
=
true
;
}
else
{
...
...
@@ -1316,8 +1316,8 @@ void Game::LoadExpansions(const wchar_t* expansions_path) {
}
continue
;
}
if
(
IsExtension
(
fname
,
L"
.ini"
))
{
dataManager
.
Load
INI
(
createReader
());
if
(
!
std
::
wcscmp
(
fname
,
L"corres_srv
.ini"
))
{
dataManager
.
Load
CorresSrvIni
(
createReader
());
server_list_changed
=
true
;
}
if
(
!
mywcsncasecmp
(
fname
,
L"pack/"
,
5
)
&&
IsExtension
(
fname
,
L".ydk"
))
{
...
...
gframe/game.h
View file @
a65a474b
...
...
@@ -698,8 +698,7 @@ public:
irr
::
gui
::
IGUIButton
*
btnServerList
;
irr
::
gui
::
IGUIWindow
*
wServerList
;
irr
::
gui
::
IGUIListBox
*
lstServerList
;
irr
::
gui
::
IGUIButton
*
btnServerSelected
;
irr
::
gui
::
IGUIButton
*
btnServerCancel
;
irr
::
gui
::
IGUIButton
*
btnServerReturn
;
};
extern
Game
*
mainGame
;
...
...
@@ -929,8 +928,7 @@ extern Game* mainGame;
#define BUTTON_SERVER_LIST 392
#define LISTBOX_SERVER_LIST 393
#define BUTTON_SERVER_SELECTED 394
#define BUTTON_SERVER_CANCEL 395
#define BUTTON_SERVER_RETURN 394
#define TEXTURE_DUEL 0
#define TEXTURE_DECK 1
...
...
gframe/menu_handler.cpp
View file @
a65a474b
...
...
@@ -90,8 +90,8 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break
;
}
case
BUTTON_JOIN_CANCEL
:
{
mainGame
->
HideElement
(
mainGame
->
wServerList
);
mainGame
->
HideElement
(
mainGame
->
wLanWindow
);
mainGame
->
HideElement
(
mainGame
->
wServerList
);
mainGame
->
ShowElement
(
mainGame
->
wMainMenu
);
if
(
exit_on_return
)
mainGame
->
device
->
closeDevice
();
...
...
@@ -105,6 +105,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame
->
btnHostConfirm
->
setEnabled
(
true
);
mainGame
->
btnHostCancel
->
setEnabled
(
true
);
mainGame
->
HideElement
(
mainGame
->
wLanWindow
);
mainGame
->
HideElement
(
mainGame
->
wServerList
);
mainGame
->
ShowElement
(
mainGame
->
wCreateHost
);
break
;
}
...
...
@@ -490,16 +491,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame
->
PopupElement
(
mainGame
->
wServerList
);
break
;
}
case
BUTTON_SERVER_SELECTED
:
{
int
sel
=
mainGame
->
lstServerList
->
getSelected
();
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
);
mainGame
->
HideElement
(
mainGame
->
wServerList
);
break
;
}
case
BUTTON_SERVER_CANCEL
:
{
case
BUTTON_SERVER_RETURN
:
{
mainGame
->
HideElement
(
mainGame
->
wServerList
);
break
;
}
...
...
@@ -614,6 +606,13 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame
->
cbBotDeck
->
setVisible
(
mainGame
->
botInfo
[
sel
].
select_deckfile
);
break
;
}
case
LISTBOX_SERVER_LIST
:
{
int
sel
=
mainGame
->
lstServerList
->
getSelected
();
auto
target
=
sel
==
-
1
?
L""
:
dataManager
.
_serverStrings
[
sel
].
second
.
c_str
();
wcscpy
(
mainGame
->
gameConf
.
lasthost
,
target
);
mainGame
->
ebJoinHost
->
setText
(
target
);
break
;
}
}
break
;
}
...
...
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