From c8f1c1613050864a4c59a6781c147ef7c2fbfe42 Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 1 Jan 2024 10:29:26 -0500 Subject: [PATCH] fix SND_HashName --- src/Common/Game/T6/CommonT6.h | 2 +- src/Common/Game/T6/T6_Assets.h | 10 +++---- .../T6/AssetDumpers/AssetDumperSndBank.cpp | 30 +++++++------------ 3 files changed, 16 insertions(+), 26 deletions(-) diff --git a/src/Common/Game/T6/CommonT6.h b/src/Common/Game/T6/CommonT6.h index c6afdd1bb..6580ccdf3 100644 --- a/src/Common/Game/T6/CommonT6.h +++ b/src/Common/Game/T6/CommonT6.h @@ -23,7 +23,7 @@ namespace T6 while (str[offset]) { const auto c = tolower(str[offset++]); - result = c + 33 * result; + result = c + 0x1003F * result; } if (!result) diff --git a/src/Common/Game/T6/T6_Assets.h b/src/Common/Game/T6/T6_Assets.h index b5af3a313..76948153a 100644 --- a/src/Common/Game/T6/T6_Assets.h +++ b/src/Common/Game/T6/T6_Assets.h @@ -5602,8 +5602,8 @@ namespace T6 struct SndAliasFlags { // flags0 - SndAliasLoopType looping : 1; // 0 - SndAliasPanType panType : 1; // 1 + unsigned int looping : 1; // 0 + unsigned int panType : 1; // 1 unsigned int distanceLpf : 1; // 2 unsigned int doppler : 1; // 3 unsigned int isBig : 1; // 4 @@ -5614,7 +5614,7 @@ namespace T6 unsigned int voiceLimit : 1; // 9 unsigned int ignoreMaxDist : 1; // 10 unsigned int busType : 4; // 11-14 - SndAliasLoadType loadType : 2; // 15-16 + unsigned int loadType : 2; // 15-16 unsigned int volumeGroup : 5; // 17-21 unsigned int fluxType : 3; // 22-24 unsigned int limitType : 2; // 25-26 @@ -5674,9 +5674,9 @@ namespace T6 char duckGroup; }; - #ifndef __zonecodegenerator +#ifndef __zonecodegenerator static_assert(sizeof(SndAliasFlags) == 8); - #endif +#endif struct type_align(4) pathlink_s { diff --git a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp index 8ef9da811..b36a4f3c9 100644 --- a/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp +++ b/src/ObjWriting/Game/T6/AssetDumpers/AssetDumperSndBank.cpp @@ -1,7 +1,7 @@ #include "AssetDumperSndBank.h" -#include "Game/T6/CommonT6.h" #include "Csv/CsvStream.h" +#include "Game/T6/CommonT6.h" #include "ObjContainer/SoundBank/SoundBank.h" #include "Sound/WavWriter.h" #include "nlohmann/json.hpp" @@ -169,25 +169,15 @@ namespace "", }; - const std::unordered_map CURVES_MAP{ - {T6::Common::SND_HashName(CURVES_ENUM[0].data()), CURVES_ENUM[0]}, - {T6::Common::SND_HashName(CURVES_ENUM[1].data()), CURVES_ENUM[1]}, - {T6::Common::SND_HashName(CURVES_ENUM[2].data()), CURVES_ENUM[2]}, - {T6::Common::SND_HashName(CURVES_ENUM[3].data()), CURVES_ENUM[3]}, - {T6::Common::SND_HashName(CURVES_ENUM[4].data()), CURVES_ENUM[4]}, - {T6::Common::SND_HashName(CURVES_ENUM[5].data()), CURVES_ENUM[5]}, - {T6::Common::SND_HashName(CURVES_ENUM[6].data()), CURVES_ENUM[6]}, - {T6::Common::SND_HashName(CURVES_ENUM[7].data()), CURVES_ENUM[7]}, - {T6::Common::SND_HashName(CURVES_ENUM[8].data()), CURVES_ENUM[8]}, - {T6::Common::SND_HashName(CURVES_ENUM[9].data()), CURVES_ENUM[9]}, - {T6::Common::SND_HashName(CURVES_ENUM[10].data()), CURVES_ENUM[10]}, - {T6::Common::SND_HashName(CURVES_ENUM[11].data()), CURVES_ENUM[11]}, - {T6::Common::SND_HashName(CURVES_ENUM[12].data()), CURVES_ENUM[12]}, - {T6::Common::SND_HashName(CURVES_ENUM[13].data()), CURVES_ENUM[13]}, - {T6::Common::SND_HashName(CURVES_ENUM[14].data()), CURVES_ENUM[14]}, - {T6::Common::SND_HashName(CURVES_ENUM[15].data()), CURVES_ENUM[15]}, - {T6::Common::SND_HashName(CURVES_ENUM[16].data()), CURVES_ENUM[16]}, - }; + std::unordered_map CreateCurvesMap() + { + std::unordered_map result; + for (auto i = 0u; i < std::extent_v; i++) + result.emplace(T6::Common::SND_HashName(CURVES_ENUM[i].data()), CURVES_ENUM[i]); + return result; + } + + const std::unordered_map CURVES_MAP = CreateCurvesMap(); const std::string DUCK_GROUPS_ENUM[]{ "snp_alerts_gameplay",