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
bf201703
Commit
bf201703
authored
Dec 31, 2016
by
mercury233
Committed by
DailyShana
Dec 31, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update resolve host address (#1902)
* update resolve host address * update * update
parent
9b9ddb8d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
41 deletions
+40
-41
gframe/game.cpp
gframe/game.cpp
+9
-9
gframe/game.h
gframe/game.h
+2
-2
gframe/menu_handler.cpp
gframe/menu_handler.cpp
+27
-29
strings.conf
strings.conf
+1
-0
system.conf
system.conf
+1
-1
No files found.
gframe/game.cpp
View file @
bf201703
...
...
@@ -100,12 +100,12 @@ bool Game::Initialize() {
lstHostList
->
setItemHeight
(
18
);
btnLanRefresh
=
env
->
addButton
(
rect
<
s32
>
(
240
,
325
,
340
,
350
),
wLanWindow
,
BUTTON_LAN_REFRESH
,
dataManager
.
GetSysString
(
1217
));
env
->
addStaticText
(
dataManager
.
GetSysString
(
1221
),
rect
<
s32
>
(
10
,
360
,
220
,
380
),
false
,
false
,
wLanWindow
);
ebJoin
IP
=
env
->
addEditBox
(
gameConf
.
lastip
,
rect
<
s32
>
(
110
,
355
,
2
50
,
380
),
true
,
wLanWindow
);
ebJoin
IP
->
setTextAlignment
(
irr
::
gui
::
EGUIA_CENTER
,
irr
::
gui
::
EGUIA_CENTER
);
ebJoinPort
=
env
->
addEditBox
(
gameConf
.
lastport
,
rect
<
s32
>
(
260
,
355
,
3
20
,
380
),
true
,
wLanWindow
);
ebJoin
Host
=
env
->
addEditBox
(
gameConf
.
lasthost
,
rect
<
s32
>
(
110
,
355
,
3
50
,
380
),
true
,
wLanWindow
);
ebJoin
Host
->
setTextAlignment
(
irr
::
gui
::
EGUIA_CENTER
,
irr
::
gui
::
EGUIA_CENTER
);
ebJoinPort
=
env
->
addEditBox
(
gameConf
.
lastport
,
rect
<
s32
>
(
360
,
355
,
4
20
,
380
),
true
,
wLanWindow
);
ebJoinPort
->
setTextAlignment
(
irr
::
gui
::
EGUIA_CENTER
,
irr
::
gui
::
EGUIA_CENTER
);
env
->
addStaticText
(
dataManager
.
GetSysString
(
1222
),
rect
<
s32
>
(
10
,
390
,
220
,
410
),
false
,
false
,
wLanWindow
);
ebJoinPass
=
env
->
addEditBox
(
gameConf
.
roompass
,
rect
<
s32
>
(
110
,
385
,
3
20
,
410
),
true
,
wLanWindow
);
ebJoinPass
=
env
->
addEditBox
(
gameConf
.
roompass
,
rect
<
s32
>
(
110
,
385
,
4
20
,
410
),
true
,
wLanWindow
);
ebJoinPass
->
setTextAlignment
(
irr
::
gui
::
EGUIA_CENTER
,
irr
::
gui
::
EGUIA_CENTER
);
btnJoinHost
=
env
->
addButton
(
rect
<
s32
>
(
460
,
355
,
570
,
380
),
wLanWindow
,
BUTTON_JOIN_HOST
,
dataManager
.
GetSysString
(
1223
));
btnJoinCancel
=
env
->
addButton
(
rect
<
s32
>
(
460
,
385
,
570
,
410
),
wLanWindow
,
BUTTON_JOIN_CANCEL
,
dataManager
.
GetSysString
(
1212
));
...
...
@@ -864,7 +864,7 @@ void Game::LoadConfig() {
gameConf
.
lastdeck
[
0
]
=
0
;
gameConf
.
numfont
[
0
]
=
0
;
gameConf
.
textfont
[
0
]
=
0
;
gameConf
.
last
ip
[
0
]
=
0
;
gameConf
.
last
host
[
0
]
=
0
;
gameConf
.
lastport
[
0
]
=
0
;
gameConf
.
roompass
[
0
]
=
0
;
//settings
...
...
@@ -902,9 +902,9 @@ void Game::LoadConfig() {
BufferIO
::
CopyWStr
(
wstr
,
gameConf
.
numfont
,
256
);
}
else
if
(
!
strcmp
(
strbuf
,
"serverport"
))
{
gameConf
.
serverport
=
atoi
(
valbuf
);
}
else
if
(
!
strcmp
(
strbuf
,
"last
ip
"
))
{
}
else
if
(
!
strcmp
(
strbuf
,
"last
host
"
))
{
BufferIO
::
DecodeUTF8
(
valbuf
,
wstr
);
BufferIO
::
CopyWStr
(
wstr
,
gameConf
.
last
ip
,
20
);
BufferIO
::
CopyWStr
(
wstr
,
gameConf
.
last
host
,
20
);
}
else
if
(
!
strcmp
(
strbuf
,
"lastport"
))
{
BufferIO
::
DecodeUTF8
(
valbuf
,
wstr
);
BufferIO
::
CopyWStr
(
wstr
,
gameConf
.
lastport
,
20
);
...
...
@@ -969,8 +969,8 @@ void Game::SaveConfig() {
BufferIO
::
EncodeUTF8
(
gameConf
.
numfont
,
linebuf
);
fprintf
(
fp
,
"numfont = %s
\n
"
,
linebuf
);
fprintf
(
fp
,
"serverport = %d
\n
"
,
gameConf
.
serverport
);
BufferIO
::
EncodeUTF8
(
gameConf
.
last
ip
,
linebuf
);
fprintf
(
fp
,
"last
ip
= %s
\n
"
,
linebuf
);
BufferIO
::
EncodeUTF8
(
gameConf
.
last
host
,
linebuf
);
fprintf
(
fp
,
"last
host
= %s
\n
"
,
linebuf
);
BufferIO
::
EncodeUTF8
(
gameConf
.
lastport
,
linebuf
);
fprintf
(
fp
,
"lastport = %s
\n
"
,
linebuf
);
//settings
...
...
gframe/game.h
View file @
bf201703
...
...
@@ -16,7 +16,7 @@ struct Config {
unsigned
short
antialias
;
unsigned
short
serverport
;
unsigned
char
textfontsize
;
wchar_t
last
ip
[
2
0
];
wchar_t
last
host
[
10
0
];
wchar_t
lastport
[
10
];
wchar_t
nickname
[
20
];
wchar_t
gamename
[
20
];
...
...
@@ -218,7 +218,7 @@ public:
irr
::
gui
::
IGUIEditBox
*
ebNickName
;
irr
::
gui
::
IGUIListBox
*
lstHostList
;
irr
::
gui
::
IGUIButton
*
btnLanRefresh
;
irr
::
gui
::
IGUIEditBox
*
ebJoin
IP
;
irr
::
gui
::
IGUIEditBox
*
ebJoin
Host
;
irr
::
gui
::
IGUIEditBox
*
ebJoinPort
;
irr
::
gui
::
IGUIEditBox
*
ebJoinPass
;
irr
::
gui
::
IGUIButton
*
btnJoinHost
;
...
...
gframe/menu_handler.cpp
View file @
bf201703
...
...
@@ -31,38 +31,36 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
break
;
}
case
BUTTON_JOIN_HOST
:
{
#if WINVER >= 0x0600
struct
addrinfo
hints
,
*
servinfo
;
memset
(
&
hints
,
0
,
sizeof
(
struct
addrinfo
));
hints
.
ai_family
=
AF_INET
;
/* Allow IPv4 or IPv6 */
hints
.
ai_socktype
=
SOCK_STREAM
;
/* Datagram socket */
hints
.
ai_flags
=
AI_PASSIVE
;
/* For wildcard IP address */
hints
.
ai_protocol
=
0
;
/* Any protocol */
hints
.
ai_canonname
=
NULL
;
hints
.
ai_addr
=
NULL
;
hints
.
ai_next
=
NULL
;
int
status
;
char
hostname
[
100
];
char
ip
[
20
];
const
wchar_t
*
pstr
=
mainGame
->
ebJoinIP
->
getText
();
BufferIO
::
CopyWStr
(
pstr
,
hostname
,
100
);
if
((
status
=
getaddrinfo
(
hostname
,
NULL
,
&
hints
,
&
servinfo
))
==
-
1
)
{
fprintf
(
stderr
,
"getaddrinfo error: %s
\n
"
,
gai_strerror
(
status
));
//error handling
BufferIO
::
CopyWStr
(
pstr
,
ip
,
16
);
}
else
inet_ntop
(
AF_INET
,
&
(((
struct
sockaddr_in
*
)
servinfo
->
ai_addr
)
->
sin_addr
),
ip
,
20
);
freeaddrinfo
(
servinfo
);
#else
char
hostname
[
100
];
char
ip
[
20
];
const
wchar_t
*
pstr
=
mainGame
->
ebJoinIP
->
getText
();
BufferIO
::
CopyWStr
(
pstr
,
hostname
,
100
);
const
wchar_t
*
pstr
=
mainGame
->
ebJoinHost
->
getText
();
BufferIO
::
CopyWStr
(
pstr
,
ip
,
16
);
#endif
unsigned
int
remote_addr
=
htonl
(
inet_addr
(
ip
));
if
(
remote_addr
==
-
1
)
{
char
hostname
[
100
];
char
port
[
6
];
BufferIO
::
CopyWStr
(
pstr
,
hostname
,
100
);
BufferIO
::
CopyWStr
(
mainGame
->
ebJoinPort
->
getText
(),
port
,
6
);
struct
evutil_addrinfo
hints
;
struct
evutil_addrinfo
*
answer
=
NULL
;
memset
(
&
hints
,
0
,
sizeof
(
hints
));
hints
.
ai_family
=
AF_INET
;
hints
.
ai_socktype
=
SOCK_STREAM
;
hints
.
ai_protocol
=
IPPROTO_TCP
;
hints
.
ai_flags
=
EVUTIL_AI_ADDRCONFIG
;
int
status
=
evutil_getaddrinfo
(
hostname
,
port
,
&
hints
,
&
answer
);
if
(
status
!=
0
)
{
mainGame
->
gMutex
.
Lock
();
mainGame
->
env
->
addMessageBox
(
L""
,
dataManager
.
GetSysString
(
1412
));
mainGame
->
gMutex
.
Unlock
();
break
;
}
else
{
sockaddr_in
*
sin
=
((
struct
sockaddr_in
*
)
answer
->
ai_addr
);
evutil_inet_ntop
(
AF_INET
,
&
(
sin
->
sin_addr
),
ip
,
20
);
remote_addr
=
htonl
(
inet_addr
(
ip
));
}
}
unsigned
int
remote_port
=
_wtoi
(
mainGame
->
ebJoinPort
->
getText
());
BufferIO
::
CopyWStr
(
pstr
,
mainGame
->
gameConf
.
last
ip
,
2
0
);
BufferIO
::
CopyWStr
(
pstr
,
mainGame
->
gameConf
.
last
host
,
10
0
);
BufferIO
::
CopyWStr
(
mainGame
->
ebJoinPort
->
getText
(),
mainGame
->
gameConf
.
lastport
,
20
);
if
(
DuelClient
::
StartClient
(
remote_addr
,
remote_port
,
false
))
{
mainGame
->
btnCreateHost
->
setEnabled
(
false
);
...
...
@@ -297,7 +295,7 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
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
->
ebJoin
IP
->
setText
(
buf
);
mainGame
->
ebJoin
Host
->
setText
(
buf
);
myswprintf
(
buf
,
L"%d"
,
port
);
mainGame
->
ebJoinPort
->
setText
(
buf
);
break
;
...
...
strings.conf
View file @
bf201703
...
...
@@ -363,6 +363,7 @@
!
system
1409
等待更换副卡组中...
!
system
1410
卡组数量与先前不符合。
!
system
1411
版本不匹配(%
X
.
0
%
X
.%
X
)。
!
system
1412
无法解析主机地址。
!
system
1500
决斗结束。
!
system
1501
录像结束。
!
system
1502
连接已断开。
...
...
system.conf
View file @
bf201703
...
...
@@ -9,7 +9,7 @@ lastdeck = new
textfont
=
c
:/
windows
/
fonts
/
simsun
.
ttc
14
numfont
=
c
:/
windows
/
fonts
/
arialbd
.
ttf
serverport
=
7911
last
ip
=
127
.
0
.
0
.
1
last
host
=
127
.
0
.
0
.
1
lastport
=
7911
autopos
=
1
randompos
=
0
...
...
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