From 2478a1355f34c7f8bcc4562ea1ff8052bc743392 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 9 Feb 2024 11:39:51 -0500 Subject: [PATCH] code review changes --- src/Crypto/Impl/AlgorithmMD5.h | 2 +- src/ObjCommon/Csv/ParsedCsv.cpp | 16 ++-- src/ObjCommon/Csv/ParsedCsv.h | 8 +- src/ObjCommon/Game/T6/ObjConstantsT6.h | 9 --- ...{ObjConstantsT6.cpp => SoundConstantsT6.h} | 20 ++--- .../T6/AssetLoaders/AssetLoaderSoundBank.cpp | 74 +++++++++---------- .../SoundBank/SoundBankWriter.cpp | 49 ++++++------ .../ObjContainer/SoundBank/SoundBankWriter.h | 2 +- .../T6/AssetDumpers/AssetDumperSndBank.cpp | 36 ++++----- src/ObjWriting/Sound/WavWriter.h | 2 +- src/Utils/Utils/StringUtils.cpp | 4 +- 11 files changed, 104 insertions(+), 118 deletions(-) rename src/ObjCommon/Game/T6/{ObjConstantsT6.cpp => SoundConstantsT6.h} (80%) diff --git a/src/Crypto/Impl/AlgorithmMD5.h b/src/Crypto/Impl/AlgorithmMD5.h index 25024f08..4687572a 100644 --- a/src/Crypto/Impl/AlgorithmMD5.h +++ b/src/Crypto/Impl/AlgorithmMD5.h @@ -7,7 +7,7 @@ class AlgorithmMD5 : public IHashFunction AlgorithmMD5Impl* m_impl; public: - static const int HASH_SIZE = 20; + static const int HASH_SIZE = 16; AlgorithmMD5(); ~AlgorithmMD5() override; diff --git a/src/ObjCommon/Csv/ParsedCsv.cpp b/src/ObjCommon/Csv/ParsedCsv.cpp index d566eac8..9ddb3e5a 100644 --- a/src/ObjCommon/Csv/ParsedCsv.cpp +++ b/src/ObjCommon/Csv/ParsedCsv.cpp @@ -1,19 +1,19 @@ #include "Csv/ParsedCsv.h" -ParsedCsvRow::ParsedCsvRow(std::unordered_map& headers, std::vector& row) +ParsedCsvRow::ParsedCsvRow(std::unordered_map& headers, std::vector row) : headers(headers), - values(row) + values(std::move(row)) { } -const std::string ParsedCsvRow::GetValue(const std::string& header, bool required) const +std::string ParsedCsvRow::GetValue(const std::string& header, bool required) const { if (this->headers.find(header) == this->headers.end()) { if (required) - std::cerr << "ERROR: Required column \"" << header << "\" was not found"; + std::cerr << "ERROR: Required column \"" << header << "\" was not found" << std::endl; else - std::cerr << "WARNING: Expected column \"" << header << "\" was not found"; + std::cerr << "WARNING: Expected column \"" << header << "\" was not found" << std::endl; return {}; } @@ -21,14 +21,14 @@ const std::string ParsedCsvRow::GetValue(const std::string& header, bool require auto& value = this->values.at(this->headers[header]); if (required && value.empty()) { - std::cerr << "ERROR: Required column \"" << header << "\" does not have a value"; + std::cerr << "ERROR: Required column \"" << header << "\" does not have a value" << std::endl; return {}; } return value; } -const float ParsedCsvRow::GetValueFloat(const std::string& header, bool required) const +float ParsedCsvRow::GetValueFloat(const std::string& header, bool required) const { const auto& value = this->GetValue(header, required); if (!value.empty()) @@ -65,7 +65,7 @@ ParsedCsv::ParsedCsv(const CsvInputStream& inputStream, bool hasHeaders) for (auto i = hasHeaders ? 1u : 0u; i < csvLines.size(); i++) { auto& rowValues = csvLines[i]; - this->rows.push_back(ParsedCsvRow(this->headers, rowValues)); + this->rows.emplace_back(this->headers, std::move(rowValues)); } } diff --git a/src/ObjCommon/Csv/ParsedCsv.h b/src/ObjCommon/Csv/ParsedCsv.h index 22d4e5be..ff2030d3 100644 --- a/src/ObjCommon/Csv/ParsedCsv.h +++ b/src/ObjCommon/Csv/ParsedCsv.h @@ -1,7 +1,7 @@ #pragma once -#include #include #include +#include "Csv/CsvStream.h" class ParsedCsvRow { @@ -9,9 +9,9 @@ class ParsedCsvRow std::vector values; public: - explicit ParsedCsvRow(std::unordered_map& headers, std::vector& row); - const std::string GetValue(const std::string& header, bool required = false) const; - const float GetValueFloat(const std::string& header, bool required = false) const; + explicit ParsedCsvRow(std::unordered_map& headers, std::vector row); + std::string GetValue(const std::string& header, bool required = false) const; + float GetValueFloat(const std::string& header, bool required = false) const; template T GetValueInt(const std::string& header, bool required = false) const { diff --git a/src/ObjCommon/Game/T6/ObjConstantsT6.h b/src/ObjCommon/Game/T6/ObjConstantsT6.h index d5991d9a..392102fa 100644 --- a/src/ObjCommon/Game/T6/ObjConstantsT6.h +++ b/src/ObjCommon/Game/T6/ObjConstantsT6.h @@ -26,14 +26,5 @@ namespace T6 static constexpr const char* GDF_FILENAME_WEAPON_ATTACHMENT = "attachment.gdf"; static constexpr const char* GDF_FILENAME_WEAPON_ATTACHMENT_UNIQUE = "attachmentunique.gdf"; static constexpr const char* GDF_FILENAME_ZBARRIER = "zbarrier.gdf"; - - static const std::array SOUND_GROUPS; - static const std::array SOUND_CURVES; - static const std::array SOUND_DUCK_GROUPS; - static const std::array SOUND_LIMIT_TYPES; - static const std::array SOUND_MOVE_TYPES; - static const std::array SOUND_LOAD_TYPES; - static const std::array SOUND_BUS_IDS; - static const std::array SOUND_RANDOMIZE_TYPES; }; } // namespace T6 diff --git a/src/ObjCommon/Game/T6/ObjConstantsT6.cpp b/src/ObjCommon/Game/T6/SoundConstantsT6.h similarity index 80% rename from src/ObjCommon/Game/T6/ObjConstantsT6.cpp rename to src/ObjCommon/Game/T6/SoundConstantsT6.h index 3ac97809..feb7cff6 100644 --- a/src/ObjCommon/Game/T6/ObjConstantsT6.cpp +++ b/src/ObjCommon/Game/T6/SoundConstantsT6.h @@ -1,8 +1,9 @@ -#include "ObjConstantsT6.h" +#pragma once +#include namespace T6 { - const std::array ObjConstants::SOUND_GROUPS{ + inline const std::string SOUND_GROUPS[]{ "grp_reference", "grp_master", "grp_wpn_lfe", @@ -32,7 +33,7 @@ namespace T6 "", }; - const std::array ObjConstants::SOUND_CURVES{ + inline const std::string SOUND_CURVES[]{ "default", "defaultmin", "allon", @@ -53,7 +54,7 @@ namespace T6 "", }; - const std::array ObjConstants::SOUND_DUCK_GROUPS{ + inline const std::string SOUND_DUCK_GROUPS[]{ "snp_alerts_gameplay", "snp_ambience", "snp_claw", @@ -88,14 +89,14 @@ namespace T6 "snp_x3", }; - const std::array ObjConstants::SOUND_LIMIT_TYPES{ + inline const std::string SOUND_LIMIT_TYPES[]{ "none", "oldest", "reject", "priority", }; - const std::array ObjConstants::SOUND_MOVE_TYPES{ + inline const std::string SOUND_MOVE_TYPES[]{ "none", "left_player", "center_player", @@ -106,14 +107,14 @@ namespace T6 "right_shot", }; - const std::array ObjConstants::SOUND_LOAD_TYPES{ + inline const std::string SOUND_LOAD_TYPES[]{ "unknown", "loaded", "streamed", "primed", }; - const std::array ObjConstants::SOUND_BUS_IDS{ + inline const std::string SOUND_BUS_IDS[]{ "bus_reverb", "bus_fx", "bus_voice", @@ -127,11 +128,10 @@ namespace T6 "", }; - const std::array ObjConstants::SOUND_RANDOMIZE_TYPES{ + inline const std::string SOUND_RANDOMIZE_TYPES[]{ "volume", "pitch", "variant", "", }; - } // namespace T6 diff --git a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp index 5a19f6e1..4b6d0775 100644 --- a/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp +++ b/src/ObjLoading/Game/T6/AssetLoaders/AssetLoaderSoundBank.cpp @@ -2,7 +2,7 @@ #include "Csv/ParsedCsv.h" #include "Game/T6/CommonT6.h" -#include "Game/T6/ObjConstantsT6.h" +#include "Game/T6/SoundConstantsT6.h" #include "Game/T6/T6.h" #include "ObjContainer/SoundBank/SoundBankWriter.h" #include "Pool/GlobalAssetPool.h" @@ -180,24 +180,18 @@ bool LoadSoundAlias(MemoryManager* memory, SndAlias* alias, const ParsedCsvRow& alias->flags.pauseable = row.GetValue("pause") == "yes"; alias->flags.stopOnDeath = row.GetValue("stop_on_death") == "yes"; - alias->duckGroup = - static_cast(GetValueIndex(row.GetValue("duck_group"), ObjConstants::SOUND_DUCK_GROUPS.data(), ObjConstants::SOUND_DUCK_GROUPS.size())); - alias->flags.volumeGroup = GetValueIndex(row.GetValue("group"), ObjConstants::SOUND_GROUPS.data(), ObjConstants::SOUND_GROUPS.size()); - alias->flags.fluxType = GetValueIndex(row.GetValue("move_type"), ObjConstants::SOUND_MOVE_TYPES.data(), ObjConstants::SOUND_MOVE_TYPES.size()); - alias->flags.loadType = GetValueIndex(row.GetValue("type"), ObjConstants::SOUND_LOAD_TYPES.data(), ObjConstants::SOUND_LOAD_TYPES.size()); - alias->flags.busType = GetValueIndex(row.GetValue("bus"), ObjConstants::SOUND_BUS_IDS.data(), ObjConstants::SOUND_BUS_IDS.size()); - alias->flags.limitType = GetValueIndex(row.GetValue("limit_type"), ObjConstants::SOUND_LIMIT_TYPES.data(), ObjConstants::SOUND_LIMIT_TYPES.size()); - alias->flags.volumeFalloffCurve = GetValueIndex(row.GetValue("volume_falloff_curve"), ObjConstants::SOUND_CURVES.data(), ObjConstants::SOUND_CURVES.size()); - alias->flags.reverbFalloffCurve = GetValueIndex(row.GetValue("reverb_falloff_curve"), ObjConstants::SOUND_CURVES.data(), ObjConstants::SOUND_CURVES.size()); - - alias->flags.entityLimitType = - GetValueIndex(row.GetValue("entity_limit_type"), ObjConstants::SOUND_LIMIT_TYPES.data(), ObjConstants::SOUND_LIMIT_TYPES.size()); - alias->flags.volumeMinFalloffCurve = - GetValueIndex(row.GetValue("volume_min_falloff_curve"), ObjConstants::SOUND_CURVES.data(), ObjConstants::SOUND_CURVES.size()); - alias->flags.reverbMinFalloffCurve = - GetValueIndex(row.GetValue("reverb_min_falloff_curve"), ObjConstants::SOUND_CURVES.data(), ObjConstants::SOUND_CURVES.size()); - alias->flags.randomizeType = - GetValueIndex(row.GetValue("randomize_type"), ObjConstants::SOUND_RANDOMIZE_TYPES.data(), ObjConstants::SOUND_RANDOMIZE_TYPES.size()); + alias->duckGroup = static_cast(GetValueIndex(row.GetValue("duck_group"), SOUND_DUCK_GROUPS, std::extent_v)); + alias->flags.volumeGroup = GetValueIndex(row.GetValue("group"), SOUND_GROUPS, std::extent_v); + alias->flags.fluxType = GetValueIndex(row.GetValue("move_type"), SOUND_MOVE_TYPES, std::extent_v); + alias->flags.loadType = GetValueIndex(row.GetValue("type"), SOUND_LOAD_TYPES, std::extent_v); + alias->flags.busType = GetValueIndex(row.GetValue("bus"), SOUND_BUS_IDS, std::extent_v); + alias->flags.limitType = GetValueIndex(row.GetValue("limit_type"), SOUND_LIMIT_TYPES, std::extent_v); + alias->flags.volumeFalloffCurve = GetValueIndex(row.GetValue("volume_falloff_curve"), SOUND_CURVES, std::extent_v); + alias->flags.reverbFalloffCurve = GetValueIndex(row.GetValue("reverb_falloff_curve"), SOUND_CURVES, std::extent_v); + alias->flags.entityLimitType = GetValueIndex(row.GetValue("entity_limit_type"), SOUND_LIMIT_TYPES, std::extent_v); + alias->flags.volumeMinFalloffCurve = GetValueIndex(row.GetValue("volume_min_falloff_curve"), SOUND_CURVES, std::extent_v); + alias->flags.reverbMinFalloffCurve = GetValueIndex(row.GetValue("reverb_min_falloff_curve"), SOUND_CURVES, std::extent_v); + alias->flags.randomizeType = GetValueIndex(row.GetValue("randomize_type"), SOUND_RANDOMIZE_TYPES, std::extent_v); return true; } @@ -208,16 +202,15 @@ bool LoadSoundAliasIndexList(MemoryManager* memory, SndBank* sndBank) sndBank->aliasIndex = static_cast(memory->Alloc(sizeof(SndIndexEntry) * sndBank->aliasCount)); memset(sndBank->aliasIndex, 0xFF, sizeof(SndIndexEntry) * sndBank->aliasCount); - bool* setAliasIndexList = new bool[sndBank->aliasCount]; - memset(setAliasIndexList, false, sndBank->aliasCount); + const auto setAliasIndexList = std::make_unique(sndBank->aliasCount); for (auto i = 0u; i < sndBank->aliasCount; i++) { auto idx = sndBank->alias[i].id % sndBank->aliasCount; - if (sndBank->aliasIndex[idx].value == USHRT_MAX) + if (sndBank->aliasIndex[idx].value == std::numeric_limits::max()) { sndBank->aliasIndex[idx].value = i; - sndBank->aliasIndex[idx].next = USHRT_MAX; + sndBank->aliasIndex[idx].next = std::numeric_limits::max(); setAliasIndexList[i] = true; } } @@ -228,44 +221,42 @@ bool LoadSoundAliasIndexList(MemoryManager* memory, SndBank* sndBank) continue; auto idx = sndBank->alias[i].id % sndBank->aliasCount; - while (sndBank->aliasIndex[idx].next != USHRT_MAX) + while (sndBank->aliasIndex[idx].next != std::numeric_limits::max()) { idx = sndBank->aliasIndex[idx].next; } auto offset = 1u; - auto freeIdx = USHRT_MAX; + auto freeIdx = std::numeric_limits::max(); while (true) { freeIdx = (idx + offset) % sndBank->aliasCount; - if (sndBank->aliasIndex[freeIdx].value == USHRT_MAX) + if (sndBank->aliasIndex[freeIdx].value == std::numeric_limits::max()) break; freeIdx = (idx + sndBank->aliasCount - offset) % sndBank->aliasCount; - if (sndBank->aliasIndex[freeIdx].value == USHRT_MAX) + if (sndBank->aliasIndex[freeIdx].value == std::numeric_limits::max()) break; offset++; - freeIdx = USHRT_MAX; + freeIdx = std::numeric_limits::max(); if (offset >= sndBank->aliasCount) break; } - if (freeIdx == USHRT_MAX) + if (freeIdx == std::numeric_limits::max()) { std::cerr << "Unable to allocate sound bank alias index list" << std::endl; - delete[] setAliasIndexList; return false; } sndBank->aliasIndex[idx].next = freeIdx; sndBank->aliasIndex[freeIdx].value = i; - sndBank->aliasIndex[freeIdx].next = USHRT_MAX; + sndBank->aliasIndex[freeIdx].next = std::numeric_limits::max(); setAliasIndexList[i] = true; } - delete[] setAliasIndexList; return true; } @@ -436,8 +427,7 @@ bool LoadSoundDuckList(ISearchPath* searchPath, MemoryManager* memory, SndBank* for (auto& valueJson : duckJson["values"]) { - auto index = - GetValueIndex(valueJson["duckGroup"].get(), ObjConstants::SOUND_DUCK_GROUPS.data(), ObjConstants::SOUND_DUCK_GROUPS.size()); + auto index = GetValueIndex(valueJson["duckGroup"].get(), SOUND_DUCK_GROUPS, std::extent_v); duck->attenuation[index] = valueJson["attenuation"].get(); duck->filter[index] = valueJson["filter"].get(); @@ -550,14 +540,15 @@ bool AssetLoaderSoundBank::LoadFromRaw( // write the output linked sound bank if (sablWriter) { - auto size = static_cast(sablWriter->Write()); + size_t dataSize = 0u; + auto result = sablWriter->Write(dataSize); sablStream->close(); - if (size != UINT32_MAX) + if (result) { - sndBank->loadedAssets.dataSize = size; - sndBank->loadedAssets.data = static_cast(memory->Alloc(size)); - memset(sndBank->loadedAssets.data, 0, size); + sndBank->loadedAssets.dataSize = dataSize; + sndBank->loadedAssets.data = static_cast(memory->Alloc(dataSize)); + memset(sndBank->loadedAssets.data, 0, dataSize); } else { @@ -569,10 +560,11 @@ bool AssetLoaderSoundBank::LoadFromRaw( // write the output streamed sound bank if (sabsWriter) { - auto size = static_cast(sabsWriter->Write()); + size_t dataSize = 0u; + auto result = sabsWriter->Write(dataSize); sabsStream->close(); - if (size == UINT32_MAX) + if (!result) { std::cerr << "Streamed Sound Bank for " << assetName << " failed to generate. Please check your build files." << std::endl; return false; diff --git a/src/ObjLoading/ObjContainer/SoundBank/SoundBankWriter.cpp b/src/ObjLoading/ObjContainer/SoundBank/SoundBankWriter.cpp index 1ea92661..bab982d4 100644 --- a/src/ObjLoading/ObjContainer/SoundBank/SoundBankWriter.cpp +++ b/src/ObjLoading/ObjContainer/SoundBank/SoundBankWriter.cpp @@ -2,12 +2,11 @@ #include "Crypto.h" #include "ObjContainer/SoundBank/SoundBankTypes.h" -#include "Sound/WavTypes.h" #include "Sound/FlacDecoder.h" +#include "Sound/WavTypes.h" #include "Utils/Alignment.h" #include "Utils/FileUtils.h" - #include #include #include @@ -78,8 +77,8 @@ public: void AlignToChunk() { - if ((m_current_offset & 0xF) != 0) - Pad(0x10 - (m_current_offset & 0xF)); + if (m_current_offset % 16 != 0) + Pad(16 - (m_current_offset % 16)); } void WriteHeader() @@ -91,18 +90,20 @@ public: SoundAssetBankChecksum checksum{}; memset(&checksum, 0xCC, sizeof(SoundAssetBankChecksum)); - SoundAssetBankHeader header{MAGIC, - VERSION, - sizeof(SoundAssetBankEntry), - sizeof(SoundAssetBankChecksum), - 0x40, - m_entries.size(), - 0, - 0, - m_total_size, - m_entry_section_offset, - m_checksum_section_offset, - checksum}; + SoundAssetBankHeader header{ + MAGIC, + VERSION, + sizeof(SoundAssetBankEntry), + sizeof(SoundAssetBankChecksum), + 0x40, + m_entries.size(), + 0, + 0, + m_total_size, + m_entry_section_offset, + m_checksum_section_offset, + checksum, + }; strncpy(header.dependencies, m_file_name.data(), header.dependencySize); @@ -169,7 +170,7 @@ public: static_cast(m_current_offset), decoder->GetFrameCount(), frameRateIndex, - decoder->GetNumChannels(), + static_cast(decoder->GetNumChannels()), sound.looping, 8, }; @@ -192,7 +193,8 @@ public: auto lastEntry = m_entries.rbegin(); if (!sound.streamed && lastEntry->frameRateIndex != 6) { - std::cout << "WARNING: Loaded sound \"" << soundFilePath << "\" should have a framerate of 48000 but doesn't. This sound may not work on all games!" << std::endl; + std::cout << "WARNING: Loaded sound \"" << soundFilePath + << "\" should have a framerate of 48000 but doesn't. This sound may not work on all games!" << std::endl; } // calculate checksum @@ -240,12 +242,12 @@ public: AlignToChunk(); } - std::int64_t Write() override + bool Write(size_t& dataSize) override { if (!WriteEntries()) { std::cerr << "An error occurred writing the sound bank entires. Please check output." << std::endl; - return -1; + return false; } WriteEntryList(); @@ -259,11 +261,12 @@ public: if (m_current_offset > UINT32_MAX) { std::cerr << "Sound bank files must be under 4GB. Please reduce the number of sounds being written!" << std::endl; - return -1; + return false; } - // return the total size for the sound asset data - return m_entry_section_offset - DATA_OFFSET; + // output the total size for the sound asset data + dataSize = static_cast(m_entry_section_offset - DATA_OFFSET); + return true; } private: diff --git a/src/ObjLoading/ObjContainer/SoundBank/SoundBankWriter.h b/src/ObjLoading/ObjContainer/SoundBank/SoundBankWriter.h index cb0fb07a..ccd338b3 100644 --- a/src/ObjLoading/ObjContainer/SoundBank/SoundBankWriter.h +++ b/src/ObjLoading/ObjContainer/SoundBank/SoundBankWriter.h @@ -17,7 +17,7 @@ public: SoundBankWriter& operator=(SoundBankWriter&& other) noexcept = default; virtual void AddSound(const std::string& soundFilePath, unsigned int soundId, bool looping = false, bool streamed = false) = 0; - virtual std::int64_t Write() = 0; + virtual bool Write(size_t& dataSize) = 0; static std::unique_ptr Create(const std::string& fileName, std::ostream& stream, ISearchPath* assetSearchPath); diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp index 33bf94c1..e25b5a99 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp @@ -2,7 +2,7 @@ #include "Csv/CsvStream.h" #include "Game/T6/CommonT6.h" -#include "Game/T6/ObjConstantsT6.h" +#include "Game/T6/SoundConstantsT6.h" #include "ObjContainer/SoundBank/SoundBank.h" #include "Sound/WavWriter.h" #include "nlohmann/json.hpp" @@ -123,8 +123,8 @@ namespace std::unordered_map CreateCurvesMap() { std::unordered_map result; - for (auto i = 0u; i < ObjConstants::SOUND_CURVES.size(); i++) - result.emplace(T6::Common::SND_HashName(ObjConstants::SOUND_CURVES[i].data()), ObjConstants::SOUND_CURVES[i]); + for (auto i = 0u; i < std::extent_v; i++) + result.emplace(T6::Common::SND_HashName(SOUND_CURVES[i].data()), SOUND_CURVES[i]); return result; } @@ -226,7 +226,7 @@ class AssetDumperSndBank::Internal stream.WriteColumn((alias->secondaryname && *alias->secondaryname) ? alias->secondaryname : ""); // group - stream.WriteColumn(ObjConstants::SOUND_GROUPS[alias->flags.volumeGroup]); + stream.WriteColumn(SOUND_GROUPS[alias->flags.volumeGroup]); // vol_min stream.WriteColumn(std::to_string(alias->volMin)); @@ -247,28 +247,28 @@ class AssetDumperSndBank::Internal stream.WriteColumn(std::to_string(alias->distReverbMax)); // volume_falloff_curve - stream.WriteColumn(ObjConstants::SOUND_CURVES[alias->flags.volumeFalloffCurve]); + stream.WriteColumn(SOUND_CURVES[alias->flags.volumeFalloffCurve]); // reverb_falloff_curve - stream.WriteColumn(ObjConstants::SOUND_CURVES[alias->flags.reverbFalloffCurve]); + stream.WriteColumn(SOUND_CURVES[alias->flags.reverbFalloffCurve]); // volume_min_falloff_curve - stream.WriteColumn(ObjConstants::SOUND_CURVES[alias->flags.volumeMinFalloffCurve]); + stream.WriteColumn(SOUND_CURVES[alias->flags.volumeMinFalloffCurve]); // reverb_min_falloff_curve" - stream.WriteColumn(ObjConstants::SOUND_CURVES[alias->flags.reverbMinFalloffCurve]); + stream.WriteColumn(SOUND_CURVES[alias->flags.reverbMinFalloffCurve]); // limit_count stream.WriteColumn(std::to_string(alias->limitCount)); // limit_type - stream.WriteColumn(ObjConstants::SOUND_LIMIT_TYPES[alias->flags.limitType]); + stream.WriteColumn(SOUND_LIMIT_TYPES[alias->flags.limitType]); // entity_limit_count stream.WriteColumn(std::to_string(alias->entityLimitCount)); // entity_limit_type - stream.WriteColumn(ObjConstants::SOUND_LIMIT_TYPES[alias->flags.entityLimitType]); + stream.WriteColumn(SOUND_LIMIT_TYPES[alias->flags.entityLimitType]); // pitch_min stream.WriteColumn(std::to_string(alias->pitchMin)); @@ -295,13 +295,13 @@ class AssetDumperSndBank::Internal stream.WriteColumn(""); // type - stream.WriteColumn(ObjConstants::SOUND_LOAD_TYPES[alias->flags.loadType]); + stream.WriteColumn(SOUND_LOAD_TYPES[alias->flags.loadType]); // loop stream.WriteColumn(alias->flags.looping == T6::SA_NON_LOOPING ? "nonlooping" : "looping"); // randomize_type - stream.WriteColumn(ObjConstants::SOUND_RANDOMIZE_TYPES[std::min(alias->flags.randomizeType, 3u)]); + stream.WriteColumn(SOUND_RANDOMIZE_TYPES[std::min(alias->flags.randomizeType, 3u)]); // probability", stream.WriteColumn(std::to_string(alias->probability)); @@ -316,7 +316,7 @@ class AssetDumperSndBank::Internal stream.WriteColumn(FindNameForDuck(alias->duck, bank)); // duck_group", - stream.WriteColumn(ObjConstants::SOUND_DUCK_GROUPS[alias->duckGroup]); + stream.WriteColumn(SOUND_DUCK_GROUPS[alias->duckGroup]); // pan", stream.WriteColumn(alias->flags.panType == SA_PAN_2D ? "2d" : "3d"); @@ -346,7 +346,7 @@ class AssetDumperSndBank::Internal stream.WriteColumn(alias->flags.distanceLpf ? "yes" : "no"); // move_type", - stream.WriteColumn(ObjConstants::SOUND_MOVE_TYPES[alias->flags.fluxType]); + stream.WriteColumn(SOUND_MOVE_TYPES[alias->flags.fluxType]); // move_time", stream.WriteColumn(std::to_string(alias->fluxTime)); @@ -397,7 +397,7 @@ class AssetDumperSndBank::Internal stream.WriteColumn(alias->flags.stopOnDeath ? "yes" : "no"); // bus", - stream.WriteColumn(ObjConstants::SOUND_BUS_IDS[alias->flags.busType]); + stream.WriteColumn(SOUND_BUS_IDS[alias->flags.busType]); // snapshot", stream.WriteColumn(""); @@ -630,9 +630,9 @@ class AssetDumperSndBank::Internal for (auto i = 0u; i < 32u; i++) { values.push_back({ - {"duckGroup", ObjConstants::SOUND_DUCK_GROUPS[i]}, - {"attenuation", duck.attenuation[i] }, - {"filter", duck.filter[i] } + {"duckGroup", SOUND_DUCK_GROUPS[i]}, + {"attenuation", duck.attenuation[i] }, + {"filter", duck.filter[i] } }); } diff --git a/src/ObjWriting/Sound/WavWriter.h b/src/ObjWriting/Sound/WavWriter.h index eb0174a9..4ce2bbc5 100644 --- a/src/ObjWriting/Sound/WavWriter.h +++ b/src/ObjWriting/Sound/WavWriter.h @@ -1,6 +1,6 @@ #pragma once -#include #include +#include "Sound/WavTypes.h" class WavWriter { diff --git a/src/Utils/Utils/StringUtils.cpp b/src/Utils/Utils/StringUtils.cpp index cb5ede9c..d582fa1f 100644 --- a/src/Utils/Utils/StringUtils.cpp +++ b/src/Utils/Utils/StringUtils.cpp @@ -104,13 +104,13 @@ namespace utils std::vector StringSplit(const std::string& str, const char delim) { - std::vector strings{}; + std::vector strings; std::istringstream stream(str); std::string s; while (std::getline(stream, s, delim)) { - strings.push_back(s); + strings.emplace_back(std::move(s)); } return strings;