[Freeciv-Dev] (PR#6863) Remove calls to get_unit_in_focus() from control
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] (PR#6863) Remove calls to get_unit_in_focus() from control.c |
From: |
"Arnstein Lindgard" <a-l@xxxxxxx> |
Date: |
Fri, 14 Nov 2003 03:00:36 -0800 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=6863 >
Swap all calls to "get_unit_in_focus()" with "punit_focus" in
client/control.c. Maybe some ancient code that requested focus unit
from server.
Currently it has mess like:
if (get_unit_in_focus() && unit_flag(punit_focus, F_HELP_WONDER))
request_unit_caravan_action(punit_focus, PACKET_UNIT_HELP_BUILD_WONDER);
Arnstein
? autom4te-2.53.cache
Index: client/control.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/control.c,v
retrieving revision 1.116
diff -u -r1.116 control.c
--- client/control.c 2003/11/04 23:01:42 1.116
+++ client/control.c 2003/11/14 10:44:27
@@ -377,7 +377,7 @@
static struct unit *pblinking_unit;
struct unit *punit;
- if((punit=get_unit_in_focus())) {
+ if ((punit = punit_focus)) {
if (punit != pblinking_unit) {
/* When the focus unit changes, we reset the is_shown flag. */
pblinking_unit = punit;
@@ -594,7 +594,7 @@
**************************************************************************/
void request_unit_goto(void)
{
- struct unit *punit = get_unit_in_focus();
+ struct unit *punit = punit_focus;
if (!punit)
return;
@@ -621,11 +621,9 @@
**************************************************************************/
void request_unit_connect(void)
{
- struct unit *punit=get_unit_in_focus();
-
- if (punit && can_unit_do_connect (punit, ACTIVITY_IDLE)) {
- set_hover_state(punit, HOVER_CONNECT);
- update_unit_info_label(punit);
+ if (punit_focus && can_unit_do_connect (punit_focus, ACTIVITY_IDLE)) {
+ set_hover_state(punit_focus, HOVER_CONNECT);
+ update_unit_info_label(punit_focus);
}
}
@@ -928,7 +926,7 @@
**************************************************************************/
void request_unit_patrol(void)
{
- struct unit *punit = get_unit_in_focus();
+ struct unit *punit = punit_focus;
if (!punit)
return;
@@ -1219,10 +1217,9 @@
**************************************************************************/
void request_center_focus_unit(void)
{
- struct unit *punit;
-
- if((punit=get_unit_in_focus()))
- center_tile_mapcanvas(punit->x, punit->y);
+ if (punit_focus) {
+ center_tile_mapcanvas(punit_focus->x, punit_focus->y);
+ }
}
/**************************************************************************
@@ -1231,7 +1228,7 @@
void request_unit_wait(struct unit *punit)
{
punit->focus_status=FOCUS_WAIT;
- if(punit==get_unit_in_focus()) {
+ if (punit == punit_focus) {
advance_unit_focus();
/* set_unit_focus(punit_focus); */ /* done in advance_unit_focus */
}
@@ -1242,8 +1239,8 @@
**************************************************************************/
void request_unit_move_done(void)
{
- if(get_unit_in_focus()) {
- get_unit_in_focus()->focus_status=FOCUS_DONE;
+ if (punit_focus) {
+ punit_focus->focus_status = FOCUS_DONE;
advance_unit_focus();
/* set_unit_focus(punit_focus); */ /* done in advance_unit_focus */
}
@@ -1317,7 +1314,7 @@
refresh_tile_mapcanvas(punit->x, punit->y, FALSE);
}
- if(get_unit_in_focus()==punit) update_menus();
+ if (punit_focus == punit) update_menus();
}
/**************************************************************************
@@ -1529,9 +1526,9 @@
**************************************************************************/
void key_unit_move(enum direction8 gui_dir)
{
- if (get_unit_in_focus()) {
+ if (punit_focus) {
enum direction8 map_dir = gui_to_map_dir(gui_dir);
- request_move_unit_direction(get_unit_in_focus(), map_dir);
+ request_move_unit_direction(punit_focus, map_dir);
}
}
@@ -1540,8 +1537,9 @@
**************************************************************************/
void key_unit_build_city(void)
{
- if(get_unit_in_focus())
+ if (punit_focus) {
request_unit_build_city(punit_focus);
+ }
}
/**************************************************************************
@@ -1549,8 +1547,9 @@
**************************************************************************/
void key_unit_build_wonder(void)
{
- if (get_unit_in_focus() && unit_flag(punit_focus, F_HELP_WONDER))
+ if (punit_focus && unit_flag(punit_focus, F_HELP_WONDER)) {
request_unit_caravan_action(punit_focus, PACKET_UNIT_HELP_BUILD_WONDER);
+ }
}
/**************************************************************************
@@ -1558,8 +1557,9 @@
**************************************************************************/
void key_unit_connect(void)
{
- if(get_unit_in_focus())
+ if (punit_focus) {
request_unit_connect();
+ }
}
/**************************************************************************
@@ -1568,7 +1568,7 @@
void key_unit_diplomat_actions(void)
{
struct city *pcity; /* need pcity->id */
- if(get_unit_in_focus()
+ if (punit_focus
&& is_diplomat_unit(punit_focus)
&& (pcity = map_get_city(punit_focus->x, punit_focus->y))
&& !diplomat_dialog_is_open() /* confusing otherwise? */
@@ -1582,8 +1582,9 @@
**************************************************************************/
void key_unit_done(void)
{
- if(get_unit_in_focus())
+ if (punit_focus) {
request_unit_move_done();
+ }
}
/**************************************************************************
@@ -1591,8 +1592,9 @@
**************************************************************************/
void key_unit_goto(void)
{
- if(get_unit_in_focus())
+ if (punit_focus) {
request_unit_goto();
+ }
}
/**************************************************************************
@@ -1600,8 +1602,9 @@
**************************************************************************/
void key_unit_nuke(void)
{
- if(get_unit_in_focus())
+ if (punit_focus) {
request_unit_nuke(punit_focus);
+ }
}
/**************************************************************************
@@ -1609,9 +1612,9 @@
**************************************************************************/
void key_unit_paradrop(void)
{
- if(get_unit_in_focus())
- if(can_unit_paradrop(punit_focus))
- request_unit_paradrop(punit_focus);
+ if (punit_focus && can_unit_paradrop(punit_focus)) {
+ request_unit_paradrop(punit_focus);
+ }
}
/**************************************************************************
@@ -1619,8 +1622,9 @@
**************************************************************************/
void key_unit_patrol(void)
{
- if(get_unit_in_focus())
+ if (punit_focus) {
request_unit_patrol();
+ }
}
/**************************************************************************
@@ -1628,8 +1632,9 @@
**************************************************************************/
void key_unit_traderoute(void)
{
- if (get_unit_in_focus() && unit_flag(punit_focus, F_TRADE_ROUTE))
+ if (punit_focus && unit_flag(punit_focus, F_TRADE_ROUTE)) {
request_unit_caravan_action(punit_focus, PACKET_UNIT_ESTABLISH_TRADE);
+ }
}
/**************************************************************************
@@ -1637,8 +1642,9 @@
**************************************************************************/
void key_unit_unload(void)
{
- if(get_unit_in_focus())
+ if (punit_focus) {
request_unit_unload(punit_focus);
+ }
}
/**************************************************************************
@@ -1646,8 +1652,9 @@
**************************************************************************/
void key_unit_wait(void)
{
- if(get_unit_in_focus())
+ if (punit_focus) {
request_unit_wait(punit_focus);
+ }
}
/**************************************************************************
@@ -1655,8 +1662,9 @@
***************************************************************************/
void key_unit_wakeup_others(void)
{
- if(get_unit_in_focus())
+ if (punit_focus) {
request_unit_wakeup(punit_focus);
+ }
}
/**************************************************************************
@@ -1664,9 +1672,10 @@
**************************************************************************/
void key_unit_airbase(void)
{
- if(get_unit_in_focus())
- if(can_unit_do_activity(punit_focus, ACTIVITY_AIRBASE))
- request_new_unit_activity(punit_focus, ACTIVITY_AIRBASE);
+ if (punit_focus &&
+ can_unit_do_activity(punit_focus, ACTIVITY_AIRBASE)) {
+ request_new_unit_activity(punit_focus, ACTIVITY_AIRBASE);
+ }
}
/**************************************************************************
@@ -1674,10 +1683,10 @@
**************************************************************************/
void key_unit_auto_attack(void)
{
- if(get_unit_in_focus())
- if(!unit_flag(punit_focus, F_SETTLERS) &&
- can_unit_do_auto(punit_focus))
- request_unit_auto(punit_focus);
+ if (punit_focus && !unit_flag(punit_focus, F_SETTLERS) &&
+ can_unit_do_auto(punit_focus)) {
+ request_unit_auto(punit_focus);
+ }
}
/**************************************************************************
@@ -1685,9 +1694,10 @@
**************************************************************************/
void key_unit_auto_explore(void)
{
- if(get_unit_in_focus())
- if(can_unit_do_activity(punit_focus, ACTIVITY_EXPLORE))
- request_new_unit_activity(punit_focus, ACTIVITY_EXPLORE);
+ if (punit_focus &&
+ can_unit_do_activity(punit_focus, ACTIVITY_EXPLORE)) {
+ request_new_unit_activity(punit_focus, ACTIVITY_EXPLORE);
+ }
}
/**************************************************************************
@@ -1695,10 +1705,10 @@
**************************************************************************/
void key_unit_auto_settle(void)
{
- if(get_unit_in_focus())
- if(unit_flag(punit_focus, F_SETTLERS) &&
- can_unit_do_auto(punit_focus))
- request_unit_auto(punit_focus);
+ if (punit_focus && unit_flag(punit_focus, F_SETTLERS) &&
+ can_unit_do_auto(punit_focus)) {
+ request_unit_auto(punit_focus);
+ }
}
/**************************************************************************
@@ -1706,8 +1716,9 @@
**************************************************************************/
void key_unit_disband(void)
{
- if(get_unit_in_focus())
+ if (punit_focus) {
request_unit_disband(punit_focus);
+ }
}
/**************************************************************************
@@ -1715,9 +1726,10 @@
**************************************************************************/
void key_unit_fallout(void)
{
- if(get_unit_in_focus())
- if(can_unit_do_activity(punit_focus, ACTIVITY_FALLOUT))
- request_new_unit_activity(punit_focus, ACTIVITY_FALLOUT);
+ if (punit_focus &&
+ can_unit_do_activity(punit_focus, ACTIVITY_FALLOUT)) {
+ request_new_unit_activity(punit_focus, ACTIVITY_FALLOUT);
+ }
}
/**************************************************************************
@@ -1725,9 +1737,10 @@
**************************************************************************/
void key_unit_fortify(void)
{
- if(get_unit_in_focus())
- if(can_unit_do_activity(punit_focus, ACTIVITY_FORTIFYING))
- request_new_unit_activity(punit_focus, ACTIVITY_FORTIFYING);
+ if (punit_focus &&
+ can_unit_do_activity(punit_focus, ACTIVITY_FORTIFYING)) {
+ request_new_unit_activity(punit_focus, ACTIVITY_FORTIFYING);
+ }
}
/**************************************************************************
@@ -1735,9 +1748,10 @@
**************************************************************************/
void key_unit_fortress(void)
{
- if(get_unit_in_focus())
- if(can_unit_do_activity(punit_focus, ACTIVITY_FORTRESS))
- request_new_unit_activity(punit_focus, ACTIVITY_FORTRESS);
+ if (punit_focus &&
+ can_unit_do_activity(punit_focus, ACTIVITY_FORTRESS)) {
+ request_new_unit_activity(punit_focus, ACTIVITY_FORTRESS);
+ }
}
/**************************************************************************
@@ -1745,8 +1759,9 @@
**************************************************************************/
void key_unit_homecity(void)
{
- if(get_unit_in_focus())
+ if (punit_focus) {
request_unit_change_homecity(punit_focus);
+ }
}
/**************************************************************************
@@ -1754,9 +1769,10 @@
**************************************************************************/
void key_unit_irrigate(void)
{
- if(get_unit_in_focus())
- if(can_unit_do_activity(punit_focus, ACTIVITY_IRRIGATE))
- request_new_unit_activity(punit_focus, ACTIVITY_IRRIGATE);
+ if (punit_focus &&
+ can_unit_do_activity(punit_focus, ACTIVITY_IRRIGATE)) {
+ request_new_unit_activity(punit_focus, ACTIVITY_IRRIGATE);
+ }
}
/**************************************************************************
@@ -1764,9 +1780,10 @@
**************************************************************************/
void key_unit_mine(void)
{
- if(get_unit_in_focus())
- if(can_unit_do_activity(punit_focus, ACTIVITY_MINE))
- request_new_unit_activity(punit_focus, ACTIVITY_MINE);
+ if (punit_focus &&
+ can_unit_do_activity(punit_focus, ACTIVITY_MINE)) {
+ request_new_unit_activity(punit_focus, ACTIVITY_MINE);
+ }
}
/**************************************************************************
@@ -1774,9 +1791,10 @@
**************************************************************************/
void key_unit_pillage(void)
{
- if(get_unit_in_focus())
- if(can_unit_do_activity(punit_focus, ACTIVITY_PILLAGE))
- request_unit_pillage(punit_focus);
+ if (punit_focus &&
+ can_unit_do_activity(punit_focus, ACTIVITY_PILLAGE)) {
+ request_unit_pillage(punit_focus);
+ }
}
/**************************************************************************
@@ -1784,9 +1802,10 @@
**************************************************************************/
void key_unit_pollution(void)
{
- if(get_unit_in_focus())
- if(can_unit_do_activity(punit_focus, ACTIVITY_POLLUTION))
- request_new_unit_activity(punit_focus, ACTIVITY_POLLUTION);
+ if (punit_focus &&
+ can_unit_do_activity(punit_focus, ACTIVITY_POLLUTION)) {
+ request_new_unit_activity(punit_focus, ACTIVITY_POLLUTION);
+ }
}
/**************************************************************************
@@ -1794,7 +1813,7 @@
**************************************************************************/
void key_unit_road(void)
{
- if(get_unit_in_focus()) {
+ if (punit_focus) {
if(can_unit_do_activity(punit_focus, ACTIVITY_ROAD))
request_new_unit_activity(punit_focus, ACTIVITY_ROAD);
else if(can_unit_do_activity(punit_focus, ACTIVITY_RAILROAD))
@@ -1807,9 +1826,10 @@
**************************************************************************/
void key_unit_sentry(void)
{
- if(get_unit_in_focus())
- if(can_unit_do_activity(punit_focus, ACTIVITY_SENTRY))
- request_new_unit_activity(punit_focus, ACTIVITY_SENTRY);
+ if (punit_focus &&
+ can_unit_do_activity(punit_focus, ACTIVITY_SENTRY)) {
+ request_new_unit_activity(punit_focus, ACTIVITY_SENTRY);
+ }
}
/**************************************************************************
@@ -1817,9 +1837,10 @@
**************************************************************************/
void key_unit_transform(void)
{
- if(get_unit_in_focus())
- if(can_unit_do_activity(punit_focus, ACTIVITY_TRANSFORM))
- request_new_unit_activity(punit_focus, ACTIVITY_TRANSFORM);
+ if (punit_focus &&
+ can_unit_do_activity(punit_focus, ACTIVITY_TRANSFORM)) {
+ request_new_unit_activity(punit_focus, ACTIVITY_TRANSFORM);
+ }
}
/**************************************************************************
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#6863) Remove calls to get_unit_in_focus() from control.c,
Arnstein Lindgard <=
|
|