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
xiaoye
ygopro
Commits
7da877f6
Commit
7da877f6
authored
Apr 13, 2025
by
nanahira
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into server-develop
parents
878ba230
8370d66f
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
79 additions
and
74 deletions
+79
-74
gframe/config.h
gframe/config.h
+15
-0
gframe/data_manager.cpp
gframe/data_manager.cpp
+2
-4
gframe/deck_manager.cpp
gframe/deck_manager.cpp
+1
-1
gframe/duelclient.cpp
gframe/duelclient.cpp
+3
-9
gframe/event_handler.cpp
gframe/event_handler.cpp
+0
-4
gframe/game.cpp
gframe/game.cpp
+6
-6
gframe/gframe.cpp
gframe/gframe.cpp
+6
-2
gframe/replay.cpp
gframe/replay.cpp
+2
-2
gframe/sound_manager.cpp
gframe/sound_manager.cpp
+36
-38
gframe/sound_manager.h
gframe/sound_manager.h
+8
-8
No files found.
gframe/config.h
View file @
7da877f6
...
...
@@ -79,6 +79,21 @@ inline FILE* mywfopen(const wchar_t* filename, const char* mode) {
return
fp
;
}
#if !defined(_WIN32)
#define myfopen std::fopen
#elif defined(WDK_NTDDI_VERSION) && (WDK_NTDDI_VERSION >= 0x0A000005) // Redstone 4, Version 1803, Build 17134.
#define FOPEN_WINDOWS_SUPPORT_UTF8
#define myfopen std::fopen
#else
inline
FILE
*
myfopen
(
const
char
*
filename
,
const
char
*
mode
)
{
wchar_t
wfilename
[
256
]{};
BufferIO
::
DecodeUTF8
(
filename
,
wfilename
);
wchar_t
wmode
[
20
]{};
BufferIO
::
CopyCharArray
(
mode
,
wmode
);
return
_wfopen
(
wfilename
,
wmode
);
}
#endif
#if !defined(YGOPRO_SERVER_MODE) || defined(SERVER_ZIP_SUPPORT)
#include <irrlicht.h>
#endif
...
...
gframe/data_manager.cpp
View file @
7da877f6
...
...
@@ -131,7 +131,7 @@ bool DataManager::LoadDB(const wchar_t* wfile) {
}
#ifndef YGOPRO_SERVER_MODE
bool
DataManager
::
LoadStrings
(
const
char
*
file
)
{
FILE
*
fp
=
std
::
fopen
(
file
,
"r"
);
FILE
*
fp
=
my
fopen
(
file
,
"r"
);
if
(
!
fp
)
return
false
;
char
linebuf
[
TEXT_LINE_SIZE
]{};
...
...
@@ -480,9 +480,7 @@ unsigned char* DataManager::ReadScriptFromIrrFS(const char* script_name, int* sl
}
#endif
unsigned
char
*
DataManager
::
ReadScriptFromFile
(
const
char
*
script_name
,
int
*
slen
)
{
wchar_t
fname
[
256
]{};
BufferIO
::
DecodeUTF8
(
script_name
,
fname
);
FILE
*
fp
=
mywfopen
(
fname
,
"rb"
);
FILE
*
fp
=
myfopen
(
script_name
,
"rb"
);
if
(
!
fp
)
return
nullptr
;
size_t
len
=
std
::
fread
(
scriptBuffer
,
1
,
sizeof
scriptBuffer
,
fp
);
...
...
gframe/deck_manager.cpp
View file @
7da877f6
...
...
@@ -13,7 +13,7 @@ DeckManager deckManager;
void
DeckManager
::
LoadLFListSingle
(
const
char
*
path
)
{
auto
cur
=
_lfList
.
rend
();
FILE
*
fp
=
std
::
fopen
(
path
,
"r"
);
FILE
*
fp
=
my
fopen
(
path
,
"r"
);
char
linebuf
[
256
]{};
wchar_t
strBuffer
[
256
]{};
if
(
fp
)
{
...
...
gframe/duelclient.cpp
View file @
7da877f6
...
...
@@ -1313,10 +1313,8 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
//playing custom bgm
case
21
:
{
//HINT_MUSIC
if
(
data
)
{
char
textBufferU
[
1024
];
myswprintf
(
textBuffer
,
L"./sound/BGM/custom/%ls.mp3"
,
dataManager
.
GetDesc
(
data
));
BufferIO
::
EncodeUTF8
(
textBuffer
,
textBufferU
);
soundManager
.
PlayCustomBGM
(
textBufferU
);
soundManager
.
PlayCustomBGM
(
textBuffer
);
}
else
{
soundManager
.
StopBGM
();
}
...
...
@@ -1325,10 +1323,8 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
//playing custom sound effect
case
22
:
{
//HINT_SOUND
if
(
data
)
{
char
textBufferU
[
1024
];
myswprintf
(
textBuffer
,
L"./sound/custom/%ls.wav"
,
dataManager
.
GetDesc
(
data
));
BufferIO
::
EncodeUTF8
(
textBuffer
,
textBufferU
);
soundManager
.
PlayCustomSound
(
textBufferU
);
soundManager
.
PlayCustomSound
(
textBuffer
);
}
else
{
soundManager
.
StopSound
();
}
...
...
@@ -1337,10 +1333,8 @@ bool DuelClient::ClientAnalyze(unsigned char* msg, int len) {
//playing custom bgm in ogg format
case
23
:
{
//HINT_MUSIC_OGG
if
(
data
)
{
char
textBufferU
[
1024
];
myswprintf
(
textBuffer
,
L"./sound/BGM/custom/%ls.ogg"
,
dataManager
.
GetDesc
(
data
));
BufferIO
::
EncodeUTF8
(
textBuffer
,
textBufferU
);
soundManager
.
PlayCustomBGM
(
textBufferU
);
soundManager
.
PlayCustomBGM
(
textBuffer
);
}
else
{
soundManager
.
StopBGM
();
}
...
...
gframe/event_handler.cpp
View file @
7da877f6
...
...
@@ -1933,7 +1933,6 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
return
true
;
break
;
}
#ifdef YGOPRO_USE_AUDIO
case
CHECKBOX_ENABLE_MUSIC
:
{
if
(
!
mainGame
->
chkEnableMusic
->
isChecked
())
soundManager
.
StopBGM
();
...
...
@@ -1946,7 +1945,6 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
return
true
;
break
;
}
#endif
case
CHECKBOX_DISABLE_CHAT
:
{
bool
show
=
(
mainGame
->
is_building
&&
!
mainGame
->
is_siding
)
?
false
:
true
;
mainGame
->
wChat
->
setVisible
(
show
);
...
...
@@ -2052,7 +2050,6 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
return
true
;
break
;
}
#ifdef YGOPRO_USE_AUDIO
case
SCROLL_VOLUME
:
{
mainGame
->
gameConf
.
sound_volume
=
(
double
)
mainGame
->
scrSoundVolume
->
getPos
()
/
100
;
mainGame
->
gameConf
.
music_volume
=
(
double
)
mainGame
->
scrMusicVolume
->
getPos
()
/
100
;
...
...
@@ -2061,7 +2058,6 @@ bool ClientField::OnCommonEvent(const irr::SEvent& event) {
return
true
;
break
;
}
#endif
case
SCROLL_TAB_HELPER
:
{
irr
::
core
::
rect
<
irr
::
s32
>
pos
=
mainGame
->
tabHelper
->
getRelativePosition
();
mainGame
->
tabHelper
->
setRelativePosition
(
irr
::
core
::
recti
(
0
,
mainGame
->
scrTabHelper
->
getPos
()
*
-
1
,
pos
.
LowerRightCorner
.
X
,
pos
.
LowerRightCorner
.
Y
));
...
...
gframe/game.cpp
View file @
7da877f6
...
...
@@ -1479,9 +1479,9 @@ void Game::RefreshBot() {
if
(
!
gameConf
.
enable_bot_mode
)
return
;
botInfo
.
clear
();
FILE
*
fp
=
std
::
fopen
(
GetLocaleDir
(
"bot.conf"
),
"r"
);
FILE
*
fp
=
my
fopen
(
GetLocaleDir
(
"bot.conf"
),
"r"
);
if
(
!
fp
)
fp
=
std
::
fopen
(
"bot.conf"
,
"r"
);
fp
=
my
fopen
(
"bot.conf"
,
"r"
);
char
linebuf
[
256
]{};
char
strbuf
[
256
]{};
if
(
fp
)
{
...
...
@@ -1542,7 +1542,7 @@ void Game::RefreshBot() {
}
}
bool
Game
::
LoadConfigFromFile
(
const
char
*
file
)
{
FILE
*
fp
=
std
::
fopen
(
file
,
"r"
);
FILE
*
fp
=
my
fopen
(
file
,
"r"
);
if
(
!
fp
){
return
false
;
}
...
...
@@ -1815,9 +1815,9 @@ void Game::LoadConfig() {
}
void
Game
::
SaveConfig
()
{
#ifdef YGOPRO_COMPAT_MYCARD
FILE
*
fp
=
std
::
fopen
(
"system.conf"
,
"w"
);
FILE
*
fp
=
my
fopen
(
"system.conf"
,
"w"
);
#else
FILE
*
fp
=
std
::
fopen
(
"system_user.conf"
,
"w"
);
FILE
*
fp
=
my
fopen
(
"system_user.conf"
,
"w"
);
#endif //YGOPRO_COMPAT_MYCARD
std
::
fprintf
(
fp
,
"#config file
\n
#nickname & gamename should be less than 20 characters
\n
"
);
char
linebuf
[
CONFIG_LINE_SIZE
];
...
...
@@ -2100,7 +2100,7 @@ void Game::AddDebugMsg(const char* msg) {
}
#ifndef YGOPRO_SERVER_MODE
void
Game
::
ErrorLog
(
const
char
*
msg
)
{
FILE
*
fp
=
std
::
fopen
(
"error.log"
,
"a"
);
FILE
*
fp
=
my
fopen
(
"error.log"
,
"a"
);
if
(
!
fp
)
return
;
time_t
nowtime
=
std
::
time
(
nullptr
);
...
...
gframe/gframe.cpp
View file @
7da877f6
...
...
@@ -27,8 +27,12 @@ void ClickButton(irr::gui::IGUIElement* btn) {
#endif //YGOPRO_SERVER_MODE
int
main
(
int
argc
,
char
*
argv
[])
{
#ifndef _WIN32
std
::
setlocale
(
LC_CTYPE
,
"UTF-8"
);
#if defined(FOPEN_WINDOWS_SUPPORT_UTF8)
std
::
setlocale
(
LC_CTYPE
,
".UTF-8"
);
#elif defined(__APPLE__)
std
::
setlocale
(
LC_CTYPE
,
"C.UTF-8"
);
#elif !defined(_WIN32)
std
::
setlocale
(
LC_CTYPE
,
""
);
#endif
#if defined __APPLE__ && !defined YGOPRO_SERVER_MODE
CFURLRef
bundle_url
=
CFBundleCopyBundleURL
(
CFBundleGetMainBundle
());
...
...
gframe/replay.cpp
View file @
7da877f6
...
...
@@ -48,9 +48,9 @@ void Replay::BeginRecord() {
strftime
(
tmppath
,
40
,
"./replay/%Y-%m-%d %H-%M-%S %%u.yrp"
,
localedtime
);
char
path
[
40
];
std
::
sprintf
(
path
,
tmppath
,
server_port
);
fp
=
std
::
fopen
(
path
,
"wb"
);
fp
=
my
fopen
(
path
,
"wb"
);
#else
fp
=
std
::
fopen
(
"./replay/_LastReplay.yrp"
,
"wb"
);
fp
=
my
fopen
(
"./replay/_LastReplay.yrp"
,
"wb"
);
#endif //YGOPRO_SERVER_MODE
if
(
!
fp
)
return
;
...
...
gframe/sound_manager.cpp
View file @
7da877f6
...
...
@@ -85,7 +85,7 @@ void SoundManager::RefershBGMDir(std::wstring path, int scene) {
}
});
}
void
SoundManager
::
PlaySound
(
char
*
sound
)
{
void
SoundManager
::
PlaySound
(
wchar_t
*
sound
)
{
#ifdef YGOPRO_USE_AUDIO
if
(
!
mainGame
->
chkEnableSound
->
isChecked
())
return
;
...
...
@@ -111,17 +111,13 @@ void SoundManager::PlaySound(char* sound) {
usingSoundEffectPointer
=
playingSoundEffect
[
0
];
ma_sound_uninit
(
usingSoundEffectPointer
);
}
#ifdef _WIN32
wchar_t
sound_w
[
1024
];
BufferIO
::
DecodeUTF8
(
sound
,
sound_w
);
ma_sound_init_from_file_w
(
&
engineSound
,
sound_w
,
MA_SOUND_FLAG_ASYNC
|
MA_SOUND_FLAG_STREAM
,
nullptr
,
nullptr
,
usingSoundEffectPointer
);
#else
ma_sound_init_from_file
(
&
engineSound
,
sound
,
MA_SOUND_FLAG_ASYNC
|
MA_SOUND_FLAG_STREAM
,
nullptr
,
nullptr
,
usingSoundEffectPointer
);
#endif
ma_sound_init_from_file_w
(
&
engineSound
,
sound
,
MA_SOUND_FLAG_ASYNC
|
MA_SOUND_FLAG_STREAM
,
nullptr
,
nullptr
,
usingSoundEffectPointer
);
ma_sound_start
(
usingSoundEffectPointer
);
#endif
#ifdef YGOPRO_USE_IRRKLANG
engineSound
->
play2D
(
sound
);
char
csound
[
1024
];
BufferIO
::
EncodeUTF8
(
sound
,
csound
);
engineSound
->
play2D
(
csound
);
#endif
#endif
}
...
...
@@ -258,12 +254,13 @@ void SoundManager::PlaySoundEffect(int sound) {
default:
break
;
}
char
soundPath
[
40
];
std
::
snprintf
(
soundPath
,
40
,
"./sound/%s.wav"
,
soundName
);
PlaySound
(
soundPath
);
wchar_t
soundPathW
[
40
];
myswprintf
(
soundPathW
,
L
"./sound/%s.wav"
,
soundName
);
PlaySound
(
soundPath
W
);
#endif // YGOPRO_USE_AUDIO
}
void
SoundManager
::
PlayDialogSound
(
irr
::
gui
::
IGUIElement
*
element
)
{
#ifdef YGOPRO_USE_AUDIO
if
(
element
==
mainGame
->
wMessage
)
{
PlaySoundEffect
(
SOUND_INFO
);
}
else
if
(
element
==
mainGame
->
wQuery
)
{
...
...
@@ -285,37 +282,44 @@ void SoundManager::PlayDialogSound(irr::gui::IGUIElement * element) {
}
else
if
(
element
==
mainGame
->
wFTSelect
)
{
PlaySoundEffect
(
SOUND_QUESTION
);
}
#endif // YGOPRO_USE_AUDIO
}
bool
SoundManager
::
Is
CurrentlyPlaying
(
char
*
song
)
{
bool
SoundManager
::
Is
PlayingMusic
(
wchar_t
*
music
)
{
#ifdef YGOPRO_USE_MINIAUDIO
return
currentPlayingMusic
[
0
]
&&
strcmp
(
currentPlayingMusic
,
song
)
==
0
&&
ma_sound_is_playing
(
&
soundBGM
);
if
(
music
)
{
return
!
mywcsncasecmp
(
currentPlayingMusic
,
music
,
1024
)
&&
ma_sound_is_playing
(
&
soundBGM
);
}
else
{
return
ma_sound_is_playing
(
&
soundBGM
);
}
#endif
#ifdef YGOPRO_USE_IRRKLANG
return
engineMusic
->
isCurrentlyPlaying
(
song
);
if
(
music
)
{
char
cmusic
[
1024
];
BufferIO
::
EncodeUTF8
(
music
,
cmusic
);
return
engineMusic
->
isCurrentlyPlaying
(
cmusic
);
}
else
{
return
soundBGM
&&
!
soundBGM
->
isFinished
();
}
#endif
return
false
;
}
void
SoundManager
::
PlayMusic
(
char
*
song
,
bool
loop
)
{
void
SoundManager
::
PlayMusic
(
wchar_t
*
music
,
bool
loop
)
{
#ifdef YGOPRO_USE_AUDIO
if
(
!
mainGame
->
chkEnableMusic
->
isChecked
())
return
;
if
(
!
Is
CurrentlyPlaying
(
song
))
{
if
(
!
Is
PlayingMusic
(
music
))
{
StopBGM
();
SetMusicVolume
(
mainGame
->
gameConf
.
music_volume
);
#ifdef YGOPRO_USE_MINIAUDIO
strcpy
(
currentPlayingMusic
,
song
);
#ifdef _WIN32
wchar_t
song_w
[
1024
];
BufferIO
::
DecodeUTF8
(
song
,
song_w
);
ma_sound_init_from_file_w
(
&
engineMusic
,
song_w
,
MA_SOUND_FLAG_ASYNC
|
MA_SOUND_FLAG_STREAM
,
nullptr
,
nullptr
,
&
soundBGM
);
#else
ma_sound_init_from_file
(
&
engineMusic
,
song
,
MA_SOUND_FLAG_ASYNC
|
MA_SOUND_FLAG_STREAM
,
nullptr
,
nullptr
,
&
soundBGM
);
#endif
BufferIO
::
CopyWStr
(
music
,
currentPlayingMusic
,
1024
);
ma_sound_init_from_file_w
(
&
engineMusic
,
music
,
MA_SOUND_FLAG_ASYNC
|
MA_SOUND_FLAG_STREAM
,
nullptr
,
nullptr
,
&
soundBGM
);
ma_sound_set_looping
(
&
soundBGM
,
loop
);
ma_sound_start
(
&
soundBGM
);
#endif
#ifdef YGOPRO_USE_IRRKLANG
soundBGM
=
engineMusic
->
play2D
(
song
,
loop
,
false
,
true
);
char
cmusic
[
1024
];
BufferIO
::
EncodeUTF8
(
music
,
cmusic
);
soundBGM
=
engineMusic
->
play2D
(
cmusic
,
loop
,
false
,
true
);
#endif
}
#endif
...
...
@@ -326,28 +330,22 @@ void SoundManager::PlayBGM(int scene) {
return
;
if
(
!
mainGame
->
chkMusicMode
->
isChecked
())
scene
=
BGM_ALL
;
char
BGMName
[
1024
];
#if defined(YGOPRO_USE_MINIAUDIO)
if
((
scene
!=
bgm_scene
)
&&
(
bgm_scene
!=
BGM_CUSTOM
)
||
(
scene
!=
previous_bgm_scene
)
&&
(
bgm_scene
==
BGM_CUSTOM
)
||
!
IsCurrentlyPlaying
(
currentPlayingMusic
))
{
#elif defined(YGOPRO_USE_IRRKLANG)
if
((
scene
!=
bgm_scene
)
&&
(
bgm_scene
!=
BGM_CUSTOM
)
||
(
scene
!=
previous_bgm_scene
)
&&
(
bgm_scene
==
BGM_CUSTOM
)
||
(
soundBGM
&&
soundBGM
->
isFinished
()))
{
#endif
if
((
scene
!=
bgm_scene
)
&&
(
bgm_scene
!=
BGM_CUSTOM
)
||
(
scene
!=
previous_bgm_scene
)
&&
(
bgm_scene
==
BGM_CUSTOM
)
||
!
IsPlayingMusic
())
{
int
count
=
BGMList
[
scene
].
size
();
if
(
count
<=
0
)
return
;
bgm_scene
=
scene
;
int
bgm
=
rnd
.
get_random_integer
(
0
,
count
-
1
);
auto
name
=
BGMList
[
scene
][
bgm
].
c_str
();
wchar_t
fname
[
1024
];
myswprintf
(
fname
,
L"./sound/BGM/%ls"
,
name
);
BufferIO
::
EncodeUTF8
(
fname
,
BGMName
);
wchar_t
BGMName
[
1024
];
myswprintf
(
BGMName
,
L"./sound/BGM/%ls"
,
name
);
PlayMusic
(
BGMName
,
false
);
}
#endif
}
void
SoundManager
::
PlayCustomBGM
(
char
*
BGMName
)
{
void
SoundManager
::
PlayCustomBGM
(
wchar_t
*
BGMName
)
{
#ifdef YGOPRO_USE_AUDIO
if
(
!
mainGame
->
chkEnableMusic
->
isChecked
()
||
!
mainGame
->
chkMusicMode
->
isChecked
()
||
bgm_process
||
Is
CurrentlyPlaying
(
BGMName
))
if
(
!
mainGame
->
chkEnableMusic
->
isChecked
()
||
!
mainGame
->
chkMusicMode
->
isChecked
()
||
bgm_process
||
Is
PlayingMusic
(
BGMName
))
return
;
bgm_process
=
true
;
int
pscene
=
bgm_scene
;
...
...
@@ -358,7 +356,7 @@ void SoundManager::PlayCustomBGM(char* BGMName) {
bgm_process
=
false
;
#endif
}
void
SoundManager
::
PlayCustomSound
(
char
*
SoundName
)
{
void
SoundManager
::
PlayCustomSound
(
wchar_t
*
SoundName
)
{
PlaySound
(
SoundName
);
}
void
SoundManager
::
StopBGM
()
{
...
...
gframe/sound_manager.h
View file @
7da877f6
...
...
@@ -15,8 +15,8 @@ namespace ygo {
class
SoundManager
{
private:
std
::
vector
<
std
::
wstring
>
BGMList
[
9
];
int
bgm_scene
;
int
previous_bgm_scene
;
int
bgm_scene
{}
;
int
previous_bgm_scene
{}
;
bool
bgm_process
;
mt19937
rnd
;
#ifdef YGOPRO_USE_MINIAUDIO
...
...
@@ -28,7 +28,7 @@ private:
ma_engine
engineSound
;
ma_engine
engineMusic
;
ma_sound
soundBGM
;
char
currentPlayingMusic
[
1024
]{};
wchar_t
currentPlayingMusic
[
1024
]{};
ma_sound
*
playingSoundEffect
[
10
]{};
#endif
#ifdef YGOPRO_USE_IRRKLANG
...
...
@@ -41,14 +41,14 @@ private:
public:
bool
Init
();
void
RefreshBGMList
();
void
PlaySound
(
char
*
sound
);
void
PlaySound
(
wchar_t
*
sound
);
void
PlaySoundEffect
(
int
sound
);
void
PlayDialogSound
(
irr
::
gui
::
IGUIElement
*
element
);
bool
Is
CurrentlyPlaying
(
char
*
song
);
void
PlayMusic
(
char
*
song
,
bool
loop
);
bool
Is
PlayingMusic
(
wchar_t
*
music
=
0
);
void
PlayMusic
(
wchar_t
*
music
,
bool
loop
);
void
PlayBGM
(
int
scene
);
void
PlayCustomBGM
(
char
*
BGMName
);
void
PlayCustomSound
(
char
*
SoundName
);
void
PlayCustomBGM
(
wchar_t
*
BGMName
);
void
PlayCustomSound
(
wchar_t
*
SoundName
);
void
StopBGM
();
void
StopSound
();
void
SetSoundVolume
(
double
volume
);
...
...
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