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
REIKAI
ygopro
Commits
d1c4b218
Commit
d1c4b218
authored
Dec 13, 2017
by
edo9300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added replay recording without writing
parent
595e266a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
64 additions
and
45 deletions
+64
-45
gframe/duelclient.cpp
gframe/duelclient.cpp
+34
-10
gframe/duelclient.h
gframe/duelclient.h
+0
-1
gframe/replay.cpp
gframe/replay.cpp
+22
-26
gframe/replay.h
gframe/replay.h
+2
-2
gframe/single_duel.cpp
gframe/single_duel.cpp
+2
-2
gframe/single_mode.cpp
gframe/single_mode.cpp
+2
-2
gframe/tag_duel.cpp
gframe/tag_duel.cpp
+2
-2
No files found.
gframe/duelclient.cpp
View file @
d1c4b218
...
...
@@ -28,7 +28,6 @@ mtrandom DuelClient::rnd;
std
::
vector
<
BufferIO
::
ReplayPacket
>
DuelClient
::
replay_stream
;
Replay
DuelClient
::
last_replay
;
bool
DuelClient
::
old_replay
=
true
;
bool
DuelClient
::
is_refreshing
=
false
;
int
DuelClient
::
match_kill
=
0
;
...
...
@@ -797,8 +796,8 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
ReplayHeader
pheader
;
memcpy
(
&
pheader
,
prep
,
sizeof
(
ReplayHeader
));
replay_stream
.
push_back
(
BufferIO
::
ReplayPacket
(
OLD_REPLAY_MODE
,
prep
,
len
-
1
));
if
(
old_replay
&&
mainGame
->
saveReplay
)
{
last_replay
.
BeginRecord
();
if
(
mainGame
->
saveReplay
)
{
last_replay
.
BeginRecord
(
false
);
last_replay
.
WriteHeader
(
pheader
);
last_replay
.
pheader
.
id
=
0x58707279
;
last_replay
.
WriteData
(
mainGame
->
dInfo
.
hostname
,
40
,
false
);
...
...
@@ -807,7 +806,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
last_replay
.
WriteData
(
mainGame
->
dInfo
.
hostname_tag
,
40
,
false
);
last_replay
.
WriteData
(
mainGame
->
dInfo
.
clientname_tag
,
40
,
false
);
}
last_replay
.
WriteInt32
(
mainGame
->
dInfo
.
duel_field
|
mainGame
->
dInfo
.
extraval
);
last_replay
.
WriteInt32
(
mainGame
->
dInfo
.
duel_field
|
mainGame
->
dInfo
.
extraval
>>
8
);
last_replay
.
WriteStream
(
replay_stream
);
last_replay
.
EndRecord
();
}
...
...
@@ -957,12 +956,37 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
break
;
}
case
STOC_NEW_REPLAY
:
{
char
*
prep
=
pdata
;
memcpy
(
&
last_replay
.
pheader
,
prep
,
sizeof
(
ReplayHeader
));
prep
+=
sizeof
(
ReplayHeader
);
memcpy
(
last_replay
.
comp_data
,
prep
,
len
-
sizeof
(
ReplayHeader
)
-
1
);
last_replay
.
comp_size
=
len
-
sizeof
(
ReplayHeader
)
-
1
;
old_replay
=
false
;
mainGame
->
gMutex
.
Lock
();
mainGame
->
wPhase
->
setVisible
(
false
);
if
(
mainGame
->
dInfo
.
player_type
<
7
)
mainGame
->
btnLeaveGame
->
setVisible
(
false
);
mainGame
->
btnChainIgnore
->
setVisible
(
false
);
mainGame
->
btnChainAlways
->
setVisible
(
false
);
mainGame
->
btnChainWhenAvail
->
setVisible
(
false
);
mainGame
->
btnCancelOrFinish
->
setVisible
(
false
);
time_t
nowtime
=
time
(
NULL
);
struct
tm
*
localedtime
=
localtime
(
&
nowtime
);
char
timebuf
[
40
];
strftime
(
timebuf
,
40
,
"%Y-%m-%d %H-%M-%S"
,
localedtime
);
size_t
size
=
strlen
(
timebuf
)
+
1
;
wchar_t
timetext
[
80
];
mbstowcs
(
timetext
,
timebuf
,
size
);
mainGame
->
ebRSName
->
setText
(
timetext
);
mainGame
->
PopupElement
(
mainGame
->
wReplaySave
);
mainGame
->
gMutex
.
Unlock
();
mainGame
->
replaySignal
.
Reset
();
mainGame
->
replaySignal
.
Wait
();
if
(
mainGame
->
saveReplay
||
!
is_host
)
{
char
*
prep
=
pdata
;
Replay
new_replay
;
memcpy
(
&
new_replay
.
pheader
,
prep
,
sizeof
(
ReplayHeader
));
prep
+=
sizeof
(
ReplayHeader
);
memcpy
(
new_replay
.
comp_data
,
prep
,
len
-
sizeof
(
ReplayHeader
)
-
1
);
new_replay
.
comp_size
=
len
-
sizeof
(
ReplayHeader
)
-
1
;
if
(
mainGame
->
saveReplay
)
new_replay
.
SaveReplay
(
mainGame
->
ebRSName
->
getText
());
else
new_replay
.
SaveReplay
(
L"_LastReplay"
);
}
break
;
}
}
...
...
gframe/duelclient.h
View file @
d1c4b218
...
...
@@ -48,7 +48,6 @@ public:
static
void
HandleSTOCPacketLan
(
char
*
data
,
unsigned
int
len
);
static
std
::
vector
<
BufferIO
::
ReplayPacket
>
replay_stream
;
static
Replay
last_replay
;
static
bool
old_replay
;
static
int
ClientAnalyze
(
char
*
msg
,
unsigned
int
len
);
static
void
SetResponseI
(
int
respI
);
static
void
SetResponseB
(
void
*
respB
,
unsigned
char
len
);
...
...
gframe/replay.cpp
View file @
d1c4b218
...
...
@@ -16,36 +16,25 @@ Replay::~Replay() {
delete
[]
replay_data
;
delete
[]
comp_data
;
}
void
Replay
::
BeginRecord
()
{
void
Replay
::
BeginRecord
(
bool
write
)
{
#ifdef _WIN32
if
(
is_recording
)
if
(
is_recording
&&
is_writing
)
CloseHandle
(
recording_fp
);
recording_fp
=
CreateFileW
(
L"./replay/_LastReplay.yrp"
,
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
FILE_FLAG_WRITE_THROUGH
,
NULL
);
if
(
recording_fp
==
INVALID_HANDLE_VALUE
)
return
;
#else
if
(
is_recording
)
fclose
(
fp
);
fp
=
fopen
(
"./replay/_LastReplay.yrp"
,
"wb"
);
if
(
!
fp
)
return
;
#endif
pdata
=
replay_data
;
is_recording
=
true
;
}
void
Replay
::
BeginRecord2
()
{
#ifdef _WIN32
if
(
is_recording
)
CloseHandle
(
recording_fp
);
recording_fp
=
CreateFileW
(
L"./replay/_LastReplay2.yrp"
,
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
FILE_FLAG_WRITE_THROUGH
,
NULL
);
if
(
recording_fp
==
INVALID_HANDLE_VALUE
)
return
;
is_writing
=
write
;
if
(
is_writing
)
{
recording_fp
=
CreateFileW
(
L"./replay/_LastReplay.yrp"
,
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
FILE_FLAG_WRITE_THROUGH
,
NULL
);
if
(
recording_fp
==
INVALID_HANDLE_VALUE
)
return
;
}
#else
if
(
is_recording
)
if
(
is_recording
&&
is_writing
)
fclose
(
fp
);
fp
=
fopen
(
"./replay/_LastReplay2.yrp"
,
"wb"
);
if
(
!
fp
)
return
;
is_writing
=
write
;
if
(
is_writing
)
{
fp
=
fopen
(
"./replay/_LastReplay.yrp"
,
"wb"
);
if
(
!
fp
)
return
;
}
#endif
pdata
=
replay_data
;
is_recording
=
true
;
...
...
@@ -62,6 +51,7 @@ void Replay::WriteStream(std::vector<BufferIO::ReplayPacket> stream) {
}
void
Replay
::
WriteHeader
(
ReplayHeader
&
header
)
{
pheader
=
header
;
if
(
!
is_writing
)
return
;
#ifdef _WIN32
DWORD
size
;
WriteFile
(
recording_fp
,
&
header
,
sizeof
(
header
),
&
size
,
NULL
);
...
...
@@ -75,6 +65,7 @@ void Replay::WriteData(const void* data, unsigned int length, bool flush) {
return
;
memcpy
(
pdata
,
data
,
length
);
pdata
+=
length
;
if
(
!
is_writing
)
return
;
#ifdef _WIN32
DWORD
size
;
WriteFile
(
recording_fp
,
data
,
length
,
&
size
,
NULL
);
...
...
@@ -89,6 +80,7 @@ void Replay::WriteInt32(int data, bool flush) {
return
;
*
((
int
*
)(
pdata
))
=
data
;
pdata
+=
4
;
if
(
!
is_writing
)
return
;
#ifdef _WIN32
DWORD
size
;
WriteFile
(
recording_fp
,
&
data
,
sizeof
(
int
),
&
size
,
NULL
);
...
...
@@ -103,6 +95,7 @@ void Replay::WriteInt16(short data, bool flush) {
return
;
*
((
short
*
)(
pdata
))
=
data
;
pdata
+=
2
;
if
(
!
is_writing
)
return
;
#ifdef _WIN32
DWORD
size
;
WriteFile
(
recording_fp
,
&
data
,
sizeof
(
short
),
&
size
,
NULL
);
...
...
@@ -117,6 +110,7 @@ void Replay::WriteInt8(char data, bool flush) {
return
;
*
pdata
=
data
;
pdata
++
;
if
(
!
is_writing
)
return
;
#ifdef _WIN32
DWORD
size
;
WriteFile
(
recording_fp
,
&
data
,
sizeof
(
char
),
&
size
,
NULL
);
...
...
@@ -129,6 +123,7 @@ void Replay::WriteInt8(char data, bool flush) {
void
Replay
::
Flush
()
{
if
(
!
is_recording
)
return
;
if
(
!
is_writing
)
return
;
#ifdef _WIN32
#else
fflush
(
fp
);
...
...
@@ -137,6 +132,7 @@ void Replay::Flush() {
void
Replay
::
EndRecord
()
{
if
(
!
is_recording
)
return
;
if
(
is_writing
)
#ifdef _WIN32
CloseHandle
(
recording_fp
);
#else
...
...
gframe/replay.h
View file @
d1c4b218
...
...
@@ -26,8 +26,7 @@ class Replay {
public:
Replay
();
~
Replay
();
void
BeginRecord
();
void
BeginRecord2
();
void
BeginRecord
(
bool
write
=
true
);
void
WriteStream
(
std
::
vector
<
BufferIO
::
ReplayPacket
>
stream
);
void
WritePacket
(
BufferIO
::
ReplayPacket
p
);
void
WriteHeader
(
ReplayHeader
&
header
);
...
...
@@ -61,6 +60,7 @@ public:
size_t
replay_size
;
size_t
comp_size
;
bool
is_recording
;
bool
is_writing
;
bool
is_replaying
;
};
...
...
gframe/single_duel.cpp
View file @
d1c4b218
...
...
@@ -400,13 +400,13 @@ void SingleDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
rh
.
flag
=
REPLAY_LUA64
;
time_t
seed
=
time
(
0
);
rh
.
seed
=
seed
;
last_replay
.
BeginRecord
();
last_replay
.
BeginRecord
(
false
);
last_replay
.
WriteHeader
(
rh
);
rnd
.
reset
(
seed
);
last_replay
.
WriteData
(
players
[
0
]
->
name
,
40
,
false
);
last_replay
.
WriteData
(
players
[
1
]
->
name
,
40
,
false
);
//records the replay with the new system
new_replay
.
BeginRecord
2
();
new_replay
.
BeginRecord
();
rh
.
id
=
0x58707279
;
new_replay
.
WriteHeader
(
rh
);
new_replay
.
WriteData
(
players
[
0
]
->
name
,
40
,
false
);
...
...
gframe/single_mode.cpp
View file @
d1c4b218
...
...
@@ -108,10 +108,10 @@ int SingleMode::SinglePlayThread(void* param) {
char
engineBuffer
[
0x1000
];
is_closing
=
false
;
is_continuing
=
true
;
last_replay
.
BeginRecord
();
last_replay
.
BeginRecord
(
false
);
last_replay
.
WriteHeader
(
rh
);
//records the replay with the new system
new_replay
.
BeginRecord
2
();
new_replay
.
BeginRecord
();
rh
.
id
=
0x58707279
;
new_replay
.
WriteHeader
(
rh
);
replay_stream
.
clear
();
...
...
gframe/tag_duel.cpp
View file @
d1c4b218
...
...
@@ -357,7 +357,7 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
rh
.
flag
=
REPLAY_TAG
+
REPLAY_LUA64
;
time_t
seed
=
time
(
0
);
rh
.
seed
=
seed
;
last_replay
.
BeginRecord
();
last_replay
.
BeginRecord
(
false
);
last_replay
.
WriteHeader
(
rh
);
rnd
.
reset
(
seed
);
last_replay
.
WriteData
(
players
[
0
]
->
name
,
40
,
false
);
...
...
@@ -365,7 +365,7 @@ void TagDuel::TPResult(DuelPlayer* dp, unsigned char tp) {
last_replay
.
WriteData
(
players
[
2
]
->
name
,
40
,
false
);
last_replay
.
WriteData
(
players
[
3
]
->
name
,
40
,
false
);
//records the replay with the new system
new_replay
.
BeginRecord
2
();
new_replay
.
BeginRecord
();
rh
.
id
=
0x58707279
;
new_replay
.
WriteHeader
(
rh
);
new_replay
.
WriteData
(
players
[
0
]
->
name
,
40
,
false
);
...
...
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