Skip to content
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

Isometric fixes #60283

Merged
merged 4 commits into from
Aug 29, 2022
Merged

Isometric fixes #60283

merged 4 commits into from
Aug 29, 2022

Conversation

irwiss
Copy link
Contributor

@irwiss irwiss commented Aug 18, 2022

Summary

Bugfixes "Fixes for isometric tilesets"

Purpose of change

Fixes #57123

Sort of fixes as it just disables selecting smashbutton for overmap tileset until an implementation is done:

Fixes #58951
Fixes #60169 (issue unrelated to android)

As in, these are bugs because smashbutton is available for selection, but appears to be that they should be feature requests instead

Describe the solution

Tileset load order determined if you had experienced the bug or not - cached_options.h had a global iso_mode that was set by whatever tileset happened to load last, and read (and cached, for example in minimap) at random times, this caused weird behaviour.

Removed the global, added tileset::tile_isometric that returns the right value for that tileset, a few getters for it, and routed queries for the global through the getters.

Minimap now syncs to whichever iso/ortho tileset is currently active.

The terrain offset issue in #58951 and #60169 is trivial to fix, something like this (click me) will get terrain and extras rendering sort of correctly (centered)
diff --git a/src/sdltiles.cpp b/src/sdltiles.cpp
index 23be4ce5f0d688d68ad13aa5f8342112c01fa6ac..eb439418a968b172f65a5c21b236317788ef1248 100644
--- a/src/sdltiles.cpp
+++ b/src/sdltiles.cpp
@@ -863,14 +863,20 @@ void cata_tiles::draw_om( const point &dest, const tripoint_abs_omt &center_abs_
     const bool viewing_weather = uistate.overmap_debug_weather || uistate.overmap_visible_weather;
     o = corner_NW.raw().xy();
 
-    const auto global_omt_to_draw_position = []( const tripoint_abs_omt & omp ) {
+    const auto global_omt_to_draw_position = [&overmap_area, isometric = is_isometric()]
+    ( const tripoint_abs_omt & omp ) {
         // z position is hardcoded to 0 because the things this will be used to draw should not be skipped
+        if( isometric ) {
+            tripoint offset = ( overmap_area.p_max - overmap_area.p_min ) / 2;
+            return tripoint( omp.raw().xy() - offset.xy(), 0 );
+        }
         return tripoint( omp.raw().xy(), 0 );
     };
 
     for( int row = min_row; row < max_row; row++ ) {
         for( int col = min_col; col < max_col; col++ ) {
             const tripoint_abs_omt omp = corner_NW + point( col, row );
+            const tripoint draw_pos = global_omt_to_draw_position( omp );
 
             const bool see = overmap_buffer.seen( omp );
             const bool los = see && you.overmap_los( omp, sight_points );
@@ -897,10 +903,10 @@ void cata_tiles::draw_om( const point &dest, const tripoint_abs_omt &center_abs_
 
             const lit_level ll = overmap_buffer.is_explored( omp ) ? lit_level::LOW : lit_level::LIT;
             // light level is now used for choosing between grayscale filter and normal lit tiles.
-            draw_from_id_string( id, TILE_CATEGORY::OVERMAP_TERRAIN, "overmap_terrain", omp.raw(),
+            draw_from_id_string( id, TILE_CATEGORY::OVERMAP_TERRAIN, "overmap_terrain", draw_pos,
                                  subtile, rotation, ll, false, height_3d );
             if( !mx.is_empty() && mx->autonote ) {
-                draw_from_id_string( mx.str(), TILE_CATEGORY::MAP_EXTRA, "map_extra", omp.raw(),
+                draw_from_id_string( mx.str(), TILE_CATEGORY::MAP_EXTRA, "map_extra", draw_pos,
                                      0, 0, ll, false );
             }
 

But it appears that there's lots of other issues such as tiles overdrawing each other, city labels floating and appear to be moving in mysterious ways, the (centered) isometric map also doesn't fill the entire screen - a simple fix is bumping up max_row/max_col in draw_om, but that is again a dirty fix.
TL;DR Overmap iso tileset support needs a proper implementation before it can work right. Smashbutton also appears to be missing most tiles used by overmap so it looks like super bugged ascii map just rendered in iso projection.

For now ( until someone gets a desire to implement overmap iso support ) I think disallowing smashbutton as overmap tileset is acceptable workaround, if not then cherrypick all but the last commit.
Using smashbutton as a "normal" game tileset should work, including mixing iso and non-iso for near/far tilesets.

Describe alternatives you've considered

Testing

  1. Assign smashbutton to either near or far tileset, the other should be non-iso and try moving around
    both modes should work
    check in iso mode the direction keys have an intercept that rotates them "right".
    check minimap syncs up to current tileset - when in iso tileset it should be in iso mode, and same for ortho mode
  2. Save/quit/reload check everything still works right
  3. Switch the tilesets assignments made in step 1 and repeat the tests ()
  4. Save/quit/reload check everything still works right
  5. Check Smashbutton is not available as selection for overmap tileset

Additional context

@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` <Bugfix> This is a fix for a bug (or closes open issue) json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions labels Aug 18, 2022
@irwiss irwiss marked this pull request as ready for review August 19, 2022 06:10
@dseguin dseguin merged commit 36ef515 into CleverRaven:master Aug 29, 2022
@irwiss irwiss deleted the isometric-fixes branch August 29, 2022 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` json-styled JSON lint passed, label assigned by github actions
Projects
None yet
2 participants