Author: cazfi
Date: Thu Jun 26 19:39:07 2014
New Revision: 25274

URL: http://svn.gna.org/viewcvs/freeciv?rev=25274&view=rev
Log:
Moved TECH_LOG functionality from server common code to default AI as only
it uses it.

See patch #4844

Modified:
    trunk/ai/default/advdomestic.c
    trunk/ai/default/advmilitary.c
    trunk/ai/default/aiair.c
    trunk/ai/default/aicity.c
    trunk/ai/default/aidiplomat.c
    trunk/ai/default/aiferry.c
    trunk/ai/default/aihand.c
    trunk/ai/default/aihunt.c
    trunk/ai/default/ailog.c
    trunk/ai/default/ailog.h
    trunk/ai/default/aiparatrooper.c
    trunk/ai/default/aisettler.c
    trunk/ai/default/aitech.c
    trunk/server/srv_log.c
    trunk/server/srv_log.h

Modified: trunk/ai/default/advdomestic.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/advdomestic.c?rev=25274&r1=25273&r2=25274&view=diff
==============================================================================
--- trunk/ai/default/advdomestic.c      (original)
+++ trunk/ai/default/advdomestic.c      Thu Jun 26 19:39:07 2014
@@ -55,6 +55,7 @@
 #include "advmilitary.h"
 #include "aicity.h"
 #include "aidata.h"
+#include "ailog.h"
 #include "aiplayer.h"
 #include "aitech.h"
 #include "aitools.h"

Modified: trunk/ai/default/advmilitary.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/advmilitary.c?rev=25274&r1=25273&r2=25274&view=diff
==============================================================================
--- trunk/ai/default/advmilitary.c      (original)
+++ trunk/ai/default/advmilitary.c      Thu Jun 26 19:39:07 2014
@@ -56,6 +56,7 @@
 #include "aiferry.h"
 #include "aihand.h"
 #include "aihunt.h"
+#include "ailog.h"
 #include "aiparatrooper.h"
 #include "aiplayer.h"
 #include "aitech.h"

Modified: trunk/ai/default/aiair.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aiair.c?rev=25274&r1=25273&r2=25274&view=diff
==============================================================================
--- trunk/ai/default/aiair.c    (original)
+++ trunk/ai/default/aiair.c    Thu Jun 26 19:39:07 2014
@@ -44,6 +44,7 @@
 /* ai/default */
 #include "aicity.h"
 #include "aiplayer.h"
+#include "ailog.h"
 #include "aitools.h"
 #include "aiunit.h"
 

Modified: trunk/ai/default/aicity.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aicity.c?rev=25274&r1=25273&r2=25274&view=diff
==============================================================================
--- trunk/ai/default/aicity.c   (original)
+++ trunk/ai/default/aicity.c   Thu Jun 26 19:39:07 2014
@@ -53,6 +53,7 @@
 #include "advdomestic.h"
 #include "advmilitary.h"
 #include "aihand.h"
+#include "ailog.h"
 #include "aiplayer.h"
 #include "aisettler.h"
 #include "aitools.h"

Modified: trunk/ai/default/aidiplomat.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aidiplomat.c?rev=25274&r1=25273&r2=25274&view=diff
==============================================================================
--- trunk/ai/default/aidiplomat.c       (original)
+++ trunk/ai/default/aidiplomat.c       Thu Jun 26 19:39:07 2014
@@ -64,6 +64,7 @@
 #include "aidata.h"
 #include "aiguard.h"
 #include "aihand.h"
+#include "ailog.h"
 #include "aiplayer.h"
 #include "aitools.h"
 #include "aiunit.h"

Modified: trunk/ai/default/aiferry.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aiferry.c?rev=25274&r1=25273&r2=25274&view=diff
==============================================================================
--- trunk/ai/default/aiferry.c  (original)
+++ trunk/ai/default/aiferry.c  Thu Jun 26 19:39:07 2014
@@ -48,6 +48,7 @@
 /* ai/default */
 #include "aidata.h"
 #include "aiguard.h"
+#include "ailog.h"
 #include "aiplayer.h"
 #include "aitools.h"
 #include "aiunit.h"

Modified: trunk/ai/default/aihand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aihand.c?rev=25274&r1=25273&r2=25274&view=diff
==============================================================================
--- trunk/ai/default/aihand.c   (original)
+++ trunk/ai/default/aihand.c   Thu Jun 26 19:39:07 2014
@@ -57,6 +57,7 @@
 #include "advmilitary.h"
 #include "advspace.h"
 #include "aicity.h"
+#include "ailog.h"
 #include "aiplayer.h"
 #include "aitech.h"
 #include "aitools.h"

Modified: trunk/ai/default/aihunt.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aihunt.c?rev=25274&r1=25273&r2=25274&view=diff
==============================================================================
--- trunk/ai/default/aihunt.c   (original)
+++ trunk/ai/default/aihunt.c   Thu Jun 26 19:39:07 2014
@@ -48,6 +48,7 @@
 
 /* ai/default */
 #include "aicity.h"
+#include "ailog.h"
 #include "aiplayer.h"
 #include "aitools.h"
 #include "aiunit.h"

Modified: trunk/ai/default/ailog.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/ailog.c?rev=25274&r1=25273&r2=25274&view=diff
==============================================================================
--- trunk/ai/default/ailog.c    (original)
+++ trunk/ai/default/ailog.c    Thu Jun 26 19:39:07 2014
@@ -55,6 +55,39 @@
 
   fc_snprintf(buffer, buflength, "%d %d",
               unit_data->bodyguard, unit_data->ferryboat);
+}
+
+/**************************************************************************
+  Log player tech messages.
+**************************************************************************/
+void real_tech_log(const char *file, const char *function, int line,
+                   enum log_level level, bool notify,
+                   const struct player *pplayer, struct advance *padvance,
+                   const char *msg, ...)
+{
+  char buffer[500];
+  char buffer2[500];
+  va_list ap;
+
+  if (!valid_advance(padvance) || advance_by_number(A_NONE) == padvance) {
+    return;
+  }
+
+  fc_snprintf(buffer, sizeof(buffer), "%s::%s (want %d, dist %d) ",
+              player_name(pplayer),
+              advance_name_by_player(pplayer, advance_number(padvance)),
+              pplayer->ai_common.tech_want[advance_index(padvance)],
+              num_unknown_techs_for_goal(pplayer, advance_number(padvance)));
+
+  va_start(ap, msg);
+  fc_vsnprintf(buffer2, sizeof(buffer2), msg, ap);
+  va_end(ap);
+
+  cat_snprintf(buffer, sizeof(buffer), "%s", buffer2);
+  if (notify) {
+    notify_conn(NULL, NULL, E_AI_DEBUG, ftc_log, "%s", buffer);
+  }
+  do_log(file, function, line, FALSE, level, "%s", buffer);
 }
 
 /**************************************************************************

Modified: trunk/ai/default/ailog.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/ailog.h?rev=25274&r1=25273&r2=25274&view=diff
==============================================================================
--- trunk/ai/default/ailog.h    (original)
+++ trunk/ai/default/ailog.h    Thu Jun 26 19:39:07 2014
@@ -16,6 +16,10 @@
 /* utility */
 #include "log.h"
 #include "support.h"
+ 
+/* Change these and remake to watch logs from a specific 
+   part of the AI code. */
+#define LOGLEVEL_TECH LOG_DEBUG
 
 struct player;
 
@@ -23,6 +27,22 @@
                   const struct city *pcity);
 void dai_unit_log(struct ai_type *ait, char *buffer, int buflength,
                   const struct unit *punit);
+
+void real_tech_log(const char *file, const char *function, int line,
+                   enum log_level level, bool notify,
+                   const struct player *pplayer, struct advance *padvance,
+                   const char *msg, ...)
+                   fc__attribute((__format__ (__printf__, 8, 9)));
+#define TECH_LOG(loglevel, pplayer, padvance, msg, ...)                     \
+{                                                                           \
+  bool notify = BV_ISSET(pplayer->server.debug, PLAYER_DEBUG_TECH);         \
+  enum log_level level = (notify ? LOG_AI_TEST                              \
+                          : MIN(loglevel, LOGLEVEL_TECH));                  \
+  if (log_do_output_for_level(level)) {                                     \
+    real_tech_log(__FILE__, __FUNCTION__, __FC_LINE__, level, notify,       \
+                  pplayer, padvance, msg, ## __VA_ARGS__);                  \
+  }                                                                         \
+}
 
 void real_diplo_log(struct ai_type *ait,
                     const char *file, const char *function, int line,

Modified: trunk/ai/default/aiparatrooper.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aiparatrooper.c?rev=25274&r1=25273&r2=25274&view=diff
==============================================================================
--- trunk/ai/default/aiparatrooper.c    (original)
+++ trunk/ai/default/aiparatrooper.c    Thu Jun 26 19:39:07 2014
@@ -45,6 +45,7 @@
 
 /* ai/default */
 #include "aicity.h"
+#include "ailog.h"
 #include "aiplayer.h"
 #include "aiunit.h"
 #include "aitools.h"

Modified: trunk/ai/default/aisettler.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aisettler.c?rev=25274&r1=25273&r2=25274&view=diff
==============================================================================
--- trunk/ai/default/aisettler.c        (original)
+++ trunk/ai/default/aisettler.c        Thu Jun 26 19:39:07 2014
@@ -57,6 +57,7 @@
 #include "aidata.h"
 #include "aicity.h"
 #include "aiferry.h"
+#include "ailog.h"
 #include "aiplayer.h"
 #include "aitools.h"
 #include "aiunit.h"

Modified: trunk/ai/default/aitech.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/aitech.c?rev=25274&r1=25273&r2=25274&view=diff
==============================================================================
--- trunk/ai/default/aitech.c   (original)
+++ trunk/ai/default/aitech.c   Thu Jun 26 19:39:07 2014
@@ -34,6 +34,7 @@
 
 /* ai */
 #include "advmilitary.h"
+#include "ailog.h"
 #include "aitools.h"
 
 #include "aitech.h"

Modified: trunk/server/srv_log.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/srv_log.c?rev=25274&r1=25273&r2=25274&view=diff
==============================================================================
--- trunk/server/srv_log.c      (original)
+++ trunk/server/srv_log.c      Thu Jun 26 19:39:07 2014
@@ -42,39 +42,6 @@
 static int recursion[AIT_LAST];
 
 /* General AI logging functions */
-
-/**************************************************************************
-  Log player tech messages.
-**************************************************************************/
-void real_tech_log(const char *file, const char *function, int line,
-                   enum log_level level, bool notify,
-                   const struct player *pplayer, struct advance *padvance,
-                   const char *msg, ...)
-{
-  char buffer[500];
-  char buffer2[500];
-  va_list ap;
-
-  if (!valid_advance(padvance) || advance_by_number(A_NONE) == padvance) {
-    return;
-  }
-
-  fc_snprintf(buffer, sizeof(buffer), "%s::%s (want %d, dist %d) ",
-              player_name(pplayer),
-              advance_name_by_player(pplayer, advance_number(padvance)),
-              pplayer->ai_common.tech_want[advance_index(padvance)],
-              num_unknown_techs_for_goal(pplayer, advance_number(padvance)));
-
-  va_start(ap, msg);
-  fc_vsnprintf(buffer2, sizeof(buffer2), msg, ap);
-  va_end(ap);
-
-  cat_snprintf(buffer, sizeof(buffer), "%s", buffer2);
-  if (notify) {
-    notify_conn(NULL, NULL, E_AI_DEBUG, ftc_log, "%s", buffer);
-  }
-  do_log(file, function, line, FALSE, level, "%s", buffer);
-}
 
 /**************************************************************************
   Log city messages, they will appear like this

Modified: trunk/server/srv_log.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/srv_log.h?rev=25274&r1=25273&r2=25274&view=diff
==============================================================================
--- trunk/server/srv_log.h      (original)
+++ trunk/server/srv_log.h      Thu Jun 26 19:39:07 2014
@@ -34,7 +34,6 @@
 #define LOGLEVEL_BUILD LOG_DEBUG
 #define LOGLEVEL_HUNT LOG_DEBUG
 #define LOGLEVEL_PLAYER LOG_DEBUG
-#define LOGLEVEL_TECH LOG_DEBUG
 
 #define LOG_AI_TEST LOG_NORMAL
 
@@ -77,22 +76,6 @@
   TIMER_START, TIMER_STOP
 };
 
-void real_tech_log(const char *file, const char *function, int line,
-                   enum log_level level, bool notify,
-                   const struct player *pplayer, struct advance *padvance,
-                   const char *msg, ...)
-                   fc__attribute((__format__ (__printf__, 8, 9)));
-#define TECH_LOG(loglevel, pplayer, padvance, msg, ...)                     \
-{                                                                           \
-  bool notify = BV_ISSET(pplayer->server.debug, PLAYER_DEBUG_TECH);         \
-  enum log_level level = (notify ? LOG_AI_TEST                              \
-                          : MIN(loglevel, LOGLEVEL_TECH));                  \
-  if (log_do_output_for_level(level)) {                                     \
-    real_tech_log(__FILE__, __FUNCTION__, __FC_LINE__, level, notify,       \
-                  pplayer, padvance, msg, ## __VA_ARGS__);                  \
-  }                                                                         \
-}
-
 void real_city_log(const char *file, const char *function, int line,
                    enum log_level level, bool notify,
                    const struct city *pcity, const char *msg, ...)


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to