[Freeciv-Dev] Re: (PR#4751) replace some 'int' with 'bool' in the drawin
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] Re: (PR#4751) replace some 'int' with 'bool' in the drawing code |
From: |
"Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx> |
Date: |
Mon, 4 Aug 2003 21:51:11 -0700 |
Reply-to: |
rt@xxxxxxxxxxxxxx |
Jason Short wrote:
> This patch changes the 'solid_bg' and 'fog' variables, used in scattered
> places in the drawing code, from integers to booleans.
>
> Tested under GTK and XAW.
And the patch...
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.55
diff -u -r1.55 mapview_common.c
--- client/mapview_common.c 2003/07/28 04:10:56 1.55
+++ client/mapview_common.c 2003/08/05 04:29:43
@@ -418,8 +418,8 @@
int unit_width, int unit_height)
{
struct Sprite *sprites[40];
- int solid_bg, i;
- int count = fill_unit_sprite_array(sprites, punit, &solid_bg);
+ bool solid_bg;
+ int count = fill_unit_sprite_array(sprites, punit, &solid_bg), i;
if (!is_isometric && solid_bg) {
gui_put_rectangle(pcanvas_store, player_color(unit_owner(punit)),
@@ -510,16 +510,16 @@
int canvas_x, int canvas_y, bool citymode)
{
struct Sprite *tile_sprs[80];
- int fill_bg; /* FIXME: should be bool */
+ bool solid_bg;
struct player *pplayer;
bool is_real = normalize_map_pos(&map_x, &map_y);
if (is_real && tile_get_known(map_x, map_y)) {
int count = fill_tile_sprite_array(tile_sprs, map_x, map_y, citymode,
- &fill_bg, &pplayer);
+ &solid_bg, &pplayer);
int i = 0;
- if (fill_bg) {
+ if (solid_bg) {
enum color_std color = pplayer ? player_color(pplayer)
: COLOR_STD_BACKGROUND;
gui_put_rectangle(pcanvas_store, color, canvas_x, canvas_y,
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.126
diff -u -r1.126 tilespec.c
--- client/tilespec.c 2003/08/01 19:58:47 1.126
+++ client/tilespec.c 2003/08/05 04:29:44
@@ -1256,16 +1256,16 @@
Fill in the sprite array for the city
***********************************************************************/
static int fill_city_sprite_array(struct Sprite **sprs, struct city *pcity,
- int *solid_bg)
+ bool *solid_bg)
{
struct Sprite **save_sprs=sprs;
- *solid_bg = 0;
+ *solid_bg = FALSE;
if (!no_backdrop) {
if(!solid_color_behind_units) {
*sprs++ = get_city_nation_flag_sprite(pcity);
} else {
- *solid_bg = 1;
+ *solid_bg = TRUE;
}
}
@@ -1380,11 +1380,11 @@
Fill in the sprite array for the unit
***********************************************************************/
int fill_unit_sprite_array(struct Sprite **sprs, struct unit *punit,
- int *solid_bg)
+ bool *solid_bg)
{
struct Sprite **save_sprs=sprs;
int ihp;
- *solid_bg = 0;
+ *solid_bg = FALSE;
if (is_isometric) {
if (!no_backdrop) {
@@ -1395,7 +1395,7 @@
if (!solid_color_behind_units) {
*sprs++ = get_unit_nation_flag_sprite(punit);
} else {
- *solid_bg = 1;
+ *solid_bg = TRUE;
}
}
}
@@ -1820,7 +1820,7 @@
int fill_tile_sprite_array_iso(struct Sprite **sprs, struct Sprite **coasts,
struct Sprite **dither,
int x, int y, bool citymode,
- int *solid_bg)
+ bool *solid_bg)
{
enum tile_terrain_type ttype, ttype_near[8];
enum tile_special_type tspecial, tspecial_near[8];
@@ -1828,7 +1828,7 @@
struct city *pcity;
struct Sprite **save_sprs = sprs;
- *solid_bg = 0;
+ *solid_bg = FALSE;
if (tile_get_known(x, y) == TILE_UNKNOWN)
return -1;
@@ -1901,7 +1901,7 @@
}
}
} else {
- *solid_bg = 1;
+ *solid_bg = TRUE;
/* This call is duplicated because it is normally
* drawn underneath rivers. */
@@ -2012,7 +2012,8 @@
12) FoW
***********************************************************************/
int fill_tile_sprite_array(struct Sprite **sprs, int abs_x0, int abs_y0,
- bool citymode, int *solid_bg, struct player
**pplayer)
+ bool citymode, bool *solid_bg,
+ struct player **pplayer)
{
enum tile_terrain_type ttype, ttype_near[8];
enum tile_special_type tspecial, tspecial_near[8];
@@ -2027,7 +2028,7 @@
int den_y=map.ysize*.24;
struct Sprite **save_sprs=sprs;
- *solid_bg = 0;
+ *solid_bg = FALSE;
*pplayer = NULL;
ptile=map_get_tile(abs_x0, abs_y0);
@@ -2079,7 +2080,7 @@
if (draw_terrain)
*sprs++=mysprite;
else
- *solid_bg = 1;
+ *solid_bg = TRUE;
if(is_ocean(ttype) && draw_terrain) {
int dir;
@@ -2172,7 +2173,7 @@
}
if (pcity && draw_cities) {
- int dummy;
+ bool dummy;
sprs += fill_city_sprite_array(sprs, pcity, &dummy);
}
@@ -2183,7 +2184,7 @@
if ((!focus_unit_hidden || pfocus != punit) &&
(draw_units || (draw_focus_unit && !focus_unit_hidden
&& punit == pfocus))) {
- int dummy;
+ bool dummy;
no_backdrop = (pcity != NULL);
sprs += fill_unit_sprite_array(sprs, punit, &dummy);
Index: client/tilespec.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.h,v
retrieving revision 1.45
diff -u -r1.45 tilespec.h
--- client/tilespec.h 2003/07/17 04:43:03 1.45
+++ client/tilespec.h 2003/08/05 04:29:44
@@ -52,10 +52,12 @@
int fill_tile_sprite_array_iso(struct Sprite **sprs, struct Sprite **coasts,
struct Sprite **dither,
int x, int y, bool citymode,
- int *solid_bg);
+ bool *solid_bg);
int fill_tile_sprite_array(struct Sprite **sprs, int abs_x0, int abs_y0,
- bool citymode, int *solid_bg, struct player
**pplayer);
-int fill_unit_sprite_array(struct Sprite **sprs, struct unit *punit, int
*solid_bg);
+ bool citymode, bool *solid_bg,
+ struct player **pplayer);
+int fill_unit_sprite_array(struct Sprite **sprs, struct unit *punit,
+ bool *solid_bg);
int fill_city_sprite_array_iso(struct Sprite **sprs, struct city *pcity);
enum color_std player_color(struct player *pplayer);
Index: client/gui-gtk/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapview.c,v
retrieving revision 1.178
diff -u -r1.178 mapview.c
--- client/gui-gtk/mapview.c 2003/07/25 18:59:45 1.178
+++ client/gui-gtk/mapview.c 2003/08/05 04:29:44
@@ -63,7 +63,7 @@
struct Sprite *ssprite,
int offset_x, int offset_y,
int width, int height,
- int fog);
+ bool fog);
static void really_draw_segment(int src_x, int src_y, int dir,
bool write_to_screen, bool force);
static void pixmap_put_tile_iso(GdkDrawable *pm, int x, int y,
@@ -1044,7 +1044,7 @@
struct Sprite *ssprite,
int offset_x, int offset_y,
int width, int height,
- int fog)
+ bool fog)
{
if (!ssprite || !width || !height)
return;
@@ -1308,7 +1308,7 @@
int canvas_x, int canvas_y,
int offset_x, int offset_y_unit,
int width, int height_unit,
- int fog)
+ bool fog)
{
struct Sprite *sprites[80];
int count = fill_city_sprite_array_iso(sprites, pcity);
@@ -1351,7 +1351,7 @@
static void dither_tile(GdkDrawable *pixmap, struct Sprite **dither,
int canvas_x, int canvas_y,
int offset_x, int offset_y,
- int width, int height, int fog)
+ int width, int height, bool fog)
{
if (!width || !height)
return;
@@ -1436,8 +1436,7 @@
struct unit *punit, *pfocus;
enum tile_special_type special;
int count, i = 0;
- int fog;
- int solid_bg;
+ bool solid_bg, fog;
struct canvas_store canvas_store = {pm};
if (!width || !(height || height_unit))
Index: client/gui-gtk-2.0/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/mapview.c,v
retrieving revision 1.72
diff -u -r1.72 mapview.c
--- client/gui-gtk-2.0/mapview.c 2003/07/25 18:59:46 1.72
+++ client/gui-gtk-2.0/mapview.c 2003/08/05 04:29:44
@@ -64,7 +64,7 @@
struct Sprite *ssprite,
int offset_x, int offset_y,
int width, int height,
- int fog);
+ bool fog);
static void really_draw_segment(int src_x, int src_y, int dir,
bool write_to_screen, bool force);
static void pixmap_put_tile_iso(GdkDrawable *pm, int x, int y,
@@ -1127,7 +1127,7 @@
struct Sprite *ssprite,
int offset_x, int offset_y,
int width, int height,
- int fog)
+ bool fog)
{
if (!ssprite || !width || !height)
return;
@@ -1391,7 +1391,7 @@
int canvas_x, int canvas_y,
int offset_x, int offset_y_unit,
int width, int height_unit,
- int fog)
+ bool fog)
{
struct Sprite *sprites[80];
int count = fill_city_sprite_array_iso(sprites, pcity);
@@ -1434,7 +1434,7 @@
static void dither_tile(GdkDrawable *pixmap, struct Sprite **dither,
int canvas_x, int canvas_y,
int offset_x, int offset_y,
- int width, int height, int fog)
+ int width, int height, bool fog)
{
if (!width || !height)
return;
@@ -1519,8 +1519,7 @@
struct unit *punit, *pfocus;
enum tile_special_type special;
int count, i = 0;
- int fog;
- int solid_bg;
+ bool solid_bg, fog;
struct canvas_store canvas_store = {pm};
if (!width || !(height || height_unit))
Index: client/gui-sdl/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-sdl/mapview.c,v
retrieving revision 1.54
diff -u -r1.54 mapview.c
--- client/gui-sdl/mapview.c 2003/07/24 13:47:54 1.54
+++ client/gui-sdl/mapview.c 2003/08/05 04:29:44
@@ -1535,7 +1535,8 @@
static SDL_Rect copy, des;
static SDL_Rect src_hp = {0,0,0,0};
static SDL_Rect src_flag = {0,0,0,0};
- static int dummy, count;
+ static int count, i;
+ bool solid_bg;
if(!pUnit) {
return;
@@ -1544,7 +1545,7 @@
des.x = map_x;
des.y = map_y;
- count = fill_unit_sprite_array(pSprites, pUnit, &dummy);
+ count = fill_unit_sprite_array(pSprites, pUnit, &solid_bg);
des.x += NORMAL_TILE_WIDTH / 4;
@@ -1571,9 +1572,9 @@
des.x = map_x;
des.y = map_y;
copy = des;
- for (dummy = 1; dummy < count - 1; dummy++) {
- if (pSprites[dummy]) {
- SDL_BlitSurface(GET_SURF(pSprites[dummy]), NULL, pDest, &des);
+ for (i = 1; i < count - 1; i++) {
+ if (pSprites[i]) {
+ SDL_BlitSurface(GET_SURF(pSprites[i]), NULL, pDest, &des);
des = copy;
}
}
@@ -1616,8 +1617,8 @@
static struct unit *pUnit = NULL, *pFocus = NULL;
static enum tile_special_type special;
static enum tile_terrain_type terrain;
- static int count, i, solid_bg;
- static bool fog, full_ocean;
+ static int count, i;
+ static bool fog, full_ocean, solid_bg;
count =
fill_tile_sprite_array_iso(pTile_sprs, pCoasts, pDither, map_col,
Index: client/gui-win32/mapview.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/mapview.c,v
retrieving revision 1.77
diff -u -r1.77 mapview.c
--- client/gui-win32/mapview.c 2003/07/25 18:59:46 1.77
+++ client/gui-win32/mapview.c 2003/08/05 04:29:44
@@ -78,7 +78,7 @@
static void dither_tile(HDC hdc, struct Sprite **dither,
int canvas_x, int canvas_y,
int offset_x, int offset_y,
- int width, int height, int fog);
+ int width, int height, bool fog);
static void put_line(HDC hdc, int x, int y,
int dir, bool write_to_screen);
static void draw_rates(HDC hdc);
@@ -175,7 +175,8 @@
**************************************************************************/
void put_unit_pixmap(struct unit *punit, HDC hdc,int canvas_x,int canvas_y)
{
- int solid_bg;
+ bool solid_bg;
+
if (is_isometric) {
struct Sprite *sprites[40];
int count = fill_unit_sprite_array(sprites, punit,&solid_bg);
@@ -1059,7 +1060,7 @@
static void dither_tile(HDC hdc, struct Sprite **dither,
int canvas_x, int canvas_y,
int offset_x, int offset_y,
- int width, int height, int fog)
+ int width, int height, bool fog)
{
if (!width || !height)
return;
@@ -1182,7 +1183,7 @@
struct Sprite *ssprite,
int offset_x, int offset_y,
int width, int height,
- int fog)
+ bool fog)
{
if (!ssprite || !width || !height)
return;
@@ -1315,7 +1316,7 @@
int width, int height_unit)
{
struct Sprite *sprites[40];
- int dummy;
+ bool dummy;
int count = fill_unit_sprite_array(sprites, punit, &dummy);
int i;
@@ -1336,7 +1337,7 @@
int canvas_x, int canvas_y,
int offset_x, int offset_y_unit,
int width, int height_unit,
- int fog)
+ bool fog)
{
struct Sprite *sprites[80];
int count = fill_city_sprite_array_iso(sprites, pcity);
@@ -1370,9 +1371,7 @@
struct unit *punit, *pfocus;
enum tile_special_type special;
int count, i = 0;
- int fog;
- int solid_bg;
- int is_real;
+ bool fog, solid_bg, is_real;
if (!width || !(height || height_unit))
return;
|
|