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;
921 /* Protected by auto-picker */
922 if (autopick_idx >= 0 &&
923 !(autopick_list[autopick_idx].action & DO_AUTODESTROY))
928 /* Auto-picker/destroyer */
929 if (autopick_idx >= 0 &&
930 (autopick_list[autopick_idx].action & DO_AUTODESTROY))
934 /* Not to be destroyed */
935 if (!destroy) return FALSE;
937 /* Now decided to destroy */
941 /* Describe the object (with {terrible/special}) */
942 object_desc(o_name, o_ptr, TRUE, 3);
945 if (!can_player_destroy_object(o_ptr))
949 msg_format("%s¤ÏÇ˲õÉÔǽ¤À¡£", o_name);
951 msg_format("You cannot auto-destroy %s.", o_name);
958 /* Record name of destroyed item */
959 autopick_free_entry(&autopick_entry_last_destroyed);
960 autopick_entry_from_object(&autopick_entry_last_destroyed, o_ptr);
962 /* Eliminate the item (from the pack) */
965 inven_item_increase(item, -(o_ptr->number));
966 inven_item_optimize(item);
969 /* Eliminate the item (from the floor) */
972 delete_object_idx(0 - item);
975 /* Print a message */
977 msg_format("%s¤ò¼«Æ°Ç˲õ¤·¤Þ¤¹¡£", o_name);
979 msg_format("Auto-destroying %s.", o_name);
987 * Automatically pickup/destroy items in this grid.
989 void auto_pickup_items(cave_type *c_ptr)
991 s16b this_o_idx, next_o_idx = 0;
993 /* Scan the pile of objects */
994 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
999 object_type *o_ptr = &o_list[this_o_idx];
1001 /* Acquire next object */
1002 next_o_idx = o_ptr->next_o_idx;
1004 idx = is_autopick(o_ptr);
1006 /* Item index for floor -1,-2,-3,... */
1007 auto_inscribe_item((-this_o_idx), idx);
1009 if (idx >= 0 && (autopick_list[idx].action & DO_AUTOPICK))
1013 if (!inven_carry_okay(o_ptr))
1015 char o_name[MAX_NLEN];
1017 /* Describe the object */
1018 object_desc(o_name, o_ptr, TRUE, 3);
1022 msg_format("¥¶¥Ã¥¯¤Ë¤Ï%s¤òÆþ¤ì¤ë·ä´Ö¤¬¤Ê¤¤¡£", o_name);
1024 msg_format("You have no room for %s.", o_name);
1028 py_pickup_aux(this_o_idx);
1035 * When always_pickup is 'yes', we disable
1036 * auto-destroyer from autopick function, and do only
1037 * easy-auto-destroyer.
1041 if (auto_destroy_item((-this_o_idx), idx))
1049 * Describe which kind of object is Auto-picked/destroyed
1051 static void describe_autopick(char *buff, autopick_type *entry)
1053 cptr str = entry->name;
1054 byte act = entry->action;
1055 cptr insc = entry->insc;
1061 cptr before_str[100], body_str;
1064 body_str = "¥¢¥¤¥Æ¥à";
1066 /*** Collecting items ***/
1067 /*** Which can be absorbed into a slot as a bundle ***/
1068 if (IS_FLG(FLG_COLLECTING))
1069 before_str[before_n++] = "¼ý½¸Ãæ¤Ç´û¤Ë»ý¤Ã¤Æ¤¤¤ë¥¹¥í¥Ã¥È¤Ë¤Þ¤È¤á¤é¤ì¤ë";
1071 /*** Unidentified ***/
1072 if (IS_FLG(FLG_UNIDENTIFIED))
1073 before_str[before_n++] = "̤´ÕÄê¤Î";
1075 /*** Identified ***/
1076 if (IS_FLG(FLG_IDENTIFIED))
1077 before_str[before_n++] = "´ÕÄêºÑ¤ß¤Î";
1079 /*** *Identified* ***/
1080 if (IS_FLG(FLG_STAR_IDENTIFIED))
1081 before_str[before_n++] = "´°Á´¤Ë´ÕÄêºÑ¤ß¤Î";
1083 /*** Dice boosted (weapon of slaying) ***/
1084 if (IS_FLG(FLG_BOOSTED))
1086 before_str[before_n++] = "¥À¥á¡¼¥¸¥À¥¤¥¹¤¬Ä̾ï¤è¤êÂ礤¤";
1090 /*** Weapons whose dd*ds is more than nn ***/
1091 if (IS_FLG(FLG_MORE_THAN))
1093 static char more_than_desc_str[] = "___";
1094 before_str[before_n++] = "¥À¥á¡¼¥¸¥À¥¤¥¹¤ÎºÇÂçÃͤ¬";
1097 sprintf(more_than_desc_str,"%d", entry->dice);
1098 before_str[before_n++] = more_than_desc_str;
1099 before_str[before_n++] = "°Ê¾å¤Î";
1102 /*** Items whose magical bonus is more than nn ***/
1103 if (IS_FLG(FLG_MORE_BONUS))
1105 static char more_bonus_desc_str[] = "___";
1106 before_str[before_n++] = "½¤ÀµÃͤ¬(+";
1108 sprintf(more_bonus_desc_str,"%d", entry->bonus);
1109 before_str[before_n++] = more_bonus_desc_str;
1110 before_str[before_n++] = ")°Ê¾å¤Î";
1113 /*** Worthless items ***/
1114 if (IS_FLG(FLG_WORTHLESS))
1115 before_str[before_n++] = "Ź¤Ç̵²ÁÃͤÈȽÄꤵ¤ì¤ë";
1118 if (IS_FLG(FLG_ARTIFACT))
1120 before_str[before_n++] = "¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤Î";
1125 if (IS_FLG(FLG_EGO))
1127 before_str[before_n++] = "¥¨¥´¥¢¥¤¥Æ¥à¤Î";
1132 if (IS_FLG(FLG_NAMELESS))
1134 before_str[before_n++] = "¥¨¥´¤Ç¤â¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤Ç¤â¤Ê¤¤";
1138 /*** Unaware items ***/
1139 if (IS_FLG(FLG_UNAWARE))
1140 before_str[before_n++] = "̤´ÕÄê¤Ç¤½¤Î¸ú²Ì¤âȽÌÀ¤·¤Æ¤¤¤Ê¤¤";
1142 /*** Wanted monster's corpse/skeletons ***/
1143 if (IS_FLG(FLG_WANTED))
1145 before_str[before_n++] = "¥Ï¥ó¥¿¡¼»ö̳½ê¤Ç¾Þ¶â¼ó¤È¤µ¤ì¤Æ¤¤¤ë";
1146 body_str = "»àÂΤä¹ü";
1149 /*** Human corpse/skeletons (for Daemon magic) ***/
1150 if (IS_FLG(FLG_HUMAN))
1152 before_str[before_n++] = "°ËâËâË¡¤Ç»È¤¦¤¿¤á¤Î¿Í´Ö¤ä¥Ò¥å¡¼¥Þ¥Î¥¤¥É¤Î";
1153 body_str = "»àÂΤä¹ü";
1156 /*** Unique monster's corpse/skeletons/statues ***/
1157 if (IS_FLG(FLG_UNIQUE))
1159 before_str[before_n++] = "¥æ¥Ë¡¼¥¯¥â¥ó¥¹¥¿¡¼¤Î";
1160 body_str = "»àÂΤä¹ü";
1163 /*** Unreadable spellbooks ***/
1164 if (IS_FLG(FLG_UNREADABLE))
1166 before_str[before_n++] = "¤¢¤Ê¤¿¤¬Æɤá¤Ê¤¤Îΰè¤Î";
1167 body_str = "ËâË¡½ñ";
1170 /*** First realm spellbooks ***/
1171 if (IS_FLG(FLG_REALM1))
1173 before_str[before_n++] = "Âè°ìÎΰè¤Î";
1174 body_str = "ËâË¡½ñ";
1177 /*** Second realm spellbooks ***/
1178 if (IS_FLG(FLG_REALM2))
1180 before_str[before_n++] = "ÂèÆóÎΰè¤Î";
1181 body_str = "ËâË¡½ñ";
1184 /*** First rank spellbooks ***/
1185 if (IS_FLG(FLG_FIRST))
1187 before_str[before_n++] = "Á´4ºý¤ÎÆâ¤Î1ºýÌܤÎ";
1188 body_str = "ËâË¡½ñ";
1191 /*** Second rank spellbooks ***/
1192 if (IS_FLG(FLG_SECOND))
1194 before_str[before_n++] = "Á´4ºý¤ÎÆâ¤Î2ºýÌܤÎ";
1195 body_str = "ËâË¡½ñ";
1198 /*** Third rank spellbooks ***/
1199 if (IS_FLG(FLG_THIRD))
1201 before_str[before_n++] = "Á´4ºý¤ÎÆâ¤Î3ºýÌܤÎ";
1202 body_str = "ËâË¡½ñ";
1205 /*** Fourth rank spellbooks ***/
1206 if (IS_FLG(FLG_FOURTH))
1208 before_str[before_n++] = "Á´4ºý¤ÎÆâ¤Î4ºýÌܤÎ";
1209 body_str = "ËâË¡½ñ";
1213 if (IS_FLG(FLG_ITEMS))
1214 ; /* Nothing to do */
1215 else if (IS_FLG(FLG_WEAPONS))
1217 else if (IS_FLG(FLG_ARMORS))
1219 else if (IS_FLG(FLG_MISSILES))
1220 body_str = "ÃƤäÌð¤ä¥¯¥í¥¹¥Ü¥¦¤ÎÌð";
1221 else if (IS_FLG(FLG_DEVICES))
1222 body_str = "´¬Êª¤äËâË¡ËÀ¤ä¾ó¤ä¥í¥Ã¥É";
1223 else if (IS_FLG(FLG_LIGHTS))
1224 body_str = "¸÷¸»ÍѤΥ¢¥¤¥Æ¥à";
1225 else if (IS_FLG(FLG_JUNKS))
1226 body_str = "Àޤ줿ËÀÅù¤Î¥¬¥é¥¯¥¿";
1227 else if (IS_FLG(FLG_SPELLBOOKS))
1228 body_str = "ËâË¡½ñ";
1229 else if (IS_FLG(FLG_HAFTED))
1231 else if (IS_FLG(FLG_SHIELDS))
1233 else if (IS_FLG(FLG_BOWS))
1234 body_str = "¥¹¥ê¥ó¥°¤äµÝ¤ä¥¯¥í¥¹¥Ü¥¦";
1235 else if (IS_FLG(FLG_RINGS))
1237 else if (IS_FLG(FLG_AMULETS))
1238 body_str = "¥¢¥ß¥å¥ì¥Ã¥È";
1239 else if (IS_FLG(FLG_SUITS))
1241 else if (IS_FLG(FLG_CLOAKS))
1242 body_str = "¥¯¥í¡¼¥¯";
1243 else if (IS_FLG(FLG_HELMS))
1244 body_str = "¥Ø¥ë¥á¥Ã¥È¤ä´§";
1245 else if (IS_FLG(FLG_GLOVES))
1247 else if (IS_FLG(FLG_BOOTS))
1248 body_str = "¥Ö¡¼¥Ä";
1252 strcat(buff, "Á´¤Æ¤Î");
1253 else for (i = 0; i < before_n && before_str[i]; i++)
1254 strcat(buff, before_str[i]);
1256 strcat(buff, body_str);
1266 strcat(buff, "¤Ç¡¢Ì¾Á°¤¬¡Ö");
1267 strncat(buff, str, 80);
1269 strcat(buff, "¡×¤Ç»Ï¤Þ¤ë¤â¤Î");
1271 strcat(buff, "¡×¤ò´Þ¤à¤â¤Î");
1275 strncat(buff, format("¤Ë¡Ö%s¡×¤È¹ï¤ó¤Ç", insc), 80);
1279 if (act & DONT_AUTOPICK)
1280 strcat(buff, "ÊüÃÖ¤¹¤ë¡£");
1281 else if (act & DO_AUTODESTROY)
1282 strcat(buff, "Ç˲õ¤¹¤ë¡£");
1284 strcat(buff, "½¦¤¦¡£");
1286 if (act & DO_DISPLAY)
1288 if (act & DONT_AUTOPICK)
1289 strcat(buff, "Á´ÂΥޥå×('M')¤Ç'N'¤ò²¡¤·¤¿¤È¤¤Ëɽ¼¨¤¹¤ë¡£");
1290 else if (act & DO_AUTODESTROY)
1291 strcat(buff, "Á´ÂΥޥå×('M')¤Ç'K'¤ò²¡¤·¤¿¤È¤¤Ëɽ¼¨¤¹¤ë¡£");
1293 strcat(buff, "Á´ÂΥޥå×('M')¤Ç'M'¤ò²¡¤·¤¿¤È¤¤Ëɽ¼¨¤¹¤ë¡£");
1296 strcat(buff, "Á´ÂΥޥåפˤÏɽ¼¨¤·¤Ê¤¤");
1300 cptr before_str[20], after_str[20], which_str[20], whose_str[20], body_str;
1301 int before_n = 0, after_n = 0, which_n = 0, whose_n = 0;
1305 /*** Collecting items ***/
1306 /*** Which can be absorbed into a slot as a bundle ***/
1307 if (IS_FLG(FLG_COLLECTING))
1308 which_str[which_n++] = "can be absorbed into an existing inventory slot";
1310 /*** Unidentified ***/
1311 if (IS_FLG(FLG_UNIDENTIFIED))
1312 before_str[before_n++] = "unidentified";
1314 /*** Identified ***/
1315 if (IS_FLG(FLG_IDENTIFIED))
1316 before_str[before_n++] = "identified";
1318 /*** *Identified* ***/
1319 if (IS_FLG(FLG_STAR_IDENTIFIED))
1320 before_str[before_n++] = "fully identified";
1322 /*** Worthless items ***/
1323 if (IS_FLG(FLG_WORTHLESS))
1325 before_str[before_n++] = "worthless";
1326 which_str[which_n++] = "can not be sold at stores";
1330 if (IS_FLG(FLG_ARTIFACT))
1332 before_str[before_n++] = "artifact";
1336 if (IS_FLG(FLG_EGO))
1338 before_str[before_n++] = "ego";
1342 if (IS_FLG(FLG_NAMELESS))
1344 body_str = "equipment";
1345 which_str[which_n++] = "is neither ego-item nor artifact";
1348 /*** Unaware items ***/
1349 if (IS_FLG(FLG_UNAWARE))
1351 before_str[before_n++] = "unidentified";
1352 whose_str[whose_n++] = "basic abilities are not known";
1355 /*** Dice boosted (weapon of slaying) ***/
1356 if (IS_FLG(FLG_BOOSTED))
1358 body_str = "weapons";
1359 whose_str[whose_n++] = "damage dice is bigger than normal";
1362 /*** Weapons whose dd*ds is more than nn ***/
1363 if (IS_FLG(FLG_MORE_THAN))
1365 static char more_than_desc_str[] =
1366 "maximum damage from dice is bigger than __";
1367 body_str = "weapons";
1369 sprintf(more_than_desc_str + sizeof(more_than_desc_str) - 3,
1371 whose_str[whose_n++] = more_than_desc_str;
1374 /*** Items whose magical bonus is more than nn ***/
1375 if (IS_FLG(FLG_MORE_BONUS))
1377 static char more_bonus_desc_str[] =
1378 "magical bonus is bigger than (+__)";
1380 sprintf(more_bonus_desc_str + sizeof(more_bonus_desc_str) - 4,
1381 "%d)", entry->bonus);
1382 whose_str[whose_n++] = more_bonus_desc_str;
1385 /*** Wanted monster's corpse/skeletons ***/
1386 if (IS_FLG(FLG_WANTED))
1388 body_str = "corpse or skeletons";
1389 which_str[which_n++] = "is wanted at the Hunter's Office";
1392 /*** Human corpse/skeletons (for Daemon magic) ***/
1393 if (IS_FLG(FLG_HUMAN))
1395 before_str[before_n++] = "humanoid";
1396 body_str = "corpse or skeletons";
1397 which_str[which_n++] = "can be used for Daemon magic";
1400 /*** Unique monster's corpse/skeletons/statues ***/
1401 if (IS_FLG(FLG_UNIQUE))
1403 before_str[before_n++] = "unique monster's";
1404 body_str = "corpse or skeletons";
1407 /*** Unreadable spellbooks ***/
1408 if (IS_FLG(FLG_UNREADABLE))
1410 body_str = "spellbooks";
1411 after_str[after_n++] = "of different realms from yours";
1414 /*** First realm spellbooks ***/
1415 if (IS_FLG(FLG_REALM1))
1417 body_str = "spellbooks";
1418 after_str[after_n++] = "of your first realm";
1421 /*** Second realm spellbooks ***/
1422 if (IS_FLG(FLG_REALM2))
1424 body_str = "spellbooks";
1425 after_str[after_n++] = "of your second realm";
1428 /*** First rank spellbooks ***/
1429 if (IS_FLG(FLG_FIRST))
1431 before_str[before_n++] = "first one of four";
1432 body_str = "spellbooks";
1435 /*** Second rank spellbooks ***/
1436 if (IS_FLG(FLG_SECOND))
1438 before_str[before_n++] = "second one of four";
1439 body_str = "spellbooks";
1442 /*** Third rank spellbooks ***/
1443 if (IS_FLG(FLG_THIRD))
1445 before_str[before_n++] = "third one of four";
1446 body_str = "spellbooks";
1449 /*** Fourth rank spellbooks ***/
1450 if (IS_FLG(FLG_FOURTH))
1452 before_str[before_n++] = "fourth one of four";
1453 body_str = "spellbooks";
1457 if (IS_FLG(FLG_ITEMS))
1458 ; /* Nothing to do */
1459 else if (IS_FLG(FLG_WEAPONS))
1460 body_str = "weapons";
1461 else if (IS_FLG(FLG_ARMORS))
1462 body_str = "armors";
1463 else if (IS_FLG(FLG_MISSILES))
1464 body_str = "shots, arrows or crossbow bolts";
1465 else if (IS_FLG(FLG_DEVICES))
1466 body_str = "scrolls, wands, staves or rods";
1467 else if (IS_FLG(FLG_LIGHTS))
1468 body_str = "light sources";
1469 else if (IS_FLG(FLG_JUNKS))
1470 body_str = "junk such as broken sticks";
1471 else if (IS_FLG(FLG_SPELLBOOKS))
1472 body_str = "spellbooks";
1473 else if (IS_FLG(FLG_HAFTED))
1474 body_str = "hafted weapons";
1475 else if (IS_FLG(FLG_SHIELDS))
1476 body_str = "shields";
1477 else if (IS_FLG(FLG_BOWS))
1478 body_str = "slings, bows or crossbows";
1479 else if (IS_FLG(FLG_RINGS))
1481 else if (IS_FLG(FLG_AMULETS))
1482 body_str = "amulets";
1483 else if (IS_FLG(FLG_SUITS))
1484 body_str = "body armors";
1485 else if (IS_FLG(FLG_CLOAKS))
1486 body_str = "cloaks";
1487 else if (IS_FLG(FLG_HELMS))
1488 body_str = "helms or crowns";
1489 else if (IS_FLG(FLG_GLOVES))
1490 body_str = "gloves";
1491 else if (IS_FLG(FLG_BOOTS))
1494 /* Prepare a string for item name */
1501 whose_str[whose_n++] = "name is beginning with \"";
1504 which_str[which_n++] = "have \"";
1508 /* Describe action flag */
1509 if (act & DONT_AUTOPICK)
1510 strcpy(buff, "Leave on floor ");
1511 else if (act & DO_AUTODESTROY)
1512 strcpy(buff, "Destroy ");
1514 strcpy(buff, "Pickup ");
1516 /* Auto-insctiption */
1518 strncat(buff, format("and inscribe \"%s\" on ", insc), 80);
1522 strcat(buff, "all ");
1523 else for (i = 0; i < before_n && before_str[i]; i++)
1525 strcat(buff, before_str[i]);
1530 strcat(buff, body_str);
1533 for (i = 0; i < after_n && after_str[i]; i++)
1536 strcat(buff, after_str[i]);
1540 for (i = 0; i < whose_n && whose_str[i]; i++)
1543 strcat(buff, " whose ");
1545 strcat(buff, ", and ");
1547 strcat(buff, whose_str[i]);
1550 /* Item name ; whose name is beginning with "str" */
1557 /* whose ..., and which .... */
1558 if (whose_n && which_n)
1559 strcat(buff, ", and ");
1562 for (i = 0; i < which_n && which_str[i]; i++)
1565 strcat(buff, " which ");
1567 strcat(buff, ", and ");
1569 strcat(buff, which_str[i]);
1572 /* Item name ; which have "str" as part of its name */
1575 strncat(buff, str, 80);
1576 strcat(buff, "\" as part of its name");
1580 /* Describe whether it will be displayed on the full map or not */
1581 if (act & DO_DISPLAY)
1583 if (act & DONT_AUTOPICK)
1584 strcat(buff, " Display these items when you press 'N' in the full map('M').");
1585 else if (act & DO_AUTODESTROY)
1586 strcat(buff, " Display these items when you press 'K' in the full map('M').");
1588 strcat(buff, " Display these items when you press 'M' in the full map('M').");
1591 strcat(buff, " Not displayed in the full map.");
1597 #define MAX_LINES 3000
1600 * Read whole lines of a file to memory
1602 static cptr *read_text_lines(cptr filename, bool user)
1604 cptr *lines_list = NULL;
1612 /* Hack -- drop permissions */
1614 path_build(buf, 1024, ANGBAND_DIR_USER, filename);
1618 path_build(buf, 1024, ANGBAND_DIR_PREF, filename);
1622 fff = my_fopen(buf, "r");
1626 /* Allocate list of pointers */
1627 C_MAKE(lines_list, MAX_LINES, cptr);
1630 while (0 == my_fgets(fff, buf, 1024))
1632 lines_list[lines++] = string_make(buf);
1633 if (lines >= MAX_LINES - 1) break;
1636 lines_list[0] = string_make("");
1644 if (!fff) return NULL;
1648 static cptr *read_pickpref_text_lines(void)
1654 sprintf(buf, "picktype-%s.prf", player_name);
1656 sprintf(buf, "pickpref-%s.prf", player_name);
1658 lines_list = read_text_lines(buf, TRUE);
1663 lines_list = read_text_lines("picktype.prf", TRUE);
1665 lines_list = read_text_lines("pickpref.prf", TRUE);
1672 lines_list = read_text_lines("picktype.prf", FALSE);
1674 lines_list = read_text_lines("pickpref.prf", FALSE);
1680 /* Allocate list of pointers */
1681 C_MAKE(lines_list, MAX_LINES, cptr);
1682 lines_list[0] = string_make("");
1688 * Write whole lines of memory to a file.
1690 static bool write_text_lines(cptr filename, cptr *lines_list)
1697 /* Hack -- drop permissions */
1700 /* Build the filename */
1701 path_build(buf, 1024, ANGBAND_DIR_USER, filename);
1704 fff = my_fopen(buf, "w");
1707 for (lines = 0; lines_list[lines]; lines++)
1708 my_fputs(fff, lines_list[lines], 1024);
1716 if (!fff) return FALSE;
1722 * Free memory of lines_list.
1724 static void free_text_lines(cptr *lines_list)
1728 for (lines = 0; lines_list[lines]; lines++)
1729 string_free(lines_list[lines]);
1731 /* free list of pointers */
1732 C_FREE((char **)lines_list, MAX_LINES, char *);
1737 * Delete or insert string
1739 static void toggle_string(cptr *lines_list, int flg, int y)
1741 autopick_type an_entry, *entry = &an_entry;
1743 if (!autopick_new_entry(entry, lines_list[y]))
1746 string_free(lines_list[y]);
1752 lines_list[y] = autopick_line_from_entry(entry);
1756 * Insert return code and split the line
1758 static bool insert_return_code(cptr *lines_list, int cx, int cy)
1763 for (k = 0; lines_list[k]; k++)
1764 /* count number of lines */ ;
1766 if (k >= MAX_LINES - 2) return FALSE;
1769 /* Move down lines */
1771 lines_list[k+1] = lines_list[k];
1773 /* Split current line */
1774 for (i = j = 0; lines_list[cy][i] && i < cx; i++)
1777 if (iskanji(lines_list[cy][i]))
1778 buf[j++] = lines_list[cy][i++];
1780 buf[j++] = lines_list[cy][i];
1783 lines_list[cy+1] = string_make(&lines_list[cy][i]);
1784 string_free(lines_list[cy]);
1785 lines_list[cy] = string_make(buf);
1791 * Get auto-picker entry from o_ptr.
1793 void autopick_entry_from_object(autopick_type *entry, object_type *o_ptr)
1795 char o_name[MAX_NLEN];
1796 object_desc(o_name, o_ptr, FALSE, 0);
1798 entry->name = string_make(o_name);
1799 entry->insc = string_make(quark_str(o_ptr->inscription));
1800 entry->action = DO_AUTOPICK | DO_DISPLAY;
1801 entry->flag[0] = entry->flag[1] = 0L;
1804 if (!object_aware_p(o_ptr))
1805 ADD_FLG(FLG_UNAWARE);
1806 if (object_value(o_ptr) <= 0)
1807 ADD_FLG(FLG_WORTHLESS);
1809 if (object_known_p(o_ptr))
1813 else if (o_ptr->name1 || o_ptr->art_name)
1814 ADD_FLG(FLG_ARTIFACT);
1820 case TV_HAFTED: case TV_POLEARM: case TV_SWORD: case TV_DIGGING:
1821 k_ptr = &k_info[o_ptr->k_idx];
1822 if ((o_ptr->dd != k_ptr->dd) || (o_ptr->ds != k_ptr->ds))
1823 ADD_FLG(FLG_BOOSTED);
1826 if (o_ptr->tval == TV_CORPSE && object_is_shoukinkubi(o_ptr))
1828 REM_FLG(FLG_WORTHLESS);
1829 ADD_FLG(FLG_WANTED);
1832 if ((o_ptr->tval == TV_CORPSE || o_ptr->tval == TV_STATUE)
1833 && (r_info[o_ptr->pval].flags1 & RF1_UNIQUE))
1835 REM_FLG(FLG_WORTHLESS);
1836 ADD_FLG(FLG_UNIQUE);
1839 if (o_ptr->tval == TV_CORPSE && strchr("pht", r_info[o_ptr->pval].d_char))
1841 REM_FLG(FLG_WORTHLESS);
1845 if (o_ptr->tval >= TV_LIFE_BOOK &&
1846 !check_book_realm(o_ptr->tval, o_ptr->sval))
1847 ADD_FLG(FLG_UNREADABLE);
1849 if (REALM1_BOOK == o_ptr->tval &&
1850 p_ptr->pclass != CLASS_SORCERER &&
1851 p_ptr->pclass != CLASS_RED_MAGE)
1852 ADD_FLG(FLG_REALM1);
1854 if (REALM2_BOOK == o_ptr->tval &&
1855 p_ptr->pclass != CLASS_SORCERER &&
1856 p_ptr->pclass != CLASS_RED_MAGE)
1857 ADD_FLG(FLG_REALM2);
1859 if (o_ptr->tval >= TV_LIFE_BOOK && 0 == o_ptr->sval)
1861 if (o_ptr->tval >= TV_LIFE_BOOK && 1 == o_ptr->sval)
1862 ADD_FLG(FLG_SECOND);
1863 if (o_ptr->tval >= TV_LIFE_BOOK && 2 == o_ptr->sval)
1865 if (o_ptr->tval >= TV_LIFE_BOOK && 3 == o_ptr->sval)
1866 ADD_FLG(FLG_FOURTH);
1868 if (o_ptr->tval == TV_SHOT || o_ptr->tval == TV_BOLT
1869 || o_ptr->tval == TV_ARROW)
1870 ADD_FLG(FLG_MISSILES);
1871 else if (o_ptr->tval == TV_SCROLL || o_ptr->tval == TV_STAFF
1872 || o_ptr->tval == TV_WAND || o_ptr->tval == TV_ROD)
1873 ADD_FLG(FLG_DEVICES);
1874 else if (o_ptr->tval == TV_LITE)
1875 ADD_FLG(FLG_LIGHTS);
1876 else if (o_ptr->tval == TV_SKELETON || o_ptr->tval == TV_BOTTLE
1877 || o_ptr->tval == TV_JUNK || o_ptr->tval == TV_STATUE)
1879 else if (o_ptr->tval >= TV_LIFE_BOOK)
1880 ADD_FLG(FLG_SPELLBOOKS);
1881 else if (o_ptr->tval == TV_HAFTED)
1882 ADD_FLG(FLG_HAFTED);
1883 else if (o_ptr->tval == TV_POLEARM || o_ptr->tval == TV_SWORD
1884 || o_ptr->tval == TV_DIGGING)
1885 ADD_FLG(FLG_WEAPONS);
1886 else if (o_ptr->tval == TV_SHIELD)
1887 ADD_FLG(FLG_SHIELDS);
1888 else if (o_ptr->tval == TV_BOW)
1890 else if (o_ptr->tval == TV_RING)
1892 else if (o_ptr->tval == TV_AMULET)
1893 ADD_FLG(FLG_AMULETS);
1894 else if (o_ptr->tval == TV_DRAG_ARMOR || o_ptr->tval == TV_HARD_ARMOR ||
1895 o_ptr->tval == TV_SOFT_ARMOR)
1897 else if (o_ptr->tval == TV_CLOAK)
1898 ADD_FLG(FLG_CLOAKS);
1899 else if (o_ptr->tval == TV_HELM)
1901 else if (o_ptr->tval == TV_GLOVES)
1902 ADD_FLG(FLG_GLOVES);
1903 else if (o_ptr->tval == TV_BOOTS)
1910 * Choose an item and get auto-picker entry from it.
1912 static bool entry_from_choosed_object(autopick_type *entry)
1920 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÅÐÏ¿¤·¤Þ¤¹¤«? ";
1921 s = "¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£";
1923 q = "Entry which item? ";
1924 s = "You have nothing to entry.";
1926 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP))) return FALSE;
1928 /* Get the item (in the pack) */
1931 o_ptr = &inventory[item];
1934 /* Get the item (on the floor) */
1937 o_ptr = &o_list[0 - item];
1940 autopick_entry_from_object(entry, o_ptr);
1946 * Initialize auto-picker preference
1948 void init_autopicker(void)
1950 static const char easy_autopick_inscription[] = "(:=g";
1951 autopick_type entry;
1954 /* Clear old entries */
1955 for( i = 0; i < max_autopick; i++)
1956 autopick_free_entry(&autopick_list[i]);
1960 /* There is always one entry "=g" */
1961 autopick_new_entry(&entry, easy_autopick_inscription);
1962 autopick_list[max_autopick++] = entry;
1967 * Description of control commands
1972 static cptr ctrl_command_desc[] =
1975 #define LAST_DESTROYED 6
1976 "^P ^N ^B ^F ¾å²¼º¸±¦¤Ë°ÜÆ°",
1977 "^A ^E ¹Ô¤ÎÀèƬ¡¢½ªÃ¼",
1978 "^Q ÆþÎÏ/¥³¥Þ¥ó¥É¥â¡¼¥ÉÀÚ¤êÂؤ¨",
1979 "^R Êѹ¹¤òÁ´¤Æ¼è¤ê¾Ã¤·¤Æ¸µ¤ËÌ᤹",
1980 "------------------------------------",
1981 "^I »ý¤Áʪ/ÁõÈ÷¤«¤éÁªÂò",
1983 "^K ¥«¡¼¥½¥ë¤«¤é½ªÃ¼¤Þ¤Çºï½ü",
1984 "^Y ºï½ü(^K)¤·¤¿¹Ô¤òÁÞÆþ",
1985 "^C ¼ï²¡¢¿¦¶È¤Î¾ò·ï¼°¤òÁÞÆþ",
1986 "------------------------------------",
1987 "^S Êѹ¹ (!Ç˲õ/~ÊüÃÖ/½¦¤¦)",
1988 "^G \"(\" Á´ÂΥޥåפÇɽ¼¨¤·¤Ê¤¤",
1989 "^O \"#\" ¼«Æ°¹ï¤ß",
1990 "------------------------------------",
1991 "^U ̤´ÕÄê/̤ȽÌÀ/´ÕÄê/*´ÕÄê*",
1993 "^X ̵ÌÃ/¥¨¥´/¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È",
1997 #define LAST_DESTROYED 6
1998 "^P ^N ^B ^F Move Cursor",
1999 "^A ^E Beginning and End of Line",
2000 "^Q Toggle Insert/Command mode",
2001 "^R Revert to Original File",
2002 "------------------------------------",
2003 "^I Object in Inventry/Equipment",
2005 "^K Kill Rest of Line",
2006 "^Y Insert killed(^K) text",
2007 "^C Insert conditional expression",
2008 "------------------------------------",
2009 "^S Toggle(!Destroy/~Leave/Pick)",
2010 "^G \"(\" No display in the 'M'ap",
2011 "^O \"#\" Auto-Inscribe",
2012 "------------------------------------",
2013 "^U Toggle 'identified' state",
2015 "^X Toggle nameless/ego/artifact",
2016 "^Z \"collecting\"",
2022 #define MAX_YANK 1024
2023 #define MAX_LINELEN 1024
2024 #define DIRTY_ALL 0x01
2025 #define DIRTY_COMMAND 0x02
2026 #define DIRTY_MODE 0x04
2027 #define DIRTY_SCREEN 0x04
2030 * In-game editor of Object Auto-picker/Destoryer
2032 void do_cmd_edit_autopick(void)
2034 static int cx = 0, cy = 0;
2035 static int upper = 0, left = 0;
2037 cptr last_destroyed;
2038 char last_destroyed_command[WID_DESC+3];
2039 char yank_buf[MAX_YANK];
2041 autopick_type an_entry, *entry = &an_entry;
2042 char buf[MAX_LINELEN];
2048 int old_upper = -1, old_left = -1;
2050 int key = -1, old_key;
2052 bool edit_mode = FALSE;
2054 byte dirty_flags = DIRTY_ALL | DIRTY_COMMAND | DIRTY_MODE;
2055 int dirty_line = -1;
2057 int wid, hgt, old_wid = -1, old_hgt = -1;
2059 /* Free old entries */
2062 /* Name of the Last Destroyed Item */
2063 last_destroyed = autopick_line_from_entry(&autopick_entry_last_destroyed);
2065 /* Command Description of the Last Destroyed Item */
2068 strcpy(last_destroyed_command, "^L \"");
2069 strncpy(last_destroyed_command + 4, last_destroyed, WID_DESC-4);
2070 last_destroyed_command[WID_DESC+2] = '\0';
2075 strcpy(last_destroyed_command, "^L ºÇ¸å¤Ë¼«Æ°Ç˲õ¤·¤¿¥¢¥¤¥Æ¥à̾");
2077 strcpy(last_destroyed_command, "^L Last destroyed object");
2080 ctrl_command_desc[LAST_DESTROYED] = last_destroyed_command;
2082 /* Conditional Expression for Class and Race */
2083 sprintf(classrace, "?:[AND [EQU $RACE %s] [EQU $CLASS %s]]",
2085 rp_ptr->E_title, cp_ptr->E_title
2087 rp_ptr->title, cp_ptr->title
2091 /* Clear yank buffer */
2094 /* Read or initialize whole text */
2095 lines_list = read_pickpref_text_lines();
2097 /* Reset cursor position if needed */
2098 for (i = 0; i < cy; i++)
2107 /* Save the screen */
2110 /* Process requests until done */
2114 Term_get_size(&wid, &hgt);
2117 /* Don't let cursor at second byte of kanji */
2118 for (i = 0; lines_list[cy][i]; i++)
2119 if (iskanji(lines_list[cy][i]))
2130 /* Scroll if necessary */
2131 if (cy < upper || upper + hgt - 4 <= cy)
2132 upper = cy - (hgt-4)/2;
2135 if ((cx < left + 10 && left > 0) || left + wid - WID_DESC - 5 <= cx)
2136 left = cx - (wid - WID_DESC)*2/3;
2140 /* Redraw whole window after resize */
2141 if (old_wid != wid || old_hgt != hgt)
2142 dirty_flags |= DIRTY_SCREEN;
2144 /* Redraw all text after scroll */
2145 else if (old_upper != upper || old_left != left)
2146 dirty_flags |= DIRTY_ALL;
2149 if (dirty_flags & DIRTY_SCREEN)
2151 dirty_flags = DIRTY_ALL | DIRTY_COMMAND | DIRTY_MODE;
2157 if (dirty_flags & DIRTY_COMMAND)
2159 /* Display control command */
2160 for (i = 0; ctrl_command_desc[i]; i++)
2161 Term_putstr(wid - WID_DESC, i + 1, WID_DESC, TERM_WHITE, ctrl_command_desc[i]);
2164 /* Redraw mode line */
2165 if (dirty_flags & DIRTY_MODE)
2167 int sepa_length = wid - WID_DESC;
2170 for (i = 0; i < sepa_length; i++)
2176 strncpy(buf + sepa_length - 21, " (INSERT MODE) ", 16);
2178 strncpy(buf + sepa_length - 21, " (COMMAND MODE) ", 16);
2180 Term_putstr(0, hgt - 3, sepa_length, (byte) (edit_mode ? TERM_YELLOW : TERM_WHITE), buf);
2183 /* Dump up to 20, or hgt-4, lines of messages */
2184 for (i = 0; i < hgt - 4; i++)
2189 /* clean or dirty? */
2190 if (!(dirty_flags & DIRTY_ALL) && (dirty_line != upper+i))
2193 msg = lines_list[upper+i];
2196 /* Apply horizontal scroll */
2197 for (j = 0; *msg; msg++, j++)
2199 if (j == left) break;
2215 Term_erase(0, i + 1, wid - WID_DESC);
2217 /* Dump the messages, bottom to top */
2218 Term_putstr(leftcol, i + 1, wid - WID_DESC - 1, TERM_WHITE, msg);
2221 for (; i < hgt - 4; i++)
2224 Term_erase(0, i + 1, wid - WID_DESC);
2227 /* Display header line */
2230 prt("^Q ESC ¤Ç¥³¥Þ¥ó¥É¥â¡¼¥É¤Ø°Ü¹Ô¡¢Ä̾ï¤Îʸ»ú¤Ï¤½¤Î¤Þ¤ÞÆþÎÏ", 0, 0);
2232 prt("q _ ¤Ç½ªÎ»¡¢hjkl2468 ¤Ç°ÜÆ°¡¢^Q a i ¤ÇÆþÎϥ⡼¥É", 0, 0);
2235 prt("Press ^Q ESC to command mode, any letters to insert", 0, 0);
2237 prt("Press q _ to quit, hjkl2468 to move, ^Q a i to insert mode", 0, 0);
2239 /* Display current position */
2240 prt (format("(%d,%d)", cx, cy), 0, 70);
2242 /* Display information when updated */
2243 if (old_cy != cy || (dirty_flags & DIRTY_ALL) || dirty_line == cy)
2245 /* Clear information line */
2246 Term_erase(0, hgt - 3 + 1, wid);
2247 Term_erase(0, hgt - 3 + 2, wid);
2249 /* Display information */
2250 if (lines_list[cy][0] == '#')
2253 prt("¤³¤Î¹Ô¤Ï¥³¥á¥ó¥È¤Ç¤¹¡£", hgt - 3 + 1, 0);
2255 prt("This line is comment.", hgt - 3 + 1, 0);
2258 else if (lines_list[cy][1] == ':')
2260 switch(lines_list[cy][0])
2264 prt("¤³¤Î¹Ô¤Ï¾ò·ïʬ´ô¼°¤Ç¤¹¡£", hgt - 3 + 1, 0);
2266 prt("This line is Conditional Expression.", hgt - 3 + 1, 0);
2271 prt("¤³¤Î¹Ô¤Ï¥Þ¥¯¥í¤Î¼Â¹ÔÆâÍƤòÄêµÁ¤·¤Þ¤¹¡£", hgt - 3 + 1, 0);
2273 prt("This line defines Macro action.", hgt - 3 + 1, 0);
2278 prt("¤³¤Î¹Ô¤Ï¥Þ¥¯¥í¤Î¥È¥ê¥¬¡¼¡¦¥¡¼¤òÄêµÁ¤·¤Þ¤¹¡£", hgt - 3 + 1, 0);
2280 prt("This line defines Macro trigger key.", hgt - 3 + 1, 0);
2285 prt("¤³¤Î¹Ô¤Ï¥¡¼ÇÛÃÖ¤òÄêµÁ¤·¤Þ¤¹¡£", hgt - 3 + 1, 0);
2287 prt("This line defines Keymap.", hgt - 3 + 1, 0);
2293 /* Get description of an autopicker preference line */
2294 else if (autopick_new_entry(entry, lines_list[cy]))
2299 describe_autopick(buf, entry);
2301 roff_to_buf(buf, 81, temp);
2303 for (i = 0; i< 2; i++)
2309 prt(t, hgt - 3 + 1 + i, 0);
2313 autopick_free_entry(entry);
2318 Term_gotoxy(cx - left, cy - upper + 1);
2324 /* Save old key and location */
2332 /* Do not process macros except special keys */
2333 inkey_special = TRUE;
2344 /* Mode line is now dirty */
2345 dirty_flags |= DIRTY_MODE;
2348 /* Insert a character */
2349 else if (!iscntrl(key&0xff))
2353 /* Save preceding string */
2354 for (i = j = 0; lines_list[cy][i] && i < cx; i++)
2355 buf[j++] = lines_list[cy][i];
2357 /* Add a character */
2363 if (j+2 < MAX_LINELEN)
2375 if (j+1 < MAX_LINELEN)
2381 for (; lines_list[cy][i] && j + 1 < MAX_LINELEN; i++)
2382 buf[j++] = lines_list[cy][i];
2385 /* Replace current line with new line */
2386 string_free(lines_list[cy]);
2387 lines_list[cy] = string_make(buf);
2389 /* Move to correct collumn */
2390 len = strlen(lines_list[cy]);
2391 if (len < cx) cx = len;
2400 if (key == 'q' || key == '_') break;
2407 /* Mode line is now dirty */
2408 dirty_flags |= DIRTY_MODE;
2411 if (!autopick_new_entry(entry, lines_list[cy]))
2413 string_free(lines_list[cy]);
2415 entry->action &= ~DO_AUTODESTROY;
2416 if (entry->action & DO_AUTOPICK)
2418 entry->action &= ~DO_AUTOPICK;
2419 entry->action |= DONT_AUTOPICK;
2423 entry->action &= ~DONT_AUTOPICK;
2424 entry->action |= DO_AUTOPICK;
2427 lines_list[cy] = autopick_line_from_entry(entry);
2433 if (!autopick_new_entry(entry, lines_list[cy]))
2435 string_free(lines_list[cy]);
2437 entry->action &= ~DONT_AUTOPICK;
2438 if (entry->action & DO_AUTOPICK)
2440 entry->action &= ~DO_AUTOPICK;
2441 entry->action |= DO_AUTODESTROY;
2445 entry->action &= ~DO_AUTODESTROY;
2446 entry->action |= DO_AUTOPICK;
2449 lines_list[cy] = autopick_line_from_entry(entry);
2474 while (cy < upper + hgt-4 && lines_list[cy + 1])
2479 while (0 < cy && upper <= cy)
2481 while (0 < upper && cy + 1 < upper + hgt - 4)
2490 /* Beginning of line */
2498 len = strlen(lines_list[cy]);
2499 if (len < cx) cx = len;
2504 cx = strlen(lines_list[cy]);
2508 /* Insert a conditinal expression line */
2509 insert_return_code(lines_list, 0, cy);
2510 lines_list[cy] = string_make(classrace);
2512 insert_return_code(lines_list, 0, cy);
2513 lines_list[cy] = string_make("?:1");
2517 dirty_flags |= DIRTY_ALL;
2521 cx = strlen(lines_list[cy]);
2526 if (iskanji(lines_list[cy][cx])) cx++;
2529 len = strlen(lines_list[cy]);
2532 if (lines_list[cy + 1])
2542 /* Toggle display on the 'M'ap */
2543 if (!autopick_new_entry(entry, lines_list[cy]))
2545 string_free(lines_list[cy]);
2547 if (entry->action & DO_DISPLAY)
2549 entry->action &= ~DO_DISPLAY;
2554 entry->action |= DO_DISPLAY;
2558 lines_list[cy] = autopick_line_from_entry(entry);
2564 /* Insert choosen item name */
2565 if (!entry_from_choosed_object(entry))
2567 /* Now dirty because of item/equip menu */
2568 dirty_flags |= DIRTY_SCREEN;
2571 tmp = autopick_line_from_entry(entry);
2572 autopick_free_entry(entry);
2575 insert_return_code(lines_list, 0, cy);
2576 lines_list[cy] = tmp;
2579 /* Now dirty because of item/equip menu */
2580 dirty_flags |= DIRTY_SCREEN;
2584 /* Insert a name of last destroyed item */
2587 insert_return_code(lines_list, 0, cy);
2588 lines_list[cy] = string_make(last_destroyed);
2592 dirty_flags |= DIRTY_ALL;
2595 case '\n': case '\r':
2596 /* Split a line or insert end of line */
2597 insert_return_code(lines_list, cx, cy);
2602 dirty_flags |= DIRTY_ALL;
2606 if (lines_list[cy + 1]) cy++;
2609 /* Prepare to write auto-inscription text */
2610 if (!autopick_new_entry(entry, lines_list[cy]))
2612 string_free(lines_list[cy]);
2614 if (!entry->insc) entry->insc = string_make("");
2616 lines_list[cy] = autopick_line_from_entry(entry);
2618 /* Move to collumn for auto inscription */
2619 for (cx = 0; lines_list[cy][cx]; cx++)
2620 if (lines_list[cy][cx] == '#') break;
2626 dirty_flags |= DIRTY_MODE;
2634 edit_mode = !edit_mode;
2636 /* Mode line is now dirty */
2637 dirty_flags |= DIRTY_MODE;
2640 /* Revert to original */
2642 if (!get_check("Á´¤Æ¤ÎÊѹ¹¤òÇË´þ¤·¤Æ¸µ¤Î¾õÂÖ¤ËÌᤷ¤Þ¤¹¡£¤è¤í¤·¤¤¤Ç¤¹¤«¡© "))
2644 if (!get_check("Discard all change and revert to original file. Are you sure? "))
2648 free_text_lines(lines_list);
2649 lines_list = read_pickpref_text_lines();
2650 dirty_flags |= DIRTY_ALL | DIRTY_MODE;
2655 /* Rotate action; pickup/destroy/leave */
2656 if (!autopick_new_entry(entry, lines_list[cy]))
2658 string_free(lines_list[cy]);
2660 if (entry->action & DO_AUTOPICK)
2662 entry->action &= ~DO_AUTOPICK;
2663 entry->action |= DO_AUTODESTROY;
2665 else if (entry->action & DO_AUTODESTROY)
2667 entry->action &= ~DO_AUTODESTROY;
2668 entry->action |= DONT_AUTOPICK;
2670 else if (entry->action & DONT_AUTOPICK)
2672 entry->action &= ~DONT_AUTOPICK;
2673 entry->action |= DO_AUTOPICK;
2676 lines_list[cy] = autopick_line_from_entry(entry);
2685 /* Rotate identify-state; identified/unidentified/... */
2686 if (!autopick_new_entry(entry, lines_list[cy]))
2688 string_free(lines_list[cy]);
2690 if (IS_FLG(FLG_UNIDENTIFIED))
2692 REM_FLG(FLG_UNIDENTIFIED);
2693 ADD_FLG(FLG_UNAWARE);
2694 REM_FLG(FLG_IDENTIFIED);
2695 REM_FLG(FLG_STAR_IDENTIFIED);
2697 else if (IS_FLG(FLG_UNAWARE))
2699 REM_FLG(FLG_UNIDENTIFIED);
2700 REM_FLG(FLG_UNAWARE);
2701 ADD_FLG(FLG_IDENTIFIED);
2702 REM_FLG(FLG_STAR_IDENTIFIED);
2704 else if (IS_FLG(FLG_STAR_IDENTIFIED))
2706 REM_FLG(FLG_UNIDENTIFIED);
2707 REM_FLG(FLG_UNAWARE);
2708 REM_FLG(FLG_IDENTIFIED);
2709 REM_FLG(FLG_STAR_IDENTIFIED);
2711 else if (IS_FLG(FLG_IDENTIFIED))
2713 REM_FLG(FLG_UNIDENTIFIED);
2714 REM_FLG(FLG_UNAWARE);
2715 REM_FLG(FLG_IDENTIFIED);
2716 ADD_FLG(FLG_STAR_IDENTIFIED);
2720 ADD_FLG(FLG_UNIDENTIFIED);
2721 REM_FLG(FLG_UNAWARE);
2722 REM_FLG(FLG_IDENTIFIED);
2723 REM_FLG(FLG_STAR_IDENTIFIED);
2726 lines_list[cy] = autopick_line_from_entry(entry);
2733 while (cy < upper + hgt-4 && lines_list[cy + 1])
2738 /* Toggle 'worthless' */
2739 toggle_string(lines_list, FLG_WORTHLESS, cy);
2744 /* Rotate within nameless, ego, artifact */
2745 if (!autopick_new_entry(entry, lines_list[cy]))
2747 string_free(lines_list[cy]);
2749 if (IS_FLG(FLG_NAMELESS))
2751 REM_FLG(FLG_NAMELESS);
2753 REM_FLG(FLG_ARTIFACT);
2755 else if (IS_FLG(FLG_EGO))
2757 REM_FLG(FLG_NAMELESS);
2759 ADD_FLG(FLG_ARTIFACT);
2761 else if (IS_FLG(FLG_ARTIFACT))
2763 REM_FLG(FLG_NAMELESS);
2765 REM_FLG(FLG_ARTIFACT);
2769 ADD_FLG(FLG_NAMELESS);
2771 REM_FLG(FLG_ARTIFACT);
2774 lines_list[cy] = autopick_line_from_entry(entry);
2781 /* Paste killed text */
2782 if (strlen(yank_buf))
2784 for (j = 0; yank_buf[j]; j += strlen(yank_buf + j) + 1)
2788 /* Split current line */
2789 insert_return_code(lines_list, cx, cy);
2791 /* Paste yank buffer */
2792 for(i = 0; lines_list[cy][i]; i++)
2793 buf[i] = lines_list[cy][i];
2794 while (yank_buf[k] && i < MAX_LINELEN)
2795 buf[i++] = yank_buf[k++];
2798 string_free(lines_list[cy]);
2799 lines_list[cy] = string_make(buf);
2801 /* Move to the beggining of next line */
2807 dirty_flags |= DIRTY_ALL;
2811 /* Toggle 'collecting' */
2812 toggle_string(lines_list, FLG_COLLECTING, cy);
2818 /* Kill rest of line */
2819 if (lines_list[cy][0] != '\0' && (uint)cx < strlen(lines_list[cy]))
2821 /* Save preceding string */
2822 for (i = 0; lines_list[cy][i] && i < cx; i++)
2825 if (iskanji(lines_list[cy][i]))
2827 buf[i] = lines_list[cy][i];
2831 buf[i] = lines_list[cy][i];
2836 if (old_key == KTRL('k'))
2838 j += strlen(yank_buf + j) + 1;
2840 /* Copy following to yank buffer */
2841 while (lines_list[cy][i] && j < MAX_YANK - 2)
2842 yank_buf[j++] = lines_list[cy][i++];
2843 yank_buf[j++] = '\0';
2846 /* Replace current line with 'preceding string' */
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++;
2867 len = strlen(lines_list[cy]);
2870 if (lines_list[cy + 1])
2884 /* delete a return code and union two lines */
2886 cx = strlen(lines_list[cy-1]);
2887 strcpy(buf, lines_list[cy-1]);
2888 strcat(buf, lines_list[cy]);
2889 string_free(lines_list[cy-1]);
2890 string_free(lines_list[cy]);
2891 lines_list[cy-1] = string_make(buf);
2892 for (i = cy; lines_list[i+1]; i++)
2893 lines_list[i] = lines_list[i+1];
2894 lines_list[i] = NULL;
2898 dirty_flags |= DIRTY_ALL;
2902 for (i = j = 0; lines_list[cy][i] && i < cx; i++)
2906 if (iskanji(lines_list[cy][i]))
2907 buf[j++] = lines_list[cy][i++];
2909 buf[j++] = lines_list[cy][i];
2916 for (; lines_list[cy][i]; i++)
2917 buf[j++] = lines_list[cy][i];
2919 string_free(lines_list[cy]);
2920 lines_list[cy] = string_make(buf);
2929 /* Restore the screen */
2933 sprintf(buf, "picktype-%s.prf", player_name);
2935 sprintf(buf, "pickpref-%s.prf", player_name);
2937 write_text_lines(buf, lines_list);
2938 free_text_lines(lines_list);
2940 string_free(last_destroyed);
2942 /* Reload autopick pref */
2943 process_pickpref_file(buf);