[Freeciv-Dev] Re: (PR#2703) Fast focus v2
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Follow-up:
It was possible to remove further bits of code.
In the city dialogs, the "fast focus" behaviour was already
implemented (not requesting focus from server). Since the client
is now consistent, activate_unit() could be removed client-wide,
and calls to it replaced with set_unit_focus() direct.
This patch should have no consequence other than removing a few
redudant calls, saving a few cycles and lines of code.
Arnstein
diff -ruN -Xdiff_ignore Feb-09/client/gui-gtk/citydlg.c
killmore/client/gui-gtk/citydlg.c
--- Feb-09/client/gui-gtk/citydlg.c Wed Feb 5 05:58:28 2003
+++ killmore/client/gui-gtk/citydlg.c Mon Feb 10 15:26:51 2003
@@ -208,7 +208,6 @@
/****************************************/
static void initialize_city_dialogs(void);
-static void activate_unit(struct unit *punit);
static struct city_dialog *get_city_dialog(struct city *pcity);
static gint keyboard_handler(GtkWidget * widget, GdkEventKey * event,
@@ -523,17 +522,6 @@
}
}
-/****************************************************************
-...
-*****************************************************************/
-static void activate_unit(struct unit *punit)
-{
- if ((punit->activity != ACTIVITY_IDLE || punit->ai.control)
- && can_unit_do_activity(punit, ACTIVITY_IDLE))
- request_new_unit_activity(punit, ACTIVITY_IDLE);
- set_unit_focus(punit);
-}
-
/**************************************************************************
...
**************************************************************************/
@@ -2551,7 +2539,7 @@
(pcity = map_get_city(punit->x, punit->y)) &&
(pdialog = get_city_dialog(pcity)) && can_client_issue_orders() &&
(ev->button == 2 || ev->button == 3)) {
- activate_unit(punit);
+ set_unit_focus(punit);
if (ev->button == 2)
close_city_dialog(pdialog);
}
@@ -2574,7 +2562,7 @@
(pcity = find_city_by_id(punit->homecity)) &&
(pdialog = get_city_dialog(pcity)) && can_client_issue_orders() &&
(ev->button == 2 || ev->button == 3)) {
- activate_unit(punit);
+ set_unit_focus(punit);
if (ev->button == 2)
close_city_dialog(pdialog);
}
@@ -2590,7 +2578,7 @@
struct unit *punit;
if ((punit = player_find_unit_by_id(game.player_ptr, (size_t) data)))
- activate_unit(punit);
+ set_unit_focus(punit);
}
/****************************************************************
@@ -2603,7 +2591,7 @@
struct city_dialog *pdialog;
if ((punit = player_find_unit_by_id(game.player_ptr, (size_t) data))) {
- activate_unit(punit);
+ set_unit_focus(punit);
if ((pcity = player_find_city_by_id(game.player_ptr, punit->homecity)))
if ((pdialog = get_city_dialog(pcity)))
close_city_dialog(pdialog);
@@ -2620,7 +2608,7 @@
struct city_dialog *pdialog;
if ((punit = player_find_unit_by_id(game.player_ptr, (size_t) data))) {
- activate_unit(punit);
+ set_unit_focus(punit);
if ((pcity = map_get_city(punit->x, punit->y)))
if ((pdialog = get_city_dialog(pcity)))
close_city_dialog(pdialog);
diff -ruN -Xdiff_ignore Feb-09/client/gui-gtk/dialogs.c
killmore/client/gui-gtk/dialogs.c
--- Feb-09/client/gui-gtk/dialogs.c Sun Feb 2 05:58:32 2003
+++ killmore/client/gui-gtk/dialogs.c Tue Feb 11 16:41:31 2003
@@ -1647,7 +1647,6 @@
struct unit *punit = player_find_unit_by_id(game.player_ptr,
unit_select_ids[i]);
if(punit) {
- request_new_unit_activity(punit, ACTIVITY_IDLE);
set_unit_focus(punit);
}
}
@@ -1661,7 +1660,6 @@
struct unit *punit = player_find_unit_by_id(game.player_ptr, id);
if (punit) {
- request_new_unit_activity(punit, ACTIVITY_IDLE);
set_unit_focus(punit);
}
diff -ruN -Xdiff_ignore Feb-09/client/gui-gtk/gui_main.c
killmore/client/gui-gtk/gui_main.c
--- Feb-09/client/gui-gtk/gui_main.c Thu Feb 6 05:58:17 2003
+++ killmore/client/gui-gtk/gui_main.c Tue Feb 11 16:41:09 2003
@@ -1017,7 +1017,6 @@
punit = find_unit_by_id(unit_ids[i]);
if(punit) { /* should always be true at this point */
if (punit->owner == game.player_idx) { /* may be non-true if alliance */
- request_new_unit_activity(punit, ACTIVITY_IDLE);
set_unit_focus(punit);
}
}
diff -ruN -Xdiff_ignore Feb-09/client/gui-gtk-2.0/citydlg.c
killmore/client/gui-gtk-2.0/citydlg.c
--- Feb-09/client/gui-gtk-2.0/citydlg.c Wed Feb 5 05:58:30 2003
+++ killmore/client/gui-gtk-2.0/citydlg.c Mon Feb 10 15:26:51 2003
@@ -204,7 +204,6 @@
/****************************************/
static void initialize_city_dialogs(void);
-static void activate_unit(struct unit *punit);
static struct city_dialog *get_city_dialog(struct city *pcity);
static gint keyboard_handler(GtkWidget * widget, GdkEventKey * event,
@@ -509,17 +508,6 @@
}
}
-/****************************************************************
-...
-*****************************************************************/
-static void activate_unit(struct unit *punit)
-{
- if ((punit->activity != ACTIVITY_IDLE || punit->ai.control)
- && can_unit_do_activity(punit, ACTIVITY_IDLE))
- request_new_unit_activity(punit, ACTIVITY_IDLE);
- set_unit_focus(punit);
-}
-
/**************************************************************************
...
**************************************************************************/
@@ -2638,7 +2626,7 @@
(pcity = map_get_city(punit->x, punit->y)) &&
(pdialog = get_city_dialog(pcity)) && (ev->button == 2
|| ev->button == 3)) {
- activate_unit(punit);
+ set_unit_focus(punit);
if (ev->button == 2)
close_city_dialog(pdialog);
}
@@ -2661,7 +2649,7 @@
(pcity = find_city_by_id(punit->homecity)) &&
(pdialog = get_city_dialog(pcity)) && (ev->button == 2
|| ev->button == 3)) {
- activate_unit(punit);
+ set_unit_focus(punit);
if (ev->button == 2)
close_city_dialog(pdialog);
}
@@ -2677,7 +2665,7 @@
struct unit *punit;
if ((punit = player_find_unit_by_id(game.player_ptr, (size_t) data)))
- activate_unit(punit);
+ set_unit_focus(punit);
}
/****************************************************************
@@ -2691,7 +2679,7 @@
struct city_dialog *pdialog;
if ((punit = player_find_unit_by_id(game.player_ptr, (size_t) data))) {
- activate_unit(punit);
+ set_unit_focus(punit);
if ((pcity = player_find_city_by_id(game.player_ptr, punit->homecity)))
if ((pdialog = get_city_dialog(pcity)))
close_city_dialog(pdialog);
@@ -2709,7 +2697,7 @@
struct city_dialog *pdialog;
if ((punit = player_find_unit_by_id(game.player_ptr, (size_t) data))) {
- activate_unit(punit);
+ set_unit_focus(punit);
if ((pcity = map_get_city(punit->x, punit->y)))
if ((pdialog = get_city_dialog(pcity)))
close_city_dialog(pdialog);
diff -ruN -Xdiff_ignore Feb-09/client/gui-gtk-2.0/dialogs.c
killmore/client/gui-gtk-2.0/dialogs.c
--- Feb-09/client/gui-gtk-2.0/dialogs.c Wed Feb 5 05:58:30 2003
+++ killmore/client/gui-gtk-2.0/dialogs.c Tue Feb 11 16:38:52 2003
@@ -1568,7 +1568,6 @@
struct unit *punit = player_find_unit_by_id(game.player_ptr,
unit_select_ids[i]);
if(punit) {
- request_new_unit_activity(punit, ACTIVITY_IDLE);
set_unit_focus(punit);
}
}
@@ -1582,7 +1581,6 @@
struct unit *punit = player_find_unit_by_id(game.player_ptr, id);
if (punit) {
- request_new_unit_activity(punit, ACTIVITY_IDLE);
set_unit_focus(punit);
}
diff -ruN -Xdiff_ignore Feb-09/client/gui-gtk-2.0/gui_main.c
killmore/client/gui-gtk-2.0/gui_main.c
--- Feb-09/client/gui-gtk-2.0/gui_main.c Thu Feb 6 05:58:17 2003
+++ killmore/client/gui-gtk-2.0/gui_main.c Tue Feb 11 16:39:07 2003
@@ -1112,7 +1112,6 @@
punit = find_unit_by_id(unit_ids[i]);
if(punit) { /* should always be true at this point */
if (punit->owner == game.player_idx) { /* may be non-true if alliance */
- request_new_unit_activity(punit, ACTIVITY_IDLE);
set_unit_focus(punit);
}
}
diff -ruN -Xdiff_ignore Feb-09/client/gui-mui/dialogs.c
killmore/client/gui-mui/dialogs.c
--- Feb-09/client/gui-mui/dialogs.c Wed Feb 5 05:58:32 2003
+++ killmore/client/gui-mui/dialogs.c Tue Feb 11 16:39:46 2003
@@ -1453,7 +1453,6 @@
{
struct unit *punit=unit_list_get(&ptile->units, i);
if(punit) {
- request_new_unit_activity(punit, ACTIVITY_IDLE);
set_unit_focus(punit);
}
}
diff -ruN -Xdiff_ignore Feb-09/client/gui-sdl/citydlg.c
killmore/client/gui-sdl/citydlg.c
--- Feb-09/client/gui-sdl/citydlg.c Fri Jan 31 05:56:34 2003
+++ killmore/client/gui-sdl/citydlg.c Mon Feb 10 15:26:52 2003
@@ -181,19 +181,6 @@
/**************************************************************************
- ...
-**************************************************************************/
-static void activate_unit(struct unit *pUnit)
-{
- if ((pUnit->activity != ACTIVITY_IDLE || pUnit->ai.control)
- && can_unit_do_activity(pUnit, ACTIVITY_IDLE)) {
- request_new_unit_activity(pUnit, ACTIVITY_IDLE);
- }
-
- set_unit_focus(pUnit);
-}
-
-/**************************************************************************
Destroy City Dlg.
**************************************************************************/
static void del_city_dialog(void)
@@ -355,7 +342,7 @@
if ((pUnit =
player_find_unit_by_id(game.player_ptr, MAX_ID - pButton->ID))) {
- activate_unit(pUnit);
+ set_unit_focus(pUnit);
}
del_group_of_widgets_from_gui_list(pCityDlg->pBeginCityMenuWidgetList,
@@ -391,7 +378,7 @@
center_tile_mapcanvas(pUnit->x, pUnit->y);
- activate_unit(pUnit);
+ set_unit_focus(pUnit);
refresh_rects();
}
diff -ruN -Xdiff_ignore Feb-09/client/gui-win32/citydlg.c
killmore/client/gui-win32/citydlg.c
--- Feb-09/client/gui-win32/citydlg.c Wed Feb 5 05:58:37 2003
+++ killmore/client/gui-win32/citydlg.c Mon Feb 10 15:26:52 2003
@@ -945,19 +945,6 @@
**************************************************************************/
-static void activate_unit(struct unit *punit)
-{
- if((punit->activity!=ACTIVITY_IDLE || punit->ai.control)
- && can_unit_do_activity(punit, ACTIVITY_IDLE))
- request_new_unit_activity(punit, ACTIVITY_IDLE);
- set_unit_focus(punit);
-}
-
-/**************************************************************************
-...
-**************************************************************************/
-
-
static void buy_callback_yes(HWND w, void * data)
{
struct city_dialog *pdialog;
@@ -1408,7 +1395,7 @@
destroy_message_dialog(w);
if((punit=player_find_unit_by_id(game.player_ptr, (size_t)data))) {
- activate_unit(punit);
+ set_unit_focus(punit);
if((pcity=player_find_city_by_id(game.player_ptr, punit->homecity)))
if((pdialog=get_city_dialog(pcity)))
CityDlgClose(pdialog);
@@ -1482,7 +1469,7 @@
struct unit *punit;
if((punit=player_find_unit_by_id(game.player_ptr, (size_t)data)))
- activate_unit(punit);
+ set_unit_focus(punit);
destroy_message_dialog(w);
}
@@ -1498,7 +1485,7 @@
destroy_message_dialog(w);
if((punit=player_find_unit_by_id(game.player_ptr, (size_t)data))) {
- activate_unit(punit);
+ set_unit_focus(punit);
if((pcity=map_get_city(punit->x, punit->y)))
if((pdialog=get_city_dialog(pcity)))
CityDlgClose(pdialog);
diff -ruN -Xdiff_ignore Feb-09/client/gui-win32/dialogs.c
killmore/client/gui-win32/dialogs.c
--- Feb-09/client/gui-win32/dialogs.c Tue Jan 28 05:57:33 2003
+++ killmore/client/gui-win32/dialogs.c Tue Feb 11 16:40:17 2003
@@ -612,7 +612,6 @@
struct unit *punit = player_find_unit_by_id(game.player_ptr,
unit_select_ids[i]);
if(punit) {
- request_new_unit_activity(punit, ACTIVITY_IDLE);
set_unit_focus(punit);
}
}
@@ -624,7 +623,6 @@
struct unit *punit=player_find_unit_by_id(game.player_ptr,
unit_select_ids[id]);
if(punit && punit->owner == game.player_idx) {
- request_new_unit_activity(punit, ACTIVITY_IDLE);
set_unit_focus(punit);
}
}
diff -ruN -Xdiff_ignore Feb-09/client/gui-xaw/citydlg.c
killmore/client/gui-xaw/citydlg.c
--- Feb-09/client/gui-xaw/citydlg.c Wed Feb 5 05:58:38 2003
+++ killmore/client/gui-xaw/citydlg.c Mon Feb 10 15:26:52 2003
@@ -1132,18 +1132,6 @@
/****************************************************************
...
*****************************************************************/
-static void activate_unit(struct unit *punit)
-{
- if((punit->activity!=ACTIVITY_IDLE || punit->ai.control)
- && can_unit_do_activity(punit, ACTIVITY_IDLE))
- request_new_unit_activity(punit, ACTIVITY_IDLE);
- set_unit_focus(punit);
-}
-
-
-/****************************************************************
-...
-*****************************************************************/
static void present_units_activate_callback(Widget w, XtPointer client_data,
XtPointer call_data)
{
@@ -1152,7 +1140,7 @@
struct city_dialog *pdialog;
if((punit=player_find_unit_by_id(game.player_ptr, (size_t)client_data))) {
- activate_unit(punit);
+ set_unit_focus(punit);
if((pcity=map_get_city(punit->x, punit->y)))
if((pdialog=get_city_dialog(pcity)))
city_dialog_update_present_units(pdialog, 0);
@@ -1173,7 +1161,7 @@
struct city_dialog *pdialog;
if((punit=player_find_unit_by_id(game.player_ptr, (size_t)client_data))) {
- activate_unit(punit);
+ set_unit_focus(punit);
if((pcity=map_get_city(punit->x, punit->y)))
if((pdialog=get_city_dialog(pcity)))
city_dialog_update_supported_units(pdialog, 0);
@@ -1197,7 +1185,7 @@
destroy_message_dialog(w);
if((punit=player_find_unit_by_id(game.player_ptr, (size_t)client_data))) {
- activate_unit(punit);
+ set_unit_focus(punit);
if((pcity=map_get_city(punit->x, punit->y)))
if((pdialog=get_city_dialog(pcity)))
close_city_dialog(pdialog);
@@ -1218,7 +1206,7 @@
destroy_message_dialog(w);
if((punit=player_find_unit_by_id(game.player_ptr, (size_t)client_data))) {
- activate_unit(punit);
+ set_unit_focus(punit);
if((pcity=player_find_city_by_id(game.player_ptr, punit->homecity)))
if((pdialog=get_city_dialog(pcity)))
close_city_dialog(pdialog);
@@ -1313,12 +1301,12 @@
(pdialog=get_city_dialog(pcity))) {
if(e->type==ButtonRelease && e->xbutton.button==Button2) {
- activate_unit(punit);
+ set_unit_focus(punit);
close_city_dialog(pdialog);
return;
}
if(e->type==ButtonRelease && e->xbutton.button==Button3) {
- activate_unit(punit);
+ set_unit_focus(punit);
return;
}
@@ -1624,12 +1612,12 @@
if((pcity=find_city_by_id(punit->homecity)))
if((pdialog=get_city_dialog(pcity))) {
if(e->type==ButtonRelease && e->xbutton.button==Button2) {
- activate_unit(punit);
+ set_unit_focus(punit);
close_city_dialog(pdialog);
return;
}
if(e->type==ButtonRelease && e->xbutton.button==Button3) {
- activate_unit(punit);
+ set_unit_focus(punit);
return;
}
popup_message_dialog(pdialog->shell,
diff -ruN -Xdiff_ignore Feb-09/client/gui-xaw/dialogs.c
killmore/client/gui-xaw/dialogs.c
--- Feb-09/client/gui-xaw/dialogs.c Sun Feb 2 05:58:33 2003
+++ killmore/client/gui-xaw/dialogs.c Tue Feb 11 16:40:54 2003
@@ -1766,7 +1766,6 @@
struct unit *punit = player_find_unit_by_id(game.player_ptr,
unit_select_ids[i]);
if(punit) {
- request_new_unit_activity(punit, ACTIVITY_IDLE);
set_unit_focus(punit);
}
}
@@ -1789,7 +1788,6 @@
struct unit *punit = player_find_unit_by_id(game.player_ptr,
unit_select_ids[i]);
if(punit) {
- request_new_unit_activity(punit, ACTIVITY_IDLE);
set_unit_focus(punit);
}
return;
diff -ruN -Xdiff_ignore Feb-09/client/gui-xaw/gui_main.c
killmore/client/gui-xaw/gui_main.c
--- Feb-09/client/gui-xaw/gui_main.c Sun Feb 2 05:58:33 2003
+++ killmore/client/gui-xaw/gui_main.c Tue Feb 11 16:40:30 2003
@@ -483,7 +483,6 @@
punit=find_unit_by_id(unit_ids[i]);
if(punit) { /* should always be true at this point */
if (punit->owner == game.player_idx) { /* may be non-true if alliance */
- request_new_unit_activity(punit, ACTIVITY_IDLE);
set_unit_focus(punit);
}
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] Re: (PR#2703) Fast focus v2,
Arnstein Lindgard via RT <=
|
|