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(int asset_index)
: Entity(asset_index % 2 == 0), image(fishAssetPairs[asset_index].image),
mask(fishAssetPairs[asset_index].mask),
: Entity(asset_index % 2 == 0), image(getFishAssetPairs()[asset_index].image),
mask(getFishAssetPairs()[asset_index].mask),
speed(Random::floatInRange(0.25f, 2.25f)) {
const auto &aquarium = Aquarium::getInstance();
@@ -45,7 +45,7 @@ void Fish::randomizeMask() {
}
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; }

View File

@@ -4,76 +4,27 @@
#include "../SpriteUtils.h"
#include <vector>
const std::vector<AssetPair> fishAssets = {
{
{
R"(???\??)",
R"(??/ \?)",
R"(>=_('>)",
R"(??\_/?)",
R"(???/??)"},
{
R"( 1 )",
R"( 1 1 )",
R"(663745)",
R"( 111 )",
R"( 3 )"}},
{
{
R"(?????,????)",
R"(?????}\???)",
R"(\??.' `\?)",
R"(}}< ( 6>)",
R"(/??`, .'?)",
R"(?????}/???)",
R"(?????'????)"},
{
R"( 2 )",
R"( 22 )",
R"(6 11 11 )",
R"(661 7 45)",
R"(6 11 11 )",
R"( 33 )",
R"( 3 )"}},
{
{
R"(???????,--,_????)",
R"(__????_\.---'-.?)",
R"(\ '.-" // o\)",
R"(/_.'-._ \\ /)",
R"(???????`"--(/"`?)"},
{
R"( 22222 )",
R"(66 121111211 )",
R"(6 6111 77 41)",
R"(6661111 77 1)",
R"( 11113311 )"}},
{
{
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 )"}},
{
{
inline const std::vector<AssetPair> &getFishAssets() {
static const std::vector<AssetPair> fishAssets = {
{{R"(???\??)", R"(??/ \?)", R"(>=_('>)", R"(??\_/?)", R"(???/??)"},
{R"( 1 )", R"( 1 1 )", R"(663745)", R"( 111 )", R"( 3 )"}},
{{R"(?????,????)", R"(?????}\???)", R"(\??.' `\?)", R"(}}< ( 6>)",
R"(/??`, .'?)", R"(?????}/???)", R"(?????'????)"},
{R"( 2 )", R"( 22 )", R"(6 11 11 )", R"(661 7 45)",
R"(6 11 11 )", R"( 33 )", R"( 3 )"}},
{{R"(???????,--,_????)", R"(__????_\.---'-.?)", R"(\ '.-" // o\)",
R"(/_.'-._ \\ /)", R"(???????`"--(/"`?)"},
{R"( 22222 )", R"(66 121111211 )", R"(6 6111 77 41)",
R"(6661111 77 1)", R"( 11113311 )"}},
{{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"(\'-,.:-` '-,?)",
@@ -87,19 +38,21 @@ const std::vector<AssetPair> fishAssets = {
R"(66661111 111 )",
R"( 6 1 777 4 1)",
R"(6666 1111 1111 )",
R"( 22 33 )",}},
{
{
R"(_?????????_.*"\??????)",
R"(\'-._..-*` `'*-.??)",
R"(?) , (( o >)",
R"(/.`"*--.__)_.`_.-*`??)"},
R"( 22 33 )",
}},
{{R"(_?????????_.*"\??????)", R"(\'-._..-*` `'*-.??)",
R"(?) , (( o >)", R"(/.`"*--.__)_.`_.-*`??)"},
{
R"(6 11222 )",
R"(6661111111 11111 )",
R"( 6 3 77 4 1)",
R"(6661111111311311111 )",
}}};
return fishAssets;
}
inline const std::vector<AssetPair> fishAssetPairs =
createBidirectionalAssets(fishAssets);
inline const std::vector<AssetPair> &getFishAssetPairs() {
static const std::vector<AssetPair> fishAssetPairs =
createBidirectionalAssets(getFishAssets());
return fishAssetPairs;
}