Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2000:
[Freeciv-Dev] PATCH to FreeCiv CVS-Snapshot-Jul-19
Home

[Freeciv-Dev] PATCH to FreeCiv CVS-Snapshot-Jul-19

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] PATCH to FreeCiv CVS-Snapshot-Jul-19
From: Dirk Stoecker <stoecker@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 19 Jul 2000 16:19:08 +0200 (MET DST)

Hi,

A question: On Amiga it sometimes happens, that I get control over enemy units
(without the ability to do anthing with them). Is this a gui-mui related or
general problem. Seems to happen in some cases, directly after enemy destroyed
my own defender.

And, could you add an comment on CVS-page, which contains PDT->UTC/GMT
difference.

-------- Now the patch:

I removed some warnings, which are produced by SAS-C compiler. This creates a
nicer compiler run and normally also better code.

Some explicit casts added for function return:
common/map.c tile_is_known
common/shared.c cat_snprintf
server/console.c con_dump
server/gotohand.c find_air_first_destination
server/maphand.c map_get_known
server/maphand.c map_get_sent

Macro invocation calls function multiple (macro/arguments expanded):
ai/aitech.c 201
server/plrhand.c 1773
server/mapgen.c 141
server/mapgen.c 166 make_forest
--> The indentation suggested behaviour different to what was done and wanted.
--> I corrected the intendation.

Others:
server/civserver.c update_diplomatics --> added void as argument list
server/cityhand.c "package_dumb_city" --> added static keyword to declaration 
also
server/maphand.c "player_tile_init"   --> added static keyword to declaration 
also
server/maphand.c "give_tile_info_from_player_to_player" --> static keyword
server/unitfunc.c "sentry_transported_idle_units" --> static keyword

Some dead assignments in already changed modules (removed):
ai/aitech.c 149 "bestdist"
ai/aitech.c 102 "tech"
server/mapgen.c 183 "forestsize"
server/maphand.c 292/372 "ptile"
server/civserver.c 169 "option"
server/civserver.c 1935 "ptile"
--> There are much more of them :-)

In common/log.h and server/console.c:
Removed logdebug_suppress_warning and added LOG_FREELOG_UNUSED define check.
This removes the creation of the 2 static functions logdebug_check and freelog
totally, when they are unused. This removes the "static function freelog
unreachable" warning for non-GCC compilers (and shortens binary).

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-Jul-19/freeciv/ai/aitech.c ./ai/aitech.c
--- ../../freeciv-Jul-19/freeciv/ai/aitech.c    Thu May 25 11:15:35 2000
+++ ./ai/aitech.c       Wed Jul 19 13:51:09 2000
@@ -99,7 +99,7 @@
 **************************************************************************/
 static int get_wonder_tech(struct player *plr)
 {
-  int tech = A_NONE;
+  int tech;
   int building = get_nation_by_plr(plr)->goals.wonder;
   
   if (!improvement_exists(building))
@@ -146,7 +146,7 @@
   if (tech != A_NONE) {
     dist = tech_goal_turns(pplayer, tech);
     if (dist < bestdist) { 
-      bestdist = dist;
+      /*bestdist = dist;    useless command*/
       goal = tech;
     }
   }
@@ -192,13 +192,15 @@
 static void ai_select_tech(struct player *pplayer, struct ai_choice *choice,
                           struct ai_choice *gol)
 {
-  int i, j, k;
+  int i, j, k, c;
   int values[A_LAST];
   int goal_values[A_LAST];
   int prereq[A_LAST];
   unsigned char cache[A_LAST][A_LAST];
-  
-  int c = MAX(1, city_list_size(&pplayer->cities));
+
+  if((c = city_list_size(&pplayer->cities)) < 1)
+    c = 1; /* MAX means double invocation of city_list_size function */
+
   memset(values, 0, sizeof(values));
   memset(goal_values, 0, sizeof(goal_values));
   memset(cache, 0, sizeof(cache));
diff -ur ../../freeciv-Jul-19/freeciv/client/gui-mui/mapclass.c 
./client/gui-mui/mapclass.c
--- ../../freeciv-Jul-19/freeciv/client/gui-mui/mapclass.c      Mon Jul 17 
11:28:30 2000
+++ ./client/gui-mui/mapclass.c Wed Jul 19 14:44:16 2000
@@ -26,7 +26,6 @@
 #include <proto/datatypes.h>
 
 #include "fcintl.h"
-#include "log.h"
 #include "map.h"
 #include "game.h"
 #include "spaceship.h"
diff -ur ../../freeciv-Jul-19/freeciv/client/gui-mui/mapctrl.c 
./client/gui-mui/mapctrl.c
--- ../../freeciv-Jul-19/freeciv/client/gui-mui/mapctrl.c       Mon Jul 17 
11:28:30 2000
+++ ./client/gui-mui/mapctrl.c  Wed Jul 19 14:44:22 2000
@@ -22,7 +22,6 @@
 
 #include "capability.h"
 #include "game.h"
-#include "log.h"
 #include "map.h"
 #include "player.h"
 #include "support.h"
diff -ur ../../freeciv-Jul-19/freeciv/common/log.h ./common/log.h
--- ../../freeciv-Jul-19/freeciv/common/log.h   Wed Jul 19 14:29:40 2000
+++ ./common/log.h      Wed Jul 19 14:29:17 2000
@@ -57,7 +57,8 @@
                   fc__attribute((format (printf, 2, 3)));
 void vreal_freelog(int level, char *message, va_list ap);
 
-
+/* Use this define before including log, when freelog() is not used */
+#ifndef LOG_FREELOG_UNUSED
 /* A static (per-file) function to use/update the above per-file vars.
  * This should only be called for LOG_DEBUG messages.
  * It returns whether such a LOG_DEBUG message should be sent on
@@ -74,13 +75,6 @@
                                      || (line >= logdebug_thisfile.min 
                                          && line <= logdebug_thisfile.max))); 
 }
-/* Including log.h without calling freelog() can generate a
-   warning that logdebug_check is never used; can use this to
-   suppress that warning:
-*/
-#define logdebug_suppress_warning logdebug_check(__FILE__, __LINE__)
-#else
-#define logdebug_suppress_warning
 #endif
 
 /* For GCC we use a variadic macro; for others we take
@@ -117,5 +111,6 @@
   }
 }
 #endif /* __GNUC__ */
+#endif /* LOG_FREELOG_UNUSED */
 
 #endif  /* FC__LOG_H */
diff -ur ../../freeciv-Jul-19/freeciv/common/map.c ./common/map.c
--- ../../freeciv-Jul-19/freeciv/common/map.c   Tue Jul 18 11:28:48 2000
+++ ./common/map.c      Wed Jul 19 13:51:10 2000
@@ -1171,7 +1171,7 @@
 ***************************************************************/
 enum known_type tile_is_known(int x, int y)
 {
-  return ((map.tiles+map_adjust_x(x)+
+  return (enum know_type) ((map.tiles+map_adjust_x(x)+
           map_adjust_y(y)*map.xsize)->known);
 }
 
diff -ur ../../freeciv-Jul-19/freeciv/common/shared.c ./common/shared.c
--- ../../freeciv-Jul-19/freeciv/common/shared.c        Fri Jun 23 11:20:21 2000
+++ ./common/shared.c   Wed Jul 19 13:51:10 2000
@@ -380,7 +380,7 @@
   va_start(ap, format);
   ret = my_vsnprintf(str+len, n-len, format, ap);
   va_end(ap);
-  return ret + len;
+  return (int) (ret + len);
 }
 
 /***************************************************************************
diff -ur ../../freeciv-Jul-19/freeciv/server/cityhand.c ./server/cityhand.c
--- ../../freeciv-Jul-19/freeciv/server/cityhand.c      Fri Jul  7 11:27:19 2000
+++ ./server/cityhand.c Wed Jul 19 13:51:11 2000
@@ -999,7 +999,7 @@
 FIXME: we should make a new package and let the client fill in the dummy
 info itself
 **************************************************************************/
-void package_dumb_city(struct player* pplayer, int x, int y,
+static void package_dumb_city(struct player* pplayer, int x, int y,
                       struct packet_city_info *packet)
 {
   int i;
diff -ur ../../freeciv-Jul-19/freeciv/server/civserver.c ./server/civserver.c
--- ../../freeciv-Jul-19/freeciv/server/civserver.c     Sun Jul 16 11:24:09 2000
+++ ./server/civserver.c        Wed Jul 19 14:33:28 2000
@@ -166,7 +166,7 @@
   char *gamelog_filename=NULL;
   char *load_filename=NULL;
   char *script_filename=NULL;
-  char *option=NULL;
+  char *option;
   int save_counter=0;
   int loglevel=LOG_NORMAL;
   struct timer *eot_timer;     /* time server processing at end-of-turn */
@@ -760,7 +760,7 @@
  check for cease-fires running out; update reputation; update cancelling
  reasons
 **************************************************************************/
-static void update_diplomatics()
+static void update_diplomatics(void)
 {
   int p, p2;
 
@@ -1929,10 +1929,8 @@
 {
   int x,y;
   int playerid = pplayer->player_no;
-  struct tile *ptile;
   for (x = 0; x < map.xsize; x++)
     for (y = 0; y < map.ysize; y++) {
-      ptile = map_get_tile(x,y);
       map_change_seen(x, y, playerid, -1);
       if (map_get_seen(x, y, playerid) == 0)
        update_player_tile_last_seen(pplayer, x, y);
diff -ur ../../freeciv-Jul-19/freeciv/server/console.c ./server/console.c
--- ../../freeciv-Jul-19/freeciv/server/console.c       Tue Jul 18 11:29:05 2000
+++ ./server/console.c  Wed Jul 19 14:31:20 2000
@@ -23,6 +23,7 @@
 #endif
 
 #include "fcintl.h"
+#define LOG_FREELOG_UNUSED
 #include "log.h"
 #include "support.h"
 
@@ -78,7 +79,6 @@
 void con_log_init(char *log_filename, int log_level)
 {
   log_init(log_filename, log_level, (log_filename ? NULL : con_handle_log));
-  logdebug_suppress_warning;
 }
 
 /************************************************************************
@@ -102,7 +102,7 @@
     printf("%s", buf);
   }
   console_prompt_is_showing = 0;
-  return strlen(buf);
+  return (int) strlen(buf);
 }
 
 /************************************************************************
diff -ur ../../freeciv-Jul-19/freeciv/server/gotohand.c ./server/gotohand.c
--- ../../freeciv-Jul-19/freeciv/server/gotohand.c      Wed Jul 19 13:47:34 2000
+++ ./server/gotohand.c Wed Jul 19 13:51:23 2000
@@ -1316,7 +1316,7 @@
   unsigned int fuelindex[MAXFUEL+1]; /* +1: stack top pointer */
   struct refuel *prefuel, *pgoal;
   struct refuel start;
-  unsigned int found_goal = 0;
+  int found_goal = 0;
   unsigned int fullmoves = get_unit_type(punit->type)->move_rate/3;
   unsigned int fullfuel = get_unit_type(punit->type)->fuel;
   int turns = 0;
diff -ur ../../freeciv-Jul-19/freeciv/server/mapgen.c ./server/mapgen.c
--- ../../freeciv-Jul-19/freeciv/server/mapgen.c        Wed Jun 14 11:18:03 2000
+++ ./server/mapgen.c   Wed Jul 19 13:51:24 2000
@@ -138,7 +138,11 @@
 **************************************************************************/
 static void make_desert(int x, int y, int height, int diff) 
 {
-  if (abs(full_map(x, y)-height)<diff && map_get_terrain(x, y)==T_GRASSLAND) {
+  int i;
+
+  /* abs is often a macro, so prevent double function invocation */
+  i = full_map(x, y)-height;
+  if(abs(i)<diff && map_get_terrain(x, y)==T_GRASSLAND) {
     map_set_terrain(x, y, T_DESERT);
     make_desert(x-1,y, height, diff-1);
     make_desert(x,y-1, height, diff-3);
@@ -155,20 +159,25 @@
 **************************************************************************/
 static void make_forest(int x, int y, int height, int diff)
 {
+  int i;
+
   if (x==0 || x==map.xsize-1 ||y==0 || y==map.ysize-1)
     return;
 
   if (map_get_terrain(x, y)==T_GRASSLAND) {
     if (y>map.ysize*42/100 && y<map.ysize*58/100 && myrand(100)>50)
       map_set_terrain(x, y, T_JUNGLE);
-    else 
+    else
       map_set_terrain(x, y, T_FOREST);
-      if (abs(full_map(x, y)-height)<diff) {
-       if (myrand(10)>5) make_forest(x-1,y, height, diff-5);
-       if (myrand(10)>5) make_forest(x,y-1, height, diff-5);
-       if (myrand(10)>5) make_forest(x+1,y, height, diff-5);
-       if (myrand(10)>5) make_forest(x,y+1, height, diff-5);
-      }
+
+    /* abs is often a macro, so prevent double function invocation */
+    i = full_map(x, y)-height;
+    if (abs(i)<diff) {
+      if (myrand(10)>5) make_forest(x-1,y, height, diff-5);
+      if (myrand(10)>5) make_forest(x,y-1, height, diff-5);
+      if (myrand(10)>5) make_forest(x+1,y, height, diff-5);
+      if (myrand(10)>5) make_forest(x,y+1, height, diff-5);
+    }
     forests++;
   }
 }
@@ -180,7 +189,7 @@
 static void make_forests(void)
 {
   int x,y;
-  int forestsize=25;
+  int forestsize;
   forestsize=(map.xsize*map.ysize*map.forestsize)/1000;
    do {
     x=myrand(map.xsize);
diff -ur ../../freeciv-Jul-19/freeciv/server/maphand.c ./server/maphand.c
--- ../../freeciv-Jul-19/freeciv/server/maphand.c       Mon Jul 10 11:27:30 2000
+++ ./server/maphand.c  Wed Jul 19 13:51:29 2000
@@ -280,7 +280,6 @@
 {
   int dx,dy,abs_x,abs_y;
   int playerid = pplayer->player_no;
-  struct tile *ptile;
   struct city *pcity;
   send_NODRAW_tiles(pplayer,x,y,len);
   connection_do_buffer(pplayer->conn);
@@ -289,7 +288,6 @@
     for (dy = y-len;dy <= y+len;dy++) {
       if (is_real_tile(dx,dy)) {
        abs_y = map_adjust_y(dy);
-       ptile = map_get_tile(abs_x,abs_y);
        
        freelog (LOG_DEBUG, "Unfogging %i,%i. Previous fog: %i.",
                 abs_x, abs_y, map_get_seen(abs_x, abs_y, playerid));
@@ -362,14 +360,12 @@
 {
   int dx, dy, abs_x, abs_y, seen;
   int playerid = pplayer->player_no;
-  struct tile *ptile;
   connection_do_buffer(pplayer->conn);
   for (dx = x-len;dx <= x+len;dx++) {
     abs_x = map_adjust_x(dx);
     for (dy = y-len;dy <= y+len;dy++) {
       if (is_real_tile(dx,dy)) {
        abs_y = map_adjust_y(dy);
-       ptile = map_get_tile(abs_x,abs_y);
        freelog (LOG_DEBUG, "Fogging %i,%i. Previous fog: %i.",
                 abs_x, abs_y, map_get_seen(abs_x, abs_y, playerid));
        map_change_seen(abs_x, abs_y, playerid, -1);
@@ -934,8 +930,8 @@
 ***************************************************************/
 int map_get_known(int x, int y, struct player *pplayer)
 {
-  return ((map.tiles+map_adjust_x(x)+
-          map_adjust_y(y)*map.xsize)->known)&(1u<<pplayer->player_no);
+  return (int) (((map.tiles+map_adjust_x(x)+
+          map_adjust_y(y)*map.xsize)->known)&(1u<<pplayer->player_no));
 }
 
 /***************************************************************
@@ -1052,8 +1048,8 @@
 ***************************************************************/
 int map_get_sent(int x, int y, struct player *pplayer)
 {
-  return ((map.tiles+map_adjust_x(x)+
-          map_adjust_y(y)*map.xsize)->sent)&(1u<<pplayer->player_no);
+  return (int) (((map.tiles+map_adjust_x(x)+
+          map_adjust_y(y)*map.xsize)->sent)&(1u<<pplayer->player_no));
 }
 
 /***************************************************************
@@ -1086,7 +1082,7 @@
 We need to use use fogofwar_old here, so the player's tiles get
 in the same state as th other players' tiles.
 ***************************************************************/
-void player_tile_init(struct player_tile *plrtile)
+static void player_tile_init(struct player_tile *plrtile)
 {
   plrtile->terrain = T_UNKNOWN;
   plrtile->special = S_NO_SPECIAL;
@@ -1133,7 +1129,7 @@
 /***************************************************************
 ...
 ***************************************************************/
-void give_tile_info_from_player_to_player(struct player *pfrom,
+static void give_tile_info_from_player_to_player(struct player *pfrom,
                                          struct player *pdest, int x, int y)
 {
   struct dumb_city *from_city, *dest_city;
diff -ur ../../freeciv-Jul-19/freeciv/server/plrhand.c ./server/plrhand.c
--- ../../freeciv-Jul-19/freeciv/server/plrhand.c       Mon Jul 10 11:27:30 2000
+++ ./server/plrhand.c  Wed Jul 19 13:51:30 2000
@@ -1768,9 +1768,11 @@
           get_government_name(preq->government));
 
   if (!pplayer->ai.control) {
+    int i;
     /* Keep luxuries if we have any.  Try to max out science. -GJW */
-    pplayer->economic.science = MIN (100 - pplayer->economic.luxury,
-                                    get_government_max_rate 
(pplayer->government));
+    i = get_government_max_rate (pplayer->government);
+    if((pplayer->economic.science = 100 - pplayer->economic.luxury) > i)
+      pplayer->economic.science = i;
     pplayer->economic.tax = 100 - (pplayer->economic.luxury +
                                   pplayer->economic.science);
   }
diff -ur ../../freeciv-Jul-19/freeciv/server/unitfunc.c ./server/unitfunc.c
--- ../../freeciv-Jul-19/freeciv/server/unitfunc.c      Mon Jul 10 11:27:32 2000
+++ ./server/unitfunc.c Wed Jul 19 13:51:31 2000
@@ -3098,7 +3098,7 @@
 For all units which are transported by the given unit and that are
 currently idle, sentry them.
 **************************************************************************/
-void sentry_transported_idle_units(struct unit *ptrans)
+static void sentry_transported_idle_units(struct unit *ptrans)
 {
   int x = ptrans->x;
   int y = ptrans->y;

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