Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2005:
[Freeciv-Dev] Re: (PR#13727) CVS: Global /observe assert
Home

[Freeciv-Dev] Re: (PR#13727) CVS: Global /observe assert

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: yautja@xxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#13727) CVS: Global /observe assert
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 20 Aug 2005 21:07:06 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=13727 >

Brendon wrote:
> <URL: http://bugs.freeciv.org/Ticket/Display.html?id=13727 >
> 
> Latest CVS, Me vs Ai's, works ok if you /obs <player> but asserts on 
> global /obs.
> 
> civclient: tilespec.c:4368: get_government_sprite: Assertion `0' failed.
> Abort

Here's a patch.

Probably we should have a placeholder sprite for this case (and for the 
research gfx too).

-jason

Index: client/text.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/text.c,v
retrieving revision 1.47
diff -p -u -r1.47 text.c
--- client/text.c       19 Aug 2005 20:57:53 -0000      1.47
+++ client/text.c       21 Aug 2005 04:05:56 -0000
@@ -659,8 +659,13 @@ const char *get_government_tooltip(void)
 
   astr_clear(&str);
 
-  astr_add(&str, _("Shows your current government:\n%s."),
-      get_government_name(game.player_ptr->government));
+  if (game.player_ptr->government) {
+    astr_add(&str, _("Shows your current government:\n%s."),
+            get_government_name(game.player_ptr->government));
+  } else {
+    /* For observer mode */
+    astr_add(&str, _("Shows your current government"));
+  }
   return str.str;
 }
 
Index: client/tilespec.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/tilespec.c,v
retrieving revision 1.321
diff -p -u -r1.321 tilespec.c
--- client/tilespec.c   2 Aug 2005 02:40:58 -0000       1.321
+++ client/tilespec.c   21 Aug 2005 04:05:59 -0000
@@ -4364,8 +4364,9 @@ struct sprite *get_building_sprite(const
 struct sprite *get_government_sprite(const struct tileset *t,
                                     const struct government *gov)
 {
-  if (!gov || gov->index < 0 || gov->index >= game.control.government_count) {
-    assert(0);
+  if (!gov) {
+    /* This will happen for observers.  Maybe we should have a placeholder
+     * sprite...*/
     return NULL;
   }
   return t->sprites.government[gov->index];

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] Re: (PR#13727) CVS: Global /observe assert, Jason Short <=