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

Schmetterlinkskuh-Flugsimulator-Simulation 2k: Collision system doesn't work in Level 2 #1176

Closed
Ghabry opened this Issue May 21, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@Ghabry
Member

Ghabry commented May 21, 2017

Name: Schmetterlinkskuh-Flugsimulator-Simulation 2k

Download: http://rmarchiv.de/games/704

Savegame:
Save01.zip

After loading the save level 2 starts. (Epilepsy warning!). You can't collide with the scenery and just pass through making the game unwinnable because the "End game" tiles don't work either.

screenshot_20170522_014051

@Ghabry

This comment has been minimized.

Show comment
Hide comment
@Ghabry

Ghabry May 22, 2017

Member

The problem is that the map is looping so GetTerrainID actually wraps (so when the map is 20x20 and you request "20" then it wraps and takes the 1st one...). Also works in negative direction.

Somehow doesn't affect other event commands. E.g. GetEventID doesn't wrap.

Thx to scurest for the idea.

CC @CherryDT . More obscure Maker behaviour.

Member

Ghabry commented May 22, 2017

The problem is that the map is looping so GetTerrainID actually wraps (so when the map is 20x20 and you request "20" then it wraps and takes the 1st one...). Also works in negative direction.

Somehow doesn't affect other event commands. E.g. GetEventID doesn't wrap.

Thx to scurest for the idea.

CC @CherryDT . More obscure Maker behaviour.

@Ghabry

This comment has been minimized.

Show comment
Hide comment
@Ghabry

Ghabry May 22, 2017

Member
diff --git a/src/game_map.cpp b/src/game_map.cpp
index 2551b972..b4a086ca 100644
--- a/src/game_map.cpp
+++ b/src/game_map.cpp
@@ -665,7 +665,10 @@ bool Game_Map::IsCounter(int x, int y) {
 	return !!(passages_up[index] & Passable::Counter);
 }
 
-int Game_Map::GetTerrainTag(int const x, int const y) {
+int Game_Map::GetTerrainTag(int const xpos, int const ypos) {
+	int x = Game_Map::RoundX(xpos);
+	int y = Game_Map::RoundY(ypos);
+
 	if (!Game_Map::IsValid(x, y)) return 9;
 
 	unsigned const chipID = map->lower_layer[x + y * GetWidth()];

Or better change the func signature. "const int" is nonsense.

Member

Ghabry commented May 22, 2017

diff --git a/src/game_map.cpp b/src/game_map.cpp
index 2551b972..b4a086ca 100644
--- a/src/game_map.cpp
+++ b/src/game_map.cpp
@@ -665,7 +665,10 @@ bool Game_Map::IsCounter(int x, int y) {
 	return !!(passages_up[index] & Passable::Counter);
 }
 
-int Game_Map::GetTerrainTag(int const x, int const y) {
+int Game_Map::GetTerrainTag(int const xpos, int const ypos) {
+	int x = Game_Map::RoundX(xpos);
+	int y = Game_Map::RoundY(ypos);
+
 	if (!Game_Map::IsValid(x, y)) return 9;
 
 	unsigned const chipID = map->lower_layer[x + y * GetWidth()];

Or better change the func signature. "const int" is nonsense.

@Ghabry Ghabry added this to the 0.5.2 milestone May 22, 2017

@scurest

This comment has been minimized.

Show comment
Hide comment
@scurest

scurest May 23, 2017

Contributor

To get this to match RPG_RT in all cases, we'd also have to change RoundX (and RoundY) to handle all values. We only handle negative numbers as far as -width, because once you go below that, the LHS in (x + GetWidth()) % GetWidth() becomes negative. We could replace that with mod(x, GetWidth()) where

// Non-negative modulus
int mod(int x, int m) {
    return (x < 0) ? (m + x % m) : (x % m);
}

or something.

Contributor

scurest commented May 23, 2017

To get this to match RPG_RT in all cases, we'd also have to change RoundX (and RoundY) to handle all values. We only handle negative numbers as far as -width, because once you go below that, the LHS in (x + GetWidth()) % GetWidth() becomes negative. We could replace that with mod(x, GetWidth()) where

// Non-negative modulus
int mod(int x, int m) {
    return (x < 0) ? (m + x % m) : (x % m);
}

or something.

@Ghabry Ghabry self-assigned this May 28, 2017

Ghabry added a commit to Ghabry/easyrpg-player that referenced this issue May 28, 2017

Return correct terrain tag on looping maps.
Fixes the collision system in level 2 of "Schmetterlinkskuh-Flugsimulator-Simulation 2k".

Fix #1176

Ghabry added a commit to Ghabry/easyrpg-player that referenced this issue Jun 6, 2017

Return correct terrain tag on looping maps.
Fixes the collision system in level 2 of "Schmetterlinkskuh-Flugsimulator-Simulation 2k".

Fix #1176

Ghabry added a commit to Ghabry/easyrpg-player that referenced this issue Jun 17, 2017

Return correct terrain tag on looping maps.
Fixes the collision system in level 2 of "Schmetterlinkskuh-Flugsimulator-Simulation 2k".

Fix #1176

carstene1ns added a commit that referenced this issue Jun 23, 2017

Ghabry added a commit to libretro/easyrpg-libretro that referenced this issue May 22, 2018

Return correct terrain tag on looping maps.
Fixes the collision system in level 2 of "Schmetterlinkskuh-Flugsimulator-Simulation 2k".

Fix #1176

Ghabry pushed a commit to libretro/easyrpg-libretro that referenced this issue May 22, 2018

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