[Freeciv-Dev] (PR#11124) move mapview decorations into the client
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=11124 >
This patch takes the ptile->client.hilite value and moves it into a
separate client map_deco array.
The advantage of this is that we can have map decorations (this one, and
other values) without bloating the core map structure (which needs to be
small to be efficient) or polluting common/ code with them.
jason
Index: client/mapctrl_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapctrl_common.c,v
retrieving revision 1.42
diff -u -r1.42 mapctrl_common.c
--- client/mapctrl_common.c 1 Oct 2004 17:40:27 -0000 1.42
+++ client/mapctrl_common.c 21 Nov 2004 05:36:13 -0000
@@ -144,7 +144,7 @@
/* Tile passed all tests; process it.
*/
if (ptile->city && ptile->city->owner == game.player_idx) {
- ptile->client.hilite = HILITE_CITY;
+ map_deco[ptile->index].hilite = HILITE_CITY;
tiles_hilited_cities = TRUE;
}
}
@@ -237,7 +237,7 @@
**************************************************************************/
bool is_city_hilited(struct city *pcity)
{
- return pcity->tile->client.hilite == HILITE_CITY;
+ return map_deco[pcity->tile->index].hilite == HILITE_CITY;
}
/**************************************************************************
@@ -249,7 +249,7 @@
tiles_hilited_cities = FALSE;
whole_map_iterate(ptile) {
- ptile->client.hilite = HILITE_NONE;
+ map_deco[ptile->index].hilite = HILITE_NONE;
} whole_map_iterate_end;
update_map_canvas_visible();
@@ -279,14 +279,14 @@
{
struct city *pcity = ptile->city;
- if (ptile->client.hilite == HILITE_CITY) {
- ptile->client.hilite = HILITE_NONE;
+ if (map_deco[ptile->index].hilite == HILITE_CITY) {
+ map_deco[ptile->index].hilite = HILITE_NONE;
if (pcity) {
toggle_city_hilite(pcity, FALSE); /* cityrep.c */
}
}
else if (pcity && pcity->owner == game.player_idx) {
- ptile->client.hilite = HILITE_CITY;
+ map_deco[ptile->index].hilite = HILITE_CITY;
tiles_hilited_cities = TRUE;
toggle_city_hilite(pcity, TRUE);
}
Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.160
diff -u -r1.160 mapview_common.c
--- client/mapview_common.c 15 Nov 2004 17:20:55 -0000 1.160
+++ client/mapview_common.c 21 Nov 2004 05:36:14 -0000
@@ -35,6 +35,7 @@
#include "mapview_common.h"
#include "tilespec.h"
+struct mapview_decoration *map_deco;
struct mapview_canvas mapview_canvas;
struct overview overview;
bool can_slide = TRUE;
@@ -1426,10 +1427,10 @@
* map grid if it is drawn. */
if (get_tile_boundaries(dir, inset, 1,
&start_x, &start_y, &end_x, &end_y)) {
- if (ptile->client.hilite == HILITE_CITY
+ if (map_deco[ptile->index].hilite == HILITE_CITY
|| (is_isometric
&& (adjc_tile = mapstep(ptile, dir))
- && adjc_tile->client.hilite == HILITE_CITY)) {
+ && map_deco[adjc_tile->index].hilite == HILITE_CITY)) {
canvas_put_line(pcanvas, COLOR_STD_YELLOW, LINE_NORMAL,
canvas_x + start_x, canvas_y + start_y,
end_x - start_x, end_y - start_y);
@@ -2016,7 +2017,7 @@
* causing it to be marked as C_TILE_UNAVAILABLE.
*/
- if (pcity->tile->client.hilite == HILITE_CITY) {
+ if (map_deco[pcity->tile->index].hilite == HILITE_CITY) {
/* rule c */
return pcity;
}
@@ -2481,6 +2482,18 @@
}
/**************************************************************************
+ Called when we receive map dimensions. It initialized the mapview
+ decorations.
+**************************************************************************/
+void init_mapview_decorations(void)
+{
+ map_deco = fc_realloc(map_deco, MAX_MAP_INDEX * sizeof(*map_deco));
+ whole_map_iterate(ptile) {
+ map_deco[ptile->index].hilite = HILITE_NONE;
+ } whole_map_iterate_end;
+}
+
+/**************************************************************************
Called if the map in the GUI is resized.
Returns TRUE iff the canvas was redrawn.
Index: client/mapview_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.h,v
retrieving revision 1.80
diff -u -r1.80 mapview_common.h
--- client/mapview_common.h 17 Oct 2004 15:47:48 -0000 1.80
+++ client/mapview_common.h 21 Nov 2004 05:36:14 -0000
@@ -25,6 +25,13 @@
struct canvas_store; /* opaque type, real type is gui-dep */
+struct mapview_decoration {
+ /* For client Area Selection */
+ enum tile_hilite {
+ HILITE_NONE = 0, HILITE_CITY
+ } hilite;
+};
+
struct mapview_canvas {
int gui_x0, gui_y0;
int width, height; /* Size in pixels. */
@@ -41,6 +48,7 @@
struct canvas *store;
};
+extern struct mapview_decoration *map_deco;
extern struct mapview_canvas mapview_canvas;
extern struct overview overview;
@@ -218,6 +226,7 @@
void overview_update_tile(struct tile *ptile);
void set_overview_dimensions(int width, int height);
+void init_mapview_decorations(void);
bool map_canvas_resized(int width, int height);
void init_mapcanvas_and_overview(void);
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.421
diff -u -r1.421 packhand.c
--- client/packhand.c 20 Nov 2004 17:27:43 -0000 1.421
+++ client/packhand.c 21 Nov 2004 05:36:15 -0000
@@ -1345,6 +1345,7 @@
map_allocate();
init_client_goto();
+ init_mapview_decorations();
generate_citydlg_dimensions();
Index: common/map.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.c,v
retrieving revision 1.203
diff -u -r1.203 map.c
--- common/map.c 13 Nov 2004 08:34:17 -0000 1.203
+++ common/map.c 21 Nov 2004 05:36:15 -0000
@@ -362,7 +362,6 @@
ptile->worked = NULL; /* pointer to city working tile */
ptile->assigned = 0; /* bitvector */
ptile->owner = NULL; /* Tile not claimed by any nation. */
- ptile->client.hilite = HILITE_NONE; /* Area Selection in client. */
ptile->spec_sprite = NULL;
}
Index: common/map.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.h,v
retrieving revision 1.225
diff -u -r1.225 map.h
--- common/map.h 13 Nov 2004 08:34:17 -0000 1.225
+++ common/map.h 21 Nov 2004 05:36:15 -0000
@@ -31,11 +31,6 @@
#define MOVE_COST_FOR_VALID_SEA_STEP (-3)
#define MOVE_COST_FOR_VALID_AIR_STEP (-3)
-/* For client Area Selection */
-enum tile_hilite {
- HILITE_NONE = 0, HILITE_CITY
-};
-
/* Convenience macro for accessing tile coordinates. This should only be
* used for debugging. */
#define TILE_XY(ptile) ((ptile) ? (ptile)->x : -1), \
@@ -57,10 +52,6 @@
Continent_id continent;
signed char move_cost[8]; /* don't know if this helps! */
struct player *owner; /* Player owning this tile, or NULL. */
- struct {
- /* Area Selection in client. */
- enum tile_hilite hilite;
- } client;
char *spec_sprite;
};
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#11124) move mapview decorations into the client,
Jason Short <=
|
|