New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yume 2kki: Invisible events shown on maps with empty tileset graphics #1228

Closed
carstene1ns opened this Issue Jul 29, 2017 · 2 comments

Comments

Projects
None yet
3 participants
@carstene1ns
Member

carstene1ns commented Jul 29, 2017

In Yume 2kki there are some tilesets without file name in the database (not really possible with the editor, likely manually done). They are used on some maps like the music room and the events using them should be invisible. Instead we draw a black box currently.

current (0.5.2/master) expected (0.5.1/RPG_RT)
s2 s0
s3 s1

Editor:
editor

This bug was introduced by #1179 (and not fixed by 8c8ab53). Before they were not visible, because tile_id was 0 in this case. btw. we actually check for this case in Sprite_Character::OnTileSpriteReady() and draw that black box:

	if (!Game_Map::GetChipsetName().empty())
		tile = Cache::Tile(Game_Map::GetChipsetName(), tile_id);
	else
		tile = Bitmap::Create(16, 16, Color()); // black box

Changing that to be a transparent box does not work (likely because we optimize that away somewhere). This patch seems to work, but I am not happy with it because everything is skipped:

diff --git a/src/sprite_character.cpp b/src/sprite_character.cpp
index fadfb09b..28702a09 100644
--- a/src/sprite_character.cpp
+++ b/src/sprite_character.cpp
@@ -45,7 +45,8 @@ void Sprite_Character::Update() {
 			FileRequestAsync* char_request = AsyncHandler::RequestFile("CharSet", character_name);
 			request_id = char_request->Bind(&Sprite_Character::OnCharSpriteReady, this);
 			char_request->Start();
-		} else {
+		// Yume 2kki has cleared tilesets (empty tileset_name) for some maps, making events transparent.
+		} else if (!Game_Map::GetChipsetName().empty()) {
 			FileRequestAsync* tile_request = AsyncHandler::RequestFile("ChipSet", Game_Map::GetChipsetName());
 			request_id = tile_request->Bind(&Sprite_Character::OnTileSpriteReady, this);
 			tile_request->Start();
@@ -92,16 +93,7 @@ bool Sprite_Character::UsesCharset() const {
 }
 
 void Sprite_Character::OnTileSpriteReady(FileRequestResult*) {
-	std::string chipset = Game_Map::GetChipsetName();
-
-	BitmapRef tile;
-	if (!chipset.empty()) {
-		tile = Cache::Tile(Game_Map::GetChipsetName(), tile_id);
-	}
-	else {
-		tile = Bitmap::Create(16, 16, Color());
-	}
-
+	BitmapRef tile = Cache::Tile(Game_Map::GetChipsetName(), tile_id);
 	SetBitmap(tile);
 
 	Rect r;

@carstene1ns carstene1ns added this to the 0.5.3 milestone Jul 29, 2017

@Ghabry Ghabry referenced this issue Oct 10, 2017

Merged

Small Bugfixes #1280

@20kdc

This comment has been minimized.

Show comment
Hide comment
@20kdc

20kdc Oct 13, 2017

Contributor

Slightly concerned that changing it to a transparent box didn't work, mostly because it doesn't make sense. Shouldn't even be optimizable, really...

Contributor

20kdc commented Oct 13, 2017

Slightly concerned that changing it to a transparent box didn't work, mostly because it doesn't make sense. Shouldn't even be optimizable, really...

@Ghabry

This comment has been minimized.

Show comment
Hide comment
@Ghabry

Ghabry Oct 13, 2017

Member

This works for me:

diff --git a/src/sprite_character.cpp b/src/sprite_character.cpp
index fadfb09b..69d1fa7f 100644
--- a/src/sprite_character.cpp
+++ b/src/sprite_character.cpp
@@ -99,7 +99,7 @@ void Sprite_Character::OnTileSpriteReady(FileRequestResult*) {
 		tile = Cache::Tile(Game_Map::GetChipsetName(), tile_id);
 	}
 	else {
-		tile = Bitmap::Create(16, 16, Color());
+		tile = Bitmap::Create(16, 16, true);
 	}
 
 	SetBitmap(tile);

Looks like the "w, h, Color" constructor of Bitmap forwards to "w, h, transparent = false"... No idea who designed this but don't think changing this now without extra tests is a good idea.

Member

Ghabry commented Oct 13, 2017

This works for me:

diff --git a/src/sprite_character.cpp b/src/sprite_character.cpp
index fadfb09b..69d1fa7f 100644
--- a/src/sprite_character.cpp
+++ b/src/sprite_character.cpp
@@ -99,7 +99,7 @@ void Sprite_Character::OnTileSpriteReady(FileRequestResult*) {
 		tile = Cache::Tile(Game_Map::GetChipsetName(), tile_id);
 	}
 	else {
-		tile = Bitmap::Create(16, 16, Color());
+		tile = Bitmap::Create(16, 16, true);
 	}
 
 	SetBitmap(tile);

Looks like the "w, h, Color" constructor of Bitmap forwards to "w, h, transparent = false"... No idea who designed this but don't think changing this now without extra tests is a good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment