X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Fautopick.c;h=76df7267515eb3d65a99490adca88ff8eed62ed6;hb=214cab5f3f64a0501f4ec4d6fe6609729e0d5023;hp=377be8dc289452f0751de8bbfaa85a0dfba539ff;hpb=e19f999432e3f2a8d9eab778d60dad6fcdd5846c;p=hengband%2Fhengband.git diff --git a/src/autopick.c b/src/autopick.c index 377be8dc2..76df72675 100644 --- a/src/autopick.c +++ b/src/autopick.c @@ -210,7 +210,7 @@ static bool autopick_new_entry(autopick_type *entry, cptr str, bool allow_defaul cptr prev_ptr, ptr, old_ptr; int prev_flg; - if (str[1] == ':') switch (str[0]) + if (str[0] && str[1] == ':') switch (str[0]) { case '?': case '%': case 'A': case 'P': case 'C': @@ -219,6 +219,7 @@ static bool autopick_new_entry(autopick_type *entry, cptr str, bool allow_defaul entry->flag[0] = entry->flag[1] = 0L; entry->dice = 0; + entry->bonus = 0; act = DO_AUTOPICK | DO_DISPLAY; while (TRUE) @@ -520,7 +521,6 @@ static void autopick_entry_from_object(autopick_type *entry, object_type *o_ptr) { /* Ego objects */ if (object_is_ego(o_ptr)) - { if (object_is_weapon_armour_ammo(o_ptr)) { @@ -541,11 +541,8 @@ static void autopick_entry_from_object(autopick_type *entry, object_type *o_ptr) /* Don't use the object description */ name = FALSE; - if (object_is_weapon_armour_ammo(o_ptr)) - { - /* Restrict to 'common' equipments */ - if (!object_is_rare(o_ptr)) ADD_FLG(FLG_COMMON); - } + /* Restrict to 'common' equipments */ + if (!object_is_rare(o_ptr)) ADD_FLG(FLG_COMMON); } ADD_FLG(FLG_EGO); @@ -692,6 +689,8 @@ static void autopick_free_entry(autopick_type *entry) { string_free(entry->name); string_free(entry->insc); + entry->name = NULL; + entry->insc = NULL; } @@ -745,7 +744,7 @@ static cptr pickpref_filename(int filename_mode) return format("%s.prf", namebase); case PT_WITH_PNAME: - return format("%s-%s.prf", namebase, player_name); + return format("%s-%s.prf", namebase, player_base); default: return NULL; @@ -830,10 +829,10 @@ static void add_autopick_list(autopick_type *entry) C_MAKE(autopick_list, max_max_autopick, autopick_type); /* Copy from old list to new list */ - C_COPY(autopick_list, old_autopick_list, old_max_max_autopick, autopick_type); + (void)C_COPY(autopick_list, old_autopick_list, old_max_max_autopick, autopick_type); /* Kill old list */ - C_FREE(old_autopick_list, old_max_max_autopick, autopick_type); + C_KILL(old_autopick_list, old_max_max_autopick, autopick_type); } /* Add one line */ @@ -874,7 +873,11 @@ errr process_autopick_file_command(char *buf) && entry->flag[0] == autopick_list[i].flag[0] && entry->flag[1] == autopick_list[i].flag[1] && entry->dice == autopick_list[i].dice - && entry->bonus == autopick_list[i].bonus) return 0; + && entry->bonus == autopick_list[i].bonus) + { + autopick_free_entry(entry); + return 0; + } add_autopick_list(entry); return 0; @@ -1058,6 +1061,12 @@ static bool is_autopick_aux(object_type *o_ptr, autopick_type *entry, cptr o_nam /* Require boosted dice */ if ((o_ptr->dd == k_ptr->dd) && (o_ptr->ds == k_ptr->ds)) return FALSE; + + /* In Vault Quest, Dice must be hide.*/ + if(!object_is_known(o_ptr) && object_is_quest_target(o_ptr)) + { + return FALSE; + } } /*** Weapons which dd*ds is more than nn ***/ @@ -1232,11 +1241,11 @@ static bool is_autopick_aux(object_type *o_ptr, autopick_type *entry, cptr o_nam } } - /*** Rere equpiments ***/ + /*** Rere equipments ***/ if (IS_FLG(FLG_RARE) && !object_is_rare(o_ptr)) return FALSE; - /*** Common equpiments ***/ + /*** Common equipments ***/ if (IS_FLG(FLG_COMMON) && object_is_rare(o_ptr)) return FALSE; @@ -1494,21 +1503,21 @@ static bool is_opt_confirm_destroy(object_type *o_ptr) /* Known to be worthless? */ if (leave_worth) if (object_value(o_ptr) > 0) return FALSE; - + if (leave_equip) - if (!object_is_weapon_armour_ammo(o_ptr)) return FALSE; - + if (object_is_weapon_armour_ammo(o_ptr)) return FALSE; + if (leave_chest) if ((o_ptr->tval == TV_CHEST) && o_ptr->pval) return FALSE; - + if (leave_wanted) { if (object_is_shoukinkubi(o_ptr)) return FALSE; } - + if (leave_corpse) if (o_ptr->tval == TV_CORPSE) return FALSE; - + if (leave_junk) if ((o_ptr->tval == TV_SKELETON) || (o_ptr->tval == TV_BOTTLE) || (o_ptr->tval == TV_JUNK) || (o_ptr->tval == TV_STATUE)) return FALSE; @@ -1531,20 +1540,20 @@ static bool is_opt_confirm_destroy(object_type *o_ptr) else if (p_ptr->pclass == CLASS_NINJA) { if (o_ptr->tval == TV_LITE && - o_ptr->name2 == EGO_LITE_DARKNESS) + o_ptr->name2 == EGO_LITE_DARKNESS && object_is_known(o_ptr)) return FALSE; } else if (p_ptr->pclass == CLASS_BEASTMASTER || p_ptr->pclass == CLASS_CAVALRY) { if (o_ptr->tval == TV_WAND && - o_ptr->sval == SV_WAND_HEAL_MONSTER) + o_ptr->sval == SV_WAND_HEAL_MONSTER && object_is_aware(o_ptr)) return FALSE; } } - + if (o_ptr->tval == TV_GOLD) return FALSE; - + return TRUE; } @@ -1605,7 +1614,7 @@ static void auto_destroy_item(object_type *o_ptr, int autopick_idx) } /* Record name of destroyed item */ - COPY(&autopick_last_destroyed_object, o_ptr, object_type); + (void)COPY(&autopick_last_destroyed_object, o_ptr, object_type); /* Destroy Later */ o_ptr->marked |= OM_AUTODESTROY; @@ -2262,14 +2271,14 @@ static void describe_autopick(char *buff, autopick_type *entry) body_str = "ÁõÈ÷"; } - /*** Rare equpiments ***/ + /*** Rare equipments ***/ if (IS_FLG(FLG_RARE)) { before_str[before_n++] = "¥É¥é¥´¥óÁõÈ÷¤ä¥«¥ª¥¹¡¦¥Ö¥ì¡¼¥ÉÅù¤ò´Þ¤àÄÁ¤·¤¤"; body_str = "ÁõÈ÷"; } - /*** Common equpiments ***/ + /*** Common equipments ***/ if (IS_FLG(FLG_COMMON)) { before_str[before_n++] = "¤¢¤ê¤Õ¤ì¤¿(¥É¥é¥´¥óÁõÈ÷¤ä¥«¥ª¥¹¡¦¥Ö¥ì¡¼¥ÉÅù¤ÎÄÁ¤·¤¤Êª¤Ç¤Ï¤Ê¤¤)"; @@ -2482,7 +2491,7 @@ static void describe_autopick(char *buff, autopick_type *entry) if (IS_FLG(FLG_STAR_IDENTIFIED)) before_str[before_n++] = "fully identified"; - /*** Rare equpiments ***/ + /*** Rare equipments ***/ if (IS_FLG(FLG_RARE)) { before_str[before_n++] = "very rare"; @@ -2490,7 +2499,7 @@ static void describe_autopick(char *buff, autopick_type *entry) after_str[after_n++] = "such like Dragon armors, Blades of Chaos, etc."; } - /*** Common equpiments ***/ + /*** Common equipments ***/ if (IS_FLG(FLG_COMMON)) { before_str[before_n++] = "relatively common"; @@ -2838,7 +2847,7 @@ static cptr *read_text_lines(cptr filename) */ static void prepare_default_pickpref(void) { - static char *messages[] = { + const cptr messages[] = { #ifdef JP "¤¢¤Ê¤¿¤Ï¡Ö¼«Æ°½¦¤¤¥¨¥Ç¥£¥¿¡×¤ò½é¤á¤Æµ¯Æ°¤·¤Þ¤·¤¿¡£", "¼«Æ°½¦¤¤¤Î¥æ¡¼¥¶¡¼ÀßÄê¥Õ¥¡¥¤¥ë¤¬¤Þ¤À½ñ¤«¤ì¤Æ¤¤¤Ê¤¤¤Î¤Ç¡¢", @@ -2980,7 +2989,7 @@ static void free_text_lines(cptr *lines_list) string_free(lines_list[lines]); /* free list of pointers */ - C_FREE((char **)lines_list, MAX_LINES, char *); + C_KILL(lines_list, MAX_LINES, cptr); } @@ -3711,6 +3720,8 @@ static void search_for_object(text_body_type *tb, object_type *o_ptr, bool forwa while (TRUE) { + bool match; + /* End of list? */ if (forward) { @@ -3725,8 +3736,9 @@ static void search_for_object(text_body_type *tb, object_type *o_ptr, bool forwa if (!autopick_new_entry(entry, tb->lines_list[i], FALSE)) continue; /* Does this line match to the object? */ - if (!is_autopick_aux(o_ptr, entry, o_name)) continue; - + match = is_autopick_aux(o_ptr, entry, o_name); + autopick_free_entry(entry); + if (!match) continue; /* Found a line but it's inactive */ if (tb->states[i] & LSTAT_BYPASS) @@ -4603,6 +4615,8 @@ static void draw_text_editor(text_body_type *tb) char f; cptr v; cptr s = tb->lines_list[y]; + char *ss, *s_keep; + int s_len; /* Update this line's state */ tb->states[y] = state; @@ -4614,13 +4628,20 @@ static void draw_text_editor(text_body_type *tb) if (streq(s, "$AUTOREGISTER")) state |= LSTAT_AUTOREGISTER; + s_len = strlen(s); + ss = (char *)string_make(s); + s_keep = ss; + /* Parse the expr */ - v = process_pref_file_expr(&s, &f); + v = process_pref_file_expr(&ss, &f); /* Set flag */ if (streq(v, "0")) state |= LSTAT_BYPASS; else state &= ~LSTAT_BYPASS; + /* Cannot use string_free() because the string was "destroyed" */ + C_KILL(s_keep, s_len + 1, char); + /* Re-update this line's state */ tb->states[y] = state | LSTAT_EXPRESSION; } @@ -4778,7 +4799,7 @@ static void draw_text_editor(text_body_type *tb) str1 = "This line is a comment."; #endif } - else if (tb->lines_list[tb->cy][1] == ':') + else if (tb->lines_list[tb->cy][0] && tb->lines_list[tb->cy][1] == ':') { switch(tb->lines_list[tb->cy][0]) { @@ -6178,6 +6199,11 @@ void do_cmd_edit_autopick(void) tb->dirty_line = -1; tb->filename_mode = PT_DEFAULT; + if (turn < old_autosave_turn) + { + while (old_autosave_turn > turn) old_autosave_turn -= TURNS_PER_TICK * TOWN_DAWN; + } + /* Autosave */ if (turn > old_autosave_turn + 100L) { @@ -6310,6 +6336,7 @@ void do_cmd_edit_autopick(void) free_text_lines(tb->lines_list); + string_free(tb->search_str); string_free(tb->last_destroyed); /* Destroy string chain */