From 31025cdb2164ba215a5c01663453f6318d49ae2c Mon Sep 17 00:00:00 2001 From: mogami Date: Tue, 4 Nov 2003 06:45:46 +0000 Subject: [PATCH] =?utf8?q?=E8=87=AA=E5=8B=95=E6=8B=BE=E3=81=84=E9=96=A2?= =?utf8?q?=E4=BF=82=E3=81=AE=E9=96=A2=E6=95=B0=E3=81=AE=E5=90=8D=E5=89=8D?= =?utf8?q?=E3=82=92=E7=B5=B1=E4=B8=80=E7=9A=84=E3=81=AB=E6=94=B9=E5=90=8D?= =?utf8?q?=E3=80=82=E5=85=A8=E3=81=A6=E3=80=8Cautopick=E3=80=8D=E3=81=AE?= =?utf8?q?=E3=82=AD=E3=83=BC=E3=83=AF=E3=83=BC=E3=83=89=E3=82=92=E5=90=AB?= =?utf8?q?=E3=82=80=E3=82=88=E3=81=86=E3=81=AB=E3=81=97=E3=81=9F=E3=80=82?= =?utf8?q?=20=E3=81=BE=E3=81=9F=E3=80=81picktype.prf=E3=82=92=E8=AA=AD?= =?utf8?q?=E3=81=BF=E8=BE=BC=E3=82=80=E5=87=A6=E7=90=86=E3=82=92autopick.c?= =?utf8?q?=E5=86=85=E3=81=AE=E9=96=A2=E6=95=B0=E3=81=AB=E3=81=BE=E3=81=A8?= =?utf8?q?=E3=82=81=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/autopick.c | 143 ++++++++++++++++++++++++++++++++++++++++----------------- src/bldg.c | 4 +- src/cmd1.c | 6 +-- src/cmd3.c | 6 +-- src/cmd4.c | 55 ++-------------------- src/defines.h | 2 +- src/dungeon.c | 31 +++---------- src/externs.h | 16 +++---- src/files.c | 14 +++--- src/spells1.c | 2 +- src/spells3.c | 6 +-- src/store.c | 4 +- src/xtra1.c | 2 +- 13 files changed, 144 insertions(+), 147 deletions(-) diff --git a/src/autopick.c b/src/autopick.c index 7e0cbba0b..aacf6c020 100644 --- a/src/autopick.c +++ b/src/autopick.c @@ -824,12 +824,12 @@ static void autopick_free_entry(autopick_type *entry) } -/* - * Initialize auto-picker preference - */ #define MAX_AUTOPICK_DEFAULT 200 -void init_autopicker(void) +/* + * Initialize the autopick + */ +static void init_autopick(void) { static const char easy_autopick_inscription[] = "(:=g"; autopick_type entry; @@ -854,6 +854,93 @@ void init_autopicker(void) } +#define PT_DEFAULT 0 +#define PT_WITH_PNAME 1 + +/* + * Get file name for autopick preference + */ +static cptr pickpref_filename(int filename_mode) +{ +#ifdef JP + static const char namebase[] = "picktype"; +#else + static const char namebase[] = "pickpref"; +#endif + + switch (filename_mode) + { + case PT_DEFAULT: + return format("%s.prf", namebase); + + case PT_WITH_PNAME: + return format("%s-%s.prf", namebase, player_name); + + default: + return NULL; + } +} + + +/* + * Load an autopick preference file + */ +void autopick_load_pref(bool disp_mes) +{ + char buf[80]; + errr err; + + /* Free old entries */ + init_autopick(); + + /* Try a filename with player name */ + my_strcpy(buf, pickpref_filename(PT_WITH_PNAME), sizeof(buf)); + + /* Load the file */ + err = process_autopick_file(buf); + + if (err == 0 && disp_mes) + { + /* Success */ +#ifdef JP + msg_format("%s¤òÆɤ߹þ¤ß¤Þ¤·¤¿¡£", buf); +#else + msg_format("Loaded '%s'.", buf); +#endif + } + + /* No file found */ + if (0 > err) + { + /* Use default name */ + my_strcpy(buf, pickpref_filename(PT_DEFAULT), sizeof(buf)); + + /* Load the file */ + err = process_autopick_file(buf); + + if (err == 0 && disp_mes) + { + /* Success */ +#ifdef JP + msg_format("%s¤òÆɤ߹þ¤ß¤Þ¤·¤¿¡£", buf); +#else + msg_format("Loaded '%s'.", buf); +#endif + } + } + + if (err && disp_mes) + { + /* Failed */ +#ifdef JP + msg_print("¼«Æ°½¦¤¤ÀßÄê¥Õ¥¡¥¤¥ë¤ÎÆɤ߹þ¤ß¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£"); +#else + msg_print("Failed to reload autopick preference."); +#endif + } +} + + /* * Add one line to autopick_list[] */ @@ -888,7 +975,7 @@ static void add_autopick_list(autopick_type *entry) /* * Process line for auto picker/destroyer. */ -errr process_pickpref_file_line(char *buf) +errr process_autopick_file_command(char *buf) { autopick_type an_entry, *entry = &an_entry; int i; @@ -1588,7 +1675,7 @@ static void auto_destroy_item(object_type *o_ptr, int autopick_idx) /* * Auto-destroy marked item */ -static void delayed_auto_destroy_aux(int item) +static void autopick_delayed_alter_aux(int item) { object_type *o_ptr; @@ -1631,7 +1718,7 @@ static void delayed_auto_destroy_aux(int item) /* * Auto-destroy marked items in inventry and on floor */ -void delayed_auto_destroy(void) +void autopick_delayed_alter(void) { int item; @@ -1640,14 +1727,14 @@ void delayed_auto_destroy(void) * skipping after inven_item_optimize() */ for (item = INVEN_TOTAL - 1; item >= 0 ; item--) - delayed_auto_destroy_aux(item); + autopick_delayed_alter_aux(item); /* Scan the pile of objects */ item = cave[py][px].o_idx; while (item) { int next = o_list[item].next_o_idx; - delayed_auto_destroy_aux(-item); + autopick_delayed_alter_aux(-item); item = next; } } @@ -1659,7 +1746,7 @@ void delayed_auto_destroy(void) * Auto-destroyer works only on inventory or on floor stack only when * requested. */ -void auto_do_item(int item, bool destroy) +void autopick_alter_item(int item, bool destroy) { object_type *o_ptr; int idx; @@ -1685,7 +1772,7 @@ void auto_do_item(int item, bool destroy) /* * Automatically pickup/destroy items in this grid. */ -void auto_pickup_items(cave_type *c_ptr) +void autopick_pickup_items(cave_type *c_ptr) { s16b this_o_idx, next_o_idx = 0; @@ -1773,34 +1860,6 @@ void auto_pickup_items(cave_type *c_ptr) } -#define PT_DEFAULT 0 -#define PT_WITH_PNAME 1 - -/* - * Get file name for autopick preference - */ -static cptr pickpref_filename(int filename_mode) -{ -#ifdef JP - static const char namebase[] = "picktype"; -#else - static const char namebase[] = "pickpref"; -#endif - - switch (filename_mode) - { - case PT_DEFAULT: - return format("%s.prf", namebase); - - case PT_WITH_PNAME: - return format("%s-%s.prf", namebase, player_name); - - default: - return NULL; - } -} - - static const char autoregister_header[] = "?:$AUTOREGISTER"; /* @@ -1934,7 +1993,7 @@ static bool clear_auto_register(void) /* * Automatically register an auto-destroy preference line */ -bool add_auto_register(object_type *o_ptr) +bool autopick_autoregister(object_type *o_ptr) { char buf[1024]; char pref_file[1024]; @@ -5948,7 +6007,7 @@ void do_cmd_edit_autopick(void) update_playtime(); /* Free old entries */ - init_autopicker(); + init_autopick(); /* Command Description of the 'Last Destroyed Item' */ if (autopick_last_destroyed_object.k_idx) @@ -6075,7 +6134,7 @@ void do_cmd_edit_autopick(void) kill_yank_chain(tb); /* Reload autopick pref */ - process_pickpref_file(buf); + process_autopick_file(buf); /* HACK -- reset start_time so that playtime is not increase while edit */ start_time = time(NULL); diff --git a/src/bldg.c b/src/bldg.c index 1a3398d42..74af464e7 100644 --- a/src/bldg.c +++ b/src/bldg.c @@ -3825,7 +3825,7 @@ msg_format("%s #endif /* Auto-inscription */ - auto_do_item(item, FALSE); + autopick_alter_item(item, FALSE); /* Update the gold display */ building_prt_gold(); @@ -4126,7 +4126,7 @@ static void building_recharge_all(void) identify_item(o_ptr); /* Auto-inscription */ - auto_do_item(i, FALSE); + autopick_alter_item(i, FALSE); } /* Recharge */ diff --git a/src/cmd1.c b/src/cmd1.c index ddf1d9583..c7f2eef36 100644 --- a/src/cmd1.c +++ b/src/cmd1.c @@ -809,7 +809,7 @@ void py_pickup_aux(int o_idx) bool old_known = identify_item(o_ptr); /* Auto-inscription/destroy */ - auto_do_item(slot, (bool)(destroy_identify && !old_known)); + autopick_alter_item(slot, (bool)(destroy_identify && !old_known)); /* If it is destroyed, don't pick it up */ if (o_ptr->marked & OM_AUTODESTROY) return; @@ -901,7 +901,7 @@ void carry(int pickup) handle_stuff(); /* Automatically pickup/destroy/inscribe items */ - auto_pickup_items(c_ptr); + autopick_pickup_items(c_ptr); #ifdef ALLOW_EASY_FLOOR @@ -975,7 +975,7 @@ void carry(int pickup) /* Pick up objects */ else { - /* Hack - some objects were handled in auto_pickup_items(). */ + /* Hack - some objects were handled in autopick_pickup_items(). */ if (o_ptr->marked & OM_NOMSG) { /* Clear the flag. */ diff --git a/src/cmd3.c b/src/cmd3.c index 8b5075bd8..1a981566d 100644 --- a/src/cmd3.c +++ b/src/cmd3.c @@ -434,7 +434,7 @@ msg_print(" identify_item(o_ptr); /* Auto-inscription */ - auto_do_item(item, FALSE); + autopick_alter_item(item, FALSE); } /* Take a turn */ @@ -972,10 +972,10 @@ void do_cmd_destroy(void) if (i == 'a' || i == 'A') { /* Add an auto-destroy preference line */ - if (add_auto_register(o_ptr)) + if (autopick_autoregister(o_ptr)) { /* Auto-destroy it */ - auto_do_item(item, TRUE); + autopick_alter_item(item, TRUE); } /* The object is already destroyed. */ diff --git a/src/cmd4.c b/src/cmd4.c index 74e6208aa..9b562f23a 100644 --- a/src/cmd4.c +++ b/src/cmd4.c @@ -2728,64 +2728,19 @@ void do_cmd_pref(void) (void)process_pref_file_command(buf); } -void do_cmd_pickpref(void) +void do_cmd_reload_autopick(void) { char buf[80]; errr err; #ifdef JP - if(!get_check("¼«Æ°½¦¤¤ÀßÄê¥Õ¥¡¥¤¥ë¤ò¥í¡¼¥É¤·¤Þ¤¹¤«? ")) return; + if (!get_check("¼«Æ°½¦¤¤ÀßÄê¥Õ¥¡¥¤¥ë¤ò¥í¡¼¥É¤·¤Þ¤¹¤«? ")) return; #else - if(!get_check("Reload auto-pick preference file? ")) return; + if (!get_check("Reload auto-pick preference file? ")) return; #endif - /* Free old entries */ - init_autopicker(); - - /* ¥­¥ã¥éËè¤ÎÀßÄê¥Õ¥¡¥¤¥ë¤ÎÆɤ߹þ¤ß */ -#ifdef JP - sprintf(buf, "picktype-%s.prf", player_name); -#else - sprintf(buf, "pickpref-%s.prf", player_name); -#endif - err = process_pickpref_file(buf); - - if(err == 0) - { -#ifdef JP - msg_format("%s¤òÆɤ߹þ¤ß¤Þ¤·¤¿¡£", buf); -#else - msg_format("loaded '%s'.", buf); -#endif - } - - /* ¶¦Ä̤ÎÀßÄê¥Õ¥¡¥¤¥ëÆɤ߹þ¤ß */ - - /* Process 'pick????.prf' if 'pick????-.prf' doesn't exist */ - if (0 > err) - { -#ifdef JP - err = process_pickpref_file("picktype.prf"); -#else - err = process_pickpref_file("pickpref.prf"); -#endif - - if(err == 0) - { -#ifdef JP - msg_print("picktype.prf¤òÆɤ߹þ¤ß¤Þ¤·¤¿¡£"); -#else - msg_print("loaded 'pickpref.prf'."); -#endif - } - } - - -#ifdef JP - if(err) msg_print("¼«Æ°½¦¤¤ÀßÄê¥Õ¥¡¥¤¥ë¤ÎÆɤ߹þ¤ß¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£"); -#else - if(err) msg_print("Failed to reload autopick preference."); -#endif + /* Load the file with messages */ + autopick_load_pref(TRUE); } #ifdef ALLOW_MACROS diff --git a/src/defines.h b/src/defines.h index 4a7d2b7b9..94a46432f 100644 --- a/src/defines.h +++ b/src/defines.h @@ -3003,7 +3003,7 @@ * How object is marked (flags in object_type.mark) * OM_FOUND --- original boolean flag * OM_NOMSG --- temporary flag to suppress messages which were - * already printed in auto_pickup_items(). + * already printed in autopick_pickup_items(). */ #define OM_FOUND 0x01 /* original boolean flag */ #define OM_NOMSG 0x02 /* temporary flag to suppress messages */ diff --git a/src/dungeon.c b/src/dungeon.c index f5f072f25..b8708fea9 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -201,7 +201,7 @@ o_name, index_to_label(slot),game_inscriptions[feel]); o_ptr->feeling = feel; /* Auto-inscription/destroy */ - auto_do_item(slot, destroy_feeling); + autopick_alter_item(slot, destroy_feeling); /* Combine / Reorder the pack (later) */ p_ptr->notice |= (PN_COMBINE | PN_REORDER); @@ -1627,7 +1627,7 @@ msg_format("%s } /* Auto-inscription/destroy */ - auto_do_item(item, (bool)(okay && destroy_feeling)); + autopick_alter_item(item, (bool)(okay && destroy_feeling)); /* Something happened */ return (TRUE); @@ -5222,7 +5222,7 @@ msg_print(" case '$': { - do_cmd_pickpref(); + do_cmd_reload_autopick(); break; } @@ -6474,27 +6474,6 @@ static void load_all_pref_files(void) /* Process that file */ process_pref_file(buf); - /* Free old entries */ - init_autopicker(); - -#ifdef JP - sprintf(buf, "picktype-%s.prf", player_base); -#else - sprintf(buf, "pickpref-%s.prf", player_base); -#endif - - err = process_pickpref_file(buf); - - /* Process 'pick????.prf' if 'pick????-.prf' doesn't exist */ - if (0 > err) - { -#ifdef JP - process_pickpref_file("picktype.prf"); -#else - process_pickpref_file("pickpref.prf"); -#endif - } - /* Access the "realm 1" pref file */ if (p_ptr->realm1 != REALM_NONE) { @@ -6512,6 +6491,10 @@ static void load_all_pref_files(void) /* Process that file */ process_pref_file(buf); } + + + /* Load an autopick preference file */ + autopick_load_pref(FALSE); } diff --git a/src/externs.h b/src/externs.h index 1f0f2e88e..ad2d4ddcd 100644 --- a/src/externs.h +++ b/src/externs.h @@ -585,14 +585,14 @@ extern s16b now_message; extern bool use_menu; /* autopick.c */ -extern void init_autopicker(void); -extern errr process_pickpref_file_line(char *buf); +extern void autopick_load_pref(bool disp_mes); +extern errr process_autopick_file_command(char *buf); extern cptr autopick_line_from_entry(autopick_type *entry); extern int is_autopick(object_type *o_ptr); -extern void auto_do_item(int item, bool destroy); -extern void delayed_auto_destroy(void); -extern void auto_pickup_items(cave_type *c_ptr); -extern bool add_auto_register(object_type *o_ptr); +extern void autopick_alter_item(int item, bool destroy); +extern void autopick_delayed_alter(void); +extern void autopick_pickup_items(cave_type *c_ptr); +extern bool autopick_autoregister(object_type *o_ptr); extern void do_cmd_edit_autopick(void); /* birth.c */ @@ -718,7 +718,7 @@ extern void do_cmd_messages(int num_now); extern void do_cmd_options_aux(int page, cptr info); extern void do_cmd_options(void); extern void do_cmd_pref(void); -extern void do_cmd_pickpref(void); +extern void do_cmd_reload_autopick(void); extern void do_cmd_macros(void); extern void do_cmd_visuals(void); extern void do_cmd_colors(void); @@ -786,7 +786,7 @@ extern errr file_character(cptr name); extern errr process_pref_file_command(char *buf); extern cptr process_pref_file_expr(cptr *sp, char *fp); extern errr process_pref_file(cptr name); -extern errr process_pickpref_file(cptr name); +extern errr process_autopick_file(cptr name); extern errr process_histpref_file(cptr name); extern void print_equippy(void); extern errr check_time_init(void); diff --git a/src/files.c b/src/files.c index 1b1cc335a..141d8c714 100644 --- a/src/files.c +++ b/src/files.c @@ -1037,7 +1037,7 @@ cptr process_pref_file_expr(cptr *sp, char *fp) #define PREF_TYPE_NORMAL 0 -#define PREF_TYPE_PICKPREF 1 +#define PREF_TYPE_AUTOPICK 1 #define PREF_TYPE_HISTPREF 2 /* @@ -1125,8 +1125,8 @@ static errr process_pref_file_aux(cptr name, int preftype) /* Process that file if allowed */ switch (preftype) { - case PREF_TYPE_PICKPREF: - (void)process_pickpref_file(buf + 2); + case PREF_TYPE_AUTOPICK: + (void)process_autopick_file(buf + 2); break; case PREF_TYPE_HISTPREF: (void)process_histpref_file(buf + 2); @@ -1150,9 +1150,9 @@ static errr process_pref_file_aux(cptr name, int preftype) /* This is not original pref line... */ if (err) { - if (preftype != PREF_TYPE_PICKPREF) + if (preftype != PREF_TYPE_AUTOPICK) break; - err = process_pickpref_file_line(buf); + err = process_autopick_file_command(buf); } } @@ -7235,7 +7235,7 @@ errr get_rnd_line_jonly(cptr file_name, int entry, char *output, int count) /* * Process file for auto picker/destroyer. */ -errr process_pickpref_file(cptr name) +errr process_autopick_file(cptr name) { char buf[1024]; @@ -7244,7 +7244,7 @@ errr process_pickpref_file(cptr name) /* Build the filename */ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name); - err = process_pref_file_aux(buf, PREF_TYPE_PICKPREF); + err = process_pref_file_aux(buf, PREF_TYPE_AUTOPICK); /* Result */ return (err); diff --git a/src/spells1.c b/src/spells1.c index c64a45b6b..6a236feb4 100644 --- a/src/spells1.c +++ b/src/spells1.c @@ -1543,7 +1543,7 @@ note_kill = " identify_item(o_ptr); /* Auto-inscription */ - auto_do_item((-this_o_idx), FALSE); + autopick_alter_item((-this_o_idx), FALSE); break; } diff --git a/src/spells3.c b/src/spells3.c index 9cccbdde9..49df49963 100644 --- a/src/spells3.c +++ b/src/spells3.c @@ -2012,7 +2012,7 @@ void identify_pack(void) identify_item(o_ptr); /* Auto-inscription */ - auto_do_item(i, FALSE); + autopick_alter_item(i, FALSE); } } @@ -2901,7 +2901,7 @@ s = " } /* Auto-inscription/destroy */ - auto_do_item(item, (bool)(destroy_identify && !old_known)); + autopick_alter_item(item, (bool)(destroy_identify && !old_known)); /* Something happened */ return (TRUE); @@ -3082,7 +3082,7 @@ s = " (void)screen_object(o_ptr, TRUE); /* Auto-inscription/destroy */ - auto_do_item(item, (bool)(destroy_identify && !old_known)); + autopick_alter_item(item, (bool)(destroy_identify && !old_known)); /* Success */ return (TRUE); diff --git a/src/store.c b/src/store.c index 21e0c5b6f..3164a9872 100644 --- a/src/store.c +++ b/src/store.c @@ -3444,7 +3444,7 @@ msg_format("%s #endif /* Auto-inscription */ - auto_do_item(item_new, FALSE); + autopick_alter_item(item_new, FALSE); /* Now, reduce the original stack's pval. */ if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND)) @@ -3881,7 +3881,7 @@ msg_format("%s /* If items remain, auto-inscribe before optimizing */ if (o_ptr->number > 0) - auto_do_item(item, FALSE); + autopick_alter_item(item, FALSE); inven_item_optimize(item); diff --git a/src/xtra1.c b/src/xtra1.c index e82902d42..19b13e27a 100644 --- a/src/xtra1.c +++ b/src/xtra1.c @@ -5532,7 +5532,7 @@ void notice_stuff(void) if (p_ptr->notice & (PN_AUTODESTROY)) { p_ptr->notice &= ~(PN_AUTODESTROY); - delayed_auto_destroy(); + autopick_delayed_alter(); } /* Combine the pack */ -- 2.11.0