Re: [Freeciv-Dev] (PR#40087) client needs sanity check and other server log messages

2008-02-09 Thread William Allen Simpson

http://bugs.freeciv.org/Ticket/Display.html?id=40087 >

Moved the existing ruleset_error() intercept into the con_handle_log()
callback, so that server log messages can be sent to all connections.
Currently, only LOG_FATAL and LOG_ERROR.

Renamed E_MESSAGE_WALL to E_LOG_FATAL, as that was already used for the
ruleset_error() and operator message popups.

Renamed E_PLAYER_SETTINGS (unused) to E_LOG_ERROR, and these default to
chat/output only.  Used instead of E_LOG_FATAL for scripting.

Changed the event sections to be properly translatable.  Swapped the
data fields for easier sorting (by event instead of strings).  Likewise
for the soundspec file.  Used some existing sounds.

Committed trunk revision 14390.
Committed S2_2 revision 14391.

Index: server/console.c
===
--- server/console.c(revision 14389)
+++ server/console.c(working copy)
@@ -25,9 +25,11 @@
 
 #include "fciconv.h"
 #include "fcintl.h"
+#include "game.h"
 #include "log.h"
 #include "support.h"
 
+#include "plrhand.h"
 #include "srv_main.h"
 
 #include "console.h"
@@ -47,6 +49,21 @@
 /
 static void con_handle_log(int level, const char *message, bool file_too)
 {
+  if (LOG_ERROR == level) {
+notify_conn(NULL, NULL, E_LOG_ERROR, message);
+  } else if (LOG_FATAL >= level) {
+/* Make sure that message is not left to buffers when server dies */
+conn_list_iterate(game.est_connections, pconn) {
+  pconn->send_buffer->do_buffer_sends = 0;
+  pconn->compression.frozen_level = 0;
+} conn_list_iterate_end;
+
+notify_conn(NULL, NULL, E_LOG_FATAL, message);
+notify_conn(NULL, NULL, E_LOG_FATAL,
+_("Please report this message at %s"),
+BUG_URL);
+  }
+
   /* Write debug/verbose message to console only when not written to file. */
   if (!file_too || level <= LOG_NORMAL) {
 if (console_rfcstyle) {
Index: server/scripting/api.pkg
===
--- server/scripting/api.pkg(revision 14389)
+++ server/scripting/api.pkg(working copy)
@@ -419,7 +419,7 @@
 E_BROADCAST_REPORT @ BROADCAST_REPORT,
 E_GAME_END @ GAME_END,
 E_GAME_START @ GAME_START,
-E_MESSAGE_WALL @ MESSAGE_WALL,
+E_LOG_ERROR @ E_LOG_ERROR,
 E_NATION_SELECTED @ NATION_SELECTED,
 E_DESTROYED @ DESTROYED,
 E_REPORT @ REPORT,
Index: server/ruleset.c
===
--- server/ruleset.c(revision 14389)
+++ server/ruleset.c(working copy)
@@ -140,19 +140,8 @@
 
   va_start(args, format);
 
-  if (LOG_FATAL >= loglevel) {
-/* Make sure that message is not left to buffers when server dies */
-conn_list_iterate(game.est_connections, pconn) {
-  pconn->send_buffer->do_buffer_sends = 0;
-  pconn->compression.frozen_level = 0;
-} conn_list_iterate_end;
+  vreal_freelog(loglevel, format, args);
 
-vreal_freelog(loglevel, format, args);
-notify_conn(NULL, NULL, E_MESSAGE_WALL, _("Fatal ruleset error. Server 
dies!"));
-  } else {
-vreal_freelog(loglevel, format, args);
-  }
-
   va_end(args);
 
   if (LOG_FATAL >= loglevel) {
Index: server/stdinhand.c
===
--- server/stdinhand.c  (revision 14389)
+++ server/stdinhand.c  (working copy)
@@ -1636,8 +1636,8 @@
 static bool wall(char *str, bool check)
 {
   if (!check) {
-notify_conn(NULL, NULL, E_MESSAGE_WALL,
-  _("Server Operator: %s"), str);
+notify_conn(NULL, NULL, E_LOG_FATAL,
+   _("Server Operator: %s"), str);
   }
   return TRUE;
 }
Index: data/stdsounds.soundspec
===
--- data/stdsounds.soundspec(revision 14389)
+++ data/stdsounds.soundspec(working copy)
@@ -194,54 +194,38 @@
 
 ; This list contains all events up to E_TECH_GOAL
 ; (as numbered in common/events.h), in the sorted order.
-; Alphabetical sorting is based on event descriptions,
-; not to these tag names. These have been sorted using
-; Freeciv internal language (en_US)
+; Alphabetical sorting is based on these tag names,
+; as the message names and contents change. {was}
 
 ;e_ai_debug = ""
+;e_anarchy = ""
+;e_bad_command = ""
 ;e_broadcast_report = ""
 ;e_caravan_action = ""
 ;e_chat_error = ""
 ;e_chat_msg = ""
+;e_city_aq_building = ""
+;e_city_aqueduct = ""
+;e_city_build = ""
 ;e_city_cantbuild = ""
-;e_city_lost = ""
-;e_city_love = ""
+;e_city_cma_release = ""
 ;e_city_disorder = ""
 ;e_city_famine = ""
 ;e_city_famine_feared = ""
+;e_city_gran_throttle = ""
 ;e_city_growth = ""
+;e_city_lost = ""
+;e_city_love = ""
 ;e_city_may_soon_grow = ""
-;e_city_aqueduct = ""
-;e_city_aq_building = ""
 ;e_city_normal = ""
 ;e_city_nuked = ""
 ;e_city_production_changed = ""
-;e_city_cma_release = ""
-;e_city_gran_throttle = ""
 ;e_city_tr

[Freeciv-Dev] (PR#40088) 2.2-test: wrong city size after attack

2008-02-09 Thread William Allen Simpson

http://bugs.freeciv.org/Ticket/Display.html?id=40088 >

This is implied by the sanitycheck repair in PR#40086, that presumably
happened in the PR#40072 savegame.



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#40086) city center tiles not worked, bad sanity check repair?

2008-02-09 Thread William Allen Simpson

http://bugs.freeciv.org/Ticket/Display.html?id=40086 >

Leaving open, as this needs to to be retrofitted for 2.1, too.



___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#40086) city center tiles not worked, bad sanity check repair?

2008-02-09 Thread William Allen Simpson

http://bugs.freeciv.org/Ticket/Display.html?id=40086 >

Define FREE_WORKED_TILES for counting is_free_worked_tile(), currently
only 1!  Should generalize in rulesets?

Fix real_sanity_check_city() to prevent removing city workers for any
is_free_worked_tile().  Should consolidate with other functions!

Rewrite SANITY_* macros to standardize freelog() output format.

Don't assert() in game_remove_player(), use freelog() instead.

Committed trunk revision 14388.
Committed S2_2 revision 14389.


Index: server/sanitycheck.c
===
--- server/sanitycheck.c(revision 14387)
+++ server/sanitycheck.c(working copy)
@@ -39,37 +39,50 @@
 
 #ifdef SANITY_CHECKING
 
-#define SANITY_CHECK(x)
\
+#define SANITY_(_s)\
+  freelog(LOG_ERROR, "Failed %s:%d at %s:%d! " _s, \
+ __FILE__,__LINE__, file, line
+
+#define SANITY_CHECK(check)\
   do { \
-if (!(x)) {
\
-  freelog(LOG_ERROR, "Failed %s:%d (%s:%d): %s",   \
- __FILE__,__LINE__, file, line, #x);   \
+if (!(check)) {\
+  SANITY_("!(%s)"),
\
+  #check); \
 }  \
   } while(0)
 
-#define SANITY_TILE(ptile, check)  \
+#define SANITY_CITY(_city, check)  \
   do { \
 if (!(check)) {\
-  struct city *pcity = tile_city(ptile);   \
-  freelog(LOG_ERROR, "Failed %s:%d (%s:%d) at %s (%d,%d): %s", \
- __FILE__,__LINE__, file, line,\
- NULL != pcity ? city_name(pcity)  \
- : terrain_rule_name(tile_terrain(ptile)), \
- TILE_XY(ptile), #check);  \
+  SANITY_("(%4d,%4d) !(%s) in \"%s\"[%d]"),
\
+ TILE_XY((_city)->tile),   \
+ #check,   \
+ city_name(_city), \
+ (_city)->size);   \
 }  \
   } while(0)
 
-#define SANITY_CITY(pcity, check)  \
+#define SANITY_TERRAIN(_tile, check)   \
   do { \
 if (!(check)) {\
-  freelog(LOG_ERROR, "Failed %s:%d (%s:%d) in %s[%d](%d,%d): %s",  \
- __FILE__,__LINE__, file, line,\
- city_name(pcity), (pcity)->size,  \
- TILE_XY((pcity)->tile), #check);  \
+  SANITY_("(%4d,%4d) !(%s) at \"%s\""),\
+ TILE_XY(_tile),   \
+ #check,   \
+ terrain_rule_name(tile_terrain(_tile)));  \
 }  \
   } while(0)
 
+#define SANITY_TILE(_tile, check)  \
+  do { \
+struct city *_tile##_city = tile_city(_tile);  \
+if (NULL != _tile##_city) {
\
+  SANITY_CITY(_tile##_city, check);
\
+} else {   \
+  SANITY_TERRAIN(_tile, check);\
+}  \
+  } while(0)
 
+
 /**
   Sanity checking on map (tile) specials.
 **/
@@ -168,6 +181,7 @@
 CHECK_NATIVE_POS(ptile->nat_x, ptile->nat_y);
 
 if (NULL != pcity) {
+  SANITY_TILE(ptile, same_pos(pcity->tile, ptile));
   SANITY_TILE(ptile, tile_owner(ptile) != NULL);
 }
 if (tile_owner(ptile) != NULL) {
@@ -196,10 +210,