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, bool wait_optimize)
986 bool destroy = FALSE;
987 char o_name[MAX_NLEN];
990 /* Don't destroy equipped items */
991 if (item > INVEN_PACK) return FALSE;
993 /* Get the item (in the pack) */
994 if (item >= 0) o_ptr = &inventory[item];
996 /* Get the item (on the floor) */
997 else o_ptr = &o_list[0 - item];
999 /* Easy-Auto-Destroyer */
1000 if (is_opt_confirm_destroy(o_ptr)) destroy = TRUE;
1002 /* Protected by auto-picker */
1003 if (autopick_idx >= 0 &&
1004 !(autopick_list[autopick_idx].action & DO_AUTODESTROY))
1009 /* Auto-picker/destroyer */
1010 if (autopick_idx >= 0 &&
1011 (autopick_list[autopick_idx].action & DO_AUTODESTROY))
1015 /* Not to be destroyed */
1016 if (!destroy) return FALSE;
1018 /* Now decided to destroy */
1022 /* Describe the object (with {terrible/special}) */
1023 object_desc(o_name, o_ptr, TRUE, 3);
1026 if (!can_player_destroy_object(o_ptr))
1030 msg_format("%s¤ÏÇ˲õÉÔǽ¤À¡£", o_name);
1032 msg_format("You cannot auto-destroy %s.", o_name);
1039 /* Record name of destroyed item */
1040 COPY(&autopick_last_destroyed_object, o_ptr, object_type);
1042 /* Eliminate the item (from the pack) */
1045 inven_item_increase(item, -(o_ptr->number));
1048 * always optimize equipment.
1049 * optimize inventry only when wait_optimize is FALSE.
1051 if (!wait_optimize || item > INVEN_PACK)
1052 inven_item_optimize(item);
1055 /* Eliminate the item (from the floor) */
1058 delete_object_idx(0 - item);
1061 /* Print a message */
1063 msg_format("%s¤ò¼«Æ°Ç˲õ¤·¤Þ¤¹¡£", o_name);
1065 msg_format("Auto-destroying %s.", o_name);
1073 * Optimize all inventry items after consumption of staves or scrolls.
1075 void optimize_inventry_auto_destroy(void)
1079 for (i = 0; i <= INVEN_PACK; i++)
1080 inven_item_optimize(i);
1085 * Automatically pickup/destroy items in this grid.
1087 void auto_pickup_items(cave_type *c_ptr)
1089 s16b this_o_idx, next_o_idx = 0;
1091 /* Scan the pile of objects */
1092 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
1096 /* Acquire object */
1097 object_type *o_ptr = &o_list[this_o_idx];
1099 /* Acquire next object */
1100 next_o_idx = o_ptr->next_o_idx;
1102 idx = is_autopick(o_ptr);
1104 /* Item index for floor -1,-2,-3,... */
1105 auto_inscribe_item((-this_o_idx), idx);
1108 (autopick_list[idx].action & (DO_AUTOPICK | DO_QUERY_AUTOPICK)))
1112 if (!inven_carry_okay(o_ptr))
1114 char o_name[MAX_NLEN];
1116 /* Describe the object */
1117 object_desc(o_name, o_ptr, TRUE, 3);
1121 msg_format("¥¶¥Ã¥¯¤Ë¤Ï%s¤òÆþ¤ì¤ë·ä´Ö¤¬¤Ê¤¤¡£", o_name);
1123 msg_format("You have no room for %s.", o_name);
1125 /* Hack - remember that the item has given a message here. */
1126 o_ptr->marked |= OM_NOMSG;
1130 else if (autopick_list[idx].action & DO_QUERY_AUTOPICK)
1132 char out_val[MAX_NLEN+20];
1133 char o_name[MAX_NLEN];
1135 if (o_ptr->marked & OM_NO_QUERY)
1137 /* Already answered as 'No' */
1141 /* Describe the object */
1142 object_desc(o_name, o_ptr, TRUE, 3);
1145 sprintf(out_val, "%s¤ò½¦¤¤¤Þ¤¹¤«? ", o_name);
1147 sprintf(out_val, "Pick up %s? ", o_name);
1150 if (!get_check(out_val))
1152 /* Hack - remember that the item has given a message here. */
1153 o_ptr->marked |= (OM_NOMSG | OM_NO_QUERY);
1158 py_pickup_aux(this_o_idx);
1165 * When always_pickup is 'yes', we disable
1166 * auto-destroyer from autopick function, and do only
1167 * easy-auto-destroyer.
1171 if (auto_destroy_item((-this_o_idx), idx, FALSE))
1179 * Describe which kind of object is Auto-picked/destroyed
1181 static void describe_autopick(char *buff, autopick_type *entry)
1183 cptr str = entry->name;
1184 byte act = entry->action;
1185 cptr insc = entry->insc;
1191 cptr before_str[100], body_str;
1194 body_str = "¥¢¥¤¥Æ¥à";
1196 /*** Collecting items ***/
1197 /*** Which can be absorbed into a slot as a bundle ***/
1198 if (IS_FLG(FLG_COLLECTING))
1199 before_str[before_n++] = "¼ý½¸Ãæ¤Ç´û¤Ë»ý¤Ã¤Æ¤¤¤ë¥¹¥í¥Ã¥È¤Ë¤Þ¤È¤á¤é¤ì¤ë";
1201 /*** Unidentified ***/
1202 if (IS_FLG(FLG_UNIDENTIFIED))
1203 before_str[before_n++] = "̤´ÕÄê¤Î";
1205 /*** Identified ***/
1206 if (IS_FLG(FLG_IDENTIFIED))
1207 before_str[before_n++] = "´ÕÄêºÑ¤ß¤Î";
1209 /*** *Identified* ***/
1210 if (IS_FLG(FLG_STAR_IDENTIFIED))
1211 before_str[before_n++] = "´°Á´¤Ë´ÕÄêºÑ¤ß¤Î";
1213 /*** Dice boosted (weapon of slaying) ***/
1214 if (IS_FLG(FLG_BOOSTED))
1216 before_str[before_n++] = "¥À¥á¡¼¥¸¥À¥¤¥¹¤¬Ä̾ï¤è¤êÂ礤¤";
1220 /*** Weapons whose dd*ds is more than nn ***/
1221 if (IS_FLG(FLG_MORE_THAN))
1223 static char more_than_desc_str[] = "___";
1224 before_str[before_n++] = "¥À¥á¡¼¥¸¥À¥¤¥¹¤ÎºÇÂçÃͤ¬";
1227 sprintf(more_than_desc_str,"%d", entry->dice);
1228 before_str[before_n++] = more_than_desc_str;
1229 before_str[before_n++] = "°Ê¾å¤Î";
1232 /*** Items whose magical bonus is more than nn ***/
1233 if (IS_FLG(FLG_MORE_BONUS))
1235 static char more_bonus_desc_str[] = "___";
1236 before_str[before_n++] = "½¤ÀµÃͤ¬(+";
1238 sprintf(more_bonus_desc_str,"%d", entry->bonus);
1239 before_str[before_n++] = more_bonus_desc_str;
1240 before_str[before_n++] = ")°Ê¾å¤Î";
1243 /*** Worthless items ***/
1244 if (IS_FLG(FLG_WORTHLESS))
1245 before_str[before_n++] = "Ź¤Ç̵²ÁÃͤÈȽÄꤵ¤ì¤ë";
1248 if (IS_FLG(FLG_ARTIFACT))
1250 before_str[before_n++] = "¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤Î";
1255 if (IS_FLG(FLG_EGO))
1257 before_str[before_n++] = "¥¨¥´¥¢¥¤¥Æ¥à¤Î";
1262 if (IS_FLG(FLG_NAMELESS))
1264 before_str[before_n++] = "¥¨¥´¤Ç¤â¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤Ç¤â¤Ê¤¤";
1268 /*** Unaware items ***/
1269 if (IS_FLG(FLG_UNAWARE))
1270 before_str[before_n++] = "̤´ÕÄê¤Ç¤½¤Î¸ú²Ì¤âȽÌÀ¤·¤Æ¤¤¤Ê¤¤";
1272 /*** Wanted monster's corpse/skeletons ***/
1273 if (IS_FLG(FLG_WANTED))
1275 before_str[before_n++] = "¥Ï¥ó¥¿¡¼»ö̳½ê¤Ç¾Þ¶â¼ó¤È¤µ¤ì¤Æ¤¤¤ë";
1276 body_str = "»àÂΤä¹ü";
1279 /*** Human corpse/skeletons (for Daemon magic) ***/
1280 if (IS_FLG(FLG_HUMAN))
1282 before_str[before_n++] = "°ËâËâË¡¤Ç»È¤¦¤¿¤á¤Î¿Í´Ö¤ä¥Ò¥å¡¼¥Þ¥Î¥¤¥É¤Î";
1283 body_str = "»àÂΤä¹ü";
1286 /*** Unique monster's corpse/skeletons/statues ***/
1287 if (IS_FLG(FLG_UNIQUE))
1289 before_str[before_n++] = "¥æ¥Ë¡¼¥¯¥â¥ó¥¹¥¿¡¼¤Î";
1290 body_str = "»àÂΤä¹ü";
1293 /*** Unreadable spellbooks ***/
1294 if (IS_FLG(FLG_UNREADABLE))
1296 before_str[before_n++] = "¤¢¤Ê¤¿¤¬Æɤá¤Ê¤¤Îΰè¤Î";
1297 body_str = "ËâË¡½ñ";
1300 /*** First realm spellbooks ***/
1301 if (IS_FLG(FLG_REALM1))
1303 before_str[before_n++] = "Âè°ìÎΰè¤Î";
1304 body_str = "ËâË¡½ñ";
1307 /*** Second realm spellbooks ***/
1308 if (IS_FLG(FLG_REALM2))
1310 before_str[before_n++] = "ÂèÆóÎΰè¤Î";
1311 body_str = "ËâË¡½ñ";
1314 /*** First rank spellbooks ***/
1315 if (IS_FLG(FLG_FIRST))
1317 before_str[before_n++] = "Á´4ºý¤ÎÆâ¤Î1ºýÌܤÎ";
1318 body_str = "ËâË¡½ñ";
1321 /*** Second rank spellbooks ***/
1322 if (IS_FLG(FLG_SECOND))
1324 before_str[before_n++] = "Á´4ºý¤ÎÆâ¤Î2ºýÌܤÎ";
1325 body_str = "ËâË¡½ñ";
1328 /*** Third rank spellbooks ***/
1329 if (IS_FLG(FLG_THIRD))
1331 before_str[before_n++] = "Á´4ºý¤ÎÆâ¤Î3ºýÌܤÎ";
1332 body_str = "ËâË¡½ñ";
1335 /*** Fourth rank spellbooks ***/
1336 if (IS_FLG(FLG_FOURTH))
1338 before_str[before_n++] = "Á´4ºý¤ÎÆâ¤Î4ºýÌܤÎ";
1339 body_str = "ËâË¡½ñ";
1343 if (IS_FLG(FLG_ITEMS))
1344 ; /* Nothing to do */
1345 else if (IS_FLG(FLG_WEAPONS))
1347 else if (IS_FLG(FLG_ARMORS))
1349 else if (IS_FLG(FLG_MISSILES))
1350 body_str = "ÃƤäÌð¤ä¥¯¥í¥¹¥Ü¥¦¤ÎÌð";
1351 else if (IS_FLG(FLG_DEVICES))
1352 body_str = "´¬Êª¤äËâË¡ËÀ¤ä¾ó¤ä¥í¥Ã¥É";
1353 else if (IS_FLG(FLG_LIGHTS))
1354 body_str = "¸÷¸»ÍѤΥ¢¥¤¥Æ¥à";
1355 else if (IS_FLG(FLG_JUNKS))
1356 body_str = "Àޤ줿ËÀÅù¤Î¥¬¥é¥¯¥¿";
1357 else if (IS_FLG(FLG_SPELLBOOKS))
1358 body_str = "ËâË¡½ñ";
1359 else if (IS_FLG(FLG_HAFTED))
1361 else if (IS_FLG(FLG_SHIELDS))
1363 else if (IS_FLG(FLG_BOWS))
1364 body_str = "¥¹¥ê¥ó¥°¤äµÝ¤ä¥¯¥í¥¹¥Ü¥¦";
1365 else if (IS_FLG(FLG_RINGS))
1367 else if (IS_FLG(FLG_AMULETS))
1368 body_str = "¥¢¥ß¥å¥ì¥Ã¥È";
1369 else if (IS_FLG(FLG_SUITS))
1371 else if (IS_FLG(FLG_CLOAKS))
1372 body_str = "¥¯¥í¡¼¥¯";
1373 else if (IS_FLG(FLG_HELMS))
1374 body_str = "¥Ø¥ë¥á¥Ã¥È¤ä´§";
1375 else if (IS_FLG(FLG_GLOVES))
1377 else if (IS_FLG(FLG_BOOTS))
1378 body_str = "¥Ö¡¼¥Ä";
1382 strcat(buff, "Á´¤Æ¤Î");
1383 else for (i = 0; i < before_n && before_str[i]; i++)
1384 strcat(buff, before_str[i]);
1386 strcat(buff, body_str);
1396 strcat(buff, "¤Ç¡¢Ì¾Á°¤¬¡Ö");
1397 strncat(buff, str, 80);
1399 strcat(buff, "¡×¤Ç»Ï¤Þ¤ë¤â¤Î");
1401 strcat(buff, "¡×¤ò´Þ¤à¤â¤Î");
1406 strncat(buff, format("¤Ë¡Ö%s¡×", insc), 80);
1408 if (strstr(insc, "%%all"))
1409 strcat(buff, "(%%all¤ÏÁ´Ç½ÎϤòɽ¤¹±Ñ»ú¤Îµ¹æ¤ÇÃÖ´¹)");
1410 else if (strstr(insc, "%all"))
1411 strcat(buff, "(%all¤ÏÁ´Ç½ÎϤòɽ¤¹µ¹æ¤ÇÃÖ´¹)");
1412 else if (strstr(insc, "%%"))
1413 strcat(buff, "(%%¤ÏÄɲÃǽÎϤòɽ¤¹±Ñ»ú¤Îµ¹æ¤ÇÃÖ´¹)");
1414 else if (strstr(insc, "%"))
1415 strcat(buff, "(%¤ÏÄɲÃǽÎϤòɽ¤¹µ¹æ¤ÇÃÖ´¹)");
1417 strcat(buff, "¤È¹ï¤ó¤Ç");
1422 if (act & DONT_AUTOPICK)
1423 strcat(buff, "ÊüÃÖ¤¹¤ë¡£");
1424 else if (act & DO_AUTODESTROY)
1425 strcat(buff, "Ç˲õ¤¹¤ë¡£");
1426 else if (act & DO_QUERY_AUTOPICK)
1427 strcat(buff, "³Îǧ¤Î¸å¤Ë½¦¤¦¡£");
1429 strcat(buff, "½¦¤¦¡£");
1431 if (act & DO_DISPLAY)
1433 if (act & DONT_AUTOPICK)
1434 strcat(buff, "Á´ÂΥޥå×('M')¤Ç'N'¤ò²¡¤·¤¿¤È¤¤Ëɽ¼¨¤¹¤ë¡£");
1435 else if (act & DO_AUTODESTROY)
1436 strcat(buff, "Á´ÂΥޥå×('M')¤Ç'K'¤ò²¡¤·¤¿¤È¤¤Ëɽ¼¨¤¹¤ë¡£");
1438 strcat(buff, "Á´ÂΥޥå×('M')¤Ç'M'¤ò²¡¤·¤¿¤È¤¤Ëɽ¼¨¤¹¤ë¡£");
1441 strcat(buff, "Á´ÂΥޥåפˤÏɽ¼¨¤·¤Ê¤¤");
1445 cptr before_str[20], after_str[20], which_str[20], whose_str[20], body_str;
1446 int before_n = 0, after_n = 0, which_n = 0, whose_n = 0;
1450 /*** Collecting items ***/
1451 /*** Which can be absorbed into a slot as a bundle ***/
1452 if (IS_FLG(FLG_COLLECTING))
1453 which_str[which_n++] = "can be absorbed into an existing inventory slot";
1455 /*** Unidentified ***/
1456 if (IS_FLG(FLG_UNIDENTIFIED))
1457 before_str[before_n++] = "unidentified";
1459 /*** Identified ***/
1460 if (IS_FLG(FLG_IDENTIFIED))
1461 before_str[before_n++] = "identified";
1463 /*** *Identified* ***/
1464 if (IS_FLG(FLG_STAR_IDENTIFIED))
1465 before_str[before_n++] = "fully identified";
1467 /*** Worthless items ***/
1468 if (IS_FLG(FLG_WORTHLESS))
1470 before_str[before_n++] = "worthless";
1471 which_str[which_n++] = "can not be sold at stores";
1475 if (IS_FLG(FLG_ARTIFACT))
1477 before_str[before_n++] = "artifact";
1481 if (IS_FLG(FLG_EGO))
1483 before_str[before_n++] = "ego";
1487 if (IS_FLG(FLG_NAMELESS))
1489 body_str = "equipment";
1490 which_str[which_n++] = "is neither ego-item nor artifact";
1493 /*** Unaware items ***/
1494 if (IS_FLG(FLG_UNAWARE))
1496 before_str[before_n++] = "unidentified";
1497 whose_str[whose_n++] = "basic abilities are not known";
1500 /*** Dice boosted (weapon of slaying) ***/
1501 if (IS_FLG(FLG_BOOSTED))
1503 body_str = "weapons";
1504 whose_str[whose_n++] = "damage dice is bigger than normal";
1507 /*** Weapons whose dd*ds is more than nn ***/
1508 if (IS_FLG(FLG_MORE_THAN))
1510 static char more_than_desc_str[] =
1511 "maximum damage from dice is bigger than __";
1512 body_str = "weapons";
1514 sprintf(more_than_desc_str + sizeof(more_than_desc_str) - 3,
1516 whose_str[whose_n++] = more_than_desc_str;
1519 /*** Items whose magical bonus is more than nn ***/
1520 if (IS_FLG(FLG_MORE_BONUS))
1522 static char more_bonus_desc_str[] =
1523 "magical bonus is bigger than (+__)";
1525 sprintf(more_bonus_desc_str + sizeof(more_bonus_desc_str) - 4,
1526 "%d)", entry->bonus);
1527 whose_str[whose_n++] = more_bonus_desc_str;
1530 /*** Wanted monster's corpse/skeletons ***/
1531 if (IS_FLG(FLG_WANTED))
1533 body_str = "corpse or skeletons";
1534 which_str[which_n++] = "is wanted at the Hunter's Office";
1537 /*** Human corpse/skeletons (for Daemon magic) ***/
1538 if (IS_FLG(FLG_HUMAN))
1540 before_str[before_n++] = "humanoid";
1541 body_str = "corpse or skeletons";
1542 which_str[which_n++] = "can be used for Daemon magic";
1545 /*** Unique monster's corpse/skeletons/statues ***/
1546 if (IS_FLG(FLG_UNIQUE))
1548 before_str[before_n++] = "unique monster's";
1549 body_str = "corpse or skeletons";
1552 /*** Unreadable spellbooks ***/
1553 if (IS_FLG(FLG_UNREADABLE))
1555 body_str = "spellbooks";
1556 after_str[after_n++] = "of different realms from yours";
1559 /*** First realm spellbooks ***/
1560 if (IS_FLG(FLG_REALM1))
1562 body_str = "spellbooks";
1563 after_str[after_n++] = "of your first realm";
1566 /*** Second realm spellbooks ***/
1567 if (IS_FLG(FLG_REALM2))
1569 body_str = "spellbooks";
1570 after_str[after_n++] = "of your second realm";
1573 /*** First rank spellbooks ***/
1574 if (IS_FLG(FLG_FIRST))
1576 before_str[before_n++] = "first one of four";
1577 body_str = "spellbooks";
1580 /*** Second rank spellbooks ***/
1581 if (IS_FLG(FLG_SECOND))
1583 before_str[before_n++] = "second one of four";
1584 body_str = "spellbooks";
1587 /*** Third rank spellbooks ***/
1588 if (IS_FLG(FLG_THIRD))
1590 before_str[before_n++] = "third one of four";
1591 body_str = "spellbooks";
1594 /*** Fourth rank spellbooks ***/
1595 if (IS_FLG(FLG_FOURTH))
1597 before_str[before_n++] = "fourth one of four";
1598 body_str = "spellbooks";
1602 if (IS_FLG(FLG_ITEMS))
1603 ; /* Nothing to do */
1604 else if (IS_FLG(FLG_WEAPONS))
1605 body_str = "weapons";
1606 else if (IS_FLG(FLG_ARMORS))
1607 body_str = "armors";
1608 else if (IS_FLG(FLG_MISSILES))
1609 body_str = "shots, arrows or crossbow bolts";
1610 else if (IS_FLG(FLG_DEVICES))
1611 body_str = "scrolls, wands, staves or rods";
1612 else if (IS_FLG(FLG_LIGHTS))
1613 body_str = "light sources";
1614 else if (IS_FLG(FLG_JUNKS))
1615 body_str = "junk such as broken sticks";
1616 else if (IS_FLG(FLG_SPELLBOOKS))
1617 body_str = "spellbooks";
1618 else if (IS_FLG(FLG_HAFTED))
1619 body_str = "hafted weapons";
1620 else if (IS_FLG(FLG_SHIELDS))
1621 body_str = "shields";
1622 else if (IS_FLG(FLG_BOWS))
1623 body_str = "slings, bows or crossbows";
1624 else if (IS_FLG(FLG_RINGS))
1626 else if (IS_FLG(FLG_AMULETS))
1627 body_str = "amulets";
1628 else if (IS_FLG(FLG_SUITS))
1629 body_str = "body armors";
1630 else if (IS_FLG(FLG_CLOAKS))
1631 body_str = "cloaks";
1632 else if (IS_FLG(FLG_HELMS))
1633 body_str = "helms or crowns";
1634 else if (IS_FLG(FLG_GLOVES))
1635 body_str = "gloves";
1636 else if (IS_FLG(FLG_BOOTS))
1639 /* Prepare a string for item name */
1646 whose_str[whose_n++] = "name is beginning with \"";
1649 which_str[which_n++] = "have \"";
1653 /* Describe action flag */
1654 if (act & DONT_AUTOPICK)
1655 strcpy(buff, "Leave on floor ");
1656 else if (act & DO_AUTODESTROY)
1657 strcpy(buff, "Destroy ");
1658 else if (act & DO_QUERY_AUTOPICK)
1659 strcpy(buff, "Ask to pick up ");
1661 strcpy(buff, "Pickup ");
1663 /* Auto-insctiption */
1666 strncat(buff, format("and inscribe \"%s\"", insc), 80);
1668 if (strstr(insc, "%all"))
1669 strcat(buff, ", replacing %all with code string representing all abilities,");
1670 else if (strstr(insc, "%"))
1671 strcat(buff, ", replacing % with code string representing extra random abilities,");
1673 strcat(buff, " on ");
1678 strcat(buff, "all ");
1679 else for (i = 0; i < before_n && before_str[i]; i++)
1681 strcat(buff, before_str[i]);
1686 strcat(buff, body_str);
1689 for (i = 0; i < after_n && after_str[i]; i++)
1692 strcat(buff, after_str[i]);
1696 for (i = 0; i < whose_n && whose_str[i]; i++)
1699 strcat(buff, " whose ");
1701 strcat(buff, ", and ");
1703 strcat(buff, whose_str[i]);
1706 /* Item name ; whose name is beginning with "str" */
1713 /* whose ..., and which .... */
1714 if (whose_n && which_n)
1715 strcat(buff, ", and ");
1718 for (i = 0; i < which_n && which_str[i]; i++)
1721 strcat(buff, " which ");
1723 strcat(buff, ", and ");
1725 strcat(buff, which_str[i]);
1728 /* Item name ; which have "str" as part of its name */
1731 strncat(buff, str, 80);
1732 strcat(buff, "\" as part of its name");
1736 /* Describe whether it will be displayed on the full map or not */
1737 if (act & DO_DISPLAY)
1739 if (act & DONT_AUTOPICK)
1740 strcat(buff, " Display these items when you press the N key in the full 'M'ap.");
1741 else if (act & DO_AUTODESTROY)
1742 strcat(buff, " Display these items when you press the K key in the full 'M'ap.");
1744 strcat(buff, " Display these items when you press the M key in the full 'M'ap.");
1747 strcat(buff, " Not displayed in the full map.");
1753 #define MAX_LINES 3000
1756 * Read whole lines of a file to memory
1758 static cptr *read_text_lines(cptr filename, bool user)
1760 cptr *lines_list = NULL;
1768 /* Hack -- drop permissions */
1770 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, filename);
1774 path_build(buf, sizeof(buf), ANGBAND_DIR_PREF, filename);
1778 fff = my_fopen(buf, "r");
1782 /* Allocate list of pointers */
1783 C_MAKE(lines_list, MAX_LINES, cptr);
1786 while (0 == my_fgets(fff, buf, sizeof(buf)))
1788 lines_list[lines++] = string_make(buf);
1789 if (lines >= MAX_LINES - 1) break;
1792 lines_list[0] = string_make("");
1800 if (!fff) return NULL;
1805 #define PT_DEFAULT 0
1806 #define PT_WITH_PNAME 1
1808 static cptr *read_pickpref_text_lines(int *filename_mode_p)
1814 sprintf(buf, "picktype-%s.prf", player_name);
1816 sprintf(buf, "pickpref-%s.prf", player_name);
1818 lines_list = read_text_lines(buf, TRUE);
1823 lines_list = read_text_lines("picktype.prf", TRUE);
1825 lines_list = read_text_lines("pickpref.prf", TRUE);
1827 *filename_mode_p = PT_DEFAULT;
1833 lines_list = read_text_lines("picktype.prf", FALSE);
1835 lines_list = read_text_lines("pickpref.prf", FALSE);
1837 *filename_mode_p = PT_WITH_PNAME;
1842 /* Allocate list of pointers */
1843 C_MAKE(lines_list, MAX_LINES, cptr);
1844 lines_list[0] = string_make("");
1845 *filename_mode_p = PT_WITH_PNAME;
1851 * Write whole lines of memory to a file.
1853 static bool write_text_lines(cptr filename, cptr *lines_list)
1860 /* Hack -- drop permissions */
1863 /* Build the filename */
1864 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, filename);
1867 fff = my_fopen(buf, "w");
1870 for (lines = 0; lines_list[lines]; lines++)
1871 my_fputs(fff, lines_list[lines], 1024);
1879 if (!fff) return FALSE;
1885 * Free memory of lines_list.
1887 static void free_text_lines(cptr *lines_list)
1891 for (lines = 0; lines_list[lines]; lines++)
1892 string_free(lines_list[lines]);
1894 /* free list of pointers */
1895 C_FREE((char **)lines_list, MAX_LINES, char *);
1900 * Delete or insert string
1902 static void toggle_string(cptr *lines_list, int flg, int y)
1904 autopick_type an_entry, *entry = &an_entry;
1906 if (!autopick_new_entry(entry, lines_list[y]))
1909 string_free(lines_list[y]);
1915 lines_list[y] = autopick_line_from_entry_kill(entry);
1919 * Insert return code and split the line
1921 static bool insert_return_code(cptr *lines_list, int cx, int cy)
1923 char buf[MAX_LINELEN];
1926 for (k = 0; lines_list[k]; k++)
1927 /* count number of lines */ ;
1929 if (k >= MAX_LINES - 2) return FALSE;
1932 /* Move down lines */
1934 lines_list[k+1] = lines_list[k];
1936 /* Split current line */
1937 for (i = j = 0; lines_list[cy][i] && i < cx; i++)
1940 if (iskanji(lines_list[cy][i]))
1941 buf[j++] = lines_list[cy][i++];
1943 buf[j++] = lines_list[cy][i];
1946 lines_list[cy+1] = string_make(&lines_list[cy][i]);
1947 string_free(lines_list[cy]);
1948 lines_list[cy] = string_make(buf);
1954 * Get auto-picker entry from o_ptr.
1956 void autopick_entry_from_object(autopick_type *entry, object_type *o_ptr)
1958 char o_name[MAX_NLEN];
1959 object_desc(o_name, o_ptr, FALSE, 0);
1961 entry->name = string_make(o_name);
1962 entry->insc = string_make(quark_str(o_ptr->inscription));
1963 entry->action = DO_AUTOPICK | DO_DISPLAY;
1964 entry->flag[0] = entry->flag[1] = 0L;
1967 if (!object_aware_p(o_ptr))
1968 ADD_FLG(FLG_UNAWARE);
1969 if (object_value(o_ptr) <= 0)
1970 ADD_FLG(FLG_WORTHLESS);
1972 if (object_known_p(o_ptr))
1976 else if (o_ptr->name1 || o_ptr->art_name)
1977 ADD_FLG(FLG_ARTIFACT);
1983 case TV_HAFTED: case TV_POLEARM: case TV_SWORD: case TV_DIGGING:
1984 k_ptr = &k_info[o_ptr->k_idx];
1985 if ((o_ptr->dd != k_ptr->dd) || (o_ptr->ds != k_ptr->ds))
1986 ADD_FLG(FLG_BOOSTED);
1989 if (o_ptr->tval == TV_CORPSE && object_is_shoukinkubi(o_ptr))
1991 REM_FLG(FLG_WORTHLESS);
1992 ADD_FLG(FLG_WANTED);
1995 if ((o_ptr->tval == TV_CORPSE || o_ptr->tval == TV_STATUE)
1996 && (r_info[o_ptr->pval].flags1 & RF1_UNIQUE))
1998 REM_FLG(FLG_WORTHLESS);
1999 ADD_FLG(FLG_UNIQUE);
2002 if (o_ptr->tval == TV_CORPSE && strchr("pht", r_info[o_ptr->pval].d_char))
2004 REM_FLG(FLG_WORTHLESS);
2008 if (o_ptr->tval >= TV_LIFE_BOOK &&
2009 !check_book_realm(o_ptr->tval, o_ptr->sval))
2010 ADD_FLG(FLG_UNREADABLE);
2012 if (REALM1_BOOK == o_ptr->tval &&
2013 p_ptr->pclass != CLASS_SORCERER &&
2014 p_ptr->pclass != CLASS_RED_MAGE)
2015 ADD_FLG(FLG_REALM1);
2017 if (REALM2_BOOK == o_ptr->tval &&
2018 p_ptr->pclass != CLASS_SORCERER &&
2019 p_ptr->pclass != CLASS_RED_MAGE)
2020 ADD_FLG(FLG_REALM2);
2022 if (o_ptr->tval >= TV_LIFE_BOOK && 0 == o_ptr->sval)
2024 if (o_ptr->tval >= TV_LIFE_BOOK && 1 == o_ptr->sval)
2025 ADD_FLG(FLG_SECOND);
2026 if (o_ptr->tval >= TV_LIFE_BOOK && 2 == o_ptr->sval)
2028 if (o_ptr->tval >= TV_LIFE_BOOK && 3 == o_ptr->sval)
2029 ADD_FLG(FLG_FOURTH);
2031 if (o_ptr->tval == TV_SHOT || o_ptr->tval == TV_BOLT
2032 || o_ptr->tval == TV_ARROW)
2033 ADD_FLG(FLG_MISSILES);
2034 else if (o_ptr->tval == TV_SCROLL || o_ptr->tval == TV_STAFF
2035 || o_ptr->tval == TV_WAND || o_ptr->tval == TV_ROD)
2036 ADD_FLG(FLG_DEVICES);
2037 else if (o_ptr->tval == TV_LITE)
2038 ADD_FLG(FLG_LIGHTS);
2039 else if (o_ptr->tval == TV_SKELETON || o_ptr->tval == TV_BOTTLE
2040 || o_ptr->tval == TV_JUNK || o_ptr->tval == TV_STATUE)
2042 else if (o_ptr->tval >= TV_LIFE_BOOK)
2043 ADD_FLG(FLG_SPELLBOOKS);
2044 else if (o_ptr->tval == TV_HAFTED)
2045 ADD_FLG(FLG_HAFTED);
2046 else if (o_ptr->tval == TV_POLEARM || o_ptr->tval == TV_SWORD
2047 || o_ptr->tval == TV_DIGGING)
2048 ADD_FLG(FLG_WEAPONS);
2049 else if (o_ptr->tval == TV_SHIELD)
2050 ADD_FLG(FLG_SHIELDS);
2051 else if (o_ptr->tval == TV_BOW)
2053 else if (o_ptr->tval == TV_RING)
2055 else if (o_ptr->tval == TV_AMULET)
2056 ADD_FLG(FLG_AMULETS);
2057 else if (o_ptr->tval == TV_DRAG_ARMOR || o_ptr->tval == TV_HARD_ARMOR ||
2058 o_ptr->tval == TV_SOFT_ARMOR)
2060 else if (o_ptr->tval == TV_CLOAK)
2061 ADD_FLG(FLG_CLOAKS);
2062 else if (o_ptr->tval == TV_HELM)
2064 else if (o_ptr->tval == TV_GLOVES)
2065 ADD_FLG(FLG_GLOVES);
2066 else if (o_ptr->tval == TV_BOOTS)
2074 * Choose an item and get auto-picker entry from it.
2076 static object_type *choose_object(cptr q, cptr s)
2080 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP))) return NULL;
2082 /* Get the item (in the pack) */
2083 if (item >= 0) return &inventory[item];
2085 /* Get the item (on the floor) */
2086 else return &o_list[0 - item];
2091 * Choose an item and get auto-picker entry from it.
2093 static bool entry_from_choosed_object(autopick_type *entry)
2100 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÅÐÏ¿¤·¤Þ¤¹¤«? ";
2101 s = "¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£";
2103 q = "Entry which item? ";
2104 s = "You have nothing to entry.";
2106 o_ptr = choose_object(q, s);
2107 if (!o_ptr) return FALSE;
2109 autopick_entry_from_object(entry, o_ptr);
2115 * Choose an item or string for search
2117 static bool get_string_for_search(object_type **o_handle, cptr *search_strp)
2121 char buf[MAX_NLEN+20];
2124 int k_flag[MAX_NLEN+20];
2125 char prompt[] = "¸¡º÷(^I:»ý¤Áʪ ^L:Ç˲õ¤µ¤ì¤¿Êª): ";
2127 char prompt[] = "Search key(^I:inven ^L:destroyed): ";
2129 int col = sizeof(prompt) - 1;
2131 if (*search_strp) strcpy(buf, *search_strp);
2134 /* Display prompt */
2137 /* Display the default answer */
2138 Term_erase(col, 0, 255);
2139 Term_putstr(col, 0, -1, TERM_YELLOW, buf);
2148 Term_gotoxy(col + pos, 0);
2150 /* Do not process macros except special keys */
2151 inkey_special = TRUE;
2156 /* Analyze the key */
2165 if (!pos && *o_handle) return TRUE;
2166 string_free(*search_strp);
2167 *search_strp = string_make(buf);
2174 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¸¡º÷¤·¤Þ¤¹¤«? ";
2175 s = "¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£";
2177 q = "Entry which item? ";
2178 s = "You have nothing to entry.";
2180 o_ptr = choose_object(q, s);
2181 if (!o_ptr) return FALSE;
2185 string_free(*search_strp);
2186 object_desc(buf, *o_handle, FALSE, 3);
2187 *search_strp = string_make(format("<%s>", buf));
2191 if (!autopick_last_destroyed_object.k_idx) break;
2192 *o_handle = &autopick_last_destroyed_object;
2194 string_free(*search_strp);
2195 object_desc(buf, *o_handle, FALSE, 3);
2196 *search_strp = string_make(format("<%s>", buf));
2205 if (k_flag[pos]) pos--;
2220 if (pos + 1 < MAX_NLEN)
2228 else if (pos < MAX_NLEN && isprint(i))
2235 if (pos < MAX_NLEN && isprint(i)) buf[pos++] = i;
2244 /* Update the entry */
2245 Term_erase(col, 0, 255);
2246 Term_putstr(col, 0, -1, TERM_WHITE, buf);
2254 * Search next line matches for o_ptr
2256 static bool search_for_object(cptr *lines_list, object_type *o_ptr, int *cxp, int *cyp, bool forward)
2259 autopick_type an_entry, *entry = &an_entry;
2260 char o_name[MAX_NLEN];
2262 object_desc(o_name, o_ptr, FALSE, 3);
2264 /* Force to be lower case string */
2265 for (i = 0; o_name[i]; i++)
2268 if (iskanji(o_name[i]))
2272 if (isupper(o_name[i]))
2273 o_name[i] = tolower(o_name[i]);
2282 if (!lines_list[++i]) break;
2289 if (!autopick_new_entry(entry, lines_list[i])) continue;
2291 if (is_autopick_aux(o_ptr, entry, o_name))
2304 * Search next line matches to the string
2306 static bool search_for_string(cptr *lines_list, cptr search_str, int *cxp, int *cyp, bool forward)
2316 if (!lines_list[++i]) break;
2323 pos = strstr_j(lines_list[i], search_str);
2325 pos = strstr(lines_list[i], search_str);
2329 *cxp = (int)(pos - lines_list[i]);
2340 * Initialize auto-picker preference
2342 void init_autopicker(void)
2344 static const char easy_autopick_inscription[] = "(:=g";
2345 autopick_type entry;
2348 /* Clear old entries */
2349 for( i = 0; i < max_autopick; i++)
2350 autopick_free_entry(&autopick_list[i]);
2354 /* There is always one entry "=g" */
2355 autopick_new_entry(&entry, easy_autopick_inscription);
2356 autopick_list[max_autopick++] = entry;
2362 * Process line for auto picker/destroyer.
2364 errr process_pickpref_file_line(char *buf)
2366 autopick_type entry;
2369 if (max_autopick == MAX_AUTOPICK)
2372 /* Nuke illegal char */
2373 for(i = 0; buf[i]; i++)
2376 if (iskanji(buf[i]))
2382 if (isspace(buf[i]) && buf[i] != ' ')
2387 if (!autopick_new_entry(&entry, buf)) return 0;
2389 /* Already has the same entry? */
2390 for(i = 0; i < max_autopick; i++)
2391 if(!strcmp(entry.name, autopick_list[i].name)
2392 && entry.flag[0] == autopick_list[i].flag[0]
2393 && entry.flag[1] == autopick_list[i].flag[1]
2394 && entry.dice == autopick_list[i].dice
2395 && entry.bonus == autopick_list[i].bonus) return 0;
2397 autopick_list[max_autopick++] = entry;
2403 * Get a trigger key and insert ASCII string for the trigger
2405 static bool insert_macro_line(cptr *lines_list, int cy)
2414 /* Do not process macros */
2420 /* Read the pattern */
2426 /* Do not process macros */
2429 /* Do not wait for keys */
2432 /* Attempt to read a key */
2442 /* Convert the trigger */
2443 ascii_to_text(tmp, buf);
2446 if(!tmp[0]) return FALSE;
2448 /* Insert preference string */
2449 insert_return_code(lines_list, 0, cy);
2450 string_free(lines_list[cy]);
2451 lines_list[cy] = string_make(format("P:%s", tmp));
2453 /* Insert blank action preference line */
2454 insert_return_code(lines_list, 0, cy);
2455 string_free(lines_list[cy]);
2456 lines_list[cy] = string_make("A:");
2463 * Get a command key and insert ASCII string for the key
2465 static bool insert_keymap_line(cptr *lines_list, int cy)
2472 if (rogue_like_commands)
2474 mode = KEYMAP_MODE_ROGUE;
2480 mode = KEYMAP_MODE_ORIG;
2493 /* Convert the trigger */
2494 ascii_to_text(tmp, buf);
2497 if(!tmp[0]) return FALSE;
2499 /* Insert preference string */
2500 insert_return_code(lines_list, 0, cy);
2501 string_free(lines_list[cy]);
2502 lines_list[cy] = string_make(format("C:%d:%s", mode, tmp));
2504 /* Insert blank action preference line */
2505 insert_return_code(lines_list, 0, cy);
2506 string_free(lines_list[cy]);
2507 lines_list[cy] = string_make("A:");
2514 * Description of control commands
2519 static cptr ctrl_command_desc[] =
2522 #define LAST_DESTROYED 6
2523 "^P ^N ^B ^F ¾å²¼º¸±¦¤Ë°ÜÆ°",
2524 "^A ^E ¹Ô¤ÎÀèƬ¡¢½ªÃ¼",
2525 "^Q ÆþÎÏ/¥³¥Þ¥ó¥É¥â¡¼¥ÉÀÚ¤êÂؤ¨",
2526 "^R Êѹ¹¤òÁ´¤Æ¼è¤ê¾Ã¤·¤Æ¸µ¤ËÌ᤹",
2527 "------------------------------------",
2528 "^I »ý¤Áʪ/ÁõÈ÷¤«¤éÁªÂò",
2530 "^K ¥«¡¼¥½¥ë¤«¤é½ªÃ¼¤Þ¤Çºï½ü",
2531 "^Y ºï½ü(^K)¤·¤¿¹Ô¤òÁÞÆþ",
2532 "^C ¼ï²¡¢¿¦¶È¤Î¾ò·ï¼°¤òÁÞÆþ",
2533 "------------------------------------",
2534 "^S Êѹ¹ (!Ç˲õ/~ÊüÃÖ/½¦¤¦)",
2535 "^G \"(\" Á´ÂΥޥåפÇɽ¼¨¤·¤Ê¤¤",
2536 "^O \"#\" ¼«Æ°¹ï¤ß",
2537 "------------------------------------",
2538 "^U ̤´ÕÄê/̤ȽÌÀ/´ÕÄê/*´ÕÄê*",
2540 "^X ̵ÌÃ/¥¨¥´/¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È",
2544 #define LAST_DESTROYED 6
2545 "^P ^N ^B ^F Move Cursor",
2546 "^A ^E Beginning and End of Line",
2547 "^Q Toggle Insert/Command mode",
2548 "^R Revert to Original File",
2549 "------------------------------------",
2550 "^I Object in Inventry/Equipment",
2552 "^K Kill Rest of Line",
2553 "^Y Insert killed(^K) text",
2554 "^C Insert conditional expression",
2555 "------------------------------------",
2556 "^S Toggle(!Destroy/~Leave/Pick)",
2557 "^G \"(\" No display in the 'M'ap",
2558 "^O \"#\" Auto-Inscribe",
2559 "------------------------------------",
2560 "^U Toggle 'identified' state",
2562 "^X Toggle nameless/ego/artifact",
2563 "^Z \"collecting\"",
2569 #define MAX_YANK MAX_LINELEN
2570 #define DIRTY_ALL 0x01
2571 #define DIRTY_COMMAND 0x02
2572 #define DIRTY_MODE 0x04
2573 #define DIRTY_SCREEN 0x08
2574 #define DIRTY_NOT_FOUND 0x10
2575 #define DIRTY_NO_SEARCH 0x20
2578 * In-game editor of Object Auto-picker/Destoryer
2580 void do_cmd_edit_autopick(void)
2582 static int cx = 0, cy = 0;
2583 static int upper = 0, left = 0;
2585 object_type *search_o_ptr = NULL;
2586 cptr search_str = NULL;
2587 cptr last_destroyed = NULL;
2588 char last_destroyed_command[WID_DESC+3];
2589 char yank_buf[MAX_YANK];
2591 autopick_type an_entry, *entry = &an_entry;
2592 char buf[MAX_LINELEN];
2594 int filename_mode = PT_WITH_PNAME;
2599 int old_upper = -1, old_left = -1;
2601 int key = -1, old_key;
2602 bool repeated_clearing = FALSE;
2603 bool edit_mode = FALSE;
2605 byte dirty_flags = DIRTY_ALL | DIRTY_COMMAND | DIRTY_MODE;
2606 int dirty_line = -1;
2608 int wid, hgt, old_wid = -1, old_hgt = -1;
2610 static s32b old_autosave_turn = 0L;
2613 if (turn > old_autosave_turn + 100L)
2615 do_cmd_save_game(TRUE);
2616 old_autosave_turn = turn;
2619 /* HACK -- Reset start_time to stop counting playtime while edit */
2622 /* Free old entries */
2625 /* Command Description of the 'Last Destroyed Item' */
2626 if (autopick_last_destroyed_object.k_idx)
2628 autopick_entry_from_object(entry, &autopick_last_destroyed_object);
2629 last_destroyed = autopick_line_from_entry_kill(entry);
2631 my_strcpy(last_destroyed_command, format("^L \"%s\"", last_destroyed), sizeof(last_destroyed_command));
2636 strcpy(last_destroyed_command, "^L ºÇ¸å¤Ë¼«Æ°Ç˲õ¤·¤¿¥¢¥¤¥Æ¥à̾");
2638 strcpy(last_destroyed_command, "^L Last destroyed object");
2641 ctrl_command_desc[LAST_DESTROYED] = last_destroyed_command;
2643 /* Conditional Expression for Class and Race */
2644 sprintf(classrace, "?:[AND [EQU $RACE %s] [EQU $CLASS %s]]",
2646 rp_ptr->E_title, cp_ptr->E_title
2648 rp_ptr->title, cp_ptr->title
2652 /* Clear yank buffer */
2655 /* Read or initialize whole text */
2656 lines_list = read_pickpref_text_lines(&filename_mode);
2658 /* Reset cursor position if needed */
2659 for (i = 0; i < cy; i++)
2668 /* Save the screen */
2671 /* Process requests until done */
2675 Term_get_size(&wid, &hgt);
2678 /* Don't let cursor at second byte of kanji */
2679 for (i = 0; lines_list[cy][i]; i++)
2680 if (iskanji(lines_list[cy][i]))
2691 /* Scroll if necessary */
2692 if (cy < upper || upper + hgt - 4 <= cy)
2693 upper = cy - (hgt-4)/2;
2696 if ((cx < left + 10 && left > 0) || left + wid - WID_DESC - 5 <= cx)
2697 left = cx - (wid - WID_DESC)*2/3;
2701 /* Redraw whole window after resize */
2702 if (old_wid != wid || old_hgt != hgt)
2703 dirty_flags |= DIRTY_SCREEN;
2705 /* Redraw all text after scroll */
2706 else if (old_upper != upper || old_left != left)
2707 dirty_flags |= DIRTY_ALL;
2710 if (dirty_flags & DIRTY_SCREEN)
2712 dirty_flags |= (DIRTY_ALL | DIRTY_COMMAND | DIRTY_MODE);
2718 if (dirty_flags & DIRTY_COMMAND)
2720 /* Display control command */
2721 for (i = 0; ctrl_command_desc[i]; i++)
2722 Term_putstr(wid - WID_DESC, i + 1, WID_DESC, TERM_WHITE, ctrl_command_desc[i]);
2725 /* Redraw mode line */
2726 if (dirty_flags & DIRTY_MODE)
2728 int sepa_length = wid - WID_DESC;
2731 for (i = 0; i < sepa_length; i++)
2737 strncpy(buf + sepa_length - 21, " (INSERT MODE) ", 16);
2739 strncpy(buf + sepa_length - 21, " (COMMAND MODE) ", 16);
2741 Term_putstr(0, hgt - 3, sepa_length, (byte) (edit_mode ? TERM_YELLOW : TERM_WHITE), buf);
2744 /* Dump up to 20, or hgt-4, lines of messages */
2745 for (i = 0; i < hgt - 4; i++)
2750 /* clean or dirty? */
2751 if (!(dirty_flags & DIRTY_ALL) && (dirty_line != upper+i))
2754 msg = lines_list[upper+i];
2757 /* Apply horizontal scroll */
2758 for (j = 0; *msg; msg++, j++)
2760 if (j == left) break;
2776 Term_erase(0, i + 1, wid - WID_DESC);
2778 /* Dump the messages, bottom to top */
2779 Term_putstr(leftcol, i + 1, wid - WID_DESC - 1, TERM_WHITE, msg);
2782 for (; i < hgt - 4; i++)
2785 Term_erase(0, i + 1, wid - WID_DESC);
2788 /* Display header line */
2791 prt("^Q ESC ¤Ç¥³¥Þ¥ó¥É¥â¡¼¥É¤Ø°Ü¹Ô¡¢Ä̾ï¤Îʸ»ú¤Ï¤½¤Î¤Þ¤ÞÆþÎÏ", 0, 0);
2793 prt("q _ ¤Ç½ªÎ»¡¢hjkl2468 ¤Ç°ÜÆ°¡¢^Q a i ¤ÇÆþÎϥ⡼¥É¡¢/ n N ¤Ç¸¡º÷", 0, 0);
2796 prt("Press ^Q ESC to command mode, any letters to insert", 0, 0);
2798 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);
2800 /* Display current position */
2801 prt (format("(%d,%d)", cx, cy), 0, 70);
2803 /* Display information when updated */
2804 if (old_cy != cy || (dirty_flags & (DIRTY_ALL | DIRTY_NOT_FOUND | DIRTY_NO_SEARCH)) || dirty_line == cy)
2806 /* Clear information line */
2807 Term_erase(0, hgt - 3 + 1, wid);
2808 Term_erase(0, hgt - 3 + 2, wid);
2810 /* Display information */
2811 if (dirty_flags & DIRTY_NOT_FOUND)
2814 prt(format("¥Ñ¥¿¡¼¥ó¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó: %s", search_str), hgt - 3 + 1, 0);
2816 prt(format("Pattern not found: %s", search_str), hgt - 3 + 1, 0);
2819 else if (dirty_flags & DIRTY_NO_SEARCH)
2822 prt("¸¡º÷Ãæ¤Î¥Ñ¥¿¡¼¥ó¤¬¤¢¤ê¤Þ¤»¤ó('/'¤Ç¸¡º÷)¡£", hgt - 3 + 1, 0);
2824 prt("No pattern to search. (Press '/' to search.)", hgt - 3 + 1, 0);
2827 else if (lines_list[cy][0] == '#')
2830 prt("¤³¤Î¹Ô¤Ï¥³¥á¥ó¥È¤Ç¤¹¡£", hgt - 3 + 1, 0);
2832 prt("This line is comment.", hgt - 3 + 1, 0);
2835 else if (lines_list[cy][1] == ':')
2837 switch(lines_list[cy][0])
2841 prt("¤³¤Î¹Ô¤Ï¾ò·ïʬ´ô¼°¤Ç¤¹¡£", hgt - 3 + 1, 0);
2843 prt("This line is Conditional Expression.", hgt - 3 + 1, 0);
2848 prt("¤³¤Î¹Ô¤Ï¥Þ¥¯¥í¤Î¼Â¹ÔÆâÍƤòÄêµÁ¤·¤Þ¤¹¡£", hgt - 3 + 1, 0);
2850 prt("This line defines Macro action.", hgt - 3 + 1, 0);
2855 prt("¤³¤Î¹Ô¤Ï¥Þ¥¯¥í¤Î¥È¥ê¥¬¡¼¡¦¥¡¼¤òÄêµÁ¤·¤Þ¤¹¡£", hgt - 3 + 1, 0);
2857 prt("This line defines Macro trigger key.", hgt - 3 + 1, 0);
2862 prt("¤³¤Î¹Ô¤Ï¥¡¼ÇÛÃÖ¤òÄêµÁ¤·¤Þ¤¹¡£", hgt - 3 + 1, 0);
2864 prt("This line defines Keymap.", hgt - 3 + 1, 0);
2870 /* Get description of an autopicker preference line */
2871 else if (autopick_new_entry(entry, lines_list[cy]))
2876 describe_autopick(buf, entry);
2878 roff_to_buf(buf, 81, temp);
2880 for (i = 0; i< 2; i++)
2886 prt(t, hgt - 3 + 1 + i, 0);
2890 autopick_free_entry(entry);
2895 Term_gotoxy(cx - left, cy - upper + 1);
2901 /* Save old key and location */
2909 /* Do not process macros except special keys */
2910 inkey_special = TRUE;
2921 /* Mode line is now dirty */
2922 dirty_flags |= DIRTY_MODE;
2925 /* Insert a character */
2926 else if (!iscntrl(key&0xff))
2930 /* Save preceding string */
2931 for (i = j = 0; lines_list[cy][i] && i < cx; i++)
2932 buf[j++] = lines_list[cy][i];
2934 /* Add a character */
2940 if (j+2 < MAX_LINELEN)
2952 if (j+1 < MAX_LINELEN)
2958 for (; lines_list[cy][i] && j + 1 < MAX_LINELEN; i++)
2959 buf[j++] = lines_list[cy][i];
2962 /* Replace current line with new line */
2963 string_free(lines_list[cy]);
2964 lines_list[cy] = string_make(buf);
2966 /* Move to correct collumn */
2967 len = strlen(lines_list[cy]);
2968 if (len < cx) cx = len;
2977 if (key == 'q' || key == '_') break;
2984 /* Mode line is now dirty */
2985 dirty_flags |= DIRTY_MODE;
2988 if (!autopick_new_entry(entry, lines_list[cy]))
2990 if (old_key != key) repeated_clearing = FALSE;
2993 if (lines_list[cy + 1]) cy++;
2997 string_free(lines_list[cy]);
3001 if (entry->action & DONT_AUTOPICK)
3002 repeated_clearing = TRUE;
3004 repeated_clearing = FALSE;
3007 entry->action &= ~DO_AUTODESTROY;
3008 entry->action &= ~DO_QUERY_AUTOPICK;
3009 if (!repeated_clearing)
3011 entry->action &= ~DO_AUTOPICK;
3012 entry->action |= DONT_AUTOPICK;
3016 entry->action &= ~DONT_AUTOPICK;
3017 entry->action |= DO_AUTOPICK;
3020 lines_list[cy] = autopick_line_from_entry_kill(entry);
3026 if (lines_list[cy + 1]) cy++;
3030 if (!autopick_new_entry(entry, lines_list[cy]))
3032 if (old_key != key) repeated_clearing = FALSE;
3035 if (lines_list[cy + 1]) cy++;
3039 string_free(lines_list[cy]);
3043 if (entry->action & DO_AUTODESTROY)
3044 repeated_clearing = TRUE;
3046 repeated_clearing = FALSE;
3049 entry->action &= ~DONT_AUTOPICK;
3050 entry->action &= ~DO_QUERY_AUTOPICK;
3051 if (!repeated_clearing)
3053 entry->action &= ~DO_AUTOPICK;
3054 entry->action |= DO_AUTODESTROY;
3058 entry->action &= ~DO_AUTODESTROY;
3059 entry->action |= DO_AUTOPICK;
3062 lines_list[cy] = autopick_line_from_entry_kill(entry);
3068 if (lines_list[cy + 1]) cy++;
3072 if (!autopick_new_entry(entry, lines_list[cy]))
3074 if (old_key != key) repeated_clearing = FALSE;
3077 if (lines_list[cy + 1]) cy++;
3081 string_free(lines_list[cy]);
3085 if (entry->action & DO_QUERY_AUTOPICK)
3086 repeated_clearing = TRUE;
3088 repeated_clearing = FALSE;
3091 entry->action &= ~DO_AUTODESTROY;
3092 entry->action &= ~DONT_AUTOPICK;
3093 if (!repeated_clearing)
3095 entry->action &= ~DO_AUTOPICK;
3096 entry->action |= DO_QUERY_AUTOPICK;
3100 entry->action &= ~DO_QUERY_AUTOPICK;
3101 entry->action |= DO_AUTOPICK;
3104 lines_list[cy] = autopick_line_from_entry_kill(entry);
3110 if (lines_list[cy + 1]) cy++;
3114 /* Toggle display on the 'M'ap */
3115 if (!autopick_new_entry(entry, lines_list[cy]))
3117 if (old_key != key) repeated_clearing = FALSE;
3120 if (lines_list[cy + 1]) cy++;
3124 string_free(lines_list[cy]);
3128 if (entry->action & DO_DISPLAY)
3129 repeated_clearing = TRUE;
3131 repeated_clearing = FALSE;
3134 if (!repeated_clearing)
3135 entry->action |= DO_DISPLAY;
3137 entry->action &= ~DO_DISPLAY;
3139 lines_list[cy] = autopick_line_from_entry_kill(entry);
3145 if (lines_list[cy + 1]) cy++;
3165 while (cy < upper + hgt-4 && lines_list[cy + 1])
3170 while (0 < cy && upper <= cy)
3172 while (0 < upper && cy + 1 < upper + hgt - 4)
3181 while (lines_list[cy + 1])
3187 Term_erase(0, cy - upper + 1, wid - WID_DESC);
3191 Term_putstr(0, cy - upper + 1, wid - WID_DESC - 1, TERM_YELLOW, "P:<¥È¥ê¥¬¡¼¥¡¼>: ");
3193 Term_putstr(0, cy - upper + 1, wid - WID_DESC - 1, TERM_YELLOW, "P:<Trigger key>: ");
3195 if (insert_macro_line(lines_list, cy))
3197 /* Prepare to input action */
3202 dirty_flags |= DIRTY_ALL;
3203 dirty_flags |= DIRTY_MODE;
3210 Term_erase(0, cy - upper + 1, wid - WID_DESC);
3214 Term_putstr(0, cy - upper + 1, wid - WID_DESC - 1, TERM_YELLOW, format("C:%d:<¥³¥Þ¥ó¥É¥¡¼>: ", (rogue_like_commands ? KEYMAP_MODE_ROGUE : KEYMAP_MODE_ORIG)));
3216 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)));
3219 if (insert_keymap_line(lines_list, cy))
3221 /* Prepare to input action */
3226 dirty_flags |= DIRTY_ALL;
3227 dirty_flags |= DIRTY_MODE;
3231 /* Become dirty because of item/equip menu */
3232 dirty_flags |= DIRTY_SCREEN;
3234 if (!get_string_for_search(&search_o_ptr, &search_str))
3241 if (!search_for_object(lines_list, search_o_ptr, &cx, &cy, TRUE)) dirty_flags |= DIRTY_NOT_FOUND;
3243 else if (search_str)
3245 if (!search_for_string(lines_list, search_str, &cx, &cy, TRUE)) dirty_flags |= DIRTY_NOT_FOUND;
3249 dirty_flags |= DIRTY_NO_SEARCH;
3255 if (!search_for_object(lines_list, search_o_ptr, &cx, &cy, FALSE)) dirty_flags |= DIRTY_NOT_FOUND;
3257 else if (search_str)
3259 if (!search_for_string(lines_list, search_str, &cx, &cy, FALSE)) dirty_flags |= DIRTY_NOT_FOUND;
3263 dirty_flags |= DIRTY_NO_SEARCH;
3272 /* Beginning of line */
3280 len = strlen(lines_list[cy]);
3281 if (len < cx) cx = len;
3286 cx = strlen(lines_list[cy]);
3290 /* Insert a conditinal expression line */
3291 insert_return_code(lines_list, 0, cy);
3292 string_free(lines_list[cy]);
3293 lines_list[cy] = string_make(classrace);
3295 insert_return_code(lines_list, 0, cy);
3296 string_free(lines_list[cy]);
3297 lines_list[cy] = string_make("?:1");
3301 dirty_flags |= DIRTY_ALL;
3305 cx = strlen(lines_list[cy]);
3310 if (iskanji(lines_list[cy][cx])) cx++;
3313 len = strlen(lines_list[cy]);
3316 if (lines_list[cy + 1])
3326 /* Toggle display on the 'M'ap */
3327 if (!autopick_new_entry(entry, lines_list[cy]))
3329 string_free(lines_list[cy]);
3331 if (entry->action & DO_DISPLAY)
3333 entry->action &= ~DO_DISPLAY;
3338 entry->action |= DO_DISPLAY;
3342 lines_list[cy] = autopick_line_from_entry_kill(entry);
3348 /* Insert choosen item name */
3349 if (!entry_from_choosed_object(entry))
3351 /* Now dirty because of item/equip menu */
3352 dirty_flags |= DIRTY_SCREEN;
3356 insert_return_code(lines_list, 0, cy);
3357 string_free(lines_list[cy]);
3358 lines_list[cy] = autopick_line_from_entry_kill(entry);
3361 /* Now dirty because of item/equip menu */
3362 dirty_flags |= DIRTY_SCREEN;
3366 /* Insert a name of last destroyed item */
3369 insert_return_code(lines_list, 0, cy);
3370 string_free(lines_list[cy]);
3371 lines_list[cy] = string_make(last_destroyed);
3375 dirty_flags |= DIRTY_ALL;
3378 case '\n': case '\r':
3379 /* Split a line or insert end of line */
3380 insert_return_code(lines_list, cx, cy);
3385 dirty_flags |= DIRTY_ALL;
3389 if (lines_list[cy + 1]) cy++;
3392 /* Prepare to write auto-inscription text */
3393 if (!autopick_new_entry(entry, lines_list[cy]))
3395 string_free(lines_list[cy]);
3397 if (!entry->insc) entry->insc = string_make("");
3399 lines_list[cy] = autopick_line_from_entry_kill(entry);
3401 /* Move to collumn for auto inscription */
3402 for (cx = 0; lines_list[cy][cx]; cx++)
3403 if (lines_list[cy][cx] == '#') break;
3409 dirty_flags |= DIRTY_MODE;
3417 edit_mode = !edit_mode;
3419 /* Mode line is now dirty */
3420 dirty_flags |= DIRTY_MODE;
3423 /* Revert to original */
3425 if (!get_check("Á´¤Æ¤ÎÊѹ¹¤òÇË´þ¤·¤Æ¸µ¤Î¾õÂÖ¤ËÌᤷ¤Þ¤¹¡£¤è¤í¤·¤¤¤Ç¤¹¤«¡© "))
3427 if (!get_check("Discard all change and revert to original file. Are you sure? "))
3431 free_text_lines(lines_list);
3432 lines_list = read_pickpref_text_lines(&filename_mode);
3433 dirty_flags |= DIRTY_ALL | DIRTY_MODE;
3438 /* Rotate action; pickup/destroy/leave */
3439 if (!autopick_new_entry(entry, lines_list[cy]))
3441 string_free(lines_list[cy]);
3443 if (entry->action & DO_AUTOPICK)
3445 entry->action &= ~DO_AUTOPICK;
3446 entry->action |= DO_AUTODESTROY;
3448 else if (entry->action & DO_AUTODESTROY)
3450 entry->action &= ~DO_AUTODESTROY;
3451 entry->action |= DONT_AUTOPICK;
3453 else if (entry->action & DONT_AUTOPICK)
3455 entry->action &= ~DONT_AUTOPICK;
3456 entry->action |= DO_AUTOPICK;
3459 lines_list[cy] = autopick_line_from_entry_kill(entry);
3469 /* Rotate identify-state; identified/unidentified/... */
3470 if (!autopick_new_entry(entry, lines_list[cy]))
3472 string_free(lines_list[cy]);
3474 if (IS_FLG(FLG_UNIDENTIFIED))
3476 REM_FLG(FLG_UNIDENTIFIED);
3477 ADD_FLG(FLG_UNAWARE);
3478 REM_FLG(FLG_IDENTIFIED);
3479 REM_FLG(FLG_STAR_IDENTIFIED);
3481 else if (IS_FLG(FLG_UNAWARE))
3483 REM_FLG(FLG_UNIDENTIFIED);
3484 REM_FLG(FLG_UNAWARE);
3485 ADD_FLG(FLG_IDENTIFIED);
3486 REM_FLG(FLG_STAR_IDENTIFIED);
3488 else if (IS_FLG(FLG_STAR_IDENTIFIED))
3490 REM_FLG(FLG_UNIDENTIFIED);
3491 REM_FLG(FLG_UNAWARE);
3492 REM_FLG(FLG_IDENTIFIED);
3493 REM_FLG(FLG_STAR_IDENTIFIED);
3495 else if (IS_FLG(FLG_IDENTIFIED))
3497 REM_FLG(FLG_UNIDENTIFIED);
3498 REM_FLG(FLG_UNAWARE);
3499 REM_FLG(FLG_IDENTIFIED);
3500 ADD_FLG(FLG_STAR_IDENTIFIED);
3504 ADD_FLG(FLG_UNIDENTIFIED);
3505 REM_FLG(FLG_UNAWARE);
3506 REM_FLG(FLG_IDENTIFIED);
3507 REM_FLG(FLG_STAR_IDENTIFIED);
3510 lines_list[cy] = autopick_line_from_entry_kill(entry);
3517 while (cy < upper + hgt-4 && lines_list[cy + 1])
3522 /* Toggle 'worthless' */
3523 toggle_string(lines_list, FLG_WORTHLESS, cy);
3528 /* Rotate within nameless, ego, artifact */
3529 if (!autopick_new_entry(entry, lines_list[cy]))
3531 string_free(lines_list[cy]);
3533 if (IS_FLG(FLG_NAMELESS))
3535 REM_FLG(FLG_NAMELESS);
3537 REM_FLG(FLG_ARTIFACT);
3539 else if (IS_FLG(FLG_EGO))
3541 REM_FLG(FLG_NAMELESS);
3543 ADD_FLG(FLG_ARTIFACT);
3545 else if (IS_FLG(FLG_ARTIFACT))
3547 REM_FLG(FLG_NAMELESS);
3549 REM_FLG(FLG_ARTIFACT);
3553 ADD_FLG(FLG_NAMELESS);
3555 REM_FLG(FLG_ARTIFACT);
3558 lines_list[cy] = autopick_line_from_entry_kill(entry);
3565 /* Paste killed text */
3566 if (strlen(yank_buf))
3570 for (j = 0; yank_buf[j]; j += strlen(yank_buf + j) + 1)
3572 if (ret && '\n' == yank_buf[j])
3578 /* Split current line */
3579 insert_return_code(lines_list, cx, cy);
3581 /* Save preceding string */
3582 for(i = 0; lines_list[cy][i]; i++)
3583 buf[i] = lines_list[cy][i];
3585 /* Paste yank buffer */
3586 if ('\n' != yank_buf[j])
3589 while (yank_buf[k] && i < MAX_LINELEN-1)
3590 buf[i++] = yank_buf[k++];
3596 string_free(lines_list[cy]);
3597 lines_list[cy] = string_make(buf);
3599 /* Move to the beggining of next line */
3605 dirty_flags |= DIRTY_ALL;
3609 /* Toggle 'collecting' */
3610 toggle_string(lines_list, FLG_COLLECTING, cy);
3616 /* Kill rest of line */
3617 if ((uint)cx > strlen(lines_list[cy]))
3618 cx = (int)strlen(lines_list[cy]);
3620 /* Save preceding string */
3621 for (i = 0; lines_list[cy][i] && i < cx; i++)
3624 if (iskanji(lines_list[cy][i]))
3626 buf[i] = lines_list[cy][i];
3630 buf[i] = lines_list[cy][i];
3637 j += strlen(yank_buf + j) + 1;
3639 /* Copy following to yank buffer */
3640 if (lines_list[cy][i])
3642 while (lines_list[cy][i] && j < MAX_YANK - 2)
3643 yank_buf[j++] = lines_list[cy][i++];
3648 if (j < MAX_YANK - 2)
3649 yank_buf[j++] = '\n';
3652 yank_buf[j++] = '\0';
3655 /* Replace current line with 'preceding string' */
3656 string_free(lines_list[cy]);
3657 lines_list[cy] = string_make(buf);
3669 /* DELETE == go forward + BACK SPACE */
3671 if (iskanji(lines_list[cy][cx])) cx++;
3679 len = strlen(lines_list[cy]);
3682 if (lines_list[cy + 1])
3696 /* delete a return code and union two lines */
3698 cx = strlen(lines_list[cy-1]);
3699 strcpy(buf, lines_list[cy-1]);
3700 strcat(buf, lines_list[cy]);
3701 string_free(lines_list[cy-1]);
3702 string_free(lines_list[cy]);
3703 lines_list[cy-1] = string_make(buf);
3704 for (i = cy; lines_list[i+1]; i++)
3705 lines_list[i] = lines_list[i+1];
3706 lines_list[i] = NULL;
3710 dirty_flags |= DIRTY_ALL;
3714 for (i = j = k = 0; lines_list[cy][i] && i < cx; i++)
3718 if (iskanji(lines_list[cy][i]))
3719 buf[j++] = lines_list[cy][i++];
3721 buf[j++] = lines_list[cy][i];
3728 for (; lines_list[cy][i]; i++)
3729 buf[j++] = lines_list[cy][i];
3731 string_free(lines_list[cy]);
3732 lines_list[cy] = string_make(buf);
3741 /* Restore the screen */
3744 switch (filename_mode)
3748 strcpy(buf, "picktype.prf");
3750 strcpy(buf, "pickpref.prf");
3756 sprintf(buf, "picktype-%s.prf", player_name);
3758 sprintf(buf, "pickpref-%s.prf", player_name);
3763 write_text_lines(buf, lines_list);
3764 free_text_lines(lines_list);
3766 string_free(last_destroyed);
3768 /* Reload autopick pref */
3769 process_pickpref_file(buf);
3771 /* HACK -- reset start_time so that playtime is not increase while edit */
3772 start_time = time(NULL);