3 /* Purpose: Object Auto-picker/Destroyer */
6 * Copyright (c) 2002 Mogami
8 * This software may be copied and distributed for educational, research, and
9 * not for profit purposes provided that this copyright and statement are
10 * included in all such copies.
19 #define FLG_COLLECTING 1
20 #define FLG_UNIDENTIFIED 2
21 #define FLG_IDENTIFIED 3
22 #define FLG_STAR_IDENTIFIED 4
24 #define FLG_MORE_THAN 6
26 #define FLG_MORE_BONUS 8
27 #define FLG_MORE_BONUS2 9
28 #define FLG_WORTHLESS 10
29 #define FLG_ARTIFACT 11
31 #define FLG_NAMELESS 13
32 #define FLG_UNAWARE 14
36 #define FLG_UNREADABLE 18
45 #define FLG_WEAPONS 31
47 #define FLG_MISSILES 33
48 #define FLG_DEVICES 34
51 #define FLG_SPELLBOOKS 37
53 #define FLG_SHIELDS 39
56 #define FLG_AMULETS 42
65 #define KEY_ALL "¤¹¤Ù¤Æ¤Î"
66 #define KEY_COLLECTING "¼ý½¸Ãæ¤Î"
67 #define KEY_UNIDENTIFIED "̤´ÕÄê¤Î"
68 #define KEY_IDENTIFIED "´ÕÄêºÑ¤ß¤Î"
69 #define KEY_STAR_IDENTIFIED "*´ÕÄê*ºÑ¤ß¤Î"
70 #define KEY_BOOSTED "¥À¥¤¥¹Ìܤΰ㤦"
71 #define KEY_MORE_THAN "¥À¥¤¥¹ÌÜ"
72 #define KEY_DICE "°Ê¾å¤Î"
73 #define KEY_MORE_BONUS "½¤ÀµÃͤ¬"
74 #define KEY_MORE_BONUS2 "°Ê¾å¤Î"
75 #define KEY_WORTHLESS "̵²ÁÃͤÎ"
76 #define KEY_ARTIFACT "¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È"
77 #define KEY_EGO "¥¨¥´"
78 #define KEY_NAMELESS "̵ÌäÎ"
79 #define KEY_UNAWARE "̤ȽÌÀ¤Î"
80 #define KEY_WANTED "¾Þ¶â¼ó¤Î"
81 #define KEY_UNIQUE "¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¤Î"
82 #define KEY_HUMAN "¿Í´Ö¤Î"
83 #define KEY_UNREADABLE "Æɤá¤Ê¤¤"
84 #define KEY_REALM1 "Âè°ìÎΰè¤Î"
85 #define KEY_REALM2 "ÂèÆóÎΰè¤Î"
86 #define KEY_FIRST "1ºýÌܤÎ"
87 #define KEY_SECOND "2ºýÌܤÎ"
88 #define KEY_THIRD "3ºýÌܤÎ"
89 #define KEY_FOURTH "4ºýÌܤÎ"
90 #define KEY_ITEMS "¥¢¥¤¥Æ¥à"
91 #define KEY_WEAPONS "Éð´ï"
92 #define KEY_ARMORS "Ëɶñ"
93 #define KEY_MISSILES "Ìð"
94 #define KEY_DEVICES "ËâË¡¥¢¥¤¥Æ¥à"
95 #define KEY_LIGHTS "¸÷¸»"
96 #define KEY_JUNKS "¤¬¤é¤¯¤¿"
97 #define KEY_SPELLBOOKS "ËâË¡½ñ"
98 #define KEY_HAFTED "Æß´ï"
99 #define KEY_SHIELDS "½â"
100 #define KEY_BOWS "µÝ"
101 #define KEY_RINGS "»ØÎØ"
102 #define KEY_AMULETS "¥¢¥ß¥å¥ì¥Ã¥È"
103 #define KEY_SUITS "³»"
104 #define KEY_CLOAKS "¥¯¥í¡¼¥¯"
105 #define KEY_HELMS "³õ"
106 #define KEY_GLOVES "äƼê"
107 #define KEY_BOOTS "·¤"
111 #define KEY_ALL "all"
112 #define KEY_COLLECTING "collecting"
113 #define KEY_UNIDENTIFIED "unidentified"
114 #define KEY_IDENTIFIED "identified"
115 #define KEY_STAR_IDENTIFIED "*identified*"
116 #define KEY_BOOSTED "dice boosted"
117 #define KEY_MORE_THAN "more than"
118 #define KEY_DICE " dice"
119 #define KEY_MORE_BONUS "more bonus than"
120 #define KEY_MORE_BONUS2 ""
121 #define KEY_WORTHLESS "worthless"
122 #define KEY_ARTIFACT "artifact"
123 #define KEY_EGO "ego"
124 #define KEY_NAMELESS "nameless"
125 #define KEY_UNAWARE "unaware"
126 #define KEY_WANTED "wanted"
127 #define KEY_UNIQUE "unique monster's"
128 #define KEY_HUMAN "human"
129 #define KEY_UNREADABLE "unreadable"
130 #define KEY_REALM1 "first realm's"
131 #define KEY_REALM2 "second realm's"
132 #define KEY_FIRST "first"
133 #define KEY_SECOND "second"
134 #define KEY_THIRD "third"
135 #define KEY_FOURTH "fourth"
136 #define KEY_ITEMS "items"
137 #define KEY_WEAPONS "weapons"
138 #define KEY_ARMORS "armors"
139 #define KEY_MISSILES "missiles"
140 #define KEY_DEVICES "magical devices"
141 #define KEY_LIGHTS "lights"
142 #define KEY_JUNKS "junks"
143 #define KEY_SPELLBOOKS "spellbooks"
144 #define KEY_HAFTED "hafted weapons"
145 #define KEY_SHIELDS "shields"
146 #define KEY_BOWS "bows"
147 #define KEY_RINGS "rings"
148 #define KEY_AMULETS "amulets"
149 #define KEY_SUITS "suits"
150 #define KEY_CLOAKS "cloaks"
151 #define KEY_HELMS "helms"
152 #define KEY_GLOVES "gloves"
153 #define KEY_BOOTS "boots"
157 #define MATCH_KEY(KEY) (!strncmp(ptr, KEY, sizeof(KEY)-1)\
158 ? (prev_ptr = ptr, ptr += sizeof(KEY)-1, (' '==*ptr) ? ptr++ : 0, TRUE) : FALSE)
161 #define ADD_KEY(KEY) strcat(ptr, KEY)
163 #define ADD_KEY(KEY) (strcat(ptr, KEY), strcat(ptr, " "))
165 #define ADD_KEY2(KEY) strcat(ptr, KEY)
167 #define ADD_FLG(FLG) (entry->flag[FLG / 32] |= (1L << (FLG % 32)))
168 #define REM_FLG(FLG) (entry->flag[FLG / 32] &= ~(1L << (FLG % 32)))
169 #define ADD_FLG2(FLG) (entry->flag[FLG / 32] |= (1L << (FLG % 32)), prev_flg = FLG)
170 #define IS_FLG(FLG) (entry->flag[FLG / 32] & (1L << (FLG % 32)))
173 static char kanji_colon[] = "¡§";
178 * Reconstruct preference line from entry
180 cptr autopick_line_from_entry(autopick_type *entry)
184 bool sepa_flag = TRUE;
187 if (!(entry->action & DO_DISPLAY)) strcat(buf, "(");
188 if (entry->action & DO_AUTODESTROY) strcat(buf, "!");
189 if (entry->action & DONT_AUTOPICK) strcat(buf, "~");
193 if (IS_FLG(FLG_ALL)) ADD_KEY(KEY_ALL);
194 if (IS_FLG(FLG_COLLECTING)) ADD_KEY(KEY_COLLECTING);
195 if (IS_FLG(FLG_UNIDENTIFIED)) ADD_KEY(KEY_UNIDENTIFIED);
196 if (IS_FLG(FLG_IDENTIFIED)) ADD_KEY(KEY_IDENTIFIED);
197 if (IS_FLG(FLG_STAR_IDENTIFIED)) ADD_KEY(KEY_STAR_IDENTIFIED);
198 if (IS_FLG(FLG_BOOSTED)) ADD_KEY(KEY_BOOSTED);
200 if (IS_FLG(FLG_MORE_THAN))
202 ADD_KEY(KEY_MORE_THAN);
203 strcat(ptr, format("%d", entry->dice));
207 if (IS_FLG(FLG_MORE_BONUS))
209 ADD_KEY(KEY_MORE_BONUS);
210 strcat(ptr, format("%d", entry->bonus));
211 ADD_KEY(KEY_MORE_BONUS2);
214 if (IS_FLG(FLG_WORTHLESS)) ADD_KEY(KEY_WORTHLESS);
215 if (IS_FLG(FLG_ARTIFACT)) ADD_KEY(KEY_ARTIFACT);
216 if (IS_FLG(FLG_EGO)) ADD_KEY(KEY_EGO);
217 if (IS_FLG(FLG_NAMELESS)) ADD_KEY(KEY_NAMELESS);
218 if (IS_FLG(FLG_UNAWARE)) ADD_KEY(KEY_UNAWARE);
219 if (IS_FLG(FLG_WANTED)) ADD_KEY(KEY_WANTED);
220 if (IS_FLG(FLG_UNIQUE)) ADD_KEY(KEY_UNIQUE);
221 if (IS_FLG(FLG_HUMAN)) ADD_KEY(KEY_HUMAN);
222 if (IS_FLG(FLG_UNREADABLE)) ADD_KEY(KEY_UNREADABLE);
223 if (IS_FLG(FLG_REALM1)) ADD_KEY(KEY_REALM1);
224 if (IS_FLG(FLG_REALM2)) ADD_KEY(KEY_REALM2);
225 if (IS_FLG(FLG_FIRST)) ADD_KEY(KEY_FIRST);
226 if (IS_FLG(FLG_SECOND)) ADD_KEY(KEY_SECOND);
227 if (IS_FLG(FLG_THIRD)) ADD_KEY(KEY_THIRD);
228 if (IS_FLG(FLG_FOURTH)) ADD_KEY(KEY_FOURTH);
230 if (IS_FLG(FLG_ITEMS)) ADD_KEY2(KEY_ITEMS);
231 else if (IS_FLG(FLG_WEAPONS)) ADD_KEY2(KEY_WEAPONS);
232 else if (IS_FLG(FLG_ARMORS)) ADD_KEY2(KEY_ARMORS);
233 else if (IS_FLG(FLG_MISSILES)) ADD_KEY2(KEY_MISSILES);
234 else if (IS_FLG(FLG_DEVICES)) ADD_KEY2(KEY_DEVICES);
235 else if (IS_FLG(FLG_LIGHTS)) ADD_KEY2(KEY_LIGHTS);
236 else if (IS_FLG(FLG_JUNKS)) ADD_KEY2(KEY_JUNKS);
237 else if (IS_FLG(FLG_SPELLBOOKS)) ADD_KEY2(KEY_SPELLBOOKS);
238 else if (IS_FLG(FLG_HAFTED)) ADD_KEY2(KEY_HAFTED);
239 else if (IS_FLG(FLG_SHIELDS)) ADD_KEY2(KEY_SHIELDS);
240 else if (IS_FLG(FLG_BOWS)) ADD_KEY2(KEY_BOWS);
241 else if (IS_FLG(FLG_RINGS)) ADD_KEY2(KEY_RINGS);
242 else if (IS_FLG(FLG_AMULETS)) ADD_KEY2(KEY_AMULETS);
243 else if (IS_FLG(FLG_SUITS)) ADD_KEY2(KEY_SUITS);
244 else if (IS_FLG(FLG_CLOAKS)) ADD_KEY2(KEY_CLOAKS);
245 else if (IS_FLG(FLG_HELMS)) ADD_KEY2(KEY_HELMS);
246 else if (IS_FLG(FLG_GLOVES)) ADD_KEY2(KEY_GLOVES);
247 else if (IS_FLG(FLG_BOOTS)) ADD_KEY2(KEY_BOOTS);
251 if (entry->name && *entry->name)
255 strcat(buf, entry->name);
259 if (entry->flag[0] == 0L && entry->flag[0] == 0L)
266 strcat(buf, entry->insc);
269 return string_make(buf);
273 * A function to create new entry
275 bool autopick_new_entry(autopick_type *entry, cptr str)
284 if (str[1] == ':') switch (str[0])
287 case 'A': case 'P': case 'C':
291 entry->flag[0] = entry->flag[1] = 0L;
294 act = DO_AUTOPICK | DO_DISPLAY;
297 if ((act & DO_AUTOPICK) && *str == '!')
300 act |= DO_AUTODESTROY;
303 else if ((act & DO_AUTOPICK) && *str == '~')
306 act |= DONT_AUTOPICK;
309 else if ((act & DO_DISPLAY) && *str == '(')
318 /* don't mind upper or lower case */
320 for (i = 0; *str; i++)
331 /* Auto-inscription? */
339 if (isupper(c)) c = tolower(c);
345 /* Skip empty line */
346 if (*buf == 0) return FALSE;
349 prev_ptr = ptr = buf;
351 if (MATCH_KEY(KEY_ALL)) ADD_FLG(FLG_ALL);
352 if (MATCH_KEY(KEY_COLLECTING)) ADD_FLG(FLG_COLLECTING);
353 if (MATCH_KEY(KEY_UNIDENTIFIED)) ADD_FLG(FLG_UNIDENTIFIED);
354 if (MATCH_KEY(KEY_IDENTIFIED)) ADD_FLG(FLG_IDENTIFIED);
355 if (MATCH_KEY(KEY_STAR_IDENTIFIED)) ADD_FLG(FLG_STAR_IDENTIFIED);
356 if (MATCH_KEY(KEY_BOOSTED)) ADD_FLG(FLG_BOOSTED);
358 /*** Weapons whose dd*ds is more than nn ***/
359 if (MATCH_KEY(KEY_MORE_THAN))
364 /* Drop leading spaces */
365 while (' ' == *ptr) ptr++;
368 while (isdigit(*ptr))
370 entry->dice = 10 * entry->dice + (*ptr - '0');
377 (void)MATCH_KEY(KEY_DICE);
378 ADD_FLG(FLG_MORE_THAN);
384 /*** Items whose magical bonus is more than n ***/
385 if (MATCH_KEY(KEY_MORE_BONUS))
390 /* Drop leading spaces */
391 while (' ' == *ptr) ptr++;
394 while (isdigit(*ptr))
396 entry->bonus = 10 * entry->bonus + (*ptr - '0');
403 (void)MATCH_KEY(KEY_MORE_BONUS2);
404 ADD_FLG(FLG_MORE_BONUS);
410 if (MATCH_KEY(KEY_WORTHLESS)) ADD_FLG(FLG_WORTHLESS);
411 if (MATCH_KEY(KEY_ARTIFACT)) ADD_FLG(FLG_ARTIFACT);
412 if (MATCH_KEY(KEY_EGO)) ADD_FLG(FLG_EGO);
413 if (MATCH_KEY(KEY_NAMELESS)) ADD_FLG(FLG_NAMELESS);
414 if (MATCH_KEY(KEY_UNAWARE)) ADD_FLG(FLG_UNAWARE);
415 if (MATCH_KEY(KEY_WANTED)) ADD_FLG(FLG_WANTED);
416 if (MATCH_KEY(KEY_UNIQUE)) ADD_FLG(FLG_UNIQUE);
417 if (MATCH_KEY(KEY_HUMAN)) ADD_FLG(FLG_HUMAN);
418 if (MATCH_KEY(KEY_UNREADABLE)) ADD_FLG(FLG_UNREADABLE);
419 if (MATCH_KEY(KEY_REALM1)) ADD_FLG(FLG_REALM1);
420 if (MATCH_KEY(KEY_REALM2)) ADD_FLG(FLG_REALM2);
421 if (MATCH_KEY(KEY_FIRST)) ADD_FLG(FLG_FIRST);
422 if (MATCH_KEY(KEY_SECOND)) ADD_FLG(FLG_SECOND);
423 if (MATCH_KEY(KEY_THIRD)) ADD_FLG(FLG_THIRD);
424 if (MATCH_KEY(KEY_FOURTH)) ADD_FLG(FLG_FOURTH);
426 /* Reset previous word location */
429 if (MATCH_KEY(KEY_ITEMS)) ADD_FLG2(FLG_ITEMS);
430 else if (MATCH_KEY(KEY_WEAPONS)) ADD_FLG2(FLG_WEAPONS);
431 else if (MATCH_KEY(KEY_ARMORS)) ADD_FLG2(FLG_ARMORS);
432 else if (MATCH_KEY(KEY_MISSILES)) ADD_FLG2(FLG_MISSILES);
433 else if (MATCH_KEY(KEY_DEVICES)) ADD_FLG2(FLG_DEVICES);
434 else if (MATCH_KEY(KEY_LIGHTS)) ADD_FLG2(FLG_LIGHTS);
435 else if (MATCH_KEY(KEY_JUNKS)) ADD_FLG2(FLG_JUNKS);
436 else if (MATCH_KEY(KEY_SPELLBOOKS)) ADD_FLG2(FLG_SPELLBOOKS);
437 else if (MATCH_KEY(KEY_HAFTED)) ADD_FLG2(FLG_HAFTED);
438 else if (MATCH_KEY(KEY_SHIELDS)) ADD_FLG2(FLG_SHIELDS);
439 else if (MATCH_KEY(KEY_BOWS)) ADD_FLG2(FLG_BOWS);
440 else if (MATCH_KEY(KEY_RINGS)) ADD_FLG2(FLG_RINGS);
441 else if (MATCH_KEY(KEY_AMULETS)) ADD_FLG2(FLG_AMULETS);
442 else if (MATCH_KEY(KEY_SUITS)) ADD_FLG2(FLG_SUITS);
443 else if (MATCH_KEY(KEY_CLOAKS)) ADD_FLG2(FLG_CLOAKS);
444 else if (MATCH_KEY(KEY_HELMS)) ADD_FLG2(FLG_HELMS);
445 else if (MATCH_KEY(KEY_GLOVES)) ADD_FLG2(FLG_GLOVES);
446 else if (MATCH_KEY(KEY_BOOTS)) ADD_FLG2(FLG_BOOTS);
448 /* Last 'keyword' must be at the correct location */
451 else if (*ptr == '\0')
452 ; /* nothing to do */
454 else if (ptr[0] == kanji_colon[0] && ptr[1] == kanji_colon[1])
460 entry->flag[prev_flg/32] &= ~(1L<< (prev_flg%32));
463 entry->name = string_make(ptr);
465 entry->insc = string_make(insc);
471 * A function to delete entry
473 void autopick_free_entry(autopick_type *entry)
475 string_free(entry->name);
476 string_free(entry->insc);
480 * A function for Auto-picker/destroyer
481 * Examine whether the object matches to the list of keywords or not.
483 int is_autopick(object_type *o_ptr)
486 char o_name[MAX_NLEN];
488 if (o_ptr->tval == TV_GOLD) return -1;
490 object_desc(o_name, o_ptr, FALSE, 3);
492 /* Force to be lower case string */
493 for (i = 0; o_name[i]; i++)
496 if (iskanji(o_name[i]))
500 if (isupper(o_name[i]))
501 o_name[i] = tolower(o_name[i]);
504 for (i=0; i < max_autopick; i++)
506 autopick_type *entry = &autopick_list[i];
508 cptr ptr = autopick_list[i].name;
510 /*** Unidentified ***/
511 if (IS_FLG(FLG_UNIDENTIFIED)
512 && (object_known_p(o_ptr) || (o_ptr->ident & IDENT_SENSE)))
516 if (IS_FLG(FLG_IDENTIFIED) && !object_known_p(o_ptr))
519 /*** *Identified* ***/
520 if (IS_FLG(FLG_STAR_IDENTIFIED) &&
521 (!object_known_p(o_ptr) || !(o_ptr->ident & IDENT_MENTAL)))
524 /*** Dice boosted (weapon of slaying) ***/
525 if (IS_FLG(FLG_BOOSTED))
527 object_kind *k_ptr = &k_info[o_ptr->k_idx];
529 switch( o_ptr->tval )
535 if ((o_ptr->dd != k_ptr->dd) || (o_ptr->ds != k_ptr->ds))
544 /*** Weapons whic dd*ds is more than nn ***/
545 if (IS_FLG(FLG_MORE_THAN))
547 if (o_ptr->dd * o_ptr->ds < entry->dice)
551 /*** Weapons whic dd*ds is more than nn ***/
552 if (IS_FLG(FLG_MORE_BONUS))
554 if (!object_known_p(o_ptr)) continue;
556 if (k_info[o_ptr->k_idx].pval ||
557 (o_ptr->name2 && e_info[o_ptr->name2].max_pval))
559 if (o_ptr->pval < entry->bonus) continue;
563 if (o_ptr->to_h < entry->bonus &&
564 o_ptr->to_d < entry->bonus &&
565 o_ptr->to_a < entry->bonus &&
566 o_ptr->pval < entry->bonus)
571 /*** Worthless items ***/
572 if (IS_FLG(FLG_WORTHLESS) && object_value(o_ptr) > 0)
575 /*** Artifact object ***/
576 if (IS_FLG(FLG_ARTIFACT))
578 if (!object_known_p(o_ptr) || (!o_ptr->name1 && !o_ptr->art_name))
585 if (!object_known_p(o_ptr) || !o_ptr->name2)
590 if (IS_FLG(FLG_NAMELESS))
595 case TV_SHOT: case TV_ARROW: case TV_BOLT: case TV_BOW:
596 case TV_DIGGING: case TV_HAFTED: case TV_POLEARM: case TV_SWORD:
597 case TV_BOOTS: case TV_GLOVES: case TV_HELM: case TV_CROWN:
598 case TV_SHIELD: case TV_CLOAK:
599 case TV_SOFT_ARMOR: case TV_HARD_ARMOR: case TV_DRAG_ARMOR:
600 case TV_LITE: case TV_AMULET: case TV_RING: case TV_CARD:
601 if ((!object_known_p(o_ptr) || o_ptr->inscription
602 || o_ptr->name1 || o_ptr->name2 || o_ptr->art_name))
611 /*** Unaware items ***/
612 if (IS_FLG(FLG_UNAWARE) && object_aware_p(o_ptr))
615 /*** Wanted monster's corpse/skeletons ***/
616 if (IS_FLG(FLG_WANTED) &&
617 (o_ptr->tval != TV_CORPSE || !object_is_shoukinkubi(o_ptr)))
620 /*** Unique monster's corpse/skeletons/statues ***/
621 if (IS_FLG(FLG_UNIQUE) &&
622 ((o_ptr->tval != TV_CORPSE && o_ptr->tval != TV_STATUE) ||
623 !(r_info[o_ptr->pval].flags1 & RF1_UNIQUE)))
626 /*** Human corpse/skeletons (for Daemon magic) ***/
627 if (IS_FLG(FLG_HUMAN) &&
628 (o_ptr->tval != TV_CORPSE ||
629 !strchr("pht", r_info[o_ptr->pval].d_char)))
632 /*** Unreadable spellbooks ***/
633 if (IS_FLG(FLG_UNREADABLE) &&
634 (o_ptr->tval < TV_LIFE_BOOK ||
635 check_book_realm(o_ptr->tval, o_ptr->sval)))
638 /*** First realm spellbooks ***/
639 if (IS_FLG(FLG_REALM1) &&
640 (REALM1_BOOK != o_ptr->tval ||
641 p_ptr->pclass == CLASS_SORCERER ||
642 p_ptr->pclass == CLASS_RED_MAGE))
645 /*** Second realm spellbooks ***/
646 if (IS_FLG(FLG_REALM2) &&
647 (REALM2_BOOK != o_ptr->tval ||
648 p_ptr->pclass == CLASS_SORCERER ||
649 p_ptr->pclass == CLASS_RED_MAGE))
652 /*** First rank spellbooks ***/
653 if (IS_FLG(FLG_FIRST) &&
654 (o_ptr->tval < TV_LIFE_BOOK || 0 != o_ptr->sval))
657 /*** Second rank spellbooks ***/
658 if (IS_FLG(FLG_SECOND) &&
659 (o_ptr->tval < TV_LIFE_BOOK || 1 != o_ptr->sval))
662 /*** Third rank spellbooks ***/
663 if (IS_FLG(FLG_THIRD) &&
664 (o_ptr->tval < TV_LIFE_BOOK || 2 != o_ptr->sval))
667 /*** Fourth rank spellbooks ***/
668 if (IS_FLG(FLG_FOURTH) &&
669 (o_ptr->tval < TV_LIFE_BOOK || 3 != o_ptr->sval))
673 if (IS_FLG(FLG_WEAPONS))
677 case TV_BOW: case TV_HAFTED: case TV_POLEARM:
678 case TV_SWORD: case TV_DIGGING:
683 else if (IS_FLG(FLG_ARMORS))
687 case TV_BOOTS: case TV_GLOVES: case TV_CLOAK: case TV_CROWN:
688 case TV_HELM: case TV_SHIELD: case TV_SOFT_ARMOR:
689 case TV_HARD_ARMOR: case TV_DRAG_ARMOR:
694 else if (IS_FLG(FLG_MISSILES))
698 case TV_SHOT: case TV_BOLT: case TV_ARROW:
703 else if (IS_FLG(FLG_DEVICES))
707 case TV_SCROLL: case TV_STAFF: case TV_WAND: case TV_ROD:
712 else if (IS_FLG(FLG_LIGHTS))
714 if (!(o_ptr->tval == TV_LITE))
717 else if (IS_FLG(FLG_JUNKS))
721 case TV_SKELETON: case TV_BOTTLE:
722 case TV_JUNK: case TV_STATUE:
727 else if (IS_FLG(FLG_SPELLBOOKS))
729 if (!(o_ptr->tval >= TV_LIFE_BOOK))
732 else if (IS_FLG(FLG_HAFTED))
734 if (!(o_ptr->tval == TV_HAFTED))
737 else if (IS_FLG(FLG_SHIELDS))
739 if (!(o_ptr->tval == TV_SHIELD))
742 else if (IS_FLG(FLG_BOWS))
744 if (!(o_ptr->tval == TV_BOW))
747 else if (IS_FLG(FLG_RINGS))
749 if (!(o_ptr->tval == TV_RING))
752 else if (IS_FLG(FLG_AMULETS))
754 if (!(o_ptr->tval == TV_AMULET))
757 else if (IS_FLG(FLG_SUITS))
759 if (!(o_ptr->tval == TV_DRAG_ARMOR ||
760 o_ptr->tval == TV_HARD_ARMOR ||
761 o_ptr->tval == TV_SOFT_ARMOR))
764 else if (IS_FLG(FLG_CLOAKS))
766 if (!(o_ptr->tval == TV_CLOAK))
769 else if (IS_FLG(FLG_HELMS))
771 if (!(o_ptr->tval == TV_CROWN || o_ptr->tval == TV_HELM))
774 else if (IS_FLG(FLG_GLOVES))
776 if (!(o_ptr->tval == TV_GLOVES))
779 else if (IS_FLG(FLG_BOOTS))
781 if (!(o_ptr->tval == TV_BOOTS))
789 if (!strncmp(o_name, ptr, strlen(ptr)))
794 if (strstr_j(o_name, ptr))
796 if (strstr(o_name, ptr))
805 if (!IS_FLG(FLG_COLLECTING))
807 /* Check if there is a same item */
808 for (j = 0; j < INVEN_PACK; j++)
811 * 'Collecting' means the item must be absorbed
812 * into an inventory slot.
813 * But an item can not be absorbed into itself!
815 if ((&inventory[j] != o_ptr) &&
816 object_similar(&inventory[j], o_ptr))
827 * Automatically destroy items in this grid.
829 static bool is_opt_confirm_destroy(object_type *o_ptr)
831 if (!destroy_items) return FALSE;
833 /* Known to be worthless? */
835 if (object_value(o_ptr) > 0) return FALSE;
838 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_DRAG_ARMOR)) return FALSE;
841 if ((o_ptr->tval == TV_CHEST) && o_ptr->pval) return FALSE;
845 if (o_ptr->tval == TV_CORPSE
846 && object_is_shoukinkubi(o_ptr)) return FALSE;
850 if (o_ptr->tval == TV_CORPSE) return FALSE;
853 if ((o_ptr->tval == TV_SKELETON) || (o_ptr->tval == TV_BOTTLE) || (o_ptr->tval == TV_JUNK) || (o_ptr->tval == TV_STATUE)) return FALSE;
855 if (o_ptr->tval == TV_GOLD) return FALSE;
864 void auto_inscribe_item(int item, int idx)
868 /* Get the item (in the pack) */
869 if (item >= 0) o_ptr = &inventory[item];
871 /* Get the item (on the floor) */
872 else o_ptr = &o_list[0 - item];
874 /* Auto-inscription or Re-inscribe for resistances {%} */
875 if ((idx < 0 || !autopick_list[idx].insc) && !o_ptr->inscription)
878 if (o_ptr->inscription)
879 o_ptr->inscription = inscribe_flags(o_ptr, quark_str(o_ptr->inscription));
881 o_ptr->inscription = inscribe_flags(o_ptr, autopick_list[idx].insc);
883 if (item > INVEN_PACK)
885 /* Redraw inscription */
886 p_ptr->window |= (PW_EQUIP);
888 /* {.} and {$} effect p_ptr->warning and TRC_TELEPORT_SELF */
889 p_ptr->update |= (PU_BONUS);
893 /* Redraw inscription */
894 p_ptr->window |= (PW_INVEN);
900 * Automatically destroy an item if it is to be destroyed
903 bool auto_destroy_item(int item, int autopick_idx)
905 bool destroy = FALSE;
906 char o_name[MAX_NLEN];
909 /* Don't destroy equipped items */
910 if (item > INVEN_PACK) return FALSE;
912 /* Get the item (in the pack) */
913 if (item >= 0) o_ptr = &inventory[item];
915 /* Get the item (on the floor) */
916 else o_ptr = &o_list[0 - item];
918 /* Easy-Auto-Destroyer */
919 if (is_opt_confirm_destroy(o_ptr)) destroy = TRUE;
923 /* Protected by auto-picker */
924 if (autopick_idx >= 0 &&
925 !(autopick_list[autopick_idx].action & DO_AUTODESTROY))
930 /* Auto-picker/destroyer */
931 if (autopick_idx >= 0 &&
932 (autopick_list[autopick_idx].action & DO_AUTODESTROY))
936 /* Not to be destroyed */
937 if (!destroy) return FALSE;
939 /* Now decided to destroy */
943 /* Describe the object (with {terrible/special}) */
944 object_desc(o_name, o_ptr, TRUE, 3);
947 if (!can_player_destroy_object(o_ptr))
951 msg_format("%s¤ÏÇ˲õÉÔǽ¤À¡£", o_name);
953 msg_format("You cannot auto-destroy %s.", o_name);
960 /* Record name of destroyed item */
961 autopick_free_entry(&autopick_entry_last_destroyed);
962 autopick_entry_from_object(&autopick_entry_last_destroyed, o_ptr);
964 /* Eliminate the item (from the pack) */
967 inven_item_increase(item, -(o_ptr->number));
968 inven_item_optimize(item);
971 /* Eliminate the item (from the floor) */
974 delete_object_idx(0 - item);
977 /* Print a message */
979 msg_format("%s¤ò¼«Æ°Ç˲õ¤·¤Þ¤¹¡£", o_name);
981 msg_format("Auto-destroying %s.", o_name);
989 * Automatically pickup/destroy items in this grid.
991 void auto_pickup_items(cave_type *c_ptr)
993 s16b this_o_idx, next_o_idx = 0;
995 /* Scan the pile of objects */
996 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
1000 /* Acquire object */
1001 object_type *o_ptr = &o_list[this_o_idx];
1003 /* Acquire next object */
1004 next_o_idx = o_ptr->next_o_idx;
1006 idx = is_autopick(o_ptr);
1008 /* Item index for floor -1,-2,-3,... */
1009 auto_inscribe_item((-this_o_idx), idx);
1011 if (idx >= 0 && (autopick_list[idx].action & DO_AUTOPICK))
1015 if (!inven_carry_okay(o_ptr))
1017 char o_name[MAX_NLEN];
1019 /* Describe the object */
1020 object_desc(o_name, o_ptr, TRUE, 3);
1024 msg_format("¥¶¥Ã¥¯¤Ë¤Ï%s¤òÆþ¤ì¤ë·ä´Ö¤¬¤Ê¤¤¡£", o_name);
1026 msg_format("You have no room for %s.", o_name);
1030 py_pickup_aux(this_o_idx);
1037 * When always_pickup is 'yes', we disable
1038 * auto-destroyer from autopick function, and do only
1039 * easy-auto-destroyer.
1043 if (auto_destroy_item((-this_o_idx), idx))
1051 * Describe which kind of object is Auto-picked/destroyed
1053 static void describe_autopick(char *buff, autopick_type *entry)
1055 cptr str = entry->name;
1056 byte act = entry->action;
1057 cptr insc = entry->insc;
1063 cptr before_str[20], body_str;
1066 body_str = "¥¢¥¤¥Æ¥à";
1068 /*** Collecting items ***/
1069 /*** Which can be absorbed into a slot as a bundle ***/
1070 if (IS_FLG(FLG_COLLECTING))
1071 before_str[before_n++] = "¼ý½¸Ãæ¤Ç´û¤Ë»ý¤Ã¤Æ¤¤¤ë¥¹¥í¥Ã¥È¤Ë¤Þ¤È¤á¤é¤ì¤ë";
1073 /*** Unidentified ***/
1074 if (IS_FLG(FLG_UNIDENTIFIED))
1075 before_str[before_n++] = "̤´ÕÄê¤Î";
1077 /*** Identified ***/
1078 if (IS_FLG(FLG_IDENTIFIED))
1079 before_str[before_n++] = "´ÕÄêºÑ¤ß¤Î";
1081 /*** *Identified* ***/
1082 if (IS_FLG(FLG_STAR_IDENTIFIED))
1083 before_str[before_n++] = "´°Á´¤Ë´ÕÄêºÑ¤ß¤Î";
1085 /*** Dice boosted (weapon of slaying) ***/
1086 if (IS_FLG(FLG_BOOSTED))
1088 before_str[before_n++] = "¥À¥á¡¼¥¸¥À¥¤¥¹¤¬Ä̾ï¤è¤êÂ礤¤";
1092 /*** Weapons whose dd*ds is more than nn ***/
1093 if (IS_FLG(FLG_MORE_THAN))
1095 static char more_than_desc_str[] = "___";
1096 before_str[before_n++] = "¥À¥á¡¼¥¸¥À¥¤¥¹¤ÎºÇÂçÃͤ¬";
1099 sprintf(more_than_desc_str,"%d", entry->dice);
1100 before_str[before_n++] = more_than_desc_str;
1101 before_str[before_n++] = "°Ê¾å¤Î";
1104 /*** Items whose magical bonus is more than nn ***/
1105 if (IS_FLG(FLG_MORE_BONUS))
1107 static char more_bonus_desc_str[] = "___";
1108 before_str[before_n++] = "½¤ÀµÃͤ¬(+";
1110 sprintf(more_bonus_desc_str,"%d", entry->bonus);
1111 before_str[before_n++] = more_bonus_desc_str;
1112 before_str[before_n++] = ")°Ê¾å¤Î";
1115 /*** Worthless items ***/
1116 if (IS_FLG(FLG_WORTHLESS))
1117 before_str[before_n++] = "Ź¤Ç̵²ÁÃͤÈȽÄꤵ¤ì¤ë";
1120 if (IS_FLG(FLG_ARTIFACT))
1122 before_str[before_n++] = "¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤Î";
1127 if (IS_FLG(FLG_EGO))
1129 before_str[before_n++] = "¥¨¥´¥¢¥¤¥Æ¥à¤Î";
1134 if (IS_FLG(FLG_NAMELESS))
1136 before_str[before_n++] = "¥¨¥´¤Ç¤â¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤Ç¤â¤Ê¤¤";
1140 /*** Unaware items ***/
1141 if (IS_FLG(FLG_UNAWARE))
1142 before_str[before_n++] = "̤´ÕÄê¤Ç¤½¤Î¸ú²Ì¤âȽÌÀ¤·¤Æ¤¤¤Ê¤¤";
1144 /*** Wanted monster's corpse/skeletons ***/
1145 if (IS_FLG(FLG_WANTED))
1147 before_str[before_n++] = "¥Ï¥ó¥¿¡¼»ö̳½ê¤Ç¾Þ¶â¼ó¤È¤µ¤ì¤Æ¤¤¤ë";
1148 body_str = "»àÂΤä¹ü";
1151 /*** Human corpse/skeletons (for Daemon magic) ***/
1152 if (IS_FLG(FLG_HUMAN))
1154 before_str[before_n++] = "°ËâËâË¡¤Ç»È¤¦¤¿¤á¤Î¿Í´Ö¤ä¥Ò¥å¡¼¥Þ¥Î¥¤¥É¤Î";
1155 body_str = "»àÂΤä¹ü";
1158 /*** Unique monster's corpse/skeletons/statues ***/
1159 if (IS_FLG(FLG_UNIQUE))
1161 before_str[before_n++] = "¥æ¥Ë¡¼¥¯¥â¥ó¥¹¥¿¡¼¤Î";
1162 body_str = "»àÂΤä¹ü";
1165 /*** Unreadable spellbooks ***/
1166 if (IS_FLG(FLG_UNREADABLE))
1168 before_str[before_n++] = "¤¢¤Ê¤¿¤¬Æɤá¤Ê¤¤Îΰè¤Î";
1169 body_str = "ËâË¡½ñ";
1172 /*** First realm spellbooks ***/
1173 if (IS_FLG(FLG_REALM1))
1175 before_str[before_n++] = "Âè°ìÎΰè¤Î";
1176 body_str = "ËâË¡½ñ";
1179 /*** Second realm spellbooks ***/
1180 if (IS_FLG(FLG_REALM2))
1182 before_str[before_n++] = "ÂèÆóÎΰè¤Î";
1183 body_str = "ËâË¡½ñ";
1186 /*** First rank spellbooks ***/
1187 if (IS_FLG(FLG_FIRST))
1189 before_str[before_n++] = "Á´4ºý¤ÎÆâ¤Î1ºýÌܤÎ";
1190 body_str = "ËâË¡½ñ";
1193 /*** Second rank spellbooks ***/
1194 if (IS_FLG(FLG_SECOND))
1196 before_str[before_n++] = "Á´4ºý¤ÎÆâ¤Î2ºýÌܤÎ";
1197 body_str = "ËâË¡½ñ";
1200 /*** Third rank spellbooks ***/
1201 if (IS_FLG(FLG_THIRD))
1203 before_str[before_n++] = "Á´4ºý¤ÎÆâ¤Î3ºýÌܤÎ";
1204 body_str = "ËâË¡½ñ";
1207 /*** Fourth rank spellbooks ***/
1208 if (IS_FLG(FLG_FOURTH))
1210 before_str[before_n++] = "Á´4ºý¤ÎÆâ¤Î4ºýÌܤÎ";
1211 body_str = "ËâË¡½ñ";
1215 if (IS_FLG(FLG_ITEMS))
1216 ; /* Nothing to do */
1217 else if (IS_FLG(FLG_WEAPONS))
1219 else if (IS_FLG(FLG_ARMORS))
1221 else if (IS_FLG(FLG_MISSILES))
1222 body_str = "ÃƤäÌð¤ä¥¯¥í¥¹¥Ü¥¦¤ÎÌð";
1223 else if (IS_FLG(FLG_DEVICES))
1224 body_str = "´¬Êª¤äËâË¡ËÀ¤ä¾ó¤ä¥í¥Ã¥É";
1225 else if (IS_FLG(FLG_LIGHTS))
1226 body_str = "¸÷¸»ÍѤΥ¢¥¤¥Æ¥à";
1227 else if (IS_FLG(FLG_JUNKS))
1228 body_str = "Àޤ줿ËÀÅù¤Î¥¬¥é¥¯¥¿";
1229 else if (IS_FLG(FLG_SPELLBOOKS))
1230 body_str = "ËâË¡½ñ";
1231 else if (IS_FLG(FLG_HAFTED))
1233 else if (IS_FLG(FLG_SHIELDS))
1235 else if (IS_FLG(FLG_BOWS))
1236 body_str = "¥¹¥ê¥ó¥°¤äµÝ¤ä¥¯¥í¥¹¥Ü¥¦";
1237 else if (IS_FLG(FLG_RINGS))
1239 else if (IS_FLG(FLG_AMULETS))
1240 body_str = "¥¢¥ß¥å¥ì¥Ã¥È";
1241 else if (IS_FLG(FLG_SUITS))
1243 else if (IS_FLG(FLG_CLOAKS))
1244 body_str = "¥¯¥í¡¼¥¯";
1245 else if (IS_FLG(FLG_HELMS))
1246 body_str = "¥Ø¥ë¥á¥Ã¥È¤ä´§";
1247 else if (IS_FLG(FLG_GLOVES))
1249 else if (IS_FLG(FLG_BOOTS))
1250 body_str = "¥Ö¡¼¥Ä";
1254 strcat(buff, "Á´¤Æ¤Î");
1255 else for (i = 0; i < before_n && before_str[i]; i++)
1256 strcat(buff, before_str[i]);
1258 strcat(buff, body_str);
1268 strcat(buff, "¤Ç¡¢Ì¾Á°¤¬¡Ö");
1269 strncat(buff, str, 80);
1271 strcat(buff, "¡×¤Ç»Ï¤Þ¤ë¤â¤Î");
1273 strcat(buff, "¡×¤ò´Þ¤à¤â¤Î");
1277 strncat(buff, format("¤Ë¡Ö%s¡×¤È¹ï¤ó¤Ç", insc), 80);
1281 if (act & DONT_AUTOPICK)
1282 strcat(buff, "ÊüÃÖ¤¹¤ë¡£");
1283 else if (act & DO_AUTODESTROY)
1284 strcat(buff, "Ç˲õ¤¹¤ë¡£");
1286 strcat(buff, "½¦¤¦¡£");
1288 if (act & DO_DISPLAY)
1290 if (act & DONT_AUTOPICK)
1291 strcat(buff, "Á´ÂΥޥå×('M')¤Ç'N'¤ò²¡¤·¤¿¤È¤¤Ëɽ¼¨¤¹¤ë¡£");
1292 else if (act & DO_AUTODESTROY)
1293 strcat(buff, "Á´ÂΥޥå×('M')¤Ç'K'¤ò²¡¤·¤¿¤È¤¤Ëɽ¼¨¤¹¤ë¡£");
1295 strcat(buff, "Á´ÂΥޥå×('M')¤Ç'M'¤ò²¡¤·¤¿¤È¤¤Ëɽ¼¨¤¹¤ë¡£");
1298 strcat(buff, "Á´ÂΥޥåפˤÏɽ¼¨¤·¤Ê¤¤");
1302 cptr before_str[20], after_str[20], which_str[20], whose_str[20], body_str;
1303 int before_n = 0, after_n = 0, which_n = 0, whose_n = 0;
1307 /*** Collecting items ***/
1308 /*** Which can be absorbed into a slot as a bundle ***/
1309 if (IS_FLG(FLG_COLLECTING))
1310 which_str[which_n++] = "can be absorbed into an existing inventory slot";
1312 /*** Unidentified ***/
1313 if (IS_FLG(FLG_UNIDENTIFIED))
1314 before_str[before_n++] = "unidentified";
1316 /*** Identified ***/
1317 if (IS_FLG(FLG_IDENTIFIED))
1318 before_str[before_n++] = "identified";
1320 /*** *Identified* ***/
1321 if (IS_FLG(FLG_STAR_IDENTIFIED))
1322 before_str[before_n++] = "fully identified";
1324 /*** Worthless items ***/
1325 if (IS_FLG(FLG_WORTHLESS))
1327 before_str[before_n++] = "worthless";
1328 which_str[which_n++] = "can not be sold at stores";
1332 if (IS_FLG(FLG_ARTIFACT))
1334 before_str[before_n++] = "artifact";
1338 if (IS_FLG(FLG_EGO))
1340 before_str[before_n++] = "ego";
1344 if (IS_FLG(FLG_NAMELESS))
1346 body_str = "equipment";
1347 which_str[which_n++] = "is neither ego-item nor artifact";
1350 /*** Unaware items ***/
1351 if (IS_FLG(FLG_UNAWARE))
1353 before_str[before_n++] = "unidentified";
1354 whose_str[whose_n++] = "basic abilities are not known";
1357 /*** Dice boosted (weapon of slaying) ***/
1358 if (IS_FLG(FLG_BOOSTED))
1360 body_str = "weapons";
1361 whose_str[whose_n++] = "damage dice is bigger than normal";
1364 /*** Weapons whose dd*ds is more than nn ***/
1365 if (IS_FLG(FLG_MORE_THAN))
1367 static char more_than_desc_str[] =
1368 "maximum damage from dice is bigger than __";
1369 body_str = "weapons";
1371 sprintf(more_than_desc_str + sizeof(more_than_desc_str) - 3,
1373 whose_str[whose_n++] = more_than_desc_str;
1376 /*** Items whose magical bonus is more than nn ***/
1377 if (IS_FLG(FLG_MORE_BONUS))
1379 static char more_bonus_desc_str[] =
1380 "magical bonus is bigger than (+__)";
1382 sprintf(more_bonus_desc_str + sizeof(more_bonus_desc_str) - 4,
1383 "%d)", entry->bonus);
1384 whose_str[whose_n++] = more_bonus_desc_str;
1387 /*** Wanted monster's corpse/skeletons ***/
1388 if (IS_FLG(FLG_WANTED))
1390 body_str = "corpse or skeletons";
1391 which_str[which_n++] = "is wanted at the Hunter's Office";
1394 /*** Human corpse/skeletons (for Daemon magic) ***/
1395 if (IS_FLG(FLG_HUMAN))
1397 before_str[before_n++] = "humanoid";
1398 body_str = "corpse or skeletons";
1399 which_str[which_n++] = "can be used for Daemon magic";
1402 /*** Unique monster's corpse/skeletons/statues ***/
1403 if (IS_FLG(FLG_UNIQUE))
1405 before_str[before_n++] = "unique monster's";
1406 body_str = "corpse or skeletons";
1409 /*** Unreadable spellbooks ***/
1410 if (IS_FLG(FLG_UNREADABLE))
1412 body_str = "spellbooks";
1413 after_str[after_n++] = "of different realms from yours";
1416 /*** First realm spellbooks ***/
1417 if (IS_FLG(FLG_REALM1))
1419 body_str = "spellbooks";
1420 after_str[after_n++] = "of your first realm";
1423 /*** Second realm spellbooks ***/
1424 if (IS_FLG(FLG_REALM2))
1426 body_str = "spellbooks";
1427 after_str[after_n++] = "of your second realm";
1430 /*** First rank spellbooks ***/
1431 if (IS_FLG(FLG_FIRST))
1433 before_str[before_n++] = "first one of four";
1434 body_str = "spellbooks";
1437 /*** Second rank spellbooks ***/
1438 if (IS_FLG(FLG_SECOND))
1440 before_str[before_n++] = "second one of four";
1441 body_str = "spellbooks";
1444 /*** Third rank spellbooks ***/
1445 if (IS_FLG(FLG_THIRD))
1447 before_str[before_n++] = "third one of four";
1448 body_str = "spellbooks";
1451 /*** Fourth rank spellbooks ***/
1452 if (IS_FLG(FLG_FOURTH))
1454 before_str[before_n++] = "fourth one of four";
1455 body_str = "spellbooks";
1459 if (IS_FLG(FLG_ITEMS))
1460 ; /* Nothing to do */
1461 else if (IS_FLG(FLG_WEAPONS))
1462 body_str = "weapons";
1463 else if (IS_FLG(FLG_ARMORS))
1464 body_str = "armors";
1465 else if (IS_FLG(FLG_MISSILES))
1466 body_str = "shots, arrows or crossbow bolts";
1467 else if (IS_FLG(FLG_DEVICES))
1468 body_str = "scrolls, wands, staves or rods";
1469 else if (IS_FLG(FLG_LIGHTS))
1470 body_str = "light sources";
1471 else if (IS_FLG(FLG_JUNKS))
1472 body_str = "junk such as broken sticks";
1473 else if (IS_FLG(FLG_SPELLBOOKS))
1474 body_str = "spellbooks";
1475 else if (IS_FLG(FLG_HAFTED))
1476 body_str = "hafted weapons";
1477 else if (IS_FLG(FLG_SHIELDS))
1478 body_str = "shields";
1479 else if (IS_FLG(FLG_BOWS))
1480 body_str = "slings, bows or crossbows";
1481 else if (IS_FLG(FLG_RINGS))
1483 else if (IS_FLG(FLG_AMULETS))
1484 body_str = "amulets";
1485 else if (IS_FLG(FLG_SUITS))
1486 body_str = "body armors";
1487 else if (IS_FLG(FLG_CLOAKS))
1488 body_str = "cloaks";
1489 else if (IS_FLG(FLG_HELMS))
1490 body_str = "helms or crowns";
1491 else if (IS_FLG(FLG_GLOVES))
1492 body_str = "gloves";
1493 else if (IS_FLG(FLG_BOOTS))
1496 /* Prepare a string for item name */
1503 whose_str[whose_n++] = "name is beginning with \"";
1506 which_str[which_n++] = "have \"";
1510 /* Describe action flag */
1511 if (act & DONT_AUTOPICK)
1512 strcpy(buff, "Leave on floor ");
1513 else if (act & DO_AUTODESTROY)
1514 strcpy(buff, "Destroy ");
1516 strcpy(buff, "Pickup ");
1518 /* Auto-insctiption */
1520 strncat(buff, format("and inscribe \"%s\" on ", insc), 80);
1524 strcat(buff, "all ");
1525 else for (i = 0; i < before_n && before_str[i]; i++)
1527 strcat(buff, before_str[i]);
1532 strcat(buff, body_str);
1535 for (i = 0; i < after_n && after_str[i]; i++)
1538 strcat(buff, after_str[i]);
1542 for (i = 0; i < whose_n && whose_str[i]; i++)
1545 strcat(buff, " whose ");
1547 strcat(buff, ", and ");
1549 strcat(buff, whose_str[i]);
1552 /* Item name ; whose name is beginning with "str" */
1559 /* whose ..., and which .... */
1560 if (whose_n && which_n)
1561 strcat(buff, ", and ");
1564 for (i = 0; i < which_n && which_str[i]; i++)
1567 strcat(buff, " which ");
1569 strcat(buff, ", and ");
1571 strcat(buff, which_str[i]);
1574 /* Item name ; which have "str" as part of its name */
1577 strncat(buff, str, 80);
1578 strcat(buff, "\" as part of its name");
1582 /* Describe whether it will be displayed on the full map or not */
1583 if (act & DO_DISPLAY)
1585 if (act & DONT_AUTOPICK)
1586 strcat(buff, " Display these items when you press 'N' in the full map('M').");
1587 else if (act & DO_AUTODESTROY)
1588 strcat(buff, " Display these items when you press 'K' in the full map('M').");
1590 strcat(buff, " Display these items when you press 'M' in the full map('M').");
1593 strcat(buff, " Not displayed in the full map.");
1599 #define MAX_LINES 3000
1602 * Read whole lines of a file to memory
1604 static cptr *read_text_lines(cptr filename, bool user)
1606 cptr *lines_list = NULL;
1614 /* Hack -- drop permissions */
1616 path_build(buf, 1024, ANGBAND_DIR_USER, filename);
1620 path_build(buf, 1024, ANGBAND_DIR_PREF, filename);
1624 fff = my_fopen(buf, "r");
1628 /* Allocate list of pointers */
1629 C_MAKE(lines_list, MAX_LINES, cptr);
1632 while (0 == my_fgets(fff, buf, 1024))
1634 lines_list[lines++] = string_make(buf);
1635 if (lines >= MAX_LINES - 1) break;
1638 lines_list[0] = string_make("");
1646 if (!fff) return NULL;
1650 static cptr *read_pickpref_text_lines(void)
1656 sprintf(buf, "picktype-%s.prf", player_name);
1658 sprintf(buf, "pickpref-%s.prf", player_name);
1660 lines_list = read_text_lines(buf, TRUE);
1665 lines_list = read_text_lines("picktype.prf", TRUE);
1667 lines_list = read_text_lines("pickpref.prf", TRUE);
1674 lines_list = read_text_lines("picktype.prf", FALSE);
1676 lines_list = read_text_lines("pickpref.prf", FALSE);
1682 /* Allocate list of pointers */
1683 C_MAKE(lines_list, MAX_LINES, cptr);
1684 lines_list[0] = string_make("");
1690 * Write whole lines of memory to a file.
1692 static bool write_text_lines(cptr filename, cptr *lines_list)
1699 /* Hack -- drop permissions */
1702 /* Build the filename */
1703 path_build(buf, 1024, ANGBAND_DIR_USER, filename);
1706 fff = my_fopen(buf, "w");
1709 for (lines = 0; lines_list[lines]; lines++)
1710 my_fputs(fff, lines_list[lines], 1024);
1718 if (!fff) return FALSE;
1724 * Free memory of lines_list.
1726 static void free_text_lines(cptr *lines_list)
1730 for (lines = 0; lines_list[lines]; lines++)
1731 string_free(lines_list[lines]);
1733 /* free list of pointers */
1734 C_FREE((char **)lines_list, MAX_LINES, char *);
1741 static void insert_string(cptr *lines_list, cptr str, int x, int y)
1746 for (i = j = 0; lines_list[y][i] && i < x; i++)
1747 buf[j++] = lines_list[y][i];
1749 while (*str) buf[j++] = *str++;
1751 for (; lines_list[y][i]; i++)
1752 buf[j++] = lines_list[y][i];
1754 string_free(lines_list[y]);
1755 lines_list[y] = string_make(buf);
1761 static void delete_string(cptr *lines_list, int n, int x, int y)
1766 for (i = j = 0; lines_list[y][i] && i < x; i++)
1769 if (iskanji(lines_list[y][i]))
1770 buf[j++] = lines_list[y][i++];
1772 buf[j++] = lines_list[y][i];
1776 for (; lines_list[y][i]; i++)
1777 buf[j++] = lines_list[y][i];
1779 string_free(lines_list[y]);
1780 lines_list[y] = string_make(buf);
1785 * Delete or insert string
1787 static void toggle_string(cptr *lines_list, int flg, int y)
1789 autopick_type an_entry, *entry = &an_entry;
1791 if (!autopick_new_entry(entry, lines_list[y]))
1794 string_free(lines_list[y]);
1800 lines_list[y] = autopick_line_from_entry(entry);
1804 * Insert return code and split the line
1806 static bool insert_return_code(cptr *lines_list, int cx, int cy)
1811 for (k = 0; lines_list[k]; k++)
1812 /* count number of lines */ ;
1814 if (k >= MAX_LINES - 2) return FALSE;
1817 /* Move down lines */
1819 lines_list[k+1] = lines_list[k];
1821 /* Split current line */
1822 for (i = j = 0; lines_list[cy][i] && i < cx; i++)
1825 if (iskanji(lines_list[cy][i]))
1826 buf[j++] = lines_list[cy][i++];
1828 buf[j++] = lines_list[cy][i];
1831 lines_list[cy+1] = string_make(&lines_list[cy][i]);
1832 string_free(lines_list[cy]);
1833 lines_list[cy] = string_make(buf);
1839 * Get auto-picker entry from o_ptr.
1841 void autopick_entry_from_object(autopick_type *entry, object_type *o_ptr)
1843 char o_name[MAX_NLEN];
1844 object_desc(o_name, o_ptr, FALSE, 0);
1846 entry->name = string_make(o_name);
1847 entry->insc = string_make(quark_str(o_ptr->inscription));
1848 entry->action = DO_AUTOPICK | DO_DISPLAY;
1849 entry->flag[0] = entry->flag[1] = 0L;
1852 if (!object_aware_p(o_ptr))
1853 ADD_FLG(FLG_UNAWARE);
1854 if (object_value(o_ptr) <= 0)
1855 ADD_FLG(FLG_WORTHLESS);
1857 if (object_known_p(o_ptr))
1861 else if (o_ptr->name1 || o_ptr->art_name)
1862 ADD_FLG(FLG_ARTIFACT);
1868 case TV_HAFTED: case TV_POLEARM: case TV_SWORD: case TV_DIGGING:
1869 k_ptr = &k_info[o_ptr->k_idx];
1870 if ((o_ptr->dd != k_ptr->dd) || (o_ptr->ds != k_ptr->ds))
1871 ADD_FLG(FLG_BOOSTED);
1874 if (o_ptr->tval == TV_CORPSE && object_is_shoukinkubi(o_ptr))
1876 REM_FLG(FLG_WORTHLESS);
1877 ADD_FLG(FLG_WANTED);
1880 if ((o_ptr->tval == TV_CORPSE || o_ptr->tval == TV_STATUE)
1881 && (r_info[o_ptr->pval].flags1 & RF1_UNIQUE))
1883 REM_FLG(FLG_WORTHLESS);
1884 ADD_FLG(FLG_UNIQUE);
1887 if (o_ptr->tval == TV_CORPSE && strchr("pht", r_info[o_ptr->pval].d_char))
1889 REM_FLG(FLG_WORTHLESS);
1893 if (o_ptr->tval >= TV_LIFE_BOOK &&
1894 !check_book_realm(o_ptr->tval, o_ptr->sval))
1895 ADD_FLG(FLG_UNREADABLE);
1897 if (REALM1_BOOK == o_ptr->tval &&
1898 p_ptr->pclass != CLASS_SORCERER &&
1899 p_ptr->pclass != CLASS_RED_MAGE)
1900 ADD_FLG(FLG_REALM1);
1902 if (REALM2_BOOK == o_ptr->tval &&
1903 p_ptr->pclass != CLASS_SORCERER &&
1904 p_ptr->pclass != CLASS_RED_MAGE)
1905 ADD_FLG(FLG_REALM2);
1907 if (o_ptr->tval >= TV_LIFE_BOOK && 0 == o_ptr->sval)
1909 if (o_ptr->tval >= TV_LIFE_BOOK && 1 == o_ptr->sval)
1910 ADD_FLG(FLG_SECOND);
1911 if (o_ptr->tval >= TV_LIFE_BOOK && 2 == o_ptr->sval)
1913 if (o_ptr->tval >= TV_LIFE_BOOK && 3 == o_ptr->sval)
1914 ADD_FLG(FLG_FOURTH);
1916 if (o_ptr->tval == TV_SHOT || o_ptr->tval == TV_BOLT
1917 || o_ptr->tval == TV_ARROW)
1918 ADD_FLG(FLG_MISSILES);
1919 else if (o_ptr->tval == TV_SCROLL || o_ptr->tval == TV_STAFF
1920 || o_ptr->tval == TV_WAND || o_ptr->tval == TV_ROD)
1921 ADD_FLG(FLG_DEVICES);
1922 else if (o_ptr->tval == TV_LITE)
1923 ADD_FLG(FLG_LIGHTS);
1924 else if (o_ptr->tval == TV_SKELETON || o_ptr->tval == TV_BOTTLE
1925 || o_ptr->tval == TV_JUNK || o_ptr->tval == TV_STATUE)
1927 else if (o_ptr->tval >= TV_LIFE_BOOK)
1928 ADD_FLG(FLG_SPELLBOOKS);
1929 else if (o_ptr->tval == TV_HAFTED)
1930 ADD_FLG(FLG_HAFTED);
1931 else if (o_ptr->tval == TV_POLEARM || o_ptr->tval == TV_SWORD
1932 || o_ptr->tval == TV_DIGGING)
1933 ADD_FLG(FLG_WEAPONS);
1934 else if (o_ptr->tval == TV_SHIELD)
1935 ADD_FLG(FLG_SHIELDS);
1936 else if (o_ptr->tval == TV_BOW)
1938 else if (o_ptr->tval == TV_RING)
1940 else if (o_ptr->tval == TV_AMULET)
1941 ADD_FLG(FLG_AMULETS);
1942 else if (o_ptr->tval == TV_DRAG_ARMOR || o_ptr->tval == TV_HARD_ARMOR ||
1943 o_ptr->tval == TV_SOFT_ARMOR)
1945 else if (o_ptr->tval == TV_CLOAK)
1946 ADD_FLG(FLG_CLOAKS);
1947 else if (o_ptr->tval == TV_HELM)
1949 else if (o_ptr->tval == TV_GLOVES)
1950 ADD_FLG(FLG_GLOVES);
1951 else if (o_ptr->tval == TV_BOOTS)
1958 * Choose an item and get auto-picker entry from it.
1960 static bool entry_from_choosed_object(autopick_type *entry)
1968 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÅÐÏ¿¤·¤Þ¤¹¤«? ";
1969 s = "¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£";
1971 q = "Entry which item? ";
1972 s = "You have nothing to entry.";
1974 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP))) return FALSE;
1976 /* Get the item (in the pack) */
1979 o_ptr = &inventory[item];
1982 /* Get the item (on the floor) */
1985 o_ptr = &o_list[0 - item];
1988 autopick_entry_from_object(entry, o_ptr);
1994 * Initialize auto-picker preference
1996 void init_autopicker(void)
1998 static const char easy_autopick_inscription[] = "(:=g";
1999 autopick_type entry;
2002 /* Clear old entries */
2003 for( i = 0; i < max_autopick; i++)
2004 autopick_free_entry(&autopick_list[i]);
2008 /* There is always one entry "=g" */
2009 autopick_new_entry(&entry, easy_autopick_inscription);
2010 autopick_list[max_autopick++] = entry;
2015 * Description of control commands
2020 static cptr ctrl_command_desc[] =
2023 #define LAST_DESTROYED 6
2024 "^P ^N ^B ^F ¾å²¼º¸±¦¤Ë°ÜÆ°",
2025 "^A ^E ¹Ô¤ÎÀèƬ¡¢½ªÃ¼",
2026 "^Q ÆþÎÏ/¥³¥Þ¥ó¥É¥â¡¼¥ÉÀÚ¤êÂؤ¨",
2027 "^R Êѹ¹¤òÁ´¤Æ¼è¤ê¾Ã¤·¤Æ¸µ¤ËÌ᤹",
2028 "------------------------------------",
2029 "^I »ý¤Áʪ/ÁõÈ÷¤«¤éÁªÂò",
2031 "^K ¥«¡¼¥½¥ë¤«¤é½ªÃ¼¤Þ¤Çºï½ü",
2032 "^Y ºï½ü(^K)¤·¤¿¹Ô¤òÁÞÆþ",
2033 "^C ¼ï²¡¢¿¦¶È¤Î¾ò·ï¼°¤òÁÞÆþ",
2034 "------------------------------------",
2035 "^S Êѹ¹ (!Ç˲õ/~ÊüÃÖ/½¦¤¦)",
2036 "^G \"(\" Á´ÂΥޥåפÇɽ¼¨¤·¤Ê¤¤",
2037 "^O \"#\" ¼«Æ°¹ï¤ß",
2038 "------------------------------------",
2039 "^U ̤´ÕÄê/̤ȽÌÀ/´ÕÄê/*´ÕÄê*",
2041 "^X ̵ÌÃ/¥¨¥´/¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È",
2045 #define LAST_DESTROYED 6
2046 "^P ^N ^B ^F Move Cursor",
2047 "^A ^E Beginning and End of Line",
2048 "^Q Toggle Insert/Command mode",
2049 "^R Revert to Original File",
2050 "------------------------------------",
2051 "^I Object in Inventry/Equipment",
2053 "^K Kill Rest of Line",
2054 "^Y Insert killed(^K) text",
2055 "^C Insert conditional expression",
2056 "------------------------------------",
2057 "^S Toggle(!Destroy/~Leave/Pick)",
2058 "^G \"(\" No display in the 'M'ap",
2059 "^O \"#\" Auto-Inscribe",
2060 "------------------------------------",
2061 "^U Toggle 'identified' state",
2063 "^X Toggle nameless/ego/artifact",
2064 "^Z \"collecting\"",
2070 #define MAX_YANK 1024
2071 #define DIRTY_ALL 0x01
2072 #define DIRTY_COMMAND 0x02
2073 #define DIRTY_MODE 0x04
2074 #define DIRTY_SCREEN 0x04
2077 * In-game editor of Object Auto-picker/Destoryer
2079 void do_cmd_edit_autopick(void)
2081 static int cx = 0, cy = 0;
2082 static int upper = 0, left = 0;
2084 cptr last_destroyed;
2085 char last_destroyed_command[WID_DESC+3];
2086 char yank_buf[MAX_YANK];
2088 autopick_type an_entry, *entry = &an_entry;
2095 int old_upper = -1, old_left = -1;
2097 int key = -1, old_key;
2099 bool edit_mode = FALSE;
2101 byte dirty_flags = DIRTY_ALL | DIRTY_COMMAND | DIRTY_MODE;
2102 int dirty_line = -1;
2104 int wid, hgt, old_wid = -1, old_hgt = -1;
2106 /* Free old entries */
2109 /* Name of the Last Destroyed Item */
2110 last_destroyed = autopick_line_from_entry(&autopick_entry_last_destroyed);
2112 /* Command Description of the Last Destroyed Item */
2115 strcpy(last_destroyed_command, "^L \"");
2116 strncpy(last_destroyed_command + 4, last_destroyed, WID_DESC-4);
2117 last_destroyed_command[WID_DESC+2] = '\0';
2122 strcpy(last_destroyed_command, "^L ºÇ¸å¤Ë¼«Æ°Ç˲õ¤·¤¿¥¢¥¤¥Æ¥à̾");
2124 strcpy(last_destroyed_command, "^L Last destroyed object");
2127 ctrl_command_desc[LAST_DESTROYED] = last_destroyed_command;
2129 /* Conditional Expression for Class and Race */
2130 sprintf(classrace, "?:[AND [EQU $RACE %s] [EQU $CLASS %s]]",
2132 rp_ptr->E_title, cp_ptr->E_title
2134 rp_ptr->title, cp_ptr->title
2138 /* Clear yank buffer */
2141 /* Read or initialize whole text */
2142 lines_list = read_pickpref_text_lines();
2144 /* Reset cursor position if needed */
2145 for (i = 0; i < cy; i++)
2154 /* Save the screen */
2157 /* Process requests until done */
2161 Term_get_size(&wid, &hgt);
2164 /* Don't let cursor at second byte of kanji */
2165 for (i = 0; lines_list[cy][i]; i++)
2166 if (iskanji(lines_list[cy][i]))
2177 /* Scroll if necessary */
2178 if (cy < upper || upper + hgt - 4 <= cy)
2179 upper = cy - (hgt-4)/2;
2182 if ((cx < left + 10 && left > 0) || left + wid - WID_DESC - 5 <= cx)
2183 left = cx - (wid - WID_DESC)*2/3;
2187 /* Redraw whole window after resize */
2188 if (old_wid != wid || old_hgt != hgt)
2189 dirty_flags |= DIRTY_SCREEN;
2191 /* Redraw all text after scroll */
2192 else if (old_upper != upper || old_left != left)
2193 dirty_flags |= DIRTY_ALL;
2196 if (dirty_flags & DIRTY_SCREEN)
2198 dirty_flags = DIRTY_ALL | DIRTY_COMMAND | DIRTY_MODE;
2204 if (dirty_flags & DIRTY_COMMAND)
2206 /* Display control command */
2207 for (i = 0; ctrl_command_desc[i]; i++)
2208 Term_putstr(wid - WID_DESC, i + 1, WID_DESC, TERM_WHITE, ctrl_command_desc[i]);
2211 /* Redraw mode line */
2212 if (dirty_flags & DIRTY_MODE)
2214 int sepa_length = wid - WID_DESC;
2217 for (i = 0; i < sepa_length; i++)
2223 strncpy(buf + sepa_length - 21, " (INSERT MODE) ", 16);
2225 strncpy(buf + sepa_length - 21, " (COMMAND MODE) ", 16);
2227 Term_putstr(0, hgt - 3, sepa_length, (byte) (edit_mode ? TERM_YELLOW : TERM_WHITE), buf);
2230 /* Dump up to 20, or hgt-4, lines of messages */
2231 for (i = 0; i < hgt - 4; i++)
2236 /* clean or dirty? */
2237 if (!(dirty_flags & DIRTY_ALL) && (dirty_line != upper+i))
2240 msg = lines_list[upper+i];
2243 /* Apply horizontal scroll */
2244 for (j = 0; *msg; msg++, j++)
2246 if (j == left) break;
2262 Term_erase(0, i + 1, wid - WID_DESC);
2264 /* Dump the messages, bottom to top */
2265 Term_putstr(leftcol, i + 1, wid - WID_DESC - 1, TERM_WHITE, msg);
2268 for (; i < hgt - 4; i++)
2271 Term_erase(0, i + 1, wid - WID_DESC);
2274 /* Display header line */
2277 prt("^Q ESC ¤Ç¥³¥Þ¥ó¥É¥â¡¼¥É¤Ø°Ü¹Ô¡¢Ä̾ï¤Îʸ»ú¤Ï¤½¤Î¤Þ¤ÞÆþÎÏ", 0, 0);
2279 prt("q _ ¤Ç½ªÎ»¡¢hjkl2468 ¤Ç°ÜÆ°¡¢^Q a i ¤ÇÆþÎϥ⡼¥É", 0, 0);
2282 prt("Press ^Q ESC to command mode, any letters to insert", 0, 0);
2284 prt("Press q _ to quit, hjkl2468 to move, ^Q a i to insert mode", 0, 0);
2286 /* Display current position */
2287 prt (format("(%d,%d)", cx, cy), 0, 70);
2289 /* Display information when updated */
2290 if (old_cy != cy || (dirty_flags & DIRTY_ALL) || dirty_line == cy)
2292 /* Clear information line */
2293 Term_erase(0, hgt - 3 + 1, wid);
2294 Term_erase(0, hgt - 3 + 2, wid);
2296 /* Display information */
2297 if (lines_list[cy][0] == '#')
2300 prt("¤³¤Î¹Ô¤Ï¥³¥á¥ó¥È¤Ç¤¹¡£", hgt - 3 + 1, 0);
2302 prt("This line is comment.", hgt - 3 + 1, 0);
2305 else if (lines_list[cy][1] == ':')
2307 switch(lines_list[cy][0])
2311 prt("¤³¤Î¹Ô¤Ï¾ò·ïʬ´ô¼°¤Ç¤¹¡£", hgt - 3 + 1, 0);
2313 prt("This line is Conditional Expression.", hgt - 3 + 1, 0);
2318 prt("¤³¤Î¹Ô¤Ï¥Þ¥¯¥í¤Î¼Â¹ÔÆâÍƤòÄêµÁ¤·¤Þ¤¹¡£", hgt - 3 + 1, 0);
2320 prt("This line defines Macro action.", hgt - 3 + 1, 0);
2325 prt("¤³¤Î¹Ô¤Ï¥Þ¥¯¥í¤Î¥È¥ê¥¬¡¼¡¦¥¡¼¤òÄêµÁ¤·¤Þ¤¹¡£", hgt - 3 + 1, 0);
2327 prt("This line defines Macro trigger key.", hgt - 3 + 1, 0);
2332 prt("¤³¤Î¹Ô¤Ï¥¡¼ÇÛÃÖ¤òÄêµÁ¤·¤Þ¤¹¡£", hgt - 3 + 1, 0);
2334 prt("This line defines Keymap.", hgt - 3 + 1, 0);
2340 /* Get description of an autopicker preference line */
2341 else if (autopick_new_entry(entry, lines_list[cy]))
2346 describe_autopick(buf, entry);
2348 roff_to_buf(buf, 79, temp);
2350 for (i = 0; i< 2; i++)
2356 prt(t, hgt - 3 + 1 + i, 0);
2360 autopick_free_entry(entry);
2365 Term_gotoxy(cx - left, cy - upper + 1);
2371 /* Save old key and location */
2379 /* Do not process macros except special keys */
2380 inkey_special = TRUE;
2391 /* Mode line is now dirty */
2392 dirty_flags |= DIRTY_MODE;
2394 else if (!iscntrl(key&0xff))
2398 for (i = j = 0; lines_list[cy][i] && i < cx; i++)
2399 buf[j++] = lines_list[cy][i];
2422 for (; lines_list[cy][i] && j + 1 < 1024; i++)
2423 buf[j++] = lines_list[cy][i];
2425 string_free(lines_list[cy]);
2426 lines_list[cy] = string_make(buf);
2427 len = strlen(lines_list[cy]);
2428 if (len < cx) cx = len;
2437 if (key == 'q' || key == '_') break;
2444 /* Mode line is now dirty */
2445 dirty_flags |= DIRTY_MODE;
2448 if (!autopick_new_entry(entry, lines_list[cy]))
2450 string_free(lines_list[cy]);
2452 entry->action &= ~DO_AUTODESTROY;
2453 if (entry->action & DO_AUTOPICK)
2455 entry->action &= ~DO_AUTOPICK;
2456 entry->action |= DONT_AUTOPICK;
2460 entry->action &= ~DONT_AUTOPICK;
2461 entry->action |= DO_AUTOPICK;
2464 lines_list[cy] = autopick_line_from_entry(entry);
2470 if (!autopick_new_entry(entry, lines_list[cy]))
2472 string_free(lines_list[cy]);
2474 entry->action &= ~DONT_AUTOPICK;
2475 if (entry->action & DO_AUTOPICK)
2477 entry->action &= ~DO_AUTOPICK;
2478 entry->action |= DO_AUTODESTROY;
2482 entry->action &= ~DO_AUTODESTROY;
2483 entry->action |= DO_AUTOPICK;
2486 lines_list[cy] = autopick_line_from_entry(entry);
2511 while (cy < upper + hgt-4 && lines_list[cy + 1])
2516 while (0 < cy && upper <= cy)
2518 while (0 < upper && cy + 1 < upper + hgt - 4)
2527 /* Beginning of line */
2535 len = strlen(lines_list[cy]);
2536 if (len < cx) cx = len;
2541 cx = strlen(lines_list[cy]);
2545 /* Insert a conditinal expression line */
2546 insert_return_code(lines_list, 0, cy);
2547 lines_list[cy] = string_make(classrace);
2549 insert_return_code(lines_list, 0, cy);
2550 lines_list[cy] = string_make("?:1");
2554 dirty_flags |= DIRTY_ALL;
2558 cx = strlen(lines_list[cy]);
2563 if (iskanji(lines_list[cy][cx])) cx++;
2566 len = strlen(lines_list[cy]);
2569 if (lines_list[cy + 1])
2579 /* Toggle display in the 'M'ap */
2580 if (lines_list[cy][0] != '(' && lines_list[cy][1] != '(')
2581 insert_string(lines_list, "(", 0, cy);
2582 else if (lines_list[cy][0] == '(')
2583 delete_string(lines_list, 1, 0, cy);
2584 else if (lines_list[cy][1] == '(')
2585 delete_string(lines_list, 1, 1, cy);
2591 /* Insert choosen item name */
2592 if (!entry_from_choosed_object(entry))
2594 /* Now dirty because of item/equip menu */
2595 dirty_flags |= DIRTY_SCREEN;
2598 tmp = autopick_line_from_entry(entry);
2599 autopick_free_entry(entry);
2602 insert_return_code(lines_list, 0, cy);
2603 lines_list[cy] = tmp;
2606 /* Now dirty because of item/equip menu */
2607 dirty_flags |= DIRTY_SCREEN;
2611 /* Insert a name of last destroyed item */
2614 insert_return_code(lines_list, 0, cy);
2615 lines_list[cy] = string_make(last_destroyed);
2619 dirty_flags |= DIRTY_ALL;
2622 case '\n': case '\r':
2623 /* Split a line or insert end of line */
2624 insert_return_code(lines_list, cx, cy);
2629 dirty_flags |= DIRTY_ALL;
2633 if (lines_list[cy + 1]) cy++;
2636 /* Prepare to write auto-inscription text */
2637 for (i = 0; lines_list[cy][i]; i++)
2638 if (lines_list[cy][i] == '#') break;
2639 if (!lines_list[cy][i]) insert_string(lines_list, "#", i, cy);
2645 dirty_flags |= DIRTY_MODE;
2653 edit_mode = !edit_mode;
2655 /* Mode line is now dirty */
2656 dirty_flags |= DIRTY_MODE;
2659 /* Revert to original */
2661 if (!get_check("Á´¤Æ¤ÎÊѹ¹¤òÇË´þ¤·¤Æ¸µ¤Î¾õÂÖ¤ËÌᤷ¤Þ¤¹¡£¤è¤í¤·¤¤¤Ç¤¹¤«¡© "))
2663 if (!get_check("Discard all change and revert to original file. Are you sure? "))
2667 free_text_lines(lines_list);
2668 lines_list = read_pickpref_text_lines();
2669 dirty_flags |= DIRTY_ALL | DIRTY_MODE;
2674 /* Rotate action; pickup/destroy/leave */
2675 if (!autopick_new_entry(entry, lines_list[cy]))
2677 string_free(lines_list[cy]);
2679 if (entry->action & DO_AUTOPICK)
2681 entry->action &= ~DO_AUTOPICK;
2682 entry->action |= DO_AUTODESTROY;
2684 else if (entry->action & DO_AUTODESTROY)
2686 entry->action &= ~DO_AUTODESTROY;
2687 entry->action |= DONT_AUTOPICK;
2689 else if (entry->action & DONT_AUTOPICK)
2691 entry->action &= ~DONT_AUTOPICK;
2692 entry->action |= DO_AUTOPICK;
2695 lines_list[cy] = autopick_line_from_entry(entry);
2704 /* Rotate identify-state; identified/unidentified/... */
2705 if (!autopick_new_entry(entry, lines_list[cy]))
2707 string_free(lines_list[cy]);
2709 if (IS_FLG(FLG_UNIDENTIFIED))
2711 REM_FLG(FLG_UNIDENTIFIED);
2712 ADD_FLG(FLG_UNAWARE);
2713 REM_FLG(FLG_IDENTIFIED);
2714 REM_FLG(FLG_STAR_IDENTIFIED);
2716 else if (IS_FLG(FLG_UNAWARE))
2718 REM_FLG(FLG_UNIDENTIFIED);
2719 REM_FLG(FLG_UNAWARE);
2720 ADD_FLG(FLG_IDENTIFIED);
2721 REM_FLG(FLG_STAR_IDENTIFIED);
2723 else if (IS_FLG(FLG_STAR_IDENTIFIED))
2725 REM_FLG(FLG_UNIDENTIFIED);
2726 REM_FLG(FLG_UNAWARE);
2727 REM_FLG(FLG_IDENTIFIED);
2728 REM_FLG(FLG_STAR_IDENTIFIED);
2730 else if (IS_FLG(FLG_IDENTIFIED))
2732 REM_FLG(FLG_UNIDENTIFIED);
2733 REM_FLG(FLG_UNAWARE);
2734 REM_FLG(FLG_IDENTIFIED);
2735 ADD_FLG(FLG_STAR_IDENTIFIED);
2739 ADD_FLG(FLG_UNIDENTIFIED);
2740 REM_FLG(FLG_UNAWARE);
2741 REM_FLG(FLG_IDENTIFIED);
2742 REM_FLG(FLG_STAR_IDENTIFIED);
2745 lines_list[cy] = autopick_line_from_entry(entry);
2752 while (cy < upper + hgt-4 && lines_list[cy + 1])
2757 /* Toggle 'worthless' */
2758 toggle_string(lines_list, FLG_WORTHLESS, cy);
2763 /* Rotate within nameless, ego, artifact */
2764 if (!autopick_new_entry(entry, lines_list[cy]))
2766 string_free(lines_list[cy]);
2768 if (IS_FLG(FLG_NAMELESS))
2770 REM_FLG(FLG_NAMELESS);
2772 REM_FLG(FLG_ARTIFACT);
2774 else if (IS_FLG(FLG_EGO))
2776 REM_FLG(FLG_NAMELESS);
2778 ADD_FLG(FLG_ARTIFACT);
2780 else if (IS_FLG(FLG_ARTIFACT))
2782 REM_FLG(FLG_NAMELESS);
2784 REM_FLG(FLG_ARTIFACT);
2788 ADD_FLG(FLG_NAMELESS);
2790 REM_FLG(FLG_ARTIFACT);
2793 lines_list[cy] = autopick_line_from_entry(entry);
2800 /* Paste killed text */
2801 if (strlen(yank_buf))
2804 for (j = 0; yank_buf[j]; j += strlen(yank_buf + j) + 1)
2806 insert_return_code(lines_list, 0, cy);
2807 lines_list[cy] = string_make(yank_buf + j);
2812 dirty_flags |= DIRTY_ALL;
2816 /* Toggle 'collecting' */
2817 toggle_string(lines_list, FLG_COLLECTING, cy);
2823 /* Kill rest of line */
2824 if (lines_list[cy][0] != '\0' && (unsigned int) cx < strlen(lines_list[cy]))
2826 for (i = j = 0; lines_list[cy][i] && i < cx; i++)
2829 if (iskanji(lines_list[cy][i]))
2830 buf[j++] = lines_list[cy][i++];
2832 buf[j++] = lines_list[cy][i];
2837 if (old_key == KTRL('k'))
2839 j += strlen(yank_buf + j) + 1;
2841 if (j < MAX_YANK - 2)
2843 strncpy(yank_buf + j, lines_list[cy] + i, MAX_YANK-j-2);
2844 yank_buf[MAX_YANK-2] = '\0';
2845 yank_buf[j + strlen(lines_list[cy] + i) + 1] = '\0';
2847 string_free(lines_list[cy]);
2848 lines_list[cy] = string_make(buf);
2857 /* DELETE == go forward + BACK SPACE */
2859 if (iskanji(lines_list[cy][cx])) cx++;
2862 len = strlen(lines_list[cy]);
2865 if (lines_list[cy + 1])
2883 /* delete a return code and union two lines */
2885 cx = strlen(lines_list[cy-1]);
2886 strcpy(buf, lines_list[cy-1]);
2887 strcat(buf, lines_list[cy]);
2888 string_free(lines_list[cy-1]);
2889 string_free(lines_list[cy]);
2890 lines_list[cy-1] = string_make(buf);
2891 for (i = cy; lines_list[i+1]; i++)
2892 lines_list[i] = lines_list[i+1];
2893 lines_list[i] = NULL;
2897 dirty_flags |= DIRTY_ALL;
2901 for (i = j = 0; lines_list[cy][i] && i < cx; i++)
2905 if (iskanji(lines_list[cy][i]))
2906 buf[j++] = lines_list[cy][i++];
2908 buf[j++] = lines_list[cy][i];
2915 for (; lines_list[cy][i]; i++)
2916 buf[j++] = lines_list[cy][i];
2918 string_free(lines_list[cy]);
2919 lines_list[cy] = string_make(buf);
2928 /* Restore the screen */
2932 sprintf(buf, "picktype-%s.prf", player_name);
2934 sprintf(buf, "pickpref-%s.prf", player_name);
2936 write_text_lines(buf, lines_list);
2937 free_text_lines(lines_list);
2939 string_free(last_destroyed);
2941 /* Reload autopick pref */
2942 process_pickpref_file(buf);