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
7c39f047
Commit
7c39f047
authored
Jul 14, 2019
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:Fluorohydride/ygopro
parents
2ec1fcb1
de2ec1ba
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
18 additions
and
58 deletions
+18
-58
gframe/config.h
gframe/config.h
+1
-1
gframe/duelclient.cpp
gframe/duelclient.cpp
+4
-5
gframe/duelclient.h
gframe/duelclient.h
+2
-2
gframe/game.cpp
gframe/game.cpp
+2
-10
gframe/mythread.h
gframe/mythread.h
+0
-31
gframe/netserver.cpp
gframe/netserver.cpp
+2
-2
gframe/netserver.h
gframe/netserver.h
+1
-1
gframe/replay_mode.cpp
gframe/replay_mode.cpp
+2
-2
gframe/replay_mode.h
gframe/replay_mode.h
+1
-1
gframe/single_mode.cpp
gframe/single_mode.cpp
+2
-2
gframe/single_mode.h
gframe/single_mode.h
+1
-1
No files found.
gframe/config.h
View file @
7c39f047
...
@@ -70,11 +70,11 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
...
@@ -70,11 +70,11 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
#include <stdlib.h>
#include <stdlib.h>
#include <memory.h>
#include <memory.h>
#include <time.h>
#include <time.h>
#include <thread>
#include "bufferio.h"
#include "bufferio.h"
#include "myfilesystem.h"
#include "myfilesystem.h"
#include "mymutex.h"
#include "mymutex.h"
#include "mysignal.h"
#include "mysignal.h"
#include "mythread.h"
#include "../ocgcore/ocgapi.h"
#include "../ocgcore/ocgapi.h"
#include "../ocgcore/common.h"
#include "../ocgcore/common.h"
...
...
gframe/duelclient.cpp
View file @
7c39f047
...
@@ -74,7 +74,7 @@ bool DuelClient::StartClient(unsigned int ip, unsigned short port, bool create_g
...
@@ -74,7 +74,7 @@ bool DuelClient::StartClient(unsigned int ip, unsigned short port, bool create_g
event
*
resp_event
=
event_new
(
client_base
,
0
,
EV_TIMEOUT
,
ConnectTimeout
,
0
);
event
*
resp_event
=
event_new
(
client_base
,
0
,
EV_TIMEOUT
,
ConnectTimeout
,
0
);
event_add
(
resp_event
,
&
timeout
);
event_add
(
resp_event
,
&
timeout
);
}
}
Thread
::
NewThread
(
ClientThread
,
0
);
std
::
thread
(
ClientThread
).
detach
(
);
return
true
;
return
true
;
}
}
void
DuelClient
::
ConnectTimeout
(
evutil_socket_t
fd
,
short
events
,
void
*
arg
)
{
void
DuelClient
::
ConnectTimeout
(
evutil_socket_t
fd
,
short
events
,
void
*
arg
)
{
...
@@ -241,7 +241,7 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
...
@@ -241,7 +241,7 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
mainGame
->
device
->
closeDevice
();
mainGame
->
device
->
closeDevice
();
}
}
}
}
int
DuelClient
::
ClientThread
(
void
*
param
)
{
int
DuelClient
::
ClientThread
()
{
event_base_dispatch
(
client_base
);
event_base_dispatch
(
client_base
);
bufferevent_free
(
client_bev
);
bufferevent_free
(
client_bev
);
event_base_free
(
client_base
);
event_base_free
(
client_base
);
...
@@ -4069,7 +4069,7 @@ void DuelClient::BeginRefreshHost() {
...
@@ -4069,7 +4069,7 @@ void DuelClient::BeginRefreshHost() {
timeval
timeout
=
{
3
,
0
};
timeval
timeout
=
{
3
,
0
};
resp_event
=
event_new
(
broadev
,
reply
,
EV_TIMEOUT
|
EV_READ
|
EV_PERSIST
,
BroadcastReply
,
broadev
);
resp_event
=
event_new
(
broadev
,
reply
,
EV_TIMEOUT
|
EV_READ
|
EV_PERSIST
,
BroadcastReply
,
broadev
);
event_add
(
resp_event
,
&
timeout
);
event_add
(
resp_event
,
&
timeout
);
Thread
::
NewThread
(
RefreshThread
,
broadev
);
std
::
thread
(
RefreshThread
,
broadev
).
detach
(
);
//send request
//send request
SOCKADDR_IN
local
;
SOCKADDR_IN
local
;
local
.
sin_family
=
AF_INET
;
local
.
sin_family
=
AF_INET
;
...
@@ -4098,8 +4098,7 @@ void DuelClient::BeginRefreshHost() {
...
@@ -4098,8 +4098,7 @@ void DuelClient::BeginRefreshHost() {
closesocket
(
sSend
);
closesocket
(
sSend
);
}
}
}
}
int
DuelClient
::
RefreshThread
(
void
*
arg
)
{
int
DuelClient
::
RefreshThread
(
event_base
*
broadev
)
{
event_base
*
broadev
=
(
event_base
*
)
arg
;
event_base_dispatch
(
broadev
);
event_base_dispatch
(
broadev
);
evutil_socket_t
fd
;
evutil_socket_t
fd
;
event_get_assignment
(
resp_event
,
0
,
&
fd
,
0
,
0
,
0
);
event_get_assignment
(
resp_event
,
0
,
&
fd
,
0
,
0
,
0
);
...
...
gframe/duelclient.h
View file @
7c39f047
...
@@ -48,7 +48,7 @@ public:
...
@@ -48,7 +48,7 @@ public:
static
void
StopClient
(
bool
is_exiting
=
false
);
static
void
StopClient
(
bool
is_exiting
=
false
);
static
void
ClientRead
(
bufferevent
*
bev
,
void
*
ctx
);
static
void
ClientRead
(
bufferevent
*
bev
,
void
*
ctx
);
static
void
ClientEvent
(
bufferevent
*
bev
,
short
events
,
void
*
ctx
);
static
void
ClientEvent
(
bufferevent
*
bev
,
short
events
,
void
*
ctx
);
static
int
ClientThread
(
void
*
param
);
static
int
ClientThread
();
static
void
HandleSTOCPacketLan
(
char
*
data
,
unsigned
int
len
);
static
void
HandleSTOCPacketLan
(
char
*
data
,
unsigned
int
len
);
static
int
ClientAnalyze
(
char
*
msg
,
unsigned
int
len
);
static
int
ClientAnalyze
(
char
*
msg
,
unsigned
int
len
);
static
void
SwapField
();
static
void
SwapField
();
...
@@ -87,7 +87,7 @@ public:
...
@@ -87,7 +87,7 @@ public:
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
();
static
int
RefreshThread
(
void
*
arg
);
static
int
RefreshThread
(
event_base
*
broadev
);
static
void
BroadcastReply
(
evutil_socket_t
fd
,
short
events
,
void
*
arg
);
static
void
BroadcastReply
(
evutil_socket_t
fd
,
short
events
,
void
*
arg
);
};
};
...
...
gframe/game.cpp
View file @
7c39f047
...
@@ -930,11 +930,7 @@ void Game::MainLoop() {
...
@@ -930,11 +930,7 @@ void Game::MainLoop() {
fps
++
;
fps
++
;
cur_time
=
timer
->
getTime
();
cur_time
=
timer
->
getTime
();
if
(
cur_time
<
fps
*
17
-
20
)
if
(
cur_time
<
fps
*
17
-
20
)
#ifdef _WIN32
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
20
));
Sleep
(
20
);
#else
usleep
(
20000
);
#endif
if
(
cur_time
>=
1000
)
{
if
(
cur_time
>=
1000
)
{
myswprintf
(
cap
,
L"KoishiPro FPS: %d"
,
fps
);
myswprintf
(
cap
,
L"KoishiPro FPS: %d"
,
fps
);
device
->
setWindowCaption
(
cap
);
device
->
setWindowCaption
(
cap
);
...
@@ -955,11 +951,7 @@ void Game::MainLoop() {
...
@@ -955,11 +951,7 @@ void Game::MainLoop() {
DuelClient
::
StopClient
(
true
);
DuelClient
::
StopClient
(
true
);
if
(
dInfo
.
isSingleMode
)
if
(
dInfo
.
isSingleMode
)
SingleMode
::
StopPlay
(
true
);
SingleMode
::
StopPlay
(
true
);
#ifdef _WIN32
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
500
));
Sleep
(
500
);
#else
usleep
(
500000
);
#endif
SaveConfig
();
SaveConfig
();
// device->drop();
// device->drop();
}
}
...
...
gframe/mythread.h
deleted
100644 → 0
View file @
2ec1fcb1
#ifndef THREAD_H
#define THREAD_H
#ifdef _WIN32
#include <windows.h>
class
Thread
{
public:
static
void
NewThread
(
int
(
*
thread_func
)(
void
*
),
void
*
param
)
{
CreateThread
(
0
,
0
,
(
LPTHREAD_START_ROUTINE
)
thread_func
,
param
,
0
,
0
);
}
};
#else // _WIN32
#include <pthread.h>
class
Thread
{
public:
static
void
NewThread
(
int
(
*
thread_func
)(
void
*
),
void
*
param
)
{
pthread_t
thread
;
pthread_attr_t
attr
;
pthread_attr_init
(
&
attr
);
pthread_create
(
&
thread
,
&
attr
,
(
void
*
(
*
)(
void
*
))
thread_func
,
param
);
}
};
#endif // _WIN32
#endif // THREAD_H
gframe/netserver.cpp
View file @
7c39f047
...
@@ -33,7 +33,7 @@ bool NetServer::StartServer(unsigned short port) {
...
@@ -33,7 +33,7 @@ bool NetServer::StartServer(unsigned short port) {
return
false
;
return
false
;
}
}
evconnlistener_set_error_cb
(
listener
,
ServerAcceptError
);
evconnlistener_set_error_cb
(
listener
,
ServerAcceptError
);
Thread
::
NewThread
(
ServerThread
,
net_evbase
);
std
::
thread
(
ServerThread
).
detach
(
);
return
true
;
return
true
;
}
}
bool
NetServer
::
StartBroadcast
()
{
bool
NetServer
::
StartBroadcast
()
{
...
@@ -136,7 +136,7 @@ void NetServer::ServerEchoEvent(bufferevent* bev, short events, void* ctx) {
...
@@ -136,7 +136,7 @@ void NetServer::ServerEchoEvent(bufferevent* bev, short events, void* ctx) {
else
DisconnectPlayer
(
dp
);
else
DisconnectPlayer
(
dp
);
}
}
}
}
int
NetServer
::
ServerThread
(
void
*
param
)
{
int
NetServer
::
ServerThread
()
{
event_base_dispatch
(
net_evbase
);
event_base_dispatch
(
net_evbase
);
for
(
auto
bit
=
users
.
begin
();
bit
!=
users
.
end
();
++
bit
)
{
for
(
auto
bit
=
users
.
begin
();
bit
!=
users
.
end
();
++
bit
)
{
bufferevent_disable
(
bit
->
first
,
EV_READ
);
bufferevent_disable
(
bit
->
first
,
EV_READ
);
...
...
gframe/netserver.h
View file @
7c39f047
...
@@ -33,7 +33,7 @@ public:
...
@@ -33,7 +33,7 @@ public:
static
void
ServerAcceptError
(
evconnlistener
*
listener
,
void
*
ctx
);
static
void
ServerAcceptError
(
evconnlistener
*
listener
,
void
*
ctx
);
static
void
ServerEchoRead
(
bufferevent
*
bev
,
void
*
ctx
);
static
void
ServerEchoRead
(
bufferevent
*
bev
,
void
*
ctx
);
static
void
ServerEchoEvent
(
bufferevent
*
bev
,
short
events
,
void
*
ctx
);
static
void
ServerEchoEvent
(
bufferevent
*
bev
,
short
events
,
void
*
ctx
);
static
int
ServerThread
(
void
*
param
);
static
int
ServerThread
();
static
void
DisconnectPlayer
(
DuelPlayer
*
dp
);
static
void
DisconnectPlayer
(
DuelPlayer
*
dp
);
static
void
HandleCTOSPacket
(
DuelPlayer
*
dp
,
char
*
data
,
unsigned
int
len
);
static
void
HandleCTOSPacket
(
DuelPlayer
*
dp
,
char
*
data
,
unsigned
int
len
);
static
void
SendPacketToPlayer
(
DuelPlayer
*
dp
,
unsigned
char
proto
)
{
static
void
SendPacketToPlayer
(
DuelPlayer
*
dp
,
unsigned
char
proto
)
{
...
...
gframe/replay_mode.cpp
View file @
7c39f047
...
@@ -24,7 +24,7 @@ bool ReplayMode::StartReplay(int skipturn) {
...
@@ -24,7 +24,7 @@ bool ReplayMode::StartReplay(int skipturn) {
skip_turn
=
skipturn
;
skip_turn
=
skipturn
;
if
(
skip_turn
<
0
)
if
(
skip_turn
<
0
)
skip_turn
=
0
;
skip_turn
=
0
;
Thread
::
NewThread
(
ReplayThread
,
0
);
std
::
thread
(
ReplayThread
).
detach
(
);
return
true
;
return
true
;
}
}
void
ReplayMode
::
StopReplay
(
bool
is_exiting
)
{
void
ReplayMode
::
StopReplay
(
bool
is_exiting
)
{
...
@@ -56,7 +56,7 @@ bool ReplayMode::ReadReplayResponse() {
...
@@ -56,7 +56,7 @@ bool ReplayMode::ReadReplayResponse() {
set_responseb
(
pduel
,
resp
);
set_responseb
(
pduel
,
resp
);
return
result
;
return
result
;
}
}
int
ReplayMode
::
ReplayThread
(
void
*
param
)
{
int
ReplayMode
::
ReplayThread
()
{
const
ReplayHeader
&
rh
=
cur_replay
.
pheader
;
const
ReplayHeader
&
rh
=
cur_replay
.
pheader
;
mainGame
->
dInfo
.
isFirst
=
true
;
mainGame
->
dInfo
.
isFirst
=
true
;
mainGame
->
dInfo
.
isTag
=
!!
(
rh
.
flag
&
REPLAY_TAG
);
mainGame
->
dInfo
.
isTag
=
!!
(
rh
.
flag
&
REPLAY_TAG
);
...
...
gframe/replay_mode.h
View file @
7c39f047
...
@@ -32,7 +32,7 @@ public:
...
@@ -32,7 +32,7 @@ public:
static
void
SwapField
();
static
void
SwapField
();
static
void
Pause
(
bool
is_pause
,
bool
is_step
);
static
void
Pause
(
bool
is_pause
,
bool
is_step
);
static
bool
ReadReplayResponse
();
static
bool
ReadReplayResponse
();
static
int
ReplayThread
(
void
*
param
);
static
int
ReplayThread
();
static
bool
StartDuel
();
static
bool
StartDuel
();
static
void
EndDuel
();
static
void
EndDuel
();
static
void
Restart
(
bool
refresh
);
static
void
Restart
(
bool
refresh
);
...
...
gframe/single_mode.cpp
View file @
7c39f047
...
@@ -12,7 +12,7 @@ bool SingleMode::is_continuing = false;
...
@@ -12,7 +12,7 @@ bool SingleMode::is_continuing = false;
Replay
SingleMode
::
last_replay
;
Replay
SingleMode
::
last_replay
;
bool
SingleMode
::
StartPlay
()
{
bool
SingleMode
::
StartPlay
()
{
Thread
::
NewThread
(
SinglePlayThread
,
0
);
std
::
thread
(
SinglePlayThread
).
detach
(
);
return
true
;
return
true
;
}
}
void
SingleMode
::
StopPlay
(
bool
is_exiting
)
{
void
SingleMode
::
StopPlay
(
bool
is_exiting
)
{
...
@@ -28,7 +28,7 @@ void SingleMode::SetResponse(unsigned char* resp, unsigned int len) {
...
@@ -28,7 +28,7 @@ void SingleMode::SetResponse(unsigned char* resp, unsigned int len) {
last_replay
.
WriteData
(
resp
,
len
);
last_replay
.
WriteData
(
resp
,
len
);
set_responseb
(
pduel
,
resp
);
set_responseb
(
pduel
,
resp
);
}
}
int
SingleMode
::
SinglePlayThread
(
void
*
param
)
{
int
SingleMode
::
SinglePlayThread
()
{
const
int
start_lp
=
8000
;
const
int
start_lp
=
8000
;
const
int
start_hand
=
5
;
const
int
start_hand
=
5
;
const
int
draw_count
=
1
;
const
int
draw_count
=
1
;
...
...
gframe/single_mode.h
View file @
7c39f047
...
@@ -15,7 +15,7 @@ public:
...
@@ -15,7 +15,7 @@ public:
static
bool
StartPlay
();
static
bool
StartPlay
();
static
void
StopPlay
(
bool
is_exiting
=
false
);
static
void
StopPlay
(
bool
is_exiting
=
false
);
static
void
SetResponse
(
unsigned
char
*
resp
,
unsigned
int
len
);
static
void
SetResponse
(
unsigned
char
*
resp
,
unsigned
int
len
);
static
int
SinglePlayThread
(
void
*
param
);
static
int
SinglePlayThread
();
static
bool
SinglePlayAnalyze
(
char
*
msg
,
unsigned
int
len
);
static
bool
SinglePlayAnalyze
(
char
*
msg
,
unsigned
int
len
);
static
void
SinglePlayRefresh
(
int
flag
=
0xf81fff
);
static
void
SinglePlayRefresh
(
int
flag
=
0xf81fff
);
...
...
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