Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-2pick
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-2pick
Commits
e060c5f2
Commit
e060c5f2
authored
Oct 03, 2017
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge FrreverX
parent
cb415ab0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
11 deletions
+50
-11
gframe/duelclient.cpp
gframe/duelclient.cpp
+39
-11
gframe/duelclient.h
gframe/duelclient.h
+6
-0
gframe/game.cpp
gframe/game.cpp
+5
-0
No files found.
gframe/duelclient.cpp
View file @
e060c5f2
...
...
@@ -31,6 +31,11 @@ int DuelClient::match_kill = 0;
std
::
vector
<
HostPacket
>
DuelClient
::
hosts
;
std
::
set
<
unsigned
int
>
DuelClient
::
remotes
;
event
*
DuelClient
::
resp_event
=
0
;
//modded
unsigned
int
DuelClient
::
temp_ip
=
0
;
unsigned
short
DuelClient
::
temp_port
=
0
;
unsigned
short
DuelClient
::
temp_ver
=
0
;
bool
DuelClient
::
try_needed
=
false
;
bool
DuelClient
::
StartClient
(
unsigned
int
ip
,
unsigned
short
port
,
bool
create_game
)
{
if
(
connect_state
)
...
...
@@ -45,6 +50,10 @@ bool DuelClient::StartClient(unsigned int ip, unsigned short port, bool create_g
sin
.
sin_port
=
htons
(
port
);
client_bev
=
bufferevent_socket_new
(
client_base
,
-
1
,
BEV_OPT_CLOSE_ON_FREE
);
bufferevent_setcb
(
client_bev
,
ClientRead
,
NULL
,
ClientEvent
,
(
void
*
)
create_game
);
//modded
temp_ip
=
ip
;
temp_port
=
port
;
if
(
bufferevent_socket_connect
(
client_bev
,
(
sockaddr
*
)
&
sin
,
sizeof
(
sin
))
<
0
)
{
bufferevent_free
(
client_bev
);
event_base_free
(
client_base
);
...
...
@@ -66,6 +75,8 @@ void DuelClient::ConnectTimeout(evutil_socket_t fd, short events, void* arg) {
if
(
connect_state
==
0x7
)
return
;
if
(
!
is_closing
)
{
//modded
temp_ver
=
0
;
mainGame
->
btnCreateHost
->
setEnabled
(
true
);
mainGame
->
btnJoinHost
->
setEnabled
(
true
);
mainGame
->
btnJoinCancel
->
setEnabled
(
true
);
...
...
@@ -125,6 +136,9 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
SendPacketToServer
(
CTOS_CREATE_GAME
,
cscg
);
}
else
{
CTOS_JoinGame
csjg
;
if
(
temp_ver
)
csjg
.
version
=
temp_ver
;
else
csjg
.
version
=
PRO_VERSION
;
csjg
.
gameid
=
0
;
BufferIO
::
CopyWStr
(
mainGame
->
ebJoinPass
->
getText
(),
csjg
.
pass
,
20
);
...
...
@@ -136,6 +150,8 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
bufferevent_disable
(
bev
,
EV_READ
);
if
(
!
is_closing
)
{
if
(
connect_state
==
0x1
)
{
//modded
temp_ver
=
0
;
mainGame
->
btnCreateHost
->
setEnabled
(
true
);
mainGame
->
btnJoinHost
->
setEnabled
(
true
);
mainGame
->
btnJoinCancel
->
setEnabled
(
true
);
...
...
@@ -201,6 +217,8 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
STOC_ErrorMsg
*
pkt
=
(
STOC_ErrorMsg
*
)
pdata
;
switch
(
pkt
->
msg
)
{
case
ERRMSG_JOINERROR
:
{
//modded
temp_ver
=
0
;
mainGame
->
btnCreateHost
->
setEnabled
(
true
);
mainGame
->
btnJoinHost
->
setEnabled
(
true
);
mainGame
->
btnJoinCancel
->
setEnabled
(
true
);
...
...
@@ -234,7 +252,10 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame
->
gMutex
.
Unlock
();
break
;
}
//modded
case
ERRMSG_VERERROR
:
{
if
(
temp_ver
)
{
temp_ver
=
0
;
mainGame
->
btnCreateHost
->
setEnabled
(
true
);
mainGame
->
btnJoinHost
->
setEnabled
(
true
);
mainGame
->
btnJoinCancel
->
setEnabled
(
true
);
...
...
@@ -244,6 +265,11 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame
->
env
->
addMessageBox
(
L""
,
msgbuf
);
mainGame
->
gMutex
.
Unlock
();
event_base_loopbreak
(
client_base
);
}
else
{
event_base_loopbreak
(
client_base
);
temp_ver
=
pkt
->
code
;
try_needed
=
true
;
}
break
;
}
}
...
...
@@ -314,6 +340,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
break
;
}
case
STOC_JOIN_GAME
:
{
temp_ver
=
0
;
STOC_JoinGame
*
pkt
=
(
STOC_JoinGame
*
)
pdata
;
std
::
wstring
str
;
wchar_t
msgbuf
[
256
];
...
...
@@ -3584,7 +3611,8 @@ void DuelClient::BroadcastReply(evutil_socket_t fd, short events, void * arg) {
/*int ret = */
recvfrom
(
fd
,
buf
,
256
,
0
,
(
sockaddr
*
)
&
bc_addr
,
&
sz
);
unsigned
int
ipaddr
=
bc_addr
.
sin_addr
.
s_addr
;
HostPacket
*
pHP
=
(
HostPacket
*
)
buf
;
if
(
!
is_closing
&&
pHP
->
identifier
==
NETWORK_SERVER_ID
&&
pHP
->
version
==
PRO_VERSION
&&
remotes
.
find
(
ipaddr
)
==
remotes
.
end
()
)
{
//modded
if
(
!
is_closing
&&
pHP
->
identifier
==
NETWORK_SERVER_ID
&&
remotes
.
find
(
ipaddr
)
==
remotes
.
end
()
)
{
mainGame
->
gMutex
.
Lock
();
remotes
.
insert
(
ipaddr
);
pHP
->
ipaddr
=
ipaddr
;
...
...
gframe/duelclient.h
View file @
e060c5f2
...
...
@@ -33,6 +33,12 @@ private:
static
wchar_t
event_string
[
256
];
static
mtrandom
rnd
;
public:
//modded
static
unsigned
int
temp_ip
;
static
unsigned
short
temp_port
;
static
unsigned
short
temp_ver
;
static
bool
try_needed
;
static
bool
StartClient
(
unsigned
int
ip
,
unsigned
short
port
,
bool
create_game
=
true
);
static
void
ConnectTimeout
(
evutil_socket_t
fd
,
short
events
,
void
*
arg
);
static
void
StopClient
(
bool
is_exiting
=
false
);
...
...
gframe/game.cpp
View file @
e060c5f2
...
...
@@ -735,6 +735,11 @@ void Game::MainLoop() {
if
(
dInfo
.
time_left
[
dInfo
.
time_player
])
dInfo
.
time_left
[
dInfo
.
time_player
]
--
;
}
//modded
if
(
DuelClient
::
try_needed
)
{
DuelClient
::
try_needed
=
false
;
DuelClient
::
StartClient
(
DuelClient
::
temp_ip
,
DuelClient
::
temp_port
,
false
);
}
}
DuelClient
::
StopClient
(
true
);
if
(
mainGame
->
dInfo
.
isSingleMode
)
...
...
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