Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile
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
fallenstardust
YGOMobile
Commits
97ee33c8
Commit
97ee33c8
authored
Dec 27, 2024
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update gframe
parent
d44d64e6
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
55 deletions
+39
-55
Classes/gframe/replay.cpp
Classes/gframe/replay.cpp
+18
-37
Classes/gframe/replay.h
Classes/gframe/replay.h
+15
-12
Classes/gframe/replay_mode.cpp
Classes/gframe/replay_mode.cpp
+2
-2
Classes/gframe/single_duel.cpp
Classes/gframe/single_duel.cpp
+1
-1
Classes/gframe/single_mode.cpp
Classes/gframe/single_mode.cpp
+2
-2
Classes/gframe/tag_duel.cpp
Classes/gframe/tag_duel.cpp
+1
-1
No files found.
Classes/gframe/replay.cpp
View file @
97ee33c8
...
...
@@ -28,7 +28,6 @@ void Replay::BeginRecord() {
if
(
!
fp
)
return
;
#endif
pwrite
=
replay_data
;
replay_size
=
0
;
comp_size
=
0
;
is_replaying
=
false
;
...
...
@@ -44,13 +43,13 @@ void Replay::WriteHeader(ReplayHeader& header) {
fflush
(
fp
);
#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
)
return
;
if
(
length
<
0
||
(
int
)(
pwrite
-
replay_data
)
+
length
>
MAX_REPLAY_SIZE
)
if
(
replay_size
+
length
>
MAX_REPLAY_SIZE
)
return
;
std
::
memcpy
(
pwrit
e
,
data
,
length
);
pwrit
e
+=
length
;
std
::
memcpy
(
replay_data
+
replay_siz
e
,
data
,
length
);
replay_siz
e
+=
length
;
#ifdef _WIN32
DWORD
size
;
WriteFile
(
recording_fp
,
data
,
length
,
&
size
,
nullptr
);
...
...
@@ -60,14 +59,8 @@ void Replay::WriteData(const void* data, int length, bool flush) {
fflush
(
fp
);
#endif
}
void
Replay
::
WriteInt32
(
int
data
,
bool
flush
)
{
WriteData
(
&
data
,
sizeof
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
::
WriteInt32
(
int32_t
data
,
bool
flush
)
{
Write
<
int32_t
>
(
data
,
flush
);
}
void
Replay
::
Flush
()
{
if
(
!
is_recording
)
...
...
@@ -85,7 +78,6 @@ void Replay::EndRecord() {
#else
fclose
(
fp
);
#endif
replay_size
=
pwrite
-
replay_data
;
pheader
.
datasize
=
replay_size
;
pheader
.
flag
|=
REPLAY_COMPRESSED
;
size_t
propsize
=
5
;
...
...
@@ -119,7 +111,7 @@ bool Replay::OpenReplay(const wchar_t* name) {
if
(
!
rfp
)
return
false
;
pdata
=
replay_data
;
data_position
=
0
;
is_recording
=
false
;
is_replaying
=
false
;
replay_size
=
0
;
...
...
@@ -209,37 +201,26 @@ bool Replay::ReadName(wchar_t* data) {
BufferIO
::
CopyWStr
(
buffer
,
data
,
20
);
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
)
return
false
;
if
(
length
<
0
)
return
false
;
if
((
int
)(
pdata
-
replay_data
)
+
length
>
(
int
)
replay_size
)
{
if
(
data_position
+
length
>
replay_size
)
{
is_replaying
=
false
;
return
false
;
}
std
::
memcpy
(
data
,
pdata
,
length
);
pdata
+=
length
;
if
(
length
)
std
::
memcpy
(
data
,
&
replay_data
[
data_position
],
length
);
data_position
+=
length
;
return
true
;
}
template
<
typename
T
>
T
Replay
::
ReadValue
()
{
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
>
();
int32_t
Replay
::
ReadInt32
()
{
return
Read
<
int32_t
>
();
}
void
Replay
::
Rewind
()
{
pdata
=
replay_data
;
data_position
=
0
;
}
}
Classes/gframe/replay.h
View file @
97ee33c8
...
...
@@ -34,10 +34,12 @@ public:
// record
void
BeginRecord
();
void
WriteHeader
(
ReplayHeader
&
header
);
void
WriteData
(
const
void
*
data
,
int
length
,
bool
flush
=
true
);
void
WriteInt32
(
int
data
,
bool
flush
=
true
);
void
WriteInt16
(
short
data
,
bool
flush
=
true
);
void
WriteInt8
(
char
data
,
bool
flush
=
true
);
void
WriteData
(
const
void
*
data
,
size_t
length
,
bool
flush
=
true
);
template
<
typename
T
>
void
Write
(
T
data
,
bool
flush
=
true
)
{
WriteData
(
&
data
,
sizeof
(
T
),
flush
);
}
void
WriteInt32
(
int32_t
data
,
bool
flush
=
true
);
void
Flush
();
void
EndRecord
();
void
SaveReplay
(
const
wchar_t
*
name
);
...
...
@@ -49,13 +51,15 @@ public:
static
bool
RenameReplay
(
const
wchar_t
*
oldname
,
const
wchar_t
*
newname
);
bool
ReadNextResponse
(
unsigned
char
resp
[]);
bool
ReadName
(
wchar_t
*
data
);
//
void ReadHeader(ReplayHeader& header);
bool
ReadData
(
void
*
data
,
in
t
length
);
void
ReadHeader
(
ReplayHeader
&
header
);
bool
ReadData
(
void
*
data
,
size_
t
length
);
template
<
typename
T
>
T
ReadValue
();
int
ReadInt32
();
short
ReadInt16
();
char
ReadInt8
();
T
Read
()
{
T
ret
{};
ReadData
(
&
ret
,
sizeof
(
T
));
return
ret
;
}
int32_t
ReadInt32
();
void
Rewind
();
FILE
*
fp
{
nullptr
};
...
...
@@ -70,8 +74,7 @@ public:
private:
unsigned
char
*
replay_data
;
size_t
replay_size
{};
unsigned
char
*
pwrite
{};
unsigned
char
*
pdata
{};
size_t
data_position
{};
bool
is_recording
{};
bool
is_replaying
{};
};
...
...
Classes/gframe/replay_mode.cpp
View file @
97ee33c8
...
...
@@ -228,8 +228,8 @@ bool ReplayMode::StartDuel() {
}
}
else
{
char
filename
[
256
];
int
slen
=
cur_replay
.
ReadInt16
();
if
(
slen
<
0
||
slen
>
255
)
{
auto
slen
=
cur_replay
.
Read
<
uint16_t
>
();
if
(
slen
>
sizeof
(
filename
)
-
1
)
{
return
false
;
}
cur_replay
.
ReadData
(
filename
,
slen
);
...
...
Classes/gframe/single_duel.cpp
View file @
97ee33c8
...
...
@@ -1413,7 +1413,7 @@ void SingleDuel::GetResponse(DuelPlayer* dp, unsigned char* pdata, unsigned int
if
(
len
>
SIZE_RETURN_VALUE
)
len
=
SIZE_RETURN_VALUE
;
std
::
memcpy
(
resb
,
pdata
,
len
);
last_replay
.
Write
Int8
(
len
);
last_replay
.
Write
<
uint8_t
>
(
len
);
last_replay
.
WriteData
(
resb
,
len
);
set_responseb
(
pduel
,
resb
);
players
[
dp
->
type
]
->
state
=
0xff
;
...
...
Classes/gframe/single_mode.cpp
View file @
97ee33c8
...
...
@@ -25,7 +25,7 @@ void SingleMode::StopPlay(bool is_exiting) {
void
SingleMode
::
SetResponse
(
unsigned
char
*
resp
,
unsigned
int
len
)
{
if
(
!
pduel
)
return
;
last_replay
.
Write
Int8
(
len
);
last_replay
.
Write
<
uint8_t
>
(
len
);
last_replay
.
WriteData
(
resp
,
len
);
set_responseb
(
pduel
,
resp
);
}
...
...
@@ -108,7 +108,7 @@ int SingleMode::SinglePlayThread() {
last_replay
.
WriteInt32
(
start_hand
,
false
);
last_replay
.
WriteInt32
(
draw_count
,
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
.
Flush
();
start_duel
(
pduel
,
opt
);
...
...
Classes/gframe/tag_duel.cpp
View file @
97ee33c8
...
...
@@ -1515,7 +1515,7 @@ void TagDuel::GetResponse(DuelPlayer* dp, unsigned char* pdata, unsigned int len
if
(
len
>
SIZE_RETURN_VALUE
)
len
=
SIZE_RETURN_VALUE
;
std
::
memcpy
(
resb
,
pdata
,
len
);
last_replay
.
Write
Int8
(
len
);
last_replay
.
Write
<
uint8_t
>
(
len
);
last_replay
.
WriteData
(
resb
,
len
);
set_responseb
(
pduel
,
resb
);
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