Index: common/player.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/player.c,v retrieving revision 1.94 diff -u -r1.94 player.c --- common/player.c 2002/04/05 05:56:49 1.94 +++ common/player.c 2002/05/18 16:08:17 @@ -230,29 +230,31 @@ } /*************************************************************** -no map visibility check here! + Returns TRUE iff the player can see the unit. No map visibility + check here! Allied units and cities can be used for sub hunting. ***************************************************************/ bool player_can_see_unit(struct player *pplayer, struct unit *punit) { - if (pplayers_allied(unit_owner(punit), pplayer)) + if (pplayers_allied(unit_owner(punit), pplayer) + || !is_hiding_unit(punit)) { return TRUE; - if (is_hiding_unit(punit)) { - /* Search for units/cities that might be able to see the sub/missile */ - struct city *pcity; - square_iterate(punit->x, punit->y, 1, x, y) { - unit_list_iterate(map_get_tile(x, y)->units, punit2) { - if (pplayers_allied(unit_owner(punit2), pplayer)) - return TRUE; - } unit_list_iterate_end; + } - pcity = map_get_city(x, y); - if (pcity && (pplayers_allied(city_owner(pcity), pplayer))) + /* Search for units/cities that might be able to see the sub/missile */ + adjc_iterate(punit->x, punit->y, x1, y1) { + struct city *pcity = map_get_city(x1, y1); + unit_list_iterate(map_get_tile(x1, y1)->units, punit2) { + if (pplayers_allied(unit_owner(punit2), pplayer)) { return TRUE; - } square_iterate_end; - return FALSE; - } else { - return TRUE; - } + } + } unit_list_iterate_end; + + if (pcity && pplayers_allied(city_owner(pcity), pplayer)) { + return TRUE; + } + } adjc_iterate_end; + + return FALSE; } /*************************************************************** Index: common/unit.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/unit.c,v retrieving revision 1.158 diff -u -r1.158 unit.c --- common/unit.c 2002/04/05 05:25:38 1.158 +++ common/unit.c 2002/05/18 16:08:18 @@ -391,25 +391,16 @@ /************************************************************************** - Is the unit one that is invisible on the map, which is currently limited - to subs and missiles in subs. - FIXME: this should be made more general: does not handle cargo units - on an invisible transport, or planes on invisible carrier. + Is the unit one that is invisible on the map. A unit is invisible if + it has the F_PARTIAL_INVIS flag or if it transported by a unit with + this flag. **************************************************************************/ bool is_hiding_unit(struct unit *punit) { - if(unit_flag(punit, F_PARTIAL_INVIS)) return TRUE; - if(unit_flag(punit, F_MISSILE)) { - if(map_get_terrain(punit->x, punit->y)==T_OCEAN) { - unit_list_iterate(map_get_tile(punit->x, punit->y)->units, punit2) { - if(unit_flag(punit2, F_PARTIAL_INVIS) - && unit_flag(punit2, F_MISSILE_CARRIER)) { - return TRUE; - } - } unit_list_iterate_end; - } - } - return FALSE; + struct unit *transporter = find_unit_by_id(punit->transported_by); + + return (unit_flag(punit, F_PARTIAL_INVIS) + || unit_flag(transporter, F_PARTIAL_INVIS)); } /************************************************************************** Index: server/cityhand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/cityhand.c,v retrieving revision 1.112 diff -u -r1.112 cityhand.c --- server/cityhand.c 2002/02/27 11:46:20 1.112 +++ server/cityhand.c 2002/05/18 16:08:19 @@ -71,12 +71,12 @@ void handle_city_change_specialist(struct player *pplayer, struct packet_city_request *preq) { - struct city *pcity; - pcity=find_city_by_id(preq->city_id); - if(!pcity) - return; - if(!player_owns_city(pplayer, pcity)) + struct city *pcity = player_find_city_by_id(pplayer, preq->city_id); + + if (!pcity) { return; + } + if(preq->specialist_from==SP_ELVIS) { if(pcity->size<5) return; @@ -118,12 +118,11 @@ void handle_city_make_specialist(struct player *pplayer, struct packet_city_request *preq) { - struct city *pcity; + struct city *pcity = player_find_city_by_id(pplayer, preq->city_id); - pcity=find_city_by_id(preq->city_id); - if(!pcity) + if (!pcity) { return; - if (!player_owns_city(pplayer, pcity)) return; + } if (is_city_center(preq->worker_x, preq->worker_y)) { auto_arrange_workers(pcity); sync_cities(); @@ -146,7 +145,7 @@ void handle_city_make_worker(struct player *pplayer, struct packet_city_request *preq) { - struct city *pcity; + struct city *pcity = player_find_city_by_id(pplayer, preq->city_id); if (!is_valid_city_coords(preq->worker_x, preq->worker_y)) { freelog(LOG_ERROR, "invalid city coords %d,%d in package", @@ -154,9 +153,9 @@ return; } - pcity = player_find_city_by_id(pplayer, preq->city_id); - if (!pcity) + if (!pcity) { return; + } if (is_city_center(preq->worker_x, preq->worker_y)) { auto_arrange_workers(pcity); @@ -214,11 +213,11 @@ **************************************************************************/ void handle_city_sell(struct player *pplayer, struct packet_city_request *preq) { - struct city *pcity; - pcity=find_city_by_id(preq->city_id); - if (!pcity || !player_owns_city(pplayer, pcity) - || preq->build_id>=game.num_impr_types) + struct city *pcity = player_find_city_by_id(pplayer, preq->city_id); + + if (!pcity || preq->build_id >= game.num_impr_types) { return; + } really_handle_city_sell(pplayer, pcity, preq->build_id); } @@ -229,7 +228,8 @@ { char *name; int cost, total; - if (!pcity || !player_owns_city(pplayer, pcity)) return; + + assert(pcity && player_owns_city(pplayer, pcity)); if (pcity->did_buy > 0) { notify_player_ex(pplayer, pcity->x, pcity->y, E_NOEVENT, @@ -301,13 +301,11 @@ **************************************************************************/ void handle_city_worklist(struct player *pplayer, struct packet_city_request *preq) { - struct city *pcity; - pcity=find_city_by_id(preq->city_id); + struct city *pcity = player_find_city_by_id(pplayer, preq->city_id); - if (!pcity) - return; - if (!player_owns_city(pplayer, pcity)) + if (!pcity) { return; + } copy_worklist(&pcity->worklist, &preq->worklist); @@ -319,12 +317,11 @@ **************************************************************************/ void handle_city_buy(struct player *pplayer, struct packet_city_request *preq) { - struct city *pcity = find_city_by_id(preq->city_id); + struct city *pcity = player_find_city_by_id(pplayer, preq->city_id); - if (!pcity) - return; - if (!player_owns_city(pplayer, pcity)) + if (!pcity) { return; + } really_handle_city_buy(pplayer, pcity); } @@ -335,12 +332,11 @@ void handle_city_refresh(struct player *pplayer, struct packet_generic_integer *preq) { if (preq->value != 0) { - struct city *pcity = find_city_by_id(preq->value); + struct city *pcity = player_find_city_by_id(pplayer, preq->value); - if (!pcity) + if (!pcity) { return; - if (!player_owns_city(pplayer, pcity)) - return; + } city_refresh(pcity); send_city_info(pplayer, pcity); @@ -355,15 +351,12 @@ void handle_city_change(struct player *pplayer, struct packet_city_request *preq) { - struct city *pcity; - pcity=find_city_by_id(preq->city_id); + struct city *pcity = player_find_city_by_id(pplayer, preq->city_id); + if (!pcity) { - freelog(LOG_ERROR, "Pcity null in handle_city_change" - " (%s, id = %d)!", pplayer->name, preq->city_id); return; } - if(!player_owns_city(pplayer, pcity)) - return; + if (preq->is_build_id_unit_id && !can_build_unit(pcity, preq->build_id)) return; if (!preq->is_build_id_unit_id && !can_build_improvement(pcity, preq->build_id)) @@ -388,13 +381,11 @@ struct packet_city_request *preq) { char *cp; - struct city *pcity; - - pcity = find_city_by_id(preq->city_id); - if (!pcity) - return; - if (!player_owns_city(pplayer, pcity)) + struct city *pcity = player_find_city_by_id(pplayer, preq->city_id); + + if (!pcity) { return; + } if((cp=get_sane_name(preq->name))) { /* more sanity tests! any existing city with that name? */ @@ -412,8 +403,12 @@ void handle_city_options(struct player *pplayer, struct packet_generic_values *preq) { - struct city *pcity = find_city_by_id(preq->value1); - if (!pcity || pcity->owner != pplayer->player_no) return; + struct city *pcity = player_find_city_by_id(pplayer, preq->value1); + + if (!pcity) { + return; + } + pcity->city_options = preq->value2; /* We don't need to send the full city info, since no other properties * depend on the attack options. --dwp Index: server/unithand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/unithand.c,v retrieving revision 1.223 diff -u -r1.223 unithand.c --- server/unithand.c 2002/03/18 01:49:43 1.223 +++ server/unithand.c 2002/05/18 16:08:20 @@ -64,7 +64,7 @@ void handle_unit_goto_tile(struct player *pplayer, struct packet_unit_request *req) { - struct unit *punit; + struct unit *punit = player_find_unit_by_id(pplayer, req->unit_id); /* * Discard invalid packet. Replace this with is_normal_map_pos if @@ -74,22 +74,27 @@ return; } - if((punit=player_find_unit_by_id(pplayer, req->unit_id))) { - punit->goto_dest_x=req->x; - punit->goto_dest_y=req->y; + if(!punit) { + return; + } - set_unit_activity(punit, ACTIVITY_GOTO); + punit->goto_dest_x = req->x; + punit->goto_dest_y = req->y; - send_unit_info(NULL, punit); + set_unit_activity(punit, ACTIVITY_GOTO); - /* Normally units on goto does not pick up extra units, even if - the units are in a city and are sentried. But if we just started - the goto We want to take them with us, so we do this. */ - if (get_transporter_capacity(punit) > 0) - assign_units_to_transporter(punit, TRUE); + send_unit_info(NULL, punit); - do_unit_goto(punit, GOTO_MOVE_ANY, TRUE); + /* + * Normally units on goto does not pick up extra units, even if the + * units are in a city and are sentried. But if we just started the + * goto We want to take them with us, so we do this. + */ + if (get_transporter_capacity(punit) > 0) { + assign_units_to_transporter(punit, TRUE); } + + do_unit_goto(punit, GOTO_MOVE_ANY, TRUE); } /************************************************************************** @@ -98,7 +103,7 @@ void handle_unit_airlift(struct player *pplayer, struct packet_unit_request *req) { - struct unit *punit; + struct unit *punit = player_find_unit_by_id(pplayer, req->unit_id); struct city *pcity; /* @@ -109,7 +114,6 @@ return; } - punit = player_find_unit_by_id(pplayer, req->unit_id); pcity = map_get_city(req->x, req->y); if (punit && pcity) { do_airline(punit, pcity); @@ -124,7 +128,7 @@ void handle_unit_connect(struct player *pplayer, struct packet_unit_connect *req) { - struct unit *punit; + struct unit *punit = player_find_unit_by_id(pplayer, req->unit_id); /* * Discard invalid packet. Replace this with is_normal_map_pos if @@ -134,21 +138,25 @@ return; } - if((punit=player_find_unit_by_id(pplayer, req->unit_id))) { - if (can_unit_do_connect (punit, req->activity_type)) { - punit->goto_dest_x=req->dest_x; - punit->goto_dest_y=req->dest_y; - - set_unit_activity(punit, req->activity_type); - punit->connecting = TRUE; - - send_unit_info(NULL, punit); - - /* avoid wasting first turn if unit cannot do the activity - on the starting tile */ - if (! can_unit_do_activity(punit, req->activity_type)) - do_unit_goto(punit, get_activity_move_restriction(req->activity_type), FALSE); - } + if (!punit || !can_unit_do_connect(punit, req->activity_type)) { + return; + } + + punit->goto_dest_x = req->dest_x; + punit->goto_dest_y = req->dest_y; + + set_unit_activity(punit, req->activity_type); + punit->connecting = TRUE; + + send_unit_info(NULL, punit); + + /* + * Avoid wasting first turn if unit cannot do the activity on the + * starting tile. + */ + if (!can_unit_do_activity(punit, req->activity_type)) { + do_unit_goto(punit, get_activity_move_restriction(req->activity_type), + FALSE); } } @@ -162,7 +170,7 @@ int to_unit; int upgraded = 0; if ((to_unit =can_upgrade_unittype(pplayer, packet->type)) == -1) { - notify_player(pplayer, _("Game: Illegal package, can't upgrade %s (yet)."), + notify_player(pplayer, _("Game: Illegal packet, can't upgrade %s (yet)."), unit_types[packet->type].name); return; } @@ -193,7 +201,8 @@ } /************************************************************************** - Upgrade a single unit + Upgrade a single unit. + TODO: should upgrades in allied cities be possible? **************************************************************************/ void handle_unit_upgrade_request(struct player *pplayer, struct packet_unit_request *packet) @@ -201,11 +210,11 @@ int cost; int from_unit, to_unit; struct unit *punit = player_find_unit_by_id(pplayer, packet->unit_id); - struct city *pcity = find_city_by_id(packet->city_id); + struct city *pcity = player_find_city_by_id(pplayer, packet->city_id); - if (!punit) return; - if (!pcity) return; - if (pcity->owner != pplayer->player_no) return; /* Allied city! */ + if (!punit || !pcity) { + return; + } if(punit->x!=pcity->x || punit->y!=pcity->y) { notify_player(pplayer, _("Game: Illegal move, unit not in city!")); @@ -233,7 +242,7 @@ /*************************************************************** Tell the client the cost of inciting a revolt or bribing a unit. - Only send result back to the requesting connection, no all + Only send result back to the requesting connection, not all connections for that player. ***************************************************************/ void handle_incite_inq(struct connection *pconn, @@ -275,9 +284,9 @@ struct unit *pvictim=find_unit_by_id(packet->target_id); struct city *pcity=find_city_by_id(packet->target_id); - if (!pdiplomat) return; - if (!unit_flag(pdiplomat, F_DIPLOMAT)) + if (!pdiplomat || !unit_flag(pdiplomat, F_DIPLOMAT)) { return; + } if(pdiplomat->moves_left > 0) { switch(packet->action_type) { @@ -353,30 +362,28 @@ void handle_unit_change_homecity(struct player *pplayer, struct packet_unit_request *req) { - struct unit *punit; - - if ((punit=player_find_unit_by_id(pplayer, req->unit_id))) { - struct city *old_pcity = - player_find_city_by_id(pplayer, punit->homecity); - struct city *new_pcity = player_find_city_by_id(pplayer, req->city_id); - - if (new_pcity && new_pcity->owner == punit->owner) { - unit_list_insert(&new_pcity->units_supported, punit); - if (old_pcity) { - unit_list_unlink(&old_pcity->units_supported, punit); - } + struct unit *punit = player_find_unit_by_id(pplayer, req->unit_id); + struct city *old_pcity = player_find_city_by_id(pplayer, punit->homecity); + struct city *new_pcity = player_find_city_by_id(pplayer, req->city_id); - punit->homecity = req->city_id; - send_unit_info(pplayer, punit); + if(!punit || !new_pcity) { + return; + } - city_refresh(new_pcity); - send_city_info(pplayer, new_pcity); + unit_list_insert(&new_pcity->units_supported, punit); + if (old_pcity) { + unit_list_unlink(&old_pcity->units_supported, punit); + } - if (old_pcity) { - city_refresh(old_pcity); - send_city_info(pplayer, old_pcity); - } - } + punit->homecity = req->city_id; + send_unit_info(pplayer, punit); + + city_refresh(new_pcity); + send_city_info(pplayer, new_pcity); + + if (old_pcity) { + city_refresh(old_pcity); + send_city_info(pplayer, old_pcity); } } @@ -410,12 +417,14 @@ struct packet_unit_request *req, struct genlist_iterator *iter) { - struct unit *punit; - struct city *pcity; - if ((punit=player_find_unit_by_id(pplayer, req->unit_id))) { - pcity=map_get_city(punit->x, punit->y); - do_unit_disband_safe(pcity, punit, iter); + struct unit *punit = player_find_unit_by_id(pplayer, req->unit_id); + struct city *pcity = map_get_city(punit->x, punit->y); + + if (!punit) { + return; } + + do_unit_disband_safe(pcity, punit, iter); } /************************************************************************** @@ -560,12 +569,12 @@ void handle_unit_build_city(struct player *pplayer, struct packet_unit_request *req) { - struct unit *punit; + struct unit *punit = player_find_unit_by_id(pplayer, req->unit_id); enum add_build_city_result res; - punit = player_find_unit_by_id(pplayer, req->unit_id); - if (!punit) + if (!punit) { return; + } res = test_unit_add_or_build_city(punit); @@ -582,42 +591,40 @@ **************************************************************************/ void handle_unit_info(struct player *pplayer, struct packet_unit_info *pinfo) { - struct unit *punit; + struct unit *punit = player_find_unit_by_id(pplayer, pinfo->id); - punit=player_find_unit_by_id(pplayer, pinfo->id); + if (!punit) { + return; + } - if(punit) { - if (!same_pos(punit->x, punit->y, pinfo->x, pinfo->y)) { - /* - * Discard invalid packet. Replace this with is_normal_map_pos - * if capstr is set to "1.12.0". - */ - if (!normalize_map_pos(&pinfo->x, &pinfo->y)) { - return; - } - - if (is_tiles_adjacent(punit->x, punit->y, pinfo->x, pinfo->y)) { - punit->ai.control = FALSE; - handle_unit_move_request(punit, pinfo->x, pinfo->y, FALSE, FALSE); - } else { - /* This can happen due to lag, so don't complain too loudly */ - freelog(LOG_DEBUG, "tiles are not adjacent, unit pos %d,%d trying " - "to go to %d,%d!\n", punit->x, punit->y, pinfo->x, pinfo->y); - } + if (!same_pos(punit->x, punit->y, pinfo->x, pinfo->y)) { + /* + * Discard invalid packet. Replace this with is_normal_map_pos + * if capstr is set to "1.12.0". + */ + if (!normalize_map_pos(&pinfo->x, &pinfo->y)) { + return; } - else if(punit->activity!=pinfo->activity || - punit->activity_target!=pinfo->activity_target || - pinfo->select_it || - punit->ai.control) { - /* Treat change in ai.control as change in activity, so - * idle autosettlers behave correctly when selected --dwp - */ + + if (is_tiles_adjacent(punit->x, punit->y, pinfo->x, pinfo->y)) { punit->ai.control = FALSE; - handle_unit_activity_request_targeted(punit, - pinfo->activity, - pinfo->activity_target, - pinfo->select_it); - } + handle_unit_move_request(punit, pinfo->x, pinfo->y, FALSE, FALSE); + } else { + /* This can happen due to lag, so don't complain too loudly */ + freelog(LOG_DEBUG, "tiles are not adjacent, unit pos %d,%d trying " + "to go to %d,%d!\n", punit->x, punit->y, pinfo->x, pinfo->y); + } + } else if (punit->activity != pinfo->activity || + punit->activity_target != pinfo->activity_target || + pinfo->select_it || punit->ai.control) { + /* Treat change in ai.control as change in activity, so + * idle autosettlers behave correctly when selected --dwp + */ + punit->ai.control = FALSE; + handle_unit_activity_request_targeted(punit, + pinfo->activity, + pinfo->activity_target, + pinfo->select_it); } } @@ -626,7 +633,7 @@ **************************************************************************/ void handle_move_unit(struct player *pplayer, struct packet_move_unit *pmove) { - struct unit *punit; + struct unit *punit = player_find_unit_by_id(pplayer, pmove->unid); /* * Discard invalid packet. Replace this with is_normal_map_pos if @@ -636,10 +643,10 @@ return; } - punit=player_find_unit_by_id(pplayer, pmove->unid); - if (punit && is_tiles_adjacent(punit->x, punit->y, pmove->x, pmove->y)) { - handle_unit_move_request(punit, pmove->x, pmove->y, FALSE, FALSE); + if (!punit || !is_tiles_adjacent(punit->x, punit->y, pmove->x, pmove->y)) { + return; } + handle_unit_move_request(punit, pmove->x, pmove->y, FALSE, FALSE); } /************************************************************************** @@ -1139,16 +1146,13 @@ void handle_unit_help_build_wonder(struct player *pplayer, struct packet_unit_request *req) { - struct unit *punit; - struct city *pcity_dest; - - punit = player_find_unit_by_id(pplayer, req->unit_id); - if (!punit || !unit_flag(punit, F_HELP_WONDER)) - return; + struct unit *punit = player_find_unit_by_id(pplayer, req->unit_id); + struct city *pcity_dest = find_city_by_id(req->city_id); - pcity_dest = find_city_by_id(req->city_id); - if (!pcity_dest || !unit_can_help_build_wonder(punit, pcity_dest)) + if (!punit || !unit_flag(punit, F_HELP_WONDER) || !pcity_dest + || !unit_can_help_build_wonder(punit, pcity_dest)) { return; + } if (!is_tiles_adjacent(punit->x, punit->y, pcity_dest->x, pcity_dest->y) && !same_pos(punit->x, punit->y, pcity_dest->x, pcity_dest->y)) @@ -1182,18 +1186,18 @@ bool handle_unit_establish_trade(struct player *pplayer, struct packet_unit_request *req) { - struct unit *punit; - struct city *pcity_homecity, *pcity_dest; + struct unit *punit = player_find_unit_by_id(pplayer, req->unit_id); + struct city *pcity_homecity, *pcity_dest = find_city_by_id(req->city_id); int revenue; - punit = player_find_unit_by_id(pplayer, req->unit_id); - if (!punit || !unit_flag(punit, F_TRADE_ROUTE)) + if (!punit || !unit_flag(punit, F_TRADE_ROUTE) || !pcity_dest) { return FALSE; - - pcity_homecity=player_find_city_by_id(pplayer, punit->homecity); - pcity_dest=find_city_by_id(req->city_id); - if(!pcity_homecity || !pcity_dest) + } + + pcity_homecity = player_find_city_by_id(pplayer, punit->homecity); + if (!pcity_homecity) { return FALSE; + } if (!is_tiles_adjacent(punit->x, punit->y, pcity_dest->x, pcity_dest->y) && !same_pos(punit->x, punit->y, pcity_dest->x, pcity_dest->y)) @@ -1361,33 +1365,35 @@ { struct unit *punit = player_find_unit_by_id(pplayer, req->unit_id); - if (punit) { - unit_list_iterate(map_get_tile(punit->x, punit->y)->units, punit2) { - if (punit != punit2 && punit2->activity == ACTIVITY_SENTRY) { - bool wakeup = FALSE; - - if (is_ground_units_transport(punit)) { - if (is_ground_unit(punit2)) - wakeup = TRUE; - } - - if (unit_flag(punit, F_MISSILE_CARRIER)) { - if (unit_flag(punit2, F_MISSILE)) - wakeup = TRUE; - } - - if (unit_flag(punit, F_CARRIER)) { - if (is_air_unit(punit2)) - wakeup = TRUE; - } - - if (wakeup) { - set_unit_activity(punit2, ACTIVITY_IDLE); - send_unit_info(NULL, punit2); - } - } - } unit_list_iterate_end; + if (!punit) { + return; } + + unit_list_iterate(map_get_tile(punit->x, punit->y)->units, punit2) { + if (punit != punit2 && punit2->activity == ACTIVITY_SENTRY) { + bool wakeup = FALSE; + + if (is_ground_units_transport(punit)) { + if (is_ground_unit(punit2)) + wakeup = TRUE; + } + + if (unit_flag(punit, F_MISSILE_CARRIER)) { + if (unit_flag(punit2, F_MISSILE)) + wakeup = TRUE; + } + + if (unit_flag(punit, F_CARRIER)) { + if (is_air_unit(punit2)) + wakeup = TRUE; + } + + if (wakeup) { + set_unit_activity(punit2, ACTIVITY_IDLE); + send_unit_info(NULL, punit2); + } + } + } unit_list_iterate_end; } /************************************************************************** @@ -1396,10 +1402,12 @@ void handle_unit_nuke(struct player *pplayer, struct packet_unit_request *req) { - struct unit *punit; - - if((punit=player_find_unit_by_id(pplayer, req->unit_id))) - handle_unit_attack_request(punit, punit); + struct unit *punit = player_find_unit_by_id(pplayer, req->unit_id); + + if (!punit) { + return; + } + handle_unit_attack_request(punit, punit); } /************************************************************************** @@ -1410,13 +1418,8 @@ { struct unit *punit = player_find_unit_by_id(pplayer, req->unit_id); - if (!punit) + if (!punit) { return; - - if (unit_owner(punit) != pplayer) { - freelog(LOG_ERROR, "%s trying to paradrop a non-owner unit!\n", - pplayer->name); - return; } do_paradrop(punit, req->x, req->y); @@ -1431,8 +1434,9 @@ { struct unit *punit = player_find_unit_by_id(pplayer, packet->unit_id); - if (!punit || punit->owner != pplayer->player_no) + if (!punit) { return FALSE; + } if (packet->first_index != 0) { freelog(LOG_ERROR, "Bad route packet, first_index is %d!", Index: server/unittools.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v retrieving revision 1.176 diff -u -r1.176 unittools.c --- server/unittools.c 2002/05/12 16:54:24 1.176 +++ server/unittools.c 2002/05/18 16:08:22 @@ -2017,9 +2017,9 @@ conn_list_iterate(*dest, pconn) { struct player *pplayer = pconn->player; if (!pplayer && !pconn->observer) continue; - if (!pplayer - || map_get_known_and_seen(info.x, info.y, pplayer) - || map_get_known_and_seen(x, y, pplayer)) { + if (!pplayer || ((map_get_known_and_seen(info.x, info.y, pplayer) + || map_get_known_and_seen(x, y, pplayer)) + && player_can_see_unit(pplayer, punit))) { send_packet_unit_info(pconn, &info); } }