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;
937 if (o_ptr->tval == TV_GOLD) return FALSE;
946 void auto_inscribe_item(int item, int idx)
950 /* Get the item (in the pack) */
951 if (item >= 0) o_ptr = &inventory[item];
953 /* Get the item (on the floor) */
954 else o_ptr = &o_list[0 - item];
956 /* Auto-inscription or Re-inscribe for resistances {%} */
957 if ((idx < 0 || !autopick_list[idx].insc) && !o_ptr->inscription)
960 if (o_ptr->inscription)
961 o_ptr->inscription = inscribe_flags(o_ptr, quark_str(o_ptr->inscription));
963 o_ptr->inscription = inscribe_flags(o_ptr, autopick_list[idx].insc);
965 if (item > INVEN_PACK)
967 /* Redraw inscription */
968 p_ptr->window |= (PW_EQUIP);
970 /* {.} and {$} effect p_ptr->warning and TRC_TELEPORT_SELF */
971 p_ptr->update |= (PU_BONUS);
975 /* Redraw inscription */
976 p_ptr->window |= (PW_INVEN);
982 * Automatically destroy an item if it is to be destroyed
984 bool auto_destroy_item(int item, int autopick_idx)
986 bool destroy = FALSE;
989 /* Don't destroy equipped items */
990 if (item > INVEN_PACK) return FALSE;
992 /* Get the item (in the pack) */
993 if (item >= 0) o_ptr = &inventory[item];
995 /* Get the item (on the floor) */
996 else o_ptr = &o_list[0 - item];
998 /* Easy-Auto-Destroyer */
999 if (is_opt_confirm_destroy(o_ptr)) destroy = TRUE;
1001 /* Protected by auto-picker */
1002 if (autopick_idx >= 0 &&
1003 !(autopick_list[autopick_idx].action & DO_AUTODESTROY))
1008 /* Auto-picker/destroyer */
1009 if (autopick_idx >= 0 &&
1010 (autopick_list[autopick_idx].action & DO_AUTODESTROY))
1014 /* Not to be destroyed */
1015 if (!destroy) return FALSE;
1017 /* Now decided to destroy */
1022 if (!can_player_destroy_object(o_ptr))
1024 char o_name[MAX_NLEN];
1026 /* Describe the object (with {terrible/special}) */
1027 object_desc(o_name, o_ptr, TRUE, 3);
1031 msg_format("%s¤ÏÇ˲õÉÔǽ¤À¡£", o_name);
1033 msg_format("You cannot auto-destroy %s.", o_name);
1040 /* Record name of destroyed item */
1041 COPY(&autopick_last_destroyed_object, o_ptr, object_type);
1044 o_ptr->marked |= OM_AUTODESTROY;
1045 p_ptr->notice |= PN_AUTODESTROY;
1052 * Auto-destroy marked item
1054 static void delayed_auto_destroy_aux(int item)
1058 /* Get the item (in the pack) */
1059 if (item >= 0) o_ptr = &inventory[item];
1061 /* Get the item (on the floor) */
1062 else o_ptr = &o_list[0 - item];
1064 if (o_ptr->k_idx && o_ptr->marked & OM_AUTODESTROY)
1066 char o_name[MAX_NLEN];
1068 /* Describe the object (with {terrible/special}) */
1069 object_desc(o_name, o_ptr, TRUE, 3);
1071 /* Eliminate the item (from the pack) */
1074 inven_item_increase(item, -(o_ptr->number));
1075 inven_item_optimize(item);
1078 /* Eliminate the item (from the floor) */
1081 delete_object_idx(0 - item);
1084 /* Print a message */
1086 msg_format("%s¤ò¼«Æ°Ç˲õ¤·¤Þ¤¹¡£", o_name);
1088 msg_format("Auto-destroying %s.", o_name);
1095 * Auto-destroy marked item in inventry and on floor
1097 void delayed_auto_destroy(void)
1102 * Scan inventry in reverse order to prevent
1103 * skipping after inven_item_optimize()
1105 for (item = INVEN_TOTAL; item >= 0 ; item--)
1106 delayed_auto_destroy_aux(item);
1108 /* Scan the pile of objects */
1109 item = cave[py][px].o_idx;
1112 int next = o_list[item].next_o_idx;
1113 delayed_auto_destroy_aux(-item);
1120 * Automatically pickup/destroy items in this grid.
1122 void auto_pickup_items(cave_type *c_ptr)
1124 s16b this_o_idx, next_o_idx = 0;
1126 /* Scan the pile of objects */
1127 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
1131 /* Acquire object */
1132 object_type *o_ptr = &o_list[this_o_idx];
1134 /* Acquire next object */
1135 next_o_idx = o_ptr->next_o_idx;
1137 idx = is_autopick(o_ptr);
1139 /* Item index for floor -1,-2,-3,... */
1140 auto_inscribe_item((-this_o_idx), idx);
1143 (autopick_list[idx].action & (DO_AUTOPICK | DO_QUERY_AUTOPICK)))
1147 if (!inven_carry_okay(o_ptr))
1149 char o_name[MAX_NLEN];
1151 /* Describe the object */
1152 object_desc(o_name, o_ptr, TRUE, 3);
1156 msg_format("¥¶¥Ã¥¯¤Ë¤Ï%s¤òÆþ¤ì¤ë·ä´Ö¤¬¤Ê¤¤¡£", o_name);
1158 msg_format("You have no room for %s.", o_name);
1160 /* Hack - remember that the item has given a message here. */
1161 o_ptr->marked |= OM_NOMSG;
1165 else if (autopick_list[idx].action & DO_QUERY_AUTOPICK)
1167 char out_val[MAX_NLEN+20];
1168 char o_name[MAX_NLEN];
1170 if (o_ptr->marked & OM_NO_QUERY)
1172 /* Already answered as 'No' */
1176 /* Describe the object */
1177 object_desc(o_name, o_ptr, TRUE, 3);
1180 sprintf(out_val, "%s¤ò½¦¤¤¤Þ¤¹¤«? ", o_name);
1182 sprintf(out_val, "Pick up %s? ", o_name);
1185 if (!get_check(out_val))
1187 /* Hack - remember that the item has given a message here. */
1188 o_ptr->marked |= (OM_NOMSG | OM_NO_QUERY);
1193 py_pickup_aux(this_o_idx);
1200 * When always_pickup is 'yes', we disable
1201 * auto-destroyer from autopick function, and do only
1202 * easy-auto-destroyer.
1206 if (auto_destroy_item((-this_o_idx), idx))
1214 * Describe which kind of object is Auto-picked/destroyed
1216 static void describe_autopick(char *buff, autopick_type *entry)
1218 cptr str = entry->name;
1219 byte act = entry->action;
1220 cptr insc = entry->insc;
1226 cptr before_str[100], body_str;
1229 body_str = "¥¢¥¤¥Æ¥à";
1231 /*** Collecting items ***/
1232 /*** Which can be absorbed into a slot as a bundle ***/
1233 if (IS_FLG(FLG_COLLECTING))
1234 before_str[before_n++] = "¼ý½¸Ãæ¤Ç´û¤Ë»ý¤Ã¤Æ¤¤¤ë¥¹¥í¥Ã¥È¤Ë¤Þ¤È¤á¤é¤ì¤ë";
1236 /*** Unidentified ***/
1237 if (IS_FLG(FLG_UNIDENTIFIED))
1238 before_str[before_n++] = "̤´ÕÄê¤Î";
1240 /*** Identified ***/
1241 if (IS_FLG(FLG_IDENTIFIED))
1242 before_str[before_n++] = "´ÕÄêºÑ¤ß¤Î";
1244 /*** *Identified* ***/
1245 if (IS_FLG(FLG_STAR_IDENTIFIED))
1246 before_str[before_n++] = "´°Á´¤Ë´ÕÄêºÑ¤ß¤Î";
1248 /*** Dice boosted (weapon of slaying) ***/
1249 if (IS_FLG(FLG_BOOSTED))
1251 before_str[before_n++] = "¥À¥á¡¼¥¸¥À¥¤¥¹¤¬Ä̾ï¤è¤êÂ礤¤";
1255 /*** Weapons whose dd*ds is more than nn ***/
1256 if (IS_FLG(FLG_MORE_THAN))
1258 static char more_than_desc_str[] = "___";
1259 before_str[before_n++] = "¥À¥á¡¼¥¸¥À¥¤¥¹¤ÎºÇÂçÃͤ¬";
1262 sprintf(more_than_desc_str,"%d", entry->dice);
1263 before_str[before_n++] = more_than_desc_str;
1264 before_str[before_n++] = "°Ê¾å¤Î";
1267 /*** Items whose magical bonus is more than nn ***/
1268 if (IS_FLG(FLG_MORE_BONUS))
1270 static char more_bonus_desc_str[] = "___";
1271 before_str[before_n++] = "½¤ÀµÃͤ¬(+";
1273 sprintf(more_bonus_desc_str,"%d", entry->bonus);
1274 before_str[before_n++] = more_bonus_desc_str;
1275 before_str[before_n++] = ")°Ê¾å¤Î";
1278 /*** Worthless items ***/
1279 if (IS_FLG(FLG_WORTHLESS))
1280 before_str[before_n++] = "Ź¤Ç̵²ÁÃͤÈȽÄꤵ¤ì¤ë";
1283 if (IS_FLG(FLG_ARTIFACT))
1285 before_str[before_n++] = "¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤Î";
1290 if (IS_FLG(FLG_EGO))
1292 before_str[before_n++] = "¥¨¥´¥¢¥¤¥Æ¥à¤Î";
1297 if (IS_FLG(FLG_NAMELESS))
1299 before_str[before_n++] = "¥¨¥´¤Ç¤â¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤Ç¤â¤Ê¤¤";
1303 /*** Unaware items ***/
1304 if (IS_FLG(FLG_UNAWARE))
1305 before_str[before_n++] = "̤´ÕÄê¤Ç¤½¤Î¸ú²Ì¤âȽÌÀ¤·¤Æ¤¤¤Ê¤¤";
1307 /*** Wanted monster's corpse/skeletons ***/
1308 if (IS_FLG(FLG_WANTED))
1310 before_str[before_n++] = "¥Ï¥ó¥¿¡¼»ö̳½ê¤Ç¾Þ¶â¼ó¤È¤µ¤ì¤Æ¤¤¤ë";
1311 body_str = "»àÂΤä¹ü";
1314 /*** Human corpse/skeletons (for Daemon magic) ***/
1315 if (IS_FLG(FLG_HUMAN))
1317 before_str[before_n++] = "°ËâËâË¡¤Ç»È¤¦¤¿¤á¤Î¿Í´Ö¤ä¥Ò¥å¡¼¥Þ¥Î¥¤¥É¤Î";
1318 body_str = "»àÂΤä¹ü";
1321 /*** Unique monster's corpse/skeletons/statues ***/
1322 if (IS_FLG(FLG_UNIQUE))
1324 before_str[before_n++] = "¥æ¥Ë¡¼¥¯¥â¥ó¥¹¥¿¡¼¤Î";
1325 body_str = "»àÂΤä¹ü";
1328 /*** Unreadable spellbooks ***/
1329 if (IS_FLG(FLG_UNREADABLE))
1331 before_str[before_n++] = "¤¢¤Ê¤¿¤¬Æɤá¤Ê¤¤Îΰè¤Î";
1332 body_str = "ËâË¡½ñ";
1335 /*** First realm spellbooks ***/
1336 if (IS_FLG(FLG_REALM1))
1338 before_str[before_n++] = "Âè°ìÎΰè¤Î";
1339 body_str = "ËâË¡½ñ";
1342 /*** Second realm spellbooks ***/
1343 if (IS_FLG(FLG_REALM2))
1345 before_str[before_n++] = "ÂèÆóÎΰè¤Î";
1346 body_str = "ËâË¡½ñ";
1349 /*** First rank spellbooks ***/
1350 if (IS_FLG(FLG_FIRST))
1352 before_str[before_n++] = "Á´4ºý¤ÎÆâ¤Î1ºýÌܤÎ";
1353 body_str = "ËâË¡½ñ";
1356 /*** Second rank spellbooks ***/
1357 if (IS_FLG(FLG_SECOND))
1359 before_str[before_n++] = "Á´4ºý¤ÎÆâ¤Î2ºýÌܤÎ";
1360 body_str = "ËâË¡½ñ";
1363 /*** Third rank spellbooks ***/
1364 if (IS_FLG(FLG_THIRD))
1366 before_str[before_n++] = "Á´4ºý¤ÎÆâ¤Î3ºýÌܤÎ";
1367 body_str = "ËâË¡½ñ";
1370 /*** Fourth rank spellbooks ***/
1371 if (IS_FLG(FLG_FOURTH))
1373 before_str[before_n++] = "Á´4ºý¤ÎÆâ¤Î4ºýÌܤÎ";
1374 body_str = "ËâË¡½ñ";
1378 if (IS_FLG(FLG_ITEMS))
1379 ; /* Nothing to do */
1380 else if (IS_FLG(FLG_WEAPONS))
1382 else if (IS_FLG(FLG_ARMORS))
1384 else if (IS_FLG(FLG_MISSILES))
1385 body_str = "ÃƤäÌð¤ä¥¯¥í¥¹¥Ü¥¦¤ÎÌð";
1386 else if (IS_FLG(FLG_DEVICES))
1387 body_str = "´¬Êª¤äËâË¡ËÀ¤ä¾ó¤ä¥í¥Ã¥É";
1388 else if (IS_FLG(FLG_LIGHTS))
1389 body_str = "¸÷¸»ÍѤΥ¢¥¤¥Æ¥à";
1390 else if (IS_FLG(FLG_JUNKS))
1391 body_str = "Àޤ줿ËÀÅù¤Î¥¬¥é¥¯¥¿";
1392 else if (IS_FLG(FLG_SPELLBOOKS))
1393 body_str = "ËâË¡½ñ";
1394 else if (IS_FLG(FLG_HAFTED))
1396 else if (IS_FLG(FLG_SHIELDS))
1398 else if (IS_FLG(FLG_BOWS))
1399 body_str = "¥¹¥ê¥ó¥°¤äµÝ¤ä¥¯¥í¥¹¥Ü¥¦";
1400 else if (IS_FLG(FLG_RINGS))
1402 else if (IS_FLG(FLG_AMULETS))
1403 body_str = "¥¢¥ß¥å¥ì¥Ã¥È";
1404 else if (IS_FLG(FLG_SUITS))
1406 else if (IS_FLG(FLG_CLOAKS))
1407 body_str = "¥¯¥í¡¼¥¯";
1408 else if (IS_FLG(FLG_HELMS))
1409 body_str = "¥Ø¥ë¥á¥Ã¥È¤ä´§";
1410 else if (IS_FLG(FLG_GLOVES))
1412 else if (IS_FLG(FLG_BOOTS))
1413 body_str = "¥Ö¡¼¥Ä";
1417 strcat(buff, "Á´¤Æ¤Î");
1418 else for (i = 0; i < before_n && before_str[i]; i++)
1419 strcat(buff, before_str[i]);
1421 strcat(buff, body_str);
1431 strcat(buff, "¤Ç¡¢Ì¾Á°¤¬¡Ö");
1432 strncat(buff, str, 80);
1434 strcat(buff, "¡×¤Ç»Ï¤Þ¤ë¤â¤Î");
1436 strcat(buff, "¡×¤ò´Þ¤à¤â¤Î");
1441 strncat(buff, format("¤Ë¡Ö%s¡×", insc), 80);
1443 if (strstr(insc, "%%all"))
1444 strcat(buff, "(%%all¤ÏÁ´Ç½ÎϤòɽ¤¹±Ñ»ú¤Îµ¹æ¤ÇÃÖ´¹)");
1445 else if (strstr(insc, "%all"))
1446 strcat(buff, "(%all¤ÏÁ´Ç½ÎϤòɽ¤¹µ¹æ¤ÇÃÖ´¹)");
1447 else if (strstr(insc, "%%"))
1448 strcat(buff, "(%%¤ÏÄɲÃǽÎϤòɽ¤¹±Ñ»ú¤Îµ¹æ¤ÇÃÖ´¹)");
1449 else if (strstr(insc, "%"))
1450 strcat(buff, "(%¤ÏÄɲÃǽÎϤòɽ¤¹µ¹æ¤ÇÃÖ´¹)");
1452 strcat(buff, "¤È¹ï¤ó¤Ç");
1457 if (act & DONT_AUTOPICK)
1458 strcat(buff, "ÊüÃÖ¤¹¤ë¡£");
1459 else if (act & DO_AUTODESTROY)
1460 strcat(buff, "Ç˲õ¤¹¤ë¡£");
1461 else if (act & DO_QUERY_AUTOPICK)
1462 strcat(buff, "³Îǧ¤Î¸å¤Ë½¦¤¦¡£");
1464 strcat(buff, "½¦¤¦¡£");
1466 if (act & DO_DISPLAY)
1468 if (act & DONT_AUTOPICK)
1469 strcat(buff, "Á´ÂΥޥå×('M')¤Ç'N'¤ò²¡¤·¤¿¤È¤¤Ëɽ¼¨¤¹¤ë¡£");
1470 else if (act & DO_AUTODESTROY)
1471 strcat(buff, "Á´ÂΥޥå×('M')¤Ç'K'¤ò²¡¤·¤¿¤È¤¤Ëɽ¼¨¤¹¤ë¡£");
1473 strcat(buff, "Á´ÂΥޥå×('M')¤Ç'M'¤ò²¡¤·¤¿¤È¤¤Ëɽ¼¨¤¹¤ë¡£");
1476 strcat(buff, "Á´ÂΥޥåפˤÏɽ¼¨¤·¤Ê¤¤");
1480 cptr before_str[20], after_str[20], which_str[20], whose_str[20], body_str;
1481 int before_n = 0, after_n = 0, which_n = 0, whose_n = 0;
1485 /*** Collecting items ***/
1486 /*** Which can be absorbed into a slot as a bundle ***/
1487 if (IS_FLG(FLG_COLLECTING))
1488 which_str[which_n++] = "can be absorbed into an existing inventory slot";
1490 /*** Unidentified ***/
1491 if (IS_FLG(FLG_UNIDENTIFIED))
1492 before_str[before_n++] = "unidentified";
1494 /*** Identified ***/
1495 if (IS_FLG(FLG_IDENTIFIED))
1496 before_str[before_n++] = "identified";
1498 /*** *Identified* ***/
1499 if (IS_FLG(FLG_STAR_IDENTIFIED))
1500 before_str[before_n++] = "fully identified";
1502 /*** Worthless items ***/
1503 if (IS_FLG(FLG_WORTHLESS))
1505 before_str[before_n++] = "worthless";
1506 which_str[which_n++] = "can not be sold at stores";
1510 if (IS_FLG(FLG_ARTIFACT))
1512 before_str[before_n++] = "artifact";
1516 if (IS_FLG(FLG_EGO))
1518 before_str[before_n++] = "ego";
1522 if (IS_FLG(FLG_NAMELESS))
1524 body_str = "equipment";
1525 which_str[which_n++] = "is neither ego-item nor artifact";
1528 /*** Unaware items ***/
1529 if (IS_FLG(FLG_UNAWARE))
1531 before_str[before_n++] = "unidentified";
1532 whose_str[whose_n++] = "basic abilities are not known";
1535 /*** Dice boosted (weapon of slaying) ***/
1536 if (IS_FLG(FLG_BOOSTED))
1538 body_str = "weapons";
1539 whose_str[whose_n++] = "damage dice is bigger than normal";
1542 /*** Weapons whose dd*ds is more than nn ***/
1543 if (IS_FLG(FLG_MORE_THAN))
1545 static char more_than_desc_str[] =
1546 "maximum damage from dice is bigger than __";
1547 body_str = "weapons";
1549 sprintf(more_than_desc_str + sizeof(more_than_desc_str) - 3,
1551 whose_str[whose_n++] = more_than_desc_str;
1554 /*** Items whose magical bonus is more than nn ***/
1555 if (IS_FLG(FLG_MORE_BONUS))
1557 static char more_bonus_desc_str[] =
1558 "magical bonus is bigger than (+__)";
1560 sprintf(more_bonus_desc_str + sizeof(more_bonus_desc_str) - 4,
1561 "%d)", entry->bonus);
1562 whose_str[whose_n++] = more_bonus_desc_str;
1565 /*** Wanted monster's corpse/skeletons ***/
1566 if (IS_FLG(FLG_WANTED))
1568 body_str = "corpse or skeletons";
1569 which_str[which_n++] = "is wanted at the Hunter's Office";
1572 /*** Human corpse/skeletons (for Daemon magic) ***/
1573 if (IS_FLG(FLG_HUMAN))
1575 before_str[before_n++] = "humanoid";
1576 body_str = "corpse or skeletons";
1577 which_str[which_n++] = "can be used for Daemon magic";
1580 /*** Unique monster's corpse/skeletons/statues ***/
1581 if (IS_FLG(FLG_UNIQUE))
1583 before_str[before_n++] = "unique monster's";
1584 body_str = "corpse or skeletons";
1587 /*** Unreadable spellbooks ***/
1588 if (IS_FLG(FLG_UNREADABLE))
1590 body_str = "spellbooks";
1591 after_str[after_n++] = "of different realms from yours";
1594 /*** First realm spellbooks ***/
1595 if (IS_FLG(FLG_REALM1))
1597 body_str = "spellbooks";
1598 after_str[after_n++] = "of your first realm";
1601 /*** Second realm spellbooks ***/
1602 if (IS_FLG(FLG_REALM2))
1604 body_str = "spellbooks";
1605 after_str[after_n++] = "of your second realm";
1608 /*** First rank spellbooks ***/
1609 if (IS_FLG(FLG_FIRST))
1611 before_str[before_n++] = "first one of four";
1612 body_str = "spellbooks";
1615 /*** Second rank spellbooks ***/
1616 if (IS_FLG(FLG_SECOND))
1618 before_str[before_n++] = "second one of four";
1619 body_str = "spellbooks";
1622 /*** Third rank spellbooks ***/
1623 if (IS_FLG(FLG_THIRD))
1625 before_str[before_n++] = "third one of four";
1626 body_str = "spellbooks";
1629 /*** Fourth rank spellbooks ***/
1630 if (IS_FLG(FLG_FOURTH))
1632 before_str[before_n++] = "fourth one of four";
1633 body_str = "spellbooks";
1637 if (IS_FLG(FLG_ITEMS))
1638 ; /* Nothing to do */
1639 else if (IS_FLG(FLG_WEAPONS))
1640 body_str = "weapons";
1641 else if (IS_FLG(FLG_ARMORS))
1642 body_str = "armors";
1643 else if (IS_FLG(FLG_MISSILES))
1644 body_str = "shots, arrows or crossbow bolts";
1645 else if (IS_FLG(FLG_DEVICES))
1646 body_str = "scrolls, wands, staves or rods";
1647 else if (IS_FLG(FLG_LIGHTS))
1648 body_str = "light sources";
1649 else if (IS_FLG(FLG_JUNKS))
1650 body_str = "junk such as broken sticks";
1651 else if (IS_FLG(FLG_SPELLBOOKS))
1652 body_str = "spellbooks";
1653 else if (IS_FLG(FLG_HAFTED))
1654 body_str = "hafted weapons";
1655 else if (IS_FLG(FLG_SHIELDS))
1656 body_str = "shields";
1657 else if (IS_FLG(FLG_BOWS))
1658 body_str = "slings, bows or crossbows";
1659 else if (IS_FLG(FLG_RINGS))
1661 else if (IS_FLG(FLG_AMULETS))
1662 body_str = "amulets";
1663 else if (IS_FLG(FLG_SUITS))
1664 body_str = "body armors";
1665 else if (IS_FLG(FLG_CLOAKS))
1666 body_str = "cloaks";
1667 else if (IS_FLG(FLG_HELMS))
1668 body_str = "helms or crowns";
1669 else if (IS_FLG(FLG_GLOVES))
1670 body_str = "gloves";
1671 else if (IS_FLG(FLG_BOOTS))
1674 /* Prepare a string for item name */
1681 whose_str[whose_n++] = "name is beginning with \"";
1684 which_str[which_n++] = "have \"";
1688 /* Describe action flag */
1689 if (act & DONT_AUTOPICK)
1690 strcpy(buff, "Leave on floor ");
1691 else if (act & DO_AUTODESTROY)
1692 strcpy(buff, "Destroy ");
1693 else if (act & DO_QUERY_AUTOPICK)
1694 strcpy(buff, "Ask to pick up ");
1696 strcpy(buff, "Pickup ");
1698 /* Auto-insctiption */
1701 strncat(buff, format("and inscribe \"%s\"", insc), 80);
1703 if (strstr(insc, "%all"))
1704 strcat(buff, ", replacing %all with code string representing all abilities,");
1705 else if (strstr(insc, "%"))
1706 strcat(buff, ", replacing % with code string representing extra random abilities,");
1708 strcat(buff, " on ");
1713 strcat(buff, "all ");
1714 else for (i = 0; i < before_n && before_str[i]; i++)
1716 strcat(buff, before_str[i]);
1721 strcat(buff, body_str);
1724 for (i = 0; i < after_n && after_str[i]; i++)
1727 strcat(buff, after_str[i]);
1731 for (i = 0; i < whose_n && whose_str[i]; i++)
1734 strcat(buff, " whose ");
1736 strcat(buff, ", and ");
1738 strcat(buff, whose_str[i]);
1741 /* Item name ; whose name is beginning with "str" */
1748 /* whose ..., and which .... */
1749 if (whose_n && which_n)
1750 strcat(buff, ", and ");
1753 for (i = 0; i < which_n && which_str[i]; i++)
1756 strcat(buff, " which ");
1758 strcat(buff, ", and ");
1760 strcat(buff, which_str[i]);
1763 /* Item name ; which have "str" as part of its name */
1766 strncat(buff, str, 80);
1767 strcat(buff, "\" as part of its name");
1771 /* Describe whether it will be displayed on the full map or not */
1772 if (act & DO_DISPLAY)
1774 if (act & DONT_AUTOPICK)
1775 strcat(buff, " Display these items when you press the N key in the full 'M'ap.");
1776 else if (act & DO_AUTODESTROY)
1777 strcat(buff, " Display these items when you press the K key in the full 'M'ap.");
1779 strcat(buff, " Display these items when you press the M key in the full 'M'ap.");
1782 strcat(buff, " Not displayed in the full map.");
1788 #define MAX_LINES 3000
1791 * Read whole lines of a file to memory
1793 static cptr *read_text_lines(cptr filename, bool user)
1795 cptr *lines_list = NULL;
1803 /* Hack -- drop permissions */
1805 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, filename);
1809 path_build(buf, sizeof(buf), ANGBAND_DIR_PREF, filename);
1813 fff = my_fopen(buf, "r");
1817 /* Allocate list of pointers */
1818 C_MAKE(lines_list, MAX_LINES, cptr);
1821 while (0 == my_fgets(fff, buf, sizeof(buf)))
1823 lines_list[lines++] = string_make(buf);
1824 if (lines >= MAX_LINES - 1) break;
1827 lines_list[0] = string_make("");
1835 if (!fff) return NULL;
1840 #define PT_DEFAULT 0
1841 #define PT_WITH_PNAME 1
1843 static cptr *read_pickpref_text_lines(int *filename_mode_p)
1849 sprintf(buf, "picktype-%s.prf", player_name);
1851 sprintf(buf, "pickpref-%s.prf", player_name);
1853 lines_list = read_text_lines(buf, TRUE);
1858 lines_list = read_text_lines("picktype.prf", TRUE);
1860 lines_list = read_text_lines("pickpref.prf", TRUE);
1862 *filename_mode_p = PT_DEFAULT;
1868 lines_list = read_text_lines("picktype.prf", FALSE);
1870 lines_list = read_text_lines("pickpref.prf", FALSE);
1872 *filename_mode_p = PT_WITH_PNAME;
1877 /* Allocate list of pointers */
1878 C_MAKE(lines_list, MAX_LINES, cptr);
1879 lines_list[0] = string_make("");
1880 *filename_mode_p = PT_WITH_PNAME;
1886 * Write whole lines of memory to a file.
1888 static bool write_text_lines(cptr filename, cptr *lines_list)
1895 /* Hack -- drop permissions */
1898 /* Build the filename */
1899 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, filename);
1902 fff = my_fopen(buf, "w");
1905 for (lines = 0; lines_list[lines]; lines++)
1906 my_fputs(fff, lines_list[lines], 1024);
1914 if (!fff) return FALSE;
1920 * Free memory of lines_list.
1922 static void free_text_lines(cptr *lines_list)
1926 for (lines = 0; lines_list[lines]; lines++)
1927 string_free(lines_list[lines]);
1929 /* free list of pointers */
1930 C_FREE((char **)lines_list, MAX_LINES, char *);
1935 * Delete or insert string
1937 static void toggle_string(cptr *lines_list, int flg, int y)
1939 autopick_type an_entry, *entry = &an_entry;
1941 if (!autopick_new_entry(entry, lines_list[y]))
1944 string_free(lines_list[y]);
1950 lines_list[y] = autopick_line_from_entry_kill(entry);
1954 * Insert return code and split the line
1956 static bool insert_return_code(cptr *lines_list, int cx, int cy)
1958 char buf[MAX_LINELEN];
1961 for (k = 0; lines_list[k]; k++)
1962 /* count number of lines */ ;
1964 if (k >= MAX_LINES - 2) return FALSE;
1967 /* Move down lines */
1969 lines_list[k+1] = lines_list[k];
1971 /* Split current line */
1972 for (i = j = 0; lines_list[cy][i] && i < cx; i++)
1975 if (iskanji(lines_list[cy][i]))
1976 buf[j++] = lines_list[cy][i++];
1978 buf[j++] = lines_list[cy][i];
1981 lines_list[cy+1] = string_make(&lines_list[cy][i]);
1982 string_free(lines_list[cy]);
1983 lines_list[cy] = string_make(buf);
1989 * Get auto-picker entry from o_ptr.
1991 void autopick_entry_from_object(autopick_type *entry, object_type *o_ptr)
1993 char o_name[MAX_NLEN];
1994 object_desc(o_name, o_ptr, FALSE, 0);
1996 entry->name = string_make(o_name);
1997 entry->insc = string_make(quark_str(o_ptr->inscription));
1998 entry->action = DO_AUTOPICK | DO_DISPLAY;
1999 entry->flag[0] = entry->flag[1] = 0L;
2002 if (!object_aware_p(o_ptr))
2003 ADD_FLG(FLG_UNAWARE);
2004 if (object_value(o_ptr) <= 0)
2005 ADD_FLG(FLG_WORTHLESS);
2007 if (object_known_p(o_ptr))
2011 else if (o_ptr->name1 || o_ptr->art_name)
2012 ADD_FLG(FLG_ARTIFACT);
2018 case TV_HAFTED: case TV_POLEARM: case TV_SWORD: case TV_DIGGING:
2019 k_ptr = &k_info[o_ptr->k_idx];
2020 if ((o_ptr->dd != k_ptr->dd) || (o_ptr->ds != k_ptr->ds))
2021 ADD_FLG(FLG_BOOSTED);
2024 if (o_ptr->tval == TV_CORPSE && object_is_shoukinkubi(o_ptr))
2026 REM_FLG(FLG_WORTHLESS);
2027 ADD_FLG(FLG_WANTED);
2030 if ((o_ptr->tval == TV_CORPSE || o_ptr->tval == TV_STATUE)
2031 && (r_info[o_ptr->pval].flags1 & RF1_UNIQUE))
2033 REM_FLG(FLG_WORTHLESS);
2034 ADD_FLG(FLG_UNIQUE);
2037 if (o_ptr->tval == TV_CORPSE && strchr("pht", r_info[o_ptr->pval].d_char))
2039 REM_FLG(FLG_WORTHLESS);
2043 if (o_ptr->tval >= TV_LIFE_BOOK &&
2044 !check_book_realm(o_ptr->tval, o_ptr->sval))
2045 ADD_FLG(FLG_UNREADABLE);
2047 if (REALM1_BOOK == o_ptr->tval &&
2048 p_ptr->pclass != CLASS_SORCERER &&
2049 p_ptr->pclass != CLASS_RED_MAGE)
2050 ADD_FLG(FLG_REALM1);
2052 if (REALM2_BOOK == o_ptr->tval &&
2053 p_ptr->pclass != CLASS_SORCERER &&
2054 p_ptr->pclass != CLASS_RED_MAGE)
2055 ADD_FLG(FLG_REALM2);
2057 if (o_ptr->tval >= TV_LIFE_BOOK && 0 == o_ptr->sval)
2059 if (o_ptr->tval >= TV_LIFE_BOOK && 1 == o_ptr->sval)
2060 ADD_FLG(FLG_SECOND);
2061 if (o_ptr->tval >= TV_LIFE_BOOK && 2 == o_ptr->sval)
2063 if (o_ptr->tval >= TV_LIFE_BOOK && 3 == o_ptr->sval)
2064 ADD_FLG(FLG_FOURTH);
2066 if (o_ptr->tval == TV_SHOT || o_ptr->tval == TV_BOLT
2067 || o_ptr->tval == TV_ARROW)
2068 ADD_FLG(FLG_MISSILES);
2069 else if (o_ptr->tval == TV_SCROLL || o_ptr->tval == TV_STAFF
2070 || o_ptr->tval == TV_WAND || o_ptr->tval == TV_ROD)
2071 ADD_FLG(FLG_DEVICES);
2072 else if (o_ptr->tval == TV_LITE)
2073 ADD_FLG(FLG_LIGHTS);
2074 else if (o_ptr->tval == TV_SKELETON || o_ptr->tval == TV_BOTTLE
2075 || o_ptr->tval == TV_JUNK || o_ptr->tval == TV_STATUE)
2077 else if (o_ptr->tval >= TV_LIFE_BOOK)
2078 ADD_FLG(FLG_SPELLBOOKS);
2079 else if (o_ptr->tval == TV_HAFTED)
2080 ADD_FLG(FLG_HAFTED);
2081 else if (o_ptr->tval == TV_POLEARM || o_ptr->tval == TV_SWORD
2082 || o_ptr->tval == TV_DIGGING)
2083 ADD_FLG(FLG_WEAPONS);
2084 else if (o_ptr->tval == TV_SHIELD)
2085 ADD_FLG(FLG_SHIELDS);
2086 else if (o_ptr->tval == TV_BOW)
2088 else if (o_ptr->tval == TV_RING)
2090 else if (o_ptr->tval == TV_AMULET)
2091 ADD_FLG(FLG_AMULETS);
2092 else if (o_ptr->tval == TV_DRAG_ARMOR || o_ptr->tval == TV_HARD_ARMOR ||
2093 o_ptr->tval == TV_SOFT_ARMOR)
2095 else if (o_ptr->tval == TV_CLOAK)
2096 ADD_FLG(FLG_CLOAKS);
2097 else if (o_ptr->tval == TV_HELM)
2099 else if (o_ptr->tval == TV_GLOVES)
2100 ADD_FLG(FLG_GLOVES);
2101 else if (o_ptr->tval == TV_BOOTS)
2109 * Choose an item and get auto-picker entry from it.
2111 static object_type *choose_object(cptr q, cptr s)
2115 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP))) return NULL;
2117 /* Get the item (in the pack) */
2118 if (item >= 0) return &inventory[item];
2120 /* Get the item (on the floor) */
2121 else return &o_list[0 - item];
2126 * Choose an item and get auto-picker entry from it.
2128 static bool entry_from_choosed_object(autopick_type *entry)
2135 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÅÐÏ¿¤·¤Þ¤¹¤«? ";
2136 s = "¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£";
2138 q = "Entry which item? ";
2139 s = "You have nothing to entry.";
2141 o_ptr = choose_object(q, s);
2142 if (!o_ptr) return FALSE;
2144 autopick_entry_from_object(entry, o_ptr);
2150 * Choose an item or string for search
2152 static bool get_string_for_search(object_type **o_handle, cptr *search_strp)
2156 char buf[MAX_NLEN+20];
2159 int k_flag[MAX_NLEN+20];
2160 char prompt[] = "¸¡º÷(^I:»ý¤Áʪ ^L:Ç˲õ¤µ¤ì¤¿Êª): ";
2162 char prompt[] = "Search key(^I:inven ^L:destroyed): ";
2164 int col = sizeof(prompt) - 1;
2166 if (*search_strp) strcpy(buf, *search_strp);
2169 /* Display prompt */
2172 /* Display the default answer */
2173 Term_erase(col, 0, 255);
2174 Term_putstr(col, 0, -1, TERM_YELLOW, buf);
2183 Term_gotoxy(col + pos, 0);
2185 /* Do not process macros except special keys */
2186 inkey_special = TRUE;
2191 /* Analyze the key */
2200 if (!pos && *o_handle) return TRUE;
2201 string_free(*search_strp);
2202 *search_strp = string_make(buf);
2209 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¸¡º÷¤·¤Þ¤¹¤«? ";
2210 s = "¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£";
2212 q = "Entry which item? ";
2213 s = "You have nothing to entry.";
2215 o_ptr = choose_object(q, s);
2216 if (!o_ptr) return FALSE;
2220 string_free(*search_strp);
2221 object_desc(buf, *o_handle, FALSE, 3);
2222 *search_strp = string_make(format("<%s>", buf));
2226 if (!autopick_last_destroyed_object.k_idx) break;
2227 *o_handle = &autopick_last_destroyed_object;
2229 string_free(*search_strp);
2230 object_desc(buf, *o_handle, FALSE, 3);
2231 *search_strp = string_make(format("<%s>", buf));
2240 if (k_flag[pos]) pos--;
2255 if (pos + 1 < MAX_NLEN)
2263 else if (pos < MAX_NLEN && isprint(i))
2270 if (pos < MAX_NLEN && isprint(i)) buf[pos++] = i;
2279 /* Update the entry */
2280 Term_erase(col, 0, 255);
2281 Term_putstr(col, 0, -1, TERM_WHITE, buf);
2289 * Search next line matches for o_ptr
2291 static bool search_for_object(cptr *lines_list, object_type *o_ptr, int *cxp, int *cyp, bool forward)
2294 autopick_type an_entry, *entry = &an_entry;
2295 char o_name[MAX_NLEN];
2297 object_desc(o_name, o_ptr, FALSE, 3);
2299 /* Force to be lower case string */
2300 for (i = 0; o_name[i]; i++)
2303 if (iskanji(o_name[i]))
2307 if (isupper(o_name[i]))
2308 o_name[i] = tolower(o_name[i]);
2317 if (!lines_list[++i]) break;
2324 if (!autopick_new_entry(entry, lines_list[i])) continue;
2326 if (is_autopick_aux(o_ptr, entry, o_name))
2339 * Search next line matches to the string
2341 static bool search_for_string(cptr *lines_list, cptr search_str, int *cxp, int *cyp, bool forward)
2351 if (!lines_list[++i]) break;
2358 pos = strstr_j(lines_list[i], search_str);
2360 pos = strstr(lines_list[i], search_str);
2364 *cxp = (int)(pos - lines_list[i]);
2375 * Initialize auto-picker preference
2377 void init_autopicker(void)
2379 static const char easy_autopick_inscription[] = "(:=g";
2380 autopick_type entry;
2383 /* Clear old entries */
2384 for( i = 0; i < max_autopick; i++)
2385 autopick_free_entry(&autopick_list[i]);
2389 /* There is always one entry "=g" */
2390 autopick_new_entry(&entry, easy_autopick_inscription);
2391 autopick_list[max_autopick++] = entry;
2397 * Process line for auto picker/destroyer.
2399 errr process_pickpref_file_line(char *buf)
2401 autopick_type entry;
2404 if (max_autopick == MAX_AUTOPICK)
2407 /* Nuke illegal char */
2408 for(i = 0; buf[i]; i++)
2411 if (iskanji(buf[i]))
2417 if (isspace(buf[i]) && buf[i] != ' ')
2422 if (!autopick_new_entry(&entry, buf)) return 0;
2424 /* Already has the same entry? */
2425 for(i = 0; i < max_autopick; i++)
2426 if(!strcmp(entry.name, autopick_list[i].name)
2427 && entry.flag[0] == autopick_list[i].flag[0]
2428 && entry.flag[1] == autopick_list[i].flag[1]
2429 && entry.dice == autopick_list[i].dice
2430 && entry.bonus == autopick_list[i].bonus) return 0;
2432 autopick_list[max_autopick++] = entry;
2438 * Get a trigger key and insert ASCII string for the trigger
2440 static bool insert_macro_line(cptr *lines_list, int cy)
2449 /* Do not process macros */
2455 /* Read the pattern */
2461 /* Do not process macros */
2464 /* Do not wait for keys */
2467 /* Attempt to read a key */
2477 /* Convert the trigger */
2478 ascii_to_text(tmp, buf);
2481 if(!tmp[0]) return FALSE;
2483 /* Insert preference string */
2484 insert_return_code(lines_list, 0, cy);
2485 string_free(lines_list[cy]);
2486 lines_list[cy] = string_make(format("P:%s", tmp));
2488 /* Insert blank action preference line */
2489 insert_return_code(lines_list, 0, cy);
2490 string_free(lines_list[cy]);
2491 lines_list[cy] = string_make("A:");
2498 * Get a command key and insert ASCII string for the key
2500 static bool insert_keymap_line(cptr *lines_list, int cy)
2507 if (rogue_like_commands)
2509 mode = KEYMAP_MODE_ROGUE;
2515 mode = KEYMAP_MODE_ORIG;
2528 /* Convert the trigger */
2529 ascii_to_text(tmp, buf);
2532 if(!tmp[0]) return FALSE;
2534 /* Insert preference string */
2535 insert_return_code(lines_list, 0, cy);
2536 string_free(lines_list[cy]);
2537 lines_list[cy] = string_make(format("C:%d:%s", mode, tmp));
2539 /* Insert blank action preference line */
2540 insert_return_code(lines_list, 0, cy);
2541 string_free(lines_list[cy]);
2542 lines_list[cy] = string_make("A:");
2549 * Description of control commands
2554 static cptr ctrl_command_desc[] =
2557 #define LAST_DESTROYED 6
2558 "^P ^N ^B ^F ¾å²¼º¸±¦¤Ë°ÜÆ°",
2559 "^A ^E ¹Ô¤ÎÀèƬ¡¢½ªÃ¼",
2560 "^Q ÆþÎÏ/¥³¥Þ¥ó¥É¥â¡¼¥ÉÀÚ¤êÂؤ¨",
2561 "^R Êѹ¹¤òÁ´¤Æ¼è¤ê¾Ã¤·¤Æ¸µ¤ËÌ᤹",
2562 "------------------------------------",
2563 "^I »ý¤Áʪ/ÁõÈ÷¤«¤éÁªÂò",
2565 "^K ¥«¡¼¥½¥ë¤«¤é½ªÃ¼¤Þ¤Çºï½ü",
2566 "^Y ºï½ü(^K)¤·¤¿¹Ô¤òÁÞÆþ",
2567 "^C ¼ï²¡¢¿¦¶È¤Î¾ò·ï¼°¤òÁÞÆþ",
2568 "------------------------------------",
2569 "^S Êѹ¹ (!Ç˲õ/~ÊüÃÖ/½¦¤¦)",
2570 "^G \"(\" Á´ÂΥޥåפÇɽ¼¨¤·¤Ê¤¤",
2571 "^O \"#\" ¼«Æ°¹ï¤ß",
2572 "------------------------------------",
2573 "^U ̤´ÕÄê/̤ȽÌÀ/´ÕÄê/*´ÕÄê*",
2575 "^X ̵ÌÃ/¥¨¥´/¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È",
2579 #define LAST_DESTROYED 6
2580 "^P ^N ^B ^F Move Cursor",
2581 "^A ^E Beginning and End of Line",
2582 "^Q Toggle Insert/Command mode",
2583 "^R Revert to Original File",
2584 "------------------------------------",
2585 "^I Object in Inventry/Equipment",
2587 "^K Kill Rest of Line",
2588 "^Y Insert killed(^K) text",
2589 "^C Insert conditional expression",
2590 "------------------------------------",
2591 "^S Toggle(!Destroy/~Leave/Pick)",
2592 "^G \"(\" No display in the 'M'ap",
2593 "^O \"#\" Auto-Inscribe",
2594 "------------------------------------",
2595 "^U Toggle 'identified' state",
2597 "^X Toggle nameless/ego/artifact",
2598 "^Z \"collecting\"",
2604 #define MAX_YANK MAX_LINELEN
2605 #define DIRTY_ALL 0x01
2606 #define DIRTY_COMMAND 0x02
2607 #define DIRTY_MODE 0x04
2608 #define DIRTY_SCREEN 0x08
2609 #define DIRTY_NOT_FOUND 0x10
2610 #define DIRTY_NO_SEARCH 0x20
2613 * In-game editor of Object Auto-picker/Destoryer
2615 void do_cmd_edit_autopick(void)
2617 static int cx = 0, cy = 0;
2618 static int upper = 0, left = 0;
2620 object_type *search_o_ptr = NULL;
2621 cptr search_str = NULL;
2622 cptr last_destroyed = NULL;
2623 char last_destroyed_command[WID_DESC+3];
2624 char yank_buf[MAX_YANK];
2626 autopick_type an_entry, *entry = &an_entry;
2627 char buf[MAX_LINELEN];
2629 int filename_mode = PT_WITH_PNAME;
2634 int old_upper = -1, old_left = -1;
2636 int key = -1, old_key;
2637 bool repeated_clearing = FALSE;
2638 bool edit_mode = FALSE;
2640 byte dirty_flags = DIRTY_ALL | DIRTY_COMMAND | DIRTY_MODE;
2641 int dirty_line = -1;
2643 int wid, hgt, old_wid = -1, old_hgt = -1;
2645 static s32b old_autosave_turn = 0L;
2648 if (turn > old_autosave_turn + 100L)
2650 do_cmd_save_game(TRUE);
2651 old_autosave_turn = turn;
2654 /* HACK -- Reset start_time to stop counting playtime while edit */
2657 /* Free old entries */
2660 /* Command Description of the 'Last Destroyed Item' */
2661 if (autopick_last_destroyed_object.k_idx)
2663 autopick_entry_from_object(entry, &autopick_last_destroyed_object);
2664 last_destroyed = autopick_line_from_entry_kill(entry);
2666 my_strcpy(last_destroyed_command, format("^L \"%s\"", last_destroyed), sizeof(last_destroyed_command));
2671 strcpy(last_destroyed_command, "^L ºÇ¸å¤Ë¼«Æ°Ç˲õ¤·¤¿¥¢¥¤¥Æ¥à̾");
2673 strcpy(last_destroyed_command, "^L Last destroyed object");
2676 ctrl_command_desc[LAST_DESTROYED] = last_destroyed_command;
2678 /* Conditional Expression for Class and Race */
2679 sprintf(classrace, "?:[AND [EQU $RACE %s] [EQU $CLASS %s]]",
2681 rp_ptr->E_title, cp_ptr->E_title
2683 rp_ptr->title, cp_ptr->title
2687 /* Clear yank buffer */
2690 /* Read or initialize whole text */
2691 lines_list = read_pickpref_text_lines(&filename_mode);
2693 /* Reset cursor position if needed */
2694 for (i = 0; i < cy; i++)
2703 /* Save the screen */
2706 /* Process requests until done */
2710 Term_get_size(&wid, &hgt);
2713 /* Don't let cursor at second byte of kanji */
2714 for (i = 0; lines_list[cy][i]; i++)
2715 if (iskanji(lines_list[cy][i]))
2726 /* Scroll if necessary */
2727 if (cy < upper || upper + hgt - 4 <= cy)
2728 upper = cy - (hgt-4)/2;
2731 if ((cx < left + 10 && left > 0) || left + wid - WID_DESC - 5 <= cx)
2732 left = cx - (wid - WID_DESC)*2/3;
2736 /* Redraw whole window after resize */
2737 if (old_wid != wid || old_hgt != hgt)
2738 dirty_flags |= DIRTY_SCREEN;
2740 /* Redraw all text after scroll */
2741 else if (old_upper != upper || old_left != left)
2742 dirty_flags |= DIRTY_ALL;
2745 if (dirty_flags & DIRTY_SCREEN)
2747 dirty_flags |= (DIRTY_ALL | DIRTY_COMMAND | DIRTY_MODE);
2753 if (dirty_flags & DIRTY_COMMAND)
2755 /* Display control command */
2756 for (i = 0; ctrl_command_desc[i]; i++)
2757 Term_putstr(wid - WID_DESC, i + 1, WID_DESC, TERM_WHITE, ctrl_command_desc[i]);
2760 /* Redraw mode line */
2761 if (dirty_flags & DIRTY_MODE)
2763 int sepa_length = wid - WID_DESC;
2766 for (i = 0; i < sepa_length; i++)
2772 strncpy(buf + sepa_length - 21, " (INSERT MODE) ", 16);
2774 strncpy(buf + sepa_length - 21, " (COMMAND MODE) ", 16);
2776 Term_putstr(0, hgt - 3, sepa_length, (byte) (edit_mode ? TERM_YELLOW : TERM_WHITE), buf);
2779 /* Dump up to 20, or hgt-4, lines of messages */
2780 for (i = 0; i < hgt - 4; i++)
2785 /* clean or dirty? */
2786 if (!(dirty_flags & DIRTY_ALL) && (dirty_line != upper+i))
2789 msg = lines_list[upper+i];
2792 /* Apply horizontal scroll */
2793 for (j = 0; *msg; msg++, j++)
2795 if (j == left) break;
2811 Term_erase(0, i + 1, wid - WID_DESC);
2813 /* Dump the messages, bottom to top */
2814 Term_putstr(leftcol, i + 1, wid - WID_DESC - 1, TERM_WHITE, msg);
2817 for (; i < hgt - 4; i++)
2820 Term_erase(0, i + 1, wid - WID_DESC);
2823 /* Display header line */
2826 prt("^Q ESC ¤Ç¥³¥Þ¥ó¥É¥â¡¼¥É¤Ø°Ü¹Ô¡¢Ä̾ï¤Îʸ»ú¤Ï¤½¤Î¤Þ¤ÞÆþÎÏ", 0, 0);
2828 prt("q _ ¤Ç½ªÎ»¡¢hjkl2468 ¤Ç°ÜÆ°¡¢^Q a i ¤ÇÆþÎϥ⡼¥É¡¢/ n N ¤Ç¸¡º÷", 0, 0);
2831 prt("Press ^Q ESC to command mode, any letters to insert", 0, 0);
2833 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);
2835 /* Display current position */
2836 prt (format("(%d,%d)", cx, cy), 0, 70);
2838 /* Display information when updated */
2839 if (old_cy != cy || (dirty_flags & (DIRTY_ALL | DIRTY_NOT_FOUND | DIRTY_NO_SEARCH)) || dirty_line == cy)
2841 /* Clear information line */
2842 Term_erase(0, hgt - 3 + 1, wid);
2843 Term_erase(0, hgt - 3 + 2, wid);
2845 /* Display information */
2846 if (dirty_flags & DIRTY_NOT_FOUND)
2849 prt(format("¥Ñ¥¿¡¼¥ó¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó: %s", search_str), hgt - 3 + 1, 0);
2851 prt(format("Pattern not found: %s", search_str), hgt - 3 + 1, 0);
2854 else if (dirty_flags & DIRTY_NO_SEARCH)
2857 prt("¸¡º÷Ãæ¤Î¥Ñ¥¿¡¼¥ó¤¬¤¢¤ê¤Þ¤»¤ó('/'¤Ç¸¡º÷)¡£", hgt - 3 + 1, 0);
2859 prt("No pattern to search. (Press '/' to search.)", hgt - 3 + 1, 0);
2862 else if (lines_list[cy][0] == '#')
2865 prt("¤³¤Î¹Ô¤Ï¥³¥á¥ó¥È¤Ç¤¹¡£", hgt - 3 + 1, 0);
2867 prt("This line is comment.", hgt - 3 + 1, 0);
2870 else if (lines_list[cy][1] == ':')
2872 switch(lines_list[cy][0])
2876 prt("¤³¤Î¹Ô¤Ï¾ò·ïʬ´ô¼°¤Ç¤¹¡£", hgt - 3 + 1, 0);
2878 prt("This line is Conditional Expression.", hgt - 3 + 1, 0);
2883 prt("¤³¤Î¹Ô¤Ï¥Þ¥¯¥í¤Î¼Â¹ÔÆâÍƤòÄêµÁ¤·¤Þ¤¹¡£", hgt - 3 + 1, 0);
2885 prt("This line defines Macro action.", hgt - 3 + 1, 0);
2890 prt("¤³¤Î¹Ô¤Ï¥Þ¥¯¥í¤Î¥È¥ê¥¬¡¼¡¦¥¡¼¤òÄêµÁ¤·¤Þ¤¹¡£", hgt - 3 + 1, 0);
2892 prt("This line defines Macro trigger key.", hgt - 3 + 1, 0);
2897 prt("¤³¤Î¹Ô¤Ï¥¡¼ÇÛÃÖ¤òÄêµÁ¤·¤Þ¤¹¡£", hgt - 3 + 1, 0);
2899 prt("This line defines Keymap.", hgt - 3 + 1, 0);
2905 /* Get description of an autopicker preference line */
2906 else if (autopick_new_entry(entry, lines_list[cy]))
2911 describe_autopick(buf, entry);
2913 roff_to_buf(buf, 81, temp);
2915 for (i = 0; i< 2; i++)
2921 prt(t, hgt - 3 + 1 + i, 0);
2925 autopick_free_entry(entry);
2930 Term_gotoxy(cx - left, cy - upper + 1);
2936 /* Save old key and location */
2944 /* Do not process macros except special keys */
2945 inkey_special = TRUE;
2956 /* Mode line is now dirty */
2957 dirty_flags |= DIRTY_MODE;
2960 /* Insert a character */
2961 else if (!iscntrl(key&0xff))
2965 /* Save preceding string */
2966 for (i = j = 0; lines_list[cy][i] && i < cx; i++)
2967 buf[j++] = lines_list[cy][i];
2969 /* Add a character */
2975 if (j+2 < MAX_LINELEN)
2987 if (j+1 < MAX_LINELEN)
2993 for (; lines_list[cy][i] && j + 1 < MAX_LINELEN; i++)
2994 buf[j++] = lines_list[cy][i];
2997 /* Replace current line with new line */
2998 string_free(lines_list[cy]);
2999 lines_list[cy] = string_make(buf);
3001 /* Move to correct collumn */
3002 len = strlen(lines_list[cy]);
3003 if (len < cx) cx = len;
3012 if (key == 'q' || key == '_') break;
3019 /* Mode line is now dirty */
3020 dirty_flags |= DIRTY_MODE;
3023 if (!autopick_new_entry(entry, lines_list[cy]))
3025 if (old_key != key) repeated_clearing = FALSE;
3028 if (lines_list[cy + 1]) cy++;
3032 string_free(lines_list[cy]);
3036 if (entry->action & DONT_AUTOPICK)
3037 repeated_clearing = TRUE;
3039 repeated_clearing = FALSE;
3042 entry->action &= ~DO_AUTODESTROY;
3043 entry->action &= ~DO_QUERY_AUTOPICK;
3044 if (!repeated_clearing)
3046 entry->action &= ~DO_AUTOPICK;
3047 entry->action |= DONT_AUTOPICK;
3051 entry->action &= ~DONT_AUTOPICK;
3052 entry->action |= DO_AUTOPICK;
3055 lines_list[cy] = autopick_line_from_entry_kill(entry);
3061 if (lines_list[cy + 1]) cy++;
3065 if (!autopick_new_entry(entry, lines_list[cy]))
3067 if (old_key != key) repeated_clearing = FALSE;
3070 if (lines_list[cy + 1]) cy++;
3074 string_free(lines_list[cy]);
3078 if (entry->action & DO_AUTODESTROY)
3079 repeated_clearing = TRUE;
3081 repeated_clearing = FALSE;
3084 entry->action &= ~DONT_AUTOPICK;
3085 entry->action &= ~DO_QUERY_AUTOPICK;
3086 if (!repeated_clearing)
3088 entry->action &= ~DO_AUTOPICK;
3089 entry->action |= DO_AUTODESTROY;
3093 entry->action &= ~DO_AUTODESTROY;
3094 entry->action |= DO_AUTOPICK;
3097 lines_list[cy] = autopick_line_from_entry_kill(entry);
3103 if (lines_list[cy + 1]) cy++;
3107 if (!autopick_new_entry(entry, lines_list[cy]))
3109 if (old_key != key) repeated_clearing = FALSE;
3112 if (lines_list[cy + 1]) cy++;
3116 string_free(lines_list[cy]);
3120 if (entry->action & DO_QUERY_AUTOPICK)
3121 repeated_clearing = TRUE;
3123 repeated_clearing = FALSE;
3126 entry->action &= ~DO_AUTODESTROY;
3127 entry->action &= ~DONT_AUTOPICK;
3128 if (!repeated_clearing)
3130 entry->action &= ~DO_AUTOPICK;
3131 entry->action |= DO_QUERY_AUTOPICK;
3135 entry->action &= ~DO_QUERY_AUTOPICK;
3136 entry->action |= DO_AUTOPICK;
3139 lines_list[cy] = autopick_line_from_entry_kill(entry);
3145 if (lines_list[cy + 1]) cy++;
3149 /* Toggle display on the 'M'ap */
3150 if (!autopick_new_entry(entry, lines_list[cy]))
3152 if (old_key != key) repeated_clearing = FALSE;
3155 if (lines_list[cy + 1]) cy++;
3159 string_free(lines_list[cy]);
3163 if (entry->action & DO_DISPLAY)
3164 repeated_clearing = TRUE;
3166 repeated_clearing = FALSE;
3169 if (!repeated_clearing)
3170 entry->action |= DO_DISPLAY;
3172 entry->action &= ~DO_DISPLAY;
3174 lines_list[cy] = autopick_line_from_entry_kill(entry);
3180 if (lines_list[cy + 1]) cy++;
3200 while (cy < upper + hgt-4 && lines_list[cy + 1])
3205 while (0 < cy && upper <= cy)
3207 while (0 < upper && cy + 1 < upper + hgt - 4)
3216 while (lines_list[cy + 1])
3222 Term_erase(0, cy - upper + 1, wid - WID_DESC);
3226 Term_putstr(0, cy - upper + 1, wid - WID_DESC - 1, TERM_YELLOW, "P:<¥È¥ê¥¬¡¼¥¡¼>: ");
3228 Term_putstr(0, cy - upper + 1, wid - WID_DESC - 1, TERM_YELLOW, "P:<Trigger key>: ");
3230 if (insert_macro_line(lines_list, cy))
3232 /* Prepare to input action */
3237 dirty_flags |= DIRTY_ALL;
3238 dirty_flags |= DIRTY_MODE;
3245 Term_erase(0, cy - upper + 1, wid - WID_DESC);
3249 Term_putstr(0, cy - upper + 1, wid - WID_DESC - 1, TERM_YELLOW, format("C:%d:<¥³¥Þ¥ó¥É¥¡¼>: ", (rogue_like_commands ? KEYMAP_MODE_ROGUE : KEYMAP_MODE_ORIG)));
3251 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)));
3254 if (insert_keymap_line(lines_list, cy))
3256 /* Prepare to input action */
3261 dirty_flags |= DIRTY_ALL;
3262 dirty_flags |= DIRTY_MODE;
3266 /* Become dirty because of item/equip menu */
3267 dirty_flags |= DIRTY_SCREEN;
3269 if (!get_string_for_search(&search_o_ptr, &search_str))
3276 if (!search_for_object(lines_list, search_o_ptr, &cx, &cy, TRUE)) dirty_flags |= DIRTY_NOT_FOUND;
3278 else if (search_str)
3280 if (!search_for_string(lines_list, search_str, &cx, &cy, TRUE)) dirty_flags |= DIRTY_NOT_FOUND;
3284 dirty_flags |= DIRTY_NO_SEARCH;
3290 if (!search_for_object(lines_list, search_o_ptr, &cx, &cy, FALSE)) dirty_flags |= DIRTY_NOT_FOUND;
3292 else if (search_str)
3294 if (!search_for_string(lines_list, search_str, &cx, &cy, FALSE)) dirty_flags |= DIRTY_NOT_FOUND;
3298 dirty_flags |= DIRTY_NO_SEARCH;
3307 /* Beginning of line */
3315 len = strlen(lines_list[cy]);
3316 if (len < cx) cx = len;
3321 cx = strlen(lines_list[cy]);
3325 /* Insert a conditinal expression line */
3326 insert_return_code(lines_list, 0, cy);
3327 string_free(lines_list[cy]);
3328 lines_list[cy] = string_make(classrace);
3330 insert_return_code(lines_list, 0, cy);
3331 string_free(lines_list[cy]);
3332 lines_list[cy] = string_make("?:1");
3336 dirty_flags |= DIRTY_ALL;
3340 cx = strlen(lines_list[cy]);
3345 if (iskanji(lines_list[cy][cx])) cx++;
3348 len = strlen(lines_list[cy]);
3351 if (lines_list[cy + 1])
3361 /* Toggle display on the 'M'ap */
3362 if (!autopick_new_entry(entry, lines_list[cy]))
3364 string_free(lines_list[cy]);
3366 if (entry->action & DO_DISPLAY)
3368 entry->action &= ~DO_DISPLAY;
3373 entry->action |= DO_DISPLAY;
3377 lines_list[cy] = autopick_line_from_entry_kill(entry);
3383 /* Insert choosen item name */
3384 if (!entry_from_choosed_object(entry))
3386 /* Now dirty because of item/equip menu */
3387 dirty_flags |= DIRTY_SCREEN;
3391 insert_return_code(lines_list, 0, cy);
3392 string_free(lines_list[cy]);
3393 lines_list[cy] = autopick_line_from_entry_kill(entry);
3396 /* Now dirty because of item/equip menu */
3397 dirty_flags |= DIRTY_SCREEN;
3401 /* Insert a name of last destroyed item */
3404 insert_return_code(lines_list, 0, cy);
3405 string_free(lines_list[cy]);
3406 lines_list[cy] = string_make(last_destroyed);
3410 dirty_flags |= DIRTY_ALL;
3413 case '\n': case '\r':
3414 /* Split a line or insert end of line */
3415 insert_return_code(lines_list, cx, cy);
3420 dirty_flags |= DIRTY_ALL;
3424 if (lines_list[cy + 1]) cy++;
3427 /* Prepare to write auto-inscription text */
3428 if (!autopick_new_entry(entry, lines_list[cy]))
3430 string_free(lines_list[cy]);
3432 if (!entry->insc) entry->insc = string_make("");
3434 lines_list[cy] = autopick_line_from_entry_kill(entry);
3436 /* Move to collumn for auto inscription */
3437 for (cx = 0; lines_list[cy][cx]; cx++)
3438 if (lines_list[cy][cx] == '#') break;
3444 dirty_flags |= DIRTY_MODE;
3452 edit_mode = !edit_mode;
3454 /* Mode line is now dirty */
3455 dirty_flags |= DIRTY_MODE;
3458 /* Revert to original */
3460 if (!get_check("Á´¤Æ¤ÎÊѹ¹¤òÇË´þ¤·¤Æ¸µ¤Î¾õÂÖ¤ËÌᤷ¤Þ¤¹¡£¤è¤í¤·¤¤¤Ç¤¹¤«¡© "))
3462 if (!get_check("Discard all change and revert to original file. Are you sure? "))
3466 free_text_lines(lines_list);
3467 lines_list = read_pickpref_text_lines(&filename_mode);
3468 dirty_flags |= DIRTY_ALL | DIRTY_MODE;
3473 /* Rotate action; pickup/destroy/leave */
3474 if (!autopick_new_entry(entry, lines_list[cy]))
3476 string_free(lines_list[cy]);
3478 if (entry->action & DO_AUTOPICK)
3480 entry->action &= ~DO_AUTOPICK;
3481 entry->action |= DO_AUTODESTROY;
3483 else if (entry->action & DO_AUTODESTROY)
3485 entry->action &= ~DO_AUTODESTROY;
3486 entry->action |= DONT_AUTOPICK;
3488 else if (entry->action & DONT_AUTOPICK)
3490 entry->action &= ~DONT_AUTOPICK;
3491 entry->action |= DO_AUTOPICK;
3494 lines_list[cy] = autopick_line_from_entry_kill(entry);
3504 /* Rotate identify-state; identified/unidentified/... */
3505 if (!autopick_new_entry(entry, lines_list[cy]))
3507 string_free(lines_list[cy]);
3509 if (IS_FLG(FLG_UNIDENTIFIED))
3511 REM_FLG(FLG_UNIDENTIFIED);
3512 ADD_FLG(FLG_UNAWARE);
3513 REM_FLG(FLG_IDENTIFIED);
3514 REM_FLG(FLG_STAR_IDENTIFIED);
3516 else if (IS_FLG(FLG_UNAWARE))
3518 REM_FLG(FLG_UNIDENTIFIED);
3519 REM_FLG(FLG_UNAWARE);
3520 ADD_FLG(FLG_IDENTIFIED);
3521 REM_FLG(FLG_STAR_IDENTIFIED);
3523 else if (IS_FLG(FLG_STAR_IDENTIFIED))
3525 REM_FLG(FLG_UNIDENTIFIED);
3526 REM_FLG(FLG_UNAWARE);
3527 REM_FLG(FLG_IDENTIFIED);
3528 REM_FLG(FLG_STAR_IDENTIFIED);
3530 else if (IS_FLG(FLG_IDENTIFIED))
3532 REM_FLG(FLG_UNIDENTIFIED);
3533 REM_FLG(FLG_UNAWARE);
3534 REM_FLG(FLG_IDENTIFIED);
3535 ADD_FLG(FLG_STAR_IDENTIFIED);
3539 ADD_FLG(FLG_UNIDENTIFIED);
3540 REM_FLG(FLG_UNAWARE);
3541 REM_FLG(FLG_IDENTIFIED);
3542 REM_FLG(FLG_STAR_IDENTIFIED);
3545 lines_list[cy] = autopick_line_from_entry_kill(entry);
3552 while (cy < upper + hgt-4 && lines_list[cy + 1])
3557 /* Toggle 'worthless' */
3558 toggle_string(lines_list, FLG_WORTHLESS, cy);
3563 /* Rotate within nameless, ego, artifact */
3564 if (!autopick_new_entry(entry, lines_list[cy]))
3566 string_free(lines_list[cy]);
3568 if (IS_FLG(FLG_NAMELESS))
3570 REM_FLG(FLG_NAMELESS);
3572 REM_FLG(FLG_ARTIFACT);
3574 else if (IS_FLG(FLG_EGO))
3576 REM_FLG(FLG_NAMELESS);
3578 ADD_FLG(FLG_ARTIFACT);
3580 else if (IS_FLG(FLG_ARTIFACT))
3582 REM_FLG(FLG_NAMELESS);
3584 REM_FLG(FLG_ARTIFACT);
3588 ADD_FLG(FLG_NAMELESS);
3590 REM_FLG(FLG_ARTIFACT);
3593 lines_list[cy] = autopick_line_from_entry_kill(entry);
3600 /* Paste killed text */
3601 if (strlen(yank_buf))
3605 for (j = 0; yank_buf[j]; j += strlen(yank_buf + j) + 1)
3607 if (ret && '\n' == yank_buf[j])
3613 /* Split current line */
3614 insert_return_code(lines_list, cx, cy);
3616 /* Save preceding string */
3617 for(i = 0; lines_list[cy][i]; i++)
3618 buf[i] = lines_list[cy][i];
3620 /* Paste yank buffer */
3621 if ('\n' != yank_buf[j])
3624 while (yank_buf[k] && i < MAX_LINELEN-1)
3625 buf[i++] = yank_buf[k++];
3631 string_free(lines_list[cy]);
3632 lines_list[cy] = string_make(buf);
3634 /* Move to the beggining of next line */
3640 dirty_flags |= DIRTY_ALL;
3644 /* Toggle 'collecting' */
3645 toggle_string(lines_list, FLG_COLLECTING, cy);
3651 /* Kill rest of line */
3652 if ((uint)cx > strlen(lines_list[cy]))
3653 cx = (int)strlen(lines_list[cy]);
3655 /* Save preceding string */
3656 for (i = 0; lines_list[cy][i] && i < cx; i++)
3659 if (iskanji(lines_list[cy][i]))
3661 buf[i] = lines_list[cy][i];
3665 buf[i] = lines_list[cy][i];
3672 j += strlen(yank_buf + j) + 1;
3674 /* Copy following to yank buffer */
3675 if (lines_list[cy][i])
3677 while (lines_list[cy][i] && j < MAX_YANK - 2)
3678 yank_buf[j++] = lines_list[cy][i++];
3683 if (j < MAX_YANK - 2)
3684 yank_buf[j++] = '\n';
3687 yank_buf[j++] = '\0';
3690 /* Replace current line with 'preceding string' */
3691 string_free(lines_list[cy]);
3692 lines_list[cy] = string_make(buf);
3704 /* DELETE == go forward + BACK SPACE */
3706 if (iskanji(lines_list[cy][cx])) cx++;
3714 len = strlen(lines_list[cy]);
3717 if (lines_list[cy + 1])
3731 /* delete a return code and union two lines */
3733 cx = strlen(lines_list[cy-1]);
3734 strcpy(buf, lines_list[cy-1]);
3735 strcat(buf, lines_list[cy]);
3736 string_free(lines_list[cy-1]);
3737 string_free(lines_list[cy]);
3738 lines_list[cy-1] = string_make(buf);
3739 for (i = cy; lines_list[i+1]; i++)
3740 lines_list[i] = lines_list[i+1];
3741 lines_list[i] = NULL;
3745 dirty_flags |= DIRTY_ALL;
3749 for (i = j = k = 0; lines_list[cy][i] && i < cx; i++)
3753 if (iskanji(lines_list[cy][i]))
3754 buf[j++] = lines_list[cy][i++];
3756 buf[j++] = lines_list[cy][i];
3763 for (; lines_list[cy][i]; i++)
3764 buf[j++] = lines_list[cy][i];
3766 string_free(lines_list[cy]);
3767 lines_list[cy] = string_make(buf);
3776 /* Restore the screen */
3779 switch (filename_mode)
3783 strcpy(buf, "picktype.prf");
3785 strcpy(buf, "pickpref.prf");
3791 sprintf(buf, "picktype-%s.prf", player_name);
3793 sprintf(buf, "pickpref-%s.prf", player_name);
3798 write_text_lines(buf, lines_list);
3799 free_text_lines(lines_list);
3801 string_free(last_destroyed);
3803 /* Reload autopick pref */
3804 process_pickpref_file(buf);
3806 /* HACK -- reset start_time so that playtime is not increase while edit */
3807 start_time = time(NULL);