[Freeciv-Dev] (PR#3948) don't send NODRAW tiles
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
The server sends extra tiles to the client - every unknown tile that is
adjacent to a known tile will be sent. This helps the client, since it
traditionally needs to know the terrain type of an adjacent tile to
correctly draw a known tile.
For some time, we've (I think) all been agreement that this is bad. In
addition to the intentional cheating it allows, it gives everyone more
information than they should normally have. For instance you can easily
tell where the coastline goes, goto lines are affected in weird ways, etc.
So, as I was looking at the maphand code, I set out to change this.
First I removed the send_NODRAW_tiles function from maphand.c. To my
suprise, I found that this function was the only user of map_get_sent()!
The map.tiles->sent variable stores whether this tile has *ever* been
sent to the player, and is only checked to see if we need to send it
again as a NODRAW tile (this seems inefficient; we could just check
map_get_known instead). So I also removed this variable from map.tiles,
along with everything that updated it.
Once all the server code was removed, only a single line is needed for
the client. Additionally, a new manditory capability would be needed
for this change (otherwise the graphics become pathological at the
borders of the known map).
The result is quite good. In non-iso view tiles sometimes change as you
reveal new portions of the map - for instance a cactus may disappear
from the desert when you discover than an adjacent tile isn't actually
desert. But this is a small price to pay IMO.
jason
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.116
diff -u -r1.116 tilespec.c
--- client/tilespec.c 2003/04/04 16:14:50 1.116
+++ client/tilespec.c 2003/04/07 08:07:07
@@ -1338,7 +1338,8 @@
for (dir = 0; dir < 8; dir++) {
int x1, y1;
- if (MAPSTEP(x1, y1, map_x, map_y, dir)) {
+ if (MAPSTEP(x1, y1, map_x, map_y, dir)
+ && tile_get_known(x1, y1) != TILE_UNKNOWN) {
tspecial_near[dir] = map_get_special(x1, y1);
ttype_near[dir] = map_get_terrain(x1, y1);
@@ -1348,7 +1349,7 @@
ttype_near[dir] = T_GRASSLAND;
}
} else {
- /* We draw the edges of the map as if the same terrain just
+ /* We draw the edges of the (known) map as if the same terrain just
* continued off the edge of the map. */
tspecial_near[dir] = S_NO_SPECIAL;
ttype_near[dir] = *ttype;
Index: common/map.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.c,v
retrieving revision 1.137
diff -u -r1.137 map.c
--- common/map.c 2003/04/03 04:13:49 1.137
+++ common/map.c 2003/04/07 08:07:08
@@ -209,7 +209,6 @@
ptile->special = S_NO_SPECIAL;
ptile->known = 0;
ptile->continent = 0;
- ptile->sent = 0;
ptile->city = NULL;
unit_list_init(&ptile->units);
ptile->worked = NULL; /* pointer to city working tile */
Index: common/map.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.h,v
retrieving revision 1.143
diff -u -r1.143 map.h
--- common/map.h 2003/04/04 15:47:49 1.143
+++ common/map.h 2003/04/07 08:07:08
@@ -55,9 +55,6 @@
unsigned int known; /* A bitvector on the server side, an
enum known_type on the client side.
Player_no is index */
- unsigned int sent; /* Indicates if the client know the tile
- as TILE_KNOWN_NODRAW. A bitvector like known.
- Not used on the client side. */
int assigned; /* these can save a lot of CPU usage -- Syela */
struct city *worked; /* city working tile, or NULL if none */
unsigned short continent;
Index: server/maphand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/maphand.c,v
retrieving revision 1.120
diff -u -r1.120 maphand.c
--- server/maphand.c 2003/04/04 15:47:50 1.120
+++ server/maphand.c 2003/04/07 08:07:10
@@ -47,12 +47,6 @@
int x, int y);
static void send_tile_info_always(struct player *pplayer,
struct conn_list *dest, int x, int y);
-static void send_NODRAW_tiles(struct player *pplayer,
- struct conn_list *dest, int x, int y, int len);
-static bool map_get_sent(int x, int y, struct player *pplayer);
-static void map_set_sent(int x, int y, struct player *pplayer);
-static void map_clear_sent(int x, int y, struct player *pplayer);
-static void set_unknown_tiles_to_unsent(struct player *pplayer);
static void shared_vision_change_seen(int x, int y, struct player *pplayer,
int change);
static int map_get_seen(int x, int y, struct player *pplayer);
static void map_change_own_seen(int x, int y, struct player *pplayer,
@@ -293,12 +287,6 @@
int tiles_sent;
if (!dest) dest = &game.game_connections;
-
- conn_list_iterate(*dest, pconn) {
- if (pconn->player) {
- set_unknown_tiles_to_unsent(pconn->player);
- }
- } conn_list_iterate_end;
/* send whole map piece by piece to each player to balance the load
of the send buffers better */
@@ -323,7 +311,6 @@
if (!pplayer) {
send_tile_info_always(pplayer, &pconn->self, x, y);
} else if (map_get_known(x, y, pplayer)) {
- send_NODRAW_tiles(pplayer, &pconn->self, x, y, 0);
send_tile_info_always(pplayer, &pconn->self, x, y);
}
} conn_list_iterate_end;
@@ -489,7 +476,6 @@
bool old_known = map_get_known(x, y, pplayer);
freelog(LOG_DEBUG, "really unfogging %d,%d\n", x, y);
- send_NODRAW_tiles(pplayer, &pplayer->connections, x, y, 0);
map_set_known(x, y, pplayer);
@@ -554,24 +540,6 @@
}
/**************************************************************************
- Send KNOWN_NODRAW tiles as required by pplayer, to specified connections.
- We send only the unknown tiles around the square with length len.
- pplayer must not be NULL.
-**************************************************************************/
-static void send_NODRAW_tiles(struct player *pplayer, struct conn_list *dest,
- int x, int y, int len)
-{
- conn_list_do_buffer(dest);
- square_iterate(x, y, len+1, abs_x, abs_y) {
- if (!map_get_sent(abs_x, abs_y, pplayer)) {
- send_tile_info_always(pplayer, dest, abs_x, abs_y);
- map_set_sent(abs_x, abs_y, pplayer);
- }
- } square_iterate_end;
- conn_list_do_unbuffer(dest);
-}
-
-/**************************************************************************
...
**************************************************************************/
static void really_fog_area(struct player *pplayer, int x, int y)
@@ -731,7 +699,6 @@
freelog(LOG_DEBUG, "Showing %i,%i", x, y);
- send_NODRAW_tiles(pplayer, &pplayer->connections, x, y, 0);
if (!map_get_known_and_seen(x, y, pplayer)) {
map_set_known(x, y, pplayer);
@@ -897,40 +864,6 @@
}
/***************************************************************
-...
-***************************************************************/
-static void map_set_sent(int x, int y, struct player *pplayer)
-{
- map_get_tile(x, y)->sent |= (1u<<pplayer->player_no);
-}
-
-/***************************************************************
-...
-***************************************************************/
-static void map_clear_sent(int x, int y, struct player *pplayer)
-{
- map_get_tile(x, y)->sent &= ~(1u<<pplayer->player_no);
-}
-
-/***************************************************************
-...
-***************************************************************/
-static bool map_get_sent(int x, int y, struct player *pplayer)
-{
- return TEST_BIT(map_get_tile(x, y)->sent, pplayer->player_no);
-}
-
-/***************************************************************
-...
-***************************************************************/
-static void set_unknown_tiles_to_unsent(struct player *pplayer)
-{
- whole_map_iterate(x, y) {
- map_clear_sent(x, y, pplayer);
- } whole_map_iterate_end;
-}
-
-/***************************************************************
Allocate space for map, and initialise the tiles.
Uses current map.xsize and map.ysize.
****************************************************************/
@@ -1047,7 +980,6 @@
dest_tile->terrain = from_tile->terrain;
dest_tile->special = from_tile->special;
dest_tile->last_updated = from_tile->last_updated;
- send_NODRAW_tiles(pdest, &pdest->connections, x, y, 0);
send_tile_info_always(pdest, &pdest->connections, x, y);
/* update and send city knowledge */
Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.114
diff -u -r1.114 savegame.c
--- server/savegame.c 2003/02/17 22:49:28 1.114
+++ server/savegame.c 2003/04/07 08:07:11
@@ -392,12 +392,6 @@
map.have_specials = TRUE;
-
- /* Should be handled as part of send_all_know_tiles,
- but do it here too for safety */
- whole_map_iterate(x, y) {
- map_get_tile(x, y)->sent = 0;
- } whole_map_iterate_end;
}
/***************************************************************
|
|