diff -ru -X /home/jjm/cvs/no.freeciv FreecivCVS/client/civclient.c freeciv/client/civclient.c --- FreecivCVS/client/civclient.c Sun Apr 30 16:53:51 2000 +++ freeciv/client/civclient.c Tue May 30 10:35:26 2000 @@ -383,6 +383,7 @@ info.movesleft=punit->moves_left; info.activity=punit->activity; info.activity_target=punit->activity_target; + info.select_it=0; send_packet_unit_info(&aconnection, &info); } diff -ru -X /home/jjm/cvs/no.freeciv FreecivCVS/client/control.c freeciv/client/control.c --- FreecivCVS/client/control.c Sun May 28 00:46:42 2000 +++ freeciv/client/control.c Tue May 30 11:34:23 2000 @@ -88,7 +88,6 @@ punit->focus_status=FOCUS_AVAIL; refresh_tile_mapcanvas(punit->x, punit->y, 1); - put_cross_overlay_tile(punit->x, punit->y); } /* avoid the old focus unit disappearing: */ @@ -119,6 +118,17 @@ } /************************************************************************** +The only difference is that here we draw the "cross". +**************************************************************************/ +void set_unit_focus_and_select(struct unit *punit) +{ + set_unit_focus(punit); + if (punit) { + put_cross_overlay_tile(punit->x, punit->y); + } +} + +/************************************************************************** If there is no unit currently in focus, or if the current unit in focus should not be in focus, then get a new focus unit. We let GOTO-ing units stay in focus, so that if they have moves left @@ -579,6 +589,28 @@ send_unit_info(&req_unit); } +/************************************************************************** +... +**************************************************************************/ +void request_unit_selected(struct unit *punit) +{ + struct packet_unit_info info; + + info.id=punit->id; + info.owner=punit->owner; + info.x=punit->x; + info.y=punit->y; + info.homecity=punit->homecity; + info.veteran=punit->veteran; + info.type=punit->type; + info.movesleft=punit->moves_left; + info.activity=ACTIVITY_IDLE; + info.activity_target=0; + info.select_it=1; + + send_packet_unit_info(&aconnection, &info); +} + /**************************************************************** ... *****************************************************************/ @@ -934,12 +966,11 @@ struct unit *punit=unit_list_get(&ptile->units, 0); if(game.player_idx==punit->owner) { if(can_unit_do_activity(punit, ACTIVITY_IDLE)) { - /* struct unit *old_focus=get_unit_in_focus(); */ - request_new_unit_activity(punit, ACTIVITY_IDLE); - /* this is now done in set_unit_focus: --dwp */ - /* if(old_focus) - refresh_tile_mapcanvas(old_focus->x, old_focus->y, 1); */ - set_unit_focus(punit); + request_unit_selected(punit); + if (!(game.player_ptr->conn && + has_capability("select_unit", game.player_ptr->conn->capability))) { + set_unit_focus(punit); + } } } } diff -ru -X /home/jjm/cvs/no.freeciv FreecivCVS/client/control.h freeciv/client/control.h --- FreecivCVS/client/control.h Wed May 10 16:38:07 2000 +++ freeciv/client/control.h Tue May 30 11:16:48 2000 @@ -28,6 +28,7 @@ void request_new_unit_activity(struct unit *punit, enum unit_activity act); void request_new_unit_activity_targeted(struct unit *punit, enum unit_activity act, int tgt); +void request_unit_selected(struct unit *punit); void request_unit_pillage(struct unit *punit); void request_unit_sentry(struct unit *punit); void request_unit_fortify(struct unit *punit); @@ -55,6 +56,7 @@ struct unit *get_unit_in_focus(void); void set_unit_focus(struct unit *punit); void set_unit_focus_no_center(struct unit *punit); +void set_unit_focus_and_select(struct unit *punit); void update_unit_focus(void); struct unit *find_visible_unit(struct tile *ptile); void set_units_in_combat(struct unit *pattacker, struct unit *pdefender); diff -ru -X /home/jjm/cvs/no.freeciv FreecivCVS/client/packhand.c freeciv/client/packhand.c --- FreecivCVS/client/packhand.c Mon May 29 13:52:57 2000 +++ freeciv/client/packhand.c Tue May 30 11:15:53 2000 @@ -633,7 +633,11 @@ if(repaint_unit) refresh_tile_mapcanvas(punit->x, punit->y, 1); - update_unit_focus(); + if(packet->select_it) { + set_unit_focus_and_select(punit); + } else { + update_unit_focus(); + } } /************************************************************************** diff -ru -X /home/jjm/cvs/no.freeciv FreecivCVS/common/capstr.c freeciv/common/capstr.c --- FreecivCVS/common/capstr.c Sun May 28 00:46:43 2000 +++ freeciv/common/capstr.c Tue May 30 11:11:51 2000 @@ -72,7 +72,7 @@ #define CAPABILITY "+1.10 +fog_of_war +fortify_two_step +get_sabotage_list \ ocean_reclamation +dipl_cli_pop_dlg advance_focus_packet +30players \ -submarine_flags +gen_impr +dipl_states" +submarine_flags +gen_impr +dipl_states select_unit" /* "+1.10" is protocol for 1.10.0 stable release @@ -101,6 +101,9 @@ "dipl_states" is for servers and clients that understand diplomatic states: alliances, cease-fires, and what-have-you. + + "select_unit" is protocol extension for explicit handling of user + selection of units by clicking on the map. */ void init_our_capability(void) diff -ru -X /home/jjm/cvs/no.freeciv FreecivCVS/common/packets.c freeciv/common/packets.c --- FreecivCVS/common/packets.c Mon May 29 13:52:57 2000 +++ freeciv/common/packets.c Tue May 30 11:32:42 2000 @@ -1898,7 +1898,8 @@ cptr=put_uint8(buffer+2, PACKET_UNIT_INFO); cptr=put_uint16(cptr, req->id); cptr=put_uint8(cptr, req->owner); - pack=(req->carried ? 0x08 : 0) + pack=(req->select_it ? 0x04 : 0) + | (req->carried ? 0x08 : 0) | (req->veteran ? 0x10 : 0) | (req->ai ? 0x20 : 0) | (req->paradropped ? 0x40 : 0) @@ -2086,6 +2087,7 @@ packet->paradropped = (pack&0x40) ? 1 : 0; packet->connecting = (pack&0x80) ? 1 : 0; packet->carried = (pack&0x08) ? 1 : 0; + packet->select_it = (pack&0x04) ? 1 : 0; iget_uint8(&iter, &packet->x); iget_uint8(&iter, &packet->y); iget_uint16(&iter, &packet->homecity); diff -ru -X /home/jjm/cvs/no.freeciv FreecivCVS/common/packets.h freeciv/common/packets.h --- FreecivCVS/common/packets.h Mon May 29 13:52:57 2000 +++ freeciv/common/packets.h Tue May 30 10:22:52 2000 @@ -294,8 +294,8 @@ int paradropped; int connecting; int carried; + int select_it; }; - /********************************************************* diff -ru -X /home/jjm/cvs/no.freeciv FreecivCVS/server/unitfunc.c freeciv/server/unitfunc.c --- FreecivCVS/server/unitfunc.c Mon May 29 13:52:57 2000 +++ freeciv/server/unitfunc.c Tue May 30 11:02:31 2000 @@ -2670,7 +2670,7 @@ the other players can see either the target or destination tile. **************************************************************************/ void send_unit_info_to_onlookers(struct player *dest, struct unit *punit, - int x, int y, int carried) + int x, int y, int carried, int select_it) { int o; struct packet_unit_info info; @@ -2698,6 +2698,7 @@ info.paradropped=punit->paradropped; info.connecting=punit->connecting; info.carried = carried; + info.select_it = select_it; for(o=0; ox,punit->y, 0); + send_unit_info_to_onlookers(dest, punit, punit->x, punit->y, 0, 0); } /************************************************************************** @@ -3233,7 +3234,7 @@ pcargo->x = dest_x; pcargo->y = dest_y; unit_list_insert(&pdesttile->units, pcargo); - send_unit_info_to_onlookers(0, pcargo, src_x, src_y, 1); + send_unit_info_to_onlookers(0, pcargo, src_x, src_y, 1, 0); handle_unit_move_consequences(pcargo, src_x, src_y, dest_x, dest_y); } unit_list_iterate_end; unit_list_unlink_all(&cargo_units); @@ -3253,7 +3254,7 @@ !(pplayer->ai.control)) { set_unit_activity(punit, ACTIVITY_SENTRY); } - send_unit_info_to_onlookers(0, punit, src_x, src_y, 0); + send_unit_info_to_onlookers(0, punit, src_x, src_y, 0, 0); handle_unit_move_consequences(punit, src_x, src_y, dest_x, dest_y); diff -ru -X /home/jjm/cvs/no.freeciv FreecivCVS/server/unitfunc.h freeciv/server/unitfunc.h --- FreecivCVS/server/unitfunc.h Sun May 21 12:16:37 2000 +++ freeciv/server/unitfunc.h Tue May 30 10:52:41 2000 @@ -56,7 +56,7 @@ void kill_unit(struct unit *pkiller, struct unit *punit); void send_unit_info(struct player *dest, struct unit *punit); void send_unit_info_to_onlookers(struct player *dest, struct unit *punit, - int x, int y, int carried); + int x, int y, int carried, int select_it); void maybe_make_veteran(struct unit *punit); void unit_versus_unit(struct unit *attacker, struct unit *defender); int get_total_attack_power(struct unit *attacker, struct unit *defender); diff -ru -X /home/jjm/cvs/no.freeciv FreecivCVS/server/unithand.c freeciv/server/unithand.c --- FreecivCVS/server/unithand.c Sun May 28 00:46:55 2000 +++ freeciv/server/unithand.c Tue May 30 11:33:19 2000 @@ -454,13 +454,16 @@ } else if(punit->activity!=pinfo->activity || punit->activity_target!=pinfo->activity_target || + pinfo->select_it || punit->ai.control==1) { /* Treat change in ai.control as change in activity, so * idle autosettlers behave correctly when selected --dwp */ punit->ai.control=0; handle_unit_activity_request_targeted(punit, - pinfo->activity, pinfo->activity_target); + pinfo->activity, + pinfo->activity_target, + pinfo->select_it); } } } @@ -1320,13 +1323,13 @@ **************************************************************************/ void handle_unit_activity_request_targeted(struct unit *punit, enum unit_activity new_activity, - int new_target) + int new_target, int select_unit) { if(can_unit_do_activity_targeted(punit, new_activity, new_target)) { enum unit_activity old_activity = punit->activity; int old_target = punit->activity_target; set_unit_activity_targeted(punit, new_activity, new_target); - send_unit_info(0, punit); + send_unit_info_to_onlookers(0, punit, punit->x, punit->y, 0, select_unit); handle_unit_activity_dependencies(punit, old_activity, old_target); } } diff -ru -X /home/jjm/cvs/no.freeciv FreecivCVS/server/unithand.h freeciv/server/unithand.h --- FreecivCVS/server/unithand.h Tue May 2 07:52:54 2000 +++ freeciv/server/unithand.h Tue May 30 10:49:22 2000 @@ -51,9 +51,9 @@ struct packet_unit_request *req); void handle_unit_activity_request(struct unit *punit, enum unit_activity new_activity); -void handle_unit_activity_request_targeted(struct unit *punit, +void handle_unit_activity_request_targeted(struct unit *punit, enum unit_activity new_activity, - int new_target); + int new_target, int select_unit); void handle_unit_unload_request(struct player *pplayer, struct packet_unit_request *req); void handle_unit_nuke(struct player *pplayer,