[Freeciv-Dev] (PR#40561) [Editor] Remove server-only editor stuff from common/ files

2008-11-16 Thread Madeline Book

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

Version 3 fixes a mistake in edithand_init().


---
見つけられますか?
commit 84e305391f23dbaeafc8c4891e0ededba8ffa364
Author: Madeline Book <[EMAIL PROTECTED]>
Date:   Sun Nov 16 21:55:35 2008 -0500

no_server_editor_stuff_in_common_v3.patch
---
 common/map.c   |1 -
 common/player.h|3 --
 common/tile.h  |3 --
 server/Makefile.am |1 +
 server/edithand.c  |   87 +--
 server/edithand.h  |   19 +++
 server/plrhand.c   |1 -
 server/srv_main.c  |3 ++
 8 files changed, 86 insertions(+), 32 deletions(-)

diff --git a/common/map.c b/common/map.c
index 27d372f..e5a6685 100644
--- a/common/map.c
+++ b/common/map.c
@@ -288,7 +288,6 @@ static void tile_init(struct tile *ptile)
   ptile->owner= NULL; /* Not claimed by any player. */
   ptile->worked   = NULL; /* No city working here. */
   ptile->spec_sprite = NULL;
-  ptile->editor.need_terrain_fix = FALSE;
 }
 
 /
diff --git a/common/player.h b/common/player.h
index a35400e..824cbaa 100644
--- a/common/player.h
+++ b/common/player.h
@@ -203,9 +203,6 @@ struct player {
   struct attribute_block_s attribute_block;
   struct attribute_block_s attribute_block_buffer;
   bv_debug debug;
-  struct {
-bool fog_of_war_disabled;
-  } editor;
 };
 
 /* A slot is a possibly uninitialized player. */
diff --git a/common/tile.h b/common/tile.h
index 93e7a5d..8c886d0 100644
--- a/common/tile.h
+++ b/common/tile.h
@@ -46,9 +46,6 @@ struct tile {
   struct player *owner;			/* NULL for not owned */
   struct city *worked;			/* NULL for not worked */
   char *spec_sprite;
-  struct {
-bool need_terrain_fix; /* Server only. */
-  } editor;
 };
 
 /* get 'struct tile_list' and related functions: */
diff --git a/server/Makefile.am b/server/Makefile.am
index 09f5812..7e570db 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -42,6 +42,7 @@ libcivserver_a_SOURCES = \
 		diplomats.c	\
 		diplomats.h	\
 		edithand.c	\
+		edithand.h	\
 		gamehand.c	\
 		gamehand.h	\
 		gotohand.c	\
diff --git a/server/edithand.c b/server/edithand.c
index a17a88d..7508342 100644
--- a/server/edithand.c
+++ b/server/edithand.c
@@ -36,6 +36,7 @@
 #include "citytools.h"
 #include "cityturn.h"
 #include "connecthand.h"
+#include "edithand.h"
 #include "gamehand.h"
 #include "hand_gen.h"
 #include "maphand.h"
@@ -46,28 +47,64 @@
 #include "unittools.h"
 #include "utilities.h"
 
-/* The number of tiles for which expensive checks have
- * been deferred after their terrains have been edited. */
-static int unfixed_terrain_count;
+/* This table holds pointers to tiles for which expensive
+ * checks (e.g. assign_continent_numbers) have been left
+ * until after a sequence of edits is complete. */
+static struct hash_table *unfixed_tile_table;
 
+/* Array of size player_slot_count() indexed by player
+ * number to tell whether a given player has fog of war
+ * disabled in edit mode. */
+static bool *unfogged_players;
+
+/
+  Initialize data structures required for edit mode.
+/
+void edithand_init(void)
+{
+  if (unfixed_tile_table != NULL) {
+hash_free(unfixed_tile_table);
+  }
+  unfixed_tile_table = hash_new(hash_fval_keyval, hash_fcmp_keyval);
+
+  if (unfogged_players != NULL) {
+free(unfogged_players);
+  }
+  unfogged_players = fc_calloc(player_slot_count(), sizeof(bool));
+}
+
+/
+  Free all memory used by data structures required for edit mode.
+/
+void edithand_free(void)
+{
+  if (unfixed_tile_table != NULL) {
+hash_free(unfixed_tile_table);
+unfixed_tile_table = NULL;
+  }
+
+  if (unfogged_players != NULL) {
+free(unfogged_players);
+unfogged_players = NULL;
+  }
+}
 
 /
   Do the potentially slow checks required after some tile's terrain changes.
 /
 static void check_edited_tile_terrains(void)
 {
-  if (unfixed_terrain_count > 0) {
-whole_map_iterate(ptile) {
-  if (!ptile->editor.need_terrain_fix) {
-continue;
-  }
-  fix_tile_on_terrain_change(ptile, FALSE);
-  ptile->editor.need_terrain_fix = FALSE;
-} whole_map_iterate_end;
-assign_continent_numbers();
-send_all_known_tiles(NULL);
+  if (hash_num_entries(unfixed_tile_table) < 1) {
+return;
   }
-  unfixed_terrain_count = 0;
+
+  hash_iterate(unfixed_tile_table, ptile, dummy) {
+fix_tile_on_terrain_change(ptile, FALSE);
+  } hash_ite

[Freeciv-Dev] (PR#40561) [Editor] Remove server-only editor stuff from common/ files

2008-11-12 Thread Madeline Book

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

> [book - Thu Nov 13 01:13:56 2008]:
> 
> Forgot to include server/edithand.h in the last patch.

Which I forgot to actually attach to that reply... :(


---
外でただの散歩だけですよ。
commit 7060c10f42c18ed42b1c4292c08bbffad5b8f5e6
Author: Madeline Book <[EMAIL PROTECTED]>
Date:   Wed Nov 12 20:11:56 2008 -0500

no_server_editor_stuff_in_common_v2.patch
---
 common/map.c   |1 -
 common/player.h|3 --
 common/tile.h  |3 --
 server/Makefile.am |1 +
 server/edithand.c  |   86 +--
 server/edithand.h  |   19 +++
 server/plrhand.c   |1 -
 server/srv_main.c  |3 ++
 8 files changed, 85 insertions(+), 32 deletions(-)

diff --git a/common/map.c b/common/map.c
index 27d372f..e5a6685 100644
--- a/common/map.c
+++ b/common/map.c
@@ -288,7 +288,6 @@ static void tile_init(struct tile *ptile)
   ptile->owner= NULL; /* Not claimed by any player. */
   ptile->worked   = NULL; /* No city working here. */
   ptile->spec_sprite = NULL;
-  ptile->editor.need_terrain_fix = FALSE;
 }
 
 /
diff --git a/common/player.h b/common/player.h
index a35400e..824cbaa 100644
--- a/common/player.h
+++ b/common/player.h
@@ -203,9 +203,6 @@ struct player {
   struct attribute_block_s attribute_block;
   struct attribute_block_s attribute_block_buffer;
   bv_debug debug;
-  struct {
-bool fog_of_war_disabled;
-  } editor;
 };
 
 /* A slot is a possibly uninitialized player. */
diff --git a/common/tile.h b/common/tile.h
index 93e7a5d..8c886d0 100644
--- a/common/tile.h
+++ b/common/tile.h
@@ -46,9 +46,6 @@ struct tile {
   struct player *owner;			/* NULL for not owned */
   struct city *worked;			/* NULL for not worked */
   char *spec_sprite;
-  struct {
-bool need_terrain_fix; /* Server only. */
-  } editor;
 };
 
 /* get 'struct tile_list' and related functions: */
diff --git a/server/Makefile.am b/server/Makefile.am
index 09f5812..7e570db 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -42,6 +42,7 @@ libcivserver_a_SOURCES = \
 		diplomats.c	\
 		diplomats.h	\
 		edithand.c	\
+		edithand.h	\
 		gamehand.c	\
 		gamehand.h	\
 		gotohand.c	\
diff --git a/server/edithand.c b/server/edithand.c
index a17a88d..15fad95 100644
--- a/server/edithand.c
+++ b/server/edithand.c
@@ -36,6 +36,7 @@
 #include "citytools.h"
 #include "cityturn.h"
 #include "connecthand.h"
+#include "edithand.h"
 #include "gamehand.h"
 #include "hand_gen.h"
 #include "maphand.h"
@@ -46,28 +47,65 @@
 #include "unittools.h"
 #include "utilities.h"
 
-/* The number of tiles for which expensive checks have
- * been deferred after their terrains have been edited. */
-static int unfixed_terrain_count;
+/* This table holds pointers to tiles for which expensive
+ * checks (e.g. assign_continent_numbers) have been left
+ * until after a sequence of edits is complete. */
+static struct hash_table *unfixed_tile_table;
 
+/* Array of size player_slot_count() indexed by player
+ * number to tell whether a given player has fog of war
+ * disabled in edit mode. */
+static bool *unfogged_players;
+
+/
+  Initialize data structures required for edit mode.
+/
+void edithand_init(void)
+{
+  if (unfixed_tile_table != NULL) {
+hash_free(unfixed_tile_table);
+  }
+  unfixed_tile_table = hash_new(hash_fval_keyval, hash_fcmp_keyval);
+
+  if (!unfogged_players) {
+free(unfogged_players);
+  }
+  unfogged_players = fc_calloc(player_slot_count(), sizeof(bool));
+}
+
+/
+  Free all memory used by data structures required for edit mode.
+/
+void edithand_free(void)
+{
+  if (unfixed_tile_table != NULL) {
+hash_free(unfixed_tile_table);
+unfixed_tile_table = NULL;
+  }
+
+  if (unfogged_players != NULL) {
+free(unfogged_players);
+unfogged_players = NULL;
+  }
+}
 
 /
   Do the potentially slow checks required after some tile's terrain changes.
 /
 static void check_edited_tile_terrains(void)
 {
-  if (unfixed_terrain_count > 0) {
-whole_map_iterate(ptile) {
-  if (!ptile->editor.need_terrain_fix) {
-continue;
-  }
-  fix_tile_on_terrain_change(ptile, FALSE);
-  ptile->editor.need_terrain_fix = FALSE;
-} whole_map_iterate_end;
-assign_continent_numbers();
-send_all_known_tiles(NULL);
+  if (hash_num_entries(unfixed_tile_table) < 1) {
+return;
   }
-  unfixed_terrain_count = 0;
+
+  hash_i

[Freeciv-Dev] (PR#40561) [Editor] Remove server-only editor stuff from common/ files

2008-11-12 Thread Madeline Book

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

Forgot to include server/edithand.h in the last patch.


---
どこへ行くつもりですか。
___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] (PR#40561) [Editor] Remove server-only editor stuff from common/ files

2008-11-12 Thread Madeline Book

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

Attached patch removes some struct fields in struct player
and struct tile that were only used by the server for editor
related support code. Instead, static data structures are
added to edithand.c which keep track of the necessary
information. This then requires the addition of edithand.h
(added to server/Makefile.am) and module initialization/
destruction functions edithand_{init,free}.


---
汚染削減委員会の作戦だった。
 common/map.c   |1 -
 common/player.h|3 --
 common/tile.h  |3 --
 server/Makefile.am |1 +
 server/edithand.c  |   86 +--
 server/plrhand.c   |1 -
 server/srv_main.c  |3 ++
 7 files changed, 66 insertions(+), 32 deletions(-)

diff --git a/common/map.c b/common/map.c
index 27d372f..e5a6685 100644
--- a/common/map.c
+++ b/common/map.c
@@ -288,7 +288,6 @@ static void tile_init(struct tile *ptile)
   ptile->owner= NULL; /* Not claimed by any player. */
   ptile->worked   = NULL; /* No city working here. */
   ptile->spec_sprite = NULL;
-  ptile->editor.need_terrain_fix = FALSE;
 }
 
 /
diff --git a/common/player.h b/common/player.h
index a35400e..824cbaa 100644
--- a/common/player.h
+++ b/common/player.h
@@ -203,9 +203,6 @@ struct player {
   struct attribute_block_s attribute_block;
   struct attribute_block_s attribute_block_buffer;
   bv_debug debug;
-  struct {
-bool fog_of_war_disabled;
-  } editor;
 };
 
 /* A slot is a possibly uninitialized player. */
diff --git a/common/tile.h b/common/tile.h
index 93e7a5d..8c886d0 100644
--- a/common/tile.h
+++ b/common/tile.h
@@ -46,9 +46,6 @@ struct tile {
   struct player *owner;			/* NULL for not owned */
   struct city *worked;			/* NULL for not worked */
   char *spec_sprite;
-  struct {
-bool need_terrain_fix; /* Server only. */
-  } editor;
 };
 
 /* get 'struct tile_list' and related functions: */
diff --git a/server/Makefile.am b/server/Makefile.am
index 09f5812..7e570db 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -42,6 +42,7 @@ libcivserver_a_SOURCES = \
 		diplomats.c	\
 		diplomats.h	\
 		edithand.c	\
+		edithand.h	\
 		gamehand.c	\
 		gamehand.h	\
 		gotohand.c	\
diff --git a/server/edithand.c b/server/edithand.c
index a17a88d..15fad95 100644
--- a/server/edithand.c
+++ b/server/edithand.c
@@ -36,6 +36,7 @@
 #include "citytools.h"
 #include "cityturn.h"
 #include "connecthand.h"
+#include "edithand.h"
 #include "gamehand.h"
 #include "hand_gen.h"
 #include "maphand.h"
@@ -46,28 +47,65 @@
 #include "unittools.h"
 #include "utilities.h"
 
-/* The number of tiles for which expensive checks have
- * been deferred after their terrains have been edited. */
-static int unfixed_terrain_count;
+/* This table holds pointers to tiles for which expensive
+ * checks (e.g. assign_continent_numbers) have been left
+ * until after a sequence of edits is complete. */
+static struct hash_table *unfixed_tile_table;
 
+/* Array of size player_slot_count() indexed by player
+ * number to tell whether a given player has fog of war
+ * disabled in edit mode. */
+static bool *unfogged_players;
+
+/
+  Initialize data structures required for edit mode.
+/
+void edithand_init(void)
+{
+  if (unfixed_tile_table != NULL) {
+hash_free(unfixed_tile_table);
+  }
+  unfixed_tile_table = hash_new(hash_fval_keyval, hash_fcmp_keyval);
+
+  if (!unfogged_players) {
+free(unfogged_players);
+  }
+  unfogged_players = fc_calloc(player_slot_count(), sizeof(bool));
+}
+
+/
+  Free all memory used by data structures required for edit mode.
+/
+void edithand_free(void)
+{
+  if (unfixed_tile_table != NULL) {
+hash_free(unfixed_tile_table);
+unfixed_tile_table = NULL;
+  }
+
+  if (unfogged_players != NULL) {
+free(unfogged_players);
+unfogged_players = NULL;
+  }
+}
 
 /
   Do the potentially slow checks required after some tile's terrain changes.
 /
 static void check_edited_tile_terrains(void)
 {
-  if (unfixed_terrain_count > 0) {
-whole_map_iterate(ptile) {
-  if (!ptile->editor.need_terrain_fix) {
-continue;
-  }
-  fix_tile_on_terrain_change(ptile, FALSE);
-  ptile->editor.need_terrain_fix = FALSE;
-} whole_map_iterate_end;
-assign_continent_numbers();
-send_all_known_tiles(NULL);
+  if (hash_num_entries(unfixed_tile_table) < 1) {
+return;
   }
-  unfixed_terrain_