#ifdef JP
#define KEY_ALL "¤¹¤Ù¤Æ¤Î"
+
+#ifdef MAC_MPW
+/*
+ * MEGA HACK -- MPW¤Î¥Ð¥°½ü¤±¡£
+ * pre-processÃæ¤Ë¡Ö¼ý¡×¤Î»ú¤Î2¥Ð¥¤¥ÈÌܤ¬¾¡¼ê¤Ë¾Ã¤¨¤Æ¤·¤Þ¤¦¡£
+ */
+#define KEY_COLLECTING "\x8e\xfb½¸Ãæ¤Î"
+#else
#define KEY_COLLECTING "¼ý½¸Ãæ¤Î"
+#endif
+
#define KEY_UNIDENTIFIED "̤´ÕÄê¤Î"
#define KEY_IDENTIFIED "´ÕÄêºÑ¤ß¤Î"
#define KEY_STAR_IDENTIFIED "*´ÕÄê*ºÑ¤ß¤Î"
#define KEY_BOOSTED "¥À¥¤¥¹Ìܤΰ㤦"
#define KEY_MORE_THAN "¥À¥¤¥¹ÌÜ"
#define KEY_DICE "°Ê¾å¤Î"
-#define KEY_MORE_BONUS "½¤ÀµÃͤ¬"
+#define KEY_MORE_BONUS "½¤ÀµÃÍ"
#define KEY_MORE_BONUS2 "°Ê¾å¤Î"
#define KEY_WORTHLESS "̵²ÁÃͤÎ"
#define KEY_ARTIFACT "¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È"
*buf = '\0';
if (!(entry->action & DO_DISPLAY)) strcat(buf, "(");
+ if (entry->action & DO_QUERY_AUTOPICK) strcat(buf, ";");
if (entry->action & DO_AUTODESTROY) strcat(buf, "!");
if (entry->action & DONT_AUTOPICK) strcat(buf, "~");
if (IS_FLG(FLG_HUMAN)) ADD_KEY(KEY_HUMAN);
if (IS_FLG(FLG_WORTHLESS)) ADD_KEY(KEY_WORTHLESS);
if (IS_FLG(FLG_NAMELESS)) ADD_KEY(KEY_NAMELESS);
- if (IS_FLG(FLG_ARTIFACT)) ADD_KEY(KEY_ARTIFACT);
if (IS_FLG(FLG_EGO)) ADD_KEY(KEY_EGO);
+ if (IS_FLG(FLG_ARTIFACT)) ADD_KEY(KEY_ARTIFACT);
+
if (IS_FLG(FLG_ITEMS)) ADD_KEY2(KEY_ITEMS);
else if (IS_FLG(FLG_WEAPONS)) ADD_KEY2(KEY_WEAPONS);
else if (IS_FLG(FLG_ARMORS)) ADD_KEY2(KEY_ARMORS);
else if (IS_FLG(FLG_HELMS)) ADD_KEY2(KEY_HELMS);
else if (IS_FLG(FLG_GLOVES)) ADD_KEY2(KEY_GLOVES);
else if (IS_FLG(FLG_BOOTS)) ADD_KEY2(KEY_BOOTS);
- else
+
+ /* You don't need sepalator after adjective */
+ /* 'artifact' is not true adjective */
+ else if (!IS_FLG(FLG_ARTIFACT))
sepa_flag = FALSE;
if (entry->name && entry->name[0])
{
- int i, j = 0;
+ int i, j = 0;
if (sepa_flag) strcat(buf, ":");
- i = strlen(buf);
- while (entry->name[j] && i < MAX_LINELEN - 2 - 1)
- {
+ i = strlen(buf);
+ while (entry->name[j] && i < MAX_LINELEN - 2 - 1)
+ {
#ifdef JP
- if (iskanji(entry->name[j]))
- buf[i++] = entry->name[j++];
+ if (iskanji(entry->name[j]))
+ buf[i++] = entry->name[j++];
#endif
- buf[i++] = entry->name[j++];
- }
- buf[i] = '\0';
- }
- else
- {
- if (entry->flag[0] == 0L && entry->flag[0] == 0L)
- return NULL;
+ buf[i++] = entry->name[j++];
+ }
+ buf[i] = '\0';
}
if (entry->insc)
{
- int i, j = 0;
+ int i, j = 0;
strcat(buf, "#");
- i = strlen(buf);
+ i = strlen(buf);
- while (entry->insc[j] && i < MAX_LINELEN - 2)
- {
+ while (entry->insc[j] && i < MAX_LINELEN - 2)
+ {
#ifdef JP
- if (iskanji(entry->insc[j]))
- buf[i++] = entry->insc[j++];
+ if (iskanji(entry->insc[j]))
+ buf[i++] = entry->insc[j++];
#endif
- buf[i++] = entry->insc[j++];
- }
- buf[i] = '\0';
+ buf[i++] = entry->insc[j++];
+ }
+ buf[i] = '\0';
}
- /* Free memory for original entry */
- autopick_free_entry(entry);
-
return string_make(buf);
}
+
+/*
+ * Reconstruct preference line from entry and kill entry
+ */
+static cptr autopick_line_from_entry_kill(autopick_type *entry)
+{
+ cptr ptr = autopick_line_from_entry(entry);
+
+ /* Free memory for original entry */
+ autopick_free_entry(entry);
+
+ return ptr;
+}
+
+
/*
* A function to create new entry
*/
act |= DONT_AUTOPICK;
str++;
}
+ else if ((act & DO_AUTOPICK) && *str == ';')
+ {
+ act &= ~DO_AUTOPICK;
+ act |= DO_QUERY_AUTOPICK;
+ str++;
+ }
else if ((act & DO_DISPLAY) && *str == '(')
{
act &= ~DO_DISPLAY;
/* Skip empty line */
if (*buf == 0) return FALSE;
- ptr = buf;
- old_ptr = NULL;
-
- while (old_ptr != ptr)
- {
- /* Save current location */
- old_ptr = ptr;
-
- if (MATCH_KEY(KEY_ALL)) ADD_FLG(FLG_ALL);
- if (MATCH_KEY(KEY_COLLECTING)) ADD_FLG(FLG_COLLECTING);
- if (MATCH_KEY(KEY_UNIDENTIFIED)) ADD_FLG(FLG_UNIDENTIFIED);
- if (MATCH_KEY(KEY_IDENTIFIED)) ADD_FLG(FLG_IDENTIFIED);
- if (MATCH_KEY(KEY_STAR_IDENTIFIED)) ADD_FLG(FLG_STAR_IDENTIFIED);
- if (MATCH_KEY(KEY_BOOSTED)) ADD_FLG(FLG_BOOSTED);
-
- /*** Weapons whose dd*ds is more than nn ***/
- if (MATCH_KEY2(KEY_MORE_THAN))
- {
- int k = 0;
- entry->dice = 0;
-
- /* Drop leading spaces */
- while (' ' == *ptr) ptr++;
-
- /* Read number */
- while (isdigit(*ptr))
- {
- entry->dice = 10 * entry->dice + (*ptr - '0');
- ptr++;
- k++;
- }
-
- if (k > 0 && k <= 2)
- {
- (void)MATCH_KEY(KEY_DICE);
- ADD_FLG(FLG_MORE_THAN);
- }
- else
- ptr = prev_ptr;
- }
-
- /*** Items whose magical bonus is more than n ***/
- if (MATCH_KEY2(KEY_MORE_BONUS))
- {
- int k = 0;
- entry->bonus = 0;
-
- /* Drop leading spaces */
- while (' ' == *ptr) ptr++;
-
- /* Read number */
- while (isdigit(*ptr))
- {
- entry->bonus = 10 * entry->bonus + (*ptr - '0');
- ptr++;
- k++;
- }
-
- if (k > 0 && k <= 2)
- {
- (void)MATCH_KEY(KEY_MORE_BONUS2);
- ADD_FLG(FLG_MORE_BONUS);
- }
- else
- ptr = prev_ptr;
- }
-
- if (MATCH_KEY(KEY_WORTHLESS)) ADD_FLG(FLG_WORTHLESS);
- if (MATCH_KEY(KEY_EGO)) ADD_FLG(FLG_EGO);
- if (MATCH_KEY(KEY_NAMELESS)) ADD_FLG(FLG_NAMELESS);
- if (MATCH_KEY(KEY_UNAWARE)) ADD_FLG(FLG_UNAWARE);
- if (MATCH_KEY(KEY_WANTED)) ADD_FLG(FLG_WANTED);
- if (MATCH_KEY(KEY_UNIQUE)) ADD_FLG(FLG_UNIQUE);
- if (MATCH_KEY(KEY_HUMAN)) ADD_FLG(FLG_HUMAN);
- if (MATCH_KEY(KEY_UNREADABLE)) ADD_FLG(FLG_UNREADABLE);
- if (MATCH_KEY(KEY_REALM1)) ADD_FLG(FLG_REALM1);
- if (MATCH_KEY(KEY_REALM2)) ADD_FLG(FLG_REALM2);
- if (MATCH_KEY(KEY_FIRST)) ADD_FLG(FLG_FIRST);
- if (MATCH_KEY(KEY_SECOND)) ADD_FLG(FLG_SECOND);
- if (MATCH_KEY(KEY_THIRD)) ADD_FLG(FLG_THIRD);
- if (MATCH_KEY(KEY_FOURTH)) ADD_FLG(FLG_FOURTH);
- }
+ ptr = prev_ptr = buf;
+ old_ptr = NULL;
+
+ while (old_ptr != ptr)
+ {
+ /* Save current location */
+ old_ptr = ptr;
+
+ if (MATCH_KEY(KEY_ALL)) ADD_FLG(FLG_ALL);
+ if (MATCH_KEY(KEY_COLLECTING)) ADD_FLG(FLG_COLLECTING);
+ if (MATCH_KEY(KEY_UNIDENTIFIED)) ADD_FLG(FLG_UNIDENTIFIED);
+ if (MATCH_KEY(KEY_IDENTIFIED)) ADD_FLG(FLG_IDENTIFIED);
+ if (MATCH_KEY(KEY_STAR_IDENTIFIED)) ADD_FLG(FLG_STAR_IDENTIFIED);
+ if (MATCH_KEY(KEY_BOOSTED)) ADD_FLG(FLG_BOOSTED);
+
+ /*** Weapons whose dd*ds is more than nn ***/
+ if (MATCH_KEY2(KEY_MORE_THAN))
+ {
+ int k = 0;
+ entry->dice = 0;
+
+ /* Drop leading spaces */
+ while (' ' == *ptr) ptr++;
+
+ /* Read number */
+ while ('0' <= *ptr && *ptr <= '9')
+ {
+ entry->dice = 10 * entry->dice + (*ptr - '0');
+ ptr++;
+ k++;
+ }
+
+ if (k > 0 && k <= 2)
+ {
+ (void)MATCH_KEY(KEY_DICE);
+ ADD_FLG(FLG_MORE_THAN);
+ }
+ else
+ ptr = prev_ptr;
+ }
+
+ /*** Items whose magical bonus is more than n ***/
+ if (MATCH_KEY2(KEY_MORE_BONUS))
+ {
+ int k = 0;
+ entry->bonus = 0;
+
+ /* Drop leading spaces */
+ while (' ' == *ptr) ptr++;
+
+ /* Read number */
+ while ('0' <= *ptr && *ptr <= '9')
+ {
+ entry->bonus = 10 * entry->bonus + (*ptr - '0');
+ ptr++;
+ k++;
+ }
+
+ if (k > 0 && k <= 2)
+ {
+ (void)MATCH_KEY(KEY_MORE_BONUS2);
+ ADD_FLG(FLG_MORE_BONUS);
+ }
+ else
+ ptr = prev_ptr;
+ }
+
+ if (MATCH_KEY(KEY_WORTHLESS)) ADD_FLG(FLG_WORTHLESS);
+ if (MATCH_KEY(KEY_EGO)) ADD_FLG(FLG_EGO);
+ if (MATCH_KEY(KEY_NAMELESS)) ADD_FLG(FLG_NAMELESS);
+ if (MATCH_KEY(KEY_UNAWARE)) ADD_FLG(FLG_UNAWARE);
+ if (MATCH_KEY(KEY_WANTED)) ADD_FLG(FLG_WANTED);
+ if (MATCH_KEY(KEY_UNIQUE)) ADD_FLG(FLG_UNIQUE);
+ if (MATCH_KEY(KEY_HUMAN)) ADD_FLG(FLG_HUMAN);
+ if (MATCH_KEY(KEY_UNREADABLE)) ADD_FLG(FLG_UNREADABLE);
+ if (MATCH_KEY(KEY_REALM1)) ADD_FLG(FLG_REALM1);
+ if (MATCH_KEY(KEY_REALM2)) ADD_FLG(FLG_REALM2);
+ if (MATCH_KEY(KEY_FIRST)) ADD_FLG(FLG_FIRST);
+ if (MATCH_KEY(KEY_SECOND)) ADD_FLG(FLG_SECOND);
+ if (MATCH_KEY(KEY_THIRD)) ADD_FLG(FLG_THIRD);
+ if (MATCH_KEY(KEY_FOURTH)) ADD_FLG(FLG_FOURTH);
+ }
/* Not yet found any noun */
prev_flg = -1;
*/
static bool is_autopick_aux(object_type *o_ptr, autopick_type *entry, cptr o_name)
{
- int j;
- cptr ptr = entry->name;
-
- /*** Unidentified ***/
- if (IS_FLG(FLG_UNIDENTIFIED)
- && (object_known_p(o_ptr) || (o_ptr->ident & IDENT_SENSE)))
- return FALSE;
-
- /*** Identified ***/
- if (IS_FLG(FLG_IDENTIFIED) && !object_known_p(o_ptr))
- return FALSE;
-
- /*** *Identified* ***/
- if (IS_FLG(FLG_STAR_IDENTIFIED) &&
- (!object_known_p(o_ptr) || !(o_ptr->ident & IDENT_MENTAL)))
- return FALSE;
-
- /*** Dice boosted (weapon of slaying) ***/
- if (IS_FLG(FLG_BOOSTED))
- {
- object_kind *k_ptr = &k_info[o_ptr->k_idx];
+ int j;
+ cptr ptr = entry->name;
+
+ /*** Unidentified ***/
+ if (IS_FLG(FLG_UNIDENTIFIED)
+ && (object_known_p(o_ptr) || (o_ptr->ident & IDENT_SENSE)))
+ return FALSE;
+
+ /*** Identified ***/
+ if (IS_FLG(FLG_IDENTIFIED) && !object_known_p(o_ptr))
+ return FALSE;
+
+ /*** *Identified* ***/
+ if (IS_FLG(FLG_STAR_IDENTIFIED) &&
+ (!object_known_p(o_ptr) || !(o_ptr->ident & IDENT_MENTAL)))
+ return FALSE;
+
+ /*** Dice boosted (weapon of slaying) ***/
+ if (IS_FLG(FLG_BOOSTED))
+ {
+ object_kind *k_ptr = &k_info[o_ptr->k_idx];
- switch( o_ptr->tval )
- {
- case TV_HAFTED:
- case TV_POLEARM:
- case TV_SWORD:
- case TV_DIGGING:
- if ((o_ptr->dd != k_ptr->dd) || (o_ptr->ds != k_ptr->ds))
- break;
- else
- return FALSE;
- default:
- return FALSE;
- }
- }
-
- /*** Weapons whic dd*ds is more than nn ***/
- if (IS_FLG(FLG_MORE_THAN))
- {
- if (o_ptr->dd * o_ptr->ds < entry->dice)
- return FALSE;
- }
+ switch( o_ptr->tval )
+ {
+ case TV_HAFTED:
+ case TV_POLEARM:
+ case TV_SWORD:
+ case TV_DIGGING:
+ if ((o_ptr->dd != k_ptr->dd) || (o_ptr->ds != k_ptr->ds))
+ break;
+ else
+ return FALSE;
+ default:
+ return FALSE;
+ }
+ }
+
+ /*** Weapons which dd*ds is more than nn ***/
+ if (IS_FLG(FLG_MORE_THAN))
+ {
+ if (o_ptr->dd * o_ptr->ds < entry->dice)
+ return FALSE;
+ }
- /*** Weapons whic dd*ds is more than nn ***/
- if (IS_FLG(FLG_MORE_BONUS))
- {
- if (!object_known_p(o_ptr)) return FALSE;
-
- if (k_info[o_ptr->k_idx].pval ||
- (o_ptr->name2 && e_info[o_ptr->name2].max_pval))
- {
- if (o_ptr->pval < entry->bonus) return FALSE;
- }
- else
- {
- if (o_ptr->to_h < entry->bonus &&
- o_ptr->to_d < entry->bonus &&
- o_ptr->to_a < entry->bonus &&
- o_ptr->pval < entry->bonus)
- return FALSE;
- }
- }
+ /*** Weapons whic dd*ds is more than nn ***/
+ if (IS_FLG(FLG_MORE_BONUS))
+ {
+ if (!object_known_p(o_ptr)) return FALSE;
+
+ if (o_ptr->pval)
+ {
+ if (o_ptr->pval < entry->bonus) return FALSE;
+ }
+ else
+ {
+ if (o_ptr->to_h < entry->bonus &&
+ o_ptr->to_d < entry->bonus &&
+ o_ptr->to_a < entry->bonus &&
+ o_ptr->pval < entry->bonus)
+ return FALSE;
+ }
+ }
- /*** Worthless items ***/
- if (IS_FLG(FLG_WORTHLESS) && object_value(o_ptr) > 0)
- return FALSE;
-
- /*** Artifact object ***/
- if (IS_FLG(FLG_ARTIFACT))
- {
- if (!object_known_p(o_ptr) || (!o_ptr->name1 && !o_ptr->art_name))
- return FALSE;
- }
-
- /*** Ego object ***/
- if (IS_FLG(FLG_EGO))
- {
- if (!object_known_p(o_ptr) || !o_ptr->name2)
- return FALSE;
- }
-
- /*** Nameless ***/
- if (IS_FLG(FLG_NAMELESS))
- {
- switch (o_ptr->tval)
- {
- case TV_WHISTLE:
- case TV_SHOT: case TV_ARROW: case TV_BOLT: case TV_BOW:
- case TV_DIGGING: case TV_HAFTED: case TV_POLEARM: case TV_SWORD:
- case TV_BOOTS: case TV_GLOVES: case TV_HELM: case TV_CROWN:
- case TV_SHIELD: case TV_CLOAK:
- case TV_SOFT_ARMOR: case TV_HARD_ARMOR: case TV_DRAG_ARMOR:
- case TV_LITE: case TV_AMULET: case TV_RING: case TV_CARD:
- if ((!object_known_p(o_ptr) || o_ptr->inscription
- || o_ptr->name1 || o_ptr->name2 || o_ptr->art_name))
- return FALSE;
- break;
- default:
- /* don't match */
- return FALSE;
- }
- }
-
- /*** Unaware items ***/
- if (IS_FLG(FLG_UNAWARE) && object_aware_p(o_ptr))
- return FALSE;
-
- /*** Wanted monster's corpse/skeletons ***/
- if (IS_FLG(FLG_WANTED) &&
- (o_ptr->tval != TV_CORPSE || !object_is_shoukinkubi(o_ptr)))
- return FALSE;
-
- /*** Unique monster's corpse/skeletons/statues ***/
- if (IS_FLG(FLG_UNIQUE) &&
- ((o_ptr->tval != TV_CORPSE && o_ptr->tval != TV_STATUE) ||
- !(r_info[o_ptr->pval].flags1 & RF1_UNIQUE)))
- return FALSE;
-
- /*** Human corpse/skeletons (for Daemon magic) ***/
- if (IS_FLG(FLG_HUMAN) &&
- (o_ptr->tval != TV_CORPSE ||
- !strchr("pht", r_info[o_ptr->pval].d_char)))
- return FALSE;
-
- /*** Unreadable spellbooks ***/
- if (IS_FLG(FLG_UNREADABLE) &&
- (o_ptr->tval < TV_LIFE_BOOK ||
- check_book_realm(o_ptr->tval, o_ptr->sval)))
- return FALSE;
-
- /*** First realm spellbooks ***/
- if (IS_FLG(FLG_REALM1) &&
- (REALM1_BOOK != o_ptr->tval ||
- p_ptr->pclass == CLASS_SORCERER ||
- p_ptr->pclass == CLASS_RED_MAGE))
- return FALSE;
-
- /*** Second realm spellbooks ***/
- if (IS_FLG(FLG_REALM2) &&
- (REALM2_BOOK != o_ptr->tval ||
- p_ptr->pclass == CLASS_SORCERER ||
- p_ptr->pclass == CLASS_RED_MAGE))
- return FALSE;
-
- /*** First rank spellbooks ***/
- if (IS_FLG(FLG_FIRST) &&
- (o_ptr->tval < TV_LIFE_BOOK || 0 != o_ptr->sval))
- return FALSE;
-
- /*** Second rank spellbooks ***/
- if (IS_FLG(FLG_SECOND) &&
- (o_ptr->tval < TV_LIFE_BOOK || 1 != o_ptr->sval))
- return FALSE;
-
- /*** Third rank spellbooks ***/
- if (IS_FLG(FLG_THIRD) &&
- (o_ptr->tval < TV_LIFE_BOOK || 2 != o_ptr->sval))
- return FALSE;
-
- /*** Fourth rank spellbooks ***/
- if (IS_FLG(FLG_FOURTH) &&
- (o_ptr->tval < TV_LIFE_BOOK || 3 != o_ptr->sval))
- return FALSE;
-
- /*** Items ***/
- if (IS_FLG(FLG_WEAPONS))
- {
- switch(o_ptr->tval)
- {
- case TV_BOW: case TV_HAFTED: case TV_POLEARM:
- case TV_SWORD: case TV_DIGGING:
- break;
- default: return FALSE;
- }
- }
- else if (IS_FLG(FLG_ARMORS))
- {
- switch(o_ptr->tval)
- {
- case TV_BOOTS: case TV_GLOVES: case TV_CLOAK: case TV_CROWN:
- case TV_HELM: case TV_SHIELD: case TV_SOFT_ARMOR:
- case TV_HARD_ARMOR: case TV_DRAG_ARMOR:
- break;
- default: return FALSE;
- }
- }
- else if (IS_FLG(FLG_MISSILES))
- {
- switch(o_ptr->tval)
- {
- case TV_SHOT: case TV_BOLT: case TV_ARROW:
- break;
- default: return FALSE;
- }
- }
- else if (IS_FLG(FLG_DEVICES))
- {
- switch(o_ptr->tval)
- {
- case TV_SCROLL: case TV_STAFF: case TV_WAND: case TV_ROD:
- break;
- default: return FALSE;
- }
- }
- else if (IS_FLG(FLG_LIGHTS))
- {
- if (!(o_ptr->tval == TV_LITE))
- return FALSE;
- }
- else if (IS_FLG(FLG_JUNKS))
- {
- switch(o_ptr->tval)
- {
- case TV_SKELETON: case TV_BOTTLE:
- case TV_JUNK: case TV_STATUE:
- break;
- default: return FALSE;
- }
- }
- else if (IS_FLG(FLG_SPELLBOOKS))
- {
- if (!(o_ptr->tval >= TV_LIFE_BOOK))
- return FALSE;
- }
- else if (IS_FLG(FLG_HAFTED))
- {
- if (!(o_ptr->tval == TV_HAFTED))
- return FALSE;
- }
- else if (IS_FLG(FLG_SHIELDS))
- {
- if (!(o_ptr->tval == TV_SHIELD))
- return FALSE;
- }
- else if (IS_FLG(FLG_BOWS))
- {
- if (!(o_ptr->tval == TV_BOW))
- return FALSE;
- }
- else if (IS_FLG(FLG_RINGS))
- {
- if (!(o_ptr->tval == TV_RING))
- return FALSE;
- }
- else if (IS_FLG(FLG_AMULETS))
- {
- if (!(o_ptr->tval == TV_AMULET))
- return FALSE;
- }
- else if (IS_FLG(FLG_SUITS))
- {
- if (!(o_ptr->tval == TV_DRAG_ARMOR ||
- o_ptr->tval == TV_HARD_ARMOR ||
- o_ptr->tval == TV_SOFT_ARMOR))
- return FALSE;
- }
- else if (IS_FLG(FLG_CLOAKS))
- {
- if (!(o_ptr->tval == TV_CLOAK))
- return FALSE;
- }
- else if (IS_FLG(FLG_HELMS))
- {
- if (!(o_ptr->tval == TV_CROWN || o_ptr->tval == TV_HELM))
- return FALSE;
- }
- else if (IS_FLG(FLG_GLOVES))
- {
- if (!(o_ptr->tval == TV_GLOVES))
- return FALSE;
- }
- else if (IS_FLG(FLG_BOOTS))
- {
- if (!(o_ptr->tval == TV_BOOTS))
- return FALSE;
- }
-
- /* Keyword don't match */
- if (*ptr == '^')
- {
- ptr++;
- if (strncmp(o_name, ptr, strlen(ptr))) return FALSE;
- }
- else
- {
+ /*** Worthless items ***/
+ if (IS_FLG(FLG_WORTHLESS) && object_value(o_ptr) > 0)
+ return FALSE;
+
+ /*** Artifact object ***/
+ if (IS_FLG(FLG_ARTIFACT))
+ {
+ if (!object_known_p(o_ptr) || (!o_ptr->name1 && !o_ptr->art_name))
+ return FALSE;
+ }
+
+ /*** Ego object ***/
+ if (IS_FLG(FLG_EGO))
+ {
+ if (!object_known_p(o_ptr) || !o_ptr->name2)
+ return FALSE;
+ }
+
+ /*** Nameless ***/
+ if (IS_FLG(FLG_NAMELESS))
+ {
+ switch (o_ptr->tval)
+ {
+ case TV_WHISTLE:
+ case TV_SHOT: case TV_ARROW: case TV_BOLT: case TV_BOW:
+ case TV_DIGGING: case TV_HAFTED: case TV_POLEARM: case TV_SWORD:
+ case TV_BOOTS: case TV_GLOVES: case TV_HELM: case TV_CROWN:
+ case TV_SHIELD: case TV_CLOAK:
+ case TV_SOFT_ARMOR: case TV_HARD_ARMOR: case TV_DRAG_ARMOR:
+ case TV_LITE: case TV_AMULET: case TV_RING: case TV_CARD:
+ if ((!object_known_p(o_ptr) || o_ptr->inscription
+ || o_ptr->name1 || o_ptr->name2 || o_ptr->art_name))
+ return FALSE;
+ break;
+ default:
+ /* don't match */
+ return FALSE;
+ }
+ }
+
+ /*** Unaware items ***/
+ if (IS_FLG(FLG_UNAWARE) && object_aware_p(o_ptr))
+ return FALSE;
+
+ /*** Wanted monster's corpse/skeletons ***/
+ if (IS_FLG(FLG_WANTED) &&
+ (o_ptr->tval != TV_CORPSE || !object_is_shoukinkubi(o_ptr)))
+ return FALSE;
+
+ /*** Unique monster's corpse/skeletons/statues ***/
+ if (IS_FLG(FLG_UNIQUE) &&
+ ((o_ptr->tval != TV_CORPSE && o_ptr->tval != TV_STATUE) ||
+ !(r_info[o_ptr->pval].flags1 & RF1_UNIQUE)))
+ return FALSE;
+
+ /*** Human corpse/skeletons (for Daemon magic) ***/
+ if (IS_FLG(FLG_HUMAN) &&
+ (o_ptr->tval != TV_CORPSE ||
+ !strchr("pht", r_info[o_ptr->pval].d_char)))
+ return FALSE;
+
+ /*** Unreadable spellbooks ***/
+ if (IS_FLG(FLG_UNREADABLE) &&
+ (o_ptr->tval < TV_LIFE_BOOK ||
+ check_book_realm(o_ptr->tval, o_ptr->sval)))
+ return FALSE;
+
+ /*** First realm spellbooks ***/
+ if (IS_FLG(FLG_REALM1) &&
+ (REALM1_BOOK != o_ptr->tval ||
+ p_ptr->pclass == CLASS_SORCERER ||
+ p_ptr->pclass == CLASS_RED_MAGE))
+ return FALSE;
+
+ /*** Second realm spellbooks ***/
+ if (IS_FLG(FLG_REALM2) &&
+ (REALM2_BOOK != o_ptr->tval ||
+ p_ptr->pclass == CLASS_SORCERER ||
+ p_ptr->pclass == CLASS_RED_MAGE))
+ return FALSE;
+
+ /*** First rank spellbooks ***/
+ if (IS_FLG(FLG_FIRST) &&
+ (o_ptr->tval < TV_LIFE_BOOK || 0 != o_ptr->sval))
+ return FALSE;
+
+ /*** Second rank spellbooks ***/
+ if (IS_FLG(FLG_SECOND) &&
+ (o_ptr->tval < TV_LIFE_BOOK || 1 != o_ptr->sval))
+ return FALSE;
+
+ /*** Third rank spellbooks ***/
+ if (IS_FLG(FLG_THIRD) &&
+ (o_ptr->tval < TV_LIFE_BOOK || 2 != o_ptr->sval))
+ return FALSE;
+
+ /*** Fourth rank spellbooks ***/
+ if (IS_FLG(FLG_FOURTH) &&
+ (o_ptr->tval < TV_LIFE_BOOK || 3 != o_ptr->sval))
+ return FALSE;
+
+ /*** Items ***/
+ if (IS_FLG(FLG_WEAPONS))
+ {
+ switch(o_ptr->tval)
+ {
+ case TV_BOW: case TV_HAFTED: case TV_POLEARM:
+ case TV_SWORD: case TV_DIGGING:
+ break;
+ default: return FALSE;
+ }
+ }
+ else if (IS_FLG(FLG_ARMORS))
+ {
+ switch(o_ptr->tval)
+ {
+ case TV_BOOTS: case TV_GLOVES: case TV_CLOAK: case TV_CROWN:
+ case TV_HELM: case TV_SHIELD: case TV_SOFT_ARMOR:
+ case TV_HARD_ARMOR: case TV_DRAG_ARMOR:
+ break;
+ default: return FALSE;
+ }
+ }
+ else if (IS_FLG(FLG_MISSILES))
+ {
+ switch(o_ptr->tval)
+ {
+ case TV_SHOT: case TV_BOLT: case TV_ARROW:
+ break;
+ default: return FALSE;
+ }
+ }
+ else if (IS_FLG(FLG_DEVICES))
+ {
+ switch(o_ptr->tval)
+ {
+ case TV_SCROLL: case TV_STAFF: case TV_WAND: case TV_ROD:
+ break;
+ default: return FALSE;
+ }
+ }
+ else if (IS_FLG(FLG_LIGHTS))
+ {
+ if (!(o_ptr->tval == TV_LITE))
+ return FALSE;
+ }
+ else if (IS_FLG(FLG_JUNKS))
+ {
+ switch(o_ptr->tval)
+ {
+ case TV_SKELETON: case TV_BOTTLE:
+ case TV_JUNK: case TV_STATUE:
+ break;
+ default: return FALSE;
+ }
+ }
+ else if (IS_FLG(FLG_SPELLBOOKS))
+ {
+ if (!(o_ptr->tval >= TV_LIFE_BOOK))
+ return FALSE;
+ }
+ else if (IS_FLG(FLG_HAFTED))
+ {
+ if (!(o_ptr->tval == TV_HAFTED))
+ return FALSE;
+ }
+ else if (IS_FLG(FLG_SHIELDS))
+ {
+ if (!(o_ptr->tval == TV_SHIELD))
+ return FALSE;
+ }
+ else if (IS_FLG(FLG_BOWS))
+ {
+ if (!(o_ptr->tval == TV_BOW))
+ return FALSE;
+ }
+ else if (IS_FLG(FLG_RINGS))
+ {
+ if (!(o_ptr->tval == TV_RING))
+ return FALSE;
+ }
+ else if (IS_FLG(FLG_AMULETS))
+ {
+ if (!(o_ptr->tval == TV_AMULET))
+ return FALSE;
+ }
+ else if (IS_FLG(FLG_SUITS))
+ {
+ if (!(o_ptr->tval == TV_DRAG_ARMOR ||
+ o_ptr->tval == TV_HARD_ARMOR ||
+ o_ptr->tval == TV_SOFT_ARMOR))
+ return FALSE;
+ }
+ else if (IS_FLG(FLG_CLOAKS))
+ {
+ if (!(o_ptr->tval == TV_CLOAK))
+ return FALSE;
+ }
+ else if (IS_FLG(FLG_HELMS))
+ {
+ if (!(o_ptr->tval == TV_CROWN || o_ptr->tval == TV_HELM))
+ return FALSE;
+ }
+ else if (IS_FLG(FLG_GLOVES))
+ {
+ if (!(o_ptr->tval == TV_GLOVES))
+ return FALSE;
+ }
+ else if (IS_FLG(FLG_BOOTS))
+ {
+ if (!(o_ptr->tval == TV_BOOTS))
+ return FALSE;
+ }
+
+ /* Keyword don't match */
+ if (*ptr == '^')
+ {
+ ptr++;
+ if (strncmp(o_name, ptr, strlen(ptr))) return FALSE;
+ }
+ else
+ {
#ifdef JP
- if (!strstr_j(o_name, ptr)) return FALSE;
+ if (!strstr_j(o_name, ptr)) return FALSE;
#else
- if (!strstr(o_name, ptr)) return FALSE;
+ if (!strstr(o_name, ptr)) return FALSE;
#endif
- }
-
- /* TRUE when it need not to be 'collecting' */
- if (!IS_FLG(FLG_COLLECTING)) return TRUE;
-
- /* Check if there is a same item */
- for (j = 0; j < INVEN_PACK; j++)
- {
- /*
- * 'Collecting' means the item must be absorbed
- * into an inventory slot.
- * But an item can not be absorbed into itself!
- */
- if ((&inventory[j] != o_ptr) &&
- object_similar(&inventory[j], o_ptr))
- return TRUE;
- }
-
- /* Not collecting */
- return FALSE;
+ }
+
+ /* TRUE when it need not to be 'collecting' */
+ if (!IS_FLG(FLG_COLLECTING)) return TRUE;
+
+ /* Check if there is a same item */
+ for (j = 0; j < INVEN_PACK; j++)
+ {
+ /*
+ * 'Collecting' means the item must be absorbed
+ * into an inventory slot.
+ * But an item can not be absorbed into itself!
+ */
+ if ((&inventory[j] != o_ptr) &&
+ object_similar(&inventory[j], o_ptr))
+ return TRUE;
+ }
+
+ /* Not collecting */
+ return FALSE;
}
{
autopick_type *entry = &autopick_list[i];
- if (is_autopick_aux(o_ptr, entry, o_name)) return i;
+ if (is_autopick_aux(o_ptr, entry, o_name)) return i;
}
- /* No matching entry */
+ /* No matching entry */
return -1;
}
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;
+
+ if (leave_special)
+ {
+#if 0
+ if (p_ptr->prace == RACE_SKELETON)
+ {
+ if (o_ptr->tval == TV_SKELETON ||
+ (o_ptr->tval == TV_CORPSE && o_ptr->sval == SV_SKELETON))
+ return FALSE;
+ }
+ else
+#endif
+ if (p_ptr->prace == RACE_DEMON)
+ {
+ if (o_ptr->tval == TV_CORPSE &&
+ o_ptr->sval == SV_CORPSE &&
+ strchr("pht", r_info[o_ptr->pval].d_char))
+ return FALSE;
+ }
+
+ if (p_ptr->pclass == CLASS_ARCHER)
+ {
+ if (o_ptr->tval == TV_SKELETON ||
+ (o_ptr->tval == TV_CORPSE && o_ptr->sval == SV_SKELETON))
+ return FALSE;
+ }
+ else if (p_ptr->pclass == CLASS_NINJA)
+ {
+ if (o_ptr->tval == TV_LITE &&
+ o_ptr->name2 == EGO_LITE_DARKNESS)
+ return FALSE;
+ }
+ }
if (o_ptr->tval == TV_GOLD) return FALSE;
if ((idx < 0 || !autopick_list[idx].insc) && !o_ptr->inscription)
return;
- if (o_ptr->inscription)
- o_ptr->inscription = inscribe_flags(o_ptr, quark_str(o_ptr->inscription));
- else
- o_ptr->inscription = inscribe_flags(o_ptr, autopick_list[idx].insc);
+ if (!o_ptr->inscription)
+ o_ptr->inscription = quark_add(autopick_list[idx].insc);
if (item > INVEN_PACK)
{
/*
* Automatically destroy an item if it is to be destroyed
*/
-bool auto_destroy_item(int item, int autopick_idx, bool wait_optimize)
+bool auto_destroy_item(int item, int autopick_idx)
{
bool destroy = FALSE;
- char o_name[MAX_NLEN];
object_type *o_ptr;
/* Don't destroy equipped items */
disturb(0,0);
- /* Describe the object (with {terrible/special}) */
- object_desc(o_name, o_ptr, TRUE, 3);
-
/* Artifact? */
if (!can_player_destroy_object(o_ptr))
{
+ char o_name[MAX_NLEN];
+
+ /* Describe the object (with {terrible/special}) */
+ object_desc(o_name, o_ptr, TRUE, 3);
+
/* Message */
#ifdef JP
msg_format("%s¤ÏÇ˲õÉÔǽ¤À¡£", o_name);
}
/* Record name of destroyed item */
- COPY(&autopick_last_destroyed_object, o_ptr, object_type);
+ COPY(&autopick_last_destroyed_object, o_ptr, object_type);
+
+ /* Destroy Later */
+ o_ptr->marked |= OM_AUTODESTROY;
+ p_ptr->notice |= PN_AUTODESTROY;
+
+ return TRUE;
+}
+
+
+/*
+ * Auto-destroy marked item
+ */
+static void delayed_auto_destroy_aux(int item)
+{
+ object_type *o_ptr;
- /* Eliminate the item (from the pack) */
- if (item >= 0)
+ /* Get the item (in the pack) */
+ if (item >= 0) o_ptr = &inventory[item];
+
+ /* Get the item (on the floor) */
+ else o_ptr = &o_list[0 - item];
+
+ if (o_ptr->k_idx && o_ptr->marked & OM_AUTODESTROY)
{
- inven_item_increase(item, -(o_ptr->number));
+ char o_name[MAX_NLEN];
- /*
- * always optimize equipment.
- * optimize inventry only when wait_optimize is FALSE.
- */
- if (!wait_optimize || item > INVEN_PACK)
+ /* Describe the object (with {terrible/special}) */
+ object_desc(o_name, o_ptr, TRUE, 3);
+
+ /* Eliminate the item (from the pack) */
+ if (item >= 0)
+ {
+ inven_item_increase(item, -(o_ptr->number));
inven_item_optimize(item);
- }
+ }
- /* Eliminate the item (from the floor) */
- else
- {
- delete_object_idx(0 - item);
- }
+ /* Eliminate the item (from the floor) */
+ else
+ {
+ delete_object_idx(0 - item);
+ }
- /* Print a message */
+ /* Print a message */
#ifdef JP
- msg_format("%s¤ò¼«Æ°Ç˲õ¤·¤Þ¤¹¡£", o_name);
+ msg_format("%s¤ò¼«Æ°Ç˲õ¤·¤Þ¤¹¡£", o_name);
#else
- msg_format("Auto-destroying %s.", o_name);
+ msg_format("Auto-destroying %s.", o_name);
#endif
-
- return TRUE;
+ }
}
/*
- * Optimize all inventry items after consumption of staves or scrolls.
+ * Auto-destroy marked item in inventry and on floor
*/
-void optimize_inventry_auto_destroy(void)
+void delayed_auto_destroy(void)
{
- int i;
+ int item;
+
+ /*
+ * Scan inventry in reverse order to prevent
+ * skipping after inven_item_optimize()
+ */
+ for (item = INVEN_TOTAL - 1; item >= 0 ; item--)
+ delayed_auto_destroy_aux(item);
- for (i = 0; i <= INVEN_PACK; i++)
- inven_item_optimize(i);
+ /* 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);
+ item = next;
+ }
}
/* Item index for floor -1,-2,-3,... */
auto_inscribe_item((-this_o_idx), idx);
- if (idx >= 0 && (autopick_list[idx].action & DO_AUTOPICK))
+ if (idx >= 0 &&
+ (autopick_list[idx].action & (DO_AUTOPICK | DO_QUERY_AUTOPICK)))
{
disturb(0,0);
#else
msg_format("You have no room for %s.", o_name);
#endif
+ /* Hack - remember that the item has given a message here. */
+ o_ptr->marked |= OM_NOMSG;
+
continue;
}
+ else if (autopick_list[idx].action & DO_QUERY_AUTOPICK)
+ {
+ char out_val[MAX_NLEN+20];
+ char o_name[MAX_NLEN];
+
+ if (o_ptr->marked & OM_NO_QUERY)
+ {
+ /* Already answered as 'No' */
+ continue;
+ }
+
+ /* Describe the object */
+ object_desc(o_name, o_ptr, TRUE, 3);
+
+#ifdef JP
+ sprintf(out_val, "%s¤ò½¦¤¤¤Þ¤¹¤«? ", o_name);
+#else
+ sprintf(out_val, "Pick up %s? ", o_name);
+#endif
+
+ if (!get_check(out_val))
+ {
+ /* Hack - remember that the item has given a message here. */
+ o_ptr->marked |= (OM_NOMSG | OM_NO_QUERY);
+ continue;
+ }
+
+ }
py_pickup_aux(this_o_idx);
continue;
*/
else
{
- if (auto_destroy_item((-this_o_idx), idx, FALSE))
+ if (auto_destroy_item((-this_o_idx), idx))
continue;
}
}
else if (IS_FLG(FLG_HELMS))
body_str = "¥Ø¥ë¥á¥Ã¥È¤ä´§";
else if (IS_FLG(FLG_GLOVES))
- body_str = "¾®¼ê";
+ body_str = "äƼê";
else if (IS_FLG(FLG_BOOTS))
body_str = "¥Ö¡¼¥Ä";
}
if (insc)
- strncat(buff, format("¤Ë¡Ö%s¡×¤È¹ï¤ó¤Ç", insc), 80);
+ {
+ strncat(buff, format("¤Ë¡Ö%s¡×", insc), 80);
+
+ if (strstr(insc, "%%all"))
+ strcat(buff, "(%%all¤ÏÁ´Ç½ÎϤòɽ¤¹±Ñ»ú¤Îµ¹æ¤ÇÃÖ´¹)");
+ else if (strstr(insc, "%all"))
+ strcat(buff, "(%all¤ÏÁ´Ç½ÎϤòɽ¤¹µ¹æ¤ÇÃÖ´¹)");
+ else if (strstr(insc, "%%"))
+ strcat(buff, "(%%¤ÏÄɲÃǽÎϤòɽ¤¹±Ñ»ú¤Îµ¹æ¤ÇÃÖ´¹)");
+ else if (strstr(insc, "%"))
+ strcat(buff, "(%¤ÏÄɲÃǽÎϤòɽ¤¹µ¹æ¤ÇÃÖ´¹)");
+
+ strcat(buff, "¤È¹ï¤ó¤Ç");
+ }
else
strcat(buff, "¤ò");
strcat(buff, "ÊüÃÖ¤¹¤ë¡£");
else if (act & DO_AUTODESTROY)
strcat(buff, "Ç˲õ¤¹¤ë¡£");
+ else if (act & DO_QUERY_AUTOPICK)
+ strcat(buff, "³Îǧ¤Î¸å¤Ë½¦¤¦¡£");
else
strcat(buff, "½¦¤¦¡£");
strcpy(buff, "Leave on floor ");
else if (act & DO_AUTODESTROY)
strcpy(buff, "Destroy ");
+ else if (act & DO_QUERY_AUTOPICK)
+ strcpy(buff, "Ask to pick up ");
else
strcpy(buff, "Pickup ");
/* Auto-insctiption */
if (insc)
- strncat(buff, format("and inscribe \"%s\" on ", insc), 80);
+ {
+ strncat(buff, format("and inscribe \"%s\"", insc), 80);
+
+ if (strstr(insc, "%all"))
+ strcat(buff, ", replacing %all with code string representing all abilities,");
+ else if (strstr(insc, "%"))
+ strcat(buff, ", replacing % with code string representing extra random abilities,");
+
+ strcat(buff, " on ");
+ }
/* Adjective */
if (!before_n)
if (act & DO_DISPLAY)
{
if (act & DONT_AUTOPICK)
- strcat(buff, " Display these items when you press 'N' in the full map('M').");
+ strcat(buff, " Display these items when you press the N key in the full 'M'ap.");
else if (act & DO_AUTODESTROY)
- strcat(buff, " Display these items when you press 'K' in the full map('M').");
+ strcat(buff, " Display these items when you press the K key in the full 'M'ap.");
else
- strcat(buff, " Display these items when you press 'M' in the full map('M').");
+ strcat(buff, " Display these items when you press the M key in the full 'M'ap.");
}
else
strcat(buff, " Not displayed in the full map.");
if (user)
{
- /* Hack -- drop permissions */
- safe_setuid_drop();
- path_build(buf, 1024, ANGBAND_DIR_USER, filename);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, filename);
}
else
{
- path_build(buf, 1024, ANGBAND_DIR_PREF, filename);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_PREF, filename);
}
/* Open the file */
C_MAKE(lines_list, MAX_LINES, cptr);
/* Parse it */
- while (0 == my_fgets(fff, buf, 1024))
+ while (0 == my_fgets(fff, buf, sizeof(buf)))
{
lines_list[lines++] = string_make(buf);
if (lines >= MAX_LINES - 1) break;
my_fclose(fff);
}
- /* Grab priv's */
- safe_setuid_grab();
-
if (!fff) return NULL;
return lines_list;
}
-static cptr *read_pickpref_text_lines(void)
+
+#define PT_DEFAULT 0
+#define PT_WITH_PNAME 1
+
+static cptr *read_pickpref_text_lines(int *filename_mode_p)
{
char buf[1024];
cptr *lines_list;
#else
lines_list = read_text_lines("pickpref.prf", TRUE);
#endif
+ *filename_mode_p = PT_DEFAULT;
}
if (!lines_list)
#else
lines_list = read_text_lines("pickpref.prf", FALSE);
#endif
+ *filename_mode_p = PT_WITH_PNAME;
}
if (!lines_list)
/* Allocate list of pointers */
C_MAKE(lines_list, MAX_LINES, cptr);
lines_list[0] = string_make("");
+ *filename_mode_p = PT_WITH_PNAME;
}
return lines_list;
}
int lines = 0;
char buf[1024];
- /* Hack -- drop permissions */
- safe_setuid_drop();
-
/* Build the filename */
- path_build(buf, 1024, ANGBAND_DIR_USER, filename);
+ path_build(buf, sizeof(buf), ANGBAND_DIR_USER, filename);
/* Open the file */
fff = my_fopen(buf, "w");
my_fclose(fff);
}
- /* Grab priv's */
- safe_setuid_grab();
-
if (!fff) return FALSE;
return TRUE;
}
else
ADD_FLG(flg);
- lines_list[y] = autopick_line_from_entry(entry);
+ lines_list[y] = autopick_line_from_entry_kill(entry);
}
/*
q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÅÐÏ¿¤·¤Þ¤¹¤«? ";
s = "¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£";
#else
- q = "Entry which item? ";
- s = "You have nothing to entry.";
+ q = "Enter which item? ";
+ s = "You have nothing to enter.";
#endif
- o_ptr = choose_object(q, s);
+ o_ptr = choose_object(q, s);
if (!o_ptr) return FALSE;
autopick_entry_from_object(entry, o_ptr);
*/
static bool get_string_for_search(object_type **o_handle, cptr *search_strp)
{
- int pos = 0;
+ int pos = 0;
cptr q, s;
- char buf[MAX_NLEN+20];
+ char buf[MAX_NLEN+20];
#ifdef JP
- int k_flag[MAX_NLEN+20];
- char prompt[] = "¸¡º÷(^I:»ý¤Áʪ ^L:Ç˲õ¤µ¤ì¤¿Êª): ";
+ int k_flag[MAX_NLEN+20];
+ char prompt[] = "¸¡º÷(^I:»ý¤Áʪ ^L:Ç˲õ¤µ¤ì¤¿Êª): ";
#else
- char prompt[] = "Search key(^I:inven ^L:destroyed): ";
+ char prompt[] = "Search key(^I:inven ^L:destroyed): ";
#endif
- int col = sizeof(prompt) - 1;
+ int col = sizeof(prompt) - 1;
- if (*search_strp) strcpy(buf, *search_strp);
- else buf[0] = '\0';
+ if (*search_strp) strcpy(buf, *search_strp);
+ else buf[0] = '\0';
/* Display prompt */
prt(prompt, 0, 0);
/* Display the default answer */
- Term_erase(col, 0, 255);
+ Term_erase(col, 0, 255);
Term_putstr(col, 0, -1, TERM_YELLOW, buf);
/* Process input */
while (1)
{
- object_type *o_ptr;
- int i;
+ object_type *o_ptr;
+ int i;
- /* Place cursor */
+ /* Place cursor */
Term_gotoxy(col + pos, 0);
/* Do not process macros except special keys */
case '\n':
case '\r':
- if (!pos && *o_handle) return TRUE;
- string_free(*search_strp);
- *search_strp = string_make(buf);
- *o_handle = NULL;
- return TRUE;
-
- case KTRL('i'):
- /* Get an item */
+ if (!pos && *o_handle) return TRUE;
+ string_free(*search_strp);
+ *search_strp = string_make(buf);
+ *o_handle = NULL;
+ return TRUE;
+
+ case KTRL('i'):
+ /* Get an item */
#ifdef JP
- q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¸¡º÷¤·¤Þ¤¹¤«? ";
- s = "¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£";
+ q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¸¡º÷¤·¤Þ¤¹¤«? ";
+ s = "¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£";
#else
- q = "Entry which item? ";
- s = "You have nothing to entry.";
+ q = "Enter which item? ";
+ s = "You have nothing to enter.";
#endif
- o_ptr = choose_object(q, s);
- if (!o_ptr) return FALSE;
+ o_ptr = choose_object(q, s);
+ if (!o_ptr) return FALSE;
- *o_handle = o_ptr;
+ *o_handle = o_ptr;
- string_free(*search_strp);
- object_desc(buf, *o_handle, FALSE, 3);
- *search_strp = string_make(format("<%s>", buf));
- return TRUE;
+ string_free(*search_strp);
+ object_desc(buf, *o_handle, FALSE, 3);
+ *search_strp = string_make(format("<%s>", buf));
+ return TRUE;
- case KTRL('l'):
- if (!autopick_last_destroyed_object.k_idx) break;
- *o_handle = &autopick_last_destroyed_object;
+ case KTRL('l'):
+ if (!autopick_last_destroyed_object.k_idx) break;
+ *o_handle = &autopick_last_destroyed_object;
- string_free(*search_strp);
- object_desc(buf, *o_handle, FALSE, 3);
- *search_strp = string_make(format("<%s>", buf));
- return TRUE;
+ string_free(*search_strp);
+ object_desc(buf, *o_handle, FALSE, 3);
+ *search_strp = string_make(format("<%s>", buf));
+ return TRUE;
case 0x7F:
case '\010':
#ifdef JP
- if (pos > 0)
- {
- pos--;
- if (k_flag[pos]) pos--;
- }
+ if (pos > 0)
+ {
+ pos--;
+ if (k_flag[pos]) pos--;
+ }
#else
if (pos > 0) pos--;
#endif
default:
#ifdef JP
- if (iskanji(i))
- {
- int next;
-
- inkey_base = TRUE;
- next = inkey ();
- if (pos + 1 < MAX_NLEN)
- {
- buf[pos++] = i;
- buf[pos] = next;
- k_flag[pos++] = 1;
- }
- else bell();
- }
- else if (pos < MAX_NLEN && isprint(i))
- {
- buf[pos] = i;
- k_flag[pos++] = 0;
- }
- else bell();
+ if (iskanji(i))
+ {
+ int next;
+
+ inkey_base = TRUE;
+ next = inkey ();
+ if (pos + 1 < MAX_NLEN)
+ {
+ buf[pos++] = i;
+ buf[pos] = next;
+ k_flag[pos++] = 1;
+ }
+ else bell();
+ }
+ else if (pos < MAX_NLEN && isprint(i))
+ {
+ buf[pos] = i;
+ k_flag[pos++] = 0;
+ }
+ else bell();
#else
if (pos < MAX_NLEN && isprint(i)) buf[pos++] = i;
else bell();
break;
}
- /* Terminate */
- buf[pos] = '\0';
+ /* Terminate */
+ buf[pos] = '\0';
- /* Update the entry */
- Term_erase(col, 0, 255);
- Term_putstr(col, 0, -1, TERM_WHITE, buf);
+ /* Update the entry */
+ Term_erase(col, 0, 255);
+ Term_putstr(col, 0, -1, TERM_WHITE, buf);
}
- /* Never reached */
+ /* Never reached */
}
*/
static bool search_for_object(cptr *lines_list, object_type *o_ptr, int *cxp, int *cyp, bool forward)
{
- int i;
+ int i;
autopick_type an_entry, *entry = &an_entry;
char o_name[MAX_NLEN];
o_name[i] = tolower(o_name[i]);
}
- i = *cyp;
-
- while (1)
- {
- if (forward)
- {
- if (!lines_list[++i]) break;
- }
- else
- {
- if (--i < 0) break;
- }
-
- if (!autopick_new_entry(entry, lines_list[i])) continue;
-
- if (is_autopick_aux(o_ptr, entry, o_name))
- {
- *cxp = 0;
- *cyp = i;
- return TRUE;
- }
- }
-
- return FALSE;
+ i = *cyp;
+
+ while (1)
+ {
+ if (forward)
+ {
+ if (!lines_list[++i]) break;
+ }
+ else
+ {
+ if (--i < 0) break;
+ }
+
+ if (!autopick_new_entry(entry, lines_list[i])) continue;
+
+ if (is_autopick_aux(o_ptr, entry, o_name))
+ {
+ *cxp = 0;
+ *cyp = i;
+ return TRUE;
+ }
+ }
+
+ return FALSE;
}
*/
static bool search_for_string(cptr *lines_list, cptr search_str, int *cxp, int *cyp, bool forward)
{
- int i = *cyp;
-
- while (1)
- {
- cptr pos;
-
- if (forward)
- {
- if (!lines_list[++i]) break;
- }
- else
- {
- if (--i < 0) break;
- }
+ int i = *cyp;
+
+ while (1)
+ {
+ cptr pos;
+
+ if (forward)
+ {
+ if (!lines_list[++i]) break;
+ }
+ else
+ {
+ if (--i < 0) break;
+ }
#ifdef JP
- pos = strstr_j(lines_list[i], search_str);
+ pos = strstr_j(lines_list[i], search_str);
#else
pos = strstr(lines_list[i], search_str);
#endif
- if (pos)
- {
- *cxp = (int)(pos - lines_list[i]);
- *cyp = i;
- return TRUE;
- }
- }
-
- return FALSE;
+ if (pos)
+ {
+ *cxp = (int)(pos - lines_list[i]);
+ *cyp = i;
+ return TRUE;
+ }
+ }
+
+ return FALSE;
}
}
+
+/*
+ * Process line for auto picker/destroyer.
+ */
+errr process_pickpref_file_line(char *buf)
+{
+ autopick_type entry;
+ int i;
+
+ if (max_autopick == MAX_AUTOPICK)
+ return 1;
+
+ /* Nuke illegal char */
+ for(i = 0; buf[i]; i++)
+ {
+#ifdef JP
+ if (iskanji(buf[i]))
+ {
+ i++;
+ continue;
+ }
+#endif
+ if (isspace(buf[i]) && buf[i] != ' ')
+ break;
+ }
+ buf[i] = 0;
+
+ if (!autopick_new_entry(&entry, buf)) return 0;
+
+ /* Already has the same entry? */
+ for(i = 0; i < max_autopick; i++)
+ if(!strcmp(entry.name, autopick_list[i].name)
+ && 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;
+
+ autopick_list[max_autopick++] = entry;
+ return 0;
+}
+
+
/*
* Get a trigger key and insert ASCII string for the trigger
*/
"^A ^E ¹Ô¤ÎÀèƬ¡¢½ªÃ¼",
"^Q ÆþÎÏ/¥³¥Þ¥ó¥É¥â¡¼¥ÉÀÚ¤êÂؤ¨",
"^R Êѹ¹¤òÁ´¤Æ¼è¤ê¾Ã¤·¤Æ¸µ¤ËÌ᤹",
- "------------------------------------",
- "^I »ý¤Áʪ/ÁõÈ÷¤«¤éÁªÂò",
+ "------------------------------------",
+ "^I »ý¤Áʪ/ÁõÈ÷¤«¤éÁªÂò",
"^L",
"^K ¥«¡¼¥½¥ë¤«¤é½ªÃ¼¤Þ¤Çºï½ü",
"^Y ºï½ü(^K)¤·¤¿¹Ô¤òÁÞÆþ",
"^C ¼ï²¡¢¿¦¶È¤Î¾ò·ï¼°¤òÁÞÆþ",
- "------------------------------------",
+ "------------------------------------",
"^S Êѹ¹ (!Ç˲õ/~ÊüÃÖ/½¦¤¦)",
"^G \"(\" Á´ÂΥޥåפÇɽ¼¨¤·¤Ê¤¤",
"^O \"#\" ¼«Æ°¹ï¤ß",
- "------------------------------------",
+ "------------------------------------",
"^U ̤´ÕÄê/̤ȽÌÀ/´ÕÄê/*´ÕÄê*",
"^W \"̵²ÁÃͤÎ\"",
"^X ̵ÌÃ/¥¨¥´/¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È",
"^A ^E Beginning and End of Line",
"^Q Toggle Insert/Command mode",
"^R Revert to Original File",
- "------------------------------------",
- "^I Object in Inventry/Equipment",
+ "------------------------------------",
+ "^I Object in Inventry/Equipment",
"^L",
"^K Kill Rest of Line",
"^Y Insert killed(^K) text",
"^C Insert conditional expression",
- "------------------------------------",
+ "------------------------------------",
"^S Toggle(!Destroy/~Leave/Pick)",
"^G \"(\" No display in the 'M'ap",
"^O \"#\" Auto-Inscribe",
- "------------------------------------",
+ "------------------------------------",
"^U Toggle 'identified' state",
"^W \"worthless\"",
"^X Toggle nameless/ego/artifact",
#define DIRTY_MODE 0x04
#define DIRTY_SCREEN 0x08
#define DIRTY_NOT_FOUND 0x10
+#define DIRTY_NO_SEARCH 0x20
/*
* In-game editor of Object Auto-picker/Destoryer
static int cx = 0, cy = 0;
static int upper = 0, left = 0;
- object_type *search_o_ptr = NULL;
- cptr search_str = NULL;
- cptr last_destroyed;
+ object_type *search_o_ptr = NULL;
+ cptr search_str = NULL;
+ cptr last_destroyed = NULL;
char last_destroyed_command[WID_DESC+3];
char yank_buf[MAX_YANK];
char classrace[80];
autopick_type an_entry, *entry = &an_entry;
char buf[MAX_LINELEN];
cptr *lines_list;
+ int filename_mode = PT_WITH_PNAME;
int i, j, k, len;
- cptr tmp;
int old_upper = -1, old_left = -1;
int old_cy = -1;
int key = -1, old_key;
- bool repeated_clearing = FALSE;
+ bool repeated_clearing = FALSE;
bool edit_mode = FALSE;
byte dirty_flags = DIRTY_ALL | DIRTY_COMMAND | DIRTY_MODE;
int wid, hgt, old_wid = -1, old_hgt = -1;
+ static s32b old_autosave_turn = 0L;
+
+ 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)
+ {
+ do_cmd_save_game(TRUE);
+ old_autosave_turn = turn;
+ }
+
+ /* HACK -- Reset start_time to stop counting playtime while edit */
+ update_playtime();
+
/* Free old entries */
init_autopicker();
- /* Name of the Last Destroyed Item */
- autopick_entry_from_object(entry, &autopick_last_destroyed_object);
- last_destroyed = autopick_line_from_entry(entry);
-
- /* Command Description of the Last Destroyed Item */
- if (last_destroyed)
+ /* Command Description of the 'Last Destroyed Item' */
+ if (autopick_last_destroyed_object.k_idx)
{
- strcpy(last_destroyed_command, "^L \"");
- strncpy(last_destroyed_command + 4, last_destroyed, WID_DESC-4);
- last_destroyed_command[WID_DESC+2] = '\0';
+ autopick_entry_from_object(entry, &autopick_last_destroyed_object);
+ last_destroyed = autopick_line_from_entry_kill(entry);
+
+ my_strcpy(last_destroyed_command, format("^L \"%s\"", last_destroyed), sizeof(last_destroyed_command));
}
else
{
yank_buf[0] = '\0';
/* Read or initialize whole text */
- lines_list = read_pickpref_text_lines();
+ lines_list = read_pickpref_text_lines(&filename_mode);
/* Reset cursor position if needed */
for (i = 0; i < cy; i++)
if (edit_mode)
prt("^Q ESC ¤Ç¥³¥Þ¥ó¥É¥â¡¼¥É¤Ø°Ü¹Ô¡¢Ä̾ï¤Îʸ»ú¤Ï¤½¤Î¤Þ¤ÞÆþÎÏ", 0, 0);
else
- prt("q _ ¤Ç½ªÎ»¡¢hjkl2468 ¤Ç°ÜÆ°¡¢^Q a i ¤ÇÆþÎϥ⡼¥É", 0, 0);
+ prt("q _ ¤Ç½ªÎ»¡¢hjkl2468 ¤Ç°ÜÆ°¡¢^Q a i ¤ÇÆþÎϥ⡼¥É¡¢/ n N ¤Ç¸¡º÷", 0, 0);
#else
if (edit_mode)
prt("Press ^Q ESC to command mode, any letters to insert", 0, 0);
else
- prt("Press q _ to quit, hjkl2468 to move, ^Q a i to insert mode", 0, 0);
+ prt(format("Press q _ to quit, %s to move, ^Q a i to insert mode, /nN to find", rogue_like_commands ? "hjkl" : "2468"), 0, 0);
#endif
/* Display current position */
prt (format("(%d,%d)", cx, cy), 0, 70);
/* Display information when updated */
- if (old_cy != cy || (dirty_flags & (DIRTY_ALL | DIRTY_NOT_FOUND)) || dirty_line == cy)
+ if (old_cy != cy || (dirty_flags & (DIRTY_ALL | DIRTY_NOT_FOUND | DIRTY_NO_SEARCH)) || dirty_line == cy)
{
/* Clear information line */
Term_erase(0, hgt - 3 + 1, wid);
Term_erase(0, hgt - 3 + 2, wid);
/* Display information */
- if (dirty_flags & DIRTY_NOT_FOUND)
- {
+ if (dirty_flags & DIRTY_NOT_FOUND)
+ {
#ifdef JP
prt(format("¥Ñ¥¿¡¼¥ó¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó: %s", search_str), hgt - 3 + 1, 0);
#else
prt(format("Pattern not found: %s", search_str), hgt - 3 + 1, 0);
#endif
- }
+ }
+ else if (dirty_flags & DIRTY_NO_SEARCH)
+ {
+#ifdef JP
+ prt("¸¡º÷Ãæ¤Î¥Ñ¥¿¡¼¥ó¤¬¤¢¤ê¤Þ¤»¤ó('/'¤Ç¸¡º÷)¡£", hgt - 3 + 1, 0);
+#else
+ prt("No pattern to search. (Press '/' to search.)", hgt - 3 + 1, 0);
+#endif
+ }
else if (lines_list[cy][0] == '#')
{
#ifdef JP
prt("¤³¤Î¹Ô¤Ï¥³¥á¥ó¥È¤Ç¤¹¡£", hgt - 3 + 1, 0);
#else
- prt("This line is comment.", hgt - 3 + 1, 0);
+ prt("This line is a comment.", hgt - 3 + 1, 0);
#endif
}
else if (lines_list[cy][1] == ':')
#ifdef JP
prt("¤³¤Î¹Ô¤Ï¾ò·ïʬ´ô¼°¤Ç¤¹¡£", hgt - 3 + 1, 0);
#else
- prt("This line is Conditional Expression.", hgt - 3 + 1, 0);
+ prt("This line is a Conditional Expression.", hgt - 3 + 1, 0);
#endif
break;
case 'A':
#ifdef JP
prt("¤³¤Î¹Ô¤Ï¥Þ¥¯¥í¤Î¼Â¹ÔÆâÍƤòÄêµÁ¤·¤Þ¤¹¡£", hgt - 3 + 1, 0);
#else
- prt("This line defines Macro action.", hgt - 3 + 1, 0);
+ prt("This line defines a Macro action.", hgt - 3 + 1, 0);
#endif
break;
case 'P':
#ifdef JP
prt("¤³¤Î¹Ô¤Ï¥Þ¥¯¥í¤Î¥È¥ê¥¬¡¼¡¦¥¡¼¤òÄêµÁ¤·¤Þ¤¹¡£", hgt - 3 + 1, 0);
#else
- prt("This line defines Macro trigger key.", hgt - 3 + 1, 0);
+ prt("This line defines a Macro trigger key.", hgt - 3 + 1, 0);
#endif
break;
case 'C':
#ifdef JP
prt("¤³¤Î¹Ô¤Ï¥¡¼ÇÛÃÖ¤òÄêµÁ¤·¤Þ¤¹¡£", hgt - 3 + 1, 0);
#else
- prt("This line defines Keymap.", hgt - 3 + 1, 0);
+ prt("This line defines a Keymap.", hgt - 3 + 1, 0);
#endif
break;
}
describe_autopick(buf, entry);
- roff_to_buf(buf, 81, temp);
+ roff_to_buf(buf, 81, temp, sizeof(temp));
t = temp;
for (i = 0; i< 2; i++)
{
/* Insert a character */
else if (!iscntrl(key&0xff))
{
- int next;
-
/* Save preceding string */
for (i = j = 0; lines_list[cy][i] && i < cx; i++)
buf[j++] = lines_list[cy][i];
/* Add a character */
#ifdef JP
- if (iskanji(key))
+ if (iskanji(key))
{
- inkey_base = TRUE;
- next = inkey();
- if (j+2 < MAX_LINELEN)
+ int next;
+
+ inkey_base = TRUE;
+ next = inkey();
+ if (j+2 < MAX_LINELEN)
{
- buf[j++] = key;
- buf[j++] = next;
+ buf[j++] = key;
+ buf[j++] = next;
cx += 2;
- }
+ }
else
- bell();
- }
+ bell();
+ }
else
#endif
{
- if (j+1 < MAX_LINELEN)
+ if (j+1 < MAX_LINELEN)
buf[j++] = key;
cx++;
}
break;
case '~':
if (!autopick_new_entry(entry, lines_list[cy]))
- {
- if (old_key != key) repeated_clearing = FALSE;
+ {
+ if (old_key != key) repeated_clearing = FALSE;
- /* Next line */
- if (lines_list[cy + 1]) cy++;
- cx = 0;
+ /* Next line */
+ if (lines_list[cy + 1]) cy++;
+ cx = 0;
break;
- }
+ }
string_free(lines_list[cy]);
- if (old_key != key)
- {
- if (entry->action & DONT_AUTOPICK)
- repeated_clearing = TRUE;
- else
- repeated_clearing = FALSE;
- }
+ if (old_key != key)
+ {
+ if (entry->action & DONT_AUTOPICK)
+ repeated_clearing = TRUE;
+ else
+ repeated_clearing = FALSE;
+ }
entry->action &= ~DO_AUTODESTROY;
+ entry->action &= ~DO_QUERY_AUTOPICK;
if (!repeated_clearing)
{
entry->action &= ~DO_AUTOPICK;
entry->action |= DO_AUTOPICK;
}
- lines_list[cy] = autopick_line_from_entry(entry);
+ lines_list[cy] = autopick_line_from_entry_kill(entry);
/* Now dirty */
dirty_line = cy;
- /* Next line */
- if (lines_list[cy + 1]) cy++;
- cx = 0;
+ /* Next line */
+ if (lines_list[cy + 1]) cy++;
+ cx = 0;
break;
case '!':
if (!autopick_new_entry(entry, lines_list[cy]))
- {
- if (old_key != key) repeated_clearing = FALSE;
+ {
+ if (old_key != key) repeated_clearing = FALSE;
- /* Next line */
- if (lines_list[cy + 1]) cy++;
- cx = 0;
+ /* Next line */
+ if (lines_list[cy + 1]) cy++;
+ cx = 0;
break;
- }
+ }
string_free(lines_list[cy]);
- if (old_key != key)
- {
- if (entry->action & DO_AUTODESTROY)
- repeated_clearing = TRUE;
- else
- repeated_clearing = FALSE;
- }
+ if (old_key != key)
+ {
+ if (entry->action & DO_AUTODESTROY)
+ repeated_clearing = TRUE;
+ else
+ repeated_clearing = FALSE;
+ }
entry->action &= ~DONT_AUTOPICK;
+ entry->action &= ~DO_QUERY_AUTOPICK;
if (!repeated_clearing)
{
entry->action &= ~DO_AUTOPICK;
entry->action |= DO_AUTOPICK;
}
- lines_list[cy] = autopick_line_from_entry(entry);
+ lines_list[cy] = autopick_line_from_entry_kill(entry);
+
+ /* Now dirty */
+ dirty_line = cy;
+
+ /* Next line */
+ if (lines_list[cy + 1]) cy++;
+ cx = 0;
+ break;
+ case ';':
+ if (!autopick_new_entry(entry, lines_list[cy]))
+ {
+ if (old_key != key) repeated_clearing = FALSE;
+
+ /* Next line */
+ if (lines_list[cy + 1]) cy++;
+ cx = 0;
+ break;
+ }
+ string_free(lines_list[cy]);
+
+ if (old_key != key)
+ {
+ if (entry->action & DO_QUERY_AUTOPICK)
+ repeated_clearing = TRUE;
+ else
+ repeated_clearing = FALSE;
+ }
+
+ entry->action &= ~DO_AUTODESTROY;
+ entry->action &= ~DONT_AUTOPICK;
+ if (!repeated_clearing)
+ {
+ entry->action &= ~DO_AUTOPICK;
+ entry->action |= DO_QUERY_AUTOPICK;
+ }
+ else
+ {
+ entry->action &= ~DO_QUERY_AUTOPICK;
+ entry->action |= DO_AUTOPICK;
+ }
+
+ lines_list[cy] = autopick_line_from_entry_kill(entry);
/* Now dirty */
dirty_line = cy;
- /* Next line */
- if (lines_list[cy + 1]) cy++;
- cx = 0;
+ /* Next line */
+ if (lines_list[cy + 1]) cy++;
+ cx = 0;
break;
case '(':
- /* Toggle display on the 'M'ap */
- if (!autopick_new_entry(entry, lines_list[cy]))
- {
- if (old_key != key) repeated_clearing = FALSE;
-
- /* Next line */
- if (lines_list[cy + 1]) cy++;
- cx = 0;
- break;
- }
- string_free(lines_list[cy]);
-
- if (old_key != key)
- {
- if (entry->action & DO_DISPLAY)
- repeated_clearing = TRUE;
- else
- repeated_clearing = FALSE;
- }
+ /* Toggle display on the 'M'ap */
+ if (!autopick_new_entry(entry, lines_list[cy]))
+ {
+ if (old_key != key) repeated_clearing = FALSE;
+
+ /* Next line */
+ if (lines_list[cy + 1]) cy++;
+ cx = 0;
+ break;
+ }
+ string_free(lines_list[cy]);
+
+ if (old_key != key)
+ {
+ if (entry->action & DO_DISPLAY)
+ repeated_clearing = TRUE;
+ else
+ repeated_clearing = FALSE;
+ }
if (!repeated_clearing)
- entry->action |= DO_DISPLAY;
- else
- entry->action &= ~DO_DISPLAY;
+ entry->action |= DO_DISPLAY;
+ else
+ entry->action &= ~DO_DISPLAY;
- lines_list[cy] = autopick_line_from_entry(entry);
+ lines_list[cy] = autopick_line_from_entry_kill(entry);
- /* Now dirty */
- dirty_line = cy;
+ /* Now dirty */
+ dirty_line = cy;
- /* Next line */
- if (lines_list[cy + 1]) cy++;
- cx = 0;
+ /* Next line */
+ if (lines_list[cy + 1]) cy++;
+ cx = 0;
break;
case '#':
case '{':
dirty_flags |= DIRTY_MODE;
}
break;
- case '/':
+ case '/':
/* Become dirty because of item/equip menu */
dirty_flags |= DIRTY_SCREEN;
- if (!get_string_for_search(&search_o_ptr, &search_str))
- break;
-
- /* fall through */
- case 'n':
- if (search_o_ptr)
- {
- if (!search_for_object(lines_list, search_o_ptr, &cx, &cy, TRUE)) dirty_flags |= DIRTY_NOT_FOUND;
- }
- else if (search_str)
- {
- if (!search_for_string(lines_list, search_str, &cx, &cy, TRUE)) dirty_flags |= DIRTY_NOT_FOUND;
- }
- break;
- case 'N':
- if (search_o_ptr)
- {
- if (!search_for_object(lines_list, search_o_ptr, &cx, &cy, FALSE)) dirty_flags |= DIRTY_NOT_FOUND;
- }
- else if (search_str)
- {
- if (!search_for_string(lines_list, search_str, &cx, &cy, FALSE)) dirty_flags |= DIRTY_NOT_FOUND;
- }
- break;
+ if (!get_string_for_search(&search_o_ptr, &search_str))
+ break;
+
+ /* fall through */
+ case 'n':
+ if (search_o_ptr)
+ {
+ if (!search_for_object(lines_list, search_o_ptr, &cx, &cy, TRUE)) dirty_flags |= DIRTY_NOT_FOUND;
+ }
+ else if (search_str)
+ {
+ if (!search_for_string(lines_list, search_str, &cx, &cy, TRUE)) dirty_flags |= DIRTY_NOT_FOUND;
+ }
+ else
+ {
+ dirty_flags |= DIRTY_NO_SEARCH;
+ }
+ break;
+ case 'N':
+ if (search_o_ptr)
+ {
+ if (!search_for_object(lines_list, search_o_ptr, &cx, &cy, FALSE)) dirty_flags |= DIRTY_NOT_FOUND;
+ }
+ else if (search_str)
+ {
+ if (!search_for_string(lines_list, search_str, &cx, &cy, FALSE)) dirty_flags |= DIRTY_NOT_FOUND;
+ }
+ else
+ {
+ dirty_flags |= DIRTY_NO_SEARCH;
+ }
+ break;
}
}
case KTRL('c'):
/* Insert a conditinal expression line */
insert_return_code(lines_list, 0, cy);
+ string_free(lines_list[cy]);
lines_list[cy] = string_make(classrace);
cy++;
insert_return_code(lines_list, 0, cy);
+ string_free(lines_list[cy]);
lines_list[cy] = string_make("?:1");
cx = 0;
if (cx > 0) cx--;
}
- lines_list[cy] = autopick_line_from_entry(entry);
+ lines_list[cy] = autopick_line_from_entry_kill(entry);
/* Now dirty */
dirty_line = cy;
dirty_flags |= DIRTY_SCREEN;
break;
}
- tmp = autopick_line_from_entry(entry);
- if (tmp)
- {
- insert_return_code(lines_list, 0, cy);
- lines_list[cy] = tmp;
- cx = 0;
+ insert_return_code(lines_list, 0, cy);
+ string_free(lines_list[cy]);
+ lines_list[cy] = autopick_line_from_entry_kill(entry);
+ cx = 0;
+
+ /* Now dirty because of item/equip menu */
+ dirty_flags |= DIRTY_SCREEN;
- /* Now dirty because of item/equip menu */
- dirty_flags |= DIRTY_SCREEN;
- }
break;
case KTRL('l'):
/* Insert a name of last destroyed item */
if (last_destroyed)
{
insert_return_code(lines_list, 0, cy);
+ string_free(lines_list[cy]);
lines_list[cy] = string_make(last_destroyed);
cx = 0;
if (!entry->insc) entry->insc = string_make("");
- lines_list[cy] = autopick_line_from_entry(entry);
+ lines_list[cy] = autopick_line_from_entry_kill(entry);
/* Move to collumn for auto inscription */
for (cx = 0; lines_list[cy][cx]; cx++)
#ifdef JP
if (!get_check("Á´¤Æ¤ÎÊѹ¹¤òÇË´þ¤·¤Æ¸µ¤Î¾õÂÖ¤ËÌᤷ¤Þ¤¹¡£¤è¤í¤·¤¤¤Ç¤¹¤«¡© "))
#else
- if (!get_check("Discard all change and revert to original file. Are you sure? "))
+ if (!get_check("Discard all changes and revert to original file. Are you sure? "))
#endif
break;
free_text_lines(lines_list);
- lines_list = read_pickpref_text_lines();
+ lines_list = read_pickpref_text_lines(&filename_mode);
dirty_flags |= DIRTY_ALL | DIRTY_MODE;
cx = cy = 0;
edit_mode = FALSE;
entry->action |= DO_AUTOPICK;
}
- lines_list[cy] = autopick_line_from_entry(entry);
+ lines_list[cy] = autopick_line_from_entry_kill(entry);
/* Now dirty */
dirty_line = cy;
REM_FLG(FLG_STAR_IDENTIFIED);
}
- lines_list[cy] = autopick_line_from_entry(entry);
+ lines_list[cy] = autopick_line_from_entry_kill(entry);
/* Now dirty */
dirty_line = cy;
REM_FLG(FLG_ARTIFACT);
}
- lines_list[cy] = autopick_line_from_entry(entry);
+ lines_list[cy] = autopick_line_from_entry_kill(entry);
/* Now dirty */
dirty_line = cy;
/* Paste killed text */
if (strlen(yank_buf))
{
- bool ret = FALSE;
+ bool ret = FALSE;
for (j = 0; yank_buf[j]; j += strlen(yank_buf + j) + 1)
{
- if (ret && '\n' == yank_buf[j])
- {
- ret = FALSE;
- continue;
- }
+ if (ret && '\n' == yank_buf[j])
+ {
+ ret = FALSE;
+ continue;
+ }
/* Split current line */
insert_return_code(lines_list, cx, cy);
buf[i] = lines_list[cy][i];
/* Paste yank buffer */
- if ('\n' != yank_buf[j])
- {
- int k = j;
- while (yank_buf[k] && i < MAX_LINELEN-1)
- buf[i++] = yank_buf[k++];
- ret = TRUE;
- }
+ if ('\n' != yank_buf[j])
+ {
+ int k = j;
+ while (yank_buf[k] && i < MAX_LINELEN-1)
+ buf[i++] = yank_buf[k++];
+ ret = TRUE;
+ }
buf[i] = '\0';
case KTRL('k'):
/* Kill rest of line */
if ((uint)cx > strlen(lines_list[cy]))
- cx = (int)strlen(lines_list[cy]);
+ cx = (int)strlen(lines_list[cy]);
- /* Save preceding string */
- for (i = 0; lines_list[cy][i] && i < cx; i++)
- {
+ /* Save preceding string */
+ for (i = 0; lines_list[cy][i] && i < cx; i++)
+ {
#ifdef JP
- if (iskanji(lines_list[cy][i]))
- {
- buf[i] = lines_list[cy][i];
- i++;
- }
+ if (iskanji(lines_list[cy][i]))
+ {
+ buf[i] = lines_list[cy][i];
+ i++;
+ }
#endif
- buf[i] = lines_list[cy][i];
- }
- buf[i] = '\0';
-
- j = 0;
- if (old_key == key)
- while (yank_buf[j])
- j += strlen(yank_buf + j) + 1;
-
- /* Copy following to yank buffer */
- if (lines_list[cy][i])
- {
- while (lines_list[cy][i] && j < MAX_YANK - 2)
- yank_buf[j++] = lines_list[cy][i++];
- i = TRUE;
- }
- else
- {
- if (j < MAX_YANK - 2)
- yank_buf[j++] = '\n';
- i = FALSE;
- }
- yank_buf[j++] = '\0';
- yank_buf[j] = '\0';
-
- /* Replace current line with 'preceding string' */
- string_free(lines_list[cy]);
- lines_list[cy] = string_make(buf);
-
- if (i)
- {
- /* Now dirty */
- dirty_line = cy;
- break;
- }
+ buf[i] = lines_list[cy][i];
+ }
+ buf[i] = '\0';
+
+ j = 0;
+ if (old_key == key)
+ while (yank_buf[j])
+ j += strlen(yank_buf + j) + 1;
+
+ /* Copy following to yank buffer */
+ if (lines_list[cy][i])
+ {
+ while (lines_list[cy][i] && j < MAX_YANK - 2)
+ yank_buf[j++] = lines_list[cy][i++];
+ i = TRUE;
+ }
+ else
+ {
+ if (j < MAX_YANK - 2)
+ yank_buf[j++] = '\n';
+ i = FALSE;
+ }
+ yank_buf[j++] = '\0';
+ yank_buf[j] = '\0';
+
+ /* Replace current line with 'preceding string' */
+ string_free(lines_list[cy]);
+ lines_list[cy] = string_make(buf);
+
+ if (i)
+ {
+ /* Now dirty */
+ dirty_line = cy;
+ break;
+ }
/* fall through */
case KTRL('d'):
break;
}
- for (i = j = 0; lines_list[cy][i] && i < cx; i++)
+ for (i = j = k = 0; lines_list[cy][i] && i < cx; i++)
{
k = j;
#ifdef JP
/* Restore the screen */
screen_load();
+ switch (filename_mode)
+ {
+ case PT_DEFAULT:
#ifdef JP
- sprintf(buf, "picktype-%s.prf", player_name);
+ strcpy(buf, "picktype.prf");
#else
- sprintf(buf, "pickpref-%s.prf", player_name);
+ strcpy(buf, "pickpref.prf");
+#endif
+ break;
+
+ case PT_WITH_PNAME:
+#ifdef JP
+ sprintf(buf, "picktype-%s.prf", player_name);
+#else
+ sprintf(buf, "pickpref-%s.prf", player_name);
#endif
+ break;
+ }
+
write_text_lines(buf, lines_list);
free_text_lines(lines_list);
/* Reload autopick pref */
process_pickpref_file(buf);
+
+ /* HACK -- reset start_time so that playtime is not increase while edit */
+ start_time = time(NULL);
}