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
0d449202
Commit
0d449202
authored
Jul 18, 2019
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:Fluorohydride/ygopro
parents
c3c03409
dad4962a
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
509 additions
and
458 deletions
+509
-458
gframe/client_field.cpp
gframe/client_field.cpp
+2
-2
gframe/config.h
gframe/config.h
+1
-1
gframe/deck_con.cpp
gframe/deck_con.cpp
+30
-30
gframe/duelclient.cpp
gframe/duelclient.cpp
+177
-177
gframe/event_handler.cpp
gframe/event_handler.cpp
+2
-2
gframe/game.cpp
gframe/game.cpp
+3
-3
gframe/game.h
gframe/game.h
+1
-2
gframe/menu_handler.cpp
gframe/menu_handler.cpp
+6
-6
gframe/mymutex.h
gframe/mymutex.h
+0
-56
gframe/mysignal.h
gframe/mysignal.h
+16
-100
gframe/replay_mode.cpp
gframe/replay_mode.cpp
+18
-18
gframe/single_mode.cpp
gframe/single_mode.cpp
+13
-13
lflist.conf
lflist.conf
+240
-48
No files found.
gframe/client_field.cpp
View file @
0d449202
...
...
@@ -606,7 +606,7 @@ void ClientField::ShowSelectOption(int select_hint) {
wchar_t
textBuffer
[
256
];
int
count
=
select_options
.
size
();
bool
quickmode
=
true
;
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
for
(
auto
option
:
select_options
)
{
if
(
mainGame
->
guiFont
->
getDimension
(
dataManager
.
GetDesc
(
option
)).
Width
>
310
)
{
quickmode
=
false
;
...
...
@@ -654,7 +654,7 @@ void ClientField::ShowSelectOption(int select_hint) {
myswprintf
(
textBuffer
,
dataManager
.
GetSysString
(
555
));
mainGame
->
wOptions
->
setText
(
textBuffer
);
mainGame
->
PopupElement
(
mainGame
->
wOptions
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
}
void
ClientField
::
ReplaySwap
()
{
std
::
swap
(
deck
[
0
],
deck
[
1
]);
...
...
gframe/config.h
View file @
0d449202
...
...
@@ -71,9 +71,9 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
#include <memory.h>
#include <time.h>
#include <thread>
#include <mutex>
#include "bufferio.h"
#include "myfilesystem.h"
#include "mymutex.h"
#include "mysignal.h"
#include "../ocgcore/ocgapi.h"
#include "../ocgcore/common.h"
...
...
gframe/deck_con.cpp
View file @
0d449202
...
...
@@ -211,10 +211,10 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
soundManager
.
PlaySoundEffect
(
SOUND_BUTTON
);
switch
(
id
)
{
case
BUTTON_CLEAR_DECK
:
{
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
SetStaticText
(
mainGame
->
stQMessage
,
310
,
mainGame
->
guiFont
,
dataManager
.
GetSysString
(
1339
));
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
prev_operation
=
id
;
break
;
}
...
...
@@ -273,7 +273,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
int
sel
=
mainGame
->
cbDBDecks
->
getSelected
();
if
(
sel
==
-
1
)
break
;
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
wDeckCode
->
setText
(
dataManager
.
GetSysString
(
1387
));
if
(
deckManager
.
current_deck
.
main
.
size
()
>
0
||
deckManager
.
current_deck
.
extra
.
size
()
>
0
||
deckManager
.
current_deck
.
side
.
size
()
>
0
)
{
wchar_t
deck_code
[
2048
];
...
...
@@ -284,7 +284,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
}
else
mainGame
->
ebDeckCode
->
setText
(
L""
);
mainGame
->
PopupElement
(
mainGame
->
wDeckCode
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
prev_operation
=
id
;
prev_sel
=
sel
;
break
;
...
...
@@ -314,22 +314,22 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
int
sel
=
mainGame
->
cbDBDecks
->
getSelected
();
if
(
sel
==
-
1
)
break
;
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
wchar_t
textBuffer
[
256
];
myswprintf
(
textBuffer
,
L"%ls
\n
%ls"
,
mainGame
->
cbDBDecks
->
getItem
(
sel
),
dataManager
.
GetSysString
(
1337
));
mainGame
->
SetStaticText
(
mainGame
->
stQMessage
,
310
,
mainGame
->
guiFont
,
textBuffer
);
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
prev_operation
=
id
;
prev_sel
=
sel
;
break
;
}
case
BUTTON_LEAVE_GAME
:
{
if
(
is_modified
&&
!
readonly
&&
!
mainGame
->
chkIgnoreDeckChanges
->
isChecked
())
{
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
SetStaticText
(
mainGame
->
stQMessage
,
310
,
mainGame
->
guiFont
,
dataManager
.
GetSysString
(
1356
));
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
prev_operation
=
id
;
break
;
}
...
...
@@ -363,10 +363,10 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
}
case
BUTTON_MANAGE_DECK
:
{
if
(
is_modified
&&
!
readonly
&&
!
mainGame
->
chkIgnoreDeckChanges
->
isChecked
())
{
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
SetStaticText
(
mainGame
->
stQMessage
,
310
,
mainGame
->
guiFont
,
dataManager
.
GetSysString
(
1356
));
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
prev_operation
=
id
;
break
;
}
...
...
@@ -374,69 +374,69 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
break
;
}
case
BUTTON_NEW_CATEGORY
:
{
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
stDMMessage
->
setText
(
dataManager
.
GetSysString
(
1469
));
mainGame
->
ebDMName
->
setVisible
(
true
);
mainGame
->
ebDMName
->
setText
(
L""
);
mainGame
->
PopupElement
(
mainGame
->
wDMQuery
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
prev_operation
=
id
;
break
;
}
case
BUTTON_RENAME_CATEGORY
:
{
if
(
mainGame
->
lstCategories
->
getSelected
()
<
4
)
break
;
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
stDMMessage
->
setText
(
dataManager
.
GetSysString
(
1469
));
mainGame
->
ebDMName
->
setVisible
(
true
);
mainGame
->
ebDMName
->
setText
(
L""
);
mainGame
->
PopupElement
(
mainGame
->
wDMQuery
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
prev_operation
=
id
;
break
;
}
case
BUTTON_DELETE_CATEGORY
:
{
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
stDMMessage
->
setText
(
dataManager
.
GetSysString
(
1470
));
mainGame
->
stDMMessage2
->
setVisible
(
true
);
mainGame
->
stDMMessage2
->
setText
(
mainGame
->
lstCategories
->
getListItem
(
mainGame
->
lstCategories
->
getSelected
()));
mainGame
->
PopupElement
(
mainGame
->
wDMQuery
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
prev_operation
=
id
;
break
;
}
case
BUTTON_NEW_DECK
:
{
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
stDMMessage
->
setText
(
dataManager
.
GetSysString
(
1471
));
mainGame
->
ebDMName
->
setVisible
(
true
);
mainGame
->
ebDMName
->
setText
(
L""
);
mainGame
->
PopupElement
(
mainGame
->
wDMQuery
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
prev_operation
=
id
;
break
;
}
case
BUTTON_RENAME_DECK
:
{
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
stDMMessage
->
setText
(
dataManager
.
GetSysString
(
1471
));
mainGame
->
ebDMName
->
setVisible
(
true
);
mainGame
->
ebDMName
->
setText
(
L""
);
mainGame
->
PopupElement
(
mainGame
->
wDMQuery
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
prev_operation
=
id
;
break
;
}
case
BUTTON_DELETE_DECK_DM
:
{
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
stDMMessage
->
setText
(
dataManager
.
GetSysString
(
1337
));
mainGame
->
stDMMessage2
->
setVisible
(
true
);
mainGame
->
stDMMessage2
->
setText
(
mainGame
->
lstDecks
->
getListItem
(
mainGame
->
lstDecks
->
getSelected
()));
mainGame
->
PopupElement
(
mainGame
->
wDMQuery
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
prev_operation
=
id
;
break
;
}
case
BUTTON_MOVE_DECK
:
{
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
stDMMessage
->
setText
(
dataManager
.
GetSysString
(
1472
));
mainGame
->
cbDMCategory
->
setVisible
(
true
);
mainGame
->
cbDMCategory
->
clear
();
...
...
@@ -448,12 +448,12 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
mainGame
->
cbDMCategory
->
addItem
(
mainGame
->
lstCategories
->
getListItem
(
i
));
}
mainGame
->
PopupElement
(
mainGame
->
wDMQuery
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
prev_operation
=
id
;
break
;
}
case
BUTTON_COPY_DECK
:
{
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
stDMMessage
->
setText
(
dataManager
.
GetSysString
(
1473
));
mainGame
->
cbDMCategory
->
setVisible
(
true
);
mainGame
->
cbDMCategory
->
clear
();
...
...
@@ -465,7 +465,7 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
mainGame
->
cbDMCategory
->
addItem
(
mainGame
->
lstCategories
->
getListItem
(
i
));
}
mainGame
->
PopupElement
(
mainGame
->
wDMQuery
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
prev_operation
=
id
;
break
;
}
...
...
@@ -888,10 +888,10 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
break
;
}
if
(
is_modified
&&
!
readonly
&&
!
mainGame
->
chkIgnoreDeckChanges
->
isChecked
())
{
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
SetStaticText
(
mainGame
->
stQMessage
,
310
,
mainGame
->
guiFont
,
dataManager
.
GetSysString
(
1356
));
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
prev_operation
=
id
;
break
;
}
...
...
@@ -904,10 +904,10 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
break
;
}
if
(
is_modified
&&
!
readonly
&&
!
mainGame
->
chkIgnoreDeckChanges
->
isChecked
())
{
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
SetStaticText
(
mainGame
->
stQMessage
,
310
,
mainGame
->
guiFont
,
dataManager
.
GetSysString
(
1356
));
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
prev_operation
=
id
;
break
;
}
...
...
gframe/duelclient.cpp
View file @
0d449202
This diff is collapsed.
Click to expand it.
gframe/event_handler.cpp
View file @
0d449202
...
...
@@ -1697,9 +1697,9 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
if
(
!
mainGame
->
dInfo
.
isReplay
&&
!
mainGame
->
HasFocus
(
EGUIET_EDIT_BOX
))
{
mainGame
->
dInfo
.
isReplaySkiping
=
event
.
KeyInput
.
PressedDown
;
if
(
mainGame
->
dInfo
.
isStarted
&&
!
mainGame
->
dInfo
.
isReplaySkiping
)
{
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
dField
.
RefreshAllCards
();
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
}
}
break
;
...
...
gframe/game.cpp
View file @
0d449202
...
...
@@ -879,7 +879,7 @@ void Game::MainLoop() {
atkframe
+=
0.1
f
;
atkdy
=
(
float
)
sin
(
atkframe
);
driver
->
beginScene
(
true
,
true
,
SColor
(
0
,
0
,
0
,
0
));
gMutex
.
L
ock
();
gMutex
.
l
ock
();
if
(
dInfo
.
isStarted
)
{
if
(
dInfo
.
isFinished
&&
showcardcode
==
1
)
soundManager
.
PlayBGM
(
BGM_WIN
);
...
...
@@ -908,7 +908,7 @@ void Game::MainLoop() {
}
DrawGUI
();
DrawSpec
();
gMutex
.
U
nlock
();
gMutex
.
u
nlock
();
if
(
signalFrame
>
0
)
{
signalFrame
--
;
if
(
!
signalFrame
)
...
...
@@ -925,7 +925,7 @@ void Game::MainLoop() {
}
}
driver
->
endScene
();
if
(
closeSignal
.
Wait
(
0
))
if
(
closeSignal
.
Wait
(
1
))
CloseDuelWindow
();
fps
++
;
cur_time
=
timer
->
getTime
();
...
...
gframe/game.h
View file @
0d449202
...
...
@@ -203,8 +203,7 @@ public:
void
takeScreenshot
();
void
SetCursor
(
ECURSOR_ICON
icon
);
Mutex
gMutex
;
Mutex
gBuffer
;
std
::
mutex
gMutex
;
Signal
frameSignal
;
Signal
actionSignal
;
Signal
replaySignal
;
...
...
gframe/menu_handler.cpp
View file @
0d449202
...
...
@@ -82,10 +82,10 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
hints
.
ai_flags
=
EVUTIL_AI_ADDRCONFIG
;
int
status
=
evutil_getaddrinfo
(
hostname
,
port
,
&
hints
,
&
answer
);
if
(
status
!=
0
)
{
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
soundManager
.
PlaySoundEffect
(
SOUND_INFO
);
mainGame
->
env
->
addMessageBox
(
L""
,
dataManager
.
GetSysString
(
1412
));
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
break
;
}
else
{
sockaddr_in
*
sin
=
((
struct
sockaddr_in
*
)
answer
->
ai_addr
);
...
...
@@ -250,12 +250,12 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
int
sel
=
mainGame
->
lstReplayList
->
getSelected
();
if
(
sel
==
-
1
)
break
;
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
wchar_t
textBuffer
[
256
];
myswprintf
(
textBuffer
,
L"%ls
\n
%ls"
,
mainGame
->
lstReplayList
->
getListItem
(
sel
),
dataManager
.
GetSysString
(
1363
));
mainGame
->
SetStaticText
(
mainGame
->
stQMessage
,
310
,
mainGame
->
guiFont
,
textBuffer
);
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
prev_operation
=
id
;
prev_sel
=
sel
;
break
;
...
...
@@ -264,11 +264,11 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
int
sel
=
mainGame
->
lstReplayList
->
getSelected
();
if
(
sel
==
-
1
)
break
;
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
wReplaySave
->
setText
(
dataManager
.
GetSysString
(
1364
));
mainGame
->
ebRSName
->
setText
(
mainGame
->
lstReplayList
->
getListItem
(
sel
));
mainGame
->
PopupElement
(
mainGame
->
wReplaySave
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
prev_operation
=
id
;
prev_sel
=
sel
;
break
;
...
...
gframe/mymutex.h
deleted
100644 → 0
View file @
c3c03409
#ifndef MUTEX_H
#define MUTEX_H
#ifdef _WIN32
#include <windows.h>
class
Mutex
{
public:
Mutex
()
{
InitializeCriticalSection
(
&
_mutex
);
}
~
Mutex
()
{
DeleteCriticalSection
(
&
_mutex
);
}
void
Lock
()
{
EnterCriticalSection
(
&
_mutex
);
}
void
Unlock
()
{
LeaveCriticalSection
(
&
_mutex
);
}
bool
TryLock
()
{
return
TryEnterCriticalSection
(
&
_mutex
)
==
TRUE
;
}
private:
CRITICAL_SECTION
_mutex
;
};
#else // _WIN32
#include <pthread.h>
class
Mutex
{
public:
Mutex
()
{
pthread_mutex_init
(
&
mutex_t
,
NULL
);
}
~
Mutex
()
{
pthread_mutex_destroy
(
&
mutex_t
);
}
void
Lock
()
{
pthread_mutex_lock
(
&
mutex_t
);
}
void
Unlock
()
{
pthread_mutex_unlock
(
&
mutex_t
);
}
bool
TryLock
()
{
return
!
pthread_mutex_trylock
(
&
mutex_t
);
}
private:
pthread_mutex_t
mutex_t
;
};
#endif // _WIN32
#endif // MUTEX_H
gframe/mysignal.h
View file @
0d449202
#ifndef SIGNAL_H
#define SIGNAL_H
#ifdef _WIN32
#include <windows.h>
class
Signal
{
public:
Signal
()
{
_event
=
CreateEvent
(
0
,
FALSE
,
FALSE
,
0
);
_nowait
=
false
;
}
~
Signal
()
{
CloseHandle
(
_event
);
}
void
Set
()
{
SetEvent
(
_event
);
}
void
Reset
()
{
ResetEvent
(
_event
);
}
void
Wait
()
{
if
(
_nowait
)
return
;
WaitForSingleObject
(
_event
,
INFINITE
);
}
bool
Wait
(
long
milli
)
{
if
(
_nowait
)
return
false
;
return
WaitForSingleObject
(
_event
,
milli
+
1
)
!=
WAIT_TIMEOUT
;
}
void
SetNoWait
(
bool
nowait
)
{
_nowait
=
nowait
;
}
private:
HANDLE
_event
;
bool
_nowait
;
};
#else // _WIN32
#include <sys/time.h>
#include <pthread.h>
#include <mutex>
#include <condition_variable>
class
Signal
{
public:
Signal
()
{
_state
=
false
;
_nowait
=
false
;
pthread_mutex_init
(
&
_mutex
,
NULL
);
pthread_cond_init
(
&
_cond
,
NULL
);
}
~
Signal
()
{
pthread_cond_destroy
(
&
_cond
);
pthread_mutex_destroy
(
&
_mutex
);
}
void
Set
()
{
if
(
pthread_mutex_lock
(
&
_mutex
))
return
;
std
::
unique_lock
<
std
::
mutex
>
lock
(
_mutex
);
_state
=
true
;
if
(
pthread_cond_broadcast
(
&
_cond
))
{
pthread_mutex_unlock
(
&
_mutex
);
// ERROR Broadcasting event status!
return
;
}
pthread_mutex_unlock
(
&
_mutex
);
_cond
.
notify_all
();
}
void
Reset
()
{
if
(
pthread_mutex_lock
(
&
_mutex
))
return
;
std
::
unique_lock
<
std
::
mutex
>
lock
(
_mutex
);
_state
=
false
;
pthread_mutex_unlock
(
&
_mutex
);
}
void
Wait
()
{
if
(
_nowait
||
pthread_mutex_lock
(
&
_mutex
)
)
if
(
_nowait
)
return
;
while
(
!
_state
)
{
if
(
pthread_cond_wait
(
&
_cond
,
&
_mutex
))
{
pthread_mutex_unlock
(
&
_mutex
);
// ERROR Waiting events;
return
;
}
}
std
::
unique_lock
<
std
::
mutex
>
lock
(
_mutex
);
_cond
.
wait
(
lock
,
[
this
]()
{
return
_state
;
});
_state
=
false
;
pthread_mutex_unlock
(
&
_mutex
);
}
bool
Wait
(
long
milliseconds
)
{
if
(
_nowait
||
pthread_mutex_lock
(
&
_mutex
)
!=
0
)
bool
Wait
(
long
milliseconds
)
{
if
(
_nowait
)
return
false
;
int
rc
=
0
;
struct
timespec
abstime
;
struct
timeval
tv
;
gettimeofday
(
&
tv
,
NULL
);
abstime
.
tv_sec
=
tv
.
tv_sec
+
milliseconds
/
1000
;
abstime
.
tv_nsec
=
tv
.
tv_usec
*
1000
+
(
milliseconds
%
1000
)
*
1000000
;
if
(
abstime
.
tv_nsec
>=
1000000000
)
{
abstime
.
tv_nsec
-=
1000000000
;
abstime
.
tv_sec
++
;
}
while
(
!
_state
)
{
if
((
rc
=
pthread_cond_timedwait
(
&
_cond
,
&
_mutex
,
&
abstime
)))
{
if
(
rc
==
ETIMEDOUT
)
break
;
pthread_mutex_unlock
(
&
_mutex
);
return
false
;
}
}
std
::
unique_lock
<
std
::
mutex
>
lock
(
_mutex
);
bool
res
=
_cond
.
wait_for
(
lock
,
std
::
chrono
::
milliseconds
(
milliseconds
),
[
this
]()
{
return
_state
;
});
_state
=
false
;
pthread_mutex_unlock
(
&
_mutex
);
return
rc
==
0
;
return
res
;
}
void
SetNoWait
(
bool
nowait
)
{
_nowait
=
nowait
;
}
private:
pthread_mutex_t
_mutex
;
pthread_cond_t
_cond
;
std
::
mutex
_mutex
;
std
::
condition_variable
_cond
;
bool
_state
;
bool
_nowait
;
};
#endif // _WIN32
#endif // SIGNAL_H
gframe/replay_mode.cpp
View file @
0d449202
...
...
@@ -90,7 +90,7 @@ int ReplayMode::ReplayThread() {
exit_pending
=
false
;
current_step
=
0
;
if
(
mainGame
->
dInfo
.
isReplaySkiping
)
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
while
(
is_continuing
&&
!
exit_pending
)
{
int
result
=
process
(
pduel
);
int
len
=
result
&
0xffff
;
...
...
@@ -99,7 +99,7 @@ int ReplayMode::ReplayThread() {
get_message
(
pduel
,
(
byte
*
)
engineBuffer
);
is_continuing
=
ReplayAnalyze
(
engineBuffer
,
len
);
if
(
is_restarting
)
{
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
is_restarting
=
false
;
mainGame
->
dInfo
.
isReplaySkiping
=
true
;
Restart
(
false
);
...
...
@@ -125,7 +125,7 @@ int ReplayMode::ReplayThread() {
mainGame
->
dInfo
.
isFinished
=
false
;
mainGame
->
dInfo
.
isReplaySkiping
=
false
;
mainGame
->
dField
.
RefreshAllCards
();
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
}
skip_step
=
step
;
current_step
=
0
;
...
...
@@ -135,7 +135,7 @@ int ReplayMode::ReplayThread() {
if
(
mainGame
->
dInfo
.
isReplaySkiping
)
{
mainGame
->
dInfo
.
isReplaySkiping
=
false
;
mainGame
->
dField
.
RefreshAllCards
();
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
}
EndDuel
();
return
0
;
...
...
@@ -232,26 +232,26 @@ void ReplayMode::EndDuel() {
end_duel
(
pduel
);
if
(
!
is_closing
)
{
mainGame
->
actionSignal
.
Reset
();
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
stMessage
->
setText
(
dataManager
.
GetSysString
(
1501
));
if
(
mainGame
->
wCardSelect
->
isVisible
())
mainGame
->
HideElement
(
mainGame
->
wCardSelect
);
mainGame
->
PopupElement
(
mainGame
->
wMessage
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
mainGame
->
actionSignal
.
Wait
();
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
dInfo
.
isStarted
=
false
;
mainGame
->
dInfo
.
isFinished
=
true
;
mainGame
->
dInfo
.
isReplay
=
false
;
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
mainGame
->
closeDoneSignal
.
Reset
();
mainGame
->
closeSignal
.
Set
();
mainGame
->
closeDoneSignal
.
Wait
();
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
ShowElement
(
mainGame
->
wReplay
);
mainGame
->
stTip
->
setVisible
(
false
);
mainGame
->
device
->
setEventReceiver
(
&
mainGame
->
menuHandler
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
if
(
exit_on_return
)
mainGame
->
device
->
closeDevice
();
}
...
...
@@ -295,9 +295,9 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
return
true
;
}
if
(
is_swaping
)
{
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
dField
.
ReplaySwap
();
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
is_swaping
=
false
;
}
char
*
offset
=
pbuf
;
...
...
@@ -308,12 +308,12 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
if
(
mainGame
->
dInfo
.
isReplaySkiping
)
{
mainGame
->
dInfo
.
isReplaySkiping
=
false
;
mainGame
->
dField
.
RefreshAllCards
();
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
}
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
stMessage
->
setText
(
L"Error occurs."
);
mainGame
->
PopupElement
(
mainGame
->
wMessage
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
mainGame
->
actionSignal
.
Reset
();
mainGame
->
actionSignal
.
Wait
();
return
false
;
...
...
@@ -327,7 +327,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
if
(
mainGame
->
dInfo
.
isReplaySkiping
)
{
mainGame
->
dInfo
.
isReplaySkiping
=
false
;
mainGame
->
dField
.
RefreshAllCards
();
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
}
pbuf
+=
2
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
...
...
@@ -509,7 +509,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
if
(
skip_turn
==
0
)
{
mainGame
->
dInfo
.
isReplaySkiping
=
false
;
mainGame
->
dField
.
RefreshAllCards
();
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
}
}
player
=
BufferIO
::
ReadInt8
(
pbuf
);
...
...
@@ -846,7 +846,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
mainGame
->
dInfo
.
isFinished
=
false
;
mainGame
->
dInfo
.
isReplaySkiping
=
false
;
mainGame
->
dField
.
RefreshAllCards
();
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
}
}
if
(
is_pausing
)
{
...
...
gframe/single_mode.cpp
View file @
0d449202
...
...
@@ -84,7 +84,7 @@ int SingleMode::SinglePlayThread() {
rh
.
version
=
PRO_VERSION
;
rh
.
flag
=
REPLAY_SINGLE_MODE
;
rh
.
seed
=
seed
;
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
HideElement
(
mainGame
->
wSinglePlay
);
mainGame
->
ClearCardInfo
();
mainGame
->
wCardImg
->
setVisible
(
true
);
...
...
@@ -98,7 +98,7 @@ int SingleMode::SinglePlayThread() {
mainGame
->
dInfo
.
isFinished
=
false
;
mainGame
->
dInfo
.
isSingleMode
=
true
;
mainGame
->
device
->
setEventReceiver
(
&
mainGame
->
dField
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
char
engineBuffer
[
0x1000
];
is_closing
=
false
;
is_continuing
=
true
;
...
...
@@ -130,7 +130,7 @@ int SingleMode::SinglePlayThread() {
}
}
last_replay
.
EndRecord
();
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
time_t
nowtime
=
time
(
NULL
);
tm
*
localedtime
=
localtime
(
&
nowtime
);
wchar_t
timetext
[
40
];
...
...
@@ -139,7 +139,7 @@ int SingleMode::SinglePlayThread() {
if
(
!
mainGame
->
chkAutoSaveReplay
->
isChecked
())
{
mainGame
->
wReplaySave
->
setText
(
dataManager
.
GetSysString
(
1340
));
mainGame
->
PopupElement
(
mainGame
->
wReplaySave
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
mainGame
->
replaySignal
.
Reset
();
mainGame
->
replaySignal
.
Wait
();
}
else
{
...
...
@@ -148,26 +148,26 @@ int SingleMode::SinglePlayThread() {
myswprintf
(
msgbuf
,
dataManager
.
GetSysString
(
1367
),
timetext
);
mainGame
->
SetStaticText
(
mainGame
->
stACMessage
,
310
,
mainGame
->
guiFont
,
msgbuf
);
mainGame
->
PopupElement
(
mainGame
->
wACMessage
,
20
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
mainGame
->
WaitFrameSignal
(
30
);
}
if
(
mainGame
->
actionParam
)
last_replay
.
SaveReplay
(
mainGame
->
ebRSName
->
getText
());
end_duel
(
pduel
);
if
(
!
is_closing
)
{
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
dInfo
.
isStarted
=
false
;
mainGame
->
dInfo
.
isFinished
=
true
;
mainGame
->
dInfo
.
isSingleMode
=
false
;
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
mainGame
->
closeDoneSignal
.
Reset
();
mainGame
->
closeSignal
.
Set
();
mainGame
->
closeDoneSignal
.
Wait
();
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
ShowElement
(
mainGame
->
wSinglePlay
);
mainGame
->
stTip
->
setVisible
(
false
);
mainGame
->
device
->
setEventReceiver
(
&
mainGame
->
menuHandler
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
if
(
exit_on_return
)
mainGame
->
device
->
closeDevice
();
}
...
...
@@ -737,9 +737,9 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
pbuf
++
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
SinglePlayReload
();
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
dField
.
RefreshAllCards
();
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
break
;
}
case
MSG_AI_NAME
:
{
...
...
@@ -761,10 +761,10 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
pbuf
+=
len
+
1
;
memcpy
(
msgbuf
,
begin
,
len
+
1
);
BufferIO
::
DecodeUTF8
(
msgbuf
,
msg
);
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
SetStaticText
(
mainGame
->
stMessage
,
310
,
mainGame
->
guiFont
,
msg
);
mainGame
->
PopupElement
(
mainGame
->
wMessage
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
mainGame
->
actionSignal
.
Reset
();
mainGame
->
actionSignal
.
Wait
();
break
;
...
...
lflist.conf
View file @
0d449202
This diff is collapsed.
Click to expand it.
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