Regression: Entering in the bedroom in Yume 2kki's Nocturnal Grove displays a black screen
Mimigris opened this issue · 4 comments
Name of the game:
Yume 2kki (version 0.125 patch 8).
Player platform:
Windows, 64 bits continuous build of the Player.
Describe the issue in detail and how to reproduce it:
Start a new game, then once you can move, try to reach Nocturnal Grove's bedroom by following the directions provided on the wiki. Alternatively, once you can move, teleport to Map 1131, at the coordinates 102, 10. Once there, move right to enter in the bedroom. After a little fade in, the screen should turn black on the continuous build, while it should not in normal gameplay.
I tested this issue on the builds of #3251 and #3259 and this issue is present in 3259 but not in 3251, so I suspect said issue was brought as part of the changes done in 3259.
Might be similar to a bug on ynoengine where the nametags were using cached sprite effects without a sprite ID, causing duplicates.
Problem is that just the filename is not unique enough. For pictures the file can have two transparency settings, also considering the transparency in the key (as we already do for the non-effect bitmap) fixes it.
diff --git a/src/cache.cpp b/src/cache.cpp
index afc411270..4d54b1eb7 100644
--- a/src/cache.cpp
+++ b/src/cache.cpp
@@ -82,7 +82,7 @@ namespace {
std::unordered_map<tile_key_type, std::weak_ptr<Bitmap>> cache_tiles;
// rect, flip_x, flip_y, tone, blend
- using effect_key_type = std::tuple<std::string, Rect, bool, bool, Tone, Color>;
+ using effect_key_type = std::tuple<std::string, bool, Rect, bool, bool, Tone, Color>;
std::map<effect_key_type, std::weak_ptr<Bitmap>> cache_effects;
std::string system_name;
@@ -465,6 +465,7 @@ BitmapRef Cache::Tile(StringView filename, int tile_id) {
BitmapRef Cache::SpriteEffect(const BitmapRef& src_bitmap, const Rect& rect, bool flip_x, bool flip_y, const Tone& tone, const Color& blend) {
const effect_key_type key {
src_bitmap->GetId(),
+ src_bitmap->GetTransparent(),
rect,
flip_x,
flip_y,
@@ -472,6 +473,8 @@ BitmapRef Cache::SpriteEffect(const BitmapRef& src_bitmap, const Rect& rect, boo
blend
};
+ assert(!src_bitmap->GetId().empty());
+
const auto it = cache_effects.find(key);
if (it == cache_effects.end() || it->second.expired()) {also added an assert to catch empty IDs.
Thank you, I'll try to compile and test this patch later today.
The fix works for ynoengine, however since there are many places that might require a proper ID I've also opted to set a default ID based on the pointer value of the BitmapRef.