3 /* Purpose: Object Auto-picker/Destroyer */
6 * Copyright (c) 2002 Mogami
8 * This software may be copied and distributed for educational, research, and
9 * not for profit purposes provided that this copyright and statement are
10 * included in all such copies.
19 #define FLG_COLLECTING 1
20 #define FLG_UNIDENTIFIED 2
21 #define FLG_IDENTIFIED 3
22 #define FLG_STAR_IDENTIFIED 4
23 #define FLG_NAMELESS 5
25 #define FLG_WORTHLESS 7
27 #define FLG_MORE_THAN 9
32 #define FLG_UNREADABLE 14
40 #define FLG_ARTIFACTS 22
41 #define FLG_WEAPONS 23
43 #define FLG_MISSILES 25
44 #define FLG_DEVICES 26
47 #define FLG_SPELLBOOKS 29
49 #define FLG_SHIELDS 31
52 #define FLG_AMULETS 34
61 #define KEY_ALL "¤¹¤Ù¤Æ¤Î"
62 #define KEY_COLLECTING "¼ý½¸Ãæ¤Î"
63 #define KEY_UNIDENTIFIED "̤´ÕÄê¤Î"
64 #define KEY_IDENTIFIED "´ÕÄêºÑ¤ß¤Î"
65 #define KEY_STAR_IDENTIFIED "*´ÕÄê*ºÑ¤ß¤Î"
66 #define KEY_NAMELESS "̵ÌäÎ"
67 #define KEY_UNAWARE "̤ȽÌÀ¤Î"
68 #define KEY_WORTHLESS "̵²ÁÃͤÎ"
69 #define KEY_BOOSTED "¥À¥¤¥¹Ìܤΰ㤦"
70 #define KEY_MORE_THAN "¥À¥¤¥¹ÌÜ"
71 #define KEY_DICE "°Ê¾å¤Î"
72 #define KEY_WANTED "¾Þ¶â¼ó¤Î"
73 #define KEY_UNIQUE "¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¤Î"
74 #define KEY_HUMAN "¿Í´Ö¤Î"
75 #define KEY_UNREADABLE "Æɤá¤Ê¤¤"
76 #define KEY_REALM1 "Âè°ìÎΰè¤Î"
77 #define KEY_REALM2 "ÂèÆóÎΰè¤Î"
78 #define KEY_FIRST "1ºýÌܤÎ"
79 #define KEY_SECOND "2ºýÌܤÎ"
80 #define KEY_THIRD "3ºýÌܤÎ"
81 #define KEY_FOURTH "4ºýÌܤÎ"
82 #define KEY_ITEMS "¥¢¥¤¥Æ¥à"
83 #define KEY_ARTIFACTS "¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È"
84 #define KEY_WEAPONS "Éð´ï"
85 #define KEY_ARMORS "Ëɶñ"
86 #define KEY_MISSILES "Ìð"
87 #define KEY_DEVICES "ËâË¡¥¢¥¤¥Æ¥à"
88 #define KEY_LIGHTS "¸÷¸»"
89 #define KEY_JUNKS "¤¬¤é¤¯¤¿"
90 #define KEY_SPELLBOOKS "ËâË¡½ñ"
91 #define KEY_HAFTED "Æß´ï"
92 #define KEY_SHIELDS "½â"
94 #define KEY_RINGS "»ØÎØ"
95 #define KEY_AMULETS "¥¢¥ß¥å¥ì¥Ã¥È"
96 #define KEY_SUITS "³»"
97 #define KEY_CLOAKS "¥¯¥í¡¼¥¯"
98 #define KEY_HELMS "³õ"
99 #define KEY_GLOVES "äƼê"
100 #define KEY_BOOTS "·¤"
104 #define KEY_ALL "all"
105 #define KEY_COLLECTING "collecting"
106 #define KEY_UNIDENTIFIED "unidentified"
107 #define KEY_IDENTIFIED "identified"
108 #define KEY_STAR_IDENTIFIED "*identified*"
109 #define KEY_NAMELESS "nameless"
110 #define KEY_UNAWARE "unaware"
111 #define KEY_WORTHLESS "worthless"
112 #define KEY_BOOSTED "dice boosted"
113 #define KEY_MORE_THAN "more than "
114 #define KEY_DICE " dice "
115 #define KEY_WANTED "wanted"
116 #define KEY_UNIQUE "unique monster's"
117 #define KEY_HUMAN "human"
118 #define KEY_UNREADABLE "unreadable"
119 #define KEY_REALM1 "first realm's"
120 #define KEY_REALM2 "second realm's"
121 #define KEY_FIRST "first"
122 #define KEY_SECOND "second"
123 #define KEY_THIRD "third"
124 #define KEY_FOURTH "fourth"
125 #define KEY_ITEMS "items"
126 #define KEY_ARTIFACTS "artifacts"
127 #define KEY_WEAPONS "weapons"
128 #define KEY_ARMORS "armors"
129 #define KEY_MISSILES "missiles"
130 #define KEY_DEVICES "magical devices"
131 #define KEY_LIGHTS "lights"
132 #define KEY_JUNKS "junks"
133 #define KEY_SPELLBOOKS "spellbooks"
134 #define KEY_HAFTED "hafted weapons"
135 #define KEY_SHIELDS "shields"
136 #define KEY_BOWS "bows"
137 #define KEY_RINGS "rings"
138 #define KEY_AMULETS "amulets"
139 #define KEY_SUITS "suits"
140 #define KEY_CLOAKS "cloaks"
141 #define KEY_HELMS "helms"
142 #define KEY_GLOVES "gloves"
143 #define KEY_BOOTS "boots"
147 #define MATCH_KEY(KEY) (!strncmp(ptr, KEY, sizeof(KEY)-1)\
148 ? (prev_ptr = ptr, ptr += sizeof(KEY)-1, (' '==*ptr) ? ptr++ : 0, TRUE) : FALSE)
151 #define ADD_KEY(KEY) strcat(ptr, KEY)
153 #define ADD_KEY(KEY) (strcat(ptr, KEY), strcat(ptr, " "))
155 #define ADD_KEY2(KEY) strcat(ptr, KEY)
157 #define ADD_FLG(FLG) (entry->flag[FLG / 32] |= (1L << (FLG % 32)))
158 #define REM_FLG(FLG) (entry->flag[FLG / 32] &= ~(1L << (FLG % 32)))
159 #define ADD_FLG2(FLG) (entry->flag[FLG / 32] |= (1L << (FLG % 32)), prev_flg = FLG)
160 #define IS_FLG(FLG) (entry->flag[FLG / 32] & (1L << (FLG % 32)))
163 static char kanji_colon[] = "¡§";
168 * Reconstruct preference line from entry
170 cptr autopick_line_from_entry(autopick_type *entry)
174 bool sepa_flag = TRUE;
177 if (!(entry->action & DO_DISPLAY)) strcat(buf, "(");
178 if (entry->action & DO_AUTODESTROY) strcat(buf, "!");
179 if (entry->action & DONT_AUTOPICK) strcat(buf, "~");
183 if (IS_FLG(FLG_ALL)) ADD_KEY(KEY_ALL);
184 if (IS_FLG(FLG_COLLECTING)) ADD_KEY(KEY_COLLECTING);
185 if (IS_FLG(FLG_UNIDENTIFIED)) ADD_KEY(KEY_UNIDENTIFIED);
186 if (IS_FLG(FLG_IDENTIFIED)) ADD_KEY(KEY_IDENTIFIED);
187 if (IS_FLG(FLG_STAR_IDENTIFIED)) ADD_KEY(KEY_STAR_IDENTIFIED);
188 if (IS_FLG(FLG_NAMELESS)) ADD_KEY(KEY_NAMELESS);
189 if (IS_FLG(FLG_UNAWARE)) ADD_KEY(KEY_UNAWARE);
190 if (IS_FLG(FLG_WORTHLESS)) ADD_KEY(KEY_WORTHLESS);
191 if (IS_FLG(FLG_BOOSTED)) ADD_KEY(KEY_BOOSTED);
193 if (IS_FLG(FLG_MORE_THAN))
195 ADD_KEY(KEY_MORE_THAN);
196 strcat(ptr, format("%2d", entry->dice));
200 if (IS_FLG(FLG_WANTED)) ADD_KEY(KEY_WANTED);
201 if (IS_FLG(FLG_UNIQUE)) ADD_KEY(KEY_UNIQUE);
202 if (IS_FLG(FLG_HUMAN)) ADD_KEY(KEY_HUMAN);
203 if (IS_FLG(FLG_UNREADABLE)) ADD_KEY(KEY_UNREADABLE);
204 if (IS_FLG(FLG_REALM1)) ADD_KEY(KEY_REALM1);
205 if (IS_FLG(FLG_REALM2)) ADD_KEY(KEY_REALM2);
206 if (IS_FLG(FLG_FIRST)) ADD_KEY(KEY_FIRST);
207 if (IS_FLG(FLG_SECOND)) ADD_KEY(KEY_SECOND);
208 if (IS_FLG(FLG_THIRD)) ADD_KEY(KEY_THIRD);
209 if (IS_FLG(FLG_FOURTH)) ADD_KEY(KEY_FOURTH);
211 if (IS_FLG(FLG_ITEMS)) ADD_KEY2(KEY_ITEMS);
212 else if (IS_FLG(FLG_ARTIFACTS)) ADD_KEY2(KEY_ARTIFACTS);
213 else if (IS_FLG(FLG_WEAPONS)) ADD_KEY2(KEY_WEAPONS);
214 else if (IS_FLG(FLG_ARMORS)) ADD_KEY2(KEY_ARMORS);
215 else if (IS_FLG(FLG_MISSILES)) ADD_KEY2(KEY_MISSILES);
216 else if (IS_FLG(FLG_DEVICES)) ADD_KEY2(KEY_DEVICES);
217 else if (IS_FLG(FLG_LIGHTS)) ADD_KEY2(KEY_LIGHTS);
218 else if (IS_FLG(FLG_JUNKS)) ADD_KEY2(KEY_JUNKS);
219 else if (IS_FLG(FLG_SPELLBOOKS)) ADD_KEY2(KEY_SPELLBOOKS);
220 else if (IS_FLG(FLG_HAFTED)) ADD_KEY2(KEY_HAFTED);
221 else if (IS_FLG(FLG_SHIELDS)) ADD_KEY2(KEY_SHIELDS);
222 else if (IS_FLG(FLG_BOWS)) ADD_KEY2(KEY_BOWS);
223 else if (IS_FLG(FLG_RINGS)) ADD_KEY2(KEY_RINGS);
224 else if (IS_FLG(FLG_AMULETS)) ADD_KEY2(KEY_AMULETS);
225 else if (IS_FLG(FLG_SUITS)) ADD_KEY2(KEY_SUITS);
226 else if (IS_FLG(FLG_CLOAKS)) ADD_KEY2(KEY_CLOAKS);
227 else if (IS_FLG(FLG_HELMS)) ADD_KEY2(KEY_HELMS);
228 else if (IS_FLG(FLG_GLOVES)) ADD_KEY2(KEY_GLOVES);
229 else if (IS_FLG(FLG_BOOTS)) ADD_KEY2(KEY_BOOTS);
233 if (entry->name && *entry->name)
237 strcat(buf, entry->name);
241 if (entry->flag[0] == 0L && entry->flag[0] == 0L)
248 strcat(buf, entry->insc);
251 return string_make(buf);
255 * A function to create new entry
257 bool autopick_new_entry(autopick_type *entry, cptr str)
266 if (str[1] == ':') switch (str[0])
269 case 'A': case 'P': case 'C':
273 entry->flag[0] = entry->flag[1] = 0L;
276 act = DO_AUTOPICK | DO_DISPLAY;
279 if ((act & DO_AUTOPICK) && *str == '!')
282 act |= DO_AUTODESTROY;
285 else if ((act & DO_AUTOPICK) && *str == '~')
288 act |= DONT_AUTOPICK;
291 else if ((act & DO_DISPLAY) && *str == '(')
300 /* don't mind upper or lower case */
302 for (i = 0; *str; i++)
313 /* Auto-inscription? */
321 if (isupper(c)) c = tolower(c);
327 /* Skip empty line */
328 if (*buf == 0) return FALSE;
331 prev_ptr = ptr = buf;
333 if (MATCH_KEY(KEY_ALL)) ADD_FLG(FLG_ALL);
334 if (MATCH_KEY(KEY_COLLECTING)) ADD_FLG(FLG_COLLECTING);
335 if (MATCH_KEY(KEY_UNIDENTIFIED)) ADD_FLG(FLG_UNIDENTIFIED);
336 if (MATCH_KEY(KEY_IDENTIFIED)) ADD_FLG(FLG_IDENTIFIED);
337 if (MATCH_KEY(KEY_STAR_IDENTIFIED)) ADD_FLG(FLG_STAR_IDENTIFIED);
338 if (MATCH_KEY(KEY_NAMELESS)) ADD_FLG(FLG_NAMELESS);
339 if (MATCH_KEY(KEY_UNAWARE)) ADD_FLG(FLG_UNAWARE);
340 if (MATCH_KEY(KEY_WORTHLESS)) ADD_FLG(FLG_WORTHLESS);
341 if (MATCH_KEY(KEY_BOOSTED)) ADD_FLG(FLG_BOOSTED);
343 /*** Weapons whic dd*ds is more than nn ***/
344 if (MATCH_KEY(KEY_MORE_THAN))
346 if (isdigit(ptr[0]) && isdigit(ptr[1]))
348 entry->dice = (ptr[0] - '0') * 10 + (ptr[1] - '0');
350 (void)MATCH_KEY(KEY_DICE);
351 ADD_FLG(FLG_MORE_THAN);
357 if (MATCH_KEY(KEY_WANTED)) ADD_FLG(FLG_WANTED);
358 if (MATCH_KEY(KEY_UNIQUE)) ADD_FLG(FLG_UNIQUE);
359 if (MATCH_KEY(KEY_HUMAN)) ADD_FLG(FLG_HUMAN);
360 if (MATCH_KEY(KEY_UNREADABLE)) ADD_FLG(FLG_UNREADABLE);
361 if (MATCH_KEY(KEY_REALM1)) ADD_FLG(FLG_REALM1);
362 if (MATCH_KEY(KEY_REALM2)) ADD_FLG(FLG_REALM2);
363 if (MATCH_KEY(KEY_FIRST)) ADD_FLG(FLG_FIRST);
364 if (MATCH_KEY(KEY_SECOND)) ADD_FLG(FLG_SECOND);
365 if (MATCH_KEY(KEY_THIRD)) ADD_FLG(FLG_THIRD);
366 if (MATCH_KEY(KEY_FOURTH)) ADD_FLG(FLG_FOURTH);
368 /* Reset previous word location */
371 if (MATCH_KEY(KEY_ITEMS)) ADD_FLG2(FLG_ITEMS);
372 else if (MATCH_KEY(KEY_ARTIFACTS)) ADD_FLG2(FLG_ARTIFACTS);
373 else if (MATCH_KEY(KEY_WEAPONS)) ADD_FLG2(FLG_WEAPONS);
374 else if (MATCH_KEY(KEY_ARMORS)) ADD_FLG2(FLG_ARMORS);
375 else if (MATCH_KEY(KEY_MISSILES)) ADD_FLG2(FLG_MISSILES);
376 else if (MATCH_KEY(KEY_DEVICES)) ADD_FLG2(FLG_DEVICES);
377 else if (MATCH_KEY(KEY_LIGHTS)) ADD_FLG2(FLG_LIGHTS);
378 else if (MATCH_KEY(KEY_JUNKS)) ADD_FLG2(FLG_JUNKS);
379 else if (MATCH_KEY(KEY_SPELLBOOKS)) ADD_FLG2(FLG_SPELLBOOKS);
380 else if (MATCH_KEY(KEY_HAFTED)) ADD_FLG2(FLG_HAFTED);
381 else if (MATCH_KEY(KEY_SHIELDS)) ADD_FLG2(FLG_SHIELDS);
382 else if (MATCH_KEY(KEY_BOWS)) ADD_FLG2(FLG_BOWS);
383 else if (MATCH_KEY(KEY_RINGS)) ADD_FLG2(FLG_RINGS);
384 else if (MATCH_KEY(KEY_AMULETS)) ADD_FLG2(FLG_AMULETS);
385 else if (MATCH_KEY(KEY_SUITS)) ADD_FLG2(FLG_SUITS);
386 else if (MATCH_KEY(KEY_CLOAKS)) ADD_FLG2(FLG_CLOAKS);
387 else if (MATCH_KEY(KEY_HELMS)) ADD_FLG2(FLG_HELMS);
388 else if (MATCH_KEY(KEY_GLOVES)) ADD_FLG2(FLG_GLOVES);
389 else if (MATCH_KEY(KEY_BOOTS)) ADD_FLG2(FLG_BOOTS);
391 /* Last 'keyword' must be at the correct location */
394 else if (*ptr == '\0')
395 ; /* nothing to do */
397 else if (ptr[0] == kanji_colon[0] && ptr[1] == kanji_colon[1])
403 entry->flag[prev_flg/32] &= ~(1L<< (prev_flg%32));
406 entry->name = string_make(ptr);
408 entry->insc = string_make(insc);
414 * A function to delete entry
416 void autopick_free_entry(autopick_type *entry)
418 string_free(entry->name);
419 string_free(entry->insc);
423 * A function for Auto-picker/destroyer
424 * Examine whether the object matches to the list of keywords or not.
426 int is_autopick(object_type *o_ptr)
429 char o_name[MAX_NLEN];
431 if (o_ptr->tval == TV_GOLD) return -1;
433 object_desc(o_name, o_ptr, FALSE, 3);
435 /* Force to be lower case string */
436 for (i = 0; o_name[i]; i++)
439 if (iskanji(o_name[i]))
443 if (isupper(o_name[i]))
444 o_name[i] = tolower(o_name[i]);
447 for (i=0; i < max_autopick; i++)
449 autopick_type *entry = &autopick_list[i];
451 cptr ptr = autopick_list[i].name;
453 /*** Unidentified ***/
454 if (IS_FLG(FLG_UNIDENTIFIED)
455 && (object_known_p(o_ptr) || (o_ptr->ident & IDENT_SENSE)))
459 if (IS_FLG(FLG_IDENTIFIED) && !object_known_p(o_ptr))
462 /*** *Identified* ***/
463 if (IS_FLG(FLG_STAR_IDENTIFIED) &&
464 (!object_known_p(o_ptr) || !(o_ptr->ident & IDENT_MENTAL)))
468 if (IS_FLG(FLG_NAMELESS))
473 case TV_SHOT: case TV_ARROW: case TV_BOLT: case TV_BOW:
474 case TV_DIGGING: case TV_HAFTED: case TV_POLEARM: case TV_SWORD:
475 case TV_BOOTS: case TV_GLOVES: case TV_HELM: case TV_CROWN:
476 case TV_SHIELD: case TV_CLOAK:
477 case TV_SOFT_ARMOR: case TV_HARD_ARMOR: case TV_DRAG_ARMOR:
478 case TV_LITE: case TV_AMULET: case TV_RING: case TV_CARD:
479 if ((!object_known_p(o_ptr) || o_ptr->inscription
480 || o_ptr->name1 || o_ptr->name2 || o_ptr->art_name))
489 /*** Unaware items ***/
490 if (IS_FLG(FLG_UNAWARE) && object_aware_p(o_ptr))
493 /*** Worthless items ***/
494 if (IS_FLG(FLG_WORTHLESS) && object_value(o_ptr) > 0)
497 /*** Dice boosted (weapon of slaying) ***/
498 if (IS_FLG(FLG_BOOSTED))
500 object_kind *k_ptr = &k_info[o_ptr->k_idx];
502 switch( o_ptr->tval )
508 if ((o_ptr->dd != k_ptr->dd) || (o_ptr->ds != k_ptr->ds))
517 /*** Weapons whic dd*ds is more than nn ***/
518 if (IS_FLG(FLG_MORE_THAN))
520 if (o_ptr->dd * o_ptr->ds < entry->dice)
524 /*** Wanted monster's corpse/skeletons ***/
525 if (IS_FLG(FLG_WANTED) &&
526 (o_ptr->tval != TV_CORPSE || !object_is_shoukinkubi(o_ptr)))
529 /*** Unique monster's corpse/skeletons/statues ***/
530 if (IS_FLG(FLG_UNIQUE) &&
531 ((o_ptr->tval != TV_CORPSE && o_ptr->tval != TV_STATUE) ||
532 !(r_info[o_ptr->pval].flags1 & RF1_UNIQUE)))
535 /*** Human corpse/skeletons (for Daemon magic) ***/
536 if (IS_FLG(FLG_HUMAN) &&
537 (o_ptr->tval != TV_CORPSE ||
538 !strchr("pht", r_info[o_ptr->pval].d_char)))
541 /*** Unreadable spellbooks ***/
542 if (IS_FLG(FLG_UNREADABLE) &&
543 (o_ptr->tval < TV_LIFE_BOOK ||
544 check_book_realm(o_ptr->tval, o_ptr->sval)))
547 /*** First realm spellbooks ***/
548 if (IS_FLG(FLG_REALM1) &&
549 (REALM1_BOOK != o_ptr->tval ||
550 p_ptr->pclass == CLASS_SORCERER ||
551 p_ptr->pclass == CLASS_RED_MAGE))
554 /*** Second realm spellbooks ***/
555 if (IS_FLG(FLG_REALM2) &&
556 (REALM2_BOOK != o_ptr->tval ||
557 p_ptr->pclass == CLASS_SORCERER ||
558 p_ptr->pclass == CLASS_RED_MAGE))
561 /*** First rank spellbooks ***/
562 if (IS_FLG(FLG_FIRST) &&
563 (o_ptr->tval < TV_LIFE_BOOK || 0 != o_ptr->sval))
566 /*** Second rank spellbooks ***/
567 if (IS_FLG(FLG_SECOND) &&
568 (o_ptr->tval < TV_LIFE_BOOK || 1 != o_ptr->sval))
571 /*** Third rank spellbooks ***/
572 if (IS_FLG(FLG_THIRD) &&
573 (o_ptr->tval < TV_LIFE_BOOK || 2 != o_ptr->sval))
576 /*** Fourth rank spellbooks ***/
577 if (IS_FLG(FLG_FOURTH) &&
578 (o_ptr->tval < TV_LIFE_BOOK || 3 != o_ptr->sval))
582 if (IS_FLG(FLG_ARTIFACTS))
584 if (!(object_known_p(o_ptr)
585 && (artifact_p(o_ptr) || o_ptr->art_name)))
588 else if (IS_FLG(FLG_WEAPONS))
592 case TV_BOW: case TV_HAFTED: case TV_POLEARM:
593 case TV_SWORD: case TV_DIGGING:
598 else if (IS_FLG(FLG_ARMORS))
602 case TV_BOOTS: case TV_GLOVES: case TV_CLOAK: case TV_CROWN:
603 case TV_HELM: case TV_SHIELD: case TV_SOFT_ARMOR:
604 case TV_HARD_ARMOR: case TV_DRAG_ARMOR:
609 else if (IS_FLG(FLG_MISSILES))
613 case TV_SHOT: case TV_BOLT: case TV_ARROW:
618 else if (IS_FLG(FLG_DEVICES))
622 case TV_SCROLL: case TV_STAFF: case TV_WAND: case TV_ROD:
627 else if (IS_FLG(FLG_LIGHTS))
629 if (!(o_ptr->tval == TV_LITE))
632 else if (IS_FLG(FLG_JUNKS))
636 case TV_SKELETON: case TV_BOTTLE:
637 case TV_JUNK: case TV_STATUE:
642 else if (IS_FLG(FLG_SPELLBOOKS))
644 if (!(o_ptr->tval >= TV_LIFE_BOOK))
647 else if (IS_FLG(FLG_HAFTED))
649 if (!(o_ptr->tval == TV_HAFTED))
652 else if (IS_FLG(FLG_SHIELDS))
654 if (!(o_ptr->tval == TV_SHIELD))
657 else if (IS_FLG(FLG_BOWS))
659 if (!(o_ptr->tval == TV_BOW))
662 else if (IS_FLG(FLG_RINGS))
664 if (!(o_ptr->tval == TV_RING))
667 else if (IS_FLG(FLG_AMULETS))
669 if (!(o_ptr->tval == TV_AMULET))
672 else if (IS_FLG(FLG_SUITS))
674 if (!(o_ptr->tval == TV_DRAG_ARMOR ||
675 o_ptr->tval == TV_HARD_ARMOR ||
676 o_ptr->tval == TV_SOFT_ARMOR))
679 else if (IS_FLG(FLG_CLOAKS))
681 if (!(o_ptr->tval == TV_CLOAK))
684 else if (IS_FLG(FLG_HELMS))
686 if (!(o_ptr->tval == TV_CROWN || o_ptr->tval == TV_HELM))
689 else if (IS_FLG(FLG_GLOVES))
691 if (!(o_ptr->tval == TV_GLOVES))
694 else if (IS_FLG(FLG_BOOTS))
696 if (!(o_ptr->tval == TV_BOOTS))
704 if (!strncmp(o_name, ptr, strlen(ptr)))
709 if (strstr_j(o_name, ptr))
711 if (strstr(o_name, ptr))
720 if (!IS_FLG(FLG_COLLECTING))
722 /* Check if there is a same item */
723 for (j = 0; j < INVEN_PACK; j++)
726 * 'Collecting' means the item must be absorbed
727 * into an inventory slot.
728 * But an item can not be absorbed into itself!
730 if ((&inventory[j] != o_ptr) &&
731 object_similar(&inventory[j], o_ptr))
742 * Automatically destroy items in this grid.
744 static bool is_opt_confirm_destroy(object_type *o_ptr)
746 if (!destroy_items) return FALSE;
748 /* Known to be worthless? */
750 if (object_value(o_ptr) > 0) return FALSE;
753 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_DRAG_ARMOR)) return FALSE;
756 if ((o_ptr->tval == TV_CHEST) && o_ptr->pval) return FALSE;
760 if (o_ptr->tval == TV_CORPSE
761 && object_is_shoukinkubi(o_ptr)) return FALSE;
765 if (o_ptr->tval == TV_CORPSE) return FALSE;
768 if ((o_ptr->tval == TV_SKELETON) || (o_ptr->tval == TV_BOTTLE) || (o_ptr->tval == TV_JUNK) || (o_ptr->tval == TV_STATUE)) return FALSE;
770 if (o_ptr->tval == TV_GOLD) return FALSE;
779 void auto_inscribe_item(int item, int idx)
783 /* Get the item (in the pack) */
784 if (item >= 0) o_ptr = &inventory[item];
786 /* Get the item (on the floor) */
787 else o_ptr = &o_list[0 - item];
789 if (idx >= 0 && autopick_list[idx].insc && !o_ptr->inscription)
791 o_ptr->inscription = inscribe_flags(o_ptr, autopick_list[idx].insc);
793 if (item >= INVEN_RARM)
795 /* Redraw inscription */
796 p_ptr->window |= (PW_EQUIP);
798 /* {.} and {$} effect p_ptr->warning and TRC_TELEPORT_SELF */
799 p_ptr->update |= (PU_BONUS);
803 /* Redraw inscription */
804 p_ptr->window |= (PW_INVEN);
811 * Automatically destroy an item if it is to be destroyed
813 bool auto_destroy_item(int item, int autopick_idx)
815 char o_name[MAX_NLEN];
818 /* Get the item (in the pack) */
819 if (item >= 0) o_ptr = &inventory[item];
821 /* Get the item (on the floor) */
822 else o_ptr = &o_list[0 - item];
824 if ((autopick_idx == -1 && is_opt_confirm_destroy(o_ptr)) ||
825 (autopick_idx >= 0 && (autopick_list[autopick_idx].action & DO_AUTODESTROY)))
829 /* Describe the object (with {terrible/special}) */
830 object_desc(o_name, o_ptr, TRUE, 3);
833 if (!can_player_destroy_object(o_ptr))
837 msg_format("%s¤ÏÇ˲õÉÔǽ¤À¡£", o_name);
839 msg_format("You cannot auto-destroy %s.", o_name);
846 /* Record name of destroyed item */
847 autopick_free_entry(&autopick_entry_last_destroyed);
848 autopick_entry_from_object(&autopick_entry_last_destroyed, o_ptr);
850 /* Eliminate the item (from the pack) */
853 inven_item_increase(item, -(o_ptr->number));
854 inven_item_optimize(item);
857 /* Eliminate the item (from the floor) */
860 delete_object_idx(0 - item);
863 /* Print a message */
865 msg_format("%s¤ò¼«Æ°Ç˲õ¤·¤Þ¤¹¡£", o_name);
867 msg_format("Auto-destroying %s.", o_name);
878 * Automatically pickup/destroy items in this grid.
880 void auto_pickup_items(cave_type *c_ptr)
882 s16b this_o_idx, next_o_idx = 0;
884 /* Scan the pile of objects */
885 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
890 object_type *o_ptr = &o_list[this_o_idx];
892 /* Acquire next object */
893 next_o_idx = o_ptr->next_o_idx;
895 idx = is_autopick(o_ptr);
897 /* Item index for floor -1,-2,-3,... */
898 auto_inscribe_item((-this_o_idx), idx);
900 if (idx >= 0 && (autopick_list[idx].action & DO_AUTOPICK))
904 if (!inven_carry_okay(o_ptr))
906 char o_name[MAX_NLEN];
908 /* Describe the object */
909 object_desc(o_name, o_ptr, TRUE, 3);
913 msg_format("¥¶¥Ã¥¯¤Ë¤Ï%s¤òÆþ¤ì¤ë·ä´Ö¤¬¤Ê¤¤¡£", o_name);
915 msg_format("You have no room for %s.", o_name);
919 py_pickup_aux(this_o_idx);
926 * When always_pickup is 'yes', we disable
927 * auto-destroyer from autopick function, and do only
928 * easy-auto-destroyer.
932 if (auto_destroy_item((-this_o_idx), (!always_pickup ? idx : -2)))
940 * Describe which kind of object is Auto-picked/destroyed
942 static void describe_autopick(char *buff, autopick_type *entry)
944 cptr str = entry->name;
945 byte act = entry->action;
946 cptr insc = entry->insc;
952 cptr before_str[20], body_str;
955 body_str = "¥¢¥¤¥Æ¥à";
957 /*** Collecting items ***/
958 /*** Which can be absorbed into a slot as a bundle ***/
959 if (IS_FLG(FLG_COLLECTING))
960 before_str[before_n++] = "¼ý½¸Ãæ¤Ç´û¤Ë»ý¤Ã¤Æ¤¤¤ë¥¹¥í¥Ã¥È¤Ë¤Þ¤È¤á¤é¤ì¤ë";
962 /*** Unidentified ***/
963 if (IS_FLG(FLG_UNIDENTIFIED))
964 before_str[before_n++] = "̤´ÕÄê¤Î";
967 if (IS_FLG(FLG_IDENTIFIED))
968 before_str[before_n++] = "´ÕÄêºÑ¤ß¤Î";
970 /*** *Identified* ***/
971 if (IS_FLG(FLG_STAR_IDENTIFIED))
972 before_str[before_n++] = "´°Á´¤Ë´ÕÄêºÑ¤ß¤Î";
975 if (IS_FLG(FLG_NAMELESS))
977 before_str[before_n++] = "¥¨¥´¤Ç¤â¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤Ç¤â¤Ê¤¤";
981 /*** Unaware items ***/
982 if (IS_FLG(FLG_UNAWARE))
983 before_str[before_n++] = "̤´ÕÄê¤Ç¤½¤Î¸ú²Ì¤âȽÌÀ¤·¤Æ¤¤¤Ê¤¤";
985 /*** Worthless items ***/
986 if (IS_FLG(FLG_WORTHLESS))
987 before_str[before_n++] = "Ź¤Ç̵²ÁÃͤÈȽÄꤵ¤ì¤ë";
989 /*** Dice boosted (weapon of slaying) ***/
990 if (IS_FLG(FLG_BOOSTED))
992 before_str[before_n++] = "¥À¥á¡¼¥¸¥À¥¤¥¹¤¬Ä̾ï¤è¤êÂ礤¤";
996 /*** Weapons whose dd*ds is more than nn ***/
997 if (IS_FLG(FLG_MORE_THAN))
999 static char more_than_desc_str[] = "___";
1000 before_str[before_n++] = "¥À¥á¡¼¥¸¥À¥¤¥¹¤ÎºÇÂçÃͤ¬";
1003 sprintf(more_than_desc_str,"%2d", entry->dice);
1004 before_str[before_n++] = more_than_desc_str;
1005 before_str[before_n++] = "°Ê¾å¤Î";
1008 /*** Wanted monster's corpse/skeletons ***/
1009 if (IS_FLG(FLG_WANTED))
1011 before_str[before_n++] = "¥Ï¥ó¥¿¡¼»ö̳½ê¤Ç¾Þ¶â¼ó¤È¤µ¤ì¤Æ¤¤¤ë";
1012 body_str = "»àÂΤä¹ü";
1015 /*** Human corpse/skeletons (for Daemon magic) ***/
1016 if (IS_FLG(FLG_HUMAN))
1018 before_str[before_n++] = "°ËâËâË¡¤Ç»È¤¦¤¿¤á¤Î¿Í´Ö¤ä¥Ò¥å¡¼¥Þ¥Î¥¤¥É¤Î";
1019 body_str = "»àÂΤä¹ü";
1022 /*** Unique monster's corpse/skeletons/statues ***/
1023 if (IS_FLG(FLG_UNIQUE))
1025 before_str[before_n++] = "¥æ¥Ë¡¼¥¯¥â¥ó¥¹¥¿¡¼¤Î";
1026 body_str = "»àÂΤä¹ü";
1029 /*** Unreadable spellbooks ***/
1030 if (IS_FLG(FLG_UNREADABLE))
1032 before_str[before_n++] = "Îΰ褬°Û¤Ê¤ë°Ù¤Ë¤¢¤Ê¤¿¤Ë¤ÏÆɤá¤Ê¤¤";
1033 body_str = "ËâË¡½ñ";
1036 /*** First realm spellbooks ***/
1037 if (IS_FLG(FLG_REALM1))
1039 before_str[before_n++] = "Âè°ìÎΰè¤Î";
1040 body_str = "ËâË¡½ñ";
1043 /*** Second realm spellbooks ***/
1044 if (IS_FLG(FLG_REALM2))
1046 before_str[before_n++] = "ÂèÆóÎΰè¤Î";
1047 body_str = "ËâË¡½ñ";
1050 /*** First rank spellbooks ***/
1051 if (IS_FLG(FLG_FIRST))
1053 before_str[before_n++] = "Á´4ºý¤ÎÆâ¤Î1ºýÌܤÎ";
1054 body_str = "ËâË¡½ñ";
1057 /*** Second rank spellbooks ***/
1058 if (IS_FLG(FLG_SECOND))
1060 before_str[before_n++] = "Á´4ºý¤ÎÆâ¤Î2ºýÌܤÎ";
1061 body_str = "ËâË¡½ñ";
1064 /*** Third rank spellbooks ***/
1065 if (IS_FLG(FLG_THIRD))
1067 before_str[before_n++] = "Á´4ºý¤ÎÆâ¤Î3ºýÌܤÎ";
1068 body_str = "ËâË¡½ñ";
1071 /*** Fourth rank spellbooks ***/
1072 if (IS_FLG(FLG_FOURTH))
1074 before_str[before_n++] = "Á´4ºý¤ÎÆâ¤Î4ºýÌܤÎ";
1075 body_str = "ËâË¡½ñ";
1079 if (IS_FLG(FLG_ITEMS))
1080 ; /* Nothing to do */
1081 else if (IS_FLG(FLG_ARTIFACTS))
1082 body_str = "¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È";
1083 else if (IS_FLG(FLG_WEAPONS))
1085 else if (IS_FLG(FLG_ARMORS))
1087 else if (IS_FLG(FLG_MISSILES))
1088 body_str = "ÃƤäÌð¤ä¥¯¥í¥¹¥Ü¥¦¤ÎÌð";
1089 else if (IS_FLG(FLG_DEVICES))
1090 body_str = "´¬Êª¤äËâË¡ËÀ¤ä¾ó¤ä¥í¥Ã¥É";
1091 else if (IS_FLG(FLG_LIGHTS))
1092 body_str = "¸÷¸»ÍѤΥ¢¥¤¥Æ¥à";
1093 else if (IS_FLG(FLG_JUNKS))
1094 body_str = "Àޤ줿ËÀÅù¤Î¥¬¥é¥¯¥¿";
1095 else if (IS_FLG(FLG_SPELLBOOKS))
1096 body_str = "ËâË¡½ñ";
1097 else if (IS_FLG(FLG_HAFTED))
1099 else if (IS_FLG(FLG_SHIELDS))
1101 else if (IS_FLG(FLG_BOWS))
1102 body_str = "¥¹¥ê¥ó¥°¤äµÝ¤ä¥¯¥í¥¹¥Ü¥¦";
1103 else if (IS_FLG(FLG_RINGS))
1105 else if (IS_FLG(FLG_AMULETS))
1106 body_str = "¥¢¥ß¥å¥ì¥Ã¥È";
1107 else if (IS_FLG(FLG_SUITS))
1109 else if (IS_FLG(FLG_CLOAKS))
1110 body_str = "¥¯¥í¡¼¥¯";
1111 else if (IS_FLG(FLG_HELMS))
1112 body_str = "¥Ø¥ë¥á¥Ã¥È¤ä´§";
1113 else if (IS_FLG(FLG_GLOVES))
1115 else if (IS_FLG(FLG_BOOTS))
1116 body_str = "¥Ö¡¼¥Ä";
1120 strcat(buff, "Á´¤Æ¤Î");
1121 else for (i = 0; i < before_n && before_str[i]; i++)
1122 strcat(buff, before_str[i]);
1124 strcat(buff, body_str);
1134 strcat(buff, "¤Ç¡¢Ì¾Á°¤¬¡Ö");
1135 strncat(buff, str, 80);
1137 strcat(buff, "¡×¤Ç»Ï¤Þ¤ë¤â¤Î");
1139 strcat(buff, "¡×¤ò´Þ¤à¤â¤Î");
1143 strncat(buff, format("¤Ë¡Ö%s¡×¤È¹ï¤ó¤Ç", insc), 80);
1147 if (act & DONT_AUTOPICK)
1148 strcat(buff, "ÊüÃÖ¤¹¤ë¡£");
1149 else if (act & DO_AUTODESTROY)
1150 strcat(buff, "Ç˲õ¤¹¤ë¡£");
1152 strcat(buff, "½¦¤¦¡£");
1154 if (act & DO_DISPLAY)
1156 if (act & DONT_AUTOPICK)
1157 strcat(buff, "Á´ÂΥޥå×('M')¤Ç'N'¤ò²¡¤·¤¿¤È¤¤Ëɽ¼¨¤¹¤ë¡£");
1158 else if (act & DO_AUTODESTROY)
1159 strcat(buff, "Á´ÂΥޥå×('M')¤Ç'K'¤ò²¡¤·¤¿¤È¤¤Ëɽ¼¨¤¹¤ë¡£");
1161 strcat(buff, "Á´ÂΥޥå×('M')¤Ç'M'¤ò²¡¤·¤¿¤È¤¤Ëɽ¼¨¤¹¤ë¡£");
1164 strcat(buff, "Á´ÂΥޥåפˤÏɽ¼¨¤·¤Ê¤¤");
1168 cptr before_str[20], after_str[20], which_str[20], whose_str[20], body_str;
1169 int before_n = 0, after_n = 0, which_n = 0, whose_n = 0;
1173 /*** Collecting items ***/
1174 /*** Which can be absorbed into a slot as a bundle ***/
1175 if (IS_FLG(FLG_COLLECTING))
1176 which_str[which_n++] = "can be absorbed into an existing inventory slot";
1178 /*** Unidentified ***/
1179 if (IS_FLG(FLG_UNIDENTIFIED))
1180 before_str[before_n++] = "unidentified";
1182 /*** Identified ***/
1183 if (IS_FLG(FLG_IDENTIFIED))
1184 before_str[before_n++] = "identified";
1186 /*** *Identified* ***/
1187 if (IS_FLG(FLG_STAR_IDENTIFIED))
1188 before_str[before_n++] = "fully identified";
1191 if (IS_FLG(FLG_NAMELESS))
1193 body_str = "equipment";
1194 which_str[which_n++] = "is neither ego-item nor artifact";
1197 /*** Unaware items ***/
1198 if (IS_FLG(FLG_UNAWARE))
1200 before_str[before_n++] = "unidentified";
1201 whose_str[whose_n++] = "basic abilities are not known";
1204 /*** Worthless items ***/
1205 if (IS_FLG(FLG_WORTHLESS))
1207 before_str[before_n++] = "worthless";
1208 which_str[which_n++] = "can not be sold at stores";
1211 /*** Dice boosted (weapon of slaying) ***/
1212 if (IS_FLG(FLG_BOOSTED))
1214 body_str = "weapons";
1215 whose_str[whose_n++] = "damage dice is bigger than normal";
1218 /*** Weapons whic dd*ds is more than nn ***/
1219 if (IS_FLG(FLG_MORE_THAN))
1221 static char more_than_desc_str[] =
1222 "maximum damage from dice is bigger than __";
1223 body_str = "weapons";
1225 sprintf(more_than_desc_str + sizeof(more_than_desc_str) - 3,
1226 "%2d", entry->dice);
1227 whose_str[whose_n++] = more_than_desc_str;
1230 /*** Wanted monster's corpse/skeletons ***/
1231 if (IS_FLG(FLG_WANTED))
1233 body_str = "corpse or skeletons";
1234 which_str[which_n++] = "is wanted at the Hunter's Office";
1237 /*** Human corpse/skeletons (for Daemon magic) ***/
1238 if (IS_FLG(FLG_HUMAN))
1240 before_str[before_n++] = "humanoid";
1241 body_str = "corpse or skeletons";
1242 which_str[which_n++] = "can be used for Daemon magic";
1245 /*** Unique monster's corpse/skeletons/statues ***/
1246 if (IS_FLG(FLG_UNIQUE))
1248 before_str[before_n++] = "unique monster's";
1249 body_str = "corpse or skeletons";
1252 /*** Unreadable spellbooks ***/
1253 if (IS_FLG(FLG_UNREADABLE))
1255 body_str = "spellbooks";
1256 after_str[after_n++] = "of different realms from yours";
1259 /*** First realm spellbooks ***/
1260 if (IS_FLG(FLG_REALM1))
1262 body_str = "spellbooks";
1263 after_str[after_n++] = "of your first realm";
1266 /*** Second realm spellbooks ***/
1267 if (IS_FLG(FLG_REALM2))
1269 body_str = "spellbooks";
1270 after_str[after_n++] = "of your second realm";
1273 /*** First rank spellbooks ***/
1274 if (IS_FLG(FLG_FIRST))
1276 before_str[before_n++] = "first one of four";
1277 body_str = "spellbooks";
1280 /*** Second rank spellbooks ***/
1281 if (IS_FLG(FLG_SECOND))
1283 before_str[before_n++] = "second one of four";
1284 body_str = "spellbooks";
1287 /*** Third rank spellbooks ***/
1288 if (IS_FLG(FLG_THIRD))
1290 before_str[before_n++] = "third one of four";
1291 body_str = "spellbooks";
1294 /*** Fourth rank spellbooks ***/
1295 if (IS_FLG(FLG_FOURTH))
1297 before_str[before_n++] = "fourth one of four";
1298 body_str = "spellbooks";
1302 if (IS_FLG(FLG_ITEMS))
1303 ; /* Nothing to do */
1304 else if (IS_FLG(FLG_WEAPONS))
1305 body_str = "weapons";
1306 else if (IS_FLG(FLG_ARMORS))
1307 body_str = "armors";
1308 else if (IS_FLG(FLG_MISSILES))
1309 body_str = "shots, arrows or crossbow bolts";
1310 else if (IS_FLG(FLG_DEVICES))
1311 body_str = "scrolls, wands, staves or rods";
1312 else if (IS_FLG(FLG_LIGHTS))
1313 body_str = "light sources";
1314 else if (IS_FLG(FLG_JUNKS))
1315 body_str = "junk such as broken sticks";
1316 else if (IS_FLG(FLG_SPELLBOOKS))
1317 body_str = "spellbooks";
1318 else if (IS_FLG(FLG_HAFTED))
1319 body_str = "hafted weapons";
1320 else if (IS_FLG(FLG_SHIELDS))
1321 body_str = "shields";
1322 else if (IS_FLG(FLG_BOWS))
1323 body_str = "slings, bows or crossbows";
1324 else if (IS_FLG(FLG_RINGS))
1326 else if (IS_FLG(FLG_AMULETS))
1327 body_str = "amulets";
1328 else if (IS_FLG(FLG_SUITS))
1329 body_str = "body armors";
1330 else if (IS_FLG(FLG_CLOAKS))
1331 body_str = "cloaks";
1332 else if (IS_FLG(FLG_HELMS))
1333 body_str = "helms or crowns";
1334 else if (IS_FLG(FLG_GLOVES))
1335 body_str = "gloves";
1336 else if (IS_FLG(FLG_BOOTS))
1339 /* Prepare a string for item name */
1346 whose_str[whose_n++] = "name is beginning with \"";
1349 which_str[which_n++] = "have \"";
1353 /* Describe action flag */
1354 if (act & DONT_AUTOPICK)
1355 strcpy(buff, "Leave on floor ");
1356 else if (act & DO_AUTODESTROY)
1357 strcpy(buff, "Destroy ");
1359 strcpy(buff, "Pickup ");
1361 /* Auto-insctiption */
1363 strncat(buff, format("and inscribe \"%s\" on ", insc), 80);
1367 strcat(buff, "all ");
1368 else for (i = 0; i < before_n && before_str[i]; i++)
1370 strcat(buff, before_str[i]);
1375 strcat(buff, body_str);
1378 for (i = 0; i < after_n && after_str[i]; i++)
1381 strcat(buff, after_str[i]);
1385 for (i = 0; i < whose_n && whose_str[i]; i++)
1388 strcat(buff, " whose ");
1390 strcat(buff, ", and ");
1392 strcat(buff, whose_str[i]);
1395 /* Item name ; whose name is beginning with "str" */
1402 /* whose ..., and which .... */
1403 if (whose_n && which_n)
1404 strcat(buff, ", and ");
1407 for (i = 0; i < which_n && which_str[i]; i++)
1410 strcat(buff, " which ");
1412 strcat(buff, ", and ");
1414 strcat(buff, which_str[i]);
1417 /* Item name ; which have "str" as part of its name */
1420 strncat(buff, str, 80);
1421 strcat(buff, "\" as part of its name");
1425 /* Describe whether it will be displayed on the full map or not */
1426 if (act & DO_DISPLAY)
1428 if (act & DONT_AUTOPICK)
1429 strcat(buff, " Display these items when you press 'N' in the full map('M').");
1430 else if (act & DO_AUTODESTROY)
1431 strcat(buff, " Display these items when you press 'K' in the full map('M').");
1433 strcat(buff, " Display these items when you press 'M' in the full map('M').");
1436 strcat(buff, " Not displayed in the full map.");
1442 #define MAX_LINES 3000
1445 * Read whole lines of a file to memory
1447 static cptr *read_text_lines(cptr filename, bool user)
1449 cptr *lines_list = NULL;
1457 /* Hack -- drop permissions */
1459 path_build(buf, 1024, ANGBAND_DIR_USER, filename);
1463 path_build(buf, 1024, ANGBAND_DIR_PREF, filename);
1467 fff = my_fopen(buf, "r");
1471 /* Allocate list of pointers */
1472 C_MAKE(lines_list, MAX_LINES, cptr);
1475 while (0 == my_fgets(fff, buf, 1024))
1477 lines_list[lines++] = string_make(buf);
1478 if (lines >= MAX_LINES - 1) break;
1481 lines_list[0] = string_make("");
1489 if (!fff) return NULL;
1493 static cptr *read_pickpref_text_lines(void)
1499 sprintf(buf, "picktype-%s.prf", player_name);
1501 sprintf(buf, "pickpref-%s.prf", player_name);
1503 lines_list = read_text_lines(buf, TRUE);
1508 lines_list = read_text_lines("picktype.prf", TRUE);
1510 lines_list = read_text_lines("pickpref.prf", TRUE);
1517 lines_list = read_text_lines("picktype.prf", FALSE);
1519 lines_list = read_text_lines("pickpref.prf", FALSE);
1525 /* Allocate list of pointers */
1526 C_MAKE(lines_list, MAX_LINES, cptr);
1527 lines_list[0] = string_make("");
1533 * Write whole lines of memory to a file.
1535 static bool write_text_lines(cptr filename, cptr *lines_list)
1542 /* Hack -- drop permissions */
1545 /* Build the filename */
1546 path_build(buf, 1024, ANGBAND_DIR_USER, filename);
1549 fff = my_fopen(buf, "w");
1552 for (lines = 0; lines_list[lines]; lines++)
1553 my_fputs(fff, lines_list[lines], 1024);
1561 if (!fff) return FALSE;
1567 * Free memory of lines_list.
1569 static void free_text_lines(cptr *lines_list)
1573 for (lines = 0; lines_list[lines]; lines++)
1574 string_free(lines_list[lines]);
1576 /* free list of pointers */
1577 C_FREE((char **)lines_list, MAX_LINES, char *);
1584 static void insert_string(cptr *lines_list, cptr str, int x, int y)
1589 for (i = j = 0; lines_list[y][i] && i < x; i++)
1590 buf[j++] = lines_list[y][i];
1592 while (*str) buf[j++] = *str++;
1594 for (; lines_list[y][i]; i++)
1595 buf[j++] = lines_list[y][i];
1597 string_free(lines_list[y]);
1598 lines_list[y] = string_make(buf);
1604 static void delete_string(cptr *lines_list, int n, int x, int y)
1609 for (i = j = 0; lines_list[y][i] && i < x; i++)
1612 if (iskanji(lines_list[y][i]))
1613 buf[j++] = lines_list[y][i++];
1615 buf[j++] = lines_list[y][i];
1619 for (; lines_list[y][i]; i++)
1620 buf[j++] = lines_list[y][i];
1622 string_free(lines_list[y]);
1623 lines_list[y] = string_make(buf);
1628 * Delete or insert string
1630 static void toggle_string(cptr *lines_list, int flg, int y)
1632 autopick_type an_entry, *entry = &an_entry;
1634 if (!autopick_new_entry(entry, lines_list[y]))
1637 string_free(lines_list[y]);
1643 lines_list[y] = autopick_line_from_entry(entry);
1647 * Insert return code and split the line
1649 static bool insert_return_code(cptr *lines_list, int cx, int cy)
1654 for (k = 0; lines_list[k]; k++)
1655 /* count number of lines */ ;
1657 if (k >= MAX_LINES - 2) return FALSE;
1660 /* Move down lines */
1662 lines_list[k+1] = lines_list[k];
1664 /* Split current line */
1665 for (i = j = 0; lines_list[cy][i] && i < cx; i++)
1668 if (iskanji(lines_list[cy][i]))
1669 buf[j++] = lines_list[cy][i++];
1671 buf[j++] = lines_list[cy][i];
1674 lines_list[cy+1] = string_make(&lines_list[cy][i]);
1675 string_free(lines_list[cy]);
1676 lines_list[cy] = string_make(buf);
1682 * Get auto-picker entry from o_ptr.
1684 void autopick_entry_from_object(autopick_type *entry, object_type *o_ptr)
1686 char o_name[MAX_NLEN];
1687 object_desc(o_name, o_ptr, FALSE, 0);
1689 entry->name = string_make(o_name);
1690 entry->insc = string_make(quark_str(o_ptr->inscription));
1691 entry->action = DO_AUTOPICK | DO_DISPLAY;
1692 entry->flag[0] = entry->flag[1] = 0L;
1695 if (!object_aware_p(o_ptr))
1696 ADD_FLG(FLG_UNAWARE);
1697 if (object_value(o_ptr) <= 0)
1698 ADD_FLG(FLG_WORTHLESS);
1703 case TV_HAFTED: case TV_POLEARM: case TV_SWORD: case TV_DIGGING:
1704 k_ptr = &k_info[o_ptr->k_idx];
1705 if ((o_ptr->dd != k_ptr->dd) || (o_ptr->ds != k_ptr->ds))
1706 ADD_FLG(FLG_BOOSTED);
1709 if (o_ptr->tval == TV_CORPSE && object_is_shoukinkubi(o_ptr))
1711 REM_FLG(FLG_WORTHLESS);
1712 ADD_FLG(FLG_WANTED);
1715 if ((o_ptr->tval == TV_CORPSE || o_ptr->tval == TV_STATUE)
1716 && (r_info[o_ptr->pval].flags1 & RF1_UNIQUE))
1718 REM_FLG(FLG_WORTHLESS);
1719 ADD_FLG(FLG_UNIQUE);
1722 if (o_ptr->tval == TV_CORPSE && strchr("pht", r_info[o_ptr->pval].d_char))
1724 REM_FLG(FLG_WORTHLESS);
1728 if (o_ptr->tval >= TV_LIFE_BOOK &&
1729 !check_book_realm(o_ptr->tval, o_ptr->sval))
1730 ADD_FLG(FLG_UNREADABLE);
1732 if (REALM1_BOOK == o_ptr->tval &&
1733 p_ptr->pclass != CLASS_SORCERER &&
1734 p_ptr->pclass != CLASS_RED_MAGE)
1735 ADD_FLG(FLG_REALM1);
1737 if (REALM2_BOOK == o_ptr->tval &&
1738 p_ptr->pclass != CLASS_SORCERER &&
1739 p_ptr->pclass != CLASS_RED_MAGE)
1740 ADD_FLG(FLG_REALM2);
1742 if (o_ptr->tval >= TV_LIFE_BOOK && 0 == o_ptr->sval)
1744 if (o_ptr->tval >= TV_LIFE_BOOK && 1 == o_ptr->sval)
1745 ADD_FLG(FLG_SECOND);
1746 if (o_ptr->tval >= TV_LIFE_BOOK && 2 == o_ptr->sval)
1748 if (o_ptr->tval >= TV_LIFE_BOOK && 3 == o_ptr->sval)
1749 ADD_FLG(FLG_FOURTH);
1751 if (object_known_p(o_ptr) && (artifact_p(o_ptr) || o_ptr->art_name))
1752 ADD_FLG(FLG_ARTIFACTS);
1754 else if (o_ptr->tval == TV_SHOT || o_ptr->tval == TV_BOLT
1755 || o_ptr->tval == TV_ARROW)
1756 ADD_FLG(FLG_MISSILES);
1757 else if (o_ptr->tval == TV_SCROLL || o_ptr->tval == TV_STAFF
1758 || o_ptr->tval == TV_WAND || o_ptr->tval == TV_ROD)
1759 ADD_FLG(FLG_DEVICES);
1760 else if (o_ptr->tval == TV_LITE)
1761 ADD_FLG(FLG_LIGHTS);
1762 else if (o_ptr->tval == TV_SKELETON || o_ptr->tval == TV_BOTTLE
1763 || o_ptr->tval == TV_JUNK || o_ptr->tval == TV_STATUE)
1765 else if (o_ptr->tval >= TV_LIFE_BOOK)
1766 ADD_FLG(FLG_SPELLBOOKS);
1767 else if (o_ptr->tval == TV_HAFTED)
1768 ADD_FLG(FLG_HAFTED);
1769 else if (o_ptr->tval == TV_POLEARM || o_ptr->tval == TV_SWORD
1770 || o_ptr->tval == TV_DIGGING)
1771 ADD_FLG(FLG_WEAPONS);
1772 else if (o_ptr->tval == TV_SHIELD)
1773 ADD_FLG(FLG_SHIELDS);
1774 else if (o_ptr->tval == TV_BOW)
1776 else if (o_ptr->tval == TV_RING)
1778 else if (o_ptr->tval == TV_AMULET)
1779 ADD_FLG(FLG_AMULETS);
1780 else if (o_ptr->tval == TV_DRAG_ARMOR || o_ptr->tval == TV_HARD_ARMOR ||
1781 o_ptr->tval == TV_SOFT_ARMOR)
1783 else if (o_ptr->tval == TV_CLOAK)
1784 ADD_FLG(FLG_CLOAKS);
1785 else if (o_ptr->tval == TV_HELM)
1787 else if (o_ptr->tval == TV_GLOVES)
1788 ADD_FLG(FLG_GLOVES);
1789 else if (o_ptr->tval == TV_BOOTS)
1796 * Choose an item and get auto-picker entry from it.
1798 static bool entry_from_object(autopick_type *entry)
1806 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÅÐÏ¿¤·¤Þ¤¹¤«? ";
1807 s = "¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£";
1809 q = "Entry which item? ";
1810 s = "You have nothing to entry.";
1812 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP))) return FALSE;
1814 /* Get the item (in the pack) */
1817 o_ptr = &inventory[item];
1820 /* Get the item (on the floor) */
1823 o_ptr = &o_list[0 - item];
1826 autopick_entry_from_object(entry, o_ptr);
1832 * Initialize auto-picker preference
1834 void init_autopicker(void)
1836 static const char easy_autopick_inscription[] = "(:=g";
1837 autopick_type entry;
1840 /* Clear old entries */
1841 for( i = 0; i < max_autopick; i++)
1842 autopick_free_entry(&autopick_list[i]);
1846 /* There is always one entry "=g" */
1847 autopick_new_entry(&entry, easy_autopick_inscription);
1848 autopick_list[max_autopick++] = entry;
1853 * Description of control commands
1858 static cptr ctrl_command_desc[] =
1861 #define LAST_DESTROYED 6
1862 "^P ^N ^B ^F ¾å²¼º¸±¦¤Ë°ÜÆ°",
1863 "^A ^E ¹Ô¤ÎÀèƬ¡¢½ªÃ¼",
1864 "^Q ÆþÎÏ/¥³¥Þ¥ó¥É¥â¡¼¥ÉÀÚ¤êÂؤ¨",
1865 "^R Êѹ¹¤òÁ´¤Æ¼è¤ê¾Ã¤·¤Æ¸µ¤ËÌ᤹",
1866 "------------------------------------",
1867 "^I »ý¤Áʪ/ÁõÈ÷¤«¤éÁªÂò",
1869 "^K ¥«¡¼¥½¥ë¤«¤é½ªÃ¼¤Þ¤Çºï½ü",
1870 "^Y ºï½ü(^K)¤·¤¿¹Ô¤òÁÞÆþ",
1871 "^C ¼ï²¡¢¿¦¶È¤Î¾ò·ï¼°¤òÁÞÆþ",
1872 "------------------------------------",
1873 "^S Êѹ¹ (!Ç˲õ/~ÊüÃÖ/½¦¤¦)",
1874 "^G \"(\" Á´ÂΥޥåפÇɽ¼¨¤·¤Ê¤¤",
1875 "^O \"#\" ¼«Æ°¹ï¤ß",
1876 "------------------------------------",
1877 "^U ̤´ÕÄê/̤ȽÌÀ/´ÕÄê/*´ÕÄê*",
1883 #define LAST_DESTROYED 6
1884 "^P ^N ^B ^F Move Cursor",
1885 "^A ^E Beginning and End of Line",
1886 "^Q Toggle Insert/Command mode",
1887 "^R Revert to Original File",
1888 "------------------------------------",
1889 "^I Object in Inventry/Equipment",
1891 "^K Kill Rest of Line",
1892 "^Y Insert killed(^K) text",
1893 "^C Insert conditional expression",
1894 "------------------------------------",
1895 "^S Toggle(!Destroy/~Leave/Pick)",
1896 "^G \"(\" No display in the 'M'ap",
1897 "^O \"#\" Auto-Inscribe",
1898 "------------------------------------",
1899 "^U Toggle 'identified' state",
1902 "^Z \"collecting\"",
1908 #define MAX_YANK 1024
1909 #define DIRTY_ALL 0x01
1910 #define DIRTY_COMMAND 0x02
1911 #define DIRTY_MODE 0x04
1912 #define DIRTY_SCREEN 0x04
1915 * In-game editor of Object Auto-picker/Destoryer
1917 void do_cmd_edit_autopick(void)
1919 static int cx = 0, cy = 0;
1920 static int upper = 0, left = 0;
1922 cptr last_destroyed;
1923 char last_destroyed_command[WID_DESC+3];
1924 char yank_buf[MAX_YANK];
1926 autopick_type an_entry, *entry = &an_entry;
1933 int old_upper = -1, old_left = -1;
1935 int key = -1, old_key;
1937 bool edit_mode = FALSE;
1939 byte dirty_flags = DIRTY_ALL | DIRTY_COMMAND | DIRTY_MODE;
1940 int dirty_line = -1;
1942 int wid, hgt, old_wid = -1, old_hgt = -1;
1944 /* Free old entries */
1947 /* Name of the Last Destroyed Item */
1948 last_destroyed = autopick_line_from_entry(&autopick_entry_last_destroyed);
1950 /* Command Description of the Last Destroyed Item */
1953 strcpy(last_destroyed_command, "^L \"");
1954 strncpy(last_destroyed_command + 4, last_destroyed, WID_DESC-4);
1955 last_destroyed_command[WID_DESC+2] = '\0';
1960 strcpy(last_destroyed_command, "^L ºÇ¸å¤Ë¼«Æ°Ç˲õ¤·¤¿¥¢¥¤¥Æ¥à̾");
1962 strcpy(last_destroyed_command, "^L Last destroyed object");
1965 ctrl_command_desc[LAST_DESTROYED] = last_destroyed_command;
1967 /* Conditional Expression for Class and Race */
1968 sprintf(classrace, "?:[AND [EQU $RACE %s] [EQU $CLASS %s]]",
1970 rp_ptr->E_title, cp_ptr->E_title
1972 rp_ptr->title, cp_ptr->title
1976 /* Clear yank buffer */
1979 /* Read or initialize whole text */
1980 lines_list = read_pickpref_text_lines();
1982 /* Reset cursor position if needed */
1983 for (i = 0; i < cy; i++)
1992 /* Save the screen */
1995 /* Process requests until done */
1999 Term_get_size(&wid, &hgt);
2002 /* Don't let cursor at second byte of kanji */
2003 for (i = 0; lines_list[cy][i]; i++)
2004 if (iskanji(lines_list[cy][i]))
2015 /* Scroll if necessary */
2016 if (cy < upper || upper + hgt - 4 <= cy)
2017 upper = cy - (hgt-4)/2;
2020 if ((cx < left + 10 && left > 0) || left + wid - WID_DESC - 5 <= cx)
2021 left = cx - (wid - WID_DESC)*2/3;
2025 /* Redraw whole window after resize */
2026 if (old_wid != wid || old_hgt != hgt)
2027 dirty_flags |= DIRTY_SCREEN;
2029 /* Redraw all text after scroll */
2030 else if (old_upper != upper || old_left != left)
2031 dirty_flags |= DIRTY_ALL;
2034 if (dirty_flags & DIRTY_SCREEN)
2036 dirty_flags = DIRTY_ALL | DIRTY_COMMAND | DIRTY_MODE;
2042 if (dirty_flags & DIRTY_COMMAND)
2044 /* Display control command */
2045 for (i = 0; ctrl_command_desc[i]; i++)
2046 Term_putstr(wid - WID_DESC, i + 1, WID_DESC, TERM_WHITE, ctrl_command_desc[i]);
2049 /* Redraw mode line */
2050 if (dirty_flags & DIRTY_MODE)
2052 int sepa_length = wid - WID_DESC;
2055 for (i = 0; i < sepa_length; i++)
2061 strncpy(buf + sepa_length - 21, " (INSERT MODE) ", 16);
2063 strncpy(buf + sepa_length - 21, " (COMMAND MODE) ", 16);
2065 Term_putstr(0, hgt - 3, sepa_length, (byte) (edit_mode ? TERM_YELLOW : TERM_WHITE), buf);
2068 /* Dump up to 20, or hgt-4, lines of messages */
2069 for (i = 0; i < hgt - 4; i++)
2074 /* clean or dirty? */
2075 if (!(dirty_flags & DIRTY_ALL) && (dirty_line != upper+i))
2078 msg = lines_list[upper+i];
2081 /* Apply horizontal scroll */
2082 for (j = 0; *msg; msg++, j++)
2084 if (j == left) break;
2100 Term_erase(0, i + 1, wid - WID_DESC);
2102 /* Dump the messages, bottom to top */
2103 Term_putstr(leftcol, i + 1, wid - WID_DESC - 1, TERM_WHITE, msg);
2106 for (; i < hgt - 4; i++)
2109 Term_erase(0, i + 1, wid - WID_DESC);
2112 /* Display header line */
2115 prt("^Q ESC ¤Ç¥³¥Þ¥ó¥É¥â¡¼¥É¤Ø°Ü¹Ô¡¢Ä̾ï¤Îʸ»ú¤Ï¤½¤Î¤Þ¤ÞÆþÎÏ", 0, 0);
2117 prt("q _ ¤Ç½ªÎ»¡¢hjkl2468 ¤Ç°ÜÆ°¡¢^Q a i ¤ÇÆþÎϥ⡼¥É", 0, 0);
2120 prt("Press ^Q ESC to command mode, any letters to insert", 0, 0);
2122 prt("Press q _ to quit, hjkl2468 to move, ^Q a i to insert mode", 0, 0);
2124 /* Display current position */
2125 prt (format("(%d,%d)", cx, cy), 0, 70);
2127 /* Display information when updated */
2128 if (old_cy != cy || (dirty_flags & DIRTY_ALL) || dirty_line == cy)
2130 /* Clear information line */
2131 Term_erase(0, hgt - 3 + 1, wid);
2132 Term_erase(0, hgt - 3 + 2, wid);
2134 /* Display information */
2135 if (lines_list[cy][0] == '#')
2138 prt("¤³¤Î¹Ô¤Ï¥³¥á¥ó¥È¤Ç¤¹¡£", hgt - 3 + 1, 0);
2140 prt("This line is comment.", hgt - 3 + 1, 0);
2143 else if (lines_list[cy][1] == ':')
2145 switch(lines_list[cy][0])
2149 prt("¤³¤Î¹Ô¤Ï¾ò·ïʬ´ô¼°¤Ç¤¹¡£", hgt - 3 + 1, 0);
2151 prt("This line is Conditional Expression.", hgt - 3 + 1, 0);
2156 prt("¤³¤Î¹Ô¤Ï¥Þ¥¯¥í¤Î¼Â¹ÔÆâÍƤòÄêµÁ¤·¤Þ¤¹¡£", hgt - 3 + 1, 0);
2158 prt("This line defines Macro action.", hgt - 3 + 1, 0);
2163 prt("¤³¤Î¹Ô¤Ï¥Þ¥¯¥í¤Î¥È¥ê¥¬¡¼¡¦¥¡¼¤òÄêµÁ¤·¤Þ¤¹¡£", hgt - 3 + 1, 0);
2165 prt("This line defines Macro trigger key.", hgt - 3 + 1, 0);
2170 prt("¤³¤Î¹Ô¤Ï¥¡¼ÇÛÃÖ¤òÄêµÁ¤·¤Þ¤¹¡£", hgt - 3 + 1, 0);
2172 prt("This line defines Keymap.", hgt - 3 + 1, 0);
2178 /* Get description of an autopicker preference line */
2179 else if (autopick_new_entry(entry, lines_list[cy]))
2184 describe_autopick(buf, entry);
2186 roff_to_buf(buf, 79, temp);
2188 for (i = 0; i< 2; i++)
2194 prt(t, hgt - 3 + 1 + i, 0);
2198 autopick_free_entry(entry);
2203 Term_gotoxy(cx - left, cy - upper + 1);
2209 /* Save old key and location */
2217 /* Do not process macros except special keys */
2218 inkey_special = TRUE;
2229 /* Mode line is now dirty */
2230 dirty_flags |= DIRTY_MODE;
2232 else if (!iscntrl(key&0xff))
2236 for (i = j = 0; lines_list[cy][i] && i < cx; i++)
2237 buf[j++] = lines_list[cy][i];
2260 for (; lines_list[cy][i] && j + 1 < 1024; i++)
2261 buf[j++] = lines_list[cy][i];
2263 string_free(lines_list[cy]);
2264 lines_list[cy] = string_make(buf);
2265 len = strlen(lines_list[cy]);
2266 if (len < cx) cx = len;
2275 if (key == 'q' || key == '_') break;
2282 /* Mode line is now dirty */
2283 dirty_flags |= DIRTY_MODE;
2286 if (!autopick_new_entry(entry, lines_list[cy]))
2288 string_free(lines_list[cy]);
2290 entry->action &= ~DO_AUTODESTROY;
2291 if (entry->action & DO_AUTOPICK)
2293 entry->action &= ~DO_AUTOPICK;
2294 entry->action |= DONT_AUTOPICK;
2298 entry->action &= ~DONT_AUTOPICK;
2299 entry->action |= DO_AUTOPICK;
2302 lines_list[cy] = autopick_line_from_entry(entry);
2308 if (!autopick_new_entry(entry, lines_list[cy]))
2310 string_free(lines_list[cy]);
2312 entry->action &= ~DONT_AUTOPICK;
2313 if (entry->action & DO_AUTOPICK)
2315 entry->action &= ~DO_AUTOPICK;
2316 entry->action |= DO_AUTODESTROY;
2320 entry->action &= ~DO_AUTODESTROY;
2321 entry->action |= DO_AUTOPICK;
2324 lines_list[cy] = autopick_line_from_entry(entry);
2349 while (cy < upper + hgt-4 && lines_list[cy + 1])
2354 while (0 < cy && upper <= cy)
2356 while (0 < upper && cy + 1 < upper + hgt - 4)
2365 /* Beginning of line */
2373 len = strlen(lines_list[cy]);
2374 if (len < cx) cx = len;
2379 cx = strlen(lines_list[cy]);
2383 /* Insert a conditinal expression line */
2384 insert_return_code(lines_list, 0, cy);
2385 lines_list[cy] = string_make(classrace);
2387 insert_return_code(lines_list, 0, cy);
2388 lines_list[cy] = string_make("?:1");
2392 dirty_flags |= DIRTY_ALL;
2396 cx = strlen(lines_list[cy]);
2401 if (iskanji(lines_list[cy][cx])) cx++;
2404 len = strlen(lines_list[cy]);
2407 if (lines_list[cy + 1])
2417 /* Toggle display in the 'M'ap */
2418 if (lines_list[cy][0] != '(' && lines_list[cy][1] != '(')
2419 insert_string(lines_list, "(", 0, cy);
2420 else if (lines_list[cy][0] == '(')
2421 delete_string(lines_list, 1, 0, cy);
2422 else if (lines_list[cy][1] == '(')
2423 delete_string(lines_list, 1, 1, cy);
2429 /* Insert choosen item name */
2430 if (!entry_from_object(entry))
2432 /* Now dirty because of item/equip menu */
2433 dirty_flags |= DIRTY_SCREEN;
2436 tmp = autopick_line_from_entry(entry);
2437 autopick_free_entry(entry);
2440 insert_return_code(lines_list, 0, cy);
2441 lines_list[cy] = tmp;
2444 /* Now dirty because of item/equip menu */
2445 dirty_flags |= DIRTY_SCREEN;
2449 /* Insert a name of last destroyed item */
2452 insert_return_code(lines_list, 0, cy);
2453 lines_list[cy] = string_make(last_destroyed);
2457 dirty_flags |= DIRTY_ALL;
2460 case '\n': case '\r':
2461 /* Split a line or insert end of line */
2462 insert_return_code(lines_list, cx, cy);
2467 dirty_flags |= DIRTY_ALL;
2471 if (lines_list[cy + 1]) cy++;
2474 /* Prepare to write auto-inscription text */
2475 for (i = 0; lines_list[cy][i]; i++)
2476 if (lines_list[cy][i] == '#') break;
2477 if (!lines_list[cy][i]) insert_string(lines_list, "#", i, cy);
2483 dirty_flags |= DIRTY_MODE;
2491 edit_mode = !edit_mode;
2493 /* Mode line is now dirty */
2494 dirty_flags |= DIRTY_MODE;
2497 /* Revert to original */
2499 if (!get_check("Á´¤Æ¤ÎÊѹ¹¤òÇË´þ¤·¤Æ¸µ¤Î¾õÂÖ¤ËÌᤷ¤Þ¤¹¡£¤è¤í¤·¤¤¤Ç¤¹¤«¡© "))
2501 if (!get_check("Discard all change and revert to original file. Are you sure? "))
2505 free_text_lines(lines_list);
2506 lines_list = read_pickpref_text_lines();
2507 dirty_flags |= DIRTY_ALL | DIRTY_MODE;
2512 /* Rotate action; pickup/destroy/leave */
2513 if (!autopick_new_entry(entry, lines_list[cy]))
2515 string_free(lines_list[cy]);
2517 if (entry->action & DO_AUTOPICK)
2519 entry->action &= ~DO_AUTOPICK;
2520 entry->action |= DO_AUTODESTROY;
2522 else if (entry->action & DO_AUTODESTROY)
2524 entry->action &= ~DO_AUTODESTROY;
2525 entry->action |= DONT_AUTOPICK;
2527 else if (entry->action & DONT_AUTOPICK)
2529 entry->action &= ~DONT_AUTOPICK;
2530 entry->action |= DO_AUTOPICK;
2533 lines_list[cy] = autopick_line_from_entry(entry);
2542 /* Rotate identify-state; identified/unidentified/... */
2543 if (!autopick_new_entry(entry, lines_list[cy]))
2545 string_free(lines_list[cy]);
2547 if (IS_FLG(FLG_UNIDENTIFIED))
2549 REM_FLG(FLG_UNIDENTIFIED);
2550 ADD_FLG(FLG_UNAWARE);
2551 REM_FLG(FLG_IDENTIFIED);
2552 REM_FLG(FLG_STAR_IDENTIFIED);
2554 else if (IS_FLG(FLG_UNAWARE))
2556 REM_FLG(FLG_UNIDENTIFIED);
2557 REM_FLG(FLG_UNAWARE);
2558 ADD_FLG(FLG_IDENTIFIED);
2559 REM_FLG(FLG_STAR_IDENTIFIED);
2561 else if (IS_FLG(FLG_STAR_IDENTIFIED))
2563 REM_FLG(FLG_UNIDENTIFIED);
2564 REM_FLG(FLG_UNAWARE);
2565 REM_FLG(FLG_IDENTIFIED);
2566 REM_FLG(FLG_STAR_IDENTIFIED);
2568 else if (IS_FLG(FLG_IDENTIFIED))
2570 REM_FLG(FLG_UNIDENTIFIED);
2571 REM_FLG(FLG_UNAWARE);
2572 REM_FLG(FLG_IDENTIFIED);
2573 ADD_FLG(FLG_STAR_IDENTIFIED);
2577 ADD_FLG(FLG_UNIDENTIFIED);
2578 REM_FLG(FLG_UNAWARE);
2579 REM_FLG(FLG_IDENTIFIED);
2580 REM_FLG(FLG_STAR_IDENTIFIED);
2583 lines_list[cy] = autopick_line_from_entry(entry);
2590 while (cy < upper + hgt-4 && lines_list[cy + 1])
2595 /* Toggle 'worthless' */
2596 toggle_string(lines_list, FLG_WORTHLESS, cy);
2601 /* Toggle 'nameless' */
2602 toggle_string(lines_list, FLG_NAMELESS, cy);
2607 /* Paste killed text */
2608 if (strlen(yank_buf))
2611 for (j = 0; yank_buf[j]; j += strlen(yank_buf + j) + 1)
2613 insert_return_code(lines_list, 0, cy);
2614 lines_list[cy] = string_make(yank_buf + j);
2619 dirty_flags |= DIRTY_ALL;
2623 /* Toggle 'collecting' */
2624 toggle_string(lines_list, FLG_COLLECTING, cy);
2630 /* Kill rest of line */
2631 if (lines_list[cy][0] != '\0' && (unsigned int) cx < strlen(lines_list[cy]))
2633 for (i = j = 0; lines_list[cy][i] && i < cx; i++)
2636 if (iskanji(lines_list[cy][i]))
2637 buf[j++] = lines_list[cy][i++];
2639 buf[j++] = lines_list[cy][i];
2644 if (old_key == KTRL('k'))
2646 j += strlen(yank_buf + j) + 1;
2648 if (j < MAX_YANK - 2)
2650 strncpy(yank_buf + j, lines_list[cy] + i, MAX_YANK-j-2);
2651 yank_buf[MAX_YANK-2] = '\0';
2652 yank_buf[j + strlen(lines_list[cy] + i) + 1] = '\0';
2654 string_free(lines_list[cy]);
2655 lines_list[cy] = string_make(buf);
2664 /* DELETE == go forward + BACK SPACE */
2666 if (iskanji(lines_list[cy][cx])) cx++;
2669 len = strlen(lines_list[cy]);
2672 if (lines_list[cy + 1])
2690 /* delete a return code and union two lines */
2692 cx = strlen(lines_list[cy-1]);
2693 strcpy(buf, lines_list[cy-1]);
2694 strcat(buf, lines_list[cy]);
2695 string_free(lines_list[cy-1]);
2696 string_free(lines_list[cy]);
2697 lines_list[cy-1] = string_make(buf);
2698 for (i = cy; lines_list[i+1]; i++)
2699 lines_list[i] = lines_list[i+1];
2700 lines_list[i] = NULL;
2704 dirty_flags |= DIRTY_ALL;
2708 for (i = j = 0; lines_list[cy][i] && i < cx; i++)
2712 if (iskanji(lines_list[cy][i]))
2713 buf[j++] = lines_list[cy][i++];
2715 buf[j++] = lines_list[cy][i];
2722 for (; lines_list[cy][i]; i++)
2723 buf[j++] = lines_list[cy][i];
2725 string_free(lines_list[cy]);
2726 lines_list[cy] = string_make(buf);
2735 /* Restore the screen */
2739 sprintf(buf, "picktype-%s.prf", player_name);
2741 sprintf(buf, "pickpref-%s.prf", player_name);
2743 write_text_lines(buf, lines_list);
2744 free_text_lines(lines_list);
2746 string_free(last_destroyed);
2748 /* Reload autopick pref */
2749 process_pickpref_file(buf);