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
cfe114f4
Commit
cfe114f4
authored
Feb 18, 2025
by
Chen Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace fprintf
parent
c6755471
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
67 additions
and
67 deletions
+67
-67
gframe/deck_manager.cpp
gframe/deck_manager.cpp
+12
-12
gframe/game.cpp
gframe/game.cpp
+55
-55
No files found.
gframe/deck_manager.cpp
View file @
cfe114f4
...
@@ -316,15 +316,15 @@ bool DeckManager::SaveDeck(Deck& deck, const wchar_t* file) {
...
@@ -316,15 +316,15 @@ bool DeckManager::SaveDeck(Deck& deck, const wchar_t* file) {
FILE
*
fp
=
OpenDeckFile
(
file
,
"w"
);
FILE
*
fp
=
OpenDeckFile
(
file
,
"w"
);
if
(
!
fp
)
if
(
!
fp
)
return
false
;
return
false
;
fprintf
(
fp
,
"#created by ...
\n
#main
\n
"
);
std
::
fprintf
(
fp
,
"#created by ...
\n
#main
\n
"
);
for
(
size_t
i
=
0
;
i
<
deck
.
main
.
size
();
++
i
)
for
(
size_t
i
=
0
;
i
<
deck
.
main
.
size
();
++
i
)
fprintf
(
fp
,
"%d
\n
"
,
deck
.
main
[
i
]
->
first
);
std
::
fprintf
(
fp
,
"%d
\n
"
,
deck
.
main
[
i
]
->
first
);
fprintf
(
fp
,
"#extra
\n
"
);
std
::
fprintf
(
fp
,
"#extra
\n
"
);
for
(
size_t
i
=
0
;
i
<
deck
.
extra
.
size
();
++
i
)
for
(
size_t
i
=
0
;
i
<
deck
.
extra
.
size
();
++
i
)
fprintf
(
fp
,
"%d
\n
"
,
deck
.
extra
[
i
]
->
first
);
std
::
fprintf
(
fp
,
"%d
\n
"
,
deck
.
extra
[
i
]
->
first
);
fprintf
(
fp
,
"!side
\n
"
);
std
::
fprintf
(
fp
,
"!side
\n
"
);
for
(
size_t
i
=
0
;
i
<
deck
.
side
.
size
();
++
i
)
for
(
size_t
i
=
0
;
i
<
deck
.
side
.
size
();
++
i
)
fprintf
(
fp
,
"%d
\n
"
,
deck
.
side
[
i
]
->
first
);
std
::
fprintf
(
fp
,
"%d
\n
"
,
deck
.
side
[
i
]
->
first
);
std
::
fclose
(
fp
);
std
::
fclose
(
fp
);
return
true
;
return
true
;
}
}
...
@@ -375,23 +375,23 @@ bool DeckManager::SaveDeckBuffer(const int deckbuf[], const wchar_t* name) {
...
@@ -375,23 +375,23 @@ bool DeckManager::SaveDeckBuffer(const int deckbuf[], const wchar_t* name) {
int
it
=
0
;
int
it
=
0
;
const
int
mainc
=
deckbuf
[
it
];
const
int
mainc
=
deckbuf
[
it
];
++
it
;
++
it
;
fprintf
(
fp
,
"#created by ...
\n
#main
\n
"
);
std
::
fprintf
(
fp
,
"#created by ...
\n
#main
\n
"
);
for
(
int
i
=
0
;
i
<
mainc
;
++
i
)
{
for
(
int
i
=
0
;
i
<
mainc
;
++
i
)
{
fprintf
(
fp
,
"%d
\n
"
,
deckbuf
[
it
]);
std
::
fprintf
(
fp
,
"%d
\n
"
,
deckbuf
[
it
]);
++
it
;
++
it
;
}
}
const
int
extrac
=
deckbuf
[
it
];
const
int
extrac
=
deckbuf
[
it
];
++
it
;
++
it
;
fprintf
(
fp
,
"#extra
\n
"
);
std
::
fprintf
(
fp
,
"#extra
\n
"
);
for
(
int
i
=
0
;
i
<
extrac
;
++
i
)
{
for
(
int
i
=
0
;
i
<
extrac
;
++
i
)
{
fprintf
(
fp
,
"%d
\n
"
,
deckbuf
[
it
]);
std
::
fprintf
(
fp
,
"%d
\n
"
,
deckbuf
[
it
]);
++
it
;
++
it
;
}
}
const
int
sidec
=
deckbuf
[
it
];
const
int
sidec
=
deckbuf
[
it
];
++
it
;
++
it
;
fprintf
(
fp
,
"!side
\n
"
);
std
::
fprintf
(
fp
,
"!side
\n
"
);
for
(
int
i
=
0
;
i
<
sidec
;
++
i
)
{
for
(
int
i
=
0
;
i
<
sidec
;
++
i
)
{
fprintf
(
fp
,
"%d
\n
"
,
deckbuf
[
it
]);
std
::
fprintf
(
fp
,
"%d
\n
"
,
deckbuf
[
it
]);
++
it
;
++
it
;
}
}
std
::
fclose
(
fp
);
std
::
fclose
(
fp
);
...
...
gframe/game.cpp
View file @
cfe114f4
...
@@ -1468,75 +1468,75 @@ void Game::LoadConfig() {
...
@@ -1468,75 +1468,75 @@ void Game::LoadConfig() {
}
}
void Game::SaveConfig() {
void Game::SaveConfig() {
FILE* fp = std::fopen("system.conf", "w");
FILE* fp = std::fopen("system.conf", "w");
fprintf
(
fp
,
"#config file
\n
#nickname & gamename should be less than 20 characters
\n
"
);
std::
fprintf(fp, "#config file\n#nickname & gamename should be less than 20 characters\n");
char linebuf[CONFIG_LINE_SIZE];
char linebuf[CONFIG_LINE_SIZE];
fprintf
(
fp
,
"use_d3d = %d
\n
"
,
gameConf
.
use_d3d
?
1
:
0
);
std::
fprintf(fp, "use_d3d = %d\n", gameConf.use_d3d ? 1 : 0);
fprintf
(
fp
,
"use_image_scale = %d
\n
"
,
gameConf
.
use_image_scale
?
1
:
0
);
std::
fprintf(fp, "use_image_scale = %d\n", gameConf.use_image_scale ? 1 : 0);
fprintf
(
fp
,
"antialias = %d
\n
"
,
gameConf
.
antialias
);
std::
fprintf(fp, "antialias = %d\n", gameConf.antialias);
fprintf
(
fp
,
"errorlog = %u
\n
"
,
enable_log
);
std::
fprintf(fp, "errorlog = %u\n", enable_log);
BufferIO::CopyWideString(ebNickName->getText(), gameConf.nickname);
BufferIO::CopyWideString(ebNickName->getText(), gameConf.nickname);
BufferIO::EncodeUTF8(gameConf.nickname, linebuf);
BufferIO::EncodeUTF8(gameConf.nickname, linebuf);
fprintf
(
fp
,
"nickname = %s
\n
"
,
linebuf
);
std::
fprintf(fp, "nickname = %s\n", linebuf);
BufferIO::EncodeUTF8(gameConf.gamename, linebuf);
BufferIO::EncodeUTF8(gameConf.gamename, linebuf);
fprintf
(
fp
,
"gamename = %s
\n
"
,
linebuf
);
std::
fprintf(fp, "gamename = %s\n", linebuf);
BufferIO::EncodeUTF8(gameConf.lastcategory, linebuf);
BufferIO::EncodeUTF8(gameConf.lastcategory, linebuf);
fprintf
(
fp
,
"lastcategory = %s
\n
"
,
linebuf
);
std::
fprintf(fp, "lastcategory = %s\n", linebuf);
BufferIO::EncodeUTF8(gameConf.lastdeck, linebuf);
BufferIO::EncodeUTF8(gameConf.lastdeck, linebuf);
fprintf
(
fp
,
"lastdeck = %s
\n
"
,
linebuf
);
std::
fprintf(fp, "lastdeck = %s\n", linebuf);
BufferIO::EncodeUTF8(gameConf.textfont, linebuf);
BufferIO::EncodeUTF8(gameConf.textfont, linebuf);
fprintf
(
fp
,
"textfont = %s %d
\n
"
,
linebuf
,
gameConf
.
textfontsize
);
std::
fprintf(fp, "textfont = %s %d\n", linebuf, gameConf.textfontsize);
BufferIO::EncodeUTF8(gameConf.numfont, linebuf);
BufferIO::EncodeUTF8(gameConf.numfont, linebuf);
fprintf
(
fp
,
"numfont = %s
\n
"
,
linebuf
);
std::
fprintf(fp, "numfont = %s\n", linebuf);
fprintf
(
fp
,
"serverport = %d
\n
"
,
gameConf
.
serverport
);
std::
fprintf(fp, "serverport = %d\n", gameConf.serverport);
BufferIO::EncodeUTF8(gameConf.lasthost, linebuf);
BufferIO::EncodeUTF8(gameConf.lasthost, linebuf);
fprintf
(
fp
,
"lasthost = %s
\n
"
,
linebuf
);
std::
fprintf(fp, "lasthost = %s\n", linebuf);
BufferIO::EncodeUTF8(gameConf.lastport, linebuf);
BufferIO::EncodeUTF8(gameConf.lastport, linebuf);
fprintf
(
fp
,
"lastport = %s
\n
"
,
linebuf
);
std::
fprintf(fp, "lastport = %s\n", linebuf);
//settings
//settings
fprintf
(
fp
,
"automonsterpos = %d
\n
"
,
(
chkMAutoPos
->
isChecked
()
?
1
:
0
));
std::
fprintf(fp, "automonsterpos = %d\n", (chkMAutoPos->isChecked() ? 1 : 0));
fprintf
(
fp
,
"autospellpos = %d
\n
"
,
(
chkSTAutoPos
->
isChecked
()
?
1
:
0
));
std::
fprintf(fp, "autospellpos = %d\n", (chkSTAutoPos->isChecked() ? 1 : 0));
fprintf
(
fp
,
"randompos = %d
\n
"
,
(
chkRandomPos
->
isChecked
()
?
1
:
0
));
std::
fprintf(fp, "randompos = %d\n", (chkRandomPos->isChecked() ? 1 : 0));
fprintf
(
fp
,
"autochain = %d
\n
"
,
(
chkAutoChain
->
isChecked
()
?
1
:
0
));
std::
fprintf(fp, "autochain = %d\n", (chkAutoChain->isChecked() ? 1 : 0));
fprintf
(
fp
,
"waitchain = %d
\n
"
,
(
chkWaitChain
->
isChecked
()
?
1
:
0
));
std::
fprintf(fp, "waitchain = %d\n", (chkWaitChain->isChecked() ? 1 : 0));
fprintf
(
fp
,
"showchain = %d
\n
"
,
(
chkDefaultShowChain
->
isChecked
()
?
1
:
0
));
std::
fprintf(fp, "showchain = %d\n", (chkDefaultShowChain->isChecked() ? 1 : 0));
fprintf
(
fp
,
"mute_opponent = %d
\n
"
,
(
chkIgnore1
->
isChecked
()
?
1
:
0
));
std::
fprintf(fp, "mute_opponent = %d\n", (chkIgnore1->isChecked() ? 1 : 0));
fprintf
(
fp
,
"mute_spectators = %d
\n
"
,
(
chkIgnore2
->
isChecked
()
?
1
:
0
));
std::
fprintf(fp, "mute_spectators = %d\n", (chkIgnore2->isChecked() ? 1 : 0));
fprintf
(
fp
,
"use_lflist = %d
\n
"
,
gameConf
.
use_lflist
);
std::
fprintf(fp, "use_lflist = %d\n", gameConf.use_lflist);
fprintf
(
fp
,
"default_lflist = %d
\n
"
,
gameConf
.
default_lflist
);
std::
fprintf(fp, "default_lflist = %d\n", gameConf.default_lflist);
fprintf
(
fp
,
"default_rule = %d
\n
"
,
gameConf
.
default_rule
==
DEFAULT_DUEL_RULE
?
0
:
gameConf
.
default_rule
);
std::
fprintf(fp, "default_rule = %d\n", gameConf.default_rule == DEFAULT_DUEL_RULE ? 0 : gameConf.default_rule);
fprintf
(
fp
,
"hide_setname = %d
\n
"
,
gameConf
.
hide_setname
);
std::
fprintf(fp, "hide_setname = %d\n", gameConf.hide_setname);
fprintf
(
fp
,
"hide_hint_button = %d
\n
"
,
gameConf
.
hide_hint_button
);
std::
fprintf(fp, "hide_hint_button = %d\n", gameConf.hide_hint_button);
fprintf
(
fp
,
"#control_mode = 0: Key A/S/D/R Chain Buttons. control_mode = 1: MouseLeft/MouseRight/NULL/F9 Without Chain Buttons
\n
"
);
std::
fprintf(fp, "#control_mode = 0: Key A/S/D/R Chain Buttons. control_mode = 1: MouseLeft/MouseRight/NULL/F9 Without Chain Buttons\n");
fprintf
(
fp
,
"control_mode = %d
\n
"
,
gameConf
.
control_mode
);
std::
fprintf(fp, "control_mode = %d\n", gameConf.control_mode);
fprintf
(
fp
,
"draw_field_spell = %d
\n
"
,
gameConf
.
draw_field_spell
);
std::
fprintf(fp, "draw_field_spell = %d\n", gameConf.draw_field_spell);
fprintf
(
fp
,
"separate_clear_button = %d
\n
"
,
gameConf
.
separate_clear_button
);
std::
fprintf(fp, "separate_clear_button = %d\n", gameConf.separate_clear_button);
fprintf
(
fp
,
"#auto_search_limit >= 0: Start search automatically when the user enters N chars
\n
"
);
std::
fprintf(fp, "#auto_search_limit >= 0: Start search automatically when the user enters N chars\n");
fprintf
(
fp
,
"auto_search_limit = %d
\n
"
,
gameConf
.
auto_search_limit
);
std::
fprintf(fp, "auto_search_limit = %d\n", gameConf.auto_search_limit);
fprintf
(
fp
,
"#search_multiple_keywords = 0: Disable. 1: Search mutiple keywords with separator
\"
\"
. 2: with separator
\"
+
\"\n
"
);
std::
fprintf(fp, "#search_multiple_keywords = 0: Disable. 1: Search mutiple keywords with separator \" \". 2: with separator \"+\"\n");
fprintf
(
fp
,
"search_multiple_keywords = %d
\n
"
,
gameConf
.
search_multiple_keywords
);
std::
fprintf(fp, "search_multiple_keywords = %d\n", gameConf.search_multiple_keywords);
fprintf
(
fp
,
"ignore_deck_changes = %d
\n
"
,
(
chkIgnoreDeckChanges
->
isChecked
()
?
1
:
0
));
std::
fprintf(fp, "ignore_deck_changes = %d\n", (chkIgnoreDeckChanges->isChecked() ? 1 : 0));
fprintf
(
fp
,
"default_ot = %d
\n
"
,
gameConf
.
defaultOT
);
std::
fprintf(fp, "default_ot = %d\n", gameConf.defaultOT);
fprintf
(
fp
,
"enable_bot_mode = %d
\n
"
,
gameConf
.
enable_bot_mode
);
std::
fprintf(fp, "enable_bot_mode = %d\n", gameConf.enable_bot_mode);
BufferIO::EncodeUTF8(gameConf.bot_deck_path, linebuf);
BufferIO::EncodeUTF8(gameConf.bot_deck_path, linebuf);
fprintf
(
fp
,
"bot_deck_path = %s
\n
"
,
linebuf
);
std::
fprintf(fp, "bot_deck_path = %s\n", linebuf);
fprintf
(
fp
,
"quick_animation = %d
\n
"
,
gameConf
.
quick_animation
);
std::
fprintf(fp, "quick_animation = %d\n", gameConf.quick_animation);
fprintf
(
fp
,
"auto_save_replay = %d
\n
"
,
(
chkAutoSaveReplay
->
isChecked
()
?
1
:
0
));
std::
fprintf(fp, "auto_save_replay = %d\n", (chkAutoSaveReplay->isChecked() ? 1 : 0));
fprintf
(
fp
,
"draw_single_chain = %d
\n
"
,
gameConf
.
draw_single_chain
);
std::
fprintf(fp, "draw_single_chain = %d\n", gameConf.draw_single_chain);
fprintf
(
fp
,
"hide_player_name = %d
\n
"
,
gameConf
.
hide_player_name
);
std::
fprintf(fp, "hide_player_name = %d\n", gameConf.hide_player_name);
fprintf
(
fp
,
"prefer_expansion_script = %d
\n
"
,
gameConf
.
prefer_expansion_script
);
std::
fprintf(fp, "prefer_expansion_script = %d\n", gameConf.prefer_expansion_script);
fprintf
(
fp
,
"window_maximized = %d
\n
"
,
(
gameConf
.
window_maximized
?
1
:
0
));
std::
fprintf(fp, "window_maximized = %d\n", (gameConf.window_maximized ? 1 : 0));
fprintf
(
fp
,
"window_width = %d
\n
"
,
gameConf
.
window_width
);
std::
fprintf(fp, "window_width = %d\n", gameConf.window_width);
fprintf
(
fp
,
"window_height = %d
\n
"
,
gameConf
.
window_height
);
std::
fprintf(fp, "window_height = %d\n", gameConf.window_height);
fprintf
(
fp
,
"resize_popup_menu = %d
\n
"
,
gameConf
.
resize_popup_menu
?
1
:
0
);
std::
fprintf(fp, "resize_popup_menu = %d\n", gameConf.resize_popup_menu ? 1 : 0);
#ifdef YGOPRO_USE_IRRKLANG
#ifdef YGOPRO_USE_IRRKLANG
fprintf
(
fp
,
"enable_sound = %d
\n
"
,
(
chkEnableSound
->
isChecked
()
?
1
:
0
));
std::
fprintf(fp, "enable_sound = %d\n", (chkEnableSound->isChecked() ? 1 : 0));
fprintf
(
fp
,
"enable_music = %d
\n
"
,
(
chkEnableMusic
->
isChecked
()
?
1
:
0
));
std::
fprintf(fp, "enable_music = %d\n", (chkEnableMusic->isChecked() ? 1 : 0));
fprintf
(
fp
,
"#Volume of sound and music, between 0 and 100
\n
"
);
std::
fprintf(fp, "#Volume of sound and music, between 0 and 100\n");
int vol = gameConf.sound_volume * 100;
int vol = gameConf.sound_volume * 100;
fprintf
(
fp
,
"sound_volume = %d
\n
"
,
vol
);
std::
fprintf(fp, "sound_volume = %d\n", vol);
vol = gameConf.music_volume * 100;
vol = gameConf.music_volume * 100;
fprintf
(
fp
,
"music_volume = %d
\n
"
,
vol
);
std::
fprintf(fp, "music_volume = %d\n", vol);
fprintf
(
fp
,
"music_mode = %d
\n
"
,
(
chkMusicMode
->
isChecked
()
?
1
:
0
));
std::
fprintf(fp, "music_mode = %d\n", (chkMusicMode->isChecked() ? 1 : 0));
#endif
#endif
std::fclose(fp);
std::fclose(fp);
}
}
...
@@ -1726,7 +1726,7 @@ void Game::ErrorLog(const char* msg) {
...
@@ -1726,7 +1726,7 @@ void Game::ErrorLog(const char* msg) {
time_t nowtime = std::time(nullptr);
time_t nowtime = std::time(nullptr);
char timebuf[40];
char timebuf[40];
std::strftime(timebuf, sizeof timebuf, "%Y-%m-%d %H:%M:%S", std::localtime(&nowtime));
std::strftime(timebuf, sizeof timebuf, "%Y-%m-%d %H:%M:%S", std::localtime(&nowtime));
fprintf
(
fp
,
"[%s]%s
\n
"
,
timebuf
,
msg
);
std::
fprintf(fp, "[%s]%s\n", timebuf, msg);
std::fclose(fp);
std::fclose(fp);
}
}
void Game::ClearTextures() {
void Game::ClearTextures() {
...
...
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