Skip to content

Commit

Permalink
[Refactor] #3236 ANGBAND_DIR_XTRA_SOUND をconcptr からpath に差し替えた
Browse files Browse the repository at this point in the history
  • Loading branch information
Hourier authored and sikabane-works committed Jan 28, 2024
1 parent 9ece32f commit 467a332
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 18 deletions.
4 changes: 2 additions & 2 deletions src/main-win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2656,11 +2656,11 @@ static void init_stuff()

validate_file(path);
path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "graf");
ANGBAND_DIR_XTRA_GRAF = string_make(path);
ANGBAND_DIR_XTRA_GRAF = path;
validate_dir(ANGBAND_DIR_XTRA_GRAF, true);

path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "sound");
ANGBAND_DIR_XTRA_SOUND = string_make(path);
ANGBAND_DIR_XTRA_SOUND = path;
validate_dir(ANGBAND_DIR_XTRA_SOUND, false);

path_build(path, sizeof(path), ANGBAND_DIR_XTRA, "music");
Expand Down
2 changes: 1 addition & 1 deletion src/main-win/main-win-cfg-reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void CfgData::insert(int key1_type, int key2_val, cfg_values *value)
* @param dir .cfgファイルのディレクトリ
* @param files .cfgファイル名。複数指定可能で、最初に見つかったファイルから読み取る。
*/
CfgReader::CfgReader(concptr dir, std::initializer_list<concptr> files)
CfgReader::CfgReader(std::filesystem::path dir, std::initializer_list<concptr> files)
{
this->dir = dir;
this->cfg_path = find_any_file(dir, files);
Expand Down
9 changes: 5 additions & 4 deletions src/main-win/main-win-cfg-reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "system/angband.h"
#include <cstddef>
#include <filesystem>
#include <initializer_list>
#include <unordered_map>
#include <vector>
Expand Down Expand Up @@ -55,14 +56,14 @@ class CfgData {

class CfgReader {
public:
CfgReader(concptr dir, std::initializer_list<concptr> files);
CfgReader(std::filesystem::path dir, std::initializer_list<concptr> files);
CfgData *read_sections(std::initializer_list<cfg_section> sections);
concptr get_cfg_path()
std::string get_cfg_path()
{
return cfg_path.data();
return cfg_path;
}

protected:
concptr dir;
std::filesystem::path dir;
std::string cfg_path;
};
2 changes: 1 addition & 1 deletion src/main-win/main-win-music.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void load_music_prefs()
CfgReader reader(ANGBAND_DIR_XTRA_MUSIC, { "music_debug.cfg", "music.cfg" });

char device_type[256];
GetPrivateProfileStringA("Device", "type", "MPEGVideo", device_type, _countof(device_type), reader.get_cfg_path());
GetPrivateProfileStringA("Device", "type", "MPEGVideo", device_type, _countof(device_type), reader.get_cfg_path().data());
mci_device_type = to_wchar(device_type).wc_str();

// clang-format off
Expand Down
11 changes: 4 additions & 7 deletions src/main-win/main-win-sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,16 @@
#include "main-win/main-win-file-utils.h"
#include "main-win/main-win-utils.h"
#include "main-win/wav-reader.h"
#include "util/angband-files.h"

#include "main/sound-definitions-table.h"

#include "util/angband-files.h"
#include <memory>
#include <queue>

#include <mmsystem.h>
#include <queue>

/*
* Directory name
*/
concptr ANGBAND_DIR_XTRA_SOUND;
std::filesystem::path ANGBAND_DIR_XTRA_SOUND;

/*
* "sound.cfg" data
Expand Down Expand Up @@ -253,7 +250,7 @@ void finalize_sound(void)
* @retval 1 設定なし
* @retval -1 PlaySoundの戻り値が正常終了以外
*/
errr play_sound(int val, int volume)
int play_sound(int val, int volume)
{
auto filename = sound_cfg_data->get_rand(TERM_XTRA_SOUND, val);
if (!filename) {
Expand Down
6 changes: 3 additions & 3 deletions src/main-win/main-win-sound.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#pragma once

#include "main-win/main-win-cfg-reader.h"
#include "system/h-type.h"
#include <array>
#include <filesystem>

extern concptr ANGBAND_DIR_XTRA_SOUND;
extern std::filesystem::path ANGBAND_DIR_XTRA_SOUND;
extern CfgData *sound_cfg_data;

void load_sound_prefs(void);
void finalize_sound(void);
errr play_sound(int val, int volume);
int play_sound(int val, int volume);

/*! 音量 100%,90%,…,10% それぞれに割り当てる実際の値(効果音の音声データの振幅を volume/SOUND_VOLUME_MAX 倍する) */
constexpr std::array<int, 10> SOUND_VOLUME_TABLE = { { 1000, 800, 600, 450, 350, 250, 170, 100, 50, 20 } };
Expand Down

0 comments on commit 467a332

Please sign in to comment.