segfault test fix

This commit is contained in:
2025-07-08 10:40:26 -04:00
parent d350044cb2
commit 2eead14b8e
2 changed files with 54 additions and 101 deletions

View File

@@ -9,8 +9,8 @@ std::unordered_map<char, char> Fish::color_map;
Fish::Fish() : Fish(getRandomAssetIndex()) {} Fish::Fish() : Fish(getRandomAssetIndex()) {}
Fish::Fish(int asset_index) Fish::Fish(int asset_index)
: Entity(asset_index % 2 == 0), image(fishAssetPairs[asset_index].image), : Entity(asset_index % 2 == 0), image(getFishAssetPairs()[asset_index].image),
mask(fishAssetPairs[asset_index].mask), mask(getFishAssetPairs()[asset_index].mask),
speed(Random::floatInRange(0.25f, 2.25f)) { speed(Random::floatInRange(0.25f, 2.25f)) {
const auto &aquarium = Aquarium::getInstance(); const auto &aquarium = Aquarium::getInstance();
@@ -45,7 +45,7 @@ void Fish::randomizeMask() {
} }
int Fish::getRandomAssetIndex() { int Fish::getRandomAssetIndex() {
return Random::intInRange(0, static_cast<int>(fishAssetPairs.size()) - 1); return Random::intInRange(0, static_cast<int>(getFishAssetPairs().size()) - 1);
} }
void Fish::update() noexcept { x += moving_right ? speed : -speed; } void Fish::update() noexcept { x += moving_right ? speed : -speed; }

View File

@@ -4,102 +4,55 @@
#include "../SpriteUtils.h" #include "../SpriteUtils.h"
#include <vector> #include <vector>
const std::vector<AssetPair> fishAssets = { inline const std::vector<AssetPair> &getFishAssets() {
{ static const std::vector<AssetPair> fishAssets = {
{ {{R"(???\??)", R"(??/ \?)", R"(>=_('>)", R"(??\_/?)", R"(???/??)"},
R"(???\??)", {R"( 1 )", R"( 1 1 )", R"(663745)", R"( 111 )", R"( 3 )"}},
R"(??/ \?)", {{R"(?????,????)", R"(?????}\???)", R"(\??.' `\?)", R"(}}< ( 6>)",
R"(>=_('>)", R"(/??`, .'?)", R"(?????}/???)", R"(?????'????)"},
R"(??\_/?)", {R"( 2 )", R"( 22 )", R"(6 11 11 )", R"(661 7 45)",
R"(???/??)"}, R"(6 11 11 )", R"( 33 )", R"( 3 )"}},
{ {{R"(???????,--,_????)", R"(__????_\.---'-.?)", R"(\ '.-" // o\)",
R"( 1 )", R"(/_.'-._ \\ /)", R"(???????`"--(/"`?)"},
R"( 1 1 )", {R"( 22222 )", R"(66 121111211 )", R"(6 6111 77 41)",
R"(663745)", R"(6661111 77 1)", R"( 11113311 )"}},
R"( 111 )", {{R"(??__?)", R"(><_'>)", R"(???'?)"},
R"( 3 )"}}, {R"( 11 )", R"(61145)", R"( 3 )"}},
{ {{R"(????????_.-`\??????)", R"(?????-:`_..,_\?????)",
{ R"(('-..:-` , '-.,?)", R"(?} _ ;':( o :)",
R"(?????,????)", R"((.-`/'-.,__'` _.-`?)", R"(???`'-.,/??//`?????)"},
R"(?????}\???)", {R"( 22222 )", R"( 222111112 )",
R"(\??.' `\?)", R"(66661111 7 1111 )", R"( 6 1 7777 4 1)",
R"(}}< ( 6>)", R"(6666211111177 1111 )", R"( 222222 333 )"}},
R"(/??`, .'?)", {{
R"(?????}/???)", R"(????????/\??????)",
R"(?????'????)"}, R"(????????\.\_????)",
{ R"(\'-,.:-` '-,?)",
R"( 2 )", R"( ) _ (>( o <)",
R"( 22 )", R"(/.-`?':._ _.-`?)",
R"(6 11 11 )", R"(??????;/?``?????)",
R"(661 7 45)", },
R"(6 11 11 )", {
R"( 33 )", R"( 22 )",
R"( 3 )"}}, R"( 2121 )",
{ R"(66661111 111 )",
{ R"( 6 1 777 4 1)",
R"(???????,--,_????)", R"(6666 1111 1111 )",
R"(__????_\.---'-.?)", R"( 22 33 )",
R"(\ '.-" // o\)", }},
R"(/_.'-._ \\ /)", {{R"(_?????????_.*"\??????)", R"(\'-._..-*` `'*-.??)",
R"(???????`"--(/"`?)"}, R"(?) , (( o >)", R"(/.`"*--.__)_.`_.-*`??)"},
{ {
R"( 22222 )", R"(6 11222 )",
R"(66 121111211 )", R"(6661111111 11111 )",
R"(6 6111 77 41)", R"( 6 3 77 4 1)",
R"(6661111 77 1)", R"(6661111111311311111 )",
R"( 11113311 )"}}, }}};
{ return fishAssets;
{ }
R"(??__?)",
R"(><_'>)",
R"(???'?)"},
{
R"( 11 )",
R"(61145)",
R"( 3 )"}},
{
{
R"(????????_.-`\??????)",
R"(?????-:`_..,_\?????)",
R"(('-..:-` , '-.,?)",
R"(?} _ ;':( o :)",
R"((.-`/'-.,__'` _.-`?)",
R"(???`'-.,/??//`?????)"},
{
R"( 22222 )",
R"( 222111112 )",
R"(66661111 7 1111 )",
R"( 6 1 7777 4 1)",
R"(6666211111177 1111 )",
R"( 222222 333 )"}},
{
{
R"(????????/\??????)",
R"(????????\.\_????)",
R"(\'-,.:-` '-,?)",
R"( ) _ (>( o <)",
R"(/.-`?':._ _.-`?)",
R"(??????;/?``?????)",
},
{
R"( 22 )",
R"( 2121 )",
R"(66661111 111 )",
R"( 6 1 777 4 1)",
R"(6666 1111 1111 )",
R"( 22 33 )",}},
{
{
R"(_?????????_.*"\??????)",
R"(\'-._..-*` `'*-.??)",
R"(?) , (( o >)",
R"(/.`"*--.__)_.`_.-*`??)"},
{
R"(6 11222 )",
R"(6661111111 11111 )",
R"( 6 3 77 4 1)",
R"(6661111111311311111 )",
}}};
inline const std::vector<AssetPair> fishAssetPairs = inline const std::vector<AssetPair> &getFishAssetPairs() {
createBidirectionalAssets(fishAssets); static const std::vector<AssetPair> fishAssetPairs =
createBidirectionalAssets(getFishAssets());
return fishAssetPairs;
}