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
wyykak
ygopro
Commits
9addd246
Commit
9addd246
authored
Jul 15, 2019
by
DailyShana
Committed by
GitHub
Jul 15, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use standard mutex library (#2224)
parent
7ab508ab
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
224 additions
and
281 deletions
+224
-281
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
+8
-8
gframe/duelclient.cpp
gframe/duelclient.cpp
+173
-173
gframe/game.cpp
gframe/game.cpp
+2
-2
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/replay_mode.cpp
gframe/replay_mode.cpp
+18
-18
gframe/single_mode.cpp
gframe/single_mode.cpp
+13
-13
No files found.
gframe/client_field.cpp
View file @
9addd246
...
@@ -595,7 +595,7 @@ void ClientField::ShowSelectOption(int select_hint) {
...
@@ -595,7 +595,7 @@ void ClientField::ShowSelectOption(int select_hint) {
wchar_t
textBuffer
[
256
];
wchar_t
textBuffer
[
256
];
int
count
=
select_options
.
size
();
int
count
=
select_options
.
size
();
bool
quickmode
=
true
;
bool
quickmode
=
true
;
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
for
(
auto
option
:
select_options
)
{
for
(
auto
option
:
select_options
)
{
if
(
mainGame
->
guiFont
->
getDimension
(
dataManager
.
GetDesc
(
option
)).
Width
>
310
)
{
if
(
mainGame
->
guiFont
->
getDimension
(
dataManager
.
GetDesc
(
option
)).
Width
>
310
)
{
quickmode
=
false
;
quickmode
=
false
;
...
@@ -643,7 +643,7 @@ void ClientField::ShowSelectOption(int select_hint) {
...
@@ -643,7 +643,7 @@ void ClientField::ShowSelectOption(int select_hint) {
myswprintf
(
textBuffer
,
dataManager
.
GetSysString
(
555
));
myswprintf
(
textBuffer
,
dataManager
.
GetSysString
(
555
));
mainGame
->
wOptions
->
setText
(
textBuffer
);
mainGame
->
wOptions
->
setText
(
textBuffer
);
mainGame
->
PopupElement
(
mainGame
->
wOptions
);
mainGame
->
PopupElement
(
mainGame
->
wOptions
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
}
}
void
ClientField
::
ReplaySwap
()
{
void
ClientField
::
ReplaySwap
()
{
std
::
swap
(
deck
[
0
],
deck
[
1
]);
std
::
swap
(
deck
[
0
],
deck
[
1
]);
...
...
gframe/config.h
View file @
9addd246
...
@@ -66,9 +66,9 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
...
@@ -66,9 +66,9 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
#include <memory.h>
#include <memory.h>
#include <time.h>
#include <time.h>
#include <thread>
#include <thread>
#include <mutex>
#include "bufferio.h"
#include "bufferio.h"
#include "myfilesystem.h"
#include "myfilesystem.h"
#include "mymutex.h"
#include "mysignal.h"
#include "mysignal.h"
#include "../ocgcore/ocgapi.h"
#include "../ocgcore/ocgapi.h"
#include "../ocgcore/common.h"
#include "../ocgcore/common.h"
...
...
gframe/deck_con.cpp
View file @
9addd246
...
@@ -129,10 +129,10 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -129,10 +129,10 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
soundManager
.
PlaySoundEffect
(
SOUND_BUTTON
);
soundManager
.
PlaySoundEffect
(
SOUND_BUTTON
);
switch
(
id
)
{
switch
(
id
)
{
case
BUTTON_CLEAR_DECK
:
{
case
BUTTON_CLEAR_DECK
:
{
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
SetStaticText
(
mainGame
->
stQMessage
,
310
,
mainGame
->
guiFont
,
dataManager
.
GetSysString
(
1339
));
mainGame
->
SetStaticText
(
mainGame
->
stQMessage
,
310
,
mainGame
->
guiFont
,
dataManager
.
GetSysString
(
1339
));
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
prev_operation
=
id
;
prev_operation
=
id
;
break
;
break
;
}
}
...
@@ -183,22 +183,22 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -183,22 +183,22 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
int
sel
=
mainGame
->
cbDBDecks
->
getSelected
();
int
sel
=
mainGame
->
cbDBDecks
->
getSelected
();
if
(
sel
==
-
1
)
if
(
sel
==
-
1
)
break
;
break
;
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
wchar_t
textBuffer
[
256
];
wchar_t
textBuffer
[
256
];
myswprintf
(
textBuffer
,
L"%ls
\n
%ls"
,
mainGame
->
cbDBDecks
->
getItem
(
sel
),
dataManager
.
GetSysString
(
1337
));
myswprintf
(
textBuffer
,
L"%ls
\n
%ls"
,
mainGame
->
cbDBDecks
->
getItem
(
sel
),
dataManager
.
GetSysString
(
1337
));
mainGame
->
SetStaticText
(
mainGame
->
stQMessage
,
310
,
mainGame
->
guiFont
,
textBuffer
);
mainGame
->
SetStaticText
(
mainGame
->
stQMessage
,
310
,
mainGame
->
guiFont
,
textBuffer
);
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
prev_operation
=
id
;
prev_operation
=
id
;
prev_sel
=
sel
;
prev_sel
=
sel
;
break
;
break
;
}
}
case
BUTTON_LEAVE_GAME
:
{
case
BUTTON_LEAVE_GAME
:
{
if
(
is_modified
&&
!
mainGame
->
chkIgnoreDeckChanges
->
isChecked
())
{
if
(
is_modified
&&
!
mainGame
->
chkIgnoreDeckChanges
->
isChecked
())
{
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
SetStaticText
(
mainGame
->
stQMessage
,
310
,
mainGame
->
guiFont
,
dataManager
.
GetSysString
(
1356
));
mainGame
->
SetStaticText
(
mainGame
->
stQMessage
,
310
,
mainGame
->
guiFont
,
dataManager
.
GetSysString
(
1356
));
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
prev_operation
=
id
;
prev_operation
=
id
;
break
;
break
;
}
}
...
@@ -368,10 +368,10 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
...
@@ -368,10 +368,10 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
}
}
case
COMBOBOX_DBDECKS
:
{
case
COMBOBOX_DBDECKS
:
{
if
(
is_modified
&&
!
mainGame
->
chkIgnoreDeckChanges
->
isChecked
())
{
if
(
is_modified
&&
!
mainGame
->
chkIgnoreDeckChanges
->
isChecked
())
{
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
SetStaticText
(
mainGame
->
stQMessage
,
310
,
mainGame
->
guiFont
,
dataManager
.
GetSysString
(
1356
));
mainGame
->
SetStaticText
(
mainGame
->
stQMessage
,
310
,
mainGame
->
guiFont
,
dataManager
.
GetSysString
(
1356
));
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
prev_operation
=
id
;
prev_operation
=
id
;
break
;
break
;
}
}
...
...
gframe/duelclient.cpp
View file @
9addd246
This diff is collapsed.
Click to expand it.
gframe/game.cpp
View file @
9addd246
...
@@ -791,7 +791,7 @@ void Game::MainLoop() {
...
@@ -791,7 +791,7 @@ void Game::MainLoop() {
atkframe
+=
0.1
f
;
atkframe
+=
0.1
f
;
atkdy
=
(
float
)
sin
(
atkframe
);
atkdy
=
(
float
)
sin
(
atkframe
);
driver
->
beginScene
(
true
,
true
,
SColor
(
0
,
0
,
0
,
0
));
driver
->
beginScene
(
true
,
true
,
SColor
(
0
,
0
,
0
,
0
));
gMutex
.
L
ock
();
gMutex
.
l
ock
();
if
(
dInfo
.
isStarted
)
{
if
(
dInfo
.
isStarted
)
{
if
(
dInfo
.
isFinished
&&
showcardcode
==
1
)
if
(
dInfo
.
isFinished
&&
showcardcode
==
1
)
soundManager
.
PlayBGM
(
BGM_WIN
);
soundManager
.
PlayBGM
(
BGM_WIN
);
...
@@ -820,7 +820,7 @@ void Game::MainLoop() {
...
@@ -820,7 +820,7 @@ void Game::MainLoop() {
}
}
DrawGUI
();
DrawGUI
();
DrawSpec
();
DrawSpec
();
gMutex
.
U
nlock
();
gMutex
.
u
nlock
();
if
(
signalFrame
>
0
)
{
if
(
signalFrame
>
0
)
{
signalFrame
--
;
signalFrame
--
;
if
(
!
signalFrame
)
if
(
!
signalFrame
)
...
...
gframe/game.h
View file @
9addd246
...
@@ -175,8 +175,7 @@ public:
...
@@ -175,8 +175,7 @@ public:
void
FlashWindow
();
void
FlashWindow
();
void
SetCursor
(
ECURSOR_ICON
icon
);
void
SetCursor
(
ECURSOR_ICON
icon
);
Mutex
gMutex
;
std
::
mutex
gMutex
;
Mutex
gBuffer
;
Signal
frameSignal
;
Signal
frameSignal
;
Signal
actionSignal
;
Signal
actionSignal
;
Signal
replaySignal
;
Signal
replaySignal
;
...
...
gframe/menu_handler.cpp
View file @
9addd246
...
@@ -80,10 +80,10 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
...
@@ -80,10 +80,10 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
hints
.
ai_flags
=
EVUTIL_AI_ADDRCONFIG
;
hints
.
ai_flags
=
EVUTIL_AI_ADDRCONFIG
;
int
status
=
evutil_getaddrinfo
(
hostname
,
port
,
&
hints
,
&
answer
);
int
status
=
evutil_getaddrinfo
(
hostname
,
port
,
&
hints
,
&
answer
);
if
(
status
!=
0
)
{
if
(
status
!=
0
)
{
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
soundManager
.
PlaySoundEffect
(
SOUND_INFO
);
soundManager
.
PlaySoundEffect
(
SOUND_INFO
);
mainGame
->
env
->
addMessageBox
(
L""
,
dataManager
.
GetSysString
(
1412
));
mainGame
->
env
->
addMessageBox
(
L""
,
dataManager
.
GetSysString
(
1412
));
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
break
;
break
;
}
else
{
}
else
{
sockaddr_in
*
sin
=
((
struct
sockaddr_in
*
)
answer
->
ai_addr
);
sockaddr_in
*
sin
=
((
struct
sockaddr_in
*
)
answer
->
ai_addr
);
...
@@ -245,12 +245,12 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
...
@@ -245,12 +245,12 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
int
sel
=
mainGame
->
lstReplayList
->
getSelected
();
int
sel
=
mainGame
->
lstReplayList
->
getSelected
();
if
(
sel
==
-
1
)
if
(
sel
==
-
1
)
break
;
break
;
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
wchar_t
textBuffer
[
256
];
wchar_t
textBuffer
[
256
];
myswprintf
(
textBuffer
,
L"%ls
\n
%ls"
,
mainGame
->
lstReplayList
->
getListItem
(
sel
),
dataManager
.
GetSysString
(
1363
));
myswprintf
(
textBuffer
,
L"%ls
\n
%ls"
,
mainGame
->
lstReplayList
->
getListItem
(
sel
),
dataManager
.
GetSysString
(
1363
));
mainGame
->
SetStaticText
(
mainGame
->
stQMessage
,
310
,
mainGame
->
guiFont
,
textBuffer
);
mainGame
->
SetStaticText
(
mainGame
->
stQMessage
,
310
,
mainGame
->
guiFont
,
textBuffer
);
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
PopupElement
(
mainGame
->
wQuery
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
prev_operation
=
id
;
prev_operation
=
id
;
prev_sel
=
sel
;
prev_sel
=
sel
;
break
;
break
;
...
@@ -259,11 +259,11 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
...
@@ -259,11 +259,11 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
int
sel
=
mainGame
->
lstReplayList
->
getSelected
();
int
sel
=
mainGame
->
lstReplayList
->
getSelected
();
if
(
sel
==
-
1
)
if
(
sel
==
-
1
)
break
;
break
;
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
wReplaySave
->
setText
(
dataManager
.
GetSysString
(
1364
));
mainGame
->
wReplaySave
->
setText
(
dataManager
.
GetSysString
(
1364
));
mainGame
->
ebRSName
->
setText
(
mainGame
->
lstReplayList
->
getListItem
(
sel
));
mainGame
->
ebRSName
->
setText
(
mainGame
->
lstReplayList
->
getListItem
(
sel
));
mainGame
->
PopupElement
(
mainGame
->
wReplaySave
);
mainGame
->
PopupElement
(
mainGame
->
wReplaySave
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
prev_operation
=
id
;
prev_operation
=
id
;
prev_sel
=
sel
;
prev_sel
=
sel
;
break
;
break
;
...
...
gframe/mymutex.h
deleted
100644 → 0
View file @
7ab508ab
#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/replay_mode.cpp
View file @
9addd246
...
@@ -90,7 +90,7 @@ int ReplayMode::ReplayThread() {
...
@@ -90,7 +90,7 @@ int ReplayMode::ReplayThread() {
exit_pending
=
false
;
exit_pending
=
false
;
current_step
=
0
;
current_step
=
0
;
if
(
mainGame
->
dInfo
.
isReplaySkiping
)
if
(
mainGame
->
dInfo
.
isReplaySkiping
)
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
while
(
is_continuing
&&
!
exit_pending
)
{
while
(
is_continuing
&&
!
exit_pending
)
{
int
result
=
process
(
pduel
);
int
result
=
process
(
pduel
);
int
len
=
result
&
0xffff
;
int
len
=
result
&
0xffff
;
...
@@ -99,7 +99,7 @@ int ReplayMode::ReplayThread() {
...
@@ -99,7 +99,7 @@ int ReplayMode::ReplayThread() {
get_message
(
pduel
,
(
byte
*
)
engineBuffer
);
get_message
(
pduel
,
(
byte
*
)
engineBuffer
);
is_continuing
=
ReplayAnalyze
(
engineBuffer
,
len
);
is_continuing
=
ReplayAnalyze
(
engineBuffer
,
len
);
if
(
is_restarting
)
{
if
(
is_restarting
)
{
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
is_restarting
=
false
;
is_restarting
=
false
;
mainGame
->
dInfo
.
isReplaySkiping
=
true
;
mainGame
->
dInfo
.
isReplaySkiping
=
true
;
Restart
(
false
);
Restart
(
false
);
...
@@ -125,7 +125,7 @@ int ReplayMode::ReplayThread() {
...
@@ -125,7 +125,7 @@ int ReplayMode::ReplayThread() {
mainGame
->
dInfo
.
isFinished
=
false
;
mainGame
->
dInfo
.
isFinished
=
false
;
mainGame
->
dInfo
.
isReplaySkiping
=
false
;
mainGame
->
dInfo
.
isReplaySkiping
=
false
;
mainGame
->
dField
.
RefreshAllCards
();
mainGame
->
dField
.
RefreshAllCards
();
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
}
}
skip_step
=
step
;
skip_step
=
step
;
current_step
=
0
;
current_step
=
0
;
...
@@ -135,7 +135,7 @@ int ReplayMode::ReplayThread() {
...
@@ -135,7 +135,7 @@ int ReplayMode::ReplayThread() {
if
(
mainGame
->
dInfo
.
isReplaySkiping
)
{
if
(
mainGame
->
dInfo
.
isReplaySkiping
)
{
mainGame
->
dInfo
.
isReplaySkiping
=
false
;
mainGame
->
dInfo
.
isReplaySkiping
=
false
;
mainGame
->
dField
.
RefreshAllCards
();
mainGame
->
dField
.
RefreshAllCards
();
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
}
}
EndDuel
();
EndDuel
();
return
0
;
return
0
;
...
@@ -228,26 +228,26 @@ void ReplayMode::EndDuel() {
...
@@ -228,26 +228,26 @@ void ReplayMode::EndDuel() {
end_duel
(
pduel
);
end_duel
(
pduel
);
if
(
!
is_closing
)
{
if
(
!
is_closing
)
{
mainGame
->
actionSignal
.
Reset
();
mainGame
->
actionSignal
.
Reset
();
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
stMessage
->
setText
(
dataManager
.
GetSysString
(
1501
));
mainGame
->
stMessage
->
setText
(
dataManager
.
GetSysString
(
1501
));
if
(
mainGame
->
wCardSelect
->
isVisible
())
if
(
mainGame
->
wCardSelect
->
isVisible
())
mainGame
->
HideElement
(
mainGame
->
wCardSelect
);
mainGame
->
HideElement
(
mainGame
->
wCardSelect
);
mainGame
->
PopupElement
(
mainGame
->
wMessage
);
mainGame
->
PopupElement
(
mainGame
->
wMessage
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
mainGame
->
actionSignal
.
Wait
();
mainGame
->
actionSignal
.
Wait
();
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
dInfo
.
isStarted
=
false
;
mainGame
->
dInfo
.
isStarted
=
false
;
mainGame
->
dInfo
.
isFinished
=
true
;
mainGame
->
dInfo
.
isFinished
=
true
;
mainGame
->
dInfo
.
isReplay
=
false
;
mainGame
->
dInfo
.
isReplay
=
false
;
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
mainGame
->
closeDoneSignal
.
Reset
();
mainGame
->
closeDoneSignal
.
Reset
();
mainGame
->
closeSignal
.
Set
();
mainGame
->
closeSignal
.
Set
();
mainGame
->
closeDoneSignal
.
Wait
();
mainGame
->
closeDoneSignal
.
Wait
();
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
ShowElement
(
mainGame
->
wReplay
);
mainGame
->
ShowElement
(
mainGame
->
wReplay
);
mainGame
->
stTip
->
setVisible
(
false
);
mainGame
->
stTip
->
setVisible
(
false
);
mainGame
->
device
->
setEventReceiver
(
&
mainGame
->
menuHandler
);
mainGame
->
device
->
setEventReceiver
(
&
mainGame
->
menuHandler
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
if
(
exit_on_return
)
if
(
exit_on_return
)
mainGame
->
device
->
closeDevice
();
mainGame
->
device
->
closeDevice
();
}
}
...
@@ -291,9 +291,9 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
...
@@ -291,9 +291,9 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
return
true
;
return
true
;
}
}
if
(
is_swaping
)
{
if
(
is_swaping
)
{
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
dField
.
ReplaySwap
();
mainGame
->
dField
.
ReplaySwap
();
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
is_swaping
=
false
;
is_swaping
=
false
;
}
}
char
*
offset
=
pbuf
;
char
*
offset
=
pbuf
;
...
@@ -304,12 +304,12 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
...
@@ -304,12 +304,12 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
if
(
mainGame
->
dInfo
.
isReplaySkiping
)
{
if
(
mainGame
->
dInfo
.
isReplaySkiping
)
{
mainGame
->
dInfo
.
isReplaySkiping
=
false
;
mainGame
->
dInfo
.
isReplaySkiping
=
false
;
mainGame
->
dField
.
RefreshAllCards
();
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
->
stMessage
->
setText
(
L"Error occurs."
);
mainGame
->
PopupElement
(
mainGame
->
wMessage
);
mainGame
->
PopupElement
(
mainGame
->
wMessage
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
mainGame
->
actionSignal
.
Reset
();
mainGame
->
actionSignal
.
Reset
();
mainGame
->
actionSignal
.
Wait
();
mainGame
->
actionSignal
.
Wait
();
return
false
;
return
false
;
...
@@ -323,7 +323,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
...
@@ -323,7 +323,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
if
(
mainGame
->
dInfo
.
isReplaySkiping
)
{
if
(
mainGame
->
dInfo
.
isReplaySkiping
)
{
mainGame
->
dInfo
.
isReplaySkiping
=
false
;
mainGame
->
dInfo
.
isReplaySkiping
=
false
;
mainGame
->
dField
.
RefreshAllCards
();
mainGame
->
dField
.
RefreshAllCards
();
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
}
}
pbuf
+=
2
;
pbuf
+=
2
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
...
@@ -505,7 +505,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
...
@@ -505,7 +505,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
if
(
skip_turn
==
0
)
{
if
(
skip_turn
==
0
)
{
mainGame
->
dInfo
.
isReplaySkiping
=
false
;
mainGame
->
dInfo
.
isReplaySkiping
=
false
;
mainGame
->
dField
.
RefreshAllCards
();
mainGame
->
dField
.
RefreshAllCards
();
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
}
}
}
}
player
=
BufferIO
::
ReadInt8
(
pbuf
);
player
=
BufferIO
::
ReadInt8
(
pbuf
);
...
@@ -842,7 +842,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
...
@@ -842,7 +842,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
mainGame
->
dInfo
.
isFinished
=
false
;
mainGame
->
dInfo
.
isFinished
=
false
;
mainGame
->
dInfo
.
isReplaySkiping
=
false
;
mainGame
->
dInfo
.
isReplaySkiping
=
false
;
mainGame
->
dField
.
RefreshAllCards
();
mainGame
->
dField
.
RefreshAllCards
();
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
}
}
}
}
if
(
is_pausing
)
{
if
(
is_pausing
)
{
...
...
gframe/single_mode.cpp
View file @
9addd246
...
@@ -79,7 +79,7 @@ int SingleMode::SinglePlayThread() {
...
@@ -79,7 +79,7 @@ int SingleMode::SinglePlayThread() {
rh
.
version
=
PRO_VERSION
;
rh
.
version
=
PRO_VERSION
;
rh
.
flag
=
REPLAY_SINGLE_MODE
;
rh
.
flag
=
REPLAY_SINGLE_MODE
;
rh
.
seed
=
seed
;
rh
.
seed
=
seed
;
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
HideElement
(
mainGame
->
wSinglePlay
);
mainGame
->
HideElement
(
mainGame
->
wSinglePlay
);
mainGame
->
ClearCardInfo
();
mainGame
->
ClearCardInfo
();
mainGame
->
wCardImg
->
setVisible
(
true
);
mainGame
->
wCardImg
->
setVisible
(
true
);
...
@@ -93,7 +93,7 @@ int SingleMode::SinglePlayThread() {
...
@@ -93,7 +93,7 @@ int SingleMode::SinglePlayThread() {
mainGame
->
dInfo
.
isFinished
=
false
;
mainGame
->
dInfo
.
isFinished
=
false
;
mainGame
->
dInfo
.
isSingleMode
=
true
;
mainGame
->
dInfo
.
isSingleMode
=
true
;
mainGame
->
device
->
setEventReceiver
(
&
mainGame
->
dField
);
mainGame
->
device
->
setEventReceiver
(
&
mainGame
->
dField
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
char
engineBuffer
[
0x1000
];
char
engineBuffer
[
0x1000
];
is_closing
=
false
;
is_closing
=
false
;
is_continuing
=
true
;
is_continuing
=
true
;
...
@@ -125,7 +125,7 @@ int SingleMode::SinglePlayThread() {
...
@@ -125,7 +125,7 @@ int SingleMode::SinglePlayThread() {
}
}
}
}
last_replay
.
EndRecord
();
last_replay
.
EndRecord
();
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
time_t
nowtime
=
time
(
NULL
);
time_t
nowtime
=
time
(
NULL
);
tm
*
localedtime
=
localtime
(
&
nowtime
);
tm
*
localedtime
=
localtime
(
&
nowtime
);
wchar_t
timetext
[
40
];
wchar_t
timetext
[
40
];
...
@@ -134,7 +134,7 @@ int SingleMode::SinglePlayThread() {
...
@@ -134,7 +134,7 @@ int SingleMode::SinglePlayThread() {
if
(
!
mainGame
->
chkAutoSaveReplay
->
isChecked
())
{
if
(
!
mainGame
->
chkAutoSaveReplay
->
isChecked
())
{
mainGame
->
wReplaySave
->
setText
(
dataManager
.
GetSysString
(
1340
));
mainGame
->
wReplaySave
->
setText
(
dataManager
.
GetSysString
(
1340
));
mainGame
->
PopupElement
(
mainGame
->
wReplaySave
);
mainGame
->
PopupElement
(
mainGame
->
wReplaySave
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
mainGame
->
replaySignal
.
Reset
();
mainGame
->
replaySignal
.
Reset
();
mainGame
->
replaySignal
.
Wait
();
mainGame
->
replaySignal
.
Wait
();
}
else
{
}
else
{
...
@@ -143,26 +143,26 @@ int SingleMode::SinglePlayThread() {
...
@@ -143,26 +143,26 @@ int SingleMode::SinglePlayThread() {
myswprintf
(
msgbuf
,
dataManager
.
GetSysString
(
1367
),
timetext
);
myswprintf
(
msgbuf
,
dataManager
.
GetSysString
(
1367
),
timetext
);
mainGame
->
SetStaticText
(
mainGame
->
stACMessage
,
310
,
mainGame
->
guiFont
,
msgbuf
);
mainGame
->
SetStaticText
(
mainGame
->
stACMessage
,
310
,
mainGame
->
guiFont
,
msgbuf
);
mainGame
->
PopupElement
(
mainGame
->
wACMessage
,
20
);
mainGame
->
PopupElement
(
mainGame
->
wACMessage
,
20
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
mainGame
->
WaitFrameSignal
(
30
);
mainGame
->
WaitFrameSignal
(
30
);
}
}
if
(
mainGame
->
actionParam
)
if
(
mainGame
->
actionParam
)
last_replay
.
SaveReplay
(
mainGame
->
ebRSName
->
getText
());
last_replay
.
SaveReplay
(
mainGame
->
ebRSName
->
getText
());
end_duel
(
pduel
);
end_duel
(
pduel
);
if
(
!
is_closing
)
{
if
(
!
is_closing
)
{
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
dInfo
.
isStarted
=
false
;
mainGame
->
dInfo
.
isStarted
=
false
;
mainGame
->
dInfo
.
isFinished
=
true
;
mainGame
->
dInfo
.
isFinished
=
true
;
mainGame
->
dInfo
.
isSingleMode
=
false
;
mainGame
->
dInfo
.
isSingleMode
=
false
;
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
mainGame
->
closeDoneSignal
.
Reset
();
mainGame
->
closeDoneSignal
.
Reset
();
mainGame
->
closeSignal
.
Set
();
mainGame
->
closeSignal
.
Set
();
mainGame
->
closeDoneSignal
.
Wait
();
mainGame
->
closeDoneSignal
.
Wait
();
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
ShowElement
(
mainGame
->
wSinglePlay
);
mainGame
->
ShowElement
(
mainGame
->
wSinglePlay
);
mainGame
->
stTip
->
setVisible
(
false
);
mainGame
->
stTip
->
setVisible
(
false
);
mainGame
->
device
->
setEventReceiver
(
&
mainGame
->
menuHandler
);
mainGame
->
device
->
setEventReceiver
(
&
mainGame
->
menuHandler
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
if
(
exit_on_return
)
if
(
exit_on_return
)
mainGame
->
device
->
closeDevice
();
mainGame
->
device
->
closeDevice
();
}
}
...
@@ -732,9 +732,9 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
...
@@ -732,9 +732,9 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
pbuf
++
;
pbuf
++
;
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
DuelClient
::
ClientAnalyze
(
offset
,
pbuf
-
offset
);
SinglePlayReload
();
SinglePlayReload
();
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
dField
.
RefreshAllCards
();
mainGame
->
dField
.
RefreshAllCards
();
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
break
;
break
;
}
}
case
MSG_AI_NAME
:
{
case
MSG_AI_NAME
:
{
...
@@ -756,10 +756,10 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
...
@@ -756,10 +756,10 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
pbuf
+=
len
+
1
;
pbuf
+=
len
+
1
;
memcpy
(
msgbuf
,
begin
,
len
+
1
);
memcpy
(
msgbuf
,
begin
,
len
+
1
);
BufferIO
::
DecodeUTF8
(
msgbuf
,
msg
);
BufferIO
::
DecodeUTF8
(
msgbuf
,
msg
);
mainGame
->
gMutex
.
L
ock
();
mainGame
->
gMutex
.
l
ock
();
mainGame
->
SetStaticText
(
mainGame
->
stMessage
,
310
,
mainGame
->
guiFont
,
msg
);
mainGame
->
SetStaticText
(
mainGame
->
stMessage
,
310
,
mainGame
->
guiFont
,
msg
);
mainGame
->
PopupElement
(
mainGame
->
wMessage
);
mainGame
->
PopupElement
(
mainGame
->
wMessage
);
mainGame
->
gMutex
.
U
nlock
();
mainGame
->
gMutex
.
u
nlock
();
mainGame
->
actionSignal
.
Reset
();
mainGame
->
actionSignal
.
Reset
();
mainGame
->
actionSignal
.
Wait
();
mainGame
->
actionSignal
.
Wait
();
break
;
break
;
...
...
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