Complete.Org: Mailing Lists: Archives: freeciv-dev: November 2002:
[Freeciv-Dev] (PR#2363) bugs when switching tilesets
Home

[Freeciv-Dev] (PR#2363) bugs when switching tilesets

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#2363) bugs when switching tilesets
From: "Jason Short via RT" <rt@xxxxxxxxxxxxxx>
Date: Tue, 19 Nov 2002 15:14:43 -0800
Reply-to: rt@xxxxxxxxxxxxxx

[jdorje - Tue Nov 19 19:57:30 2002]:

> If you switch tilesets while the client is in the wrong state, bad
> things will happen.

This patch also fixes most/all of the memory leaks with this feature.

jason

? client/gui-gtk/diff
? client/gui-stub/stub-update.diff
? client/gui-xaw/diff
Index: client//tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.90
diff -u -r1.90 tilespec.c
--- client//tilespec.c  2002/11/19 23:04:27     1.90
+++ client//tilespec.c  2002/11/19 23:12:05
@@ -42,6 +42,7 @@
 #include "support.h"
 #include "unit.h"
 
+#include "civclient.h" /* for get_client_state() */
 #include "climisc.h" /* for tile_get_known() */
 #include "control.h" /* for fill_xxx */
 #include "graphics_g.h"
@@ -268,6 +269,7 @@
 {
   int id;
   int center_x, center_y;
+  enum client_states state = get_client_state();
 
   freelog(LOG_NORMAL, "Loading tileset %s.", tileset_name);
 
@@ -279,11 +281,10 @@
 
   /* Step 1:  Cleanup.
    *
-   * We free any old data in preparation for re-reading it. This is
-   * pretty certainly incomplete, although the memory leak doesn't seem
-   * to be debilitating.
+   * We free all old data in preparation for re-reading it.
    */
-  hash_free(sprite_hash);
+  tilespec_free_tiles();
+  tilespec_free_city_tiles(game.styles_count);
   tilespec_free_toplevel();
 
   /* Step 2:  Read.
@@ -308,6 +309,10 @@
    * doesn't mess up too badly if we change tilesets while not connected
    * to a server.
    */
+  if (state < CLIENT_SELECT_RACE_STATE) {
+    /* The ruleset data is not sent until this point. */
+    return;
+  }
   for (id = T_FIRST; id < T_COUNT; id++) {
     tilespec_setup_tile_type(id);
   }
@@ -332,6 +337,11 @@
    *
    * Do any necessary redraws.
    */
+  if (state < CLIENT_GAME_RUNNING_STATE) {
+    /* Unless the client state is playing a game or in gameover,
+       we don't want/need to redraw. */
+    return;
+  }
   tileset_changed();
   center_tile_mapcanvas(center_x, center_y);
 }

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#2363) bugs when switching tilesets, Jason Short via RT <=