From 192c638fd8a7635da1b00ad620535aeb78688da1 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Mon, 17 Jul 2023 08:32:33 +0300 Subject: [PATCH 15/15] gui-stub: Update to use nullptr See osdn #48410 Signed-off-by: Marko Lindqvist --- client/gui-stub/canvas.c | 16 ++++++++-------- client/gui-stub/chatline.c | 2 +- client/gui-stub/gui_main.c | 2 +- client/gui-stub/mapview.c | 12 ++++++------ client/gui-stub/sprite.c | 31 +++++++++++++++---------------- 5 files changed, 31 insertions(+), 32 deletions(-) diff --git a/client/gui-stub/canvas.c b/client/gui-stub/canvas.c index fbf1f96f1a..eae01821af 100644 --- a/client/gui-stub/canvas.c +++ b/client/gui-stub/canvas.c @@ -26,7 +26,7 @@ struct canvas *gui_canvas_create(int width, int height) { /* PORTME */ - return NULL; + return nullptr; } /************************************************************************//** @@ -156,26 +156,26 @@ void gui_canvas_put_curved_line(struct canvas *pcanvas, struct color *pcolor, } /************************************************************************//** - Return the size of the given text in the given font. This size should - include the ascent and descent of the text. Either of width or height - may be NULL in which case those values simply shouldn't be filled out. + Return the size of the given text in the given font. This size should + include the ascent and descent of the text. Either of width or height + may be nullptr in which case those values simply shouldn't be filled out. ****************************************************************************/ void gui_get_text_size(int *width, int *height, enum client_font font, const char *text) { /* PORTME */ - if (width) { + if (width != nullptr) { *width = 0; } - if (height) { + if (height != nullptr) { *height = 0; } } /************************************************************************//** - Draw the text onto the canvas in the given color and font. The canvas + Draw the text onto the canvas in the given color and font. The canvas position does not account for the ascent of the text; this function must - take care of this manually. The text will not be NULL but may be empty. + take care of this manually. The text can't be nullptr but may be empty. ****************************************************************************/ void gui_canvas_put_text(struct canvas *pcanvas, int canvas_x, int canvas_y, enum client_font font, struct color *pcolor, diff --git a/client/gui-stub/chatline.c b/client/gui-stub/chatline.c index 18f9bd93a1..7d03b5c5a4 100644 --- a/client/gui-stub/chatline.c +++ b/client/gui-stub/chatline.c @@ -41,7 +41,7 @@ void gui_real_output_window_append(const char *astring, void log_output_window(void) { /* PORTME */ - write_chatline_content(NULL); + write_chatline_content(nullptr); } /**********************************************************************//** diff --git a/client/gui-stub/gui_main.c b/client/gui-stub/gui_main.c index c43ea59b24..26c286f743 100644 --- a/client/gui-stub/gui_main.c +++ b/client/gui-stub/gui_main.c @@ -175,7 +175,7 @@ void gui_remove_net_input(void) Set one of the unit icons (specified by idx) in the information area based on punit. - punit is the unit the information should be taken from. Use NULL to + punit is the unit the information should be taken from. Use nullptr to clear the icon. idx specified which icon should be modified. Use idx == -1 to indicate diff --git a/client/gui-stub/mapview.c b/client/gui-stub/mapview.c index 20d1973f42..0c6d8f48d9 100644 --- a/client/gui-stub/mapview.c +++ b/client/gui-stub/mapview.c @@ -61,14 +61,14 @@ void update_info_label(void) /************************************************************************//** Update the information label which gives info on the current unit - and the tile under the current unit, for specified unit. Note that + and the tile under the current unit, for specified unit. Note that in practice punit is always the focus unit. - Clears label if punit is NULL. + Clears label if punit is nullptr. Typically also updates the cursor for the map_canvas (this is related because the info label may includes "select destination" - prompt etc). And it may call update_unit_pix_label() to update the + prompt etc). And it may call update_unit_pix_label() to update the icons for units on this tile. ****************************************************************************/ void update_unit_info_label(struct unit_list *punitlist) @@ -135,12 +135,12 @@ void set_indicator_icons(struct sprite *bulb, struct sprite *sol, struct canvas *get_overview_window(void) { /* PORTME */ - return NULL; + return nullptr; } /************************************************************************//** - Mark the rectangular region as "dirty" so that we know to flush it - later. + Mark the rectangular region as "dirty" so that we know to flush + it later. ****************************************************************************/ void dirty_rect(int canvas_x, int canvas_y, int pixel_width, int pixel_height) diff --git a/client/gui-stub/sprite.c b/client/gui-stub/sprite.c index 4377fe9a3a..8fa7b7fa54 100644 --- a/client/gui-stub/sprite.c +++ b/client/gui-stub/sprite.c @@ -23,19 +23,18 @@ #include "sprite.h" /************************************************************************//** - Return a NULL-terminated, permanently allocated array of possible - graphics types extensions. Extensions listed first will be checked - first. + Return a nullptr-terminated, permanently allocated array of possible + graphics types extensions. Extensions listed first will be checked first. ****************************************************************************/ const char **gfx_fileextensions(void) { /* PORTME */ - /* hack to allow stub to run */ + /* Hack to allow stub to run */ static const char *ext[] = { "png", /* png should be the default. */ /* ...etc... */ - NULL + nullptr }; return ext; @@ -49,7 +48,7 @@ const char **gfx_fileextensions(void) struct sprite *gui_load_gfxfile(const char *filename, bool svgflag) { /* PORTME */ - return NULL; + return nullptr; } /************************************************************************//** @@ -58,20 +57,20 @@ struct sprite *gui_load_gfxfile(const char *filename, bool svgflag) source gives the sprite that is to be cropped. - x,y, width, height gives the rectangle to be cropped. The pixel at + x,y, width, height gives the rectangle to be cropped. The pixel at position of the source sprite will be at (0,0) in the new sprite, and the new sprite will have dimensions (width, height). mask gives an additional mask to be used for clipping the new sprite. Only the transparency value of the mask is used in - crop_sprite. The formula is: dest_trans = src_trans * - mask_trans. Note that because the transparency is expressed as an + crop_sprite. The formula is: dest_trans = src_trans * mask_trans. + Note that because the transparency is expressed as an integer it is common to divide it by 256 afterwards. mask_offset_x, mask_offset_y is the offset of the mask relative to the - origin of the source image. The pixel at (mask_offset_x,mask_offset_y) - in the mask image will be used to clip pixel (0,0) in the source image - which is pixel (-x,-y) in the new image. + origin of the source image. The pixel at (mask_offset_x, mask_offset_y) + in the mask image will be used to clip pixel (0, 0) in the source image + which is pixel (-x, -y) in the new image. ****************************************************************************/ struct sprite *gui_crop_sprite(struct sprite *source, int x, int y, int width, int height, @@ -80,16 +79,16 @@ struct sprite *gui_crop_sprite(struct sprite *source, float scale, bool smooth) { /* PORTME */ - return NULL; + return nullptr; } /************************************************************************//** - Create a new sprite with the given height, width and color. + Create a new sprite with the given width, height, and color. ****************************************************************************/ struct sprite *gui_create_sprite(int width, int height, struct color *pcolor) { /* PORTME */ - return NULL; + return nullptr; } /************************************************************************//** @@ -118,5 +117,5 @@ void gui_free_sprite(struct sprite *s) struct sprite *gui_load_gfxnumber(int num) { /* PORTME */ - return NULL; + return nullptr; } -- 2.40.1