summaryrefslogtreecommitdiff
blob: 1458b7ba1dfdf3be4dfddd17adca90f6a1e8c5eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
--- src/starchart.c
+++ src/starchart.c
@@ -3187,10 +3187,16 @@
 /**
  * Initializes starchart constellations.
  */
+static GSList *planets;
+
+static void add_item (gpointer key, gpointer value, gpointer user_data) {
+  /*    GSList *p_list = (GSList *)user_data; */
+  planets = g_slist_append (planets, value);
+}
+
 static void 
 init_starchart_constellations (void)
 {
-  GSList *planets = NULL;
   GSList *ppq[TOTAL_QUADS];
   GSList *list_nearby = NULL;
   GwpPlanet *planet_a, *planet_b;
@@ -3199,10 +3205,6 @@
   gdouble wx, wy;
   gdouble ax, ay, bx, by, zoom;
 
-  static void add_item (gpointer key, gpointer value, gpointer user_data) {
-    /*    GSList *p_list = (GSList *)user_data; */
-    planets = g_slist_append (planets, value);
-  }
 
   g_hash_table_foreach (planet_list, (GHFunc)add_item, NULL);
   
--- src/vcr.c
+++ src/vcr.c
@@ -2687,12 +2687,29 @@
   return( retval );
 }
 
+static gchar *name;
+
+static void foreach_func( gpointer key, gpointer value, gpointer user_data )
+{
+  GwpShip *ship = GWP_SHIP( value );
+  GtkComboBox *box = GTK_COMBO_BOX( lookup_widget( "vcr_comboboxentry_sel_ext_shp_a" ) );
+  gint *idlist = (gint *)g_object_get_data(G_OBJECT(lookup_widget("vcr_comboboxentry_sel_ext_shp_a")), "shipidlist");
+  gint curr = idlist[0];
+
+  if( gwp_ship_is_mine( ship ) )
+  {
+    curr++;
+    idlist[curr] = gwp_object_get_id( GWP_OBJECT(ship) );
+    idlist[0]++;
+    g_sprintf( name, "%03d: ", idlist[curr] );
+    strncat( name, gwp_object_get_name (GWP_OBJECT(ship)), 50 );
+    gtk_combo_box_append_text( box, name );
+  }
+}
 
 void vcr_populate_ship_a_list( GtkWidget *widget, gpointer user_data )
 {
-  gchar *name;
   gint *idlist;
-  static void foreach_func( gpointer key, gpointer value, gpointer user_data );
 
   /* test if list is already populated */
   idlist = (gint *)g_object_get_data(G_OBJECT(lookup_widget("vcr_comboboxentry_sel_ext_shp_a")), "shipidlist");
@@ -2708,23 +2725,7 @@
   GtkWidget *combox = lookup_widget("vcr_comboboxentry_sel_ext_shp_a");
   g_object_set_data(G_OBJECT(combox), "shipidlist", idlist );
 
-  void foreach_func( gpointer key, gpointer value, gpointer user_data )
-  {
-    GwpShip *ship = GWP_SHIP( value );
-    GtkComboBox *box = GTK_COMBO_BOX( lookup_widget( "vcr_comboboxentry_sel_ext_shp_a" ) );
-    gint *idlist = (gint *)g_object_get_data(G_OBJECT(lookup_widget("vcr_comboboxentry_sel_ext_shp_a")), "shipidlist");
-    gint curr = idlist[0];
 
-    if( gwp_ship_is_mine( ship ) )
-    {
-      curr++;
-      idlist[curr] = gwp_object_get_id( GWP_OBJECT(ship) );
-      idlist[0]++;
-      g_sprintf( name, "%03d: ", idlist[curr] );
-      strncat( name, gwp_object_get_name (GWP_OBJECT(ship)), 50 );
-      gtk_combo_box_append_text( box, name );
-    }
-  }
 
   g_hash_table_foreach( ship_list, (GHFunc) foreach_func, user_data );