Crossfire Client, Branch  R11627
pickup.c
Go to the documentation of this file.
00001 const char * const rcsid_gtk2_pickup_c =
00002     "$Id: pickup.c 9200 2008-06-01 17:12:43Z anmaster $";
00003 
00004 /*
00005     Crossfire client, a client program for the crossfire program.
00006 
00007     Copyright (C) 2005-2007 Mark Wedel & Crossfire Development Team
00008 
00009     This program is free software; you can redistribute it and/or modify
00010     it under the terms of the GNU General Public License as published by
00011     the Free Software Foundation; either version 2 of the License, or
00012     (at your option) any later version.
00013 
00014     This program is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017     GNU General Public License for more details.
00018 
00019     You should have received a copy of the GNU General Public License
00020     along with this program; if not, write to the Free Software
00021     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00022 
00023     The author can be reached via e-mail to crossfire@metalforge.org
00024 */
00025 
00033 #ifdef HAVE_CONFIG_H
00034 #  include <config.h>
00035 #endif
00036 
00037 #include <gtk/gtk.h>
00038 #include <glade/glade.h>
00039 
00040 #include "main.h"
00041 #include "client.h"
00042 #include "image.h"
00043 #include "gtk2proto.h"
00044 
00045 typedef struct {
00046     GtkWidget   *menuitem;
00047     uint32      pickup_mode;
00048 } PickupMapping;
00049 
00050 #define MAX_PICKUPS 50
00051 
00052 PickupMapping pickup_mapping[MAX_PICKUPS];
00053 static int num_pickups=0;
00054 
00055 /*
00056  * Definitions for detailed pickup descriptions.  The objective is to define
00057  * intelligent groups of items that the user can pick up or leave as he likes.
00058  */
00059 
00060 /* High bit as flag for new pickup options */
00061 #define PU_NOTHING              0x00000000
00062 
00063 #define PU_DEBUG                0x10000000
00064 #define PU_INHIBIT              0x20000000
00065 #define PU_STOP                 0x40000000
00066 #define PU_NEWMODE              0x80000000
00067 
00068 #define PU_RATIO                0x0000000F
00069 
00070 #define PU_FOOD                 0x00000010
00071 #define PU_DRINK                0x00000020
00072 #define PU_VALUABLES            0x00000040
00073 #define PU_BOW                  0x00000080
00074 
00075 #define PU_ARROW                0x00000100
00076 #define PU_HELMET               0x00000200
00077 #define PU_SHIELD               0x00000400
00078 #define PU_ARMOUR               0x00000800
00079 
00080 #define PU_BOOTS                0x00001000
00081 #define PU_GLOVES               0x00002000
00082 #define PU_CLOAK                0x00004000
00083 #define PU_KEY                  0x00008000
00084 
00085 #define PU_MISSILEWEAPON        0x00010000
00086 #define PU_ALLWEAPON            0x00020000
00087 #define PU_MAGICAL              0x00040000
00088 #define PU_POTION               0x00080000
00089 
00090 #define PU_SPELLBOOK            0x00100000
00091 #define PU_SKILLSCROLL          0x00200000
00092 #define PU_READABLES            0x00400000
00093 #define PU_MAGIC_DEVICE         0x00800000
00094 
00095 #define PU_NOT_CURSED           0x01000000
00096 #define PU_JEWELS               0x02000000
00097 #define PU_FLESH                0x04000000
00098 
00099 static unsigned int pmode=0, no_recurse=0;
00100 
00108 static void new_menu_pickup(int on, int val)
00109 {
00110     char modestr[128];
00111 
00112     if (no_recurse) return;
00113 
00114     if (on)
00115         pmode |= val | PU_NEWMODE;
00116     else
00117         pmode &= ~val;
00118 
00119     draw_info("To set this pickup mode to a key, use:",NDI_BLACK);
00120 
00121     snprintf(modestr, sizeof(modestr), "bind pickup %u",pmode);
00122     draw_info(modestr,NDI_BLACK);
00123     snprintf(modestr, sizeof(modestr), "pickup %u",pmode);
00124     send_command(modestr, -1, 0);
00125 }
00126 
00127 void
00128 on_menu_dont_pickup_activate           (GtkMenuItem     *menuitem,
00129                                         gpointer         user_data)
00130 {
00131     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), PU_INHIBIT);
00132 }
00133 
00134 void
00135 on_menu_stop_before_pickup_activate    (GtkMenuItem     *menuitem,
00136                                         gpointer         user_data)
00137 {
00138     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), PU_STOP);
00139 }
00140 
00141 /***************************************************************************
00142  * armor pickup options
00143  **************************************************************************/
00144 
00145 void
00146 on_menu_body_armor_activate            (GtkMenuItem     *menuitem,
00147                                         gpointer         user_data)
00148 {
00149     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), PU_ARMOUR);
00150 }
00151 
00152 void
00153 on_menu_boots_activate                 (GtkMenuItem     *menuitem,
00154                                         gpointer         user_data)
00155 {
00156     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), PU_BOOTS);
00157 }
00158 
00159 void
00160 on_menu_cloaks_activate                (GtkMenuItem     *menuitem,
00161                                         gpointer         user_data)
00162 {
00163     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), PU_CLOAK);
00164 }
00165 
00166 void
00167 on_menu_gloves_activate                (GtkMenuItem     *menuitem,
00168                                         gpointer         user_data)
00169 {
00170     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), PU_GLOVES);
00171 }
00172 
00173 void
00174 on_menu_helmets_activate               (GtkMenuItem     *menuitem,
00175                                         gpointer         user_data)
00176 {
00177     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), PU_HELMET);
00178 }
00179 
00180 void
00181 on_menu_shields_activate               (GtkMenuItem     *menuitem,
00182                                         gpointer         user_data)
00183 {
00184     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), PU_SHIELD);
00185 }
00186 
00187 /***************************************************************************
00188  * Books submenu
00189  ****************************************************************************/
00190 
00191 void
00192 on_menu_skillscrolls_activate          (GtkMenuItem     *menuitem,
00193                                         gpointer         user_data)
00194 {
00195     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), PU_SKILLSCROLL);
00196 }
00197 
00198 
00199 void
00200 on_menu_normal_book_scrolls_activate   (GtkMenuItem     *menuitem,
00201                                         gpointer         user_data)
00202 {
00203     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), PU_READABLES);
00204 }
00205 
00206 
00207 void
00208 on_menu_spellbooks_activate            (GtkMenuItem     *menuitem,
00209                                         gpointer         user_data)
00210 {
00211     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), PU_SPELLBOOK);
00212 }
00213 
00214 /***************************************************************************/
00215 
00216 void
00217 on_menu_drinks_activate                (GtkMenuItem     *menuitem,
00218                                         gpointer         user_data)
00219 {
00220     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), PU_DRINK);
00221 }
00222 
00223 void
00224 on_menu_food_activate                  (GtkMenuItem     *menuitem,
00225                                         gpointer         user_data)
00226 {
00227     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), PU_FOOD);
00228 }
00229 
00230 void
00231 on_menu_keys_activate                  (GtkMenuItem     *menuitem,
00232                                         gpointer         user_data)
00233 {
00234     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), PU_KEY);
00235 }
00236 
00237 void
00238 on_menu_magical_items_activate         (GtkMenuItem     *menuitem,
00239                                         gpointer         user_data)
00240 {
00241     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), PU_MAGICAL);
00242 }
00243 
00244 void
00245 on_menu_potions_activate                (GtkMenuItem     *menuitem,
00246                                         gpointer         user_data)
00247 {
00248     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), PU_POTION);
00249 }
00250 
00251 void
00252 on_menu_valuables_activate             (GtkMenuItem     *menuitem,
00253                                         gpointer         user_data)
00254 {
00255     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), PU_VALUABLES);
00256 }
00257 
00258 void
00259 on_menu_wands_rods_horns_activate      (GtkMenuItem     *menuitem,
00260                                         gpointer         user_data)
00261 {
00262     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), PU_MAGIC_DEVICE);
00263 }
00264 
00265 void
00266 on_menu_not_cursed_activate            (GtkMenuItem     *menuitem,
00267                                         gpointer         user_data)
00268 {
00269     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), PU_NOT_CURSED);
00270 }
00271 
00272 void
00273 on_menu_jewels_activate                  (GtkMenuItem     *menuitem,
00274                                         gpointer         user_data)
00275 {
00276     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), PU_JEWELS);
00277 }
00278 
00279 void
00280 on_menu_flesh_activate                  (GtkMenuItem     *menuitem,
00281                                         gpointer         user_data)
00282 {
00283     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), PU_FLESH);
00284 }
00285 
00286 /***************************************************************************
00287  * Weapons submenu
00288  ***************************************************************************/
00289 
00290 void
00291 on_menu_all_weapons_activate           (GtkMenuItem     *menuitem,
00292                                         gpointer         user_data)
00293 {
00294     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), PU_ALLWEAPON);
00295 }
00296 
00297 void
00298 on_menu_missile_weapons_activate       (GtkMenuItem     *menuitem,
00299                                         gpointer         user_data)
00300 {
00301     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), PU_MISSILEWEAPON);
00302 }
00303 
00304 void
00305 on_menu_bows_activate                  (GtkMenuItem     *menuitem,
00306                                         gpointer         user_data)
00307 {
00308     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), PU_BOW);
00309 }
00310 
00311 void
00312 on_menu_arrows_activate                (GtkMenuItem     *menuitem,
00313                                         gpointer         user_data)
00314 {
00315     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), PU_ARROW);
00316 }
00317 
00318 /***************************************************************************
00319  * Weight/value submenu
00320  ***************************************************************************/
00321 
00322 void
00323 on_menu_ratio_pickup_off_activate       (GtkMenuItem     *menuitem,
00324                                         gpointer         user_data)
00325 {
00326     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), 0);
00327 }
00328 
00329 void
00330 on_menu_ratio_5_activate               (GtkMenuItem     *menuitem,
00331                                         gpointer         user_data)
00332 {
00333     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), 1);
00334 }
00335 
00336 void
00337 on_menu_ratio_10_activate               (GtkMenuItem     *menuitem,
00338                                         gpointer         user_data)
00339 {
00340     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), 2);
00341 }
00342 
00343 void
00344 on_menu_ratio_15_activate               (GtkMenuItem     *menuitem,
00345                                         gpointer         user_data)
00346 {
00347     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), 3);
00348 }
00349 
00350 void
00351 on_menu_ratio_20_activate               (GtkMenuItem     *menuitem,
00352                                         gpointer         user_data)
00353 {
00354     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), 4);
00355 }
00356 
00357 void
00358 on_menu_ratio_25_activate               (GtkMenuItem     *menuitem,
00359                                         gpointer         user_data)
00360 {
00361     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), 5);
00362 }
00363 
00364 void
00365 on_menu_ratio_30_activate               (GtkMenuItem     *menuitem,
00366                                         gpointer         user_data)
00367 {
00368     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), 6);
00369 }
00370 
00371 void
00372 on_menu_ratio_35_activate               (GtkMenuItem     *menuitem,
00373                                         gpointer         user_data)
00374 {
00375     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), 7);
00376 }
00377 
00378 void
00379 on_menu_ratio_40_activate               (GtkMenuItem     *menuitem,
00380                                         gpointer         user_data)
00381 {
00382     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), 8);
00383 }
00384 
00385 void
00386 on_menu_ratio_45_activate               (GtkMenuItem     *menuitem,
00387                                         gpointer         user_data)
00388 {
00389     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), 9);
00390 }
00391 
00392 void
00393 on_menu_ratio_50_activate               (GtkMenuItem     *menuitem,
00394                                         gpointer         user_data)
00395 {
00396     new_menu_pickup(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menuitem)), 10);
00397 }
00398 
00405 void pickup_init(GtkWidget *window_root)
00406 {
00407     static int has_init=0;
00408     GladeXML *xml_tree;
00409 
00410     /*
00411      * There isn't really any harm doing this multiple times, but isn't any
00412      * point either.
00413      */
00414     if (has_init) return;
00415     has_init=1;
00416 
00417     /*
00418      * The order here really doesn't make much difference.  I suppose order
00419      * could either be in pickup modes (PU_...) or the list of items in the
00420      * menu tree.  I chose the later, as easier to make sure all the items are
00421      * accounted for.
00422      *
00423      * In practice, with these values now set up, we could use a single
00424      * function to hande all the events from the menubar instead of the values
00425      * above - that function basically takes the structure that was clicked,
00426      * and finds the value in this array that corresponds to it.  But that code
00427      * currently works fine and isn't really outdated, so isn't a big reason to
00428      * change it.
00429      */
00430 
00431     xml_tree = glade_get_widget_tree(GTK_WIDGET(window_root));
00432     pickup_mapping[num_pickups].menuitem =
00433         glade_xml_get_widget(xml_tree, "do_not_pickup");
00434     pickup_mapping[num_pickups].pickup_mode = PU_INHIBIT;
00435     num_pickups++;
00436 
00437     pickup_mapping[num_pickups].menuitem =
00438         glade_xml_get_widget(xml_tree, "stop_before_pickup1");
00439     pickup_mapping[num_pickups].pickup_mode = PU_STOP;
00440     num_pickups++;
00441 
00442     pickup_mapping[num_pickups].menuitem =
00443         glade_xml_get_widget(xml_tree, "body_armor1");
00444     pickup_mapping[num_pickups].pickup_mode = PU_ARMOUR;
00445     num_pickups++;
00446 
00447     pickup_mapping[num_pickups].menuitem =
00448         glade_xml_get_widget(xml_tree, "boots1");
00449     pickup_mapping[num_pickups].pickup_mode = PU_BOOTS;
00450     num_pickups++;
00451 
00452     pickup_mapping[num_pickups].menuitem =
00453         glade_xml_get_widget(xml_tree, "cloaks1");
00454     pickup_mapping[num_pickups].pickup_mode = PU_CLOAK;
00455     num_pickups++;
00456 
00457     pickup_mapping[num_pickups].menuitem =
00458         glade_xml_get_widget(xml_tree, "gloves1");
00459     pickup_mapping[num_pickups].pickup_mode = PU_GLOVES;
00460     num_pickups++;
00461 
00462     pickup_mapping[num_pickups].menuitem =
00463         glade_xml_get_widget(xml_tree, "helmets1");
00464     pickup_mapping[num_pickups].pickup_mode = PU_HELMET;
00465     num_pickups++;
00466 
00467     pickup_mapping[num_pickups].menuitem =
00468         glade_xml_get_widget(xml_tree, "shields1");
00469     pickup_mapping[num_pickups].pickup_mode = PU_SHIELD;
00470     num_pickups++;
00471 
00472     pickup_mapping[num_pickups].menuitem =
00473         glade_xml_get_widget(xml_tree, "skillscrolls1");
00474     pickup_mapping[num_pickups].pickup_mode = PU_SKILLSCROLL;
00475     num_pickups++;
00476 
00477     pickup_mapping[num_pickups].menuitem =
00478         glade_xml_get_widget(xml_tree, "normal_book_scrolls1");
00479     pickup_mapping[num_pickups].pickup_mode = PU_READABLES;
00480     num_pickups++;
00481 
00482     pickup_mapping[num_pickups].menuitem =
00483         glade_xml_get_widget(xml_tree, "spellbooks1");
00484     pickup_mapping[num_pickups].pickup_mode = PU_SPELLBOOK;
00485     num_pickups++;
00486 
00487     pickup_mapping[num_pickups].menuitem =
00488         glade_xml_get_widget(xml_tree, "drinks1");
00489     pickup_mapping[num_pickups].pickup_mode = PU_DRINK;
00490     num_pickups++;
00491 
00492     pickup_mapping[num_pickups].menuitem =
00493         glade_xml_get_widget(xml_tree, "food1");
00494     pickup_mapping[num_pickups].pickup_mode = PU_FOOD;
00495     num_pickups++;
00496 
00497     pickup_mapping[num_pickups].menuitem =
00498         glade_xml_get_widget(xml_tree, "flesh1");
00499     pickup_mapping[num_pickups].pickup_mode = PU_FLESH;
00500     num_pickups++;
00501 
00502     pickup_mapping[num_pickups].menuitem =
00503         glade_xml_get_widget(xml_tree, "keys1");
00504     pickup_mapping[num_pickups].pickup_mode = PU_KEY;
00505     num_pickups++;
00506 
00507     pickup_mapping[num_pickups].menuitem =
00508         glade_xml_get_widget(xml_tree, "magical_items");
00509     pickup_mapping[num_pickups].pickup_mode = PU_MAGICAL;
00510     num_pickups++;
00511 
00512     pickup_mapping[num_pickups].menuitem =
00513         glade_xml_get_widget(xml_tree, "potions");
00514     pickup_mapping[num_pickups].pickup_mode = PU_POTION;
00515     num_pickups++;
00516 
00517     pickup_mapping[num_pickups].menuitem =
00518         glade_xml_get_widget(xml_tree, "valuables");
00519     pickup_mapping[num_pickups].pickup_mode = PU_VALUABLES;
00520     num_pickups++;
00521 
00522     pickup_mapping[num_pickups].menuitem =
00523         glade_xml_get_widget(xml_tree, "wands_rods_horns");
00524     pickup_mapping[num_pickups].pickup_mode = PU_MAGIC_DEVICE;
00525     num_pickups++;
00526 
00527     pickup_mapping[num_pickups].menuitem =
00528         glade_xml_get_widget(xml_tree, "jewels1");
00529     pickup_mapping[num_pickups].pickup_mode = PU_JEWELS;
00530     num_pickups++;
00531 
00532     pickup_mapping[num_pickups].menuitem =
00533         glade_xml_get_widget(xml_tree, "all_weapons");
00534     pickup_mapping[num_pickups].pickup_mode = PU_ALLWEAPON;
00535     num_pickups++;
00536 
00537     pickup_mapping[num_pickups].menuitem =
00538         glade_xml_get_widget(xml_tree, "missile_weapons1");
00539     pickup_mapping[num_pickups].pickup_mode = PU_MISSILEWEAPON;
00540     num_pickups++;
00541 
00542     pickup_mapping[num_pickups].menuitem =
00543         glade_xml_get_widget(xml_tree, "bows1");
00544     pickup_mapping[num_pickups].pickup_mode = PU_BOW;
00545     num_pickups++;
00546 
00547     pickup_mapping[num_pickups].menuitem =
00548         glade_xml_get_widget(xml_tree, "arrows1");
00549     pickup_mapping[num_pickups].pickup_mode = PU_ARROW;
00550     num_pickups++;
00551 
00552     pickup_mapping[num_pickups].menuitem =
00553         glade_xml_get_widget(xml_tree, "ratio_pickup_off1");
00554     pickup_mapping[num_pickups].pickup_mode = ~PU_RATIO;
00555     num_pickups++;
00556 
00557     pickup_mapping[num_pickups].menuitem =
00558         glade_xml_get_widget(xml_tree, "ratio_5");
00559     pickup_mapping[num_pickups].pickup_mode = 1;
00560     num_pickups++;
00561 
00562     pickup_mapping[num_pickups].menuitem =
00563         glade_xml_get_widget(xml_tree, "ratio_10");
00564     pickup_mapping[num_pickups].pickup_mode = 2;
00565     num_pickups++;
00566 
00567     pickup_mapping[num_pickups].menuitem =
00568         glade_xml_get_widget(xml_tree, "ratio_15");
00569     pickup_mapping[num_pickups].pickup_mode = 3;
00570     num_pickups++;
00571 
00572     pickup_mapping[num_pickups].menuitem =
00573         glade_xml_get_widget(xml_tree, "ratio_20");
00574     pickup_mapping[num_pickups].pickup_mode = 4;
00575     num_pickups++;
00576 
00577     pickup_mapping[num_pickups].menuitem =
00578         glade_xml_get_widget(xml_tree, "ratio_25");
00579     pickup_mapping[num_pickups].pickup_mode = 5;
00580     num_pickups++;
00581 
00582     pickup_mapping[num_pickups].menuitem =
00583         glade_xml_get_widget(xml_tree, "ratio_30");
00584     pickup_mapping[num_pickups].pickup_mode = 6;
00585     num_pickups++;
00586 
00587     pickup_mapping[num_pickups].menuitem =
00588         glade_xml_get_widget(xml_tree, "ratio_35");
00589     pickup_mapping[num_pickups].pickup_mode = 7;
00590     num_pickups++;
00591 
00592     pickup_mapping[num_pickups].menuitem =
00593         glade_xml_get_widget(xml_tree, "ratio_40");
00594     pickup_mapping[num_pickups].pickup_mode = 8;
00595     num_pickups++;
00596 
00597     pickup_mapping[num_pickups].menuitem =
00598         glade_xml_get_widget(xml_tree, "ratio_45");
00599     pickup_mapping[num_pickups].pickup_mode = 9;
00600     num_pickups++;
00601 
00602     pickup_mapping[num_pickups].menuitem =
00603         glade_xml_get_widget(xml_tree, "ratio_50");
00604     pickup_mapping[num_pickups].pickup_mode = 10;
00605     num_pickups++;
00606 
00607     pickup_mapping[num_pickups].menuitem =
00608         glade_xml_get_widget(xml_tree, "not_cursed1");
00609     pickup_mapping[num_pickups].pickup_mode = PU_NOT_CURSED;
00610     num_pickups++;
00611 
00612     /*
00613      * Do some bounds checking.  We could actually set this exactly right,
00614      * since additional menu entries are not likely to be added often.  We exit
00615      * because if we overrun that structure, we've screwed up memory and will
00616      * likely crash or otherwise have odd behaviour.
00617      */
00618     if (num_pickups>=MAX_PICKUPS) {
00619         LOG(LOG_ERROR, "pickup.c::pickup_init", "num_pickups (%d) >= MAX_PICKUPS (%d)\n",
00620             num_pickups, MAX_PICKUPS);
00621         exit(1);
00622     }
00623 
00624 }
00625 
00629 void client_pickup(uint32 pickup)
00630 {
00631     int i;
00632 
00633     /*
00634      * no_recurse is used to limit callbacks - otherwise what happens is when
00635      * we call set_active below, it emits the appropriate signal, which results
00636      * in new_menu_pickup() getting called, which then sends a new pickup
00637      * command to the server, which then results in server sending data to
00638      * client, etc.
00639      */
00640     no_recurse=1;
00641     pmode=pickup;
00642 
00643     for (i=0; i < num_pickups; i++) {
00644         if ((pickup & ~PU_RATIO) & pickup_mapping[i].pickup_mode ||
00645             (pickup & PU_RATIO) == pickup_mapping[i].pickup_mode) {
00646             gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(pickup_mapping[i].menuitem), 1);
00647         } else {
00648             gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(pickup_mapping[i].menuitem), 0);
00649         }
00650     }
00651     no_recurse=0;
00652 }