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
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
ygopro
Commits
9a2ba2e0
Commit
9a2ba2e0
authored
Jun 13, 2025
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into server-develop
parents
14677ee2
4d045555
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
125 additions
and
88 deletions
+125
-88
gframe/deck_manager.cpp
gframe/deck_manager.cpp
+32
-36
gframe/deck_manager.h
gframe/deck_manager.h
+49
-1
gframe/duelclient.cpp
gframe/duelclient.cpp
+13
-13
gframe/duelclient.h
gframe/duelclient.h
+2
-2
gframe/game.cpp
gframe/game.cpp
+21
-11
gframe/game.h
gframe/game.h
+1
-2
gframe/gframe.cpp
gframe/gframe.cpp
+5
-10
gframe/menu_handler.cpp
gframe/menu_handler.cpp
+2
-13
No files found.
gframe/deck_manager.cpp
View file @
9a2ba2e0
...
@@ -11,53 +11,49 @@ char DeckManager::deckBuffer[0x10000]{};
...
@@ -11,53 +11,49 @@ char DeckManager::deckBuffer[0x10000]{};
#endif
#endif
DeckManager
deckManager
;
DeckManager
deckManager
;
void
DeckManager
::
LoadLFListSingle
(
const
char
*
path
)
{
void
DeckManager
::
LoadLFListSingle
(
const
char
*
path
,
bool
insert
)
{
auto
cur
=
_lfList
.
rend
();
FILE
*
fp
=
myfopen
(
path
,
"r"
);
FILE
*
fp
=
myfopen
(
path
,
"r"
);
char
linebuf
[
256
]{};
if
(
!
fp
)
return
;
wchar_t
strBuffer
[
256
]{};
_LoadLFListFromLineProvider
([
&
](
char
*
buf
,
size_t
sz
)
{
char
str1
[
16
]{};
return
std
::
fgets
(
buf
,
sz
,
fp
)
!=
nullptr
;
if
(
fp
)
{
},
insert
);
while
(
std
::
fgets
(
linebuf
,
sizeof
linebuf
,
fp
))
{
std
::
fclose
(
fp
);
if
(
linebuf
[
0
]
==
'#'
)
}
continue
;
void
DeckManager
::
LoadLFListSingle
(
const
wchar_t
*
path
,
bool
insert
)
{
if
(
linebuf
[
0
]
==
'!'
)
{
FILE
*
fp
=
mywfopen
(
path
,
"r"
);
auto
len
=
std
::
strcspn
(
linebuf
,
"
\r\n
"
);
if
(
!
fp
)
return
;
linebuf
[
len
]
=
0
;
_LoadLFListFromLineProvider
([
&
](
char
*
buf
,
size_t
sz
)
{
BufferIO
::
DecodeUTF8
(
&
linebuf
[
1
],
strBuffer
);
return
std
::
fgets
(
buf
,
sz
,
fp
)
!=
nullptr
;
LFList
newlist
;
},
insert
);
newlist
.
listName
=
strBuffer
;
std
::
fclose
(
fp
);
newlist
.
hash
=
0x7dfcee6a
;
}
_lfList
.
push_back
(
newlist
);
#if defined(SERVER_ZIP_SUPPORT) || !defined(YGOPRO_SERVER_MODE)
cur
=
_lfList
.
rbegin
();
void
DeckManager
::
LoadLFListSingle
(
irr
::
io
::
IReadFile
*
reader
,
bool
insert
)
{
continue
;
std
::
string
linebuf
;
char
ch
{};
_LoadLFListFromLineProvider
([
&
](
char
*
buf
,
size_t
sz
)
{
while
(
reader
->
read
(
&
ch
,
1
))
{
if
(
ch
==
'\0'
)
break
;
linebuf
.
push_back
(
ch
);
if
(
ch
==
'\n'
||
linebuf
.
size
()
>=
sz
-
1
)
{
std
::
strncpy
(
buf
,
linebuf
.
c_str
(),
sz
-
1
);
buf
[
sz
-
1
]
=
'\0'
;
linebuf
.
clear
();
return
true
;
}
}
if
(
cur
==
_lfList
.
rend
())
continue
;
unsigned
int
code
=
0
;
int
count
=
-
1
;
if
(
std
::
sscanf
(
linebuf
,
"%10s%*[ ]%1d"
,
str1
,
&
count
)
!=
2
)
continue
;
if
(
count
<
0
||
count
>
2
)
continue
;
code
=
std
::
strtoul
(
str1
,
nullptr
,
10
);
cur
->
content
[
code
]
=
count
;
cur
->
hash
=
cur
->
hash
^
((
code
<<
18
)
|
(
code
>>
14
))
^
((
code
<<
(
27
+
count
))
|
(
code
>>
(
5
-
count
)));
}
}
std
::
fclose
(
fp
);
return
false
;
}
},
insert
);
reader
->
drop
();
}
}
#endif
void
DeckManager
::
LoadLFList
()
{
void
DeckManager
::
LoadLFList
()
{
#ifdef SERVER_PRO2_SUPPORT
#ifdef SERVER_PRO2_SUPPORT
LoadLFListSingle
(
"config/lflist.conf"
);
LoadLFListSingle
(
"config/lflist.conf"
);
#endif
#endif
#ifdef SERVER_PRO3_SUPPORT
#ifdef SERVER_PRO3_SUPPORT
LoadLFListSingle
(
"Data/lflist.conf"
);
LoadLFListSingle
(
"Data/lflist.conf"
);
#ifndef _WIN32
LoadLFListSingle
(
"Expansions/lflist.conf"
);
#endif
#endif
#endif
LoadLFListSingle
(
"expansions/lflist.conf"
);
LoadLFListSingle
(
"specials/lflist.conf"
);
LoadLFListSingle
(
"specials/lflist.conf"
);
LoadLFListSingle
(
"lflist.conf"
);
LoadLFListSingle
(
"lflist.conf"
);
LFList
nolimit
;
LFList
nolimit
;
...
...
gframe/deck_manager.h
View file @
9a2ba2e0
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
#include <vector>
#include <vector>
#include <sstream>
#include <sstream>
#include "data_manager.h"
#include "data_manager.h"
#include "bufferio.h"
#ifndef YGOPRO_MAX_DECK
#ifndef YGOPRO_MAX_DECK
#define YGOPRO_MAX_DECK 60
#define YGOPRO_MAX_DECK 60
...
@@ -66,7 +67,11 @@ public:
...
@@ -66,7 +67,11 @@ public:
static
char
deckBuffer
[
0x10000
];
static
char
deckBuffer
[
0x10000
];
#endif
#endif
void
LoadLFListSingle
(
const
char
*
path
);
void
LoadLFListSingle
(
const
char
*
path
,
bool
insert
=
false
);
void
LoadLFListSingle
(
const
wchar_t
*
path
,
bool
insert
=
false
);
#if defined(SERVER_ZIP_SUPPORT) || !defined(YGOPRO_SERVER_MODE)
void
LoadLFListSingle
(
irr
::
io
::
IReadFile
*
reader
,
bool
insert
=
false
);
#endif
void
LoadLFList
();
void
LoadLFList
();
const
wchar_t
*
GetLFListName
(
unsigned
int
lfhash
);
const
wchar_t
*
GetLFListName
(
unsigned
int
lfhash
);
const
LFList
*
GetLFList
(
unsigned
int
lfhash
);
const
LFList
*
GetLFList
(
unsigned
int
lfhash
);
...
@@ -95,6 +100,49 @@ public:
...
@@ -95,6 +100,49 @@ public:
static
bool
DeleteCategory
(
const
wchar_t
*
name
);
static
bool
DeleteCategory
(
const
wchar_t
*
name
);
static
bool
SaveDeckArray
(
const
DeckArray
&
deck
,
const
wchar_t
*
name
);
static
bool
SaveDeckArray
(
const
DeckArray
&
deck
,
const
wchar_t
*
name
);
#endif //YGOPRO_SERVER_MODE
#endif //YGOPRO_SERVER_MODE
private:
template
<
typename
LineProvider
>
void
_LoadLFListFromLineProvider
(
LineProvider
getLine
,
bool
insert
=
false
)
{
std
::
vector
<
LFList
>
loadedLists
;
auto
cur
=
loadedLists
.
rend
();
// 注意:在临时 list 上操作
char
line
[
256
]{};
wchar_t
strBuffer
[
256
]{};
char
str1
[
16
]{};
while
(
getLine
(
line
,
sizeof
(
line
)))
{
if
(
line
[
0
]
==
'#'
)
continue
;
if
(
line
[
0
]
==
'!'
)
{
auto
len
=
std
::
strcspn
(
line
,
"
\r\n
"
);
line
[
len
]
=
0
;
BufferIO
::
DecodeUTF8
(
&
line
[
1
],
strBuffer
);
LFList
newlist
;
newlist
.
listName
=
strBuffer
;
newlist
.
hash
=
0x7dfcee6a
;
loadedLists
.
push_back
(
newlist
);
cur
=
loadedLists
.
rbegin
();
continue
;
}
if
(
cur
==
loadedLists
.
rend
())
continue
;
unsigned
int
code
=
0
;
int
count
=
-
1
;
if
(
std
::
sscanf
(
line
,
"%10s%*[ ]%1d"
,
str1
,
&
count
)
!=
2
)
continue
;
if
(
count
<
0
||
count
>
2
)
continue
;
code
=
std
::
strtoul
(
str1
,
nullptr
,
10
);
cur
->
content
[
code
]
=
count
;
cur
->
hash
=
cur
->
hash
^
((
code
<<
18
)
|
(
code
>>
14
))
^
((
code
<<
(
27
+
count
))
|
(
code
>>
(
5
-
count
)));
}
if
(
insert
)
{
_lfList
.
insert
(
_lfList
.
begin
(),
loadedLists
.
begin
(),
loadedLists
.
end
());
}
else
{
_lfList
.
insert
(
_lfList
.
end
(),
loadedLists
.
begin
(),
loadedLists
.
end
());
}
}
};
};
extern
DeckManager
deckManager
;
extern
DeckManager
deckManager
;
...
...
gframe/duelclient.cpp
View file @
9a2ba2e0
...
@@ -37,7 +37,7 @@ std::uniform_real_distribution<float> DuelClient::real_dist;
...
@@ -37,7 +37,7 @@ std::uniform_real_distribution<float> DuelClient::real_dist;
bool
DuelClient
::
is_refreshing
=
false
;
bool
DuelClient
::
is_refreshing
=
false
;
int
DuelClient
::
match_kill
=
0
;
int
DuelClient
::
match_kill
=
0
;
std
::
vector
<
HostPacket
>
DuelClient
::
hosts
;
std
::
vector
<
std
::
wstring
>
DuelClient
::
hosts
;
std
::
vector
<
std
::
wstring
>
DuelClient
::
hosts_srvpro
;
std
::
vector
<
std
::
wstring
>
DuelClient
::
hosts_srvpro
;
std
::
set
<
std
::
pair
<
unsigned
int
,
unsigned
short
>>
DuelClient
::
remotes
;
std
::
set
<
std
::
pair
<
unsigned
int
,
unsigned
short
>>
DuelClient
::
remotes
;
event
*
DuelClient
::
resp_event
=
0
;
event
*
DuelClient
::
resp_event
=
0
;
...
@@ -4395,7 +4395,14 @@ void DuelClient::BroadcastReply(evutil_socket_t fd, short events, void * arg) {
...
@@ -4395,7 +4395,14 @@ void DuelClient::BroadcastReply(evutil_socket_t fd, short events, void * arg) {
mainGame
->
gMutex
.
lock
();
mainGame
->
gMutex
.
lock
();
remotes
.
insert
(
remote
);
remotes
.
insert
(
remote
);
pHP
->
ipaddr
=
ipaddr
;
pHP
->
ipaddr
=
ipaddr
;
hosts
.
push_back
(
*
pHP
);
wchar_t
host_fulladdr
[
100
];
myswprintf
(
host_fulladdr
,
L"%d.%d.%d.%d:%d"
,
ipaddr
&
0xff
,
(
ipaddr
>>
8
)
&
0xff
,
(
ipaddr
>>
16
)
&
0xff
,
(
ipaddr
>>
24
)
&
0xff
,
pHP
->
port
);
hosts
.
push_back
(
std
::
wstring
(
host_fulladdr
));
std
::
wstring
hoststr
;
std
::
wstring
hoststr
;
hoststr
.
append
(
L"["
);
hoststr
.
append
(
L"["
);
hoststr
.
append
(
deckManager
.
GetLFListName
(
pHP
->
host
.
lflist
));
hoststr
.
append
(
deckManager
.
GetLFListName
(
pHP
->
host
.
lflist
));
...
@@ -4470,7 +4477,9 @@ bool DuelClient::LookupSRV(char *hostname, HostResult* result) {
...
@@ -4470,7 +4477,9 @@ bool DuelClient::LookupSRV(char *hostname, HostResult* result) {
auto
record
=
RetrivedSRVRecord
(
nsMsg
,
i
);
auto
record
=
RetrivedSRVRecord
(
nsMsg
,
i
);
if
(
!
record
.
valid
||
record
.
priority
>
minPriority
)
if
(
!
record
.
valid
||
record
.
priority
>
minPriority
)
continue
;
continue
;
for
(
int
j
=
0
;
j
<
record
.
weight
;
++
j
)
{
if
(
!
record
.
weight
)
record
.
weight
=
1
;
for
(
int
j
=
0
;
j
<
record
.
weight
;
++
j
)
{
if
(
record
.
priority
<
minPriority
)
{
if
(
record
.
priority
<
minPriority
)
{
records
.
clear
();
records
.
clear
();
minPriority
=
record
.
priority
;
minPriority
=
record
.
priority
;
...
@@ -4503,17 +4512,8 @@ bool DuelClient::CheckHostnameSplitter(char* hostname, HostResult* result) {
...
@@ -4503,17 +4512,8 @@ bool DuelClient::CheckHostnameSplitter(char* hostname, HostResult* result) {
return
true
;
return
true
;
}
}
HostResult
DuelClient
::
ParseHost
(
char
*
hostname
,
unsigned
short
port
)
{
HostResult
DuelClient
::
ParseHost
(
char
*
hostname
)
{
HostResult
result
;
HostResult
result
;
// if port found, use port directly
if
(
port
)
{
// if hostname contains splitter, use port after splitter in priority
if
(
!
CheckHostnameSplitter
(
hostname
,
&
result
))
{
result
.
host
=
LookupHost
(
hostname
);
result
.
port
=
port
;
}
return
result
;
}
// if hostname is an IP, use it directly and use default port
// if hostname is an IP, use it directly and use default port
unsigned
int
tryAddress
=
htonl
(
inet_addr
(
hostname
));
unsigned
int
tryAddress
=
htonl
(
inet_addr
(
hostname
));
...
...
gframe/duelclient.h
View file @
9a2ba2e0
...
@@ -93,7 +93,7 @@ public:
...
@@ -93,7 +93,7 @@ public:
static
unsigned
int
LookupHost
(
char
*
host
);
static
unsigned
int
LookupHost
(
char
*
host
);
static
bool
LookupSRV
(
char
*
hostname
,
HostResult
*
result
);
static
bool
LookupSRV
(
char
*
hostname
,
HostResult
*
result
);
static
bool
CheckHostnameSplitter
(
char
*
hostname
,
HostResult
*
result
);
static
bool
CheckHostnameSplitter
(
char
*
hostname
,
HostResult
*
result
);
static
HostResult
ParseHost
(
char
*
hostname
,
unsigned
short
port
);
static
HostResult
ParseHost
(
char
*
hostname
);
static
void
SendPacketToServer
(
unsigned
char
proto
)
{
static
void
SendPacketToServer
(
unsigned
char
proto
)
{
auto
p
=
duel_client_write
;
auto
p
=
duel_client_write
;
buffer_write
<
uint16_t
>
(
p
,
1
);
buffer_write
<
uint16_t
>
(
p
,
1
);
...
@@ -128,7 +128,7 @@ public:
...
@@ -128,7 +128,7 @@ public:
bufferevent_write
(
client_bev
,
duel_client_write
,
len
+
3
);
bufferevent_write
(
client_bev
,
duel_client_write
,
len
+
3
);
}
}
static
std
::
vector
<
HostPacket
>
hosts
;
static
std
::
vector
<
std
::
wstring
>
hosts
;
static
std
::
vector
<
std
::
wstring
>
hosts_srvpro
;
static
std
::
vector
<
std
::
wstring
>
hosts_srvpro
;
static
bool
is_srvpro
;
static
bool
is_srvpro
;
static
void
BeginRefreshHost
();
static
void
BeginRefreshHost
();
...
...
gframe/game.cpp
View file @
9a2ba2e0
...
@@ -293,12 +293,9 @@ bool Game::Initialize() {
...
@@ -293,12 +293,9 @@ bool Game::Initialize() {
lstHostList
->
setItemHeight
(
18
);
lstHostList
->
setItemHeight
(
18
);
btnLanRefresh
=
env
->
addButton
(
irr
::
core
::
rect
<
irr
::
s32
>
(
240
,
325
,
340
,
350
),
wLanWindow
,
BUTTON_LAN_REFRESH
,
dataManager
.
GetSysString
(
1217
));
btnLanRefresh
=
env
->
addButton
(
irr
::
core
::
rect
<
irr
::
s32
>
(
240
,
325
,
340
,
350
),
wLanWindow
,
BUTTON_LAN_REFRESH
,
dataManager
.
GetSysString
(
1217
));
env
->
addStaticText
(
dataManager
.
GetSysString
(
1221
),
irr
::
core
::
rect
<
irr
::
s32
>
(
10
,
360
,
220
,
380
),
false
,
false
,
wLanWindow
);
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
,
35
0
,
380
),
true
,
wLanWindow
);
ebJoinHost
=
env
->
addEditBox
(
gameConf
.
lasthost
,
irr
::
core
::
rect
<
irr
::
s32
>
(
110
,
355
,
42
0
,
380
),
true
,
wLanWindow
);
ebJoinHost
->
setTextAlignment
(
irr
::
gui
::
EGUIA_CENTER
,
irr
::
gui
::
EGUIA_CENTER
);
ebJoinHost
->
setTextAlignment
(
irr
::
gui
::
EGUIA_CENTER
,
irr
::
gui
::
EGUIA_CENTER
);
editbox_list
.
push_back
(
ebJoinHost
);
editbox_list
.
push_back
(
ebJoinHost
);
ebJoinPort
=
env
->
addEditBox
(
gameConf
.
lastport
,
irr
::
core
::
rect
<
irr
::
s32
>
(
360
,
355
,
420
,
380
),
true
,
wLanWindow
);
ebJoinPort
->
setTextAlignment
(
irr
::
gui
::
EGUIA_CENTER
,
irr
::
gui
::
EGUIA_CENTER
);
editbox_list
.
push_back
(
ebJoinPort
);
env
->
addStaticText
(
dataManager
.
GetSysString
(
1222
),
irr
::
core
::
rect
<
irr
::
s32
>
(
10
,
390
,
220
,
410
),
false
,
false
,
wLanWindow
);
env
->
addStaticText
(
dataManager
.
GetSysString
(
1222
),
irr
::
core
::
rect
<
irr
::
s32
>
(
10
,
390
,
220
,
410
),
false
,
false
,
wLanWindow
);
ebJoinPass
=
env
->
addEditBox
(
gameConf
.
roompass
,
irr
::
core
::
rect
<
irr
::
s32
>
(
110
,
385
,
420
,
410
),
true
,
wLanWindow
);
ebJoinPass
=
env
->
addEditBox
(
gameConf
.
roompass
,
irr
::
core
::
rect
<
irr
::
s32
>
(
110
,
385
,
420
,
410
),
true
,
wLanWindow
);
ebJoinPass
->
setTextAlignment
(
irr
::
gui
::
EGUIA_CENTER
,
irr
::
gui
::
EGUIA_CENTER
);
ebJoinPass
->
setTextAlignment
(
irr
::
gui
::
EGUIA_CENTER
,
irr
::
gui
::
EGUIA_CENTER
);
...
@@ -1329,13 +1326,17 @@ void Game::LoadExpansions() {
...
@@ -1329,13 +1326,17 @@ void Game::LoadExpansions() {
return
;
return
;
}
}
#ifndef YGOPRO_SERVER_MODE
#ifndef YGOPRO_SERVER_MODE
if
(
IsExtension
(
name
,
L".conf"
))
{
if
(
IsExtension
(
name
,
L".conf"
)
&&
std
::
wcscmp
(
name
,
L"lflist.conf"
)
)
{
char
upath
[
1024
];
char
upath
[
1024
];
BufferIO
::
EncodeUTF8
(
fpath
,
upath
);
BufferIO
::
EncodeUTF8
(
fpath
,
upath
);
dataManager
.
LoadStrings
(
upath
);
dataManager
.
LoadStrings
(
upath
);
return
;
return
;
}
}
#endif // YGOPRO_SERVER_MODE
#endif // YGOPRO_SERVER_MODE
if
(
!
std
::
wcscmp
(
name
,
L"lflist.conf"
))
{
deckManager
.
LoadLFListSingle
(
fpath
,
true
);
return
;
}
#if defined(SERVER_ZIP_SUPPORT) || !defined(YGOPRO_SERVER_MODE)
#if defined(SERVER_ZIP_SUPPORT) || !defined(YGOPRO_SERVER_MODE)
if
(
IsExtension
(
name
,
L".zip"
)
||
IsExtension
(
name
,
L".ypk"
))
{
if
(
IsExtension
(
name
,
L".zip"
)
||
IsExtension
(
name
,
L".ypk"
))
{
#ifdef _WIN32
#ifdef _WIN32
...
@@ -1364,16 +1365,23 @@ void Game::LoadExpansions() {
...
@@ -1364,16 +1365,23 @@ void Game::LoadExpansions() {
dataManager
.
LoadDB
(
fname
);
dataManager
.
LoadDB
(
fname
);
continue
;
continue
;
}
}
#ifndef YGOPRO_SERVER_MODE
if
(
IsExtension
(
fname
,
L".conf"
))
{
if
(
IsExtension
(
fname
,
L".conf"
))
{
#ifdef _WIN32
#ifdef _WIN32
auto
reader
=
DataManager
::
FileSystem
->
createAndOpenFile
(
fname
);
auto
reader
=
DataManager
::
FileSystem
->
createAndOpenFile
(
fname
);
#else
#else
auto
reader
=
DataManager
::
FileSystem
->
createAndOpenFile
(
uname
);
auto
reader
=
DataManager
::
FileSystem
->
createAndOpenFile
(
uname
);
#endif
#endif
dataManager
.
LoadStrings
(
reader
);
if
(
!
std
::
wcscmp
(
fname
,
L"lflist.conf"
))
deckManager
.
LoadLFListSingle
(
reader
,
true
);
else
#ifdef YGOPRO_SERVER_MODE
{}
#else
dataManager
.
LoadStrings
(
reader
);
#endif
continue
;
continue
;
}
}
#ifndef YGOPRO_SERVER_MODE
if
(
!
mywcsncasecmp
(
fname
,
L"pack/"
,
5
)
&&
IsExtension
(
fname
,
L".ydk"
))
{
if
(
!
mywcsncasecmp
(
fname
,
L"pack/"
,
5
)
&&
IsExtension
(
fname
,
L".ydk"
))
{
deckBuilder
.
expansionPacks
.
push_back
(
fname
);
deckBuilder
.
expansionPacks
.
push_back
(
fname
);
continue
;
continue
;
...
@@ -1565,7 +1573,11 @@ bool Game::LoadConfigFromFile(const char* file) {
...
@@ -1565,7 +1573,11 @@ bool Game::LoadConfigFromFile(const char* file) {
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"lasthost"
))
{
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"lasthost"
))
{
BufferIO
::
DecodeUTF8
(
valbuf
,
gameConf
.
lasthost
);
BufferIO
::
DecodeUTF8
(
valbuf
,
gameConf
.
lasthost
);
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"lastport"
))
{
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"lastport"
))
{
BufferIO
::
DecodeUTF8
(
valbuf
,
gameConf
.
lastport
);
// for migration
auto
old_lastport
=
std
::
strtol
(
valbuf
,
nullptr
,
10
);
wchar_t
old_host
[
100
];
memcpy
(
old_host
,
gameConf
.
lasthost
,
sizeof
(
wchar_t
)
*
100
);
myswprintf
(
gameConf
.
lasthost
,
L"%ls:%d"
,
old_host
,
old_lastport
);
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"automonsterpos"
))
{
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"automonsterpos"
))
{
gameConf
.
chkMAutoPos
=
std
::
strtol
(
valbuf
,
nullptr
,
10
);
gameConf
.
chkMAutoPos
=
std
::
strtol
(
valbuf
,
nullptr
,
10
);
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"autospellpos"
))
{
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"autospellpos"
))
{
...
@@ -1706,7 +1718,6 @@ void Game::LoadConfig() {
...
@@ -1706,7 +1718,6 @@ void Game::LoadConfig() {
gameConf
.
numfont
[
0
]
=
0
;
gameConf
.
numfont
[
0
]
=
0
;
gameConf
.
textfont
[
0
]
=
0
;
gameConf
.
textfont
[
0
]
=
0
;
gameConf
.
lasthost
[
0
]
=
0
;
gameConf
.
lasthost
[
0
]
=
0
;
gameConf
.
lastport
[
0
]
=
0
;
gameConf
.
roompass
[
0
]
=
0
;
gameConf
.
roompass
[
0
]
=
0
;
//settings
//settings
gameConf
.
chkMAutoPos
=
0
;
gameConf
.
chkMAutoPos
=
0
;
...
@@ -1842,8 +1853,6 @@ void Game::SaveConfig() {
...
@@ -1842,8 +1853,6 @@ void Game::SaveConfig() {
std
::
fprintf
(
fp
,
"serverport = %d
\n
"
,
gameConf
.
serverport
);
std
::
fprintf
(
fp
,
"serverport = %d
\n
"
,
gameConf
.
serverport
);
BufferIO
::
EncodeUTF8
(
gameConf
.
lasthost
,
linebuf
);
BufferIO
::
EncodeUTF8
(
gameConf
.
lasthost
,
linebuf
);
std
::
fprintf
(
fp
,
"lasthost = %s
\n
"
,
linebuf
);
std
::
fprintf
(
fp
,
"lasthost = %s
\n
"
,
linebuf
);
BufferIO
::
EncodeUTF8
(
gameConf
.
lastport
,
linebuf
);
std
::
fprintf
(
fp
,
"lastport = %s
\n
"
,
linebuf
);
BufferIO
::
EncodeUTF8
(
gameConf
.
roompass
,
linebuf
);
BufferIO
::
EncodeUTF8
(
gameConf
.
roompass
,
linebuf
);
std
::
fprintf
(
fp
,
"roompass = %s
\n
"
,
linebuf
);
std
::
fprintf
(
fp
,
"roompass = %s
\n
"
,
linebuf
);
//settings
//settings
...
@@ -2229,6 +2238,7 @@ void Game::CloseDuelWindow() {
...
@@ -2229,6 +2238,7 @@ void Game::CloseDuelWindow() {
logParam
.
clear
();
logParam
.
clear
();
lstHostList
->
clear
();
lstHostList
->
clear
();
DuelClient
::
hosts
.
clear
();
DuelClient
::
hosts
.
clear
();
DuelClient
::
hosts_srvpro
.
clear
();
ClearTextures
();
ClearTextures
();
ResizeChatInputWindow
();
ResizeChatInputWindow
();
closeDoneSignal
.
Set
();
closeDoneSignal
.
Set
();
...
...
gframe/game.h
View file @
9a2ba2e0
...
@@ -63,7 +63,7 @@ struct Config {
...
@@ -63,7 +63,7 @@ struct Config {
unsigned
short
serverport
{
7911
};
unsigned
short
serverport
{
7911
};
unsigned
char
textfontsize
{
14
};
unsigned
char
textfontsize
{
14
};
wchar_t
lasthost
[
100
]{};
wchar_t
lasthost
[
100
]{};
wchar_t
lastport
[
10
]{};
//
wchar_t lastport[10]{};
wchar_t
nickname
[
20
]{};
wchar_t
nickname
[
20
]{};
wchar_t
gamename
[
20
]{};
wchar_t
gamename
[
20
]{};
wchar_t
roompass
[
20
]{};
wchar_t
roompass
[
20
]{};
...
@@ -426,7 +426,6 @@ public:
...
@@ -426,7 +426,6 @@ public:
irr
::
gui
::
IGUIListBox
*
lstHostList
;
irr
::
gui
::
IGUIListBox
*
lstHostList
;
irr
::
gui
::
IGUIButton
*
btnLanRefresh
;
irr
::
gui
::
IGUIButton
*
btnLanRefresh
;
irr
::
gui
::
IGUIEditBox
*
ebJoinHost
;
irr
::
gui
::
IGUIEditBox
*
ebJoinHost
;
irr
::
gui
::
IGUIEditBox
*
ebJoinPort
;
irr
::
gui
::
IGUIEditBox
*
ebJoinPass
;
irr
::
gui
::
IGUIEditBox
*
ebJoinPass
;
irr
::
gui
::
IGUIButton
*
btnJoinHost
;
irr
::
gui
::
IGUIButton
*
btnJoinHost
;
irr
::
gui
::
IGUIButton
*
btnJoinCancel
;
irr
::
gui
::
IGUIButton
*
btnJoinCancel
;
...
...
gframe/gframe.cpp
View file @
9a2ba2e0
...
@@ -157,7 +157,6 @@ int main(int argc, char* argv[]) {
...
@@ -157,7 +157,6 @@ int main(int argc, char* argv[]) {
bool
keep_on_return
=
false
;
bool
keep_on_return
=
false
;
bool
deckCategorySpecified
=
false
;
bool
deckCategorySpecified
=
false
;
bool
portSpecified
=
false
;
for
(
int
i
=
1
;
i
<
wargc
;
++
i
)
{
for
(
int
i
=
1
;
i
<
wargc
;
++
i
)
{
if
(
wargc
==
2
&&
std
::
wcslen
(
wargv
[
1
])
>=
4
)
{
if
(
wargc
==
2
&&
std
::
wcslen
(
wargv
[
1
])
>=
4
)
{
wchar_t
*
pstrext
=
wargv
[
1
]
+
std
::
wcslen
(
wargv
[
1
])
-
4
;
wchar_t
*
pstrext
=
wargv
[
1
]
+
std
::
wcslen
(
wargv
[
1
])
-
4
;
...
@@ -196,21 +195,17 @@ int main(int argc, char* argv[]) {
...
@@ -196,21 +195,17 @@ int main(int argc, char* argv[]) {
++
i
;
++
i
;
if
(
i
<
wargc
)
{
if
(
i
<
wargc
)
{
ygo
::
mainGame
->
ebJoinHost
->
setText
(
wargv
[
i
]);
ygo
::
mainGame
->
ebJoinHost
->
setText
(
wargv
[
i
]);
if
(
!
portSpecified
)
ygo
::
mainGame
->
ebJoinPort
->
setText
(
L""
);
}
}
continue
;
continue
;
}
else
if
(
!
std
::
wcscmp
(
wargv
[
i
],
L"-p"
))
{
// host Port
}
else
if
(
!
std
::
wcscmp
(
wargv
[
i
],
L"-p"
))
{
// host Port
++
i
;
++
i
;
if
(
i
<
wargc
)
{
if
(
i
<
wargc
)
{
portSpecified
=
true
;
auto
port
=
_wtoi
(
wargv
[
i
]);
auto
port
=
_wtoi
(
wargv
[
i
]);
if
(
port
)
{
auto
hostText
=
ygo
::
mainGame
->
ebJoinHost
->
getText
();
wchar_t
portStr
[
6
];
if
(
port
&&
hostText
)
{
myswprintf
(
portStr
,
L"%d"
,
port
);
wchar_t
newHostStr
[
100
];
ygo
::
mainGame
->
ebJoinPort
->
setText
(
portStr
);
myswprintf
(
newHostStr
,
L"%ls:%d"
,
hostText
,
port
);
}
else
{
ygo
::
mainGame
->
ebJoinHost
->
setText
(
newHostStr
);
ygo
::
mainGame
->
ebJoinPort
->
setText
(
L""
);
}
}
}
}
continue
;
continue
;
...
...
gframe/menu_handler.cpp
View file @
9a2ba2e0
...
@@ -64,15 +64,11 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
...
@@ -64,15 +64,11 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
case
BUTTON_JOIN_HOST
:
{
case
BUTTON_JOIN_HOST
:
{
bot_mode
=
false
;
bot_mode
=
false
;
mainGame
->
TrimText
(
mainGame
->
ebJoinHost
);
mainGame
->
TrimText
(
mainGame
->
ebJoinHost
);
mainGame
->
TrimText
(
mainGame
->
ebJoinPort
);
char
hostname_tag
[
100
];
char
hostname_tag
[
100
];
wchar_t
pstr
[
100
];
wchar_t
pstr
[
100
];
wchar_t
portstr
[
10
];
BufferIO
::
CopyWideString
(
mainGame
->
ebJoinHost
->
getText
(),
pstr
);
BufferIO
::
CopyWideString
(
mainGame
->
ebJoinHost
->
getText
(),
pstr
);
BufferIO
::
CopyWideString
(
mainGame
->
ebJoinPort
->
getText
(),
portstr
);
BufferIO
::
EncodeUTF8
(
pstr
,
hostname_tag
);
BufferIO
::
EncodeUTF8
(
pstr
,
hostname_tag
);
auto
port
=
std
::
wcstol
(
portstr
,
nullptr
,
10
);
HostResult
remote
=
DuelClient
::
ParseHost
(
hostname_tag
);
HostResult
remote
=
DuelClient
::
ParseHost
(
hostname_tag
,
port
);
if
(
!
remote
.
isValid
())
{
if
(
!
remote
.
isValid
())
{
mainGame
->
gMutex
.
lock
();
mainGame
->
gMutex
.
lock
();
soundManager
.
PlaySoundEffect
(
SOUND_INFO
);
soundManager
.
PlaySoundEffect
(
SOUND_INFO
);
...
@@ -85,7 +81,6 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
...
@@ -85,7 +81,6 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break
;
break
;
}
}
BufferIO
::
CopyWideString
(
pstr
,
mainGame
->
gameConf
.
lasthost
);
BufferIO
::
CopyWideString
(
pstr
,
mainGame
->
gameConf
.
lasthost
);
BufferIO
::
CopyWideString
(
portstr
,
mainGame
->
gameConf
.
lastport
);
BufferIO
::
CopyWideString
(
mainGame
->
ebJoinPass
->
getText
(),
mainGame
->
gameConf
.
roompass
);
BufferIO
::
CopyWideString
(
mainGame
->
ebJoinPass
->
getText
(),
mainGame
->
gameConf
.
roompass
);
if
(
DuelClient
::
StartClient
(
remote
.
host
,
remote
.
port
,
false
))
{
if
(
DuelClient
::
StartClient
(
remote
.
host
,
remote
.
port
,
false
))
{
mainGame
->
btnCreateHost
->
setEnabled
(
false
);
mainGame
->
btnCreateHost
->
setEnabled
(
false
);
...
@@ -502,13 +497,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
...
@@ -502,13 +497,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
mainGame
->
ebJoinPass
->
setText
(
DuelClient
::
hosts_srvpro
[
sel
].
c_str
());
mainGame
->
ebJoinPass
->
setText
(
DuelClient
::
hosts_srvpro
[
sel
].
c_str
());
break
;
break
;
}
}
int
addr
=
DuelClient
::
hosts
[
sel
].
ipaddr
;
mainGame
->
ebJoinHost
->
setText
(
DuelClient
::
hosts
[
sel
].
c_str
());
int
port
=
DuelClient
::
hosts
[
sel
].
port
;
wchar_t
buf
[
20
];
myswprintf
(
buf
,
L"%d.%d.%d.%d"
,
addr
&
0xff
,
(
addr
>>
8
)
&
0xff
,
(
addr
>>
16
)
&
0xff
,
(
addr
>>
24
)
&
0xff
);
mainGame
->
ebJoinHost
->
setText
(
buf
);
myswprintf
(
buf
,
L"%d"
,
port
);
mainGame
->
ebJoinPort
->
setText
(
buf
);
break
;
break
;
}
}
case
LISTBOX_REPLAY_LIST
:
{
case
LISTBOX_REPLAY_LIST
:
{
...
...
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