Re: [Freeciv-Dev] (PR#40644) [Patch] Iteration support to scripting

2009-01-09 Thread Marko Lindqvist

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40644 

2009/1/8 Madeline Book:

 It would be nice if one could do

 for player in game:players() do
  print player:name()-- or whatever
 end

 Lua has a lot of great features for implementing iteration
 cleanly and efficiently: closures, generic for, coroutines,
 and object oriented syntax (see http://www.lua.org/pil/).
 It would be a shame not to make the best use of them. ;)

 True, but that does sounds more like 2.3 stuff. I don't see it
happening in 2.2 timeframe.

 I'm somewhat undecided if we should just not include any iteration
support at all at 2.2, or should we include something like my patch
for situations where modder desperately needs at least some kind of
iteration support.


 - ML



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


[Freeciv-Dev] (PR#40649) Cartography tileset seems broken

2009-01-09 Thread john w. bjerk

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40649 

Cartography is listed as a tileset that runs under 2.1, however i  
can't get it to load under 2.1.6 mac version.

If it can't be easily fixed it should at least be removed from the  
list of tilesets.
http://freeciv.wikia.com/wiki/Tilesets

--- j. w. bjerk  /  eleazar
 www.jwbjerk.com



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


[Freeciv-Dev] (PR#40650) [Patch] savegame.c compilation fix

2009-01-09 Thread Marko Lindqvist

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40650 

 Should I start testing my patches with several versions of gcc before
committing? Compiler warning (or error when compiled with
--enable-debug) appeared in one of my environments after latest
commits.

 I'll commit attached fix immediately.


 - ML

diff -Nurd -X.diff_ignore freeciv/server/savegame.c freeciv/server/savegame.c
--- freeciv/server/savegame.c	2009-01-09 20:45:26.0 +0200
+++ freeciv/server/savegame.c	2009-01-09 20:49:19.0 +0200
@@ -1037,8 +1037,8 @@
   /* Owner and ownership source are stored as plain numbers */
   if (has_capability(new_owner_map, savefile_options)) {
 int x, y;
-struct player *owner;
-struct tile *claimer;
+struct player *owner = NULL;
+struct tile *claimer = NULL;
 
 for (y = 0; y  map.ysize; y++) {
   char *buffer1 = 
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


Re: [Freeciv-Dev] (PR#40645) [Patch] Scripting API: city:has_building() player:has_wonder()

2009-01-09 Thread Marko Lindqvist

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40645 

2009/1/8 Marko Lindqvist:

  This patch adds functions city:has_building() and player:has_wonder()
 to scripting API.

 - Better comments


 - ML

diff -Nurd -X.diff_ignore freeciv/server/scripting/api_methods.c 
freeciv/server/scripting/api_methods.c
--- freeciv/server/scripting/api_methods.c  2008-10-27 04:13:34.0 
+0200
+++ freeciv/server/scripting/api_methods.c  2009-01-09 22:39:34.0 
+0200
@@ -226,3 +226,33 @@
 {
   return terrain_name_translation(pterrain);
 }
+
+/**
+  Return TRUE iff city has building
+**/
+bool api_methods_city_has_building(City *pcity, Building_Type *building)
+{
+  return city_has_building(pcity, building);
+}
+
+/**
+  Return TRUE iff player has wonder
+**/
+bool api_methods_player_has_wonder(Player *pplayer, Building_Type *building)
+{
+  int bidx = improvement_index(building);
+
+  if (pplayer-small_wonders[bidx]  0) {
+return TRUE;
+  }
+
+  if (game.info.great_wonders[bidx]  0) {
+struct city *pcity = 
game_find_city_by_number(game.info.great_wonders[bidx]);
+
+if (pcity  player_owns_city(pplayer, pcity)) {
+  return TRUE;
+}
+  }
+
+  return FALSE;
+}
diff -Nurd -X.diff_ignore freeciv/server/scripting/api_methods.h 
freeciv/server/scripting/api_methods.h
--- freeciv/server/scripting/api_methods.h  2007-08-04 18:36:19.0 
+0300
+++ freeciv/server/scripting/api_methods.h  2009-01-09 22:39:06.0 
+0200
@@ -48,5 +48,8 @@
 const char *api_methods_tech_type_name_translation(Tech_Type *ptech);
 const char *api_methods_terrain_rule_name(Terrain *pterrain);
 const char *api_methods_terrain_name_translation(Terrain *pterrain);
-#endif
 
+bool api_methods_city_has_building(City *pcity, Building_Type *building);
+bool api_methods_player_has_wonder(Player *pplayer, Building_Type *building);
+
+#endif /* FC__API_METHODS_H */
diff -Nurd -X.diff_ignore freeciv/server/scripting/api.pkg 
freeciv/server/scripting/api.pkg
--- freeciv/server/scripting/api.pkg2009-01-08 22:45:27.0 +0200
+++ freeciv/server/scripting/api.pkg2009-01-09 22:39:06.0 +0200
@@ -101,6 +101,8 @@
@ methods_player_num_cities (Player *pplayer);
 int api_methods_player_num_units
@ methods_player_num_units (Player *pplayer);
+bool api_methods_player_has_wonder
+@ methods_player_has_wonder (Player *pplayer, Building_Type *building);
 
 /* Iteration */
 void api_iterate_players
@@ -170,6 +172,10 @@
 const char *api_methods_terrain_name_translation
@ methods_terrain_name_translation (Terrain *pterrain);
 
+/* City */
+bool api_methods_city_has_building
+@ methods_city_has_building(City *pcity, Building_Type *building);
+
 $[
 -- Player methods.
 function Player:is_human()
@@ -184,6 +190,10 @@
   return methods_player_num_units(self)
 end
 
+function Player:has_wonder(building)
+  return methods_player_has_wonder(self, building)
+end
+
 -- Unit methods.
 function Unit:get_homecity()
   return find.city(self.owner, self.homecity)
@@ -287,6 +297,11 @@
 function Terrain:name_translation()
   return methods_terrain_name_translation(self)
 end
+
+-- City methods
+function City:has_building(building)
+  return methods_city_has_building(self, building)
+end
 $]
 
 /* Object find module. */
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#40651) ctrl+c does not stop autogame

2009-01-09 Thread Marko Lindqvist

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40651 

 Pressing ctrl+c once for autogame (timeout = -1) prints message 2:
Setting timeout to 0. Autogame will stop., but game continues and
server still accepts no input.


 - ML



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


[Freeciv-Dev] (PR#40644) [Patch] Iteration support to scripting

2009-01-09 Thread Madeline Book

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40644 

 [cazf...@gmail.com - Fri Jan 09 13:32:08 2009]:
 
 2009/1/8 Madeline Book:
 
  It would be nice if one could do
 
  for player in game:players() do
   print player:name()-- or whatever
  end
 
  Lua has a lot of great features for implementing iteration
  cleanly and efficiently: closures, generic for, coroutines,
  and object oriented syntax (see http://www.lua.org/pil/).
  It would be a shame not to make the best use of them. ;)
 
  True, but that does sounds more like 2.3 stuff. I don't see it
 happening in 2.2 timeframe.
 
  I'm somewhat undecided if we should just not include any iteration
 support at all at 2.2, or should we include something like my patch
 for situations where modder desperately needs at least some kind of
 iteration support.

I agree that something is better than nothing. I'm just
unsure how much more work an efficient implementation
would be. I guess the above patch is ok for now...


---
失礼しました。

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


[Freeciv-Dev] (PR#40611) default.serv sets startunits to cccwwx

2009-01-09 Thread Madeline Book

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40611 

 [guest - Mon Jan 05 12:28:43 2009]:
 
  [book - So 28. Dez 2008, 04:24:04]:
  
   [bvanev...@gmail.com - Sat Dec 27 22:33:31 2008]:
   
   [...]
   
   Solution: change line in default.serv to ccwwx
  
  Ok.
 
 The patch seems to be added to trunk?

Yes, it would appear this was already fixed in trunk.


---
この日はもう起こったか。

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


[Freeciv-Dev] (PR#40653) Memory leak when AI finishes building ferry

2009-01-09 Thread Marko Lindqvist

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40653 

==10305== 31,710 bytes in 1,099 blocks are definitely lost in loss
record 12 of 16
==10305==at 0x4C265AE: malloc (vg_replace_malloc.c:207)
==10305==by 0x405D51: fc_real_malloc (mem.c:82)
==10305==by 0x405E66: fc_real_calloc (mem.c:127)
==10305==by 0x4E9536: ai_data_phase_init (aidata.c:377)
==10305==by 0x4EA0C7: ai_data_get (aidata.c:618)
==10305==by 0x4EBE4B: aiferry_init_ferry (aiferry.c:148)
==10305==by 0x48C159: create_unit_full (unittools.c:1411)
==10305==by 0x48C258: create_unit (unittools.c:1335)
==10305==by 0x49BA1A: update_city_activities (cityturn.c:1501)
==10305==by 0x47B282: end_phase (srv_main.c:807)
==10305==by 0x47CF7D: srv_main (srv_main.c:1914)
==10305==by 0x404470: main (civserver.c:283)


 - ML



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


[Freeciv-Dev] (PR#40616) patch: allow 2.1.8 to compile under sun studio community edition 11/08

2009-01-09 Thread Madeline Book

URL: http://bugs.freeciv.org/Ticket/Display.html?id=40616 

 [james.mccl...@gmail.com - Thu Jan 01 04:14:04 2009]:
 
 Hello,
 
 I can confirm that the gtk 2 client does compile smoothly with
 the patch that you sent applied.  I can also build with the
 --enable-debug and --enable-client=sdl versions.  I have
 not tried the other two.

For completeness here is a version of the patch for trunk too
(and a minor formatting fix for the S2_1 version).


---
機知に富んだ何かがここにあったが、もう出た。
diff --git a/client/gui-gtk-2.0/repodlgs.c b/client/gui-gtk-2.0/repodlgs.c
index 587cd69..bf9c920 100644
--- a/client/gui-gtk-2.0/repodlgs.c
+++ b/client/gui-gtk-2.0/repodlgs.c
@@ -1200,7 +1200,7 @@ void activeunits_report_dialog_update(void)
 {
   struct repoinfo {
 int active_count;
-int upkeep[O_COUNT];
+int upkeep[O_MAX];
 int building_count;
   };
 
diff --git a/client/helpdata.c b/client/helpdata.c
index 7920a58..a781794 100644
--- a/client/helpdata.c
+++ b/client/helpdata.c
@@ -259,39 +259,39 @@ static void insert_allows(struct universal *psource,
   buf[0] = '\0';
 
   /* FIXME: show other data like range and survives. */
-#define COREQ_APPEND(s)			\
-  (coreq_buf[0] != '\0'			\
-   ? cat_snprintf(coreq_buf, sizeof(coreq_buf), Q_(?clistmore:, %s), (s))  \
-   : sz_strlcpy(coreq_buf, (s)))
 
   improvement_iterate(pimprove) {
 requirement_vector_iterate(pimprove-reqs, req) {
   if (are_universals_equal(psource, req-source)) {
-	char coreq_buf[512] = ;
-
-	requirement_vector_iterate(pimprove-reqs, coreq) {
-	  if (!are_universals_equal(psource, coreq-source)) {
-	char buf2[512];
-
-	COREQ_APPEND(universal_name_translation(coreq-source,
-	 buf2, sizeof(buf2)));
-	  }
-	} requirement_vector_iterate_end;
-
-	if (coreq_buf[0] == '\0') {
-	  cat_snprintf(buf, bufsz, _(Allows %s.),
-		   improvement_name_translation(pimprove));
-	} else {
-	  cat_snprintf(buf, bufsz, _(Allows %s (with %s).),
-		   improvement_name_translation(pimprove),
-		   coreq_buf);
-	}
-	cat_snprintf(buf, bufsz, \n);
+char coreq_buf[512] = ;
+
+requirement_vector_iterate(pimprove-reqs, coreq) {
+  if (!are_universals_equal(psource, coreq-source)) {
+char buf2[512] = ;
+
+universal_name_translation(coreq-source, buf2,
+   sizeof(buf2));
+if (coreq_buf[0] == '\0') {
+  sz_strlcpy(coreq_buf, buf2);
+} else {
+  cat_snprintf(coreq_buf, sizeof(coreq_buf),
+   Q_(?clistmore:, %s), buf2);
+}
+  }
+} requirement_vector_iterate_end;
+
+if (coreq_buf[0] == '\0') {
+  cat_snprintf(buf, bufsz, _(Allows %s.),
+   improvement_name_translation(pimprove));
+} else {
+  cat_snprintf(buf, bufsz, _(Allows %s (with %s).),
+   improvement_name_translation(pimprove),
+   coreq_buf);
+}
+cat_snprintf(buf, bufsz, \n);
   }
 } requirement_vector_iterate_end;
   } improvement_iterate_end;
-
-#undef COREQ_APPEND
 }
 
 /
diff --git a/client/gui-gtk-2.0/repodlgs.c b/client/gui-gtk-2.0/repodlgs.c
index 7f40ea1..1272966 100644
--- a/client/gui-gtk-2.0/repodlgs.c
+++ b/client/gui-gtk-2.0/repodlgs.c
@@ -1178,7 +1178,7 @@ void activeunits_report_dialog_update(void)
 {
   struct repoinfo {
 int active_count;
-int upkeep[O_COUNT];
+int upkeep[O_MAX];
 int building_count;
   };
 
diff --git a/client/helpdata.c b/client/helpdata.c
index 45850e2..fa8f6be 100644
--- a/client/helpdata.c
+++ b/client/helpdata.c
@@ -237,42 +237,40 @@ static void insert_allows(struct req_source *psource,
   buf[0] = '\0';
 
   /* FIXME: show other data like range and survives. */
-#define COREQ_APPEND(s)			\
-  (coreq_buf[0] != '\0'			\
-   ? cat_snprintf(coreq_buf, sizeof(coreq_buf), Q_(?clistmore:, %s), (s))  \
-   : sz_strlcpy(coreq_buf, (s)))
-
 
   impr_type_iterate(impr_id) {
 struct impr_type *building = improvement_by_number(impr_id);
 
 requirement_vector_iterate(building-reqs, req) {
   if (are_req_sources_equal(psource, req-source)) {
-	char coreq_buf[512] = ;
-
-	requirement_vector_iterate(building-reqs, coreq) {
-	  if (!are_req_sources_equal(psource, coreq-source)) {
-	char buf2[512];
-
-	COREQ_APPEND(get_req_source_text(coreq-source,
-	 buf2, sizeof(buf2)));
-	  }
-	} requirement_vector_iterate_end;
+char coreq_buf[512] = ;
+
+requirement_vector_iterate(building-reqs, coreq) {
+  if (!are_req_sources_equal(psource, coreq-source)) {
+char buf2[512] = ;
+
+get_req_source_text(coreq-source, buf2, sizeof(buf2));
+if (coreq_buf[0] == '\0') {
+  sz_strlcpy(coreq_buf, buf2);
+} else