From ede7156cecb04484848a86a72b7fb1113e099931 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Fri, 21 Apr 2023 20:56:12 +0300
Subject: [PATCH 18/18] Give tile_to_canvas_pos() parameters nonnull attribute

Some other minor adjustments
(constifying parameters, comment cleanup)

See osdn #47894

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 client/mapview_common.c | 19 ++++++++++---------
 client/mapview_common.h |  7 +++++--
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/client/mapview_common.c b/client/mapview_common.c
index 29ab185e60..1df5f45502 100644
--- a/client/mapview_common.c
+++ b/client/mapview_common.c
@@ -77,7 +77,7 @@ bool can_slide = TRUE;
 
 static bool frame_by_frame_animation = FALSE;
 
-struct tile *center_tile = NULL;
+const struct tile *center_tile = NULL;
 
 struct tile *infratile = NULL;
 
@@ -93,7 +93,7 @@ enum update_type {
 };
 
 /* A tile update has a tile associated with it as well as an area type.
- * See unqueue_mapview_updates for a thorough explanation. */
+ * See unqueue_mapview_updates() for a thorough explanation. */
 enum tile_update_type {
   TILE_UPDATE_TILE_SINGLE,
   TILE_UPDATE_TILE_FULL,
@@ -667,11 +667,12 @@ static void gui_to_map_pos(const struct tileset *t,
   }
 
   This pixel is one position closer to the lower right, which may be
-  important to remember when doing some round-off operations. Other
-  parts of the code assume tileset_tile_width(tileset) and tileset_tile_height(tileset)
-  to be even numbers.
+  important to remember when doing some round-off operations.
+  Other parts of the code assume tileset_tile_width(tileset) and
+  tileset_tile_height(tileset) to be even numbers.
 ****************************************************************************/
-bool tile_to_canvas_pos(float *canvas_x, float *canvas_y, struct tile *ptile)
+bool tile_to_canvas_pos(float *canvas_x, float *canvas_y,
+                        const struct tile *ptile)
 {
   int center_map_x, center_map_y, dx, dy, tile_x, tile_y;
 
@@ -1194,9 +1195,9 @@ struct tile *get_center_tile_mapcanvas(void)
 }
 
 /************************************************************************//**
-  Centers the mapview around (map_x, map_y).
+  Centers the mapview around ptile.
 ****************************************************************************/
-void center_tile_mapcanvas(struct tile *ptile)
+void center_tile_mapcanvas(const struct tile *ptile)
 {
   float gui_x, gui_y;
   int tile_x, tile_y;
@@ -2427,7 +2428,7 @@ void show_tile_labels(int canvas_base_x, int canvas_base_y,
         /* The update was incomplete! We queue a new update. Note that
          * this is recursively queueing an update within a dequeuing of an
          * update. This is allowed specifically because of the code in
-         * unqueue_mapview_updates. See that function for more. */
+         * unqueue_mapview_updates(). See that function for more. */
         log_debug("Re-queuing tile label %s drawing.", ptile->label);
         update_tile_label(ptile);
       }
diff --git a/client/mapview_common.h b/client/mapview_common.h
index 2f17cfdfed..abaa7b5c1f 100644
--- a/client/mapview_common.h
+++ b/client/mapview_common.h
@@ -250,7 +250,9 @@ void unqueue_mapview_updates(bool write_to_screen);
 
 void map_to_gui_vector(const struct tileset *t, float zoom,
                        float *gui_dx, float *gui_dy, int map_dx, int map_dy);
-bool tile_to_canvas_pos(float *canvas_x, float *canvas_y, struct tile *ptile);
+bool tile_to_canvas_pos(float *canvas_x, float *canvas_y,
+                        const struct tile *ptile)
+  fc__attribute((nonnull (1, 2, 3)));
 struct tile *canvas_pos_to_tile(float canvas_x, float canvas_y);
 struct tile *canvas_pos_to_nearest_tile(float canvas_x, float canvas_y);
 
@@ -263,7 +265,8 @@ void set_mapview_scroll_pos(int scroll_x, int scroll_y);
 
 void set_mapview_origin(float gui_x0, float gui_y0);
 struct tile *get_center_tile_mapcanvas(void);
-void center_tile_mapcanvas(struct tile *ptile);
+void center_tile_mapcanvas(const struct tile *ptile)
+  fc__attribute((nonnull (1)));
 
 bool tile_visible_mapcanvas(struct tile *ptile);
 bool tile_visible_and_not_on_border_mapcanvas(struct tile *ptile);
-- 
2.39.2