? civscore.log ? change_field1.diff ? data/misc/chiefs_front.spec ? data/misc/shields_front.spec Index: client/civclient.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/civclient.c,v retrieving revision 1.102 diff -u -r1.102 civclient.c --- client/civclient.c 2001/09/16 18:49:44 1.102 +++ client/civclient.c 2001/10/24 21:32:56 @@ -399,6 +399,10 @@ handle_processing_finished(); break; + case PACKET_START_TURN: + handle_start_turn(); + break; + default: freelog(LOG_ERROR, "Received unknown packet (type %d) from server!", type); /* Old clients (<= some 1.11.5-devel, capstr +1.11) used to exit() Index: common/map.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/map.c,v retrieving revision 1.97 diff -u -r1.97 map.c --- common/map.c 2001/10/15 13:42:50 1.97 +++ common/map.c 2001/10/24 21:32:57 @@ -1144,11 +1144,12 @@ ptile->terrain = T_UNKNOWN; ptile->special = S_NO_SPECIAL; ptile->known = 0; - ptile->sent = 0; ptile->city = NULL; unit_list_init(&ptile->units); ptile->worked = NULL; /* pointer to city working tile */ ptile->assigned = 0; /* bitvector */ + ptile->server.changed = -1; + ptile->server.sent = 0; } /*************************************************************** @@ -1181,7 +1182,10 @@ { assert(is_real_tile(x, y)); normalize_map_pos(&x, &y); - MAP_TILE(x, y)->continent = val; + if (MAP_TILE(x, y)->continent != val) { + MAP_TILE(x, y)->continent = val; + map_tile_set_changed(x, y, NULL, 0); + } } @@ -1214,19 +1218,30 @@ { assert(is_real_tile(x, y)); normalize_map_pos(&x, &y); - MAP_TILE(x, y)->terrain = ter; + if (MAP_TILE(x, y)->terrain != ter) { + MAP_TILE(x, y)->terrain = ter; + map_tile_set_changed(x, y, NULL, 1); + } } /*************************************************************** ... ***************************************************************/ -void map_set_special(int x, int y, enum tile_special_type spe) +void base_map_set_special(int x, int y, enum tile_special_type spe) { assert(is_real_tile(x, y)); normalize_map_pos(&x, &y); MAP_TILE(x, y)->special |= spe; +} +void map_set_special(int x, int y, enum tile_special_type spe) +{ + if (!(MAP_TILE(x, y)->special & spe)) { + map_tile_set_changed(x, y, NULL, 2); + } + base_map_set_special(x, y, spe); + if (spe & (S_ROAD | S_RAILROAD)) reset_move_costs(x, y); } @@ -1234,12 +1249,22 @@ /*************************************************************** ... ***************************************************************/ -void map_clear_special(int x, int y, enum tile_special_type spe) +void base_map_clear_special(int x, int y, enum tile_special_type spe) { assert(is_real_tile(x, y)); normalize_map_pos(&x, &y); - MAP_TILE(x, y)->special &= ~spe; + if (MAP_TILE(x, y)->special & spe) { + MAP_TILE(x, y)->special &= ~spe; + } +} + +void map_clear_special(int x, int y, enum tile_special_type spe) +{ + if (MAP_TILE(x, y)->special & spe) { + map_tile_set_changed(x, y, NULL, 3); + } + base_map_clear_special(x, y, spe); if (spe & (S_ROAD | S_RAILROAD)) reset_move_costs(x, y); } @@ -1431,4 +1456,37 @@ /* FIXME: this check will not work with an orthogonal map */ return (start_x == end_x) || (start_y == end_y); +} + +/*************************************************************** +... +***************************************************************/ +void map_tile_set_changed(int x, int y, struct player *pplayer, int n) +{ + if (pplayer) { + if(!pplayer->ai.control) + freelog(LOG_NORMAL, "map_tile_set_changed(x=%d, y=%d, player=%s n=%d)", + x, y, pplayer->name, n); + MAP_TILE(x, y)->server.changed |= (1u << pplayer->player_no); + } else { + freelog(LOG_NORMAL, "map_tile_set_changed(x=%d, y=%d, no player n=%d)", + x, y, n); + MAP_TILE(x, y)->server.changed = 0xffffffff; + } +} + +/*************************************************************** +... +***************************************************************/ +void map_tile_clear_changed(int x, int y, struct player *pplayer) +{ + MAP_TILE(x, y)->server.changed &= ~(1u << pplayer->player_no); +} + +/*************************************************************** +... +***************************************************************/ +int map_tile_get_changed(int x, int y, struct player *pplayer) +{ + return 1||(MAP_TILE(x, y)->server.changed & (1u << pplayer->player_no)); } Index: common/map.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/map.h,v retrieving revision 1.100 diff -u -r1.100 map.h --- common/map.h 2001/10/19 08:12:52 1.100 +++ common/map.h 2001/10/24 21:32:57 @@ -52,13 +52,17 @@ 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 */ signed short continent; signed char move_cost[8]; /* don't know if this helps! */ + struct { + unsigned int changed; + unsigned int sent; /* Indicates if the client know the + tile as TILE_KNOWN_NODRAW. A + bitvector like known. Not used on + the client side. */ + } server; }; @@ -269,7 +273,9 @@ enum tile_special_type map_get_special(int x, int y); void map_set_terrain(int x, int y, enum tile_terrain_type ter); void map_set_special(int x, int y, enum tile_special_type spe); +void base_map_set_special(int x, int y, enum tile_special_type spe); void map_clear_special(int x, int y, enum tile_special_type spe); +void base_map_clear_special(int x, int y, enum tile_special_type spe); void tile_init(struct tile *ptile); enum known_type tile_is_known(int x, int y); int is_real_tile(int x, int y); @@ -334,6 +340,10 @@ int can_channel_land(int x, int y); int can_reclaim_ocean(int x, int y); + +void map_tile_set_changed(int x, int y, struct player *pplayer, int n); +int map_tile_get_changed(int x, int y, struct player *pplayer); +void map_tile_clear_changed(int x, int y, struct player *pplayer); extern struct civ_map map; Index: common/packets.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/packets.c,v retrieving revision 1.166 diff -u -r1.166 packets.c --- common/packets.c 2001/10/18 16:45:32 1.166 +++ common/packets.c 2001/10/24 21:33:00 @@ -41,7 +41,7 @@ #include "packets.h" -#define PACKET_SIZE_STATISTICS 0 +#define PACKET_SIZE_STATISTICS 1 /********************************************************************** The current packet functions don't handle signed values Index: server/maphand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/maphand.c,v retrieving revision 1.87 diff -u -r1.87 maphand.c --- server/maphand.c 2001/10/11 12:37:06 1.87 +++ server/maphand.c 2001/10/24 21:33:01 @@ -326,6 +326,8 @@ struct packet_tile_info info; struct tile *ptile; + assert(dest == NULL); + if (dest==NULL) dest = &game.game_connections; ptile = map_get_tile(x, y); @@ -338,17 +340,25 @@ if (pplayer==NULL && !pconn->observer) { continue; } + if (!pconn->used) { + continue; + } + if (pplayer) { + if (!map_tile_get_changed(x, y, pplayer)) { + continue; + } + } if (pplayer == NULL || map_get_known_and_seen(x, y, pplayer)) { info.known = TILE_KNOWN; info.type = ptile->terrain; info.special = ptile->special; if (pplayer) { update_tile_knowledge(pplayer,x,y); + map_tile_clear_changed(x, y, pplayer); } send_packet_tile_info(pconn, &info); } - } - conn_list_iterate_end; + } conn_list_iterate_end; } /************************************************************************** @@ -365,33 +375,51 @@ struct packet_tile_info info; struct tile *ptile; struct player_tile *plrtile; + int send_packet = 1; ptile = map_get_tile(x, y); info.x = x; info.y = y; - if (pplayer==NULL) { /* observer sees all */ - info.known=TILE_KNOWN; + if (pplayer == NULL) { /* observer sees all */ + info.known = TILE_KNOWN; info.type = ptile->terrain; info.special = ptile->special; - } - else if (map_get_known(x, y, pplayer)) { - if (map_get_seen(x, y, pplayer)) { /* known and seen */ - update_tile_knowledge(pplayer,x,y); /* visible; update info */ - info.known = TILE_KNOWN; - } else { /* known but not seen */ - info.known = TILE_KNOWN_FOGGED; + } else { + if (!map_tile_get_changed(x, y, pplayer)) { + send_packet = 0; + } else { + if (map_get_known(x, y, pplayer)) { + if (map_get_seen(x, y, pplayer)) { /* known and seen */ + update_tile_knowledge(pplayer, x, y); /* visible; update info */ + info.known = TILE_KNOWN; + } else { /* known but not seen */ + info.known = TILE_KNOWN_FOGGED; + } + plrtile = map_get_player_tile(x, y, pplayer); + info.type = plrtile->terrain; + info.special = plrtile->special; + } else { /* unknown (the client needs these sometimes to draw correctly) */ + info.known = TILE_UNKNOWN; + info.type = ptile->terrain; + info.special = ptile->special; + } } - plrtile = map_get_player_tile(x, y, pplayer); - info.type = plrtile->terrain; - info.special = plrtile->special; - } else { /* unknown (the client needs these sometimes to draw correctly) */ - info.known = TILE_UNKNOWN; - info.type = ptile->terrain; - info.special = ptile->special; + } + if (send_packet) { + lsend_packet_tile_info(dest, &info); + conn_list_iterate(*dest, pconn) { + struct player *pplayer2 = pconn->player; + if (!pconn->used) { + continue; + } + + if (pplayer2/* && info.known == TILE_KNOWN*/) { + map_tile_clear_changed(x, y, pplayer2); + } + } conn_list_iterate_end; } - lsend_packet_tile_info(dest, &info); } /************************************************************************** @@ -795,9 +823,11 @@ void map_change_seen(int x, int y, struct player *pplayer, int change) { map_get_player_tile(x, y, pplayer)->seen += change; - freelog(LOG_DEBUG, "%d,%d, p: %d, change %d, result %d\n", x, y, - pplayer->player_no, change, map_get_player_tile(x, y, - pplayer)->seen); + freelog(LOG_DEBUG, + "map_change_seen(pos=(%d,%d), player='%s', change=%d) result=%d", + x, y, pplayer->name, change, map_get_player_tile(x, y, + pplayer)->seen); + map_tile_set_changed(x, y, pplayer, 10); } /*************************************************************** @@ -824,7 +854,10 @@ ***************************************************************/ void map_set_known(int x, int y, struct player *pplayer) { - map_get_tile(x, y)->known |= (1u<player_no); + if (!(map_get_tile(x, y)->known & (1u << pplayer->player_no))) { + map_get_tile(x, y)->known |= (1u << pplayer->player_no); + map_tile_set_changed(x, y, pplayer,11); + } } /*************************************************************** @@ -832,7 +865,10 @@ ***************************************************************/ void map_clear_known(int x, int y, struct player *pplayer) { - map_get_tile(x, y)->known &= ~(1u<player_no); + if (map_get_tile(x, y)->known & (1u << pplayer->player_no)) { + map_get_tile(x, y)->known &= ~(1u << pplayer->player_no); + map_tile_set_changed(x, y, pplayer,12); + } } /*************************************************************** @@ -870,7 +906,7 @@ ***************************************************************/ static void map_set_sent(int x, int y, struct player *pplayer) { - map_get_tile(x, y)->sent |= (1u<player_no); + map_get_tile(x, y)->server.sent |= (1u<player_no); } /*************************************************************** @@ -878,7 +914,7 @@ ***************************************************************/ static void map_clear_sent(int x, int y, struct player *pplayer) { - map_get_tile(x, y)->sent &= ~(1u<player_no); + map_get_tile(x, y)->server.sent &= ~(1u<player_no); } /*************************************************************** @@ -886,7 +922,7 @@ ***************************************************************/ static int map_get_sent(int x, int y, struct player *pplayer) { - return map_get_tile(x, y)->sent & (1u<player_no); + return map_get_tile(x, y)->server.sent & (1u<player_no); } /*************************************************************** Index: server/savegame.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v retrieving revision 1.36 diff -u -r1.36 savegame.c --- server/savegame.c 2001/10/17 13:16:45 1.36 +++ server/savegame.c 2001/10/24 21:33:04 @@ -313,7 +313,8 @@ /* get the terrain type */ LOAD_MAP_DATA(secfile_lookup_str(file, "map.t%03d", y), - map_get_tile(x, y)->terrain = char2terrain(ch)); + (map_get_tile(x, y)->terrain = + char2terrain(ch), map_tile_set_changed(x, y, NULL, 20))); assign_continent_numbers(); } @@ -400,7 +401,7 @@ /* 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; + map_get_tile(x, y)->server.sent = 0; } whole_map_iterate_end; } Index: server/settlers.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/settlers.c,v retrieving revision 1.112 diff -u -r1.112 settlers.c --- server/settlers.c 2001/10/14 21:02:17 1.112 +++ server/settlers.c 2001/10/24 21:33:05 @@ -440,9 +440,9 @@ if (!city_map_to_map(&x, &y, pcity, i, j)) return -1; if (!(map_get_special(x, y) & S_POLLUTION)) return(-1); - map_clear_special(x, y, S_POLLUTION); + base_map_clear_special(x, y, S_POLLUTION); m = city_tile_value(pcity, i, j, 0, 0); - map_set_special(x, y, S_POLLUTION); + base_map_set_special(x, y, S_POLLUTION); m = (m + best + 50) * 2; return(m); } @@ -458,9 +458,9 @@ if (!city_map_to_map(&x, &y, pcity, i, j)) return -1; if (!(map_get_special(x, y) & S_FALLOUT)) return(-1); - map_clear_special(x, y, S_FALLOUT); + base_map_clear_special(x, y, S_FALLOUT); m = city_tile_value(pcity, i, j, 0, 0); - map_set_special(x, y, S_FALLOUT); + base_map_set_special(x, y, S_FALLOUT); if (!pplayer->ai.control) m = (m + best + 50) * 2; return(m); @@ -524,7 +524,7 @@ if (ptile->city && type->irrigation_result == T_OCEAN) return -1; ptile->terrain = type->irrigation_result; - map_clear_special(x, y, S_MINE); + base_map_clear_special(x, y, S_MINE); m = city_tile_value(pcity, i, j, 0, 0); ptile->terrain = t; ptile->special = s; @@ -533,18 +533,18 @@ !(ptile->special&S_IRRIGATION) && !(ptile->special&S_MINE) && !(ptile->city) && (is_wet_or_is_wet_cardinal_around(pplayer, x, y)))) { - map_set_special(x, y, S_IRRIGATION); + base_map_set_special(x, y, S_IRRIGATION); m = city_tile_value(pcity, i, j, 0, 0); - map_clear_special(x, y, S_IRRIGATION); + base_map_clear_special(x, y, S_IRRIGATION); return(m); } else if((ptile->terrain==type->irrigation_result && (ptile->special&S_IRRIGATION) && !(ptile->special&S_FARMLAND) && player_knows_techs_with_flag(pplayer, TF_FARMLAND) && !(ptile->special&S_MINE) && !(ptile->city) && (is_wet_or_is_wet_cardinal_around(pplayer, x, y)))) { - map_set_special(x, y, S_FARMLAND); + base_map_set_special(x, y, S_FARMLAND); m = city_tile_value(pcity, i, j, 0, 0); - map_clear_special(x, y, S_FARMLAND); + base_map_clear_special(x, y, S_FARMLAND); return(m); } else return(-1); } @@ -581,9 +581,9 @@ /* Note that this code means we will never try to mine a city into the ocean */ if ((ptile->terrain == T_HILLS || ptile->terrain == T_MOUNTAINS) && !(ptile->special&S_IRRIGATION) && !(ptile->special&S_MINE)) { - map_set_special(x, y, S_MINE); + base_map_set_special(x, y, S_MINE); m = city_tile_value(pcity, i, j, 0, 0); - map_clear_special(x, y, S_MINE); + base_map_clear_special(x, y, S_MINE); return(m); } else return(-1); } @@ -622,11 +622,11 @@ ptile->terrain = r; if (get_tile_type(r)->mining_result != r) - map_clear_special(x, y, S_MINE); + base_map_clear_special(x, y, S_MINE); if (get_tile_type(r)->irrigation_result != r) { - map_clear_special(x, y, S_FARMLAND); - map_clear_special(x, y, S_IRRIGATION); + base_map_clear_special(x, y, S_FARMLAND); + base_map_clear_special(x, y, S_IRRIGATION); } m = city_tile_value(pcity, i, j, 0, 0);