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
4580cf55
Commit
4580cf55
authored
Dec 04, 2017
by
VanillaSalt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix replay mode
parent
78dd1715
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
98 additions
and
147 deletions
+98
-147
gframe/client_field.cpp
gframe/client_field.cpp
+3
-4
gframe/duelclient.cpp
gframe/duelclient.cpp
+2
-0
gframe/replay_mode.cpp
gframe/replay_mode.cpp
+89
-141
gframe/replay_mode.h
gframe/replay_mode.h
+2
-0
ocgcore
ocgcore
+1
-1
script
script
+1
-1
No files found.
gframe/client_field.cpp
View file @
4580cf55
...
...
@@ -633,10 +633,9 @@ void ClientField::ReplaySwap() {
}
mainGame
->
dInfo
.
isFirst
=
!
mainGame
->
dInfo
.
isFirst
;
std
::
swap
(
mainGame
->
dInfo
.
lp
[
0
],
mainGame
->
dInfo
.
lp
[
1
]);
for
(
int
i
=
0
;
i
<
16
;
++
i
)
std
::
swap
(
mainGame
->
dInfo
.
strLP
[
0
][
i
],
mainGame
->
dInfo
.
strLP
[
1
][
i
]);
for
(
int
i
=
0
;
i
<
20
;
++
i
)
std
::
swap
(
mainGame
->
dInfo
.
hostname
[
i
],
mainGame
->
dInfo
.
clientname
[
i
]);
std
::
swap
(
mainGame
->
dInfo
.
strLP
[
0
],
mainGame
->
dInfo
.
strLP
[
1
]);
std
::
swap
(
mainGame
->
dInfo
.
hostname
,
mainGame
->
dInfo
.
clientname
);
std
::
swap
(
mainGame
->
dInfo
.
hostname_tag
,
mainGame
->
dInfo
.
clientname_tag
);
for
(
auto
chit
=
chains
.
begin
();
chit
!=
chains
.
end
();
++
chit
)
{
chit
->
controler
=
1
-
chit
->
controler
;
GetChainLocation
(
chit
->
controler
,
chit
->
location
,
chit
->
sequence
,
&
chit
->
chain_pos
);
...
...
gframe/duelclient.cpp
View file @
4580cf55
...
...
@@ -1026,6 +1026,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
ClientCard
*
pcard
;
mainGame
->
dField
.
activatable_cards
.
clear
();
mainGame
->
dField
.
activatable_descs
.
clear
();
mainGame
->
dField
.
conti_cards
.
clear
();
count
=
BufferIO
::
ReadInt8
(
pbuf
);
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
code
=
BufferIO
::
ReadInt32
(
pbuf
);
...
...
@@ -1155,6 +1156,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
}
mainGame
->
dField
.
activatable_cards
.
clear
();
mainGame
->
dField
.
activatable_descs
.
clear
();
mainGame
->
dField
.
conti_cards
.
clear
();
count
=
BufferIO
::
ReadInt8
(
pbuf
);
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
code
=
BufferIO
::
ReadInt32
(
pbuf
);
...
...
gframe/replay_mode.cpp
View file @
4580cf55
...
...
@@ -60,107 +60,29 @@ bool ReplayMode::ReadReplayResponse() {
int
ReplayMode
::
ReplayThread
(
void
*
param
)
{
const
ReplayHeader
&
rh
=
cur_replay
.
pheader
;
mainGame
->
dInfo
.
isFirst
=
true
;
mtrandom
rnd
;
int
seed
=
rh
.
seed
;
rnd
.
reset
(
seed
);
if
(
rh
.
flag
&
REPLAY_TAG
)
{
cur_replay
.
ReadName
(
mainGame
->
dInfo
.
hostname
);
cur_replay
.
ReadName
(
mainGame
->
dInfo
.
hostname_tag
);
cur_replay
.
ReadName
(
mainGame
->
dInfo
.
clientname_tag
);
cur_replay
.
ReadName
(
mainGame
->
dInfo
.
clientname
);
mainGame
->
dInfo
.
isTag
=
true
;
mainGame
->
dInfo
.
tag_player
[
0
]
=
false
;
mainGame
->
dInfo
.
tag_player
[
1
]
=
false
;
}
else
{
cur_replay
.
ReadName
(
mainGame
->
dInfo
.
hostname
);
cur_replay
.
ReadName
(
mainGame
->
dInfo
.
clientname
);
mainGame
->
dInfo
.
isTag
=
false
;
}
if
(
rh
.
flag
&
REPLAY_SINGLE_MODE
)
{
mainGame
->
dInfo
.
isTag
=
!!
(
rh
.
flag
&
REPLAY_TAG
);
mainGame
->
dInfo
.
isSingleMode
=
!!
(
rh
.
flag
&
REPLAY_SINGLE_MODE
);
mainGame
->
dInfo
.
tag_player
[
0
]
=
false
;
mainGame
->
dInfo
.
tag_player
[
1
]
=
false
;
if
(
mainGame
->
dInfo
.
isSingleMode
)
{
set_script_reader
((
script_reader
)
SingleMode
::
ScriptReader
);
set_card_reader
((
card_reader
)
DataManager
::
CardReader
);
set_message_handler
((
message_handler
)
MessageHandler
);
mainGame
->
dInfo
.
isSingleMode
=
true
;
}
else
{
set_script_reader
(
default_script_reader
);
set_card_reader
((
card_reader
)
DataManager
::
CardReader
);
set_message_handler
((
message_handler
)
MessageHandler
);
mainGame
->
dInfo
.
isSingleMode
=
false
;
}
pduel
=
create_duel
(
rnd
.
rand
());
int
start_lp
=
cur_replay
.
ReadInt32
();
int
start_hand
=
cur_replay
.
ReadInt32
();
int
draw_count
=
cur_replay
.
ReadInt32
();
int
opt
=
cur_replay
.
ReadInt32
();
int
duel_rule
=
opt
>>
16
;
mainGame
->
dInfo
.
duel_rule
=
duel_rule
;
set_player_info
(
pduel
,
0
,
start_lp
,
start_hand
,
draw_count
);
set_player_info
(
pduel
,
1
,
start_lp
,
start_hand
,
draw_count
);
mainGame
->
dInfo
.
lp
[
0
]
=
start_lp
;
mainGame
->
dInfo
.
lp
[
1
]
=
start_lp
;
if
(
!
mainGame
->
dInfo
.
isSingleMode
)
{
if
(
!
(
opt
&
DUEL_TAG_MODE
))
{
int
main
=
cur_replay
.
ReadInt32
();
for
(
int
i
=
0
;
i
<
main
;
++
i
)
new_card
(
pduel
,
cur_replay
.
ReadInt32
(),
0
,
0
,
LOCATION_DECK
,
0
,
POS_FACEDOWN_DEFENSE
);
int
extra
=
cur_replay
.
ReadInt32
();
for
(
int
i
=
0
;
i
<
extra
;
++
i
)
new_card
(
pduel
,
cur_replay
.
ReadInt32
(),
0
,
0
,
LOCATION_EXTRA
,
0
,
POS_FACEDOWN_DEFENSE
);
mainGame
->
dField
.
Initial
(
0
,
main
,
extra
);
main
=
cur_replay
.
ReadInt32
();
for
(
int
i
=
0
;
i
<
main
;
++
i
)
new_card
(
pduel
,
cur_replay
.
ReadInt32
(),
1
,
1
,
LOCATION_DECK
,
0
,
POS_FACEDOWN_DEFENSE
);
extra
=
cur_replay
.
ReadInt32
();
for
(
int
i
=
0
;
i
<
extra
;
++
i
)
new_card
(
pduel
,
cur_replay
.
ReadInt32
(),
1
,
1
,
LOCATION_EXTRA
,
0
,
POS_FACEDOWN_DEFENSE
);
mainGame
->
dField
.
Initial
(
1
,
main
,
extra
);
}
else
{
int
main
=
cur_replay
.
ReadInt32
();
for
(
int
i
=
0
;
i
<
main
;
++
i
)
new_card
(
pduel
,
cur_replay
.
ReadInt32
(),
0
,
0
,
LOCATION_DECK
,
0
,
POS_FACEDOWN_DEFENSE
);
int
extra
=
cur_replay
.
ReadInt32
();
for
(
int
i
=
0
;
i
<
extra
;
++
i
)
new_card
(
pduel
,
cur_replay
.
ReadInt32
(),
0
,
0
,
LOCATION_EXTRA
,
0
,
POS_FACEDOWN_DEFENSE
);
mainGame
->
dField
.
Initial
(
0
,
main
,
extra
);
main
=
cur_replay
.
ReadInt32
();
for
(
int
i
=
0
;
i
<
main
;
++
i
)
new_tag_card
(
pduel
,
cur_replay
.
ReadInt32
(),
0
,
LOCATION_DECK
);
extra
=
cur_replay
.
ReadInt32
();
for
(
int
i
=
0
;
i
<
extra
;
++
i
)
new_tag_card
(
pduel
,
cur_replay
.
ReadInt32
(),
0
,
LOCATION_EXTRA
);
main
=
cur_replay
.
ReadInt32
();
for
(
int
i
=
0
;
i
<
main
;
++
i
)
new_card
(
pduel
,
cur_replay
.
ReadInt32
(),
1
,
1
,
LOCATION_DECK
,
0
,
POS_FACEDOWN_DEFENSE
);
extra
=
cur_replay
.
ReadInt32
();
for
(
int
i
=
0
;
i
<
extra
;
++
i
)
new_card
(
pduel
,
cur_replay
.
ReadInt32
(),
1
,
1
,
LOCATION_EXTRA
,
0
,
POS_FACEDOWN_DEFENSE
);
mainGame
->
dField
.
Initial
(
1
,
main
,
extra
);
main
=
cur_replay
.
ReadInt32
();
for
(
int
i
=
0
;
i
<
main
;
++
i
)
new_tag_card
(
pduel
,
cur_replay
.
ReadInt32
(),
1
,
LOCATION_DECK
);
extra
=
cur_replay
.
ReadInt32
();
for
(
int
i
=
0
;
i
<
extra
;
++
i
)
new_tag_card
(
pduel
,
cur_replay
.
ReadInt32
(),
1
,
LOCATION_EXTRA
);
}
}
else
{
char
filename
[
256
];
size_t
slen
=
cur_replay
.
ReadInt16
();
cur_replay
.
ReadData
(
filename
,
slen
);
filename
[
slen
]
=
0
;
if
(
!
preload_script
(
pduel
,
filename
,
slen
))
{
end_duel
(
pduel
);
return
0
;
}
if
(
!
StartDuel
())
{
EndDuel
();
return
0
;
}
myswprintf
(
mainGame
->
dInfo
.
strLP
[
0
],
L"%d"
,
mainGame
->
dInfo
.
lp
[
0
]);
myswprintf
(
mainGame
->
dInfo
.
strLP
[
1
],
L"%d"
,
mainGame
->
dInfo
.
lp
[
1
]);
mainGame
->
dInfo
.
turn
=
0
;
start_duel
(
pduel
,
opt
);
mainGame
->
dInfo
.
isStarted
=
true
;
mainGame
->
dInfo
.
isReplay
=
true
;
mainGame
->
dInfo
.
isReplaySkiping
=
(
skip_turn
>
0
);
char
engineBuffer
[
0x1000
];
is_continuing
=
true
;
skip_step
=
0
;
if
(
mainGame
->
dInfo
.
isSingleMode
)
{
int
len
=
get_message
(
pduel
,
(
byte
*
)
engineBuffer
);
if
(
len
>
0
)
...
...
@@ -173,7 +95,6 @@ int ReplayMode::ReplayThread(void* param) {
}
exit_pending
=
false
;
current_step
=
0
;
skip_step
=
0
;
if
(
mainGame
->
dInfo
.
isReplaySkiping
)
mainGame
->
gMutex
.
Lock
();
while
(
is_continuing
&&
!
exit_pending
)
{
...
...
@@ -183,6 +104,31 @@ int ReplayMode::ReplayThread(void* param) {
if
(
len
>
0
)
{
get_message
(
pduel
,
(
byte
*
)
engineBuffer
);
is_continuing
=
ReplayAnalyze
(
engineBuffer
,
len
);
if
(
is_restarting
)
{
is_restarting
=
false
;
int
step
=
current_step
-
1
;
if
(
step
<
0
)
step
=
0
;
if
(
mainGame
->
dInfo
.
isSingleMode
)
{
is_continuing
=
true
;
skip_step
=
0
;
int
len
=
get_message
(
pduel
,
(
byte
*
)
engineBuffer
);
if
(
len
>
0
)
{
mainGame
->
gMutex
.
Unlock
();
is_continuing
=
ReplayAnalyze
(
engineBuffer
,
len
);
mainGame
->
gMutex
.
Lock
();
}
}
if
(
step
==
0
)
{
Pause
(
true
,
false
);
mainGame
->
dInfo
.
isStarted
=
true
;
mainGame
->
dInfo
.
isReplaySkiping
=
false
;
mainGame
->
dField
.
RefreshAllCards
();
mainGame
->
gMutex
.
Unlock
();
}
skip_step
=
step
;
current_step
=
0
;
}
}
}
if
(
mainGame
->
dInfo
.
isReplaySkiping
)
{
...
...
@@ -190,63 +136,30 @@ int ReplayMode::ReplayThread(void* param) {
mainGame
->
dField
.
RefreshAllCards
();
mainGame
->
gMutex
.
Unlock
();
}
end_duel
(
pduel
);
if
(
!
is_closing
)
{
mainGame
->
actionSignal
.
Reset
();
mainGame
->
gMutex
.
Lock
();
mainGame
->
stMessage
->
setText
(
dataManager
.
GetSysString
(
1501
));
if
(
mainGame
->
wCardSelect
->
isVisible
())
mainGame
->
HideElement
(
mainGame
->
wCardSelect
);
mainGame
->
PopupElement
(
mainGame
->
wMessage
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
actionSignal
.
Wait
();
mainGame
->
gMutex
.
Lock
();
mainGame
->
dInfo
.
isStarted
=
false
;
mainGame
->
dInfo
.
isReplay
=
false
;
mainGame
->
gMutex
.
Unlock
();
mainGame
->
closeDoneSignal
.
Reset
();
mainGame
->
closeSignal
.
Set
();
mainGame
->
closeDoneSignal
.
Wait
();
mainGame
->
gMutex
.
Lock
();
mainGame
->
ShowElement
(
mainGame
->
wReplay
);
mainGame
->
stTip
->
setVisible
(
false
);
mainGame
->
device
->
setEventReceiver
(
&
mainGame
->
menuHandler
);
mainGame
->
gMutex
.
Unlock
();
if
(
exit_on_return
)
mainGame
->
device
->
closeDevice
();
}
EndDuel
();
return
0
;
}
void
ReplayMode
::
Restart
(
bool
refresh
)
{
end_duel
(
pduel
);
mainGame
->
dInfo
.
isStarted
=
false
;
mainGame
->
dField
.
Clear
();
//mainGame->device->setEventReceiver(&mainGame->dField);
cur_replay
.
Rewind
();
bool
ReplayMode
::
StartDuel
()
{
const
ReplayHeader
&
rh
=
cur_replay
.
pheader
;
//mainGame->dInfo.isFirst = true;
mtrandom
rnd
;
int
seed
=
rh
.
seed
;
rnd
.
reset
(
seed
);
if
(
rh
.
flag
&
REPLAY_TAG
)
{
if
(
mainGame
->
dInfo
.
isTag
)
{
cur_replay
.
ReadName
(
mainGame
->
dInfo
.
hostname
);
cur_replay
.
ReadName
(
mainGame
->
dInfo
.
hostname_tag
);
cur_replay
.
ReadName
(
mainGame
->
dInfo
.
clientname_tag
);
cur_replay
.
ReadName
(
mainGame
->
dInfo
.
clientname
);
mainGame
->
dInfo
.
isTag
=
true
;
mainGame
->
dInfo
.
tag_player
[
0
]
=
false
;
mainGame
->
dInfo
.
tag_player
[
1
]
=
false
;
}
else
{
cur_replay
.
ReadName
(
mainGame
->
dInfo
.
hostname
);
cur_replay
.
ReadName
(
mainGame
->
dInfo
.
clientname
);
}
//set_card_reader((card_reader)DataManager::CardReader);
//set_message_handler((message_handler)MessageHandler);
pduel
=
create_duel
(
rnd
.
rand
());
int
start_lp
=
cur_replay
.
ReadInt32
();
int
start_hand
=
cur_replay
.
ReadInt32
();
int
draw_count
=
cur_replay
.
ReadInt32
();
int
opt
=
cur_replay
.
ReadInt32
();
int
duel_rule
=
opt
>>
16
;
mainGame
->
dInfo
.
duel_rule
=
duel_rule
;
set_player_info
(
pduel
,
0
,
start_lp
,
start_hand
,
draw_count
);
set_player_info
(
pduel
,
1
,
start_lp
,
start_hand
,
draw_count
);
mainGame
->
dInfo
.
lp
[
0
]
=
start_lp
;
...
...
@@ -304,11 +217,51 @@ void ReplayMode::Restart(bool refresh) {
cur_replay
.
ReadData
(
filename
,
slen
);
filename
[
slen
]
=
0
;
if
(
!
preload_script
(
pduel
,
filename
,
slen
))
{
end_duel
(
pduel
);
return
;
return
false
;
}
}
start_duel
(
pduel
,
opt
);
return
true
;
}
void
ReplayMode
::
EndDuel
()
{
end_duel
(
pduel
);
if
(
!
is_closing
)
{
mainGame
->
actionSignal
.
Reset
();
mainGame
->
gMutex
.
Lock
();
mainGame
->
stMessage
->
setText
(
dataManager
.
GetSysString
(
1501
));
if
(
mainGame
->
wCardSelect
->
isVisible
())
mainGame
->
HideElement
(
mainGame
->
wCardSelect
);
mainGame
->
PopupElement
(
mainGame
->
wMessage
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
actionSignal
.
Wait
();
mainGame
->
gMutex
.
Lock
();
mainGame
->
dInfo
.
isStarted
=
false
;
mainGame
->
dInfo
.
isReplay
=
false
;
mainGame
->
gMutex
.
Unlock
();
mainGame
->
closeDoneSignal
.
Reset
();
mainGame
->
closeSignal
.
Set
();
mainGame
->
closeDoneSignal
.
Wait
();
mainGame
->
gMutex
.
Lock
();
mainGame
->
ShowElement
(
mainGame
->
wReplay
);
mainGame
->
stTip
->
setVisible
(
false
);
mainGame
->
device
->
setEventReceiver
(
&
mainGame
->
menuHandler
);
mainGame
->
gMutex
.
Unlock
();
if
(
exit_on_return
)
mainGame
->
device
->
closeDevice
();
}
}
void
ReplayMode
::
Restart
(
bool
refresh
)
{
end_duel
(
pduel
);
mainGame
->
dInfo
.
isStarted
=
false
;
mainGame
->
dField
.
Clear
();
//mainGame->device->setEventReceiver(&mainGame->dField);
cur_replay
.
Rewind
();
//mainGame->dInfo.isFirst = true;
mainGame
->
dInfo
.
tag_player
[
0
]
=
false
;
mainGame
->
dInfo
.
tag_player
[
1
]
=
false
;
if
(
!
StartDuel
())
{
EndDuel
();
}
if
(
refresh
)
{
mainGame
->
dField
.
RefreshAllCards
();
mainGame
->
dInfo
.
isStarted
=
true
;
...
...
@@ -318,17 +271,12 @@ void ReplayMode::Restart(bool refresh) {
is_restarting
=
true
;
}
void
ReplayMode
::
Undo
()
{
if
(
skip_step
>
0
||
current_step
==
0
)
return
;
mainGame
->
dInfo
.
isReplaySkiping
=
true
;
Restart
(
false
);
skip_step
=
current_step
-
1
;
if
(
skip_step
<
0
)
skip_step
=
0
;
current_step
=
0
;
if
(
skip_step
)
{
mainGame
->
dInfo
.
isReplaySkiping
=
true
;
mainGame
->
gMutex
.
Lock
();
Pause
(
false
,
false
);
}
else
mainGame
->
dInfo
.
isReplaySkiping
=
false
;
mainGame
->
gMutex
.
Lock
();
Pause
(
false
,
false
);
}
bool
ReplayMode
::
ReplayAnalyze
(
char
*
msg
,
unsigned
int
len
)
{
char
*
pbuf
=
msg
;
...
...
@@ -338,7 +286,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
if
(
is_closing
)
return
false
;
if
(
is_restarting
)
{
is_restarting
=
false
;
//
is_restarting = false;
return
true
;
}
if
(
is_swaping
)
{
...
...
@@ -865,6 +813,7 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
}
}
if
(
pauseable
)
{
current_step
++
;
if
(
skip_step
)
{
skip_step
--
;
if
(
skip_step
==
0
)
{
...
...
@@ -881,7 +830,6 @@ bool ReplayMode::ReplayAnalyze(char* msg, unsigned int len) {
mainGame
->
actionSignal
.
Wait
();
is_paused
=
false
;
}
current_step
++
;
}
}
return
true
;
...
...
@@ -901,7 +849,7 @@ void ReplayMode::ReplayRefresh(int flag) {
/*len = */
query_field_card
(
pduel
,
1
,
LOCATION_HAND
,
flag
,
queryBuffer
,
0
);
mainGame
->
dField
.
UpdateFieldCard
(
mainGame
->
LocalPlayer
(
1
),
LOCATION_HAND
,
(
char
*
)
queryBuffer
);
}
void
ReplayMode
::
ReplayRefreshHand
(
int
player
,
int
flag
)
{
void
ReplayMode
::
ReplayRefreshHand
(
int
player
,
int
flag
)
{
unsigned
char
queryBuffer
[
0x2000
];
/*int len = */
query_field_card
(
pduel
,
player
,
LOCATION_HAND
,
flag
,
queryBuffer
,
0
);
mainGame
->
dField
.
UpdateFieldCard
(
mainGame
->
LocalPlayer
(
player
),
LOCATION_HAND
,
(
char
*
)
queryBuffer
);
...
...
gframe/replay_mode.h
View file @
4580cf55
...
...
@@ -33,6 +33,8 @@ public:
static
void
Pause
(
bool
is_pause
,
bool
is_step
);
static
bool
ReadReplayResponse
();
static
int
ReplayThread
(
void
*
param
);
static
bool
StartDuel
();
static
void
EndDuel
();
static
void
Restart
(
bool
refresh
);
static
void
Undo
();
static
bool
ReplayAnalyze
(
char
*
msg
,
unsigned
int
len
);
...
...
ocgcore
@
18bfd819
Subproject commit
a02235065040a6fa6ce44a37ddfba953e0de9e84
Subproject commit
18bfd81912b020e799832a6068481756929e51a8
script
@
0da96933
Subproject commit
ef47b28ebdcecb27007e749f7275febf92bd71f2
Subproject commit
0da9693357cd309e5539f853566b1ba3921866e0
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