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
赤子奈落
ygopro
Commits
bc514d7a
You need to sign in or sign up before continuing.
Commit
bc514d7a
authored
Dec 26, 2024
by
wind2009
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'salix/patch-rp' into server-develop
parents
54137843
0c777eb1
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
55 deletions
+39
-55
gframe/replay.cpp
gframe/replay.cpp
+18
-37
gframe/replay.h
gframe/replay.h
+15
-12
gframe/replay_mode.cpp
gframe/replay_mode.cpp
+2
-2
gframe/single_duel.cpp
gframe/single_duel.cpp
+1
-1
gframe/single_mode.cpp
gframe/single_mode.cpp
+2
-2
gframe/tag_duel.cpp
gframe/tag_duel.cpp
+1
-1
No files found.
gframe/replay.cpp
View file @
bc514d7a
...
@@ -58,7 +58,6 @@ void Replay::BeginRecord() {
...
@@ -58,7 +58,6 @@ void Replay::BeginRecord() {
#ifdef YGOPRO_SERVER_MODE
#ifdef YGOPRO_SERVER_MODE
}
}
#endif //YGOPRO_SERVER_MODE
#endif //YGOPRO_SERVER_MODE
pwrite
=
replay_data
;
replay_size
=
0
;
replay_size
=
0
;
comp_size
=
0
;
comp_size
=
0
;
is_replaying
=
false
;
is_replaying
=
false
;
...
@@ -77,13 +76,13 @@ void Replay::WriteHeader(ReplayHeader& header) {
...
@@ -77,13 +76,13 @@ void Replay::WriteHeader(ReplayHeader& header) {
fflush
(
fp
);
fflush
(
fp
);
#endif
#endif
}
}
void
Replay
::
WriteData
(
const
void
*
data
,
in
t
length
,
bool
flush
)
{
void
Replay
::
WriteData
(
const
void
*
data
,
size_
t
length
,
bool
flush
)
{
if
(
!
is_recording
)
if
(
!
is_recording
)
return
;
return
;
if
(
length
<
0
||
(
int
)(
pwrite
-
replay_data
)
+
length
>
MAX_REPLAY_SIZE
)
if
(
replay_size
+
length
>
MAX_REPLAY_SIZE
)
return
;
return
;
std
::
memcpy
(
pwrit
e
,
data
,
length
);
std
::
memcpy
(
replay_data
+
replay_siz
e
,
data
,
length
);
pwrit
e
+=
length
;
replay_siz
e
+=
length
;
#ifdef YGOPRO_SERVER_MODE
#ifdef YGOPRO_SERVER_MODE
if
(
!
(
replay_mode
&
REPLAY_MODE_SAVE_IN_SERVER
))
return
;
if
(
!
(
replay_mode
&
REPLAY_MODE_SAVE_IN_SERVER
))
return
;
#endif
#endif
...
@@ -96,14 +95,8 @@ void Replay::WriteData(const void* data, int length, bool flush) {
...
@@ -96,14 +95,8 @@ void Replay::WriteData(const void* data, int length, bool flush) {
fflush
(
fp
);
fflush
(
fp
);
#endif
#endif
}
}
void
Replay
::
WriteInt32
(
int
data
,
bool
flush
)
{
void
Replay
::
WriteInt32
(
int32_t
data
,
bool
flush
)
{
WriteData
(
&
data
,
sizeof
data
,
flush
);
Write
<
int32_t
>
(
data
,
flush
);
}
void
Replay
::
WriteInt16
(
short
data
,
bool
flush
)
{
WriteData
(
&
data
,
sizeof
data
,
flush
);
}
void
Replay
::
WriteInt8
(
char
data
,
bool
flush
)
{
WriteData
(
&
data
,
sizeof
data
,
flush
);
}
}
void
Replay
::
Flush
()
{
void
Replay
::
Flush
()
{
if
(
!
is_recording
)
if
(
!
is_recording
)
...
@@ -130,7 +123,6 @@ void Replay::EndRecord() {
...
@@ -130,7 +123,6 @@ void Replay::EndRecord() {
#ifdef YGOPRO_SERVER_MODE
#ifdef YGOPRO_SERVER_MODE
}
}
#endif
#endif
replay_size
=
pwrite
-
replay_data
;
pheader
.
datasize
=
replay_size
;
pheader
.
datasize
=
replay_size
;
pheader
.
flag
|=
REPLAY_COMPRESSED
;
pheader
.
flag
|=
REPLAY_COMPRESSED
;
size_t
propsize
=
5
;
size_t
propsize
=
5
;
...
@@ -164,7 +156,7 @@ bool Replay::OpenReplay(const wchar_t* name) {
...
@@ -164,7 +156,7 @@ bool Replay::OpenReplay(const wchar_t* name) {
if
(
!
rfp
)
if
(
!
rfp
)
return
false
;
return
false
;
pdata
=
replay_data
;
data_position
=
0
;
is_recording
=
false
;
is_recording
=
false
;
is_replaying
=
false
;
is_replaying
=
false
;
replay_size
=
0
;
replay_size
=
0
;
...
@@ -254,37 +246,26 @@ bool Replay::ReadName(wchar_t* data) {
...
@@ -254,37 +246,26 @@ bool Replay::ReadName(wchar_t* data) {
BufferIO
::
CopyWStr
(
buffer
,
data
,
20
);
BufferIO
::
CopyWStr
(
buffer
,
data
,
20
);
return
true
;
return
true
;
}
}
bool
Replay
::
ReadData
(
void
*
data
,
int
length
)
{
void
Replay
::
ReadHeader
(
ReplayHeader
&
header
)
{
header
=
pheader
;
}
bool
Replay
::
ReadData
(
void
*
data
,
size_t
length
)
{
if
(
!
is_replaying
)
if
(
!
is_replaying
)
return
false
;
return
false
;
if
(
length
<
0
)
if
(
data_position
+
length
>
replay_size
)
{
return
false
;
if
((
int
)(
pdata
-
replay_data
)
+
length
>
(
int
)
replay_size
)
{
is_replaying
=
false
;
is_replaying
=
false
;
return
false
;
return
false
;
}
}
std
::
memcpy
(
data
,
pdata
,
length
);
if
(
length
)
pdata
+=
length
;
std
::
memcpy
(
data
,
&
replay_data
[
data_position
],
length
);
data_position
+=
length
;
return
true
;
return
true
;
}
}
template
<
typename
T
>
int32_t
Replay
::
ReadInt32
()
{
T
Replay
::
ReadValue
()
{
return
Read
<
int32_t
>
();
T
ret
{};
if
(
!
ReadData
(
&
ret
,
sizeof
ret
))
return
-
1
;
return
ret
;
}
int
Replay
::
ReadInt32
()
{
return
ReadValue
<
int32_t
>
();
}
short
Replay
::
ReadInt16
()
{
return
ReadValue
<
int16_t
>
();
}
char
Replay
::
ReadInt8
()
{
return
ReadValue
<
char
>
();
}
}
void
Replay
::
Rewind
()
{
void
Replay
::
Rewind
()
{
pdata
=
replay_data
;
data_position
=
0
;
}
}
}
}
gframe/replay.h
View file @
bc514d7a
...
@@ -40,10 +40,12 @@ public:
...
@@ -40,10 +40,12 @@ public:
// record
// record
void
BeginRecord
();
void
BeginRecord
();
void
WriteHeader
(
ReplayHeader
&
header
);
void
WriteHeader
(
ReplayHeader
&
header
);
void
WriteData
(
const
void
*
data
,
int
length
,
bool
flush
=
true
);
void
WriteData
(
const
void
*
data
,
size_t
length
,
bool
flush
=
true
);
void
WriteInt32
(
int
data
,
bool
flush
=
true
);
template
<
typename
T
>
void
WriteInt16
(
short
data
,
bool
flush
=
true
);
void
Write
(
T
data
,
bool
flush
=
true
)
{
void
WriteInt8
(
char
data
,
bool
flush
=
true
);
WriteData
(
&
data
,
sizeof
(
T
),
flush
);
}
void
WriteInt32
(
int32_t
data
,
bool
flush
=
true
);
void
Flush
();
void
Flush
();
void
EndRecord
();
void
EndRecord
();
void
SaveReplay
(
const
wchar_t
*
name
);
void
SaveReplay
(
const
wchar_t
*
name
);
...
@@ -55,13 +57,15 @@ public:
...
@@ -55,13 +57,15 @@ public:
static
bool
RenameReplay
(
const
wchar_t
*
oldname
,
const
wchar_t
*
newname
);
static
bool
RenameReplay
(
const
wchar_t
*
oldname
,
const
wchar_t
*
newname
);
bool
ReadNextResponse
(
unsigned
char
resp
[]);
bool
ReadNextResponse
(
unsigned
char
resp
[]);
bool
ReadName
(
wchar_t
*
data
);
bool
ReadName
(
wchar_t
*
data
);
//
void ReadHeader(ReplayHeader& header);
void
ReadHeader
(
ReplayHeader
&
header
);
bool
ReadData
(
void
*
data
,
in
t
length
);
bool
ReadData
(
void
*
data
,
size_
t
length
);
template
<
typename
T
>
template
<
typename
T
>
T
ReadValue
();
T
Read
()
{
int
ReadInt32
();
T
ret
{};
short
ReadInt16
();
ReadData
(
&
ret
,
sizeof
(
T
));
char
ReadInt8
();
return
ret
;
}
int32_t
ReadInt32
();
void
Rewind
();
void
Rewind
();
FILE
*
fp
{
nullptr
};
FILE
*
fp
{
nullptr
};
...
@@ -76,8 +80,7 @@ public:
...
@@ -76,8 +80,7 @@ public:
private:
private:
unsigned
char
*
replay_data
;
unsigned
char
*
replay_data
;
size_t
replay_size
{};
size_t
replay_size
{};
unsigned
char
*
pwrite
{};
size_t
data_position
{};
unsigned
char
*
pdata
{};
bool
is_recording
{};
bool
is_recording
{};
bool
is_replaying
{};
bool
is_replaying
{};
};
};
...
...
gframe/replay_mode.cpp
View file @
bc514d7a
...
@@ -228,8 +228,8 @@ bool ReplayMode::StartDuel() {
...
@@ -228,8 +228,8 @@ bool ReplayMode::StartDuel() {
}
}
}
else
{
}
else
{
char
filename
[
256
];
char
filename
[
256
];
int
slen
=
cur_replay
.
ReadInt16
();
auto
slen
=
cur_replay
.
Read
<
uint16_t
>
();
if
(
slen
<
0
||
slen
>
255
)
{
if
(
slen
>
sizeof
(
filename
)
-
1
)
{
return
false
;
return
false
;
}
}
cur_replay
.
ReadData
(
filename
,
slen
);
cur_replay
.
ReadData
(
filename
,
slen
);
...
...
gframe/single_duel.cpp
View file @
bc514d7a
...
@@ -1781,7 +1781,7 @@ void SingleDuel::GetResponse(DuelPlayer* dp, unsigned char* pdata, unsigned int
...
@@ -1781,7 +1781,7 @@ void SingleDuel::GetResponse(DuelPlayer* dp, unsigned char* pdata, unsigned int
if
(
len
>
SIZE_RETURN_VALUE
)
if
(
len
>
SIZE_RETURN_VALUE
)
len
=
SIZE_RETURN_VALUE
;
len
=
SIZE_RETURN_VALUE
;
std
::
memcpy
(
resb
,
pdata
,
len
);
std
::
memcpy
(
resb
,
pdata
,
len
);
last_replay
.
Write
Int8
(
len
);
last_replay
.
Write
<
uint8_t
>
(
len
);
last_replay
.
WriteData
(
resb
,
len
);
last_replay
.
WriteData
(
resb
,
len
);
set_responseb
(
pduel
,
resb
);
set_responseb
(
pduel
,
resb
);
players
[
dp
->
type
]
->
state
=
0xff
;
players
[
dp
->
type
]
->
state
=
0xff
;
...
...
gframe/single_mode.cpp
View file @
bc514d7a
...
@@ -25,7 +25,7 @@ void SingleMode::StopPlay(bool is_exiting) {
...
@@ -25,7 +25,7 @@ void SingleMode::StopPlay(bool is_exiting) {
void
SingleMode
::
SetResponse
(
unsigned
char
*
resp
,
unsigned
int
len
)
{
void
SingleMode
::
SetResponse
(
unsigned
char
*
resp
,
unsigned
int
len
)
{
if
(
!
pduel
)
if
(
!
pduel
)
return
;
return
;
last_replay
.
Write
Int8
(
len
);
last_replay
.
Write
<
uint8_t
>
(
len
);
last_replay
.
WriteData
(
resp
,
len
);
last_replay
.
WriteData
(
resp
,
len
);
set_responseb
(
pduel
,
resp
);
set_responseb
(
pduel
,
resp
);
}
}
...
@@ -119,7 +119,7 @@ int SingleMode::SinglePlayThread() {
...
@@ -119,7 +119,7 @@ int SingleMode::SinglePlayThread() {
last_replay
.
WriteInt32
(
start_hand
,
false
);
last_replay
.
WriteInt32
(
start_hand
,
false
);
last_replay
.
WriteInt32
(
draw_count
,
false
);
last_replay
.
WriteInt32
(
draw_count
,
false
);
last_replay
.
WriteInt32
(
opt
,
false
);
last_replay
.
WriteInt32
(
opt
,
false
);
last_replay
.
Write
Int16
(
slen
,
false
);
last_replay
.
Write
<
uint16_t
>
(
slen
,
false
);
last_replay
.
WriteData
(
filename
,
slen
,
false
);
last_replay
.
WriteData
(
filename
,
slen
,
false
);
last_replay
.
Flush
();
last_replay
.
Flush
();
start_duel
(
pduel
,
opt
);
start_duel
(
pduel
,
opt
);
...
...
gframe/tag_duel.cpp
View file @
bc514d7a
...
@@ -1871,7 +1871,7 @@ void TagDuel::GetResponse(DuelPlayer* dp, unsigned char* pdata, unsigned int len
...
@@ -1871,7 +1871,7 @@ void TagDuel::GetResponse(DuelPlayer* dp, unsigned char* pdata, unsigned int len
if
(
len
>
SIZE_RETURN_VALUE
)
if
(
len
>
SIZE_RETURN_VALUE
)
len
=
SIZE_RETURN_VALUE
;
len
=
SIZE_RETURN_VALUE
;
std
::
memcpy
(
resb
,
pdata
,
len
);
std
::
memcpy
(
resb
,
pdata
,
len
);
last_replay
.
Write
Int8
(
len
);
last_replay
.
Write
<
uint8_t
>
(
len
);
last_replay
.
WriteData
(
resb
,
len
);
last_replay
.
WriteData
(
resb
,
len
);
set_responseb
(
pduel
,
resb
);
set_responseb
(
pduel
,
resb
);
players
[
dp
->
type
]
->
state
=
0xff
;
players
[
dp
->
type
]
->
state
=
0xff
;
...
...
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