Commit 38b2bc5d authored by salix5's avatar salix5 Committed by GitHub

Use std::string in PlaySoundEffect (#2967)

parent dbaa047a
...@@ -88,143 +88,142 @@ void SoundManager::PlaySoundEffect(int sound) { ...@@ -88,143 +88,142 @@ void SoundManager::PlaySoundEffect(int sound) {
#ifdef YGOPRO_USE_AUDIO #ifdef YGOPRO_USE_AUDIO
if(!mainGame->chkEnableSound->isChecked()) if(!mainGame->chkEnableSound->isChecked())
return; return;
char soundName[32]; std::string soundName;
switch(sound) { switch(sound) {
case SOUND_SUMMON: { case SOUND_SUMMON: {
strcpy(soundName, "summon"); soundName = "summon";
break; break;
} }
case SOUND_SPECIAL_SUMMON: { case SOUND_SPECIAL_SUMMON: {
strcpy(soundName, "specialsummon"); soundName = "specialsummon";
break; break;
} }
case SOUND_ACTIVATE: { case SOUND_ACTIVATE: {
strcpy(soundName, "activate"); soundName = "activate";
break; break;
} }
case SOUND_SET: { case SOUND_SET: {
strcpy(soundName, "set"); soundName = "set";
break; break;
} }
case SOUND_FLIP: { case SOUND_FLIP: {
strcpy(soundName, "flip"); soundName = "flip";
break; break;
} }
case SOUND_REVEAL: { case SOUND_REVEAL: {
strcpy(soundName, "reveal"); soundName = "reveal";
break; break;
} }
case SOUND_EQUIP: { case SOUND_EQUIP: {
strcpy(soundName, "equip"); soundName = "equip";
break; break;
} }
case SOUND_DESTROYED: { case SOUND_DESTROYED: {
strcpy(soundName, "destroyed"); soundName = "destroyed";
break; break;
} }
case SOUND_BANISHED: { case SOUND_BANISHED: {
strcpy(soundName, "banished"); soundName = "banished";
break; break;
} }
case SOUND_TOKEN: { case SOUND_TOKEN: {
strcpy(soundName, "token"); soundName = "token";
break; break;
} }
case SOUND_NEGATE: { case SOUND_NEGATE: {
strcpy(soundName, "negate"); soundName = "negate";
break; break;
} }
case SOUND_ATTACK: { case SOUND_ATTACK: {
strcpy(soundName, "attack"); soundName = "attack";
break; break;
} }
case SOUND_DIRECT_ATTACK: { case SOUND_DIRECT_ATTACK: {
strcpy(soundName, "directattack"); soundName = "directattack";
break; break;
} }
case SOUND_DRAW: { case SOUND_DRAW: {
strcpy(soundName, "draw"); soundName = "draw";
break; break;
} }
case SOUND_SHUFFLE: { case SOUND_SHUFFLE: {
strcpy(soundName, "shuffle"); soundName = "shuffle";
break; break;
} }
case SOUND_DAMAGE: { case SOUND_DAMAGE: {
strcpy(soundName, "damage"); soundName = "damage";
break; break;
} }
case SOUND_RECOVER: { case SOUND_RECOVER: {
strcpy(soundName, "gainlp"); soundName = "gainlp";
break; break;
} }
case SOUND_COUNTER_ADD: { case SOUND_COUNTER_ADD: {
strcpy(soundName, "addcounter"); soundName = "addcounter";
break; break;
} }
case SOUND_COUNTER_REMOVE: { case SOUND_COUNTER_REMOVE: {
strcpy(soundName, "removecounter"); soundName = "removecounter";
break; break;
} }
case SOUND_COIN: { case SOUND_COIN: {
strcpy(soundName, "coinflip"); soundName = "coinflip";
break; break;
} }
case SOUND_DICE: { case SOUND_DICE: {
strcpy(soundName, "diceroll"); soundName = "diceroll";
break; break;
} }
case SOUND_NEXT_TURN: { case SOUND_NEXT_TURN: {
strcpy(soundName, "nextturn"); soundName = "nextturn";
break; break;
} }
case SOUND_PHASE: { case SOUND_PHASE: {
strcpy(soundName, "phase"); soundName = "phase";
break; break;
} }
case SOUND_MENU: { case SOUND_MENU: {
strcpy(soundName, "menu"); soundName = "menu";
break; break;
} }
case SOUND_BUTTON: { case SOUND_BUTTON: {
strcpy(soundName, "button"); soundName = "button";
break; break;
} }
case SOUND_INFO: { case SOUND_INFO: {
strcpy(soundName, "info"); soundName = "info";
break; break;
} }
case SOUND_QUESTION: { case SOUND_QUESTION: {
strcpy(soundName, "question"); soundName = "question";
break; break;
} }
case SOUND_CARD_PICK: { case SOUND_CARD_PICK: {
strcpy(soundName, "cardpick"); soundName = "cardpick";
break; break;
} }
case SOUND_CARD_DROP: { case SOUND_CARD_DROP: {
strcpy(soundName, "carddrop"); soundName = "carddrop";
break; break;
} }
case SOUND_PLAYER_ENTER: { case SOUND_PLAYER_ENTER: {
strcpy(soundName, "playerenter"); soundName = "playerenter";
break; break;
} }
case SOUND_CHAT: { case SOUND_CHAT: {
strcpy(soundName, "chatmessage"); soundName = "chatmessage";
break; break;
} }
default: default:
break; return;
} }
char soundPath[40]; std::string soundPath = "./sound/" + soundName + ".wav";
mysnprintf(soundPath, "./sound/%s.wav", soundName);
SetSoundVolume(mainGame->gameConf.sound_volume); SetSoundVolume(mainGame->gameConf.sound_volume);
#ifdef YGOPRO_USE_MINIAUDIO #ifdef YGOPRO_USE_MINIAUDIO
ma_engine_play_sound(&engineSound, soundPath, nullptr); ma_engine_play_sound(&engineSound, soundPath.c_str(), nullptr);
#endif #endif
#ifdef YGOPRO_USE_IRRKLANG #ifdef YGOPRO_USE_IRRKLANG
engineSound->play2D(soundPath); engineSound->play2D(soundPath.c_str());
#endif #endif
#endif // YGOPRO_USE_AUDIO #endif // YGOPRO_USE_AUDIO
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment