aboutsummaryrefslogtreecommitdiff
path: root/src/openvic-simulation/misc
diff options
context:
space:
mode:
author hop311 <hop3114@gmail.com>2024-08-11 00:40:07 +0200
committer hop311 <hop3114@gmail.com>2024-08-14 00:07:46 +0200
commit7e05aaccf0e13299702ddeed17661831c3ddc692 (patch)
treeb85022a240a4a24c0ee0fd44cd59ff6bc112c18f /src/openvic-simulation/misc
parent9f9c5844bfedc5e366a35cdba386027fb9f3a14a (diff)
Assorted minor fixes (clang-format.sh shebang, parse national foci scripts, factor song chance, update openvic-dataloader)assorted-fixes
Diffstat (limited to 'src/openvic-simulation/misc')
-rw-r--r--src/openvic-simulation/misc/SongChance.cpp18
-rw-r--r--src/openvic-simulation/misc/SongChance.hpp12
-rw-r--r--src/openvic-simulation/misc/SoundEffect.cpp4
-rw-r--r--src/openvic-simulation/misc/SoundEffect.hpp18
4 files changed, 28 insertions, 24 deletions
diff --git a/src/openvic-simulation/misc/SongChance.cpp b/src/openvic-simulation/misc/SongChance.cpp
index 4a99362..94fb571 100644
--- a/src/openvic-simulation/misc/SongChance.cpp
+++ b/src/openvic-simulation/misc/SongChance.cpp
@@ -3,18 +3,16 @@
using namespace OpenVic;
using namespace OpenVic::NodeTools;
-SongChance::SongChance(size_t new_index, std::string_view new_filename, ConditionalWeight&& new_chance):
-HasIdentifier { std::to_string(new_index) },
-file_name { new_filename },
-chance { std::move(new_chance) }
-{}
+SongChance::SongChance(
+ size_t new_index, std::string_view new_filename, ConditionalWeight&& new_chance
+) : HasIdentifier { std::to_string(new_index) }, file_name { new_filename }, chance { std::move(new_chance) } {}
bool SongChance::parse_scripts(DefinitionManager const& definition_manager) {
return chance.parse_scripts(definition_manager);
}
bool SongChanceManager::load_songs_file(ast::NodeCPtr root) {
- bool ret = true;
+ bool ret = true;
ret &= expect_dictionary_reserve_length(
song_chances,
@@ -28,15 +26,15 @@ bool SongChanceManager::load_songs_file(ast::NodeCPtr root) {
bool ret = expect_dictionary_keys(
"name", ONE_EXACTLY, expect_string(assign_variable_callback(name)),
- "chance", ONE_EXACTLY, chance.expect_conditional_weight(ConditionalWeight::BASE)
+ "chance", ONE_EXACTLY, chance.expect_conditional_weight(ConditionalWeight::FACTOR)
)(value);
- ret &= song_chances.add_item({song_chances.size(), name, std::move(chance) });
+ ret &= song_chances.add_item({ song_chances.size(), name, std::move(chance) });
return ret;
}
)(root);
- if(song_chances.size() == 0) {
+ if (song_chances.size() == 0) {
Logger::error("No songs found in Songs.txt");
return false;
}
@@ -50,4 +48,4 @@ bool SongChanceManager::parse_scripts(DefinitionManager const& definition_manage
ret &= songChance.parse_scripts(definition_manager);
}
return ret;
-} \ No newline at end of file
+}
diff --git a/src/openvic-simulation/misc/SongChance.hpp b/src/openvic-simulation/misc/SongChance.hpp
index f92af7a..dc7d929 100644
--- a/src/openvic-simulation/misc/SongChance.hpp
+++ b/src/openvic-simulation/misc/SongChance.hpp
@@ -1,19 +1,23 @@
#pragma once
-#include <openvic-simulation/types/IdentifierRegistry.hpp>
-#include <openvic-simulation/scripts/ConditionalWeight.hpp>
+#include "openvic-simulation/types/IdentifierRegistry.hpp"
+#include "openvic-simulation/scripts/ConditionalWeight.hpp"
namespace OpenVic {
/*For music/Songs.txt if it exists*/
struct SongChanceManager;
+
struct SongChance : HasIdentifier {
- private:
friend struct SongChanceManager;
+
+ private:
std::string PROPERTY(file_name);
ConditionalWeight PROPERTY(chance);
+
SongChance(size_t new_index, std::string_view new_filename, ConditionalWeight&& new_chance);
+
bool parse_scripts(DefinitionManager const& definition_manager);
-
+
public:
SongChance(SongChance&&) = default;
};
diff --git a/src/openvic-simulation/misc/SoundEffect.cpp b/src/openvic-simulation/misc/SoundEffect.cpp
index df3196b..b32d353 100644
--- a/src/openvic-simulation/misc/SoundEffect.cpp
+++ b/src/openvic-simulation/misc/SoundEffect.cpp
@@ -20,7 +20,7 @@ bool SoundEffectManager::_load_sound_define(std::string_view sfx_identifier, ast
Logger::error("Invalid sound identifier - empty!");
return false;
}
- if(file.empty()) {
+ if (file.empty()) {
Logger::error("Invalid sound file name - empty!");
return false;
}
@@ -35,4 +35,4 @@ bool SoundEffectManager::load_sound_defines_file(ast::NodeCPtr root) {
return _load_sound_define(key,value);
}
)(root);
-} \ No newline at end of file
+}
diff --git a/src/openvic-simulation/misc/SoundEffect.hpp b/src/openvic-simulation/misc/SoundEffect.hpp
index 7f18dce..35d05dc 100644
--- a/src/openvic-simulation/misc/SoundEffect.hpp
+++ b/src/openvic-simulation/misc/SoundEffect.hpp
@@ -1,29 +1,31 @@
#pragma once
-#include <openvic-simulation/types/fixed_point/FixedPoint.hpp>
-#include <openvic-simulation/types/IdentifierRegistry.hpp>
+#include "openvic-simulation/types/fixed_point/FixedPoint.hpp"
+#include "openvic-simulation/types/IdentifierRegistry.hpp"
namespace OpenVic {
/*For interface/Sound.sfx */
struct SoundEffectManager;
+
struct SoundEffect : HasIdentifier {
- private:
friend struct SoundEffectManager;
+
+ private:
std::string PROPERTY(file);
fixed_point_t PROPERTY(volume);
+
SoundEffect(std::string_view new_identifier, std::string_view new_file, fixed_point_t new_volume);
-
+
public:
SoundEffect(SoundEffect&&) = default;
};
-
+
struct SoundEffectManager {
-
private:
- IdentifierRegistry<SoundEffect> IDENTIFIER_REGISTRY(sound_effect);
+ IdentifierRegistry<SoundEffect> IDENTIFIER_REGISTRY(sound_effect);
bool _load_sound_define(std::string_view sfx_identifier, ast::NodeCPtr root);
public:
bool load_sound_defines_file(ast::NodeCPtr root);
};
-} \ No newline at end of file
+}