Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2000:
[Freeciv-Dev] PATCH: client optimizations
Home

[Freeciv-Dev] PATCH: client optimizations

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] PATCH: client optimizations
From: Dirk Stoecker <stoecker@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 12 Oct 2000 19:22:49 +0200 (MET DST)

Hi,

here some optimizations to client directory. This patch removes
all the warnings I get. Now only server and common directory are
missing (148 warnings remaining).

civclient.c 94: dead assignment eliminated "option"
helpdata.c 849: dead assignment eliminated "any"

- removed assigments
- made "i = 1; while(i < argc) { ... ++i}" into for() loop

clinet.c 375 Warning 304: dead assignment eliminated "p"

- changed GET_FIELD to add the zero byte before data and moved the
  lonely zero-byte add behind GET_FIELD block. Gives same result
  without warning.

clinet.c 367: old-fashioned assignment operator
control.c 591: old-fashioned assignment operator
control.c 604: old-fashioned assignment operator
control.c 839: old-fashioned assignment operator
control.c 854: old-fashioned assignment operator
control.c 1059: old-fashioned assignment operator
packhand.c 934: old-fashioned assignment operator
packhand.c 995: old-fashioned assignment operator
packhand.c 1333: old-fashioned assignment operator

- added space characters

tilespec.c 896: dead assignment eliminated "road_semi_count"
tilespec.c 896: dead assignment eliminated "road_card_count"
tilespec.c 896: dead assignment eliminated "rail_semi_count"
tilespec.c 896: dead assignment eliminated "rail_card_count"

- removed assignments

Ciao
 ____  _ _  ____  _ _    _ _  ____
|    |  |  |    |  | \  / |  |    | the cool Gremlin from Bischofswerda
|  __   |   ____|  |  \/  |  |    | WWW: http://home.pages.de/~stoecker/
|    |  |  |       |      |  |    | PGP key available on www page.
|____| _|_ |____| _|_    _|_ |____| I hope AMIGA never ends to make fun!

************************************************************************
* snail-mail: Dirk Stoecker              * e-mail:                     *
*             Geschwister-Scholl-Str. 10 * stoecker@xxxxxxxxxxxxxx     *
*             01877 Bischofswerda        * phone:                      *
*             GERMANY                    * GERMANY +49 (0)3594/706666  *
************************************************************************
diff -ur ../../freeciv-cvs/freeciv/client/civclient.c ./client/civclient.c
--- ../../freeciv-cvs/freeciv/client/civclient.c        Tue Oct  3 18:27:48 2000
+++ ./client/civclient.c        Tue Oct  3 18:09:08 2000
@@ -91,7 +91,7 @@
   int i;
   int loglevel;
   char *logfile=NULL;
-  char *option=NULL;
+  char *option;
 
   init_nls();
   dont_run_as_root(argv[0], "freeciv_client");
@@ -103,9 +103,7 @@
   sz_strlcpy(metaserver, METALIST_ADDR);
   name[0] = '\0';
 
-  i = 1;
-
-  while (i < argc) {
+  for(i = 1; i < argc; ++i) {
    if (is_option("--help", argv[i])) {
     fprintf(stderr, _("Usage: %s [option ...]\nValid options are:\n"), 
argv[0]);
     fprintf(stderr, _("  -h, --help\t\tPrint a summary of the options\n"));
@@ -149,8 +147,7 @@
       fprintf(stderr, _("Unrecognized option: \"%s\"\n"), argv[i]);
       exit(1);
    }
-   i++;
-  } /* of while */
+  } /* of for */
 
   log_init(logfile, loglevel, NULL);
 
diff -ur ../../freeciv-cvs/freeciv/client/clinet.c ./client/clinet.c
--- ../../freeciv-cvs/freeciv/client/clinet.c   Tue Oct  3 18:28:06 2000
+++ ./client/clinet.c   Tue Oct  3 18:25:18 2000
@@ -349,8 +349,8 @@
   }
 #endif
 
-#define NEXT_FIELD p=strstr(p,"<TD>"); if(p==NULL) continue; p+=4;
-#define END_FIELD  p=strstr(p,"</TD>"); if(p==NULL) continue; *p++='\0';
+#define NEXT_FIELD *p++='\0'; p=strstr(p,"<TD>"); if(p==NULL) continue; p+=4;
+#define END_FIELD  p=strstr(p,"</TD>"); if(p==NULL) continue;
 #define GET_FIELD(x) NEXT_FIELD (x)=p; END_FIELD
 
   server_list = fc_malloc(sizeof(struct server_list));
@@ -364,15 +364,15 @@
 
       p=strstr(str,"<a"); if(p==NULL) continue;
       p=strchr(p,'>');    if(p==NULL) continue;
-      name=++p;
+      name = ++p;
       p=strstr(p,"</a>"); if(p==NULL) continue;
-      *p++='\0';
 
       GET_FIELD(port);
       GET_FIELD(version);
       GET_FIELD(status);
       GET_FIELD(players);
       GET_FIELD(metastring);
+      *p = '\0'; /* the last zero byte */
 
       pserver->name = mystrdup(name);
       pserver->port = mystrdup(port);
diff -ur ../../freeciv-cvs/freeciv/client/control.c ./client/control.c
--- ../../freeciv-cvs/freeciv/client/control.c  Tue Oct  3 18:27:49 2000
+++ ./client/control.c  Tue Oct  3 18:16:45 2000
@@ -588,7 +588,7 @@
 void request_new_unit_activity(struct unit *punit, enum unit_activity act)
 {
   struct unit req_unit;
-  req_unit=*punit;
+  req_unit = *punit;
   req_unit.activity=act;
   req_unit.activity_target=0;
   send_unit_info(&req_unit);
@@ -601,7 +601,7 @@
                                        int tgt)
 {
   struct unit req_unit;
-  req_unit=*punit;
+  req_unit = *punit;
   req_unit.activity=act;
   req_unit.activity_target=tgt;
   send_unit_info(&req_unit);
@@ -836,8 +836,8 @@
   was_teleported=!is_tiles_adjacent(punit->x, punit->y, pinfo->x, pinfo->y);
   x=punit->x;
   y=punit->y;
-  punit->x=-1;  /* focus hack - if we're moving the unit in focus, it wont
-                * be redrawn on top of the city */
+  punit->x = -1;  /* focus hack - if we're moving the unit in focus, it wont
+                  * be redrawn on top of the city */
 
   unit_list_unlink(&map_get_tile(x, y)->units, punit);
 
@@ -851,8 +851,8 @@
 
   if(!pinfo->carried && !was_teleported) {
     int dx=pinfo->x - x;
-    if(dx>1) dx=-1;
-    else if(dx<-1)
+    if(dx>1) dx = -1;
+    else if(dx < -1)
       dx=1;
     if(smooth_move_units)
       move_unit_map_canvas(punit, x, y, dx, pinfo->y - punit->y);
@@ -1056,7 +1056,7 @@
     prev_unit_type = U_LAST;
     prev_activity = ACTIVITY_UNKNOWN;
     prev_hp = -1;
-    for(i=-1; i<num_units_below; i++) {
+    for(i = -1; i < num_units_below; i++) {
       set_unit_icon(i, NULL);
     }
     set_unit_icons_more_arrow(0);
diff -ur ../../freeciv-cvs/freeciv/client/helpdata.c ./client/helpdata.c
--- ../../freeciv-cvs/freeciv/client/helpdata.c Tue Oct  3 18:27:49 2000
+++ ./client/helpdata.c Tue Oct  3 18:30:31 2000
@@ -846,7 +846,8 @@
     }
     if (utype->gold_cost) {
       sprintf(buf+strlen(buf), _("%s%d gold"),
-             (any++ ? ", " : ""), utype->gold_cost);
+             (any/*++*/ ? ", " : ""), utype->gold_cost);
+      /* remove comment around pre-increment when adding new if clause */
     }
   } else {
     /* strcpy(buf, _("None")); */
diff -ur ../../freeciv-cvs/freeciv/client/packhand.c ./client/packhand.c
--- ../../freeciv-cvs/freeciv/client/packhand.c Tue Oct  3 18:28:06 2000
+++ ./client/packhand.c Tue Oct  3 18:18:54 2000
@@ -930,8 +930,8 @@
   game.nuclearwinter=pinfo->nuclearwinter;
   game.cooling=pinfo->cooling;
   if(get_client_state()!=CLIENT_GAME_RUNNING_STATE) {
-    game.player_idx=pinfo->player_idx;
-    game.player_ptr=&game.players[game.player_idx];
+    game.player_idx = pinfo->player_idx;
+    game.player_ptr = &game.players[game.player_idx];
   }
   for(i=0; i<A_LAST/*game.num_tech_types*/; i++)
     game.global_advances[i]=pinfo->global_advances[i];
@@ -992,7 +992,7 @@
   int i;
   int poptechup;
   char msg[MAX_LEN_MSG];
-  struct player *pplayer=&game.players[pinfo->playerno];
+  struct player *pplayer = &game.players[pinfo->playerno];
 
   sz_strlcpy(pplayer->name, pinfo->name);
   pplayer->nation=pinfo->nation;
@@ -1330,7 +1330,7 @@
 void handle_spaceship_info(struct packet_spaceship_info *p)
 {
   int i;
-  struct player *pplayer=&game.players[p->player_num];
+  struct player *pplayer = &game.players[p->player_num];
   struct player_spaceship *ship = &pplayer->spaceship;
   
   ship->state        = p->sship_state;
diff -ur ../../freeciv-cvs/freeciv/client/tilespec.c ./client/tilespec.c
--- ../../freeciv-cvs/freeciv/client/tilespec.c Tue Oct  3 18:27:53 2000
+++ ./client/tilespec.c Tue Oct  3 18:19:58 2000
@@ -893,7 +893,7 @@
   int tspecial, tspecial_north, tspecial_south, tspecial_east, tspecial_west;
   int tspecial_north_east, tspecial_south_east, tspecial_south_west, 
tspecial_north_west;
   int rail_card_tileno=0, rail_semi_tileno=0, road_card_tileno=0, 
road_semi_tileno=0;
-  int rail_card_count=0, rail_semi_count=0, road_card_count=0, 
road_semi_count=0;
+  int rail_card_count, rail_semi_count, road_card_count, road_semi_count;
 
   int tileno;
   struct tile *ptile;

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] PATCH: client optimizations, Dirk Stoecker <=