Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2001:
[Freeciv-Dev] [PATCH] slight optimisation at client/packhand.c
Home

[Freeciv-Dev] [PATCH] slight optimisation at client/packhand.c

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] [PATCH] slight optimisation at client/packhand.c
From: Markus Linnala <maage@xxxxxxxxx>
Date: 15 Aug 2001 13:53:52 +0300
Reply-to: Markus Linnala <maage@xxxxxxxxx>

Slight optimisation and add some additional assertions. 

pcity->currently_building is used to access array somewhere
pcity->client code.

At later part, punit is accessed no matter what, so we should
check it.

Index: freeciv_more_players//client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.174
diff -u -r1.174 packhand.c
--- freeciv/client/packhand.c   2001/07/31 13:46:19     1.174
+++ freeciv/client/packhand.c   2001/08/15 10:49:59
@@ -340,6 +340,8 @@
 
   pcity->is_building_unit=packet->is_building_unit;
   pcity->currently_building=packet->currently_building;
+  assert(pcity->currently_building >= 0 && pcity->currently_building < U_LAST);
+
   if (city_is_new)
     pcity->worklist = create_worklist();
   copy_worklist(pcity->worklist, &packet->worklist);
@@ -701,6 +703,7 @@
 {
   struct city *pcity;
   struct unit *punit;
+  struct unit *aunit;
   int repaint_unit;
   int repaint_city;            /* regards unit's homecity */
 
@@ -910,12 +913,14 @@
     else
       repaint_unit=1;
   }
+
+  assert(punit);
 
-  if(punit && punit==get_unit_in_focus())
+  aunit = get_unit_in_focus();
+  if(punit && aunit && punit==aunit)
     update_unit_info_label(punit);
-  else if(get_unit_in_focus() && get_unit_in_focus()->x==punit->x &&
-         get_unit_in_focus()->y==punit->y) {
-    update_unit_info_label(get_unit_in_focus());
+  else if(aunit && aunit->x==punit->x && aunit->y==punit->y) {
+    update_unit_info_label(aunit);
   }
 
   if(repaint_unit)

-- 
//Markus


[Prev in Thread] Current Thread [Next in Thread]