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.
15 #define MAX_LINELEN 1024
17 static object_type autopick_last_destroyed_object;
23 #define FLG_COLLECTING 1
24 #define FLG_UNIDENTIFIED 2
25 #define FLG_IDENTIFIED 3
26 #define FLG_STAR_IDENTIFIED 4
28 #define FLG_MORE_THAN 6
30 #define FLG_MORE_BONUS 8
31 #define FLG_MORE_BONUS2 9
32 #define FLG_WORTHLESS 10
33 #define FLG_ARTIFACT 11
35 #define FLG_NAMELESS 13
36 #define FLG_UNAWARE 14
40 #define FLG_UNREADABLE 18
49 #define FLG_WEAPONS 31
51 #define FLG_MISSILES 33
52 #define FLG_DEVICES 34
55 #define FLG_SPELLBOOKS 37
57 #define FLG_SHIELDS 39
60 #define FLG_AMULETS 42
69 #define KEY_ALL "¤¹¤Ù¤Æ¤Î"
73 * MEGA HACK -- MPW¤Î¥Ð¥°½ü¤±¡£
74 * pre-processÃæ¤Ë¡Ö¼ý¡×¤Î»ú¤Î2¥Ð¥¤¥ÈÌܤ¬¾¡¼ê¤Ë¾Ã¤¨¤Æ¤·¤Þ¤¦¡£
76 #define KEY_COLLECTING "\x8e\xfb½¸Ãæ¤Î"
78 #define KEY_COLLECTING "¼ý½¸Ãæ¤Î"
81 #define KEY_UNIDENTIFIED "̤´ÕÄê¤Î"
82 #define KEY_IDENTIFIED "´ÕÄêºÑ¤ß¤Î"
83 #define KEY_STAR_IDENTIFIED "*´ÕÄê*ºÑ¤ß¤Î"
84 #define KEY_BOOSTED "¥À¥¤¥¹Ìܤΰ㤦"
85 #define KEY_MORE_THAN "¥À¥¤¥¹ÌÜ"
86 #define KEY_DICE "°Ê¾å¤Î"
87 #define KEY_MORE_BONUS "½¤ÀµÃÍ"
88 #define KEY_MORE_BONUS2 "°Ê¾å¤Î"
89 #define KEY_WORTHLESS "̵²ÁÃͤÎ"
90 #define KEY_ARTIFACT "¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È"
91 #define KEY_EGO "¥¨¥´"
92 #define KEY_NAMELESS "̵ÌäÎ"
93 #define KEY_UNAWARE "̤ȽÌÀ¤Î"
94 #define KEY_WANTED "¾Þ¶â¼ó¤Î"
95 #define KEY_UNIQUE "¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¤Î"
96 #define KEY_HUMAN "¿Í´Ö¤Î"
97 #define KEY_UNREADABLE "Æɤá¤Ê¤¤"
98 #define KEY_REALM1 "Âè°ìÎΰè¤Î"
99 #define KEY_REALM2 "ÂèÆóÎΰè¤Î"
100 #define KEY_FIRST "1ºýÌܤÎ"
101 #define KEY_SECOND "2ºýÌܤÎ"
102 #define KEY_THIRD "3ºýÌܤÎ"
103 #define KEY_FOURTH "4ºýÌܤÎ"
104 #define KEY_ITEMS "¥¢¥¤¥Æ¥à"
105 #define KEY_WEAPONS "Éð´ï"
106 #define KEY_ARMORS "Ëɶñ"
107 #define KEY_MISSILES "Ìð"
108 #define KEY_DEVICES "ËâË¡¥¢¥¤¥Æ¥à"
109 #define KEY_LIGHTS "¸÷¸»"
110 #define KEY_JUNKS "¤¬¤é¤¯¤¿"
111 #define KEY_SPELLBOOKS "ËâË¡½ñ"
112 #define KEY_HAFTED "Æß´ï"
113 #define KEY_SHIELDS "½â"
114 #define KEY_BOWS "µÝ"
115 #define KEY_RINGS "»ØÎØ"
116 #define KEY_AMULETS "¥¢¥ß¥å¥ì¥Ã¥È"
117 #define KEY_SUITS "³»"
118 #define KEY_CLOAKS "¥¯¥í¡¼¥¯"
119 #define KEY_HELMS "³õ"
120 #define KEY_GLOVES "äƼê"
121 #define KEY_BOOTS "·¤"
125 #define KEY_ALL "all"
126 #define KEY_COLLECTING "collecting"
127 #define KEY_UNIDENTIFIED "unidentified"
128 #define KEY_IDENTIFIED "identified"
129 #define KEY_STAR_IDENTIFIED "*identified*"
130 #define KEY_BOOSTED "dice boosted"
131 #define KEY_MORE_THAN "more than"
132 #define KEY_DICE " dice"
133 #define KEY_MORE_BONUS "more bonus than"
134 #define KEY_MORE_BONUS2 ""
135 #define KEY_WORTHLESS "worthless"
136 #define KEY_ARTIFACT "artifact"
137 #define KEY_EGO "ego"
138 #define KEY_NAMELESS "nameless"
139 #define KEY_UNAWARE "unaware"
140 #define KEY_WANTED "wanted"
141 #define KEY_UNIQUE "unique monster's"
142 #define KEY_HUMAN "human"
143 #define KEY_UNREADABLE "unreadable"
144 #define KEY_REALM1 "first realm's"
145 #define KEY_REALM2 "second realm's"
146 #define KEY_FIRST "first"
147 #define KEY_SECOND "second"
148 #define KEY_THIRD "third"
149 #define KEY_FOURTH "fourth"
150 #define KEY_ITEMS "items"
151 #define KEY_WEAPONS "weapons"
152 #define KEY_ARMORS "armors"
153 #define KEY_MISSILES "missiles"
154 #define KEY_DEVICES "magical devices"
155 #define KEY_LIGHTS "lights"
156 #define KEY_JUNKS "junks"
157 #define KEY_SPELLBOOKS "spellbooks"
158 #define KEY_HAFTED "hafted weapons"
159 #define KEY_SHIELDS "shields"
160 #define KEY_BOWS "bows"
161 #define KEY_RINGS "rings"
162 #define KEY_AMULETS "amulets"
163 #define KEY_SUITS "suits"
164 #define KEY_CLOAKS "cloaks"
165 #define KEY_HELMS "helms"
166 #define KEY_GLOVES "gloves"
167 #define KEY_BOOTS "boots"
171 #define MATCH_KEY(KEY) (!strncmp(ptr, KEY, sizeof(KEY)-1)\
172 ? (ptr += sizeof(KEY)-1, (' '==*ptr) ? ptr++ : 0, TRUE) : FALSE)
173 #define MATCH_KEY2(KEY) (!strncmp(ptr, KEY, sizeof(KEY)-1)\
174 ? (prev_ptr = ptr, ptr += sizeof(KEY)-1, (' '==*ptr) ? ptr++ : 0, TRUE) : FALSE)
177 #define ADD_KEY(KEY) strcat(ptr, KEY)
179 #define ADD_KEY(KEY) (strcat(ptr, KEY), strcat(ptr, " "))
181 #define ADD_KEY2(KEY) strcat(ptr, KEY)
183 #define ADD_FLG(FLG) (entry->flag[FLG / 32] |= (1L << (FLG % 32)))
184 #define REM_FLG(FLG) (entry->flag[FLG / 32] &= ~(1L << (FLG % 32)))
185 #define ADD_FLG_NOUN(FLG) (ADD_FLG(FLG), prev_flg = FLG)
186 #define IS_FLG(FLG) (entry->flag[FLG / 32] & (1L << (FLG % 32)))
189 static char kanji_colon[] = "¡§";
194 * Reconstruct preference line from entry
196 cptr autopick_line_from_entry(autopick_type *entry)
198 char buf[MAX_LINELEN];
200 bool sepa_flag = TRUE;
203 if (!(entry->action & DO_DISPLAY)) strcat(buf, "(");
204 if (entry->action & DO_QUERY_AUTOPICK) strcat(buf, ";");
205 if (entry->action & DO_AUTODESTROY) strcat(buf, "!");
206 if (entry->action & DONT_AUTOPICK) strcat(buf, "~");
210 if (IS_FLG(FLG_ALL)) ADD_KEY(KEY_ALL);
211 if (IS_FLG(FLG_COLLECTING)) ADD_KEY(KEY_COLLECTING);
212 if (IS_FLG(FLG_UNIDENTIFIED)) ADD_KEY(KEY_UNIDENTIFIED);
213 if (IS_FLG(FLG_IDENTIFIED)) ADD_KEY(KEY_IDENTIFIED);
214 if (IS_FLG(FLG_STAR_IDENTIFIED)) ADD_KEY(KEY_STAR_IDENTIFIED);
215 if (IS_FLG(FLG_UNAWARE)) ADD_KEY(KEY_UNAWARE);
216 if (IS_FLG(FLG_BOOSTED)) ADD_KEY(KEY_BOOSTED);
218 if (IS_FLG(FLG_MORE_THAN))
220 ADD_KEY(KEY_MORE_THAN);
221 strcat(ptr, format("%d", entry->dice));
225 if (IS_FLG(FLG_MORE_BONUS))
227 ADD_KEY(KEY_MORE_BONUS);
228 strcat(ptr, format("%d", entry->bonus));
229 ADD_KEY(KEY_MORE_BONUS2);
232 if (IS_FLG(FLG_UNREADABLE)) ADD_KEY(KEY_UNREADABLE);
233 if (IS_FLG(FLG_REALM1)) ADD_KEY(KEY_REALM1);
234 if (IS_FLG(FLG_REALM2)) ADD_KEY(KEY_REALM2);
235 if (IS_FLG(FLG_FIRST)) ADD_KEY(KEY_FIRST);
236 if (IS_FLG(FLG_SECOND)) ADD_KEY(KEY_SECOND);
237 if (IS_FLG(FLG_THIRD)) ADD_KEY(KEY_THIRD);
238 if (IS_FLG(FLG_FOURTH)) ADD_KEY(KEY_FOURTH);
239 if (IS_FLG(FLG_WANTED)) ADD_KEY(KEY_WANTED);
240 if (IS_FLG(FLG_UNIQUE)) ADD_KEY(KEY_UNIQUE);
241 if (IS_FLG(FLG_HUMAN)) ADD_KEY(KEY_HUMAN);
242 if (IS_FLG(FLG_WORTHLESS)) ADD_KEY(KEY_WORTHLESS);
243 if (IS_FLG(FLG_NAMELESS)) ADD_KEY(KEY_NAMELESS);
244 if (IS_FLG(FLG_EGO)) ADD_KEY(KEY_EGO);
246 if (IS_FLG(FLG_ARTIFACT)) ADD_KEY(KEY_ARTIFACT);
248 if (IS_FLG(FLG_ITEMS)) ADD_KEY2(KEY_ITEMS);
249 else if (IS_FLG(FLG_WEAPONS)) ADD_KEY2(KEY_WEAPONS);
250 else if (IS_FLG(FLG_ARMORS)) ADD_KEY2(KEY_ARMORS);
251 else if (IS_FLG(FLG_MISSILES)) ADD_KEY2(KEY_MISSILES);
252 else if (IS_FLG(FLG_DEVICES)) ADD_KEY2(KEY_DEVICES);
253 else if (IS_FLG(FLG_LIGHTS)) ADD_KEY2(KEY_LIGHTS);
254 else if (IS_FLG(FLG_JUNKS)) ADD_KEY2(KEY_JUNKS);
255 else if (IS_FLG(FLG_SPELLBOOKS)) ADD_KEY2(KEY_SPELLBOOKS);
256 else if (IS_FLG(FLG_HAFTED)) ADD_KEY2(KEY_HAFTED);
257 else if (IS_FLG(FLG_SHIELDS)) ADD_KEY2(KEY_SHIELDS);
258 else if (IS_FLG(FLG_BOWS)) ADD_KEY2(KEY_BOWS);
259 else if (IS_FLG(FLG_RINGS)) ADD_KEY2(KEY_RINGS);
260 else if (IS_FLG(FLG_AMULETS)) ADD_KEY2(KEY_AMULETS);
261 else if (IS_FLG(FLG_SUITS)) ADD_KEY2(KEY_SUITS);
262 else if (IS_FLG(FLG_CLOAKS)) ADD_KEY2(KEY_CLOAKS);
263 else if (IS_FLG(FLG_HELMS)) ADD_KEY2(KEY_HELMS);
264 else if (IS_FLG(FLG_GLOVES)) ADD_KEY2(KEY_GLOVES);
265 else if (IS_FLG(FLG_BOOTS)) ADD_KEY2(KEY_BOOTS);
267 /* You don't need sepalator after adjective */
268 /* 'artifact' is not true adjective */
269 else if (!IS_FLG(FLG_ARTIFACT))
272 if (entry->name && entry->name[0])
276 if (sepa_flag) strcat(buf, ":");
279 while (entry->name[j] && i < MAX_LINELEN - 2 - 1)
282 if (iskanji(entry->name[j]))
283 buf[i++] = entry->name[j++];
285 buf[i++] = entry->name[j++];
296 while (entry->insc[j] && i < MAX_LINELEN - 2)
299 if (iskanji(entry->insc[j]))
300 buf[i++] = entry->insc[j++];
302 buf[i++] = entry->insc[j++];
307 return string_make(buf);
312 * Reconstruct preference line from entry and kill entry
314 static cptr autopick_line_from_entry_kill(autopick_type *entry)
316 cptr ptr = autopick_line_from_entry(entry);
318 /* Free memory for original entry */
319 autopick_free_entry(entry);
326 * A function to create new entry
328 bool autopick_new_entry(autopick_type *entry, cptr str)
333 char buf[MAX_LINELEN];
334 cptr prev_ptr, ptr, old_ptr;
337 if (str[1] == ':') switch (str[0])
340 case 'A': case 'P': case 'C':
344 entry->flag[0] = entry->flag[1] = 0L;
347 act = DO_AUTOPICK | DO_DISPLAY;
350 if ((act & DO_AUTOPICK) && *str == '!')
353 act |= DO_AUTODESTROY;
356 else if ((act & DO_AUTOPICK) && *str == '~')
359 act |= DONT_AUTOPICK;
362 else if ((act & DO_AUTOPICK) && *str == ';')
365 act |= DO_QUERY_AUTOPICK;
368 else if ((act & DO_DISPLAY) && *str == '(')
377 /* don't mind upper or lower case */
379 for (i = 0; *str; i++)
390 /* Auto-inscription? */
398 if (isupper(c)) c = tolower(c);
404 /* Skip empty line */
405 if (*buf == 0) return FALSE;
407 ptr = prev_ptr = buf;
410 while (old_ptr != ptr)
412 /* Save current location */
415 if (MATCH_KEY(KEY_ALL)) ADD_FLG(FLG_ALL);
416 if (MATCH_KEY(KEY_COLLECTING)) ADD_FLG(FLG_COLLECTING);
417 if (MATCH_KEY(KEY_UNIDENTIFIED)) ADD_FLG(FLG_UNIDENTIFIED);
418 if (MATCH_KEY(KEY_IDENTIFIED)) ADD_FLG(FLG_IDENTIFIED);
419 if (MATCH_KEY(KEY_STAR_IDENTIFIED)) ADD_FLG(FLG_STAR_IDENTIFIED);
420 if (MATCH_KEY(KEY_BOOSTED)) ADD_FLG(FLG_BOOSTED);
422 /*** Weapons whose dd*ds is more than nn ***/
423 if (MATCH_KEY2(KEY_MORE_THAN))
428 /* Drop leading spaces */
429 while (' ' == *ptr) ptr++;
432 while ('0' <= *ptr && *ptr <= '9')
434 entry->dice = 10 * entry->dice + (*ptr - '0');
441 (void)MATCH_KEY(KEY_DICE);
442 ADD_FLG(FLG_MORE_THAN);
448 /*** Items whose magical bonus is more than n ***/
449 if (MATCH_KEY2(KEY_MORE_BONUS))
454 /* Drop leading spaces */
455 while (' ' == *ptr) ptr++;
458 while ('0' <= *ptr && *ptr <= '9')
460 entry->bonus = 10 * entry->bonus + (*ptr - '0');
467 (void)MATCH_KEY(KEY_MORE_BONUS2);
468 ADD_FLG(FLG_MORE_BONUS);
474 if (MATCH_KEY(KEY_WORTHLESS)) ADD_FLG(FLG_WORTHLESS);
475 if (MATCH_KEY(KEY_EGO)) ADD_FLG(FLG_EGO);
476 if (MATCH_KEY(KEY_NAMELESS)) ADD_FLG(FLG_NAMELESS);
477 if (MATCH_KEY(KEY_UNAWARE)) ADD_FLG(FLG_UNAWARE);
478 if (MATCH_KEY(KEY_WANTED)) ADD_FLG(FLG_WANTED);
479 if (MATCH_KEY(KEY_UNIQUE)) ADD_FLG(FLG_UNIQUE);
480 if (MATCH_KEY(KEY_HUMAN)) ADD_FLG(FLG_HUMAN);
481 if (MATCH_KEY(KEY_UNREADABLE)) ADD_FLG(FLG_UNREADABLE);
482 if (MATCH_KEY(KEY_REALM1)) ADD_FLG(FLG_REALM1);
483 if (MATCH_KEY(KEY_REALM2)) ADD_FLG(FLG_REALM2);
484 if (MATCH_KEY(KEY_FIRST)) ADD_FLG(FLG_FIRST);
485 if (MATCH_KEY(KEY_SECOND)) ADD_FLG(FLG_SECOND);
486 if (MATCH_KEY(KEY_THIRD)) ADD_FLG(FLG_THIRD);
487 if (MATCH_KEY(KEY_FOURTH)) ADD_FLG(FLG_FOURTH);
490 /* Not yet found any noun */
493 if (MATCH_KEY2(KEY_ARTIFACT)) ADD_FLG_NOUN(FLG_ARTIFACT);
495 if (MATCH_KEY2(KEY_ITEMS)) ADD_FLG_NOUN(FLG_ITEMS);
496 else if (MATCH_KEY2(KEY_WEAPONS)) ADD_FLG_NOUN(FLG_WEAPONS);
497 else if (MATCH_KEY2(KEY_ARMORS)) ADD_FLG_NOUN(FLG_ARMORS);
498 else if (MATCH_KEY2(KEY_MISSILES)) ADD_FLG_NOUN(FLG_MISSILES);
499 else if (MATCH_KEY2(KEY_DEVICES)) ADD_FLG_NOUN(FLG_DEVICES);
500 else if (MATCH_KEY2(KEY_LIGHTS)) ADD_FLG_NOUN(FLG_LIGHTS);
501 else if (MATCH_KEY2(KEY_JUNKS)) ADD_FLG_NOUN(FLG_JUNKS);
502 else if (MATCH_KEY2(KEY_SPELLBOOKS)) ADD_FLG_NOUN(FLG_SPELLBOOKS);
503 else if (MATCH_KEY2(KEY_HAFTED)) ADD_FLG_NOUN(FLG_HAFTED);
504 else if (MATCH_KEY2(KEY_SHIELDS)) ADD_FLG_NOUN(FLG_SHIELDS);
505 else if (MATCH_KEY2(KEY_BOWS)) ADD_FLG_NOUN(FLG_BOWS);
506 else if (MATCH_KEY2(KEY_RINGS)) ADD_FLG_NOUN(FLG_RINGS);
507 else if (MATCH_KEY2(KEY_AMULETS)) ADD_FLG_NOUN(FLG_AMULETS);
508 else if (MATCH_KEY2(KEY_SUITS)) ADD_FLG_NOUN(FLG_SUITS);
509 else if (MATCH_KEY2(KEY_CLOAKS)) ADD_FLG_NOUN(FLG_CLOAKS);
510 else if (MATCH_KEY2(KEY_HELMS)) ADD_FLG_NOUN(FLG_HELMS);
511 else if (MATCH_KEY2(KEY_GLOVES)) ADD_FLG_NOUN(FLG_GLOVES);
512 else if (MATCH_KEY2(KEY_BOOTS)) ADD_FLG_NOUN(FLG_BOOTS);
514 /* Last 'keyword' must be at the correct location */
518 else if (ptr[0] == kanji_colon[0] && ptr[1] == kanji_colon[1])
521 else if (*ptr == '\0')
522 ; /* nothing to do */
528 /* A noun type keyword didn't end correctly */
529 entry->flag[prev_flg/32] &= ~(1L<< (prev_flg%32));
534 /* Save this auto-picker entry line */
535 entry->name = string_make(ptr);
537 entry->insc = string_make(insc);
543 * A function to delete entry
545 void autopick_free_entry(autopick_type *entry)
547 string_free(entry->name);
548 string_free(entry->insc);
553 * A function for Auto-picker/destroyer
554 * Examine whether the object matches to the entry
556 static bool is_autopick_aux(object_type *o_ptr, autopick_type *entry, cptr o_name)
559 cptr ptr = entry->name;
561 /*** Unidentified ***/
562 if (IS_FLG(FLG_UNIDENTIFIED)
563 && (object_known_p(o_ptr) || (o_ptr->ident & IDENT_SENSE)))
567 if (IS_FLG(FLG_IDENTIFIED) && !object_known_p(o_ptr))
570 /*** *Identified* ***/
571 if (IS_FLG(FLG_STAR_IDENTIFIED) &&
572 (!object_known_p(o_ptr) || !(o_ptr->ident & IDENT_MENTAL)))
575 /*** Dice boosted (weapon of slaying) ***/
576 if (IS_FLG(FLG_BOOSTED))
578 object_kind *k_ptr = &k_info[o_ptr->k_idx];
580 switch( o_ptr->tval )
586 if ((o_ptr->dd != k_ptr->dd) || (o_ptr->ds != k_ptr->ds))
595 /*** Weapons which dd*ds is more than nn ***/
596 if (IS_FLG(FLG_MORE_THAN))
598 if (o_ptr->dd * o_ptr->ds < entry->dice)
602 /*** Weapons whic dd*ds is more than nn ***/
603 if (IS_FLG(FLG_MORE_BONUS))
605 if (!object_known_p(o_ptr)) return FALSE;
609 if (o_ptr->pval < entry->bonus) return FALSE;
613 if (o_ptr->to_h < entry->bonus &&
614 o_ptr->to_d < entry->bonus &&
615 o_ptr->to_a < entry->bonus &&
616 o_ptr->pval < entry->bonus)
621 /*** Worthless items ***/
622 if (IS_FLG(FLG_WORTHLESS) && object_value(o_ptr) > 0)
625 /*** Artifact object ***/
626 if (IS_FLG(FLG_ARTIFACT))
628 if (!object_known_p(o_ptr) || (!o_ptr->name1 && !o_ptr->art_name))
635 if (!object_known_p(o_ptr) || !o_ptr->name2)
640 if (IS_FLG(FLG_NAMELESS))
645 case TV_SHOT: case TV_ARROW: case TV_BOLT: case TV_BOW:
646 case TV_DIGGING: case TV_HAFTED: case TV_POLEARM: case TV_SWORD:
647 case TV_BOOTS: case TV_GLOVES: case TV_HELM: case TV_CROWN:
648 case TV_SHIELD: case TV_CLOAK:
649 case TV_SOFT_ARMOR: case TV_HARD_ARMOR: case TV_DRAG_ARMOR:
650 case TV_LITE: case TV_AMULET: case TV_RING: case TV_CARD:
651 if ((!object_known_p(o_ptr) || o_ptr->inscription
652 || o_ptr->name1 || o_ptr->name2 || o_ptr->art_name))
661 /*** Unaware items ***/
662 if (IS_FLG(FLG_UNAWARE) && object_aware_p(o_ptr))
665 /*** Wanted monster's corpse/skeletons ***/
666 if (IS_FLG(FLG_WANTED) &&
667 (o_ptr->tval != TV_CORPSE || !object_is_shoukinkubi(o_ptr)))
670 /*** Unique monster's corpse/skeletons/statues ***/
671 if (IS_FLG(FLG_UNIQUE) &&
672 ((o_ptr->tval != TV_CORPSE && o_ptr->tval != TV_STATUE) ||
673 !(r_info[o_ptr->pval].flags1 & RF1_UNIQUE)))
676 /*** Human corpse/skeletons (for Daemon magic) ***/
677 if (IS_FLG(FLG_HUMAN) &&
678 (o_ptr->tval != TV_CORPSE ||
679 !strchr("pht", r_info[o_ptr->pval].d_char)))
682 /*** Unreadable spellbooks ***/
683 if (IS_FLG(FLG_UNREADABLE) &&
684 (o_ptr->tval < TV_LIFE_BOOK ||
685 check_book_realm(o_ptr->tval, o_ptr->sval)))
688 /*** First realm spellbooks ***/
689 if (IS_FLG(FLG_REALM1) &&
690 (REALM1_BOOK != o_ptr->tval ||
691 p_ptr->pclass == CLASS_SORCERER ||
692 p_ptr->pclass == CLASS_RED_MAGE))
695 /*** Second realm spellbooks ***/
696 if (IS_FLG(FLG_REALM2) &&
697 (REALM2_BOOK != o_ptr->tval ||
698 p_ptr->pclass == CLASS_SORCERER ||
699 p_ptr->pclass == CLASS_RED_MAGE))
702 /*** First rank spellbooks ***/
703 if (IS_FLG(FLG_FIRST) &&
704 (o_ptr->tval < TV_LIFE_BOOK || 0 != o_ptr->sval))
707 /*** Second rank spellbooks ***/
708 if (IS_FLG(FLG_SECOND) &&
709 (o_ptr->tval < TV_LIFE_BOOK || 1 != o_ptr->sval))
712 /*** Third rank spellbooks ***/
713 if (IS_FLG(FLG_THIRD) &&
714 (o_ptr->tval < TV_LIFE_BOOK || 2 != o_ptr->sval))
717 /*** Fourth rank spellbooks ***/
718 if (IS_FLG(FLG_FOURTH) &&
719 (o_ptr->tval < TV_LIFE_BOOK || 3 != o_ptr->sval))
723 if (IS_FLG(FLG_WEAPONS))
727 case TV_BOW: case TV_HAFTED: case TV_POLEARM:
728 case TV_SWORD: case TV_DIGGING:
730 default: return FALSE;
733 else if (IS_FLG(FLG_ARMORS))
737 case TV_BOOTS: case TV_GLOVES: case TV_CLOAK: case TV_CROWN:
738 case TV_HELM: case TV_SHIELD: case TV_SOFT_ARMOR:
739 case TV_HARD_ARMOR: case TV_DRAG_ARMOR:
741 default: return FALSE;
744 else if (IS_FLG(FLG_MISSILES))
748 case TV_SHOT: case TV_BOLT: case TV_ARROW:
750 default: return FALSE;
753 else if (IS_FLG(FLG_DEVICES))
757 case TV_SCROLL: case TV_STAFF: case TV_WAND: case TV_ROD:
759 default: return FALSE;
762 else if (IS_FLG(FLG_LIGHTS))
764 if (!(o_ptr->tval == TV_LITE))
767 else if (IS_FLG(FLG_JUNKS))
771 case TV_SKELETON: case TV_BOTTLE:
772 case TV_JUNK: case TV_STATUE:
774 default: return FALSE;
777 else if (IS_FLG(FLG_SPELLBOOKS))
779 if (!(o_ptr->tval >= TV_LIFE_BOOK))
782 else if (IS_FLG(FLG_HAFTED))
784 if (!(o_ptr->tval == TV_HAFTED))
787 else if (IS_FLG(FLG_SHIELDS))
789 if (!(o_ptr->tval == TV_SHIELD))
792 else if (IS_FLG(FLG_BOWS))
794 if (!(o_ptr->tval == TV_BOW))
797 else if (IS_FLG(FLG_RINGS))
799 if (!(o_ptr->tval == TV_RING))
802 else if (IS_FLG(FLG_AMULETS))
804 if (!(o_ptr->tval == TV_AMULET))
807 else if (IS_FLG(FLG_SUITS))
809 if (!(o_ptr->tval == TV_DRAG_ARMOR ||
810 o_ptr->tval == TV_HARD_ARMOR ||
811 o_ptr->tval == TV_SOFT_ARMOR))
814 else if (IS_FLG(FLG_CLOAKS))
816 if (!(o_ptr->tval == TV_CLOAK))
819 else if (IS_FLG(FLG_HELMS))
821 if (!(o_ptr->tval == TV_CROWN || o_ptr->tval == TV_HELM))
824 else if (IS_FLG(FLG_GLOVES))
826 if (!(o_ptr->tval == TV_GLOVES))
829 else if (IS_FLG(FLG_BOOTS))
831 if (!(o_ptr->tval == TV_BOOTS))
835 /* Keyword don't match */
839 if (strncmp(o_name, ptr, strlen(ptr))) return FALSE;
844 if (!strstr_j(o_name, ptr)) return FALSE;
846 if (!strstr(o_name, ptr)) return FALSE;
850 /* TRUE when it need not to be 'collecting' */
851 if (!IS_FLG(FLG_COLLECTING)) return TRUE;
853 /* Check if there is a same item */
854 for (j = 0; j < INVEN_PACK; j++)
857 * 'Collecting' means the item must be absorbed
858 * into an inventory slot.
859 * But an item can not be absorbed into itself!
861 if ((&inventory[j] != o_ptr) &&
862 object_similar(&inventory[j], o_ptr))
872 * A function for Auto-picker/destroyer
873 * Examine whether the object matches to the list of keywords or not.
875 int is_autopick(object_type *o_ptr)
878 char o_name[MAX_NLEN];
880 if (o_ptr->tval == TV_GOLD) return -1;
882 object_desc(o_name, o_ptr, FALSE, 3);
884 /* Force to be lower case string */
885 for (i = 0; o_name[i]; i++)
888 if (iskanji(o_name[i]))
892 if (isupper(o_name[i]))
893 o_name[i] = tolower(o_name[i]);
896 for (i=0; i < max_autopick; i++)
898 autopick_type *entry = &autopick_list[i];
900 if (is_autopick_aux(o_ptr, entry, o_name)) return i;
903 /* No matching entry */
909 * Automatically destroy items in this grid.
911 static bool is_opt_confirm_destroy(object_type *o_ptr)
913 if (!destroy_items) return FALSE;
915 /* Known to be worthless? */
917 if (object_value(o_ptr) > 0) return FALSE;
920 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_DRAG_ARMOR)) return FALSE;
923 if ((o_ptr->tval == TV_CHEST) && o_ptr->pval) return FALSE;
927 if (o_ptr->tval == TV_CORPSE
928 && object_is_shoukinkubi(o_ptr)) return FALSE;
932 if (o_ptr->tval == TV_CORPSE) return FALSE;
935 if ((o_ptr->tval == TV_SKELETON) || (o_ptr->tval == TV_BOTTLE) || (o_ptr->tval == TV_JUNK) || (o_ptr->tval == TV_STATUE)) return FALSE;
940 if (p_ptr->prace == RACE_SKELETON)
942 if (o_ptr->tval == TV_SKELETON ||
943 (o_ptr->tval == TV_CORPSE && o_ptr->sval == SV_SKELETON))
948 if (p_ptr->prace == RACE_DEMON)
950 if (o_ptr->tval == TV_CORPSE &&
951 o_ptr->sval == SV_CORPSE &&
952 strchr("pht", r_info[o_ptr->pval].d_char))
956 if (p_ptr->pclass == CLASS_ARCHER)
958 if (o_ptr->tval == TV_SKELETON ||
959 (o_ptr->tval == TV_CORPSE && o_ptr->sval == SV_SKELETON))
962 else if (p_ptr->pclass == CLASS_NINJA)
964 if (o_ptr->tval == TV_LITE &&
965 o_ptr->name2 == EGO_LITE_DARKNESS)
970 if (o_ptr->tval == TV_GOLD) return FALSE;
979 void auto_inscribe_item(int item, int idx)
983 /* Get the item (in the pack) */
984 if (item >= 0) o_ptr = &inventory[item];
986 /* Get the item (on the floor) */
987 else o_ptr = &o_list[0 - item];
989 /* Auto-inscription or Re-inscribe for resistances {%} */
990 if ((idx < 0 || !autopick_list[idx].insc) && !o_ptr->inscription)
993 if (!o_ptr->inscription)
994 o_ptr->inscription = quark_add(autopick_list[idx].insc);
996 if (item > INVEN_PACK)
998 /* Redraw inscription */
999 p_ptr->window |= (PW_EQUIP);
1001 /* {.} and {$} effect p_ptr->warning and TRC_TELEPORT_SELF */
1002 p_ptr->update |= (PU_BONUS);
1006 /* Redraw inscription */
1007 p_ptr->window |= (PW_INVEN);
1013 * Automatically destroy an item if it is to be destroyed
1015 bool auto_destroy_item(int item, int autopick_idx)
1017 bool destroy = FALSE;
1020 /* Don't destroy equipped items */
1021 if (item > INVEN_PACK) return FALSE;
1023 /* Get the item (in the pack) */
1024 if (item >= 0) o_ptr = &inventory[item];
1026 /* Get the item (on the floor) */
1027 else o_ptr = &o_list[0 - item];
1029 /* Easy-Auto-Destroyer */
1030 if (is_opt_confirm_destroy(o_ptr)) destroy = TRUE;
1032 /* Protected by auto-picker */
1033 if (autopick_idx >= 0 &&
1034 !(autopick_list[autopick_idx].action & DO_AUTODESTROY))
1039 /* Auto-picker/destroyer */
1040 if (autopick_idx >= 0 &&
1041 (autopick_list[autopick_idx].action & DO_AUTODESTROY))
1045 /* Not to be destroyed */
1046 if (!destroy) return FALSE;
1048 /* Now decided to destroy */
1053 if (!can_player_destroy_object(o_ptr))
1055 char o_name[MAX_NLEN];
1057 /* Describe the object (with {terrible/special}) */
1058 object_desc(o_name, o_ptr, TRUE, 3);
1062 msg_format("%s¤ÏÇ˲õÉÔǽ¤À¡£", o_name);
1064 msg_format("You cannot auto-destroy %s.", o_name);
1071 /* Record name of destroyed item */
1072 COPY(&autopick_last_destroyed_object, o_ptr, object_type);
1075 o_ptr->marked |= OM_AUTODESTROY;
1076 p_ptr->notice |= PN_AUTODESTROY;
1083 * Auto-destroy marked item
1085 static void delayed_auto_destroy_aux(int item)
1089 /* Get the item (in the pack) */
1090 if (item >= 0) o_ptr = &inventory[item];
1092 /* Get the item (on the floor) */
1093 else o_ptr = &o_list[0 - item];
1095 if (o_ptr->k_idx && o_ptr->marked & OM_AUTODESTROY)
1097 char o_name[MAX_NLEN];
1099 /* Describe the object (with {terrible/special}) */
1100 object_desc(o_name, o_ptr, TRUE, 3);
1102 /* Eliminate the item (from the pack) */
1105 inven_item_increase(item, -(o_ptr->number));
1106 inven_item_optimize(item);
1109 /* Eliminate the item (from the floor) */
1112 delete_object_idx(0 - item);
1115 /* Print a message */
1117 msg_format("%s¤ò¼«Æ°Ç˲õ¤·¤Þ¤¹¡£", o_name);
1119 msg_format("Auto-destroying %s.", o_name);
1126 * Auto-destroy marked item in inventry and on floor
1128 void delayed_auto_destroy(void)
1133 * Scan inventry in reverse order to prevent
1134 * skipping after inven_item_optimize()
1136 for (item = INVEN_TOTAL - 1; item >= 0 ; item--)
1137 delayed_auto_destroy_aux(item);
1139 /* Scan the pile of objects */
1140 item = cave[py][px].o_idx;
1143 int next = o_list[item].next_o_idx;
1144 delayed_auto_destroy_aux(-item);
1151 * Automatically pickup/destroy items in this grid.
1153 void auto_pickup_items(cave_type *c_ptr)
1155 s16b this_o_idx, next_o_idx = 0;
1157 /* Scan the pile of objects */
1158 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
1162 /* Acquire object */
1163 object_type *o_ptr = &o_list[this_o_idx];
1165 /* Acquire next object */
1166 next_o_idx = o_ptr->next_o_idx;
1168 idx = is_autopick(o_ptr);
1170 /* Item index for floor -1,-2,-3,... */
1171 auto_inscribe_item((-this_o_idx), idx);
1174 (autopick_list[idx].action & (DO_AUTOPICK | DO_QUERY_AUTOPICK)))
1178 if (!inven_carry_okay(o_ptr))
1180 char o_name[MAX_NLEN];
1182 /* Describe the object */
1183 object_desc(o_name, o_ptr, TRUE, 3);
1187 msg_format("¥¶¥Ã¥¯¤Ë¤Ï%s¤òÆþ¤ì¤ë·ä´Ö¤¬¤Ê¤¤¡£", o_name);
1189 msg_format("You have no room for %s.", o_name);
1191 /* Hack - remember that the item has given a message here. */
1192 o_ptr->marked |= OM_NOMSG;
1196 else if (autopick_list[idx].action & DO_QUERY_AUTOPICK)
1198 char out_val[MAX_NLEN+20];
1199 char o_name[MAX_NLEN];
1201 if (o_ptr->marked & OM_NO_QUERY)
1203 /* Already answered as 'No' */
1207 /* Describe the object */
1208 object_desc(o_name, o_ptr, TRUE, 3);
1211 sprintf(out_val, "%s¤ò½¦¤¤¤Þ¤¹¤«? ", o_name);
1213 sprintf(out_val, "Pick up %s? ", o_name);
1216 if (!get_check(out_val))
1218 /* Hack - remember that the item has given a message here. */
1219 o_ptr->marked |= (OM_NOMSG | OM_NO_QUERY);
1224 py_pickup_aux(this_o_idx);
1231 * When always_pickup is 'yes', we disable
1232 * auto-destroyer from autopick function, and do only
1233 * easy-auto-destroyer.
1237 if (auto_destroy_item((-this_o_idx), idx))
1245 * Describe which kind of object is Auto-picked/destroyed
1247 static void describe_autopick(char *buff, autopick_type *entry)
1249 cptr str = entry->name;
1250 byte act = entry->action;
1251 cptr insc = entry->insc;
1257 cptr before_str[100], body_str;
1260 body_str = "¥¢¥¤¥Æ¥à";
1262 /*** Collecting items ***/
1263 /*** Which can be absorbed into a slot as a bundle ***/
1264 if (IS_FLG(FLG_COLLECTING))
1265 before_str[before_n++] = "¼ý½¸Ãæ¤Ç´û¤Ë»ý¤Ã¤Æ¤¤¤ë¥¹¥í¥Ã¥È¤Ë¤Þ¤È¤á¤é¤ì¤ë";
1267 /*** Unidentified ***/
1268 if (IS_FLG(FLG_UNIDENTIFIED))
1269 before_str[before_n++] = "̤´ÕÄê¤Î";
1271 /*** Identified ***/
1272 if (IS_FLG(FLG_IDENTIFIED))
1273 before_str[before_n++] = "´ÕÄêºÑ¤ß¤Î";
1275 /*** *Identified* ***/
1276 if (IS_FLG(FLG_STAR_IDENTIFIED))
1277 before_str[before_n++] = "´°Á´¤Ë´ÕÄêºÑ¤ß¤Î";
1279 /*** Dice boosted (weapon of slaying) ***/
1280 if (IS_FLG(FLG_BOOSTED))
1282 before_str[before_n++] = "¥À¥á¡¼¥¸¥À¥¤¥¹¤¬Ä̾ï¤è¤êÂ礤¤";
1286 /*** Weapons whose dd*ds is more than nn ***/
1287 if (IS_FLG(FLG_MORE_THAN))
1289 static char more_than_desc_str[] = "___";
1290 before_str[before_n++] = "¥À¥á¡¼¥¸¥À¥¤¥¹¤ÎºÇÂçÃͤ¬";
1293 sprintf(more_than_desc_str,"%d", entry->dice);
1294 before_str[before_n++] = more_than_desc_str;
1295 before_str[before_n++] = "°Ê¾å¤Î";
1298 /*** Items whose magical bonus is more than nn ***/
1299 if (IS_FLG(FLG_MORE_BONUS))
1301 static char more_bonus_desc_str[] = "___";
1302 before_str[before_n++] = "½¤ÀµÃͤ¬(+";
1304 sprintf(more_bonus_desc_str,"%d", entry->bonus);
1305 before_str[before_n++] = more_bonus_desc_str;
1306 before_str[before_n++] = ")°Ê¾å¤Î";
1309 /*** Worthless items ***/
1310 if (IS_FLG(FLG_WORTHLESS))
1311 before_str[before_n++] = "Ź¤Ç̵²ÁÃͤÈȽÄꤵ¤ì¤ë";
1314 if (IS_FLG(FLG_ARTIFACT))
1316 before_str[before_n++] = "¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤Î";
1321 if (IS_FLG(FLG_EGO))
1323 before_str[before_n++] = "¥¨¥´¥¢¥¤¥Æ¥à¤Î";
1328 if (IS_FLG(FLG_NAMELESS))
1330 before_str[before_n++] = "¥¨¥´¤Ç¤â¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤Ç¤â¤Ê¤¤";
1334 /*** Unaware items ***/
1335 if (IS_FLG(FLG_UNAWARE))
1336 before_str[before_n++] = "̤´ÕÄê¤Ç¤½¤Î¸ú²Ì¤âȽÌÀ¤·¤Æ¤¤¤Ê¤¤";
1338 /*** Wanted monster's corpse/skeletons ***/
1339 if (IS_FLG(FLG_WANTED))
1341 before_str[before_n++] = "¥Ï¥ó¥¿¡¼»ö̳½ê¤Ç¾Þ¶â¼ó¤È¤µ¤ì¤Æ¤¤¤ë";
1342 body_str = "»àÂΤä¹ü";
1345 /*** Human corpse/skeletons (for Daemon magic) ***/
1346 if (IS_FLG(FLG_HUMAN))
1348 before_str[before_n++] = "°ËâËâË¡¤Ç»È¤¦¤¿¤á¤Î¿Í´Ö¤ä¥Ò¥å¡¼¥Þ¥Î¥¤¥É¤Î";
1349 body_str = "»àÂΤä¹ü";
1352 /*** Unique monster's corpse/skeletons/statues ***/
1353 if (IS_FLG(FLG_UNIQUE))
1355 before_str[before_n++] = "¥æ¥Ë¡¼¥¯¥â¥ó¥¹¥¿¡¼¤Î";
1356 body_str = "»àÂΤä¹ü";
1359 /*** Unreadable spellbooks ***/
1360 if (IS_FLG(FLG_UNREADABLE))
1362 before_str[before_n++] = "¤¢¤Ê¤¿¤¬Æɤá¤Ê¤¤Îΰè¤Î";
1363 body_str = "ËâË¡½ñ";
1366 /*** First realm spellbooks ***/
1367 if (IS_FLG(FLG_REALM1))
1369 before_str[before_n++] = "Âè°ìÎΰè¤Î";
1370 body_str = "ËâË¡½ñ";
1373 /*** Second realm spellbooks ***/
1374 if (IS_FLG(FLG_REALM2))
1376 before_str[before_n++] = "ÂèÆóÎΰè¤Î";
1377 body_str = "ËâË¡½ñ";
1380 /*** First rank spellbooks ***/
1381 if (IS_FLG(FLG_FIRST))
1383 before_str[before_n++] = "Á´4ºý¤ÎÆâ¤Î1ºýÌܤÎ";
1384 body_str = "ËâË¡½ñ";
1387 /*** Second rank spellbooks ***/
1388 if (IS_FLG(FLG_SECOND))
1390 before_str[before_n++] = "Á´4ºý¤ÎÆâ¤Î2ºýÌܤÎ";
1391 body_str = "ËâË¡½ñ";
1394 /*** Third rank spellbooks ***/
1395 if (IS_FLG(FLG_THIRD))
1397 before_str[before_n++] = "Á´4ºý¤ÎÆâ¤Î3ºýÌܤÎ";
1398 body_str = "ËâË¡½ñ";
1401 /*** Fourth rank spellbooks ***/
1402 if (IS_FLG(FLG_FOURTH))
1404 before_str[before_n++] = "Á´4ºý¤ÎÆâ¤Î4ºýÌܤÎ";
1405 body_str = "ËâË¡½ñ";
1409 if (IS_FLG(FLG_ITEMS))
1410 ; /* Nothing to do */
1411 else if (IS_FLG(FLG_WEAPONS))
1413 else if (IS_FLG(FLG_ARMORS))
1415 else if (IS_FLG(FLG_MISSILES))
1416 body_str = "ÃƤäÌð¤ä¥¯¥í¥¹¥Ü¥¦¤ÎÌð";
1417 else if (IS_FLG(FLG_DEVICES))
1418 body_str = "´¬Êª¤äËâË¡ËÀ¤ä¾ó¤ä¥í¥Ã¥É";
1419 else if (IS_FLG(FLG_LIGHTS))
1420 body_str = "¸÷¸»ÍѤΥ¢¥¤¥Æ¥à";
1421 else if (IS_FLG(FLG_JUNKS))
1422 body_str = "Àޤ줿ËÀÅù¤Î¥¬¥é¥¯¥¿";
1423 else if (IS_FLG(FLG_SPELLBOOKS))
1424 body_str = "ËâË¡½ñ";
1425 else if (IS_FLG(FLG_HAFTED))
1427 else if (IS_FLG(FLG_SHIELDS))
1429 else if (IS_FLG(FLG_BOWS))
1430 body_str = "¥¹¥ê¥ó¥°¤äµÝ¤ä¥¯¥í¥¹¥Ü¥¦";
1431 else if (IS_FLG(FLG_RINGS))
1433 else if (IS_FLG(FLG_AMULETS))
1434 body_str = "¥¢¥ß¥å¥ì¥Ã¥È";
1435 else if (IS_FLG(FLG_SUITS))
1437 else if (IS_FLG(FLG_CLOAKS))
1438 body_str = "¥¯¥í¡¼¥¯";
1439 else if (IS_FLG(FLG_HELMS))
1440 body_str = "¥Ø¥ë¥á¥Ã¥È¤ä´§";
1441 else if (IS_FLG(FLG_GLOVES))
1443 else if (IS_FLG(FLG_BOOTS))
1444 body_str = "¥Ö¡¼¥Ä";
1448 strcat(buff, "Á´¤Æ¤Î");
1449 else for (i = 0; i < before_n && before_str[i]; i++)
1450 strcat(buff, before_str[i]);
1452 strcat(buff, body_str);
1462 strcat(buff, "¤Ç¡¢Ì¾Á°¤¬¡Ö");
1463 strncat(buff, str, 80);
1465 strcat(buff, "¡×¤Ç»Ï¤Þ¤ë¤â¤Î");
1467 strcat(buff, "¡×¤ò´Þ¤à¤â¤Î");
1472 strncat(buff, format("¤Ë¡Ö%s¡×", insc), 80);
1474 if (strstr(insc, "%%all"))
1475 strcat(buff, "(%%all¤ÏÁ´Ç½ÎϤòɽ¤¹±Ñ»ú¤Îµ¹æ¤ÇÃÖ´¹)");
1476 else if (strstr(insc, "%all"))
1477 strcat(buff, "(%all¤ÏÁ´Ç½ÎϤòɽ¤¹µ¹æ¤ÇÃÖ´¹)");
1478 else if (strstr(insc, "%%"))
1479 strcat(buff, "(%%¤ÏÄɲÃǽÎϤòɽ¤¹±Ñ»ú¤Îµ¹æ¤ÇÃÖ´¹)");
1480 else if (strstr(insc, "%"))
1481 strcat(buff, "(%¤ÏÄɲÃǽÎϤòɽ¤¹µ¹æ¤ÇÃÖ´¹)");
1483 strcat(buff, "¤È¹ï¤ó¤Ç");
1488 if (act & DONT_AUTOPICK)
1489 strcat(buff, "ÊüÃÖ¤¹¤ë¡£");
1490 else if (act & DO_AUTODESTROY)
1491 strcat(buff, "Ç˲õ¤¹¤ë¡£");
1492 else if (act & DO_QUERY_AUTOPICK)
1493 strcat(buff, "³Îǧ¤Î¸å¤Ë½¦¤¦¡£");
1495 strcat(buff, "½¦¤¦¡£");
1497 if (act & DO_DISPLAY)
1499 if (act & DONT_AUTOPICK)
1500 strcat(buff, "Á´ÂΥޥå×('M')¤Ç'N'¤ò²¡¤·¤¿¤È¤¤Ëɽ¼¨¤¹¤ë¡£");
1501 else if (act & DO_AUTODESTROY)
1502 strcat(buff, "Á´ÂΥޥå×('M')¤Ç'K'¤ò²¡¤·¤¿¤È¤¤Ëɽ¼¨¤¹¤ë¡£");
1504 strcat(buff, "Á´ÂΥޥå×('M')¤Ç'M'¤ò²¡¤·¤¿¤È¤¤Ëɽ¼¨¤¹¤ë¡£");
1507 strcat(buff, "Á´ÂΥޥåפˤÏɽ¼¨¤·¤Ê¤¤");
1511 cptr before_str[20], after_str[20], which_str[20], whose_str[20], body_str;
1512 int before_n = 0, after_n = 0, which_n = 0, whose_n = 0;
1516 /*** Collecting items ***/
1517 /*** Which can be absorbed into a slot as a bundle ***/
1518 if (IS_FLG(FLG_COLLECTING))
1519 which_str[which_n++] = "can be absorbed into an existing inventory slot";
1521 /*** Unidentified ***/
1522 if (IS_FLG(FLG_UNIDENTIFIED))
1523 before_str[before_n++] = "unidentified";
1525 /*** Identified ***/
1526 if (IS_FLG(FLG_IDENTIFIED))
1527 before_str[before_n++] = "identified";
1529 /*** *Identified* ***/
1530 if (IS_FLG(FLG_STAR_IDENTIFIED))
1531 before_str[before_n++] = "fully identified";
1533 /*** Worthless items ***/
1534 if (IS_FLG(FLG_WORTHLESS))
1536 before_str[before_n++] = "worthless";
1537 which_str[which_n++] = "can not be sold at stores";
1541 if (IS_FLG(FLG_ARTIFACT))
1543 before_str[before_n++] = "artifact";
1547 if (IS_FLG(FLG_EGO))
1549 before_str[before_n++] = "ego";
1553 if (IS_FLG(FLG_NAMELESS))
1555 body_str = "equipment";
1556 which_str[which_n++] = "is neither ego-item nor artifact";
1559 /*** Unaware items ***/
1560 if (IS_FLG(FLG_UNAWARE))
1562 before_str[before_n++] = "unidentified";
1563 whose_str[whose_n++] = "basic abilities are not known";
1566 /*** Dice boosted (weapon of slaying) ***/
1567 if (IS_FLG(FLG_BOOSTED))
1569 body_str = "weapons";
1570 whose_str[whose_n++] = "damage dice is bigger than normal";
1573 /*** Weapons whose dd*ds is more than nn ***/
1574 if (IS_FLG(FLG_MORE_THAN))
1576 static char more_than_desc_str[] =
1577 "maximum damage from dice is bigger than __";
1578 body_str = "weapons";
1580 sprintf(more_than_desc_str + sizeof(more_than_desc_str) - 3,
1582 whose_str[whose_n++] = more_than_desc_str;
1585 /*** Items whose magical bonus is more than nn ***/
1586 if (IS_FLG(FLG_MORE_BONUS))
1588 static char more_bonus_desc_str[] =
1589 "magical bonus is bigger than (+__)";
1591 sprintf(more_bonus_desc_str + sizeof(more_bonus_desc_str) - 4,
1592 "%d)", entry->bonus);
1593 whose_str[whose_n++] = more_bonus_desc_str;
1596 /*** Wanted monster's corpse/skeletons ***/
1597 if (IS_FLG(FLG_WANTED))
1599 body_str = "corpse or skeletons";
1600 which_str[which_n++] = "is wanted at the Hunter's Office";
1603 /*** Human corpse/skeletons (for Daemon magic) ***/
1604 if (IS_FLG(FLG_HUMAN))
1606 before_str[before_n++] = "humanoid";
1607 body_str = "corpse or skeletons";
1608 which_str[which_n++] = "can be used for Daemon magic";
1611 /*** Unique monster's corpse/skeletons/statues ***/
1612 if (IS_FLG(FLG_UNIQUE))
1614 before_str[before_n++] = "unique monster's";
1615 body_str = "corpse or skeletons";
1618 /*** Unreadable spellbooks ***/
1619 if (IS_FLG(FLG_UNREADABLE))
1621 body_str = "spellbooks";
1622 after_str[after_n++] = "of different realms from yours";
1625 /*** First realm spellbooks ***/
1626 if (IS_FLG(FLG_REALM1))
1628 body_str = "spellbooks";
1629 after_str[after_n++] = "of your first realm";
1632 /*** Second realm spellbooks ***/
1633 if (IS_FLG(FLG_REALM2))
1635 body_str = "spellbooks";
1636 after_str[after_n++] = "of your second realm";
1639 /*** First rank spellbooks ***/
1640 if (IS_FLG(FLG_FIRST))
1642 before_str[before_n++] = "first one of four";
1643 body_str = "spellbooks";
1646 /*** Second rank spellbooks ***/
1647 if (IS_FLG(FLG_SECOND))
1649 before_str[before_n++] = "second one of four";
1650 body_str = "spellbooks";
1653 /*** Third rank spellbooks ***/
1654 if (IS_FLG(FLG_THIRD))
1656 before_str[before_n++] = "third one of four";
1657 body_str = "spellbooks";
1660 /*** Fourth rank spellbooks ***/
1661 if (IS_FLG(FLG_FOURTH))
1663 before_str[before_n++] = "fourth one of four";
1664 body_str = "spellbooks";
1668 if (IS_FLG(FLG_ITEMS))
1669 ; /* Nothing to do */
1670 else if (IS_FLG(FLG_WEAPONS))
1671 body_str = "weapons";
1672 else if (IS_FLG(FLG_ARMORS))
1673 body_str = "armors";
1674 else if (IS_FLG(FLG_MISSILES))
1675 body_str = "shots, arrows or crossbow bolts";
1676 else if (IS_FLG(FLG_DEVICES))
1677 body_str = "scrolls, wands, staves or rods";
1678 else if (IS_FLG(FLG_LIGHTS))
1679 body_str = "light sources";
1680 else if (IS_FLG(FLG_JUNKS))
1681 body_str = "junk such as broken sticks";
1682 else if (IS_FLG(FLG_SPELLBOOKS))
1683 body_str = "spellbooks";
1684 else if (IS_FLG(FLG_HAFTED))
1685 body_str = "hafted weapons";
1686 else if (IS_FLG(FLG_SHIELDS))
1687 body_str = "shields";
1688 else if (IS_FLG(FLG_BOWS))
1689 body_str = "slings, bows or crossbows";
1690 else if (IS_FLG(FLG_RINGS))
1692 else if (IS_FLG(FLG_AMULETS))
1693 body_str = "amulets";
1694 else if (IS_FLG(FLG_SUITS))
1695 body_str = "body armors";
1696 else if (IS_FLG(FLG_CLOAKS))
1697 body_str = "cloaks";
1698 else if (IS_FLG(FLG_HELMS))
1699 body_str = "helms or crowns";
1700 else if (IS_FLG(FLG_GLOVES))
1701 body_str = "gloves";
1702 else if (IS_FLG(FLG_BOOTS))
1705 /* Prepare a string for item name */
1712 whose_str[whose_n++] = "name is beginning with \"";
1715 which_str[which_n++] = "have \"";
1719 /* Describe action flag */
1720 if (act & DONT_AUTOPICK)
1721 strcpy(buff, "Leave on floor ");
1722 else if (act & DO_AUTODESTROY)
1723 strcpy(buff, "Destroy ");
1724 else if (act & DO_QUERY_AUTOPICK)
1725 strcpy(buff, "Ask to pick up ");
1727 strcpy(buff, "Pickup ");
1729 /* Auto-insctiption */
1732 strncat(buff, format("and inscribe \"%s\"", insc), 80);
1734 if (strstr(insc, "%all"))
1735 strcat(buff, ", replacing %all with code string representing all abilities,");
1736 else if (strstr(insc, "%"))
1737 strcat(buff, ", replacing % with code string representing extra random abilities,");
1739 strcat(buff, " on ");
1744 strcat(buff, "all ");
1745 else for (i = 0; i < before_n && before_str[i]; i++)
1747 strcat(buff, before_str[i]);
1752 strcat(buff, body_str);
1755 for (i = 0; i < after_n && after_str[i]; i++)
1758 strcat(buff, after_str[i]);
1762 for (i = 0; i < whose_n && whose_str[i]; i++)
1765 strcat(buff, " whose ");
1767 strcat(buff, ", and ");
1769 strcat(buff, whose_str[i]);
1772 /* Item name ; whose name is beginning with "str" */
1779 /* whose ..., and which .... */
1780 if (whose_n && which_n)
1781 strcat(buff, ", and ");
1784 for (i = 0; i < which_n && which_str[i]; i++)
1787 strcat(buff, " which ");
1789 strcat(buff, ", and ");
1791 strcat(buff, which_str[i]);
1794 /* Item name ; which have "str" as part of its name */
1797 strncat(buff, str, 80);
1798 strcat(buff, "\" as part of its name");
1802 /* Describe whether it will be displayed on the full map or not */
1803 if (act & DO_DISPLAY)
1805 if (act & DONT_AUTOPICK)
1806 strcat(buff, " Display these items when you press the N key in the full 'M'ap.");
1807 else if (act & DO_AUTODESTROY)
1808 strcat(buff, " Display these items when you press the K key in the full 'M'ap.");
1810 strcat(buff, " Display these items when you press the M key in the full 'M'ap.");
1813 strcat(buff, " Not displayed in the full map.");
1819 #define MAX_LINES 3000
1822 * Read whole lines of a file to memory
1824 static cptr *read_text_lines(cptr filename, bool user)
1826 cptr *lines_list = NULL;
1834 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, filename);
1838 path_build(buf, sizeof(buf), ANGBAND_DIR_PREF, filename);
1842 fff = my_fopen(buf, "r");
1846 /* Allocate list of pointers */
1847 C_MAKE(lines_list, MAX_LINES, cptr);
1850 while (0 == my_fgets(fff, buf, sizeof(buf)))
1852 lines_list[lines++] = string_make(buf);
1853 if (lines >= MAX_LINES - 1) break;
1856 lines_list[0] = string_make("");
1861 if (!fff) return NULL;
1866 #define PT_DEFAULT 0
1867 #define PT_WITH_PNAME 1
1869 static cptr *read_pickpref_text_lines(int *filename_mode_p)
1875 sprintf(buf, "picktype-%s.prf", player_name);
1877 sprintf(buf, "pickpref-%s.prf", player_name);
1879 lines_list = read_text_lines(buf, TRUE);
1884 lines_list = read_text_lines("picktype.prf", TRUE);
1886 lines_list = read_text_lines("pickpref.prf", TRUE);
1888 *filename_mode_p = PT_DEFAULT;
1894 lines_list = read_text_lines("picktype.prf", FALSE);
1896 lines_list = read_text_lines("pickpref.prf", FALSE);
1898 *filename_mode_p = PT_WITH_PNAME;
1903 /* Allocate list of pointers */
1904 C_MAKE(lines_list, MAX_LINES, cptr);
1905 lines_list[0] = string_make("");
1906 *filename_mode_p = PT_WITH_PNAME;
1912 * Write whole lines of memory to a file.
1914 static bool write_text_lines(cptr filename, cptr *lines_list)
1921 /* Build the filename */
1922 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, filename);
1925 fff = my_fopen(buf, "w");
1928 for (lines = 0; lines_list[lines]; lines++)
1929 my_fputs(fff, lines_list[lines], 1024);
1934 if (!fff) return FALSE;
1940 * Free memory of lines_list.
1942 static void free_text_lines(cptr *lines_list)
1946 for (lines = 0; lines_list[lines]; lines++)
1947 string_free(lines_list[lines]);
1949 /* free list of pointers */
1950 C_FREE((char **)lines_list, MAX_LINES, char *);
1955 * Delete or insert string
1957 static void toggle_string(cptr *lines_list, int flg, int y)
1959 autopick_type an_entry, *entry = &an_entry;
1961 if (!autopick_new_entry(entry, lines_list[y]))
1964 string_free(lines_list[y]);
1970 lines_list[y] = autopick_line_from_entry_kill(entry);
1974 * Insert return code and split the line
1976 static bool insert_return_code(cptr *lines_list, int cx, int cy)
1978 char buf[MAX_LINELEN];
1981 for (k = 0; lines_list[k]; k++)
1982 /* count number of lines */ ;
1984 if (k >= MAX_LINES - 2) return FALSE;
1987 /* Move down lines */
1989 lines_list[k+1] = lines_list[k];
1991 /* Split current line */
1992 for (i = j = 0; lines_list[cy][i] && i < cx; i++)
1995 if (iskanji(lines_list[cy][i]))
1996 buf[j++] = lines_list[cy][i++];
1998 buf[j++] = lines_list[cy][i];
2001 lines_list[cy+1] = string_make(&lines_list[cy][i]);
2002 string_free(lines_list[cy]);
2003 lines_list[cy] = string_make(buf);
2009 * Get auto-picker entry from o_ptr.
2011 void autopick_entry_from_object(autopick_type *entry, object_type *o_ptr)
2013 char o_name[MAX_NLEN];
2014 object_desc(o_name, o_ptr, FALSE, 0);
2016 entry->name = string_make(o_name);
2017 entry->insc = string_make(quark_str(o_ptr->inscription));
2018 entry->action = DO_AUTOPICK | DO_DISPLAY;
2019 entry->flag[0] = entry->flag[1] = 0L;
2022 if (!object_aware_p(o_ptr))
2023 ADD_FLG(FLG_UNAWARE);
2024 if (object_value(o_ptr) <= 0)
2025 ADD_FLG(FLG_WORTHLESS);
2027 if (object_known_p(o_ptr))
2031 else if (o_ptr->name1 || o_ptr->art_name)
2032 ADD_FLG(FLG_ARTIFACT);
2038 case TV_HAFTED: case TV_POLEARM: case TV_SWORD: case TV_DIGGING:
2039 k_ptr = &k_info[o_ptr->k_idx];
2040 if ((o_ptr->dd != k_ptr->dd) || (o_ptr->ds != k_ptr->ds))
2041 ADD_FLG(FLG_BOOSTED);
2044 if (o_ptr->tval == TV_CORPSE && object_is_shoukinkubi(o_ptr))
2046 REM_FLG(FLG_WORTHLESS);
2047 ADD_FLG(FLG_WANTED);
2050 if ((o_ptr->tval == TV_CORPSE || o_ptr->tval == TV_STATUE)
2051 && (r_info[o_ptr->pval].flags1 & RF1_UNIQUE))
2053 REM_FLG(FLG_WORTHLESS);
2054 ADD_FLG(FLG_UNIQUE);
2057 if (o_ptr->tval == TV_CORPSE && strchr("pht", r_info[o_ptr->pval].d_char))
2059 REM_FLG(FLG_WORTHLESS);
2063 if (o_ptr->tval >= TV_LIFE_BOOK &&
2064 !check_book_realm(o_ptr->tval, o_ptr->sval))
2065 ADD_FLG(FLG_UNREADABLE);
2067 if (REALM1_BOOK == o_ptr->tval &&
2068 p_ptr->pclass != CLASS_SORCERER &&
2069 p_ptr->pclass != CLASS_RED_MAGE)
2070 ADD_FLG(FLG_REALM1);
2072 if (REALM2_BOOK == o_ptr->tval &&
2073 p_ptr->pclass != CLASS_SORCERER &&
2074 p_ptr->pclass != CLASS_RED_MAGE)
2075 ADD_FLG(FLG_REALM2);
2077 if (o_ptr->tval >= TV_LIFE_BOOK && 0 == o_ptr->sval)
2079 if (o_ptr->tval >= TV_LIFE_BOOK && 1 == o_ptr->sval)
2080 ADD_FLG(FLG_SECOND);
2081 if (o_ptr->tval >= TV_LIFE_BOOK && 2 == o_ptr->sval)
2083 if (o_ptr->tval >= TV_LIFE_BOOK && 3 == o_ptr->sval)
2084 ADD_FLG(FLG_FOURTH);
2086 if (o_ptr->tval == TV_SHOT || o_ptr->tval == TV_BOLT
2087 || o_ptr->tval == TV_ARROW)
2088 ADD_FLG(FLG_MISSILES);
2089 else if (o_ptr->tval == TV_SCROLL || o_ptr->tval == TV_STAFF
2090 || o_ptr->tval == TV_WAND || o_ptr->tval == TV_ROD)
2091 ADD_FLG(FLG_DEVICES);
2092 else if (o_ptr->tval == TV_LITE)
2093 ADD_FLG(FLG_LIGHTS);
2094 else if (o_ptr->tval == TV_SKELETON || o_ptr->tval == TV_BOTTLE
2095 || o_ptr->tval == TV_JUNK || o_ptr->tval == TV_STATUE)
2097 else if (o_ptr->tval >= TV_LIFE_BOOK)
2098 ADD_FLG(FLG_SPELLBOOKS);
2099 else if (o_ptr->tval == TV_HAFTED)
2100 ADD_FLG(FLG_HAFTED);
2101 else if (o_ptr->tval == TV_POLEARM || o_ptr->tval == TV_SWORD
2102 || o_ptr->tval == TV_DIGGING)
2103 ADD_FLG(FLG_WEAPONS);
2104 else if (o_ptr->tval == TV_SHIELD)
2105 ADD_FLG(FLG_SHIELDS);
2106 else if (o_ptr->tval == TV_BOW)
2108 else if (o_ptr->tval == TV_RING)
2110 else if (o_ptr->tval == TV_AMULET)
2111 ADD_FLG(FLG_AMULETS);
2112 else if (o_ptr->tval == TV_DRAG_ARMOR || o_ptr->tval == TV_HARD_ARMOR ||
2113 o_ptr->tval == TV_SOFT_ARMOR)
2115 else if (o_ptr->tval == TV_CLOAK)
2116 ADD_FLG(FLG_CLOAKS);
2117 else if (o_ptr->tval == TV_HELM)
2119 else if (o_ptr->tval == TV_GLOVES)
2120 ADD_FLG(FLG_GLOVES);
2121 else if (o_ptr->tval == TV_BOOTS)
2129 * Choose an item and get auto-picker entry from it.
2131 static object_type *choose_object(cptr q, cptr s)
2135 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP))) return NULL;
2137 /* Get the item (in the pack) */
2138 if (item >= 0) return &inventory[item];
2140 /* Get the item (on the floor) */
2141 else return &o_list[0 - item];
2146 * Choose an item and get auto-picker entry from it.
2148 static bool entry_from_choosed_object(autopick_type *entry)
2155 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÅÐÏ¿¤·¤Þ¤¹¤«? ";
2156 s = "¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£";
2158 q = "Enter which item? ";
2159 s = "You have nothing to enter.";
2161 o_ptr = choose_object(q, s);
2162 if (!o_ptr) return FALSE;
2164 autopick_entry_from_object(entry, o_ptr);
2170 * Choose an item or string for search
2172 static bool get_string_for_search(object_type **o_handle, cptr *search_strp)
2176 char buf[MAX_NLEN+20];
2179 int k_flag[MAX_NLEN+20];
2180 char prompt[] = "¸¡º÷(^I:»ý¤Áʪ ^L:Ç˲õ¤µ¤ì¤¿Êª): ";
2182 char prompt[] = "Search key(^I:inven ^L:destroyed): ";
2184 int col = sizeof(prompt) - 1;
2186 if (*search_strp) strcpy(buf, *search_strp);
2189 /* Display prompt */
2192 /* Display the default answer */
2193 Term_erase(col, 0, 255);
2194 Term_putstr(col, 0, -1, TERM_YELLOW, buf);
2203 Term_gotoxy(col + pos, 0);
2205 /* Do not process macros except special keys */
2206 inkey_special = TRUE;
2211 /* Analyze the key */
2220 if (!pos && *o_handle) return TRUE;
2221 string_free(*search_strp);
2222 *search_strp = string_make(buf);
2229 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¸¡º÷¤·¤Þ¤¹¤«? ";
2230 s = "¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£";
2232 q = "Enter which item? ";
2233 s = "You have nothing to enter.";
2235 o_ptr = choose_object(q, s);
2236 if (!o_ptr) return FALSE;
2240 string_free(*search_strp);
2241 object_desc(buf, *o_handle, FALSE, 3);
2242 *search_strp = string_make(format("<%s>", buf));
2246 if (!autopick_last_destroyed_object.k_idx) break;
2247 *o_handle = &autopick_last_destroyed_object;
2249 string_free(*search_strp);
2250 object_desc(buf, *o_handle, FALSE, 3);
2251 *search_strp = string_make(format("<%s>", buf));
2260 if (k_flag[pos]) pos--;
2275 if (pos + 1 < MAX_NLEN)
2283 else if (pos < MAX_NLEN && isprint(i))
2290 if (pos < MAX_NLEN && isprint(i)) buf[pos++] = i;
2299 /* Update the entry */
2300 Term_erase(col, 0, 255);
2301 Term_putstr(col, 0, -1, TERM_WHITE, buf);
2309 * Search next line matches for o_ptr
2311 static bool search_for_object(cptr *lines_list, object_type *o_ptr, int *cxp, int *cyp, bool forward)
2314 autopick_type an_entry, *entry = &an_entry;
2315 char o_name[MAX_NLEN];
2317 object_desc(o_name, o_ptr, FALSE, 3);
2319 /* Force to be lower case string */
2320 for (i = 0; o_name[i]; i++)
2323 if (iskanji(o_name[i]))
2327 if (isupper(o_name[i]))
2328 o_name[i] = tolower(o_name[i]);
2337 if (!lines_list[++i]) break;
2344 if (!autopick_new_entry(entry, lines_list[i])) continue;
2346 if (is_autopick_aux(o_ptr, entry, o_name))
2359 * Search next line matches to the string
2361 static bool search_for_string(cptr *lines_list, cptr search_str, int *cxp, int *cyp, bool forward)
2371 if (!lines_list[++i]) break;
2378 pos = strstr_j(lines_list[i], search_str);
2380 pos = strstr(lines_list[i], search_str);
2384 *cxp = (int)(pos - lines_list[i]);
2395 * Initialize auto-picker preference
2397 void init_autopicker(void)
2399 static const char easy_autopick_inscription[] = "(:=g";
2400 autopick_type entry;
2403 /* Clear old entries */
2404 for( i = 0; i < max_autopick; i++)
2405 autopick_free_entry(&autopick_list[i]);
2409 /* There is always one entry "=g" */
2410 autopick_new_entry(&entry, easy_autopick_inscription);
2411 autopick_list[max_autopick++] = entry;
2417 * Process line for auto picker/destroyer.
2419 errr process_pickpref_file_line(char *buf)
2421 autopick_type entry;
2424 if (max_autopick == MAX_AUTOPICK)
2427 /* Nuke illegal char */
2428 for(i = 0; buf[i]; i++)
2431 if (iskanji(buf[i]))
2437 if (isspace(buf[i]) && buf[i] != ' ')
2442 if (!autopick_new_entry(&entry, buf)) return 0;
2444 /* Already has the same entry? */
2445 for(i = 0; i < max_autopick; i++)
2446 if(!strcmp(entry.name, autopick_list[i].name)
2447 && entry.flag[0] == autopick_list[i].flag[0]
2448 && entry.flag[1] == autopick_list[i].flag[1]
2449 && entry.dice == autopick_list[i].dice
2450 && entry.bonus == autopick_list[i].bonus) return 0;
2452 autopick_list[max_autopick++] = entry;
2458 * Get a trigger key and insert ASCII string for the trigger
2460 static bool insert_macro_line(cptr *lines_list, int cy)
2469 /* Do not process macros */
2475 /* Read the pattern */
2481 /* Do not process macros */
2484 /* Do not wait for keys */
2487 /* Attempt to read a key */
2497 /* Convert the trigger */
2498 ascii_to_text(tmp, buf);
2501 if(!tmp[0]) return FALSE;
2503 /* Insert preference string */
2504 insert_return_code(lines_list, 0, cy);
2505 string_free(lines_list[cy]);
2506 lines_list[cy] = string_make(format("P:%s", tmp));
2508 /* Insert blank action preference line */
2509 insert_return_code(lines_list, 0, cy);
2510 string_free(lines_list[cy]);
2511 lines_list[cy] = string_make("A:");
2518 * Get a command key and insert ASCII string for the key
2520 static bool insert_keymap_line(cptr *lines_list, int cy)
2527 if (rogue_like_commands)
2529 mode = KEYMAP_MODE_ROGUE;
2535 mode = KEYMAP_MODE_ORIG;
2548 /* Convert the trigger */
2549 ascii_to_text(tmp, buf);
2552 if(!tmp[0]) return FALSE;
2554 /* Insert preference string */
2555 insert_return_code(lines_list, 0, cy);
2556 string_free(lines_list[cy]);
2557 lines_list[cy] = string_make(format("C:%d:%s", mode, tmp));
2559 /* Insert blank action preference line */
2560 insert_return_code(lines_list, 0, cy);
2561 string_free(lines_list[cy]);
2562 lines_list[cy] = string_make("A:");
2569 * Description of control commands
2574 static cptr ctrl_command_desc[] =
2577 #define LAST_DESTROYED 6
2578 "^P ^N ^B ^F ¾å²¼º¸±¦¤Ë°ÜÆ°",
2579 "^A ^E ¹Ô¤ÎÀèƬ¡¢½ªÃ¼",
2580 "^Q ÆþÎÏ/¥³¥Þ¥ó¥É¥â¡¼¥ÉÀÚ¤êÂؤ¨",
2581 "^R Êѹ¹¤òÁ´¤Æ¼è¤ê¾Ã¤·¤Æ¸µ¤ËÌ᤹",
2582 "------------------------------------",
2583 "^I »ý¤Áʪ/ÁõÈ÷¤«¤éÁªÂò",
2585 "^K ¥«¡¼¥½¥ë¤«¤é½ªÃ¼¤Þ¤Çºï½ü",
2586 "^Y ºï½ü(^K)¤·¤¿¹Ô¤òÁÞÆþ",
2587 "^C ¼ï²¡¢¿¦¶È¤Î¾ò·ï¼°¤òÁÞÆþ",
2588 "------------------------------------",
2589 "^S Êѹ¹ (!Ç˲õ/~ÊüÃÖ/½¦¤¦)",
2590 "^G \"(\" Á´ÂΥޥåפÇɽ¼¨¤·¤Ê¤¤",
2591 "^O \"#\" ¼«Æ°¹ï¤ß",
2592 "------------------------------------",
2593 "^U ̤´ÕÄê/̤ȽÌÀ/´ÕÄê/*´ÕÄê*",
2595 "^X ̵ÌÃ/¥¨¥´/¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È",
2599 #define LAST_DESTROYED 6
2600 "^P ^N ^B ^F Move Cursor",
2601 "^A ^E Beginning and End of Line",
2602 "^Q Toggle Insert/Command mode",
2603 "^R Revert to Original File",
2604 "------------------------------------",
2605 "^I Object in Inventry/Equipment",
2607 "^K Kill Rest of Line",
2608 "^Y Insert killed(^K) text",
2609 "^C Insert conditional expression",
2610 "------------------------------------",
2611 "^S Toggle(!Destroy/~Leave/Pick)",
2612 "^G \"(\" No display in the 'M'ap",
2613 "^O \"#\" Auto-Inscribe",
2614 "------------------------------------",
2615 "^U Toggle 'identified' state",
2617 "^X Toggle nameless/ego/artifact",
2618 "^Z \"collecting\"",
2624 #define MAX_YANK MAX_LINELEN
2625 #define DIRTY_ALL 0x01
2626 #define DIRTY_COMMAND 0x02
2627 #define DIRTY_MODE 0x04
2628 #define DIRTY_SCREEN 0x08
2629 #define DIRTY_NOT_FOUND 0x10
2630 #define DIRTY_NO_SEARCH 0x20
2633 * In-game editor of Object Auto-picker/Destoryer
2635 void do_cmd_edit_autopick(void)
2637 static int cx = 0, cy = 0;
2638 static int upper = 0, left = 0;
2640 object_type *search_o_ptr = NULL;
2641 cptr search_str = NULL;
2642 cptr last_destroyed = NULL;
2643 char last_destroyed_command[WID_DESC+3];
2644 char yank_buf[MAX_YANK];
2646 autopick_type an_entry, *entry = &an_entry;
2647 char buf[MAX_LINELEN];
2649 int filename_mode = PT_WITH_PNAME;
2653 int old_upper = -1, old_left = -1;
2655 int key = -1, old_key;
2656 bool repeated_clearing = FALSE;
2657 bool edit_mode = FALSE;
2659 byte dirty_flags = DIRTY_ALL | DIRTY_COMMAND | DIRTY_MODE;
2660 int dirty_line = -1;
2662 int wid, hgt, old_wid = -1, old_hgt = -1;
2664 static s32b old_autosave_turn = 0L;
2667 if (turn > old_autosave_turn + 100L)
2669 do_cmd_save_game(TRUE);
2670 old_autosave_turn = turn;
2673 /* HACK -- Reset start_time to stop counting playtime while edit */
2676 /* Free old entries */
2679 /* Command Description of the 'Last Destroyed Item' */
2680 if (autopick_last_destroyed_object.k_idx)
2682 autopick_entry_from_object(entry, &autopick_last_destroyed_object);
2683 last_destroyed = autopick_line_from_entry_kill(entry);
2685 my_strcpy(last_destroyed_command, format("^L \"%s\"", last_destroyed), sizeof(last_destroyed_command));
2690 strcpy(last_destroyed_command, "^L ºÇ¸å¤Ë¼«Æ°Ç˲õ¤·¤¿¥¢¥¤¥Æ¥à̾");
2692 strcpy(last_destroyed_command, "^L Last destroyed object");
2695 ctrl_command_desc[LAST_DESTROYED] = last_destroyed_command;
2697 /* Conditional Expression for Class and Race */
2698 sprintf(classrace, "?:[AND [EQU $RACE %s] [EQU $CLASS %s]]",
2700 rp_ptr->E_title, cp_ptr->E_title
2702 rp_ptr->title, cp_ptr->title
2706 /* Clear yank buffer */
2709 /* Read or initialize whole text */
2710 lines_list = read_pickpref_text_lines(&filename_mode);
2712 /* Reset cursor position if needed */
2713 for (i = 0; i < cy; i++)
2722 /* Save the screen */
2725 /* Process requests until done */
2729 Term_get_size(&wid, &hgt);
2732 /* Don't let cursor at second byte of kanji */
2733 for (i = 0; lines_list[cy][i]; i++)
2734 if (iskanji(lines_list[cy][i]))
2745 /* Scroll if necessary */
2746 if (cy < upper || upper + hgt - 4 <= cy)
2747 upper = cy - (hgt-4)/2;
2750 if ((cx < left + 10 && left > 0) || left + wid - WID_DESC - 5 <= cx)
2751 left = cx - (wid - WID_DESC)*2/3;
2755 /* Redraw whole window after resize */
2756 if (old_wid != wid || old_hgt != hgt)
2757 dirty_flags |= DIRTY_SCREEN;
2759 /* Redraw all text after scroll */
2760 else if (old_upper != upper || old_left != left)
2761 dirty_flags |= DIRTY_ALL;
2764 if (dirty_flags & DIRTY_SCREEN)
2766 dirty_flags |= (DIRTY_ALL | DIRTY_COMMAND | DIRTY_MODE);
2772 if (dirty_flags & DIRTY_COMMAND)
2774 /* Display control command */
2775 for (i = 0; ctrl_command_desc[i]; i++)
2776 Term_putstr(wid - WID_DESC, i + 1, WID_DESC, TERM_WHITE, ctrl_command_desc[i]);
2779 /* Redraw mode line */
2780 if (dirty_flags & DIRTY_MODE)
2782 int sepa_length = wid - WID_DESC;
2785 for (i = 0; i < sepa_length; i++)
2791 strncpy(buf + sepa_length - 21, " (INSERT MODE) ", 16);
2793 strncpy(buf + sepa_length - 21, " (COMMAND MODE) ", 16);
2795 Term_putstr(0, hgt - 3, sepa_length, (byte) (edit_mode ? TERM_YELLOW : TERM_WHITE), buf);
2798 /* Dump up to 20, or hgt-4, lines of messages */
2799 for (i = 0; i < hgt - 4; i++)
2804 /* clean or dirty? */
2805 if (!(dirty_flags & DIRTY_ALL) && (dirty_line != upper+i))
2808 msg = lines_list[upper+i];
2811 /* Apply horizontal scroll */
2812 for (j = 0; *msg; msg++, j++)
2814 if (j == left) break;
2830 Term_erase(0, i + 1, wid - WID_DESC);
2832 /* Dump the messages, bottom to top */
2833 Term_putstr(leftcol, i + 1, wid - WID_DESC - 1, TERM_WHITE, msg);
2836 for (; i < hgt - 4; i++)
2839 Term_erase(0, i + 1, wid - WID_DESC);
2842 /* Display header line */
2845 prt("^Q ESC ¤Ç¥³¥Þ¥ó¥É¥â¡¼¥É¤Ø°Ü¹Ô¡¢Ä̾ï¤Îʸ»ú¤Ï¤½¤Î¤Þ¤ÞÆþÎÏ", 0, 0);
2847 prt("q _ ¤Ç½ªÎ»¡¢hjkl2468 ¤Ç°ÜÆ°¡¢^Q a i ¤ÇÆþÎϥ⡼¥É¡¢/ n N ¤Ç¸¡º÷", 0, 0);
2850 prt("Press ^Q ESC to command mode, any letters to insert", 0, 0);
2852 prt(format("Press q _ to quit, %s to move, ^Q a i to insert mode, /nN to find", rogue_like_commands ? "hjkl" : "2468"), 0, 0);
2854 /* Display current position */
2855 prt (format("(%d,%d)", cx, cy), 0, 70);
2857 /* Display information when updated */
2858 if (old_cy != cy || (dirty_flags & (DIRTY_ALL | DIRTY_NOT_FOUND | DIRTY_NO_SEARCH)) || dirty_line == cy)
2860 /* Clear information line */
2861 Term_erase(0, hgt - 3 + 1, wid);
2862 Term_erase(0, hgt - 3 + 2, wid);
2864 /* Display information */
2865 if (dirty_flags & DIRTY_NOT_FOUND)
2868 prt(format("¥Ñ¥¿¡¼¥ó¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó: %s", search_str), hgt - 3 + 1, 0);
2870 prt(format("Pattern not found: %s", search_str), hgt - 3 + 1, 0);
2873 else if (dirty_flags & DIRTY_NO_SEARCH)
2876 prt("¸¡º÷Ãæ¤Î¥Ñ¥¿¡¼¥ó¤¬¤¢¤ê¤Þ¤»¤ó('/'¤Ç¸¡º÷)¡£", hgt - 3 + 1, 0);
2878 prt("No pattern to search. (Press '/' to search.)", hgt - 3 + 1, 0);
2881 else if (lines_list[cy][0] == '#')
2884 prt("¤³¤Î¹Ô¤Ï¥³¥á¥ó¥È¤Ç¤¹¡£", hgt - 3 + 1, 0);
2886 prt("This line is a comment.", hgt - 3 + 1, 0);
2889 else if (lines_list[cy][1] == ':')
2891 switch(lines_list[cy][0])
2895 prt("¤³¤Î¹Ô¤Ï¾ò·ïʬ´ô¼°¤Ç¤¹¡£", hgt - 3 + 1, 0);
2897 prt("This line is a Conditional Expression.", hgt - 3 + 1, 0);
2902 prt("¤³¤Î¹Ô¤Ï¥Þ¥¯¥í¤Î¼Â¹ÔÆâÍƤòÄêµÁ¤·¤Þ¤¹¡£", hgt - 3 + 1, 0);
2904 prt("This line defines a Macro action.", hgt - 3 + 1, 0);
2909 prt("¤³¤Î¹Ô¤Ï¥Þ¥¯¥í¤Î¥È¥ê¥¬¡¼¡¦¥¡¼¤òÄêµÁ¤·¤Þ¤¹¡£", hgt - 3 + 1, 0);
2911 prt("This line defines a Macro trigger key.", hgt - 3 + 1, 0);
2916 prt("¤³¤Î¹Ô¤Ï¥¡¼ÇÛÃÖ¤òÄêµÁ¤·¤Þ¤¹¡£", hgt - 3 + 1, 0);
2918 prt("This line defines a Keymap.", hgt - 3 + 1, 0);
2924 /* Get description of an autopicker preference line */
2925 else if (autopick_new_entry(entry, lines_list[cy]))
2930 describe_autopick(buf, entry);
2932 roff_to_buf(buf, 81, temp, sizeof(temp));
2934 for (i = 0; i< 2; i++)
2940 prt(t, hgt - 3 + 1 + i, 0);
2944 autopick_free_entry(entry);
2949 Term_gotoxy(cx - left, cy - upper + 1);
2955 /* Save old key and location */
2963 /* Do not process macros except special keys */
2964 inkey_special = TRUE;
2975 /* Mode line is now dirty */
2976 dirty_flags |= DIRTY_MODE;
2979 /* Insert a character */
2980 else if (!iscntrl(key&0xff))
2982 /* Save preceding string */
2983 for (i = j = 0; lines_list[cy][i] && i < cx; i++)
2984 buf[j++] = lines_list[cy][i];
2986 /* Add a character */
2994 if (j+2 < MAX_LINELEN)
3006 if (j+1 < MAX_LINELEN)
3012 for (; lines_list[cy][i] && j + 1 < MAX_LINELEN; i++)
3013 buf[j++] = lines_list[cy][i];
3016 /* Replace current line with new line */
3017 string_free(lines_list[cy]);
3018 lines_list[cy] = string_make(buf);
3020 /* Move to correct collumn */
3021 len = strlen(lines_list[cy]);
3022 if (len < cx) cx = len;
3031 if (key == 'q' || key == '_') break;
3038 /* Mode line is now dirty */
3039 dirty_flags |= DIRTY_MODE;
3042 if (!autopick_new_entry(entry, lines_list[cy]))
3044 if (old_key != key) repeated_clearing = FALSE;
3047 if (lines_list[cy + 1]) cy++;
3051 string_free(lines_list[cy]);
3055 if (entry->action & DONT_AUTOPICK)
3056 repeated_clearing = TRUE;
3058 repeated_clearing = FALSE;
3061 entry->action &= ~DO_AUTODESTROY;
3062 entry->action &= ~DO_QUERY_AUTOPICK;
3063 if (!repeated_clearing)
3065 entry->action &= ~DO_AUTOPICK;
3066 entry->action |= DONT_AUTOPICK;
3070 entry->action &= ~DONT_AUTOPICK;
3071 entry->action |= DO_AUTOPICK;
3074 lines_list[cy] = autopick_line_from_entry_kill(entry);
3080 if (lines_list[cy + 1]) cy++;
3084 if (!autopick_new_entry(entry, lines_list[cy]))
3086 if (old_key != key) repeated_clearing = FALSE;
3089 if (lines_list[cy + 1]) cy++;
3093 string_free(lines_list[cy]);
3097 if (entry->action & DO_AUTODESTROY)
3098 repeated_clearing = TRUE;
3100 repeated_clearing = FALSE;
3103 entry->action &= ~DONT_AUTOPICK;
3104 entry->action &= ~DO_QUERY_AUTOPICK;
3105 if (!repeated_clearing)
3107 entry->action &= ~DO_AUTOPICK;
3108 entry->action |= DO_AUTODESTROY;
3112 entry->action &= ~DO_AUTODESTROY;
3113 entry->action |= DO_AUTOPICK;
3116 lines_list[cy] = autopick_line_from_entry_kill(entry);
3122 if (lines_list[cy + 1]) cy++;
3126 if (!autopick_new_entry(entry, lines_list[cy]))
3128 if (old_key != key) repeated_clearing = FALSE;
3131 if (lines_list[cy + 1]) cy++;
3135 string_free(lines_list[cy]);
3139 if (entry->action & DO_QUERY_AUTOPICK)
3140 repeated_clearing = TRUE;
3142 repeated_clearing = FALSE;
3145 entry->action &= ~DO_AUTODESTROY;
3146 entry->action &= ~DONT_AUTOPICK;
3147 if (!repeated_clearing)
3149 entry->action &= ~DO_AUTOPICK;
3150 entry->action |= DO_QUERY_AUTOPICK;
3154 entry->action &= ~DO_QUERY_AUTOPICK;
3155 entry->action |= DO_AUTOPICK;
3158 lines_list[cy] = autopick_line_from_entry_kill(entry);
3164 if (lines_list[cy + 1]) cy++;
3168 /* Toggle display on the 'M'ap */
3169 if (!autopick_new_entry(entry, lines_list[cy]))
3171 if (old_key != key) repeated_clearing = FALSE;
3174 if (lines_list[cy + 1]) cy++;
3178 string_free(lines_list[cy]);
3182 if (entry->action & DO_DISPLAY)
3183 repeated_clearing = TRUE;
3185 repeated_clearing = FALSE;
3188 if (!repeated_clearing)
3189 entry->action |= DO_DISPLAY;
3191 entry->action &= ~DO_DISPLAY;
3193 lines_list[cy] = autopick_line_from_entry_kill(entry);
3199 if (lines_list[cy + 1]) cy++;
3219 while (cy < upper + hgt-4 && lines_list[cy + 1])
3224 while (0 < cy && upper <= cy)
3226 while (0 < upper && cy + 1 < upper + hgt - 4)
3235 while (lines_list[cy + 1])
3241 Term_erase(0, cy - upper + 1, wid - WID_DESC);
3245 Term_putstr(0, cy - upper + 1, wid - WID_DESC - 1, TERM_YELLOW, "P:<¥È¥ê¥¬¡¼¥¡¼>: ");
3247 Term_putstr(0, cy - upper + 1, wid - WID_DESC - 1, TERM_YELLOW, "P:<Trigger key>: ");
3249 if (insert_macro_line(lines_list, cy))
3251 /* Prepare to input action */
3256 dirty_flags |= DIRTY_ALL;
3257 dirty_flags |= DIRTY_MODE;
3264 Term_erase(0, cy - upper + 1, wid - WID_DESC);
3268 Term_putstr(0, cy - upper + 1, wid - WID_DESC - 1, TERM_YELLOW, format("C:%d:<¥³¥Þ¥ó¥É¥¡¼>: ", (rogue_like_commands ? KEYMAP_MODE_ROGUE : KEYMAP_MODE_ORIG)));
3270 Term_putstr(0, cy - upper + 1, wid - WID_DESC - 1, TERM_YELLOW, format("C:%d:<Keypress>: ", (rogue_like_commands ? KEYMAP_MODE_ROGUE : KEYMAP_MODE_ORIG)));
3273 if (insert_keymap_line(lines_list, cy))
3275 /* Prepare to input action */
3280 dirty_flags |= DIRTY_ALL;
3281 dirty_flags |= DIRTY_MODE;
3285 /* Become dirty because of item/equip menu */
3286 dirty_flags |= DIRTY_SCREEN;
3288 if (!get_string_for_search(&search_o_ptr, &search_str))
3295 if (!search_for_object(lines_list, search_o_ptr, &cx, &cy, TRUE)) dirty_flags |= DIRTY_NOT_FOUND;
3297 else if (search_str)
3299 if (!search_for_string(lines_list, search_str, &cx, &cy, TRUE)) dirty_flags |= DIRTY_NOT_FOUND;
3303 dirty_flags |= DIRTY_NO_SEARCH;
3309 if (!search_for_object(lines_list, search_o_ptr, &cx, &cy, FALSE)) dirty_flags |= DIRTY_NOT_FOUND;
3311 else if (search_str)
3313 if (!search_for_string(lines_list, search_str, &cx, &cy, FALSE)) dirty_flags |= DIRTY_NOT_FOUND;
3317 dirty_flags |= DIRTY_NO_SEARCH;
3326 /* Beginning of line */
3334 len = strlen(lines_list[cy]);
3335 if (len < cx) cx = len;
3340 cx = strlen(lines_list[cy]);
3344 /* Insert a conditinal expression line */
3345 insert_return_code(lines_list, 0, cy);
3346 string_free(lines_list[cy]);
3347 lines_list[cy] = string_make(classrace);
3349 insert_return_code(lines_list, 0, cy);
3350 string_free(lines_list[cy]);
3351 lines_list[cy] = string_make("?:1");
3355 dirty_flags |= DIRTY_ALL;
3359 cx = strlen(lines_list[cy]);
3364 if (iskanji(lines_list[cy][cx])) cx++;
3367 len = strlen(lines_list[cy]);
3370 if (lines_list[cy + 1])
3380 /* Toggle display on the 'M'ap */
3381 if (!autopick_new_entry(entry, lines_list[cy]))
3383 string_free(lines_list[cy]);
3385 if (entry->action & DO_DISPLAY)
3387 entry->action &= ~DO_DISPLAY;
3392 entry->action |= DO_DISPLAY;
3396 lines_list[cy] = autopick_line_from_entry_kill(entry);
3402 /* Insert choosen item name */
3403 if (!entry_from_choosed_object(entry))
3405 /* Now dirty because of item/equip menu */
3406 dirty_flags |= DIRTY_SCREEN;
3410 insert_return_code(lines_list, 0, cy);
3411 string_free(lines_list[cy]);
3412 lines_list[cy] = autopick_line_from_entry_kill(entry);
3415 /* Now dirty because of item/equip menu */
3416 dirty_flags |= DIRTY_SCREEN;
3420 /* Insert a name of last destroyed item */
3423 insert_return_code(lines_list, 0, cy);
3424 string_free(lines_list[cy]);
3425 lines_list[cy] = string_make(last_destroyed);
3429 dirty_flags |= DIRTY_ALL;
3432 case '\n': case '\r':
3433 /* Split a line or insert end of line */
3434 insert_return_code(lines_list, cx, cy);
3439 dirty_flags |= DIRTY_ALL;
3443 if (lines_list[cy + 1]) cy++;
3446 /* Prepare to write auto-inscription text */
3447 if (!autopick_new_entry(entry, lines_list[cy]))
3449 string_free(lines_list[cy]);
3451 if (!entry->insc) entry->insc = string_make("");
3453 lines_list[cy] = autopick_line_from_entry_kill(entry);
3455 /* Move to collumn for auto inscription */
3456 for (cx = 0; lines_list[cy][cx]; cx++)
3457 if (lines_list[cy][cx] == '#') break;
3463 dirty_flags |= DIRTY_MODE;
3471 edit_mode = !edit_mode;
3473 /* Mode line is now dirty */
3474 dirty_flags |= DIRTY_MODE;
3477 /* Revert to original */
3479 if (!get_check("Á´¤Æ¤ÎÊѹ¹¤òÇË´þ¤·¤Æ¸µ¤Î¾õÂÖ¤ËÌᤷ¤Þ¤¹¡£¤è¤í¤·¤¤¤Ç¤¹¤«¡© "))
3481 if (!get_check("Discard all changes and revert to original file. Are you sure? "))
3485 free_text_lines(lines_list);
3486 lines_list = read_pickpref_text_lines(&filename_mode);
3487 dirty_flags |= DIRTY_ALL | DIRTY_MODE;
3492 /* Rotate action; pickup/destroy/leave */
3493 if (!autopick_new_entry(entry, lines_list[cy]))
3495 string_free(lines_list[cy]);
3497 if (entry->action & DO_AUTOPICK)
3499 entry->action &= ~DO_AUTOPICK;
3500 entry->action |= DO_AUTODESTROY;
3502 else if (entry->action & DO_AUTODESTROY)
3504 entry->action &= ~DO_AUTODESTROY;
3505 entry->action |= DONT_AUTOPICK;
3507 else if (entry->action & DONT_AUTOPICK)
3509 entry->action &= ~DONT_AUTOPICK;
3510 entry->action |= DO_AUTOPICK;
3513 lines_list[cy] = autopick_line_from_entry_kill(entry);
3523 /* Rotate identify-state; identified/unidentified/... */
3524 if (!autopick_new_entry(entry, lines_list[cy]))
3526 string_free(lines_list[cy]);
3528 if (IS_FLG(FLG_UNIDENTIFIED))
3530 REM_FLG(FLG_UNIDENTIFIED);
3531 ADD_FLG(FLG_UNAWARE);
3532 REM_FLG(FLG_IDENTIFIED);
3533 REM_FLG(FLG_STAR_IDENTIFIED);
3535 else if (IS_FLG(FLG_UNAWARE))
3537 REM_FLG(FLG_UNIDENTIFIED);
3538 REM_FLG(FLG_UNAWARE);
3539 ADD_FLG(FLG_IDENTIFIED);
3540 REM_FLG(FLG_STAR_IDENTIFIED);
3542 else if (IS_FLG(FLG_STAR_IDENTIFIED))
3544 REM_FLG(FLG_UNIDENTIFIED);
3545 REM_FLG(FLG_UNAWARE);
3546 REM_FLG(FLG_IDENTIFIED);
3547 REM_FLG(FLG_STAR_IDENTIFIED);
3549 else if (IS_FLG(FLG_IDENTIFIED))
3551 REM_FLG(FLG_UNIDENTIFIED);
3552 REM_FLG(FLG_UNAWARE);
3553 REM_FLG(FLG_IDENTIFIED);
3554 ADD_FLG(FLG_STAR_IDENTIFIED);
3558 ADD_FLG(FLG_UNIDENTIFIED);
3559 REM_FLG(FLG_UNAWARE);
3560 REM_FLG(FLG_IDENTIFIED);
3561 REM_FLG(FLG_STAR_IDENTIFIED);
3564 lines_list[cy] = autopick_line_from_entry_kill(entry);
3571 while (cy < upper + hgt-4 && lines_list[cy + 1])
3576 /* Toggle 'worthless' */
3577 toggle_string(lines_list, FLG_WORTHLESS, cy);
3582 /* Rotate within nameless, ego, artifact */
3583 if (!autopick_new_entry(entry, lines_list[cy]))
3585 string_free(lines_list[cy]);
3587 if (IS_FLG(FLG_NAMELESS))
3589 REM_FLG(FLG_NAMELESS);
3591 REM_FLG(FLG_ARTIFACT);
3593 else if (IS_FLG(FLG_EGO))
3595 REM_FLG(FLG_NAMELESS);
3597 ADD_FLG(FLG_ARTIFACT);
3599 else if (IS_FLG(FLG_ARTIFACT))
3601 REM_FLG(FLG_NAMELESS);
3603 REM_FLG(FLG_ARTIFACT);
3607 ADD_FLG(FLG_NAMELESS);
3609 REM_FLG(FLG_ARTIFACT);
3612 lines_list[cy] = autopick_line_from_entry_kill(entry);
3619 /* Paste killed text */
3620 if (strlen(yank_buf))
3624 for (j = 0; yank_buf[j]; j += strlen(yank_buf + j) + 1)
3626 if (ret && '\n' == yank_buf[j])
3632 /* Split current line */
3633 insert_return_code(lines_list, cx, cy);
3635 /* Save preceding string */
3636 for(i = 0; lines_list[cy][i]; i++)
3637 buf[i] = lines_list[cy][i];
3639 /* Paste yank buffer */
3640 if ('\n' != yank_buf[j])
3643 while (yank_buf[k] && i < MAX_LINELEN-1)
3644 buf[i++] = yank_buf[k++];
3650 string_free(lines_list[cy]);
3651 lines_list[cy] = string_make(buf);
3653 /* Move to the beggining of next line */
3659 dirty_flags |= DIRTY_ALL;
3663 /* Toggle 'collecting' */
3664 toggle_string(lines_list, FLG_COLLECTING, cy);
3670 /* Kill rest of line */
3671 if ((uint)cx > strlen(lines_list[cy]))
3672 cx = (int)strlen(lines_list[cy]);
3674 /* Save preceding string */
3675 for (i = 0; lines_list[cy][i] && i < cx; i++)
3678 if (iskanji(lines_list[cy][i]))
3680 buf[i] = lines_list[cy][i];
3684 buf[i] = lines_list[cy][i];
3691 j += strlen(yank_buf + j) + 1;
3693 /* Copy following to yank buffer */
3694 if (lines_list[cy][i])
3696 while (lines_list[cy][i] && j < MAX_YANK - 2)
3697 yank_buf[j++] = lines_list[cy][i++];
3702 if (j < MAX_YANK - 2)
3703 yank_buf[j++] = '\n';
3706 yank_buf[j++] = '\0';
3709 /* Replace current line with 'preceding string' */
3710 string_free(lines_list[cy]);
3711 lines_list[cy] = string_make(buf);
3723 /* DELETE == go forward + BACK SPACE */
3725 if (iskanji(lines_list[cy][cx])) cx++;
3733 len = strlen(lines_list[cy]);
3736 if (lines_list[cy + 1])
3750 /* delete a return code and union two lines */
3752 cx = strlen(lines_list[cy-1]);
3753 strcpy(buf, lines_list[cy-1]);
3754 strcat(buf, lines_list[cy]);
3755 string_free(lines_list[cy-1]);
3756 string_free(lines_list[cy]);
3757 lines_list[cy-1] = string_make(buf);
3758 for (i = cy; lines_list[i+1]; i++)
3759 lines_list[i] = lines_list[i+1];
3760 lines_list[i] = NULL;
3764 dirty_flags |= DIRTY_ALL;
3768 for (i = j = k = 0; lines_list[cy][i] && i < cx; i++)
3772 if (iskanji(lines_list[cy][i]))
3773 buf[j++] = lines_list[cy][i++];
3775 buf[j++] = lines_list[cy][i];
3782 for (; lines_list[cy][i]; i++)
3783 buf[j++] = lines_list[cy][i];
3785 string_free(lines_list[cy]);
3786 lines_list[cy] = string_make(buf);
3795 /* Restore the screen */
3798 switch (filename_mode)
3802 strcpy(buf, "picktype.prf");
3804 strcpy(buf, "pickpref.prf");
3810 sprintf(buf, "picktype-%s.prf", player_name);
3812 sprintf(buf, "pickpref-%s.prf", player_name);
3817 write_text_lines(buf, lines_list);
3818 free_text_lines(lines_list);
3820 string_free(last_destroyed);
3822 /* Reload autopick pref */
3823 process_pickpref_file(buf);
3825 /* HACK -- reset start_time so that playtime is not increase while edit */
3826 start_time = time(NULL);