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-520DIY
ygopro
Commits
c6755471
Commit
c6755471
authored
Feb 18, 2025
by
Chen Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace snprintf, sscanf
parent
aedaf56f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
28 deletions
+28
-28
gframe/data_manager.cpp
gframe/data_manager.cpp
+5
-5
gframe/deck_manager.cpp
gframe/deck_manager.cpp
+1
-1
gframe/game.cpp
gframe/game.cpp
+7
-7
gframe/image_manager.cpp
gframe/image_manager.cpp
+13
-13
gframe/menu_handler.cpp
gframe/menu_handler.cpp
+2
-2
No files found.
gframe/data_manager.cpp
View file @
c6755471
...
...
@@ -140,26 +140,26 @@ void DataManager::ReadStringConfLine(const char* linebuf) {
char
strbuf
[
TEXT_LINE_SIZE
]{};
int
value
{};
wchar_t
strBuffer
[
4096
]{};
if
(
sscanf
(
linebuf
,
"!%63s"
,
strbuf
)
!=
1
)
if
(
s
td
::
s
scanf
(
linebuf
,
"!%63s"
,
strbuf
)
!=
1
)
return
;
if
(
!
std
::
strcmp
(
strbuf
,
"system"
))
{
if
(
sscanf
(
&
linebuf
[
7
],
"%d %240[^
\n
]"
,
&
value
,
strbuf
)
!=
2
)
if
(
s
td
::
s
scanf
(
&
linebuf
[
7
],
"%d %240[^
\n
]"
,
&
value
,
strbuf
)
!=
2
)
return
;
BufferIO
::
DecodeUTF8
(
strbuf
,
strBuffer
);
_sysStrings
[
value
]
=
strBuffer
;
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"victory"
))
{
if
(
sscanf
(
&
linebuf
[
8
],
"%x %240[^
\n
]"
,
&
value
,
strbuf
)
!=
2
)
if
(
s
td
::
s
scanf
(
&
linebuf
[
8
],
"%x %240[^
\n
]"
,
&
value
,
strbuf
)
!=
2
)
return
;
BufferIO
::
DecodeUTF8
(
strbuf
,
strBuffer
);
_victoryStrings
[
value
]
=
strBuffer
;
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"counter"
))
{
if
(
sscanf
(
&
linebuf
[
8
],
"%x %240[^
\n
]"
,
&
value
,
strbuf
)
!=
2
)
if
(
s
td
::
s
scanf
(
&
linebuf
[
8
],
"%x %240[^
\n
]"
,
&
value
,
strbuf
)
!=
2
)
return
;
BufferIO
::
DecodeUTF8
(
strbuf
,
strBuffer
);
_counterStrings
[
value
]
=
strBuffer
;
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"setname"
))
{
//using tab for comment
if
(
sscanf
(
&
linebuf
[
8
],
"%x %240[^
\t\n
]"
,
&
value
,
strbuf
)
!=
2
)
if
(
s
td
::
s
scanf
(
&
linebuf
[
8
],
"%x %240[^
\t\n
]"
,
&
value
,
strbuf
)
!=
2
)
return
;
BufferIO
::
DecodeUTF8
(
strbuf
,
strBuffer
);
_setnameStrings
[
value
]
=
strBuffer
;
...
...
gframe/deck_manager.cpp
View file @
c6755471
...
...
@@ -30,7 +30,7 @@ void DeckManager::LoadLFListSingle(const char* path) {
}
int
code
=
0
;
int
count
=
-
1
;
if
(
sscanf
(
linebuf
,
"%d %d"
,
&
code
,
&
count
)
!=
2
)
if
(
s
td
::
s
scanf
(
linebuf
,
"%d %d"
,
&
code
,
&
count
)
!=
2
)
continue
;
if
(
code
<=
0
||
code
>
MAX_CARD_ID
)
continue
;
...
...
gframe/game.cpp
View file @
c6755471
...
...
@@ -1285,17 +1285,17 @@ void Game::RefreshBot() {
continue
;
if
(
linebuf
[
0
]
==
'!'
)
{
BotInfo
newinfo
;
if
(
sscanf
(
linebuf
,
"!%240[^
\n
]"
,
strbuf
)
!=
1
)
if
(
s
td
::
s
scanf
(
linebuf
,
"!%240[^
\n
]"
,
strbuf
)
!=
1
)
continue
;
BufferIO
::
DecodeUTF8
(
strbuf
,
newinfo
.
name
);
if
(
!
std
::
fgets
(
linebuf
,
256
,
fp
))
break
;
if
(
sscanf
(
linebuf
,
"%240[^
\n
]"
,
strbuf
)
!=
1
)
if
(
s
td
::
s
scanf
(
linebuf
,
"%240[^
\n
]"
,
strbuf
)
!=
1
)
continue
;
BufferIO
::
DecodeUTF8
(
strbuf
,
newinfo
.
command
);
if
(
!
std
::
fgets
(
linebuf
,
256
,
fp
))
break
;
if
(
sscanf
(
linebuf
,
"%240[^
\n
]"
,
strbuf
)
!=
1
)
if
(
s
td
::
s
scanf
(
linebuf
,
"%240[^
\n
]"
,
strbuf
)
!=
1
)
continue
;
BufferIO
::
DecodeUTF8
(
strbuf
,
newinfo
.
desc
);
if
(
!
std
::
fgets
(
linebuf
,
256
,
fp
))
...
...
@@ -1336,7 +1336,7 @@ void Game::LoadConfig() {
char
strbuf
[
64
]{};
char
valbuf
[
960
]{};
while
(
std
::
fgets
(
linebuf
,
sizeof
linebuf
,
fp
))
{
if
(
sscanf
(
linebuf
,
"%63s = %959s"
,
strbuf
,
valbuf
)
!=
2
)
if
(
s
td
::
s
scanf
(
linebuf
,
"%63s = %959s"
,
strbuf
,
valbuf
)
!=
2
)
continue
;
if
(
!
std
::
strcmp
(
strbuf
,
"antialias"
))
{
gameConf
.
antialias
=
strtol
(
valbuf
,
nullptr
,
10
);
...
...
@@ -1349,7 +1349,7 @@ void Game::LoadConfig() {
enable_log
=
val
&
0xff
;
}
else
if
(
!
std
::
strcmp
(
strbuf
,
"textfont"
))
{
int
textfontsize
=
0
;
if
(
sscanf
(
linebuf
,
"%63s = %959s %d"
,
strbuf
,
valbuf
,
&
textfontsize
)
!=
3
)
if
(
s
td
::
s
scanf
(
linebuf
,
"%63s = %959s %d"
,
strbuf
,
valbuf
,
&
textfontsize
)
!=
3
)
continue
;
gameConf
.
textfontsize
=
textfontsize
;
BufferIO
::
DecodeUTF8
(
valbuf
,
gameConf
.
textfont
);
...
...
@@ -1447,7 +1447,7 @@ void Game::LoadConfig() {
#endif
}
else
{
// options allowing multiple words
if
(
sscanf
(
linebuf
,
"%63s = %959[^
\n
]"
,
strbuf
,
valbuf
)
!=
2
)
if
(
s
td
::
s
scanf
(
linebuf
,
"%63s = %959[^
\n
]"
,
strbuf
,
valbuf
)
!=
2
)
continue
;
if
(
!
std
::
strcmp
(
strbuf
,
"nickname"
))
{
BufferIO
::
DecodeUTF8
(
valbuf
,
gameConf
.
nickname
);
...
...
@@ -1715,7 +1715,7 @@ void Game::AddDebugMsg(const char* msg) {
}
if
(
enable_log
&
0x2
)
{
char
msgbuf
[
1040
];
snprintf
(
msgbuf
,
sizeof
msgbuf
,
"[Script Error]: %s"
,
msg
);
s
td
::
s
nprintf
(
msgbuf
,
sizeof
msgbuf
,
"[Script Error]: %s"
,
msg
);
ErrorLog
(
msgbuf
);
}
}
...
...
gframe/image_manager.cpp
View file @
c6755471
...
...
@@ -234,10 +234,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
];
snprintf
(
file
,
sizeof
file
,
"expansions/pics/%d.jpg"
,
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"expansions/pics/%d.jpg"
,
code
);
irr
::
video
::
ITexture
*
img
=
GetTextureFromFile
(
file
,
width
,
height
);
if
(
img
==
nullptr
)
{
snprintf
(
file
,
sizeof
file
,
"pics/%d.jpg"
,
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"pics/%d.jpg"
,
code
);
img
=
GetTextureFromFile
(
file
,
width
,
height
);
}
if
(
img
==
nullptr
&&
!
mainGame
->
gameConf
.
use_image_scale
)
{
...
...
@@ -261,10 +261,10 @@ irr::video::ITexture* ImageManager::GetBigPicture(int code, float zoom) {
}
irr
::
video
::
ITexture
*
texture
;
char
file
[
256
];
snprintf
(
file
,
sizeof
file
,
"expansions/pics/%d.jpg"
,
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"expansions/pics/%d.jpg"
,
code
);
irr
::
video
::
IImage
*
srcimg
=
driver
->
createImageFromFile
(
file
);
if
(
srcimg
==
nullptr
)
{
snprintf
(
file
,
sizeof
file
,
"pics/%d.jpg"
,
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"pics/%d.jpg"
,
code
);
srcimg
=
driver
->
createImageFromFile
(
file
);
}
if
(
srcimg
==
nullptr
)
{
...
...
@@ -290,18 +290,18 @@ int ImageManager::LoadThumbThread() {
imageManager
.
tThumbLoadingCodes
.
pop
();
imageManager
.
tThumbLoadingMutex
.
unlock
();
char
file
[
256
];
snprintf
(
file
,
sizeof
file
,
"expansions/pics/thumbnail/%d.jpg"
,
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"expansions/pics/thumbnail/%d.jpg"
,
code
);
irr
::
video
::
IImage
*
img
=
imageManager
.
driver
->
createImageFromFile
(
file
);
if
(
img
==
nullptr
)
{
snprintf
(
file
,
sizeof
file
,
"pics/thumbnail/%d.jpg"
,
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"pics/thumbnail/%d.jpg"
,
code
);
img
=
imageManager
.
driver
->
createImageFromFile
(
file
);
}
if
(
img
==
nullptr
&&
mainGame
->
gameConf
.
use_image_scale
)
{
snprintf
(
file
,
sizeof
file
,
"expansions/pics/%d.jpg"
,
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"expansions/pics/%d.jpg"
,
code
);
img
=
imageManager
.
driver
->
createImageFromFile
(
file
);
}
if
(
img
==
nullptr
&&
mainGame
->
gameConf
.
use_image_scale
)
{
snprintf
(
file
,
sizeof
file
,
"pics/%d.jpg"
,
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"pics/%d.jpg"
,
code
);
img
=
imageManager
.
driver
->
createImageFromFile
(
file
);
}
if
(
img
!=
nullptr
)
{
...
...
@@ -346,7 +346,7 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
if
(
lit
!=
tThumbLoading
.
end
())
{
if
(
lit
->
second
!=
nullptr
)
{
char
file
[
256
];
snprintf
(
file
,
sizeof
file
,
"pics/thumbnail/%d.jpg"
,
code
);
s
td
::
s
nprintf
(
file
,
sizeof
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
;
...
...
@@ -379,18 +379,18 @@ irr::video::ITexture* ImageManager::GetTextureField(int code) {
auto
tit
=
tFields
.
find
(
code
);
if
(
tit
==
tFields
.
end
())
{
char
file
[
256
];
snprintf
(
file
,
sizeof
file
,
"expansions/pics/field/%d.png"
,
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"expansions/pics/field/%d.png"
,
code
);
irr
::
video
::
ITexture
*
img
=
GetTextureFromFile
(
file
,
512
*
mainGame
->
xScale
,
512
*
mainGame
->
yScale
);
if
(
img
==
nullptr
)
{
snprintf
(
file
,
sizeof
file
,
"expansions/pics/field/%d.jpg"
,
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"expansions/pics/field/%d.jpg"
,
code
);
img
=
GetTextureFromFile
(
file
,
512
*
mainGame
->
xScale
,
512
*
mainGame
->
yScale
);
}
if
(
img
==
nullptr
)
{
snprintf
(
file
,
sizeof
file
,
"pics/field/%d.png"
,
code
);
s
td
::
s
nprintf
(
file
,
sizeof
file
,
"pics/field/%d.png"
,
code
);
img
=
GetTextureFromFile
(
file
,
512
*
mainGame
->
xScale
,
512
*
mainGame
->
yScale
);
}
if
(
img
==
nullptr
)
{
snprintf
(
file
,
sizeof
file
,
"pics/field/%d.jpg"
,
code
);
s
td
::
s
nprintf
(
file
,
sizeof
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 @
c6755471
...
...
@@ -396,9 +396,9 @@ bool MenuHandler::OnEvent(const irr::SEvent& event) {
int
flag
=
0
;
flag
+=
(
mainGame
->
chkBotHand
->
isChecked
()
?
0x1
:
0
);
char
arg2
[
8
];
snprintf
(
arg2
,
sizeof
arg2
,
"%d"
,
flag
);
s
td
::
s
nprintf
(
arg2
,
sizeof
arg2
,
"%d"
,
flag
);
char
arg3
[
8
];
snprintf
(
arg3
,
sizeof
arg3
,
"%d"
,
mainGame
->
gameConf
.
serverport
);
s
td
::
s
nprintf
(
arg3
,
sizeof
arg3
,
"%d"
,
mainGame
->
gameConf
.
serverport
);
execl
(
"./bot"
,
"bot"
,
arg1
,
arg2
,
arg3
,
nullptr
);
exit
(
0
);
}
else
{
...
...
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