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
1
Merge Requests
1
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
nanahira
ygopro
Commits
70af2f52
Commit
70af2f52
authored
Aug 11, 2025
by
mercury233
Committed by
GitHub
Aug 11, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add `mysnprintf`, use `std::forward` in `myswprintf` (#2885)
parent
d5044ff8
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
32 additions
and
28 deletions
+32
-28
gframe/config.h
gframe/config.h
+6
-2
gframe/data_manager.cpp
gframe/data_manager.cpp
+2
-2
gframe/game.cpp
gframe/game.cpp
+1
-1
gframe/image_manager.cpp
gframe/image_manager.cpp
+17
-17
gframe/menu_handler.cpp
gframe/menu_handler.cpp
+2
-2
gframe/myfilesystem.h
gframe/myfilesystem.h
+2
-2
gframe/replay_mode.cpp
gframe/replay_mode.cpp
+1
-1
gframe/sound_manager.cpp
gframe/sound_manager.cpp
+1
-1
No files found.
gframe/config.h
View file @
70af2f52
...
...
@@ -54,8 +54,12 @@
#include "../ocgcore/ocgapi.h"
template
<
size_t
N
,
typename
...
TR
>
inline
int
myswprintf
(
wchar_t
(
&
buf
)[
N
],
const
wchar_t
*
fmt
,
TR
...
args
)
{
return
std
::
swprintf
(
buf
,
N
,
fmt
,
args
...);
inline
int
myswprintf
(
wchar_t
(
&
buf
)[
N
],
const
wchar_t
*
fmt
,
TR
&&
...
args
)
{
return
std
::
swprintf
(
buf
,
N
,
fmt
,
std
::
forward
<
TR
>
(
args
)...);
}
template
<
size_t
N
,
typename
...
TR
>
inline
int
mysnprintf
(
char
(
&
buf
)[
N
],
const
char
*
fmt
,
TR
&&
...
args
)
{
return
std
::
snprintf
(
buf
,
N
,
fmt
,
std
::
forward
<
TR
>
(
args
)...);
}
inline
FILE
*
mywfopen
(
const
wchar_t
*
filename
,
const
char
*
mode
)
{
...
...
gframe/data_manager.cpp
View file @
70af2f52
...
...
@@ -160,7 +160,7 @@ void DataManager::ReadStringConfLine(const char* linebuf) {
}
bool
DataManager
::
Error
(
sqlite3
*
pDB
,
sqlite3_stmt
*
pStmt
)
{
if
(
const
char
*
msg
=
sqlite3_errmsg
(
pDB
))
std
::
snprintf
(
errmsg
,
sizeof
errmsg
,
"%s"
,
msg
);
mysnprintf
(
errmsg
,
"%s"
,
msg
);
else
errmsg
[
0
]
=
'\0'
;
sqlite3_finalize
(
pStmt
);
...
...
@@ -377,7 +377,7 @@ unsigned char* DataManager::ScriptReaderEx(const char* script_path, int* slen) {
return
ReadScriptFromFile
(
script_path
,
slen
);
const
char
*
script_name
=
script_path
+
2
;
char
expansions_path
[
1024
]{};
std
::
snprintf
(
expansions_path
,
sizeof
expansions_path
,
"./expansions/%s"
,
script_name
);
mysnprintf
(
expansions_path
,
"./expansions/%s"
,
script_name
);
if
(
mainGame
->
gameConf
.
prefer_expansion_script
)
{
// debug script with raw file in expansions
if
(
ReadScriptFromFile
(
expansions_path
,
slen
))
return
scriptBuffer
;
...
...
gframe/game.cpp
View file @
70af2f52
...
...
@@ -1711,7 +1711,7 @@ void Game::AddDebugMsg(const char* msg) {
}
if
(
enable_log
&
0x2
)
{
char
msgbuf
[
1040
];
std
::
snprintf
(
msgbuf
,
sizeof
msgbuf
,
"[Script Error]: %s"
,
msg
);
mysnprintf
(
msgbuf
,
"[Script Error]: %s"
,
msg
);
ErrorLog
(
msgbuf
);
}
}
...
...
gframe/image_manager.cpp
View file @
70af2f52
...
...
@@ -237,10 +237,10 @@ irr::video::ITexture* ImageManager::GetTexture(int code, bool fit) {
auto
tit
=
tMap
[
fit
?
1
:
0
].
find
(
code
);
if
(
tit
==
tMap
[
fit
?
1
:
0
].
end
())
{
char
file
[
256
];
std
::
snprintf
(
file
,
sizeof
file
,
"expansions/pics/%d.jpg"
,
code
);
mysnprintf
(
file
,
"expansions/pics/%d.jpg"
,
code
);
irr
::
video
::
ITexture
*
img
=
GetTextureFromFile
(
file
,
width
,
height
);
if
(
img
==
nullptr
)
{
std
::
snprintf
(
file
,
sizeof
file
,
"pics/%d.jpg"
,
code
);
mysnprintf
(
file
,
"pics/%d.jpg"
,
code
);
img
=
GetTextureFromFile
(
file
,
width
,
height
);
}
if
(
img
==
nullptr
&&
!
mainGame
->
gameConf
.
use_image_scale
)
{
...
...
@@ -264,10 +264,10 @@ irr::video::ITexture* ImageManager::GetBigPicture(int code, float zoom) {
}
irr
::
video
::
ITexture
*
texture
;
char
file
[
256
];
std
::
snprintf
(
file
,
sizeof
file
,
"expansions/pics/%d.jpg"
,
code
);
mysnprintf
(
file
,
"expansions/pics/%d.jpg"
,
code
);
irr
::
video
::
IImage
*
srcimg
=
driver
->
createImageFromFile
(
file
);
if
(
srcimg
==
nullptr
)
{
std
::
snprintf
(
file
,
sizeof
file
,
"pics/%d.jpg"
,
code
);
mysnprintf
(
file
,
"pics/%d.jpg"
,
code
);
srcimg
=
driver
->
createImageFromFile
(
file
);
}
if
(
srcimg
==
nullptr
)
{
...
...
@@ -293,18 +293,18 @@ int ImageManager::LoadThumbThread() {
imageManager
.
tThumbLoadingCodes
.
pop
();
imageManager
.
tThumbLoadingMutex
.
unlock
();
char
file
[
256
];
std
::
snprintf
(
file
,
sizeof
file
,
"expansions/pics/thumbnail/%d.jpg"
,
code
);
mysnprintf
(
file
,
"expansions/pics/thumbnail/%d.jpg"
,
code
);
irr
::
video
::
IImage
*
img
=
imageManager
.
driver
->
createImageFromFile
(
file
);
if
(
img
==
nullptr
)
{
std
::
snprintf
(
file
,
sizeof
file
,
"pics/thumbnail/%d.jpg"
,
code
);
mysnprintf
(
file
,
"pics/thumbnail/%d.jpg"
,
code
);
img
=
imageManager
.
driver
->
createImageFromFile
(
file
);
}
if
(
img
==
nullptr
&&
mainGame
->
gameConf
.
use_image_scale
)
{
std
::
snprintf
(
file
,
sizeof
file
,
"expansions/pics/%d.jpg"
,
code
);
mysnprintf
(
file
,
"expansions/pics/%d.jpg"
,
code
);
img
=
imageManager
.
driver
->
createImageFromFile
(
file
);
}
if
(
img
==
nullptr
&&
mainGame
->
gameConf
.
use_image_scale
)
{
std
::
snprintf
(
file
,
sizeof
file
,
"pics/%d.jpg"
,
code
);
mysnprintf
(
file
,
"pics/%d.jpg"
,
code
);
img
=
imageManager
.
driver
->
createImageFromFile
(
file
);
}
if
(
img
!=
nullptr
)
{
...
...
@@ -347,19 +347,19 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
auto
tit
=
tThumb
.
find
(
code
);
if
(
tit
==
tThumb
.
end
()
&&
!
mainGame
->
gameConf
.
use_image_load_background_thread
)
{
char
file
[
256
];
std
::
snprintf
(
file
,
sizeof
file
,
"expansions/pics/thumbnail/%d.jpg"
,
code
);
mysnprintf
(
file
,
"expansions/pics/thumbnail/%d.jpg"
,
code
);
int
width
=
CARD_THUMB_WIDTH
*
mainGame
->
xScale
;
int
height
=
CARD_THUMB_HEIGHT
*
mainGame
->
yScale
;
irr
::
video
::
ITexture
*
img
=
GetTextureFromFile
(
file
,
width
,
height
);
if
(
img
==
NULL
)
{
std
::
snprintf
(
file
,
sizeof
file
,
"pics/thumbnail/%d.jpg"
,
code
);
mysnprintf
(
file
,
"pics/thumbnail/%d.jpg"
,
code
);
img
=
GetTextureFromFile
(
file
,
width
,
height
);
}
if
(
img
==
NULL
&&
mainGame
->
gameConf
.
use_image_scale
)
{
std
::
snprintf
(
file
,
sizeof
file
,
"expansions/pics/%d.jpg"
,
code
);
mysnprintf
(
file
,
"expansions/pics/%d.jpg"
,
code
);
img
=
GetTextureFromFile
(
file
,
width
,
height
);
if
(
img
==
NULL
)
{
std
::
snprintf
(
file
,
sizeof
file
,
"pics/%d.jpg"
,
code
);
mysnprintf
(
file
,
"pics/%d.jpg"
,
code
);
img
=
GetTextureFromFile
(
file
,
width
,
height
);
}
}
...
...
@@ -372,7 +372,7 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
if
(
lit
!=
tThumbLoading
.
end
())
{
if
(
lit
->
second
!=
nullptr
)
{
char
file
[
256
];
std
::
snprintf
(
file
,
sizeof
file
,
"pics/thumbnail/%d.jpg"
,
code
);
mysnprintf
(
file
,
"pics/thumbnail/%d.jpg"
,
code
);
irr
::
video
::
ITexture
*
texture
=
driver
->
addTexture
(
file
,
lit
->
second
);
// textures must be added in the main thread due to OpenGL
lit
->
second
->
drop
();
tThumb
[
code
]
=
texture
;
...
...
@@ -406,18 +406,18 @@ irr::video::ITexture* ImageManager::GetTextureField(int code) {
auto
tit
=
tFields
.
find
(
code
);
if
(
tit
==
tFields
.
end
())
{
char
file
[
256
];
std
::
snprintf
(
file
,
sizeof
file
,
"expansions/pics/field/%d.png"
,
code
);
mysnprintf
(
file
,
"expansions/pics/field/%d.png"
,
code
);
irr
::
video
::
ITexture
*
img
=
GetTextureFromFile
(
file
,
512
*
mainGame
->
xScale
,
512
*
mainGame
->
yScale
);
if
(
img
==
nullptr
)
{
std
::
snprintf
(
file
,
sizeof
file
,
"expansions/pics/field/%d.jpg"
,
code
);
mysnprintf
(
file
,
"expansions/pics/field/%d.jpg"
,
code
);
img
=
GetTextureFromFile
(
file
,
512
*
mainGame
->
xScale
,
512
*
mainGame
->
yScale
);
}
if
(
img
==
nullptr
)
{
std
::
snprintf
(
file
,
sizeof
file
,
"pics/field/%d.png"
,
code
);
mysnprintf
(
file
,
"pics/field/%d.png"
,
code
);
img
=
GetTextureFromFile
(
file
,
512
*
mainGame
->
xScale
,
512
*
mainGame
->
yScale
);
}
if
(
img
==
nullptr
)
{
std
::
snprintf
(
file
,
sizeof
file
,
"pics/field/%d.jpg"
,
code
);
mysnprintf
(
file
,
"pics/field/%d.jpg"
,
code
);
img
=
GetTextureFromFile
(
file
,
512
*
mainGame
->
xScale
,
512
*
mainGame
->
yScale
);
if
(
img
==
nullptr
)
{
tFields
[
code
]
=
nullptr
;
...
...
gframe/menu_handler.cpp
View file @
70af2f52
...
...
@@ -382,9 +382,9 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
int
flag
=
0
;
flag
+=
(
mainGame
->
chkBotHand
->
isChecked
()
?
0x1
:
0
);
char
arg2
[
8
];
std
::
snprintf
(
arg2
,
sizeof
arg2
,
"%d"
,
flag
);
mysnprintf
(
arg2
,
"%d"
,
flag
);
char
arg3
[
8
];
std
::
snprintf
(
arg3
,
sizeof
arg3
,
"%d"
,
mainGame
->
gameConf
.
serverport
);
mysnprintf
(
arg3
,
"%d"
,
mainGame
->
gameConf
.
serverport
);
execl
(
"./bot"
,
"bot"
,
arg1
,
arg2
,
arg3
,
nullptr
);
std
::
exit
(
0
);
}
else
{
...
...
gframe/myfilesystem.h
View file @
70af2f52
...
...
@@ -182,7 +182,7 @@ public:
bool
success
=
true
;
TraversalDir
(
dir
,
[
dir
,
&
success
](
const
char
*
name
,
bool
isdir
)
{
char
full_path
[
1024
];
int
len
=
std
::
snprintf
(
full_path
,
sizeof
full_path
,
"%s/%s"
,
dir
,
name
);
int
len
=
mysnprintf
(
full_path
,
"%s/%s"
,
dir
,
name
);
if
(
len
<
0
||
len
>=
(
int
)(
sizeof
full_path
))
{
success
=
false
;
return
;
...
...
@@ -228,7 +228,7 @@ public:
while
((
dirp
=
readdir
(
dir
))
!=
nullptr
)
{
file_unit
funit
;
char
fname
[
1024
];
int
len
=
std
::
snprintf
(
fname
,
sizeof
fname
,
"%s/%s"
,
path
,
dirp
->
d_name
);
int
len
=
mysnprintf
(
fname
,
"%s/%s"
,
path
,
dirp
->
d_name
);
if
(
len
<
0
||
len
>=
(
int
)(
sizeof
fname
))
continue
;
stat
(
fname
,
&
fileStat
);
...
...
gframe/replay_mode.cpp
View file @
70af2f52
...
...
@@ -212,7 +212,7 @@ bool ReplayMode::StartDuel() {
}
}
else
{
char
filename
[
256
]{};
std
::
snprintf
(
filename
,
sizeof
filename
,
"./single/%s"
,
cur_replay
.
script_name
.
c_str
());
mysnprintf
(
filename
,
"./single/%s"
,
cur_replay
.
script_name
.
c_str
());
if
(
!
preload_script
(
pduel
,
filename
))
{
return
false
;
}
...
...
gframe/sound_manager.cpp
View file @
70af2f52
...
...
@@ -218,7 +218,7 @@ void SoundManager::PlaySoundEffect(int sound) {
break
;
}
char
soundPath
[
40
];
std
::
snprintf
(
soundPath
,
40
,
"./sound/%s.wav"
,
soundName
);
mysnprintf
(
soundPath
,
"./sound/%s.wav"
,
soundName
);
SetSoundVolume
(
mainGame
->
gameConf
.
sound_volume
);
#ifdef YGOPRO_USE_MINIAUDIO
ma_engine_play_sound
(
&
engineSound
,
soundPath
,
nullptr
);
...
...
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