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;
607 if (k_info[o_ptr->k_idx].pval ||
608 (o_ptr->name2 && e_info[o_ptr->name2].max_pval))
610 if (o_ptr->pval < entry->bonus) return FALSE;
614 if (o_ptr->to_h < entry->bonus &&
615 o_ptr->to_d < entry->bonus &&
616 o_ptr->to_a < entry->bonus &&
617 o_ptr->pval < entry->bonus)
622 /*** Worthless items ***/
623 if (IS_FLG(FLG_WORTHLESS) && object_value(o_ptr) > 0)
626 /*** Artifact object ***/
627 if (IS_FLG(FLG_ARTIFACT))
629 if (!object_known_p(o_ptr) || (!o_ptr->name1 && !o_ptr->art_name))
636 if (!object_known_p(o_ptr) || !o_ptr->name2)
641 if (IS_FLG(FLG_NAMELESS))
646 case TV_SHOT: case TV_ARROW: case TV_BOLT: case TV_BOW:
647 case TV_DIGGING: case TV_HAFTED: case TV_POLEARM: case TV_SWORD:
648 case TV_BOOTS: case TV_GLOVES: case TV_HELM: case TV_CROWN:
649 case TV_SHIELD: case TV_CLOAK:
650 case TV_SOFT_ARMOR: case TV_HARD_ARMOR: case TV_DRAG_ARMOR:
651 case TV_LITE: case TV_AMULET: case TV_RING: case TV_CARD:
652 if ((!object_known_p(o_ptr) || o_ptr->inscription
653 || o_ptr->name1 || o_ptr->name2 || o_ptr->art_name))
662 /*** Unaware items ***/
663 if (IS_FLG(FLG_UNAWARE) && object_aware_p(o_ptr))
666 /*** Wanted monster's corpse/skeletons ***/
667 if (IS_FLG(FLG_WANTED) &&
668 (o_ptr->tval != TV_CORPSE || !object_is_shoukinkubi(o_ptr)))
671 /*** Unique monster's corpse/skeletons/statues ***/
672 if (IS_FLG(FLG_UNIQUE) &&
673 ((o_ptr->tval != TV_CORPSE && o_ptr->tval != TV_STATUE) ||
674 !(r_info[o_ptr->pval].flags1 & RF1_UNIQUE)))
677 /*** Human corpse/skeletons (for Daemon magic) ***/
678 if (IS_FLG(FLG_HUMAN) &&
679 (o_ptr->tval != TV_CORPSE ||
680 !strchr("pht", r_info[o_ptr->pval].d_char)))
683 /*** Unreadable spellbooks ***/
684 if (IS_FLG(FLG_UNREADABLE) &&
685 (o_ptr->tval < TV_LIFE_BOOK ||
686 check_book_realm(o_ptr->tval, o_ptr->sval)))
689 /*** First realm spellbooks ***/
690 if (IS_FLG(FLG_REALM1) &&
691 (REALM1_BOOK != o_ptr->tval ||
692 p_ptr->pclass == CLASS_SORCERER ||
693 p_ptr->pclass == CLASS_RED_MAGE))
696 /*** Second realm spellbooks ***/
697 if (IS_FLG(FLG_REALM2) &&
698 (REALM2_BOOK != o_ptr->tval ||
699 p_ptr->pclass == CLASS_SORCERER ||
700 p_ptr->pclass == CLASS_RED_MAGE))
703 /*** First rank spellbooks ***/
704 if (IS_FLG(FLG_FIRST) &&
705 (o_ptr->tval < TV_LIFE_BOOK || 0 != o_ptr->sval))
708 /*** Second rank spellbooks ***/
709 if (IS_FLG(FLG_SECOND) &&
710 (o_ptr->tval < TV_LIFE_BOOK || 1 != o_ptr->sval))
713 /*** Third rank spellbooks ***/
714 if (IS_FLG(FLG_THIRD) &&
715 (o_ptr->tval < TV_LIFE_BOOK || 2 != o_ptr->sval))
718 /*** Fourth rank spellbooks ***/
719 if (IS_FLG(FLG_FOURTH) &&
720 (o_ptr->tval < TV_LIFE_BOOK || 3 != o_ptr->sval))
724 if (IS_FLG(FLG_WEAPONS))
728 case TV_BOW: case TV_HAFTED: case TV_POLEARM:
729 case TV_SWORD: case TV_DIGGING:
731 default: return FALSE;
734 else if (IS_FLG(FLG_ARMORS))
738 case TV_BOOTS: case TV_GLOVES: case TV_CLOAK: case TV_CROWN:
739 case TV_HELM: case TV_SHIELD: case TV_SOFT_ARMOR:
740 case TV_HARD_ARMOR: case TV_DRAG_ARMOR:
742 default: return FALSE;
745 else if (IS_FLG(FLG_MISSILES))
749 case TV_SHOT: case TV_BOLT: case TV_ARROW:
751 default: return FALSE;
754 else if (IS_FLG(FLG_DEVICES))
758 case TV_SCROLL: case TV_STAFF: case TV_WAND: case TV_ROD:
760 default: return FALSE;
763 else if (IS_FLG(FLG_LIGHTS))
765 if (!(o_ptr->tval == TV_LITE))
768 else if (IS_FLG(FLG_JUNKS))
772 case TV_SKELETON: case TV_BOTTLE:
773 case TV_JUNK: case TV_STATUE:
775 default: return FALSE;
778 else if (IS_FLG(FLG_SPELLBOOKS))
780 if (!(o_ptr->tval >= TV_LIFE_BOOK))
783 else if (IS_FLG(FLG_HAFTED))
785 if (!(o_ptr->tval == TV_HAFTED))
788 else if (IS_FLG(FLG_SHIELDS))
790 if (!(o_ptr->tval == TV_SHIELD))
793 else if (IS_FLG(FLG_BOWS))
795 if (!(o_ptr->tval == TV_BOW))
798 else if (IS_FLG(FLG_RINGS))
800 if (!(o_ptr->tval == TV_RING))
803 else if (IS_FLG(FLG_AMULETS))
805 if (!(o_ptr->tval == TV_AMULET))
808 else if (IS_FLG(FLG_SUITS))
810 if (!(o_ptr->tval == TV_DRAG_ARMOR ||
811 o_ptr->tval == TV_HARD_ARMOR ||
812 o_ptr->tval == TV_SOFT_ARMOR))
815 else if (IS_FLG(FLG_CLOAKS))
817 if (!(o_ptr->tval == TV_CLOAK))
820 else if (IS_FLG(FLG_HELMS))
822 if (!(o_ptr->tval == TV_CROWN || o_ptr->tval == TV_HELM))
825 else if (IS_FLG(FLG_GLOVES))
827 if (!(o_ptr->tval == TV_GLOVES))
830 else if (IS_FLG(FLG_BOOTS))
832 if (!(o_ptr->tval == TV_BOOTS))
836 /* Keyword don't match */
840 if (strncmp(o_name, ptr, strlen(ptr))) return FALSE;
845 if (!strstr_j(o_name, ptr)) return FALSE;
847 if (!strstr(o_name, ptr)) return FALSE;
851 /* TRUE when it need not to be 'collecting' */
852 if (!IS_FLG(FLG_COLLECTING)) return TRUE;
854 /* Check if there is a same item */
855 for (j = 0; j < INVEN_PACK; j++)
858 * 'Collecting' means the item must be absorbed
859 * into an inventory slot.
860 * But an item can not be absorbed into itself!
862 if ((&inventory[j] != o_ptr) &&
863 object_similar(&inventory[j], o_ptr))
873 * A function for Auto-picker/destroyer
874 * Examine whether the object matches to the list of keywords or not.
876 int is_autopick(object_type *o_ptr)
879 char o_name[MAX_NLEN];
881 if (o_ptr->tval == TV_GOLD) return -1;
883 object_desc(o_name, o_ptr, FALSE, 3);
885 /* Force to be lower case string */
886 for (i = 0; o_name[i]; i++)
889 if (iskanji(o_name[i]))
893 if (isupper(o_name[i]))
894 o_name[i] = tolower(o_name[i]);
897 for (i=0; i < max_autopick; i++)
899 autopick_type *entry = &autopick_list[i];
901 if (is_autopick_aux(o_ptr, entry, o_name)) return i;
904 /* No matching entry */
910 * Automatically destroy items in this grid.
912 static bool is_opt_confirm_destroy(object_type *o_ptr)
914 if (!destroy_items) return FALSE;
916 /* Known to be worthless? */
918 if (object_value(o_ptr) > 0) return FALSE;
921 if ((o_ptr->tval >= TV_SHOT) && (o_ptr->tval <= TV_DRAG_ARMOR)) return FALSE;
924 if ((o_ptr->tval == TV_CHEST) && o_ptr->pval) return FALSE;
928 if (o_ptr->tval == TV_CORPSE
929 && object_is_shoukinkubi(o_ptr)) return FALSE;
933 if (o_ptr->tval == TV_CORPSE) return FALSE;
936 if ((o_ptr->tval == TV_SKELETON) || (o_ptr->tval == TV_BOTTLE) || (o_ptr->tval == TV_JUNK) || (o_ptr->tval == TV_STATUE)) return FALSE;
938 if (o_ptr->tval == TV_GOLD) return FALSE;
947 void auto_inscribe_item(int item, int idx)
951 /* Get the item (in the pack) */
952 if (item >= 0) o_ptr = &inventory[item];
954 /* Get the item (on the floor) */
955 else o_ptr = &o_list[0 - item];
957 /* Auto-inscription or Re-inscribe for resistances {%} */
958 if ((idx < 0 || !autopick_list[idx].insc) && !o_ptr->inscription)
961 if (o_ptr->inscription)
962 o_ptr->inscription = inscribe_flags(o_ptr, quark_str(o_ptr->inscription));
964 o_ptr->inscription = inscribe_flags(o_ptr, autopick_list[idx].insc);
966 if (item > INVEN_PACK)
968 /* Redraw inscription */
969 p_ptr->window |= (PW_EQUIP);
971 /* {.} and {$} effect p_ptr->warning and TRC_TELEPORT_SELF */
972 p_ptr->update |= (PU_BONUS);
976 /* Redraw inscription */
977 p_ptr->window |= (PW_INVEN);
983 * Automatically destroy an item if it is to be destroyed
985 bool auto_destroy_item(int item, int autopick_idx, bool wait_optimize)
987 bool destroy = FALSE;
988 char o_name[MAX_NLEN];
991 /* Don't destroy equipped items */
992 if (item > INVEN_PACK) return FALSE;
994 /* Get the item (in the pack) */
995 if (item >= 0) o_ptr = &inventory[item];
997 /* Get the item (on the floor) */
998 else o_ptr = &o_list[0 - item];
1000 /* Easy-Auto-Destroyer */
1001 if (is_opt_confirm_destroy(o_ptr)) destroy = TRUE;
1003 /* Protected by auto-picker */
1004 if (autopick_idx >= 0 &&
1005 !(autopick_list[autopick_idx].action & DO_AUTODESTROY))
1010 /* Auto-picker/destroyer */
1011 if (autopick_idx >= 0 &&
1012 (autopick_list[autopick_idx].action & DO_AUTODESTROY))
1016 /* Not to be destroyed */
1017 if (!destroy) return FALSE;
1019 /* Now decided to destroy */
1023 /* Describe the object (with {terrible/special}) */
1024 object_desc(o_name, o_ptr, TRUE, 3);
1027 if (!can_player_destroy_object(o_ptr))
1031 msg_format("%s¤ÏÇ˲õÉÔǽ¤À¡£", o_name);
1033 msg_format("You cannot auto-destroy %s.", o_name);
1040 /* Record name of destroyed item */
1041 COPY(&autopick_last_destroyed_object, o_ptr, object_type);
1043 /* Eliminate the item (from the pack) */
1046 inven_item_increase(item, -(o_ptr->number));
1049 * always optimize equipment.
1050 * optimize inventry only when wait_optimize is FALSE.
1052 if (!wait_optimize || item > INVEN_PACK)
1053 inven_item_optimize(item);
1056 /* Eliminate the item (from the floor) */
1059 delete_object_idx(0 - item);
1062 /* Print a message */
1064 msg_format("%s¤ò¼«Æ°Ç˲õ¤·¤Þ¤¹¡£", o_name);
1066 msg_format("Auto-destroying %s.", o_name);
1074 * Optimize all inventry items after consumption of staves or scrolls.
1076 void optimize_inventry_auto_destroy(void)
1080 for (i = 0; i <= INVEN_PACK; i++)
1081 inven_item_optimize(i);
1086 * Automatically pickup/destroy items in this grid.
1088 void auto_pickup_items(cave_type *c_ptr)
1090 s16b this_o_idx, next_o_idx = 0;
1092 /* Scan the pile of objects */
1093 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
1097 /* Acquire object */
1098 object_type *o_ptr = &o_list[this_o_idx];
1100 /* Acquire next object */
1101 next_o_idx = o_ptr->next_o_idx;
1103 idx = is_autopick(o_ptr);
1105 /* Item index for floor -1,-2,-3,... */
1106 auto_inscribe_item((-this_o_idx), idx);
1109 (autopick_list[idx].action & (DO_AUTOPICK | DO_QUERY_AUTOPICK)))
1113 if (!inven_carry_okay(o_ptr))
1115 char o_name[MAX_NLEN];
1117 /* Describe the object */
1118 object_desc(o_name, o_ptr, TRUE, 3);
1122 msg_format("¥¶¥Ã¥¯¤Ë¤Ï%s¤òÆþ¤ì¤ë·ä´Ö¤¬¤Ê¤¤¡£", o_name);
1124 msg_format("You have no room for %s.", o_name);
1126 /* Hack - remember that the item has given a message here. */
1127 o_ptr->marked |= OM_NOMSG;
1131 else if (autopick_list[idx].action & DO_QUERY_AUTOPICK)
1133 char out_val[MAX_NLEN+20];
1134 char o_name[MAX_NLEN];
1136 if (o_ptr->marked & OM_NO_QUERY)
1138 /* Already answered as 'No' */
1142 /* Describe the object */
1143 object_desc(o_name, o_ptr, TRUE, 3);
1146 sprintf(out_val, "%s¤ò½¦¤¤¤Þ¤¹¤«? ", o_name);
1148 sprintf(out_val, "Pick up %s? ", o_name);
1151 if (!get_check(out_val))
1153 /* Hack - remember that the item has given a message here. */
1154 o_ptr->marked |= (OM_NOMSG | OM_NO_QUERY);
1159 py_pickup_aux(this_o_idx);
1166 * When always_pickup is 'yes', we disable
1167 * auto-destroyer from autopick function, and do only
1168 * easy-auto-destroyer.
1172 if (auto_destroy_item((-this_o_idx), idx, FALSE))
1180 * Describe which kind of object is Auto-picked/destroyed
1182 static void describe_autopick(char *buff, autopick_type *entry)
1184 cptr str = entry->name;
1185 byte act = entry->action;
1186 cptr insc = entry->insc;
1192 cptr before_str[100], body_str;
1195 body_str = "¥¢¥¤¥Æ¥à";
1197 /*** Collecting items ***/
1198 /*** Which can be absorbed into a slot as a bundle ***/
1199 if (IS_FLG(FLG_COLLECTING))
1200 before_str[before_n++] = "¼ý½¸Ãæ¤Ç´û¤Ë»ý¤Ã¤Æ¤¤¤ë¥¹¥í¥Ã¥È¤Ë¤Þ¤È¤á¤é¤ì¤ë";
1202 /*** Unidentified ***/
1203 if (IS_FLG(FLG_UNIDENTIFIED))
1204 before_str[before_n++] = "̤´ÕÄê¤Î";
1206 /*** Identified ***/
1207 if (IS_FLG(FLG_IDENTIFIED))
1208 before_str[before_n++] = "´ÕÄêºÑ¤ß¤Î";
1210 /*** *Identified* ***/
1211 if (IS_FLG(FLG_STAR_IDENTIFIED))
1212 before_str[before_n++] = "´°Á´¤Ë´ÕÄêºÑ¤ß¤Î";
1214 /*** Dice boosted (weapon of slaying) ***/
1215 if (IS_FLG(FLG_BOOSTED))
1217 before_str[before_n++] = "¥À¥á¡¼¥¸¥À¥¤¥¹¤¬Ä̾ï¤è¤êÂ礤¤";
1221 /*** Weapons whose dd*ds is more than nn ***/
1222 if (IS_FLG(FLG_MORE_THAN))
1224 static char more_than_desc_str[] = "___";
1225 before_str[before_n++] = "¥À¥á¡¼¥¸¥À¥¤¥¹¤ÎºÇÂçÃͤ¬";
1228 sprintf(more_than_desc_str,"%d", entry->dice);
1229 before_str[before_n++] = more_than_desc_str;
1230 before_str[before_n++] = "°Ê¾å¤Î";
1233 /*** Items whose magical bonus is more than nn ***/
1234 if (IS_FLG(FLG_MORE_BONUS))
1236 static char more_bonus_desc_str[] = "___";
1237 before_str[before_n++] = "½¤ÀµÃͤ¬(+";
1239 sprintf(more_bonus_desc_str,"%d", entry->bonus);
1240 before_str[before_n++] = more_bonus_desc_str;
1241 before_str[before_n++] = ")°Ê¾å¤Î";
1244 /*** Worthless items ***/
1245 if (IS_FLG(FLG_WORTHLESS))
1246 before_str[before_n++] = "Ź¤Ç̵²ÁÃͤÈȽÄꤵ¤ì¤ë";
1249 if (IS_FLG(FLG_ARTIFACT))
1251 before_str[before_n++] = "¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤Î";
1256 if (IS_FLG(FLG_EGO))
1258 before_str[before_n++] = "¥¨¥´¥¢¥¤¥Æ¥à¤Î";
1263 if (IS_FLG(FLG_NAMELESS))
1265 before_str[before_n++] = "¥¨¥´¤Ç¤â¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È¤Ç¤â¤Ê¤¤";
1269 /*** Unaware items ***/
1270 if (IS_FLG(FLG_UNAWARE))
1271 before_str[before_n++] = "̤´ÕÄê¤Ç¤½¤Î¸ú²Ì¤âȽÌÀ¤·¤Æ¤¤¤Ê¤¤";
1273 /*** Wanted monster's corpse/skeletons ***/
1274 if (IS_FLG(FLG_WANTED))
1276 before_str[before_n++] = "¥Ï¥ó¥¿¡¼»ö̳½ê¤Ç¾Þ¶â¼ó¤È¤µ¤ì¤Æ¤¤¤ë";
1277 body_str = "»àÂΤä¹ü";
1280 /*** Human corpse/skeletons (for Daemon magic) ***/
1281 if (IS_FLG(FLG_HUMAN))
1283 before_str[before_n++] = "°ËâËâË¡¤Ç»È¤¦¤¿¤á¤Î¿Í´Ö¤ä¥Ò¥å¡¼¥Þ¥Î¥¤¥É¤Î";
1284 body_str = "»àÂΤä¹ü";
1287 /*** Unique monster's corpse/skeletons/statues ***/
1288 if (IS_FLG(FLG_UNIQUE))
1290 before_str[before_n++] = "¥æ¥Ë¡¼¥¯¥â¥ó¥¹¥¿¡¼¤Î";
1291 body_str = "»àÂΤä¹ü";
1294 /*** Unreadable spellbooks ***/
1295 if (IS_FLG(FLG_UNREADABLE))
1297 before_str[before_n++] = "¤¢¤Ê¤¿¤¬Æɤá¤Ê¤¤Îΰè¤Î";
1298 body_str = "ËâË¡½ñ";
1301 /*** First realm spellbooks ***/
1302 if (IS_FLG(FLG_REALM1))
1304 before_str[before_n++] = "Âè°ìÎΰè¤Î";
1305 body_str = "ËâË¡½ñ";
1308 /*** Second realm spellbooks ***/
1309 if (IS_FLG(FLG_REALM2))
1311 before_str[before_n++] = "ÂèÆóÎΰè¤Î";
1312 body_str = "ËâË¡½ñ";
1315 /*** First rank spellbooks ***/
1316 if (IS_FLG(FLG_FIRST))
1318 before_str[before_n++] = "Á´4ºý¤ÎÆâ¤Î1ºýÌܤÎ";
1319 body_str = "ËâË¡½ñ";
1322 /*** Second rank spellbooks ***/
1323 if (IS_FLG(FLG_SECOND))
1325 before_str[before_n++] = "Á´4ºý¤ÎÆâ¤Î2ºýÌܤÎ";
1326 body_str = "ËâË¡½ñ";
1329 /*** Third rank spellbooks ***/
1330 if (IS_FLG(FLG_THIRD))
1332 before_str[before_n++] = "Á´4ºý¤ÎÆâ¤Î3ºýÌܤÎ";
1333 body_str = "ËâË¡½ñ";
1336 /*** Fourth rank spellbooks ***/
1337 if (IS_FLG(FLG_FOURTH))
1339 before_str[before_n++] = "Á´4ºý¤ÎÆâ¤Î4ºýÌܤÎ";
1340 body_str = "ËâË¡½ñ";
1344 if (IS_FLG(FLG_ITEMS))
1345 ; /* Nothing to do */
1346 else if (IS_FLG(FLG_WEAPONS))
1348 else if (IS_FLG(FLG_ARMORS))
1350 else if (IS_FLG(FLG_MISSILES))
1351 body_str = "ÃƤäÌð¤ä¥¯¥í¥¹¥Ü¥¦¤ÎÌð";
1352 else if (IS_FLG(FLG_DEVICES))
1353 body_str = "´¬Êª¤äËâË¡ËÀ¤ä¾ó¤ä¥í¥Ã¥É";
1354 else if (IS_FLG(FLG_LIGHTS))
1355 body_str = "¸÷¸»ÍѤΥ¢¥¤¥Æ¥à";
1356 else if (IS_FLG(FLG_JUNKS))
1357 body_str = "Àޤ줿ËÀÅù¤Î¥¬¥é¥¯¥¿";
1358 else if (IS_FLG(FLG_SPELLBOOKS))
1359 body_str = "ËâË¡½ñ";
1360 else if (IS_FLG(FLG_HAFTED))
1362 else if (IS_FLG(FLG_SHIELDS))
1364 else if (IS_FLG(FLG_BOWS))
1365 body_str = "¥¹¥ê¥ó¥°¤äµÝ¤ä¥¯¥í¥¹¥Ü¥¦";
1366 else if (IS_FLG(FLG_RINGS))
1368 else if (IS_FLG(FLG_AMULETS))
1369 body_str = "¥¢¥ß¥å¥ì¥Ã¥È";
1370 else if (IS_FLG(FLG_SUITS))
1372 else if (IS_FLG(FLG_CLOAKS))
1373 body_str = "¥¯¥í¡¼¥¯";
1374 else if (IS_FLG(FLG_HELMS))
1375 body_str = "¥Ø¥ë¥á¥Ã¥È¤ä´§";
1376 else if (IS_FLG(FLG_GLOVES))
1378 else if (IS_FLG(FLG_BOOTS))
1379 body_str = "¥Ö¡¼¥Ä";
1383 strcat(buff, "Á´¤Æ¤Î");
1384 else for (i = 0; i < before_n && before_str[i]; i++)
1385 strcat(buff, before_str[i]);
1387 strcat(buff, body_str);
1397 strcat(buff, "¤Ç¡¢Ì¾Á°¤¬¡Ö");
1398 strncat(buff, str, 80);
1400 strcat(buff, "¡×¤Ç»Ï¤Þ¤ë¤â¤Î");
1402 strcat(buff, "¡×¤ò´Þ¤à¤â¤Î");
1407 strncat(buff, format("¤Ë¡Ö%s¡×", insc), 80);
1409 if (strstr(insc, "%%all"))
1410 strcat(buff, "(%%all¤ÏÁ´Ç½ÎϤòɽ¤¹±Ñ»ú¤Îµ¹æ¤ÇÃÖ´¹)");
1411 else if (strstr(insc, "%all"))
1412 strcat(buff, "(%all¤ÏÁ´Ç½ÎϤòɽ¤¹µ¹æ¤ÇÃÖ´¹)");
1413 else if (strstr(insc, "%%"))
1414 strcat(buff, "(%%¤ÏÄɲÃǽÎϤòɽ¤¹±Ñ»ú¤Îµ¹æ¤ÇÃÖ´¹)");
1415 else if (strstr(insc, "%"))
1416 strcat(buff, "(%¤ÏÄɲÃǽÎϤòɽ¤¹µ¹æ¤ÇÃÖ´¹)");
1418 strcat(buff, "¤È¹ï¤ó¤Ç");
1423 if (act & DONT_AUTOPICK)
1424 strcat(buff, "ÊüÃÖ¤¹¤ë¡£");
1425 else if (act & DO_AUTODESTROY)
1426 strcat(buff, "Ç˲õ¤¹¤ë¡£");
1427 else if (act & DO_QUERY_AUTOPICK)
1428 strcat(buff, "³Îǧ¤Î¸å¤Ë½¦¤¦¡£");
1430 strcat(buff, "½¦¤¦¡£");
1432 if (act & DO_DISPLAY)
1434 if (act & DONT_AUTOPICK)
1435 strcat(buff, "Á´ÂΥޥå×('M')¤Ç'N'¤ò²¡¤·¤¿¤È¤¤Ëɽ¼¨¤¹¤ë¡£");
1436 else if (act & DO_AUTODESTROY)
1437 strcat(buff, "Á´ÂΥޥå×('M')¤Ç'K'¤ò²¡¤·¤¿¤È¤¤Ëɽ¼¨¤¹¤ë¡£");
1439 strcat(buff, "Á´ÂΥޥå×('M')¤Ç'M'¤ò²¡¤·¤¿¤È¤¤Ëɽ¼¨¤¹¤ë¡£");
1442 strcat(buff, "Á´ÂΥޥåפˤÏɽ¼¨¤·¤Ê¤¤");
1446 cptr before_str[20], after_str[20], which_str[20], whose_str[20], body_str;
1447 int before_n = 0, after_n = 0, which_n = 0, whose_n = 0;
1451 /*** Collecting items ***/
1452 /*** Which can be absorbed into a slot as a bundle ***/
1453 if (IS_FLG(FLG_COLLECTING))
1454 which_str[which_n++] = "can be absorbed into an existing inventory slot";
1456 /*** Unidentified ***/
1457 if (IS_FLG(FLG_UNIDENTIFIED))
1458 before_str[before_n++] = "unidentified";
1460 /*** Identified ***/
1461 if (IS_FLG(FLG_IDENTIFIED))
1462 before_str[before_n++] = "identified";
1464 /*** *Identified* ***/
1465 if (IS_FLG(FLG_STAR_IDENTIFIED))
1466 before_str[before_n++] = "fully identified";
1468 /*** Worthless items ***/
1469 if (IS_FLG(FLG_WORTHLESS))
1471 before_str[before_n++] = "worthless";
1472 which_str[which_n++] = "can not be sold at stores";
1476 if (IS_FLG(FLG_ARTIFACT))
1478 before_str[before_n++] = "artifact";
1482 if (IS_FLG(FLG_EGO))
1484 before_str[before_n++] = "ego";
1488 if (IS_FLG(FLG_NAMELESS))
1490 body_str = "equipment";
1491 which_str[which_n++] = "is neither ego-item nor artifact";
1494 /*** Unaware items ***/
1495 if (IS_FLG(FLG_UNAWARE))
1497 before_str[before_n++] = "unidentified";
1498 whose_str[whose_n++] = "basic abilities are not known";
1501 /*** Dice boosted (weapon of slaying) ***/
1502 if (IS_FLG(FLG_BOOSTED))
1504 body_str = "weapons";
1505 whose_str[whose_n++] = "damage dice is bigger than normal";
1508 /*** Weapons whose dd*ds is more than nn ***/
1509 if (IS_FLG(FLG_MORE_THAN))
1511 static char more_than_desc_str[] =
1512 "maximum damage from dice is bigger than __";
1513 body_str = "weapons";
1515 sprintf(more_than_desc_str + sizeof(more_than_desc_str) - 3,
1517 whose_str[whose_n++] = more_than_desc_str;
1520 /*** Items whose magical bonus is more than nn ***/
1521 if (IS_FLG(FLG_MORE_BONUS))
1523 static char more_bonus_desc_str[] =
1524 "magical bonus is bigger than (+__)";
1526 sprintf(more_bonus_desc_str + sizeof(more_bonus_desc_str) - 4,
1527 "%d)", entry->bonus);
1528 whose_str[whose_n++] = more_bonus_desc_str;
1531 /*** Wanted monster's corpse/skeletons ***/
1532 if (IS_FLG(FLG_WANTED))
1534 body_str = "corpse or skeletons";
1535 which_str[which_n++] = "is wanted at the Hunter's Office";
1538 /*** Human corpse/skeletons (for Daemon magic) ***/
1539 if (IS_FLG(FLG_HUMAN))
1541 before_str[before_n++] = "humanoid";
1542 body_str = "corpse or skeletons";
1543 which_str[which_n++] = "can be used for Daemon magic";
1546 /*** Unique monster's corpse/skeletons/statues ***/
1547 if (IS_FLG(FLG_UNIQUE))
1549 before_str[before_n++] = "unique monster's";
1550 body_str = "corpse or skeletons";
1553 /*** Unreadable spellbooks ***/
1554 if (IS_FLG(FLG_UNREADABLE))
1556 body_str = "spellbooks";
1557 after_str[after_n++] = "of different realms from yours";
1560 /*** First realm spellbooks ***/
1561 if (IS_FLG(FLG_REALM1))
1563 body_str = "spellbooks";
1564 after_str[after_n++] = "of your first realm";
1567 /*** Second realm spellbooks ***/
1568 if (IS_FLG(FLG_REALM2))
1570 body_str = "spellbooks";
1571 after_str[after_n++] = "of your second realm";
1574 /*** First rank spellbooks ***/
1575 if (IS_FLG(FLG_FIRST))
1577 before_str[before_n++] = "first one of four";
1578 body_str = "spellbooks";
1581 /*** Second rank spellbooks ***/
1582 if (IS_FLG(FLG_SECOND))
1584 before_str[before_n++] = "second one of four";
1585 body_str = "spellbooks";
1588 /*** Third rank spellbooks ***/
1589 if (IS_FLG(FLG_THIRD))
1591 before_str[before_n++] = "third one of four";
1592 body_str = "spellbooks";
1595 /*** Fourth rank spellbooks ***/
1596 if (IS_FLG(FLG_FOURTH))
1598 before_str[before_n++] = "fourth one of four";
1599 body_str = "spellbooks";
1603 if (IS_FLG(FLG_ITEMS))
1604 ; /* Nothing to do */
1605 else if (IS_FLG(FLG_WEAPONS))
1606 body_str = "weapons";
1607 else if (IS_FLG(FLG_ARMORS))
1608 body_str = "armors";
1609 else if (IS_FLG(FLG_MISSILES))
1610 body_str = "shots, arrows or crossbow bolts";
1611 else if (IS_FLG(FLG_DEVICES))
1612 body_str = "scrolls, wands, staves or rods";
1613 else if (IS_FLG(FLG_LIGHTS))
1614 body_str = "light sources";
1615 else if (IS_FLG(FLG_JUNKS))
1616 body_str = "junk such as broken sticks";
1617 else if (IS_FLG(FLG_SPELLBOOKS))
1618 body_str = "spellbooks";
1619 else if (IS_FLG(FLG_HAFTED))
1620 body_str = "hafted weapons";
1621 else if (IS_FLG(FLG_SHIELDS))
1622 body_str = "shields";
1623 else if (IS_FLG(FLG_BOWS))
1624 body_str = "slings, bows or crossbows";
1625 else if (IS_FLG(FLG_RINGS))
1627 else if (IS_FLG(FLG_AMULETS))
1628 body_str = "amulets";
1629 else if (IS_FLG(FLG_SUITS))
1630 body_str = "body armors";
1631 else if (IS_FLG(FLG_CLOAKS))
1632 body_str = "cloaks";
1633 else if (IS_FLG(FLG_HELMS))
1634 body_str = "helms or crowns";
1635 else if (IS_FLG(FLG_GLOVES))
1636 body_str = "gloves";
1637 else if (IS_FLG(FLG_BOOTS))
1640 /* Prepare a string for item name */
1647 whose_str[whose_n++] = "name is beginning with \"";
1650 which_str[which_n++] = "have \"";
1654 /* Describe action flag */
1655 if (act & DONT_AUTOPICK)
1656 strcpy(buff, "Leave on floor ");
1657 else if (act & DO_AUTODESTROY)
1658 strcpy(buff, "Destroy ");
1659 else if (act & DO_QUERY_AUTOPICK)
1660 strcpy(buff, "Ask to pick up ");
1662 strcpy(buff, "Pickup ");
1664 /* Auto-insctiption */
1667 strncat(buff, format("and inscribe \"%s\"", insc), 80);
1669 if (strstr(insc, "%all"))
1670 strcat(buff, ", replacing %all with code string representing all abilities,");
1671 else if (strstr(insc, "%"))
1672 strcat(buff, ", replacing % with code string representing extra random abilities,");
1674 strcat(buff, " on ");
1679 strcat(buff, "all ");
1680 else for (i = 0; i < before_n && before_str[i]; i++)
1682 strcat(buff, before_str[i]);
1687 strcat(buff, body_str);
1690 for (i = 0; i < after_n && after_str[i]; i++)
1693 strcat(buff, after_str[i]);
1697 for (i = 0; i < whose_n && whose_str[i]; i++)
1700 strcat(buff, " whose ");
1702 strcat(buff, ", and ");
1704 strcat(buff, whose_str[i]);
1707 /* Item name ; whose name is beginning with "str" */
1714 /* whose ..., and which .... */
1715 if (whose_n && which_n)
1716 strcat(buff, ", and ");
1719 for (i = 0; i < which_n && which_str[i]; i++)
1722 strcat(buff, " which ");
1724 strcat(buff, ", and ");
1726 strcat(buff, which_str[i]);
1729 /* Item name ; which have "str" as part of its name */
1732 strncat(buff, str, 80);
1733 strcat(buff, "\" as part of its name");
1737 /* Describe whether it will be displayed on the full map or not */
1738 if (act & DO_DISPLAY)
1740 if (act & DONT_AUTOPICK)
1741 strcat(buff, " Display these items when you press the N key in the full 'M'ap.");
1742 else if (act & DO_AUTODESTROY)
1743 strcat(buff, " Display these items when you press the K key in the full 'M'ap.");
1745 strcat(buff, " Display these items when you press the M key in the full 'M'ap.");
1748 strcat(buff, " Not displayed in the full map.");
1754 #define MAX_LINES 3000
1757 * Read whole lines of a file to memory
1759 static cptr *read_text_lines(cptr filename, bool user)
1761 cptr *lines_list = NULL;
1769 /* Hack -- drop permissions */
1771 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, filename);
1775 path_build(buf, sizeof(buf), ANGBAND_DIR_PREF, filename);
1779 fff = my_fopen(buf, "r");
1783 /* Allocate list of pointers */
1784 C_MAKE(lines_list, MAX_LINES, cptr);
1787 while (0 == my_fgets(fff, buf, sizeof(buf)))
1789 lines_list[lines++] = string_make(buf);
1790 if (lines >= MAX_LINES - 1) break;
1793 lines_list[0] = string_make("");
1801 if (!fff) return NULL;
1806 #define PT_DEFAULT 0
1807 #define PT_WITH_PNAME 1
1809 static cptr *read_pickpref_text_lines(int *filename_mode_p)
1815 sprintf(buf, "picktype-%s.prf", player_name);
1817 sprintf(buf, "pickpref-%s.prf", player_name);
1819 lines_list = read_text_lines(buf, TRUE);
1824 lines_list = read_text_lines("picktype.prf", TRUE);
1826 lines_list = read_text_lines("pickpref.prf", TRUE);
1828 *filename_mode_p = PT_DEFAULT;
1834 lines_list = read_text_lines("picktype.prf", FALSE);
1836 lines_list = read_text_lines("pickpref.prf", FALSE);
1838 *filename_mode_p = PT_WITH_PNAME;
1843 /* Allocate list of pointers */
1844 C_MAKE(lines_list, MAX_LINES, cptr);
1845 lines_list[0] = string_make("");
1846 *filename_mode_p = PT_WITH_PNAME;
1852 * Write whole lines of memory to a file.
1854 static bool write_text_lines(cptr filename, cptr *lines_list)
1861 /* Hack -- drop permissions */
1864 /* Build the filename */
1865 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, filename);
1868 fff = my_fopen(buf, "w");
1871 for (lines = 0; lines_list[lines]; lines++)
1872 my_fputs(fff, lines_list[lines], 1024);
1880 if (!fff) return FALSE;
1886 * Free memory of lines_list.
1888 static void free_text_lines(cptr *lines_list)
1892 for (lines = 0; lines_list[lines]; lines++)
1893 string_free(lines_list[lines]);
1895 /* free list of pointers */
1896 C_FREE((char **)lines_list, MAX_LINES, char *);
1901 * Delete or insert string
1903 static void toggle_string(cptr *lines_list, int flg, int y)
1905 autopick_type an_entry, *entry = &an_entry;
1907 if (!autopick_new_entry(entry, lines_list[y]))
1910 string_free(lines_list[y]);
1916 lines_list[y] = autopick_line_from_entry_kill(entry);
1920 * Insert return code and split the line
1922 static bool insert_return_code(cptr *lines_list, int cx, int cy)
1924 char buf[MAX_LINELEN];
1927 for (k = 0; lines_list[k]; k++)
1928 /* count number of lines */ ;
1930 if (k >= MAX_LINES - 2) return FALSE;
1933 /* Move down lines */
1935 lines_list[k+1] = lines_list[k];
1937 /* Split current line */
1938 for (i = j = 0; lines_list[cy][i] && i < cx; i++)
1941 if (iskanji(lines_list[cy][i]))
1942 buf[j++] = lines_list[cy][i++];
1944 buf[j++] = lines_list[cy][i];
1947 lines_list[cy+1] = string_make(&lines_list[cy][i]);
1948 string_free(lines_list[cy]);
1949 lines_list[cy] = string_make(buf);
1955 * Get auto-picker entry from o_ptr.
1957 void autopick_entry_from_object(autopick_type *entry, object_type *o_ptr)
1959 char o_name[MAX_NLEN];
1960 object_desc(o_name, o_ptr, FALSE, 0);
1962 entry->name = string_make(o_name);
1963 entry->insc = string_make(quark_str(o_ptr->inscription));
1964 entry->action = DO_AUTOPICK | DO_DISPLAY;
1965 entry->flag[0] = entry->flag[1] = 0L;
1968 if (!object_aware_p(o_ptr))
1969 ADD_FLG(FLG_UNAWARE);
1970 if (object_value(o_ptr) <= 0)
1971 ADD_FLG(FLG_WORTHLESS);
1973 if (object_known_p(o_ptr))
1977 else if (o_ptr->name1 || o_ptr->art_name)
1978 ADD_FLG(FLG_ARTIFACT);
1984 case TV_HAFTED: case TV_POLEARM: case TV_SWORD: case TV_DIGGING:
1985 k_ptr = &k_info[o_ptr->k_idx];
1986 if ((o_ptr->dd != k_ptr->dd) || (o_ptr->ds != k_ptr->ds))
1987 ADD_FLG(FLG_BOOSTED);
1990 if (o_ptr->tval == TV_CORPSE && object_is_shoukinkubi(o_ptr))
1992 REM_FLG(FLG_WORTHLESS);
1993 ADD_FLG(FLG_WANTED);
1996 if ((o_ptr->tval == TV_CORPSE || o_ptr->tval == TV_STATUE)
1997 && (r_info[o_ptr->pval].flags1 & RF1_UNIQUE))
1999 REM_FLG(FLG_WORTHLESS);
2000 ADD_FLG(FLG_UNIQUE);
2003 if (o_ptr->tval == TV_CORPSE && strchr("pht", r_info[o_ptr->pval].d_char))
2005 REM_FLG(FLG_WORTHLESS);
2009 if (o_ptr->tval >= TV_LIFE_BOOK &&
2010 !check_book_realm(o_ptr->tval, o_ptr->sval))
2011 ADD_FLG(FLG_UNREADABLE);
2013 if (REALM1_BOOK == o_ptr->tval &&
2014 p_ptr->pclass != CLASS_SORCERER &&
2015 p_ptr->pclass != CLASS_RED_MAGE)
2016 ADD_FLG(FLG_REALM1);
2018 if (REALM2_BOOK == o_ptr->tval &&
2019 p_ptr->pclass != CLASS_SORCERER &&
2020 p_ptr->pclass != CLASS_RED_MAGE)
2021 ADD_FLG(FLG_REALM2);
2023 if (o_ptr->tval >= TV_LIFE_BOOK && 0 == o_ptr->sval)
2025 if (o_ptr->tval >= TV_LIFE_BOOK && 1 == o_ptr->sval)
2026 ADD_FLG(FLG_SECOND);
2027 if (o_ptr->tval >= TV_LIFE_BOOK && 2 == o_ptr->sval)
2029 if (o_ptr->tval >= TV_LIFE_BOOK && 3 == o_ptr->sval)
2030 ADD_FLG(FLG_FOURTH);
2032 if (o_ptr->tval == TV_SHOT || o_ptr->tval == TV_BOLT
2033 || o_ptr->tval == TV_ARROW)
2034 ADD_FLG(FLG_MISSILES);
2035 else if (o_ptr->tval == TV_SCROLL || o_ptr->tval == TV_STAFF
2036 || o_ptr->tval == TV_WAND || o_ptr->tval == TV_ROD)
2037 ADD_FLG(FLG_DEVICES);
2038 else if (o_ptr->tval == TV_LITE)
2039 ADD_FLG(FLG_LIGHTS);
2040 else if (o_ptr->tval == TV_SKELETON || o_ptr->tval == TV_BOTTLE
2041 || o_ptr->tval == TV_JUNK || o_ptr->tval == TV_STATUE)
2043 else if (o_ptr->tval >= TV_LIFE_BOOK)
2044 ADD_FLG(FLG_SPELLBOOKS);
2045 else if (o_ptr->tval == TV_HAFTED)
2046 ADD_FLG(FLG_HAFTED);
2047 else if (o_ptr->tval == TV_POLEARM || o_ptr->tval == TV_SWORD
2048 || o_ptr->tval == TV_DIGGING)
2049 ADD_FLG(FLG_WEAPONS);
2050 else if (o_ptr->tval == TV_SHIELD)
2051 ADD_FLG(FLG_SHIELDS);
2052 else if (o_ptr->tval == TV_BOW)
2054 else if (o_ptr->tval == TV_RING)
2056 else if (o_ptr->tval == TV_AMULET)
2057 ADD_FLG(FLG_AMULETS);
2058 else if (o_ptr->tval == TV_DRAG_ARMOR || o_ptr->tval == TV_HARD_ARMOR ||
2059 o_ptr->tval == TV_SOFT_ARMOR)
2061 else if (o_ptr->tval == TV_CLOAK)
2062 ADD_FLG(FLG_CLOAKS);
2063 else if (o_ptr->tval == TV_HELM)
2065 else if (o_ptr->tval == TV_GLOVES)
2066 ADD_FLG(FLG_GLOVES);
2067 else if (o_ptr->tval == TV_BOOTS)
2075 * Choose an item and get auto-picker entry from it.
2077 static object_type *choose_object(cptr q, cptr s)
2081 if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP))) return NULL;
2083 /* Get the item (in the pack) */
2084 if (item >= 0) return &inventory[item];
2086 /* Get the item (on the floor) */
2087 else return &o_list[0 - item];
2092 * Choose an item and get auto-picker entry from it.
2094 static bool entry_from_choosed_object(autopick_type *entry)
2101 q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÅÐÏ¿¤·¤Þ¤¹¤«? ";
2102 s = "¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£";
2104 q = "Entry which item? ";
2105 s = "You have nothing to entry.";
2107 o_ptr = choose_object(q, s);
2108 if (!o_ptr) return FALSE;
2110 autopick_entry_from_object(entry, o_ptr);
2116 * Choose an item or string for search
2118 static bool get_string_for_search(object_type **o_handle, cptr *search_strp)
2122 char buf[MAX_NLEN+20];
2125 int k_flag[MAX_NLEN+20];
2126 char prompt[] = "¸¡º÷(^I:»ý¤Áʪ ^L:Ç˲õ¤µ¤ì¤¿Êª): ";
2128 char prompt[] = "Search key(^I:inven ^L:destroyed): ";
2130 int col = sizeof(prompt) - 1;
2132 if (*search_strp) strcpy(buf, *search_strp);
2135 /* Display prompt */
2138 /* Display the default answer */
2139 Term_erase(col, 0, 255);
2140 Term_putstr(col, 0, -1, TERM_YELLOW, buf);
2149 Term_gotoxy(col + pos, 0);
2151 /* Do not process macros except special keys */
2152 inkey_special = TRUE;
2157 /* Analyze the key */
2166 if (!pos && *o_handle) return TRUE;
2167 string_free(*search_strp);
2168 *search_strp = string_make(buf);
2175 q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò¸¡º÷¤·¤Þ¤¹¤«? ";
2176 s = "¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£";
2178 q = "Entry which item? ";
2179 s = "You have nothing to entry.";
2181 o_ptr = choose_object(q, s);
2182 if (!o_ptr) return FALSE;
2186 string_free(*search_strp);
2187 object_desc(buf, *o_handle, FALSE, 3);
2188 *search_strp = string_make(format("<%s>", buf));
2192 if (!autopick_last_destroyed_object.k_idx) break;
2193 *o_handle = &autopick_last_destroyed_object;
2195 string_free(*search_strp);
2196 object_desc(buf, *o_handle, FALSE, 3);
2197 *search_strp = string_make(format("<%s>", buf));
2206 if (k_flag[pos]) pos--;
2221 if (pos + 1 < MAX_NLEN)
2229 else if (pos < MAX_NLEN && isprint(i))
2236 if (pos < MAX_NLEN && isprint(i)) buf[pos++] = i;
2245 /* Update the entry */
2246 Term_erase(col, 0, 255);
2247 Term_putstr(col, 0, -1, TERM_WHITE, buf);
2255 * Search next line matches for o_ptr
2257 static bool search_for_object(cptr *lines_list, object_type *o_ptr, int *cxp, int *cyp, bool forward)
2260 autopick_type an_entry, *entry = &an_entry;
2261 char o_name[MAX_NLEN];
2263 object_desc(o_name, o_ptr, FALSE, 3);
2265 /* Force to be lower case string */
2266 for (i = 0; o_name[i]; i++)
2269 if (iskanji(o_name[i]))
2273 if (isupper(o_name[i]))
2274 o_name[i] = tolower(o_name[i]);
2283 if (!lines_list[++i]) break;
2290 if (!autopick_new_entry(entry, lines_list[i])) continue;
2292 if (is_autopick_aux(o_ptr, entry, o_name))
2305 * Search next line matches to the string
2307 static bool search_for_string(cptr *lines_list, cptr search_str, int *cxp, int *cyp, bool forward)
2317 if (!lines_list[++i]) break;
2324 pos = strstr_j(lines_list[i], search_str);
2326 pos = strstr(lines_list[i], search_str);
2330 *cxp = (int)(pos - lines_list[i]);
2341 * Initialize auto-picker preference
2343 void init_autopicker(void)
2345 static const char easy_autopick_inscription[] = "(:=g";
2346 autopick_type entry;
2349 /* Clear old entries */
2350 for( i = 0; i < max_autopick; i++)
2351 autopick_free_entry(&autopick_list[i]);
2355 /* There is always one entry "=g" */
2356 autopick_new_entry(&entry, easy_autopick_inscription);
2357 autopick_list[max_autopick++] = entry;
2363 * Process line for auto picker/destroyer.
2365 errr process_pickpref_file_line(char *buf)
2367 autopick_type entry;
2370 if (max_autopick == MAX_AUTOPICK)
2373 /* Nuke illegal char */
2374 for(i = 0; buf[i]; i++)
2377 if (iskanji(buf[i]))
2383 if (isspace(buf[i]) && buf[i] != ' ')
2388 if (!autopick_new_entry(&entry, buf)) return 0;
2390 /* Already has the same entry? */
2391 for(i = 0; i < max_autopick; i++)
2392 if(!strcmp(entry.name, autopick_list[i].name)
2393 && entry.flag[0] == autopick_list[i].flag[0]
2394 && entry.flag[1] == autopick_list[i].flag[1]
2395 && entry.dice == autopick_list[i].dice
2396 && entry.bonus == autopick_list[i].bonus) return 0;
2398 autopick_list[max_autopick++] = entry;
2404 * Get a trigger key and insert ASCII string for the trigger
2406 static bool insert_macro_line(cptr *lines_list, int cy)
2415 /* Do not process macros */
2421 /* Read the pattern */
2427 /* Do not process macros */
2430 /* Do not wait for keys */
2433 /* Attempt to read a key */
2443 /* Convert the trigger */
2444 ascii_to_text(tmp, buf);
2447 if(!tmp[0]) return FALSE;
2449 /* Insert preference string */
2450 insert_return_code(lines_list, 0, cy);
2451 string_free(lines_list[cy]);
2452 lines_list[cy] = string_make(format("P:%s", tmp));
2454 /* Insert blank action preference line */
2455 insert_return_code(lines_list, 0, cy);
2456 string_free(lines_list[cy]);
2457 lines_list[cy] = string_make("A:");
2464 * Get a command key and insert ASCII string for the key
2466 static bool insert_keymap_line(cptr *lines_list, int cy)
2473 if (rogue_like_commands)
2475 mode = KEYMAP_MODE_ROGUE;
2481 mode = KEYMAP_MODE_ORIG;
2494 /* Convert the trigger */
2495 ascii_to_text(tmp, buf);
2498 if(!tmp[0]) return FALSE;
2500 /* Insert preference string */
2501 insert_return_code(lines_list, 0, cy);
2502 string_free(lines_list[cy]);
2503 lines_list[cy] = string_make(format("C:%d:%s", mode, tmp));
2505 /* Insert blank action preference line */
2506 insert_return_code(lines_list, 0, cy);
2507 string_free(lines_list[cy]);
2508 lines_list[cy] = string_make("A:");
2515 * Description of control commands
2520 static cptr ctrl_command_desc[] =
2523 #define LAST_DESTROYED 6
2524 "^P ^N ^B ^F ¾å²¼º¸±¦¤Ë°ÜÆ°",
2525 "^A ^E ¹Ô¤ÎÀèƬ¡¢½ªÃ¼",
2526 "^Q ÆþÎÏ/¥³¥Þ¥ó¥É¥â¡¼¥ÉÀÚ¤êÂؤ¨",
2527 "^R Êѹ¹¤òÁ´¤Æ¼è¤ê¾Ã¤·¤Æ¸µ¤ËÌ᤹",
2528 "------------------------------------",
2529 "^I »ý¤Áʪ/ÁõÈ÷¤«¤éÁªÂò",
2531 "^K ¥«¡¼¥½¥ë¤«¤é½ªÃ¼¤Þ¤Çºï½ü",
2532 "^Y ºï½ü(^K)¤·¤¿¹Ô¤òÁÞÆþ",
2533 "^C ¼ï²¡¢¿¦¶È¤Î¾ò·ï¼°¤òÁÞÆþ",
2534 "------------------------------------",
2535 "^S Êѹ¹ (!Ç˲õ/~ÊüÃÖ/½¦¤¦)",
2536 "^G \"(\" Á´ÂΥޥåפÇɽ¼¨¤·¤Ê¤¤",
2537 "^O \"#\" ¼«Æ°¹ï¤ß",
2538 "------------------------------------",
2539 "^U ̤´ÕÄê/̤ȽÌÀ/´ÕÄê/*´ÕÄê*",
2541 "^X ̵ÌÃ/¥¨¥´/¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È",
2545 #define LAST_DESTROYED 6
2546 "^P ^N ^B ^F Move Cursor",
2547 "^A ^E Beginning and End of Line",
2548 "^Q Toggle Insert/Command mode",
2549 "^R Revert to Original File",
2550 "------------------------------------",
2551 "^I Object in Inventry/Equipment",
2553 "^K Kill Rest of Line",
2554 "^Y Insert killed(^K) text",
2555 "^C Insert conditional expression",
2556 "------------------------------------",
2557 "^S Toggle(!Destroy/~Leave/Pick)",
2558 "^G \"(\" No display in the 'M'ap",
2559 "^O \"#\" Auto-Inscribe",
2560 "------------------------------------",
2561 "^U Toggle 'identified' state",
2563 "^X Toggle nameless/ego/artifact",
2564 "^Z \"collecting\"",
2570 #define MAX_YANK MAX_LINELEN
2571 #define DIRTY_ALL 0x01
2572 #define DIRTY_COMMAND 0x02
2573 #define DIRTY_MODE 0x04
2574 #define DIRTY_SCREEN 0x08
2575 #define DIRTY_NOT_FOUND 0x10
2576 #define DIRTY_NO_SEARCH 0x20
2579 * In-game editor of Object Auto-picker/Destoryer
2581 void do_cmd_edit_autopick(void)
2583 static int cx = 0, cy = 0;
2584 static int upper = 0, left = 0;
2586 object_type *search_o_ptr = NULL;
2587 cptr search_str = NULL;
2588 cptr last_destroyed = NULL;
2589 char last_destroyed_command[WID_DESC+3];
2590 char yank_buf[MAX_YANK];
2592 autopick_type an_entry, *entry = &an_entry;
2593 char buf[MAX_LINELEN];
2595 int filename_mode = PT_WITH_PNAME;
2600 int old_upper = -1, old_left = -1;
2602 int key = -1, old_key;
2603 bool repeated_clearing = FALSE;
2604 bool edit_mode = FALSE;
2606 byte dirty_flags = DIRTY_ALL | DIRTY_COMMAND | DIRTY_MODE;
2607 int dirty_line = -1;
2609 int wid, hgt, old_wid = -1, old_hgt = -1;
2611 static s32b old_autosave_turn = 0L;
2614 if (turn > old_autosave_turn + 100L)
2616 do_cmd_save_game(TRUE);
2617 old_autosave_turn = turn;
2620 /* HACK -- Reset start_time to stop counting playtime while edit */
2623 /* Free old entries */
2626 /* Command Description of the 'Last Destroyed Item' */
2627 if (autopick_last_destroyed_object.k_idx)
2629 autopick_entry_from_object(entry, &autopick_last_destroyed_object);
2630 last_destroyed = autopick_line_from_entry_kill(entry);
2632 my_strcpy(last_destroyed_command, format("^L \"%s\"", last_destroyed), sizeof(last_destroyed_command));
2637 strcpy(last_destroyed_command, "^L ºÇ¸å¤Ë¼«Æ°Ç˲õ¤·¤¿¥¢¥¤¥Æ¥à̾");
2639 strcpy(last_destroyed_command, "^L Last destroyed object");
2642 ctrl_command_desc[LAST_DESTROYED] = last_destroyed_command;
2644 /* Conditional Expression for Class and Race */
2645 sprintf(classrace, "?:[AND [EQU $RACE %s] [EQU $CLASS %s]]",
2647 rp_ptr->E_title, cp_ptr->E_title
2649 rp_ptr->title, cp_ptr->title
2653 /* Clear yank buffer */
2656 /* Read or initialize whole text */
2657 lines_list = read_pickpref_text_lines(&filename_mode);
2659 /* Reset cursor position if needed */
2660 for (i = 0; i < cy; i++)
2669 /* Save the screen */
2672 /* Process requests until done */
2676 Term_get_size(&wid, &hgt);
2679 /* Don't let cursor at second byte of kanji */
2680 for (i = 0; lines_list[cy][i]; i++)
2681 if (iskanji(lines_list[cy][i]))
2692 /* Scroll if necessary */
2693 if (cy < upper || upper + hgt - 4 <= cy)
2694 upper = cy - (hgt-4)/2;
2697 if ((cx < left + 10 && left > 0) || left + wid - WID_DESC - 5 <= cx)
2698 left = cx - (wid - WID_DESC)*2/3;
2702 /* Redraw whole window after resize */
2703 if (old_wid != wid || old_hgt != hgt)
2704 dirty_flags |= DIRTY_SCREEN;
2706 /* Redraw all text after scroll */
2707 else if (old_upper != upper || old_left != left)
2708 dirty_flags |= DIRTY_ALL;
2711 if (dirty_flags & DIRTY_SCREEN)
2713 dirty_flags |= (DIRTY_ALL | DIRTY_COMMAND | DIRTY_MODE);
2719 if (dirty_flags & DIRTY_COMMAND)
2721 /* Display control command */
2722 for (i = 0; ctrl_command_desc[i]; i++)
2723 Term_putstr(wid - WID_DESC, i + 1, WID_DESC, TERM_WHITE, ctrl_command_desc[i]);
2726 /* Redraw mode line */
2727 if (dirty_flags & DIRTY_MODE)
2729 int sepa_length = wid - WID_DESC;
2732 for (i = 0; i < sepa_length; i++)
2738 strncpy(buf + sepa_length - 21, " (INSERT MODE) ", 16);
2740 strncpy(buf + sepa_length - 21, " (COMMAND MODE) ", 16);
2742 Term_putstr(0, hgt - 3, sepa_length, (byte) (edit_mode ? TERM_YELLOW : TERM_WHITE), buf);
2745 /* Dump up to 20, or hgt-4, lines of messages */
2746 for (i = 0; i < hgt - 4; i++)
2751 /* clean or dirty? */
2752 if (!(dirty_flags & DIRTY_ALL) && (dirty_line != upper+i))
2755 msg = lines_list[upper+i];
2758 /* Apply horizontal scroll */
2759 for (j = 0; *msg; msg++, j++)
2761 if (j == left) break;
2777 Term_erase(0, i + 1, wid - WID_DESC);
2779 /* Dump the messages, bottom to top */
2780 Term_putstr(leftcol, i + 1, wid - WID_DESC - 1, TERM_WHITE, msg);
2783 for (; i < hgt - 4; i++)
2786 Term_erase(0, i + 1, wid - WID_DESC);
2789 /* Display header line */
2792 prt("^Q ESC ¤Ç¥³¥Þ¥ó¥É¥â¡¼¥É¤Ø°Ü¹Ô¡¢Ä̾ï¤Îʸ»ú¤Ï¤½¤Î¤Þ¤ÞÆþÎÏ", 0, 0);
2794 prt("q _ ¤Ç½ªÎ»¡¢hjkl2468 ¤Ç°ÜÆ°¡¢^Q a i ¤ÇÆþÎϥ⡼¥É¡¢/ n N ¤Ç¸¡º÷", 0, 0);
2797 prt("Press ^Q ESC to command mode, any letters to insert", 0, 0);
2799 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);
2801 /* Display current position */
2802 prt (format("(%d,%d)", cx, cy), 0, 70);
2804 /* Display information when updated */
2805 if (old_cy != cy || (dirty_flags & (DIRTY_ALL | DIRTY_NOT_FOUND | DIRTY_NO_SEARCH)) || dirty_line == cy)
2807 /* Clear information line */
2808 Term_erase(0, hgt - 3 + 1, wid);
2809 Term_erase(0, hgt - 3 + 2, wid);
2811 /* Display information */
2812 if (dirty_flags & DIRTY_NOT_FOUND)
2815 prt(format("¥Ñ¥¿¡¼¥ó¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó: %s", search_str), hgt - 3 + 1, 0);
2817 prt(format("Pattern not found: %s", search_str), hgt - 3 + 1, 0);
2820 else if (dirty_flags & DIRTY_NO_SEARCH)
2823 prt("¸¡º÷Ãæ¤Î¥Ñ¥¿¡¼¥ó¤¬¤¢¤ê¤Þ¤»¤ó('/'¤Ç¸¡º÷)¡£", hgt - 3 + 1, 0);
2825 prt("No pattern to search. (Press '/' to search.)", hgt - 3 + 1, 0);
2828 else if (lines_list[cy][0] == '#')
2831 prt("¤³¤Î¹Ô¤Ï¥³¥á¥ó¥È¤Ç¤¹¡£", hgt - 3 + 1, 0);
2833 prt("This line is comment.", hgt - 3 + 1, 0);
2836 else if (lines_list[cy][1] == ':')
2838 switch(lines_list[cy][0])
2842 prt("¤³¤Î¹Ô¤Ï¾ò·ïʬ´ô¼°¤Ç¤¹¡£", hgt - 3 + 1, 0);
2844 prt("This line is Conditional Expression.", hgt - 3 + 1, 0);
2849 prt("¤³¤Î¹Ô¤Ï¥Þ¥¯¥í¤Î¼Â¹ÔÆâÍƤòÄêµÁ¤·¤Þ¤¹¡£", hgt - 3 + 1, 0);
2851 prt("This line defines Macro action.", hgt - 3 + 1, 0);
2856 prt("¤³¤Î¹Ô¤Ï¥Þ¥¯¥í¤Î¥È¥ê¥¬¡¼¡¦¥¡¼¤òÄêµÁ¤·¤Þ¤¹¡£", hgt - 3 + 1, 0);
2858 prt("This line defines Macro trigger key.", hgt - 3 + 1, 0);
2863 prt("¤³¤Î¹Ô¤Ï¥¡¼ÇÛÃÖ¤òÄêµÁ¤·¤Þ¤¹¡£", hgt - 3 + 1, 0);
2865 prt("This line defines Keymap.", hgt - 3 + 1, 0);
2871 /* Get description of an autopicker preference line */
2872 else if (autopick_new_entry(entry, lines_list[cy]))
2877 describe_autopick(buf, entry);
2879 roff_to_buf(buf, 81, temp);
2881 for (i = 0; i< 2; i++)
2887 prt(t, hgt - 3 + 1 + i, 0);
2891 autopick_free_entry(entry);
2896 Term_gotoxy(cx - left, cy - upper + 1);
2902 /* Save old key and location */
2910 /* Do not process macros except special keys */
2911 inkey_special = TRUE;
2922 /* Mode line is now dirty */
2923 dirty_flags |= DIRTY_MODE;
2926 /* Insert a character */
2927 else if (!iscntrl(key&0xff))
2931 /* Save preceding string */
2932 for (i = j = 0; lines_list[cy][i] && i < cx; i++)
2933 buf[j++] = lines_list[cy][i];
2935 /* Add a character */
2941 if (j+2 < MAX_LINELEN)
2953 if (j+1 < MAX_LINELEN)
2959 for (; lines_list[cy][i] && j + 1 < MAX_LINELEN; i++)
2960 buf[j++] = lines_list[cy][i];
2963 /* Replace current line with new line */
2964 string_free(lines_list[cy]);
2965 lines_list[cy] = string_make(buf);
2967 /* Move to correct collumn */
2968 len = strlen(lines_list[cy]);
2969 if (len < cx) cx = len;
2978 if (key == 'q' || key == '_') break;
2985 /* Mode line is now dirty */
2986 dirty_flags |= DIRTY_MODE;
2989 if (!autopick_new_entry(entry, lines_list[cy]))
2991 if (old_key != key) repeated_clearing = FALSE;
2994 if (lines_list[cy + 1]) cy++;
2998 string_free(lines_list[cy]);
3002 if (entry->action & DONT_AUTOPICK)
3003 repeated_clearing = TRUE;
3005 repeated_clearing = FALSE;
3008 entry->action &= ~DO_AUTODESTROY;
3009 entry->action &= ~DO_QUERY_AUTOPICK;
3010 if (!repeated_clearing)
3012 entry->action &= ~DO_AUTOPICK;
3013 entry->action |= DONT_AUTOPICK;
3017 entry->action &= ~DONT_AUTOPICK;
3018 entry->action |= DO_AUTOPICK;
3021 lines_list[cy] = autopick_line_from_entry_kill(entry);
3027 if (lines_list[cy + 1]) cy++;
3031 if (!autopick_new_entry(entry, lines_list[cy]))
3033 if (old_key != key) repeated_clearing = FALSE;
3036 if (lines_list[cy + 1]) cy++;
3040 string_free(lines_list[cy]);
3044 if (entry->action & DO_AUTODESTROY)
3045 repeated_clearing = TRUE;
3047 repeated_clearing = FALSE;
3050 entry->action &= ~DONT_AUTOPICK;
3051 entry->action &= ~DO_QUERY_AUTOPICK;
3052 if (!repeated_clearing)
3054 entry->action &= ~DO_AUTOPICK;
3055 entry->action |= DO_AUTODESTROY;
3059 entry->action &= ~DO_AUTODESTROY;
3060 entry->action |= DO_AUTOPICK;
3063 lines_list[cy] = autopick_line_from_entry_kill(entry);
3069 if (lines_list[cy + 1]) cy++;
3073 if (!autopick_new_entry(entry, lines_list[cy]))
3075 if (old_key != key) repeated_clearing = FALSE;
3078 if (lines_list[cy + 1]) cy++;
3082 string_free(lines_list[cy]);
3086 if (entry->action & DO_QUERY_AUTOPICK)
3087 repeated_clearing = TRUE;
3089 repeated_clearing = FALSE;
3092 entry->action &= ~DO_AUTODESTROY;
3093 entry->action &= ~DONT_AUTOPICK;
3094 if (!repeated_clearing)
3096 entry->action &= ~DO_AUTOPICK;
3097 entry->action |= DO_QUERY_AUTOPICK;
3101 entry->action &= ~DO_QUERY_AUTOPICK;
3102 entry->action |= DO_AUTOPICK;
3105 lines_list[cy] = autopick_line_from_entry_kill(entry);
3111 if (lines_list[cy + 1]) cy++;
3115 /* Toggle display on the 'M'ap */
3116 if (!autopick_new_entry(entry, lines_list[cy]))
3118 if (old_key != key) repeated_clearing = FALSE;
3121 if (lines_list[cy + 1]) cy++;
3125 string_free(lines_list[cy]);
3129 if (entry->action & DO_DISPLAY)
3130 repeated_clearing = TRUE;
3132 repeated_clearing = FALSE;
3135 if (!repeated_clearing)
3136 entry->action |= DO_DISPLAY;
3138 entry->action &= ~DO_DISPLAY;
3140 lines_list[cy] = autopick_line_from_entry_kill(entry);
3146 if (lines_list[cy + 1]) cy++;
3166 while (cy < upper + hgt-4 && lines_list[cy + 1])
3171 while (0 < cy && upper <= cy)
3173 while (0 < upper && cy + 1 < upper + hgt - 4)
3182 while (lines_list[cy + 1])
3188 Term_erase(0, cy - upper + 1, wid - WID_DESC);
3192 Term_putstr(0, cy - upper + 1, wid - WID_DESC - 1, TERM_YELLOW, "P:<¥È¥ê¥¬¡¼¥¡¼>: ");
3194 Term_putstr(0, cy - upper + 1, wid - WID_DESC - 1, TERM_YELLOW, "P:<Trigger key>: ");
3196 if (insert_macro_line(lines_list, cy))
3198 /* Prepare to input action */
3203 dirty_flags |= DIRTY_ALL;
3204 dirty_flags |= DIRTY_MODE;
3211 Term_erase(0, cy - upper + 1, wid - WID_DESC);
3215 Term_putstr(0, cy - upper + 1, wid - WID_DESC - 1, TERM_YELLOW, format("C:%d:<¥³¥Þ¥ó¥É¥¡¼>: ", (rogue_like_commands ? KEYMAP_MODE_ROGUE : KEYMAP_MODE_ORIG)));
3217 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)));
3220 if (insert_keymap_line(lines_list, cy))
3222 /* Prepare to input action */
3227 dirty_flags |= DIRTY_ALL;
3228 dirty_flags |= DIRTY_MODE;
3232 /* Become dirty because of item/equip menu */
3233 dirty_flags |= DIRTY_SCREEN;
3235 if (!get_string_for_search(&search_o_ptr, &search_str))
3242 if (!search_for_object(lines_list, search_o_ptr, &cx, &cy, TRUE)) dirty_flags |= DIRTY_NOT_FOUND;
3244 else if (search_str)
3246 if (!search_for_string(lines_list, search_str, &cx, &cy, TRUE)) dirty_flags |= DIRTY_NOT_FOUND;
3250 dirty_flags |= DIRTY_NO_SEARCH;
3256 if (!search_for_object(lines_list, search_o_ptr, &cx, &cy, FALSE)) dirty_flags |= DIRTY_NOT_FOUND;
3258 else if (search_str)
3260 if (!search_for_string(lines_list, search_str, &cx, &cy, FALSE)) dirty_flags |= DIRTY_NOT_FOUND;
3264 dirty_flags |= DIRTY_NO_SEARCH;
3273 /* Beginning of line */
3281 len = strlen(lines_list[cy]);
3282 if (len < cx) cx = len;
3287 cx = strlen(lines_list[cy]);
3291 /* Insert a conditinal expression line */
3292 insert_return_code(lines_list, 0, cy);
3293 string_free(lines_list[cy]);
3294 lines_list[cy] = string_make(classrace);
3296 insert_return_code(lines_list, 0, cy);
3297 string_free(lines_list[cy]);
3298 lines_list[cy] = string_make("?:1");
3302 dirty_flags |= DIRTY_ALL;
3306 cx = strlen(lines_list[cy]);
3311 if (iskanji(lines_list[cy][cx])) cx++;
3314 len = strlen(lines_list[cy]);
3317 if (lines_list[cy + 1])
3327 /* Toggle display on the 'M'ap */
3328 if (!autopick_new_entry(entry, lines_list[cy]))
3330 string_free(lines_list[cy]);
3332 if (entry->action & DO_DISPLAY)
3334 entry->action &= ~DO_DISPLAY;
3339 entry->action |= DO_DISPLAY;
3343 lines_list[cy] = autopick_line_from_entry_kill(entry);
3349 /* Insert choosen item name */
3350 if (!entry_from_choosed_object(entry))
3352 /* Now dirty because of item/equip menu */
3353 dirty_flags |= DIRTY_SCREEN;
3357 insert_return_code(lines_list, 0, cy);
3358 string_free(lines_list[cy]);
3359 lines_list[cy] = autopick_line_from_entry_kill(entry);
3362 /* Now dirty because of item/equip menu */
3363 dirty_flags |= DIRTY_SCREEN;
3367 /* Insert a name of last destroyed item */
3370 insert_return_code(lines_list, 0, cy);
3371 string_free(lines_list[cy]);
3372 lines_list[cy] = string_make(last_destroyed);
3376 dirty_flags |= DIRTY_ALL;
3379 case '\n': case '\r':
3380 /* Split a line or insert end of line */
3381 insert_return_code(lines_list, cx, cy);
3386 dirty_flags |= DIRTY_ALL;
3390 if (lines_list[cy + 1]) cy++;
3393 /* Prepare to write auto-inscription text */
3394 if (!autopick_new_entry(entry, lines_list[cy]))
3396 string_free(lines_list[cy]);
3398 if (!entry->insc) entry->insc = string_make("");
3400 lines_list[cy] = autopick_line_from_entry_kill(entry);
3402 /* Move to collumn for auto inscription */
3403 for (cx = 0; lines_list[cy][cx]; cx++)
3404 if (lines_list[cy][cx] == '#') break;
3410 dirty_flags |= DIRTY_MODE;
3418 edit_mode = !edit_mode;
3420 /* Mode line is now dirty */
3421 dirty_flags |= DIRTY_MODE;
3424 /* Revert to original */
3426 if (!get_check("Á´¤Æ¤ÎÊѹ¹¤òÇË´þ¤·¤Æ¸µ¤Î¾õÂÖ¤ËÌᤷ¤Þ¤¹¡£¤è¤í¤·¤¤¤Ç¤¹¤«¡© "))
3428 if (!get_check("Discard all change and revert to original file. Are you sure? "))
3432 free_text_lines(lines_list);
3433 lines_list = read_pickpref_text_lines(&filename_mode);
3434 dirty_flags |= DIRTY_ALL | DIRTY_MODE;
3439 /* Rotate action; pickup/destroy/leave */
3440 if (!autopick_new_entry(entry, lines_list[cy]))
3442 string_free(lines_list[cy]);
3444 if (entry->action & DO_AUTOPICK)
3446 entry->action &= ~DO_AUTOPICK;
3447 entry->action |= DO_AUTODESTROY;
3449 else if (entry->action & DO_AUTODESTROY)
3451 entry->action &= ~DO_AUTODESTROY;
3452 entry->action |= DONT_AUTOPICK;
3454 else if (entry->action & DONT_AUTOPICK)
3456 entry->action &= ~DONT_AUTOPICK;
3457 entry->action |= DO_AUTOPICK;
3460 lines_list[cy] = autopick_line_from_entry_kill(entry);
3470 /* Rotate identify-state; identified/unidentified/... */
3471 if (!autopick_new_entry(entry, lines_list[cy]))
3473 string_free(lines_list[cy]);
3475 if (IS_FLG(FLG_UNIDENTIFIED))
3477 REM_FLG(FLG_UNIDENTIFIED);
3478 ADD_FLG(FLG_UNAWARE);
3479 REM_FLG(FLG_IDENTIFIED);
3480 REM_FLG(FLG_STAR_IDENTIFIED);
3482 else if (IS_FLG(FLG_UNAWARE))
3484 REM_FLG(FLG_UNIDENTIFIED);
3485 REM_FLG(FLG_UNAWARE);
3486 ADD_FLG(FLG_IDENTIFIED);
3487 REM_FLG(FLG_STAR_IDENTIFIED);
3489 else if (IS_FLG(FLG_STAR_IDENTIFIED))
3491 REM_FLG(FLG_UNIDENTIFIED);
3492 REM_FLG(FLG_UNAWARE);
3493 REM_FLG(FLG_IDENTIFIED);
3494 REM_FLG(FLG_STAR_IDENTIFIED);
3496 else if (IS_FLG(FLG_IDENTIFIED))
3498 REM_FLG(FLG_UNIDENTIFIED);
3499 REM_FLG(FLG_UNAWARE);
3500 REM_FLG(FLG_IDENTIFIED);
3501 ADD_FLG(FLG_STAR_IDENTIFIED);
3505 ADD_FLG(FLG_UNIDENTIFIED);
3506 REM_FLG(FLG_UNAWARE);
3507 REM_FLG(FLG_IDENTIFIED);
3508 REM_FLG(FLG_STAR_IDENTIFIED);
3511 lines_list[cy] = autopick_line_from_entry_kill(entry);
3518 while (cy < upper + hgt-4 && lines_list[cy + 1])
3523 /* Toggle 'worthless' */
3524 toggle_string(lines_list, FLG_WORTHLESS, cy);
3529 /* Rotate within nameless, ego, artifact */
3530 if (!autopick_new_entry(entry, lines_list[cy]))
3532 string_free(lines_list[cy]);
3534 if (IS_FLG(FLG_NAMELESS))
3536 REM_FLG(FLG_NAMELESS);
3538 REM_FLG(FLG_ARTIFACT);
3540 else if (IS_FLG(FLG_EGO))
3542 REM_FLG(FLG_NAMELESS);
3544 ADD_FLG(FLG_ARTIFACT);
3546 else if (IS_FLG(FLG_ARTIFACT))
3548 REM_FLG(FLG_NAMELESS);
3550 REM_FLG(FLG_ARTIFACT);
3554 ADD_FLG(FLG_NAMELESS);
3556 REM_FLG(FLG_ARTIFACT);
3559 lines_list[cy] = autopick_line_from_entry_kill(entry);
3566 /* Paste killed text */
3567 if (strlen(yank_buf))
3571 for (j = 0; yank_buf[j]; j += strlen(yank_buf + j) + 1)
3573 if (ret && '\n' == yank_buf[j])
3579 /* Split current line */
3580 insert_return_code(lines_list, cx, cy);
3582 /* Save preceding string */
3583 for(i = 0; lines_list[cy][i]; i++)
3584 buf[i] = lines_list[cy][i];
3586 /* Paste yank buffer */
3587 if ('\n' != yank_buf[j])
3590 while (yank_buf[k] && i < MAX_LINELEN-1)
3591 buf[i++] = yank_buf[k++];
3597 string_free(lines_list[cy]);
3598 lines_list[cy] = string_make(buf);
3600 /* Move to the beggining of next line */
3606 dirty_flags |= DIRTY_ALL;
3610 /* Toggle 'collecting' */
3611 toggle_string(lines_list, FLG_COLLECTING, cy);
3617 /* Kill rest of line */
3618 if ((uint)cx > strlen(lines_list[cy]))
3619 cx = (int)strlen(lines_list[cy]);
3621 /* Save preceding string */
3622 for (i = 0; lines_list[cy][i] && i < cx; i++)
3625 if (iskanji(lines_list[cy][i]))
3627 buf[i] = lines_list[cy][i];
3631 buf[i] = lines_list[cy][i];
3638 j += strlen(yank_buf + j) + 1;
3640 /* Copy following to yank buffer */
3641 if (lines_list[cy][i])
3643 while (lines_list[cy][i] && j < MAX_YANK - 2)
3644 yank_buf[j++] = lines_list[cy][i++];
3649 if (j < MAX_YANK - 2)
3650 yank_buf[j++] = '\n';
3653 yank_buf[j++] = '\0';
3656 /* Replace current line with 'preceding string' */
3657 string_free(lines_list[cy]);
3658 lines_list[cy] = string_make(buf);
3670 /* DELETE == go forward + BACK SPACE */
3672 if (iskanji(lines_list[cy][cx])) cx++;
3680 len = strlen(lines_list[cy]);
3683 if (lines_list[cy + 1])
3697 /* delete a return code and union two lines */
3699 cx = strlen(lines_list[cy-1]);
3700 strcpy(buf, lines_list[cy-1]);
3701 strcat(buf, lines_list[cy]);
3702 string_free(lines_list[cy-1]);
3703 string_free(lines_list[cy]);
3704 lines_list[cy-1] = string_make(buf);
3705 for (i = cy; lines_list[i+1]; i++)
3706 lines_list[i] = lines_list[i+1];
3707 lines_list[i] = NULL;
3711 dirty_flags |= DIRTY_ALL;
3715 for (i = j = k = 0; lines_list[cy][i] && i < cx; i++)
3719 if (iskanji(lines_list[cy][i]))
3720 buf[j++] = lines_list[cy][i++];
3722 buf[j++] = lines_list[cy][i];
3729 for (; lines_list[cy][i]; i++)
3730 buf[j++] = lines_list[cy][i];
3732 string_free(lines_list[cy]);
3733 lines_list[cy] = string_make(buf);
3742 /* Restore the screen */
3745 switch (filename_mode)
3749 strcpy(buf, "picktype.prf");
3751 strcpy(buf, "pickpref.prf");
3757 sprintf(buf, "picktype-%s.prf", player_name);
3759 sprintf(buf, "pickpref-%s.prf", player_name);
3764 write_text_lines(buf, lines_list);
3765 free_text_lines(lines_list);
3767 string_free(last_destroyed);
3769 /* Reload autopick pref */
3770 process_pickpref_file(buf);
3772 /* HACK -- reset start_time so that playtime is not increase while edit */
3773 start_time = time(NULL);