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
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
Commits
fb6814a8
Commit
fb6814a8
authored
Jul 21, 2025
by
Chen Bill
Committed by
GitHub
Jul 21, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor replay code for cross-platform compatibility (#2877)
parent
4e002a72
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
31 deletions
+6
-31
gframe/replay.cpp
gframe/replay.cpp
+2
-26
gframe/replay.h
gframe/replay.h
+4
-5
No files found.
gframe/replay.cpp
View file @
fb6814a8
#include "config.h"
#include "replay.h"
#include "replay.h"
#include "myfilesystem.h"
#include "myfilesystem.h"
#include "lzma/LzmaLib.h"
#include "lzma/LzmaLib.h"
...
@@ -15,31 +16,18 @@ Replay::~Replay() {
...
@@ -15,31 +16,18 @@ Replay::~Replay() {
void
Replay
::
BeginRecord
()
{
void
Replay
::
BeginRecord
()
{
if
(
!
FileSystem
::
IsDirExists
(
L"./replay"
)
&&
!
FileSystem
::
MakeDir
(
L"./replay"
))
if
(
!
FileSystem
::
IsDirExists
(
L"./replay"
)
&&
!
FileSystem
::
MakeDir
(
L"./replay"
))
return
;
return
;
#ifdef _WIN32
if(is_recording)
CloseHandle(recording_fp);
recording_fp = CreateFileW(L"./replay/_LastReplay.yrp", GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_FLAG_WRITE_THROUGH, nullptr);
if(recording_fp == INVALID_HANDLE_VALUE)
return;
#else
if
(
is_recording
)
if
(
is_recording
)
std
::
fclose
(
fp
);
std
::
fclose
(
fp
);
fp
=
myfopen
(
"./replay/_LastReplay.yrp"
,
"wb"
);
fp
=
myfopen
(
"./replay/_LastReplay.yrp"
,
"wb"
);
if
(
!
fp
)
if
(
!
fp
)
return
;
return
;
#endif
Reset
();
Reset
();
is_recording
=
true
;
is_recording
=
true
;
}
}
void
Replay
::
WriteHeader
(
ExtendedReplayHeader
&
header
)
{
void
Replay
::
WriteHeader
(
ExtendedReplayHeader
&
header
)
{
pheader
=
header
;
pheader
=
header
;
#ifdef _WIN32
std
::
fwrite
(
&
header
,
sizeof
header
,
1
,
fp
);
DWORD size;
WriteFile(recording_fp, &header, sizeof(header), &size, nullptr);
#else
std::fwrite(&header, sizeof(header), 1, fp);
std
::
fflush
(
fp
);
std
::
fflush
(
fp
);
#endif
}
}
void
Replay
::
WriteData
(
const
void
*
data
,
size_t
length
,
bool
flush
)
{
void
Replay
::
WriteData
(
const
void
*
data
,
size_t
length
,
bool
flush
)
{
if
(
!
is_recording
)
if
(
!
is_recording
)
...
@@ -48,14 +36,9 @@ void Replay::WriteData(const void* data, size_t length, bool flush) {
...
@@ -48,14 +36,9 @@ void Replay::WriteData(const void* data, size_t length, bool flush) {
return
;
return
;
std
::
memcpy
(
replay_data
+
replay_size
,
data
,
length
);
std
::
memcpy
(
replay_data
+
replay_size
,
data
,
length
);
replay_size
+=
length
;
replay_size
+=
length
;
#ifdef _WIN32
DWORD size;
WriteFile(recording_fp, data, length, &size, nullptr);
#else
std
::
fwrite
(
data
,
length
,
1
,
fp
);
std
::
fwrite
(
data
,
length
,
1
,
fp
);
if
(
flush
)
if
(
flush
)
std
::
fflush
(
fp
);
std
::
fflush
(
fp
);
#endif
}
}
void
Replay
::
WriteInt32
(
int32_t
data
,
bool
flush
)
{
void
Replay
::
WriteInt32
(
int32_t
data
,
bool
flush
)
{
Write
<
int32_t
>
(
data
,
flush
);
Write
<
int32_t
>
(
data
,
flush
);
...
@@ -63,19 +46,12 @@ void Replay::WriteInt32(int32_t data, bool flush) {
...
@@ -63,19 +46,12 @@ void Replay::WriteInt32(int32_t data, bool flush) {
void
Replay
::
Flush
()
{
void
Replay
::
Flush
()
{
if
(
!
is_recording
)
if
(
!
is_recording
)
return
;
return
;
#ifdef _WIN32
#else
std
::
fflush
(
fp
);
std
::
fflush
(
fp
);
#endif
}
}
void
Replay
::
EndRecord
()
{
void
Replay
::
EndRecord
()
{
if
(
!
is_recording
)
if
(
!
is_recording
)
return
;
return
;
#ifdef _WIN32
CloseHandle(recording_fp);
#else
std
::
fclose
(
fp
);
std
::
fclose
(
fp
);
#endif
pheader
.
base
.
datasize
=
replay_size
;
pheader
.
base
.
datasize
=
replay_size
;
pheader
.
base
.
flag
|=
REPLAY_COMPRESSED
;
pheader
.
base
.
flag
|=
REPLAY_COMPRESSED
;
size_t
propsize
=
5
;
size_t
propsize
=
5
;
...
...
gframe/replay.h
View file @
fb6814a8
#ifndef REPLAY_H
#ifndef REPLAY_H
#define REPLAY_H
#define REPLAY_H
#include "config.h"
#include <cstdio>
#include <vector>
#include <string>
#include "../ocgcore/ocgapi.h"
#include "deck_manager.h"
#include "deck_manager.h"
namespace
ygo
{
namespace
ygo
{
...
@@ -95,10 +98,6 @@ public:
...
@@ -95,10 +98,6 @@ public:
bool
IsReplaying
()
const
;
bool
IsReplaying
()
const
;
FILE
*
fp
{
nullptr
};
FILE
*
fp
{
nullptr
};
#ifdef _WIN32
HANDLE
recording_fp
{
nullptr
};
#endif
ExtendedReplayHeader
pheader
;
ExtendedReplayHeader
pheader
;
unsigned
char
*
comp_data
;
unsigned
char
*
comp_data
;
size_t
comp_size
{};
size_t
comp_size
{};
...
...
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