X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;ds=sidebyside;f=src%2Fautopick.c;h=a6f2e0a2effc8ded5aec60f10f06bf416731b1ba;hb=c132fb792f36026bf2e65d02176da2090de3928a;hp=f3c7e852a76b24d72fbc19821763ffbc11803cd6;hpb=690aba79b62dabb4d5b9f5159bbf8efdad99fdfb;p=hengband%2Fhengband.git diff --git a/src/autopick.c b/src/autopick.c index f3c7e852a..a6f2e0a2e 100644 --- a/src/autopick.c +++ b/src/autopick.c @@ -18,156 +18,161 @@ /* * Macros for Keywords */ -#define FLG_ALL 0 -#define FLG_COLLECTING 1 -#define FLG_UNAWARE 2 -#define FLG_UNIDENTIFIED 3 -#define FLG_IDENTIFIED 4 -#define FLG_STAR_IDENTIFIED 5 -#define FLG_BOOSTED 6 -#define FLG_MORE_DICE 7 -#define FLG_MORE_BONUS 10 -#define FLG_WORTHLESS 11 -#define FLG_ARTIFACT 12 -#define FLG_EGO 13 -#define FLG_NAMELESS 14 -#define FLG_WANTED 15 -#define FLG_UNIQUE 16 -#define FLG_HUMAN 17 -#define FLG_UNREADABLE 18 -#define FLG_REALM1 19 -#define FLG_REALM2 20 -#define FLG_FIRST 21 -#define FLG_SECOND 22 -#define FLG_THIRD 23 -#define FLG_FOURTH 24 - -#define FLG_ITEMS 30 -#define FLG_WEAPONS 31 -#define FLG_ARMORS 32 -#define FLG_MISSILES 33 -#define FLG_DEVICES 34 -#define FLG_LIGHTS 35 -#define FLG_JUNKS 36 -#define FLG_SPELLBOOKS 37 -#define FLG_HAFTED 38 -#define FLG_SHIELDS 39 -#define FLG_BOWS 40 -#define FLG_RINGS 41 -#define FLG_AMULETS 42 -#define FLG_SUITS 43 -#define FLG_CLOAKS 44 -#define FLG_HELMS 45 -#define FLG_GLOVES 46 -#define FLG_BOOTS 47 -#define FLG_FAVORITE 48 +#define FLG_ALL 0 +#define FLG_UNAWARE 1 +#define FLG_UNIDENTIFIED 2 +#define FLG_IDENTIFIED 3 +#define FLG_STAR_IDENTIFIED 4 +#define FLG_COLLECTING 5 +#define FLG_ARTIFACT 6 +#define FLG_EGO 7 +#define FLG_GOOD 10 +#define FLG_NAMELESS 11 +#define FLG_AVERAGE 12 +#define FLG_WORTHLESS 13 +#define FLG_RARE 14 +#define FLG_COMMON 15 +#define FLG_BOOSTED 16 +#define FLG_MORE_DICE 17 +#define FLG_MORE_BONUS 18 +#define FLG_WANTED 19 +#define FLG_UNIQUE 20 +#define FLG_HUMAN 21 +#define FLG_UNREADABLE 22 +#define FLG_REALM1 23 +#define FLG_REALM2 24 +#define FLG_FIRST 25 +#define FLG_SECOND 26 +#define FLG_THIRD 27 +#define FLG_FOURTH 28 + +#define FLG_ITEMS 30 +#define FLG_WEAPONS 31 +#define FLG_FAVORITE_WEAPONS 32 +#define FLG_ARMORS 33 +#define FLG_MISSILES 34 +#define FLG_DEVICES 35 +#define FLG_LIGHTS 36 +#define FLG_JUNKS 37 +#define FLG_CORPSES 38 +#define FLG_SPELLBOOKS 39 +#define FLG_HAFTED 40 +#define FLG_SHIELDS 41 +#define FLG_BOWS 42 +#define FLG_RINGS 43 +#define FLG_AMULETS 44 +#define FLG_SUITS 45 +#define FLG_CLOAKS 46 +#define FLG_HELMS 47 +#define FLG_GLOVES 48 +#define FLG_BOOTS 49 #define FLG_NOUN_BEGIN FLG_ITEMS -#define FLG_NOUN_END FLG_FAVORITE +#define FLG_NOUN_END FLG_BOOTS #ifdef JP -#define KEY_ALL "¤¹¤Ù¤Æ¤Î" - -#ifdef MAC_MPW -/* - * MEGA HACK -- MPW¤Î¥Ð¥°½ü¤±¡£ - * pre-processÃæ¤Ë¡Ö¼ý¡×¤Î»ú¤Î2¥Ð¥¤¥ÈÌܤ¬¾¡¼ê¤Ë¾Ã¤¨¤Æ¤·¤Þ¤¦¡£ - */ -#define KEY_COLLECTING "\x8e\xfb½¸Ãæ¤Î" -#else -#define KEY_COLLECTING "¼ý½¸Ãæ¤Î" -#endif - -#define KEY_UNIDENTIFIED "̤´ÕÄê¤Î" -#define KEY_IDENTIFIED "´ÕÄêºÑ¤ß¤Î" -#define KEY_STAR_IDENTIFIED "*´ÕÄê*ºÑ¤ß¤Î" -#define KEY_BOOSTED "¥À¥¤¥¹Ìܤΰ㤦" -#define KEY_MORE_THAN "¥À¥¤¥¹ÌÜ" -#define KEY_DICE "°Ê¾å¤Î" -#define KEY_MORE_BONUS "½¤ÀµÃÍ" -#define KEY_MORE_BONUS2 "°Ê¾å¤Î" -#define KEY_WORTHLESS "̵²ÁÃͤÎ" -#define KEY_ARTIFACT "¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È" -#define KEY_EGO "¥¨¥´" -#define KEY_NAMELESS "̵ÌäÎ" -#define KEY_UNAWARE "̤ȽÌÀ¤Î" -#define KEY_WANTED "¾Þ¶â¼ó¤Î" -#define KEY_UNIQUE "¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¤Î" -#define KEY_HUMAN "¿Í´Ö¤Î" -#define KEY_UNREADABLE "Æɤá¤Ê¤¤" -#define KEY_REALM1 "Âè°ìÎΰè¤Î" -#define KEY_REALM2 "ÂèÆóÎΰè¤Î" -#define KEY_FIRST "1ºýÌܤÎ" -#define KEY_SECOND "2ºýÌܤÎ" -#define KEY_THIRD "3ºýÌܤÎ" -#define KEY_FOURTH "4ºýÌܤÎ" -#define KEY_ITEMS "¥¢¥¤¥Æ¥à" -#define KEY_WEAPONS "Éð´ï" -#define KEY_ARMORS "Ëɶñ" -#define KEY_MISSILES "Ìð" -#define KEY_DEVICES "ËâË¡¥¢¥¤¥Æ¥à" -#define KEY_LIGHTS "¸÷¸»" -#define KEY_JUNKS "¤¬¤é¤¯¤¿" -#define KEY_SPELLBOOKS "ËâË¡½ñ" -#define KEY_HAFTED "Æß´ï" -#define KEY_SHIELDS "½â" -#define KEY_BOWS "µÝ" -#define KEY_RINGS "»ØÎØ" -#define KEY_AMULETS "¥¢¥ß¥å¥ì¥Ã¥È" -#define KEY_SUITS "³»" -#define KEY_CLOAKS "¥¯¥í¡¼¥¯" -#define KEY_HELMS "³õ" -#define KEY_GLOVES "äƼê" -#define KEY_BOOTS "·¤" -#define KEY_FAVORITE "ÆÀ°ÕÉð´ï" +static char KEY_ALL[] = "¤¹¤Ù¤Æ¤Î"; +static char KEY_UNAWARE[] = "̤ȽÌÀ¤Î"; +static char KEY_UNIDENTIFIED[] = "̤´ÕÄê¤Î"; +static char KEY_IDENTIFIED[] = "´ÕÄêºÑ¤ß¤Î"; +static char KEY_STAR_IDENTIFIED[] = "*´ÕÄê*ºÑ¤ß¤Î"; +static char KEY_COLLECTING[] = "¼ý½¸Ãæ¤Î"; +static char KEY_ARTIFACT[] = "¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È"; +static char KEY_EGO[] = "¥¨¥´"; +static char KEY_GOOD[] = "¾å¼Á¤Î"; +static char KEY_NAMELESS[] = "̵ÌäÎ"; +static char KEY_AVERAGE[] = "ʤÎ"; +static char KEY_WORTHLESS[] = "̵²ÁÃͤÎ"; +static char KEY_RARE[] = "¥ì¥¢¤Ê"; +static char KEY_COMMON[] = "¤¢¤ê¤Õ¤ì¤¿"; +static char KEY_BOOSTED[] = "¥À¥¤¥¹Ìܤΰ㤦"; +static char KEY_MORE_THAN[] = "¥À¥¤¥¹ÌÜ"; +static char KEY_DICE[] = "°Ê¾å¤Î"; +static char KEY_MORE_BONUS[] = "½¤ÀµÃÍ"; +static char KEY_MORE_BONUS2[] = "°Ê¾å¤Î"; +static char KEY_WANTED[] = "¾Þ¶â¼ó¤Î"; +static char KEY_UNIQUE[] = "¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¤Î"; +static char KEY_HUMAN[] = "¿Í´Ö¤Î"; +static char KEY_UNREADABLE[] = "Æɤá¤Ê¤¤"; +static char KEY_REALM1[] = "Âè°ìÎΰè¤Î"; +static char KEY_REALM2[] = "ÂèÆóÎΰè¤Î"; +static char KEY_FIRST[] = "1ºýÌܤÎ"; +static char KEY_SECOND[] = "2ºýÌܤÎ"; +static char KEY_THIRD[] = "3ºýÌܤÎ"; +static char KEY_FOURTH[] = "4ºýÌܤÎ"; +static char KEY_ITEMS[] = "¥¢¥¤¥Æ¥à"; +static char KEY_WEAPONS[] = "Éð´ï"; +static char KEY_FAVORITE_WEAPONS[] = "ÆÀ°ÕÉð´ï"; +static char KEY_ARMORS[] = "Ëɶñ"; +static char KEY_MISSILES[] = "Ìð"; +static char KEY_DEVICES[] = "ËâË¡¥¢¥¤¥Æ¥à"; +static char KEY_LIGHTS[] = "¸÷¸»"; +static char KEY_JUNKS[] = "¤¬¤é¤¯¤¿"; +static char KEY_CORPSES[] = "»àÂΤä¹ü"; +static char KEY_SPELLBOOKS[] = "ËâË¡½ñ"; +static char KEY_HAFTED[] = "Æß´ï"; +static char KEY_SHIELDS[] = "½â"; +static char KEY_BOWS[] = "µÝ"; +static char KEY_RINGS[] = "»ØÎØ"; +static char KEY_AMULETS[] = "¥¢¥ß¥å¥ì¥Ã¥È"; +static char KEY_SUITS[] = "³»"; +static char KEY_CLOAKS[] = "¥¯¥í¡¼¥¯"; +static char KEY_HELMS[] = "³õ"; +static char KEY_GLOVES[] = "äƼê"; +static char KEY_BOOTS[] = "·¤"; #else -#define KEY_ALL "all" -#define KEY_COLLECTING "collecting" -#define KEY_UNIDENTIFIED "unidentified" -#define KEY_IDENTIFIED "identified" -#define KEY_STAR_IDENTIFIED "*identified*" -#define KEY_BOOSTED "dice boosted" -#define KEY_MORE_THAN "more than" -#define KEY_DICE " dice" -#define KEY_MORE_BONUS "more bonus than" -#define KEY_MORE_BONUS2 "" -#define KEY_WORTHLESS "worthless" -#define KEY_ARTIFACT "artifact" -#define KEY_EGO "ego" -#define KEY_NAMELESS "nameless" -#define KEY_UNAWARE "unaware" -#define KEY_WANTED "wanted" -#define KEY_UNIQUE "unique monster's" -#define KEY_HUMAN "human" -#define KEY_UNREADABLE "unreadable" -#define KEY_REALM1 "first realm's" -#define KEY_REALM2 "second realm's" -#define KEY_FIRST "first" -#define KEY_SECOND "second" -#define KEY_THIRD "third" -#define KEY_FOURTH "fourth" -#define KEY_ITEMS "items" -#define KEY_WEAPONS "weapons" -#define KEY_ARMORS "armors" -#define KEY_MISSILES "missiles" -#define KEY_DEVICES "magical devices" -#define KEY_LIGHTS "lights" -#define KEY_JUNKS "junks" -#define KEY_SPELLBOOKS "spellbooks" -#define KEY_HAFTED "hafted weapons" -#define KEY_SHIELDS "shields" -#define KEY_BOWS "bows" -#define KEY_RINGS "rings" -#define KEY_AMULETS "amulets" -#define KEY_SUITS "suits" -#define KEY_CLOAKS "cloaks" -#define KEY_HELMS "helms" -#define KEY_GLOVES "gloves" -#define KEY_BOOTS "boots" -#define KEY_FAVORITE "favorite weapons" +static char KEY_ALL[] = "all"; +static char KEY_UNAWARE[] = "unaware"; +static char KEY_UNIDENTIFIED[] = "unidentified"; +static char KEY_IDENTIFIED[] = "identified"; +static char KEY_STAR_IDENTIFIED[] = "*identified*"; +static char KEY_COLLECTING[] = "collecting"; +static char KEY_ARTIFACT[] = "artifact"; +static char KEY_EGO[] = "ego"; +static char KEY_GOOD[] = "good"; +static char KEY_NAMELESS[] = "nameless"; +static char KEY_AVERAGE[] = "average"; +static char KEY_WORTHLESS[] = "worthless"; +static char KEY_RARE[] = "rare"; +static char KEY_COMMON[] = "common"; +static char KEY_BOOSTED[] = "dice boosted"; +static char KEY_MORE_THAN[] = "more than"; +static char KEY_DICE[] = " dice"; +static char KEY_MORE_BONUS[] = "more bonus than"; +static char KEY_MORE_BONUS2[] = ""; +static char KEY_WANTED[] = "wanted"; +static char KEY_UNIQUE[] = "unique monster's"; +static char KEY_HUMAN[] = "human"; +static char KEY_UNREADABLE[] = "unreadable"; +static char KEY_REALM1[] = "first realm's"; +static char KEY_REALM2[] = "second realm's"; +static char KEY_FIRST[] = "first"; +static char KEY_SECOND[] = "second"; +static char KEY_THIRD[] = "third"; +static char KEY_FOURTH[] = "fourth"; +static char KEY_ITEMS[] = "items"; +static char KEY_WEAPONS[] = "weapons"; +static char KEY_FAVORITE_WEAPONS[] = "favorite weapons"; +static char KEY_ARMORS[] = "armors"; +static char KEY_MISSILES[] = "missiles"; +static char KEY_DEVICES[] = "magical devices"; +static char KEY_LIGHTS[] = "lights"; +static char KEY_JUNKS[] = "junks"; +static char KEY_CORPSES[] = "corpses or skeletons"; +static char KEY_SPELLBOOKS[] = "spellbooks"; +static char KEY_HAFTED[] = "hafted weapons"; +static char KEY_SHIELDS[] = "shields"; +static char KEY_BOWS[] = "bows"; +static char KEY_RINGS[] = "rings"; +static char KEY_AMULETS[] = "amulets"; +static char KEY_SUITS[] = "suits"; +static char KEY_CLOAKS[] = "cloaks"; +static char KEY_HELMS[] = "helms"; +static char KEY_GLOVES[] = "gloves"; +static char KEY_BOOTS[] = "boots"; #endif /* JP */ @@ -288,6 +293,7 @@ static bool autopick_new_entry(autopick_type *entry, cptr str, bool allow_defaul if (MATCH_KEY(KEY_ALL)) ADD_FLG(FLG_ALL); if (MATCH_KEY(KEY_COLLECTING)) ADD_FLG(FLG_COLLECTING); + if (MATCH_KEY(KEY_UNAWARE)) ADD_FLG(FLG_UNAWARE); if (MATCH_KEY(KEY_UNIDENTIFIED)) ADD_FLG(FLG_UNIDENTIFIED); if (MATCH_KEY(KEY_IDENTIFIED)) ADD_FLG(FLG_IDENTIFIED); if (MATCH_KEY(KEY_STAR_IDENTIFIED)) ADD_FLG(FLG_STAR_IDENTIFIED); @@ -338,7 +344,11 @@ static bool autopick_new_entry(autopick_type *entry, cptr str, bool allow_defaul if (k > 0 && k <= 2) { +#ifdef JP (void)MATCH_KEY(KEY_MORE_BONUS2); +#else + if (' ' == *ptr) ptr++; +#endif ADD_FLG(FLG_MORE_BONUS); } else @@ -347,8 +357,11 @@ static bool autopick_new_entry(autopick_type *entry, cptr str, bool allow_defaul if (MATCH_KEY(KEY_WORTHLESS)) ADD_FLG(FLG_WORTHLESS); if (MATCH_KEY(KEY_EGO)) ADD_FLG(FLG_EGO); + if (MATCH_KEY(KEY_GOOD)) ADD_FLG(FLG_GOOD); if (MATCH_KEY(KEY_NAMELESS)) ADD_FLG(FLG_NAMELESS); - if (MATCH_KEY(KEY_UNAWARE)) ADD_FLG(FLG_UNAWARE); + if (MATCH_KEY(KEY_AVERAGE)) ADD_FLG(FLG_AVERAGE); + if (MATCH_KEY(KEY_RARE)) ADD_FLG(FLG_RARE); + if (MATCH_KEY(KEY_COMMON)) ADD_FLG(FLG_COMMON); if (MATCH_KEY(KEY_WANTED)) ADD_FLG(FLG_WANTED); if (MATCH_KEY(KEY_UNIQUE)) ADD_FLG(FLG_UNIQUE); if (MATCH_KEY(KEY_HUMAN)) ADD_FLG(FLG_HUMAN); @@ -368,11 +381,13 @@ static bool autopick_new_entry(autopick_type *entry, cptr str, bool allow_defaul if (MATCH_KEY2(KEY_ITEMS)) ADD_FLG_NOUN(FLG_ITEMS); else if (MATCH_KEY2(KEY_WEAPONS)) ADD_FLG_NOUN(FLG_WEAPONS); + else if (MATCH_KEY2(KEY_FAVORITE_WEAPONS)) ADD_FLG_NOUN(FLG_FAVORITE_WEAPONS); else if (MATCH_KEY2(KEY_ARMORS)) ADD_FLG_NOUN(FLG_ARMORS); else if (MATCH_KEY2(KEY_MISSILES)) ADD_FLG_NOUN(FLG_MISSILES); else if (MATCH_KEY2(KEY_DEVICES)) ADD_FLG_NOUN(FLG_DEVICES); else if (MATCH_KEY2(KEY_LIGHTS)) ADD_FLG_NOUN(FLG_LIGHTS); else if (MATCH_KEY2(KEY_JUNKS)) ADD_FLG_NOUN(FLG_JUNKS); + else if (MATCH_KEY2(KEY_CORPSES)) ADD_FLG_NOUN(FLG_CORPSES); else if (MATCH_KEY2(KEY_SPELLBOOKS)) ADD_FLG_NOUN(FLG_SPELLBOOKS); else if (MATCH_KEY2(KEY_HAFTED)) ADD_FLG_NOUN(FLG_HAFTED); else if (MATCH_KEY2(KEY_SHIELDS)) ADD_FLG_NOUN(FLG_SHIELDS); @@ -384,7 +399,6 @@ static bool autopick_new_entry(autopick_type *entry, cptr str, bool allow_defaul else if (MATCH_KEY2(KEY_HELMS)) ADD_FLG_NOUN(FLG_HELMS); else if (MATCH_KEY2(KEY_GLOVES)) ADD_FLG_NOUN(FLG_GLOVES); else if (MATCH_KEY2(KEY_BOOTS)) ADD_FLG_NOUN(FLG_BOOTS); - else if (MATCH_KEY2(KEY_FAVORITE)) ADD_FLG_NOUN(FLG_FAVORITE); /* Last 'keyword' must be at the correct location */ if (*ptr == ':') @@ -422,84 +436,6 @@ static bool autopick_new_entry(autopick_type *entry, cptr str, bool allow_defaul /* - * Favorite weapons - */ -static bool is_favorite(object_type *o_ptr) -{ - /* Only weapons match */ - if (!(TV_WEAPON_BEGIN <= o_ptr->tval && o_ptr->tval <= TV_WEAPON_END)) - return FALSE; - - /* Favorite weapons are varied depend on the class */ - switch (p_ptr->pclass) - { - case CLASS_PRIEST: - { - u32b flgs[TR_FLAG_SIZE]; - object_flags_known(o_ptr, flgs); - - if (!have_flag(flgs, TR_BLESSED) && - !(o_ptr->tval == TV_HAFTED)) - return FALSE; - break; - } - - case CLASS_MONK: - case CLASS_FORCETRAINER: - /* Icky to wield? */ - if (!(s_info[p_ptr->pclass].w_max[o_ptr->tval-TV_WEAPON_BEGIN][o_ptr->sval])) - return FALSE; - break; - - case CLASS_BEASTMASTER: - case CLASS_CAVALRY: - { - u32b flgs[TR_FLAG_SIZE]; - object_flags_known(o_ptr, flgs); - - /* Is it known to be suitable to using while riding? */ - if (!(have_flag(flgs, TR_RIDING))) - return FALSE; - - break; - } - - case CLASS_NINJA: - /* Icky to wield? */ - if (s_info[p_ptr->pclass].w_max[o_ptr->tval-TV_WEAPON_BEGIN][o_ptr->sval] <= WEAPON_EXP_BEGINNER) - return FALSE; - break; - - default: - /* All weapons are okay for non-special classes */ - return TRUE; - } - - return TRUE; -} - - -/* - * Convert string to lower case - */ -static void str_tolower(char *str) -{ - /* Force to be lower case string */ - for (; *str; str++) - { -#ifdef JP - if (iskanji(*str)) - { - str++; - continue; - } -#endif - *str = tolower(*str); - } -} - - -/* * Get auto-picker entry from o_ptr. */ static void autopick_entry_from_object(autopick_type *entry, object_type *o_ptr) @@ -508,8 +444,10 @@ static void autopick_entry_from_object(autopick_type *entry, object_type *o_ptr) bool name = TRUE; #ifdef JP + /* ¥¨¥´Ì䬼ÙË⤫¤â¤·¤ì¤Ê¤¤¤Î¤Ç¡¢¥Ç¥Õ¥©¥ë¥È¤Ç¡Ö^¡×¤ÏÉÕ¤±¤Ê¤¤ */ bool bol_mark = FALSE; #else + /* We can always use the ^ mark in English */ bool bol_mark = TRUE; #endif @@ -524,14 +462,14 @@ static void autopick_entry_from_object(autopick_type *entry, object_type *o_ptr) entry->dice = 0; /* Unaware */ - if (!object_aware_p(o_ptr)) + if (!object_is_aware(o_ptr)) { ADD_FLG(FLG_UNAWARE); bol_mark = TRUE; } /* Not really identified */ - else if (!object_known_p(o_ptr)) + else if (!object_is_known(o_ptr)) { if (!(o_ptr->ident & IDENT_SENSE)) { @@ -581,11 +519,10 @@ static void autopick_entry_from_object(autopick_type *entry, object_type *o_ptr) else { /* Ego objects */ - if (o_ptr->name2) + if (object_is_ego(o_ptr)) { - if (TV_WEAPON_BEGIN <= o_ptr->tval && - o_ptr->tval <= TV_ARMOR_END) + if (object_is_weapon_armour_ammo(o_ptr)) { /* * Base name of ego weapons and armors @@ -593,42 +530,54 @@ static void autopick_entry_from_object(autopick_type *entry, object_type *o_ptr) * Register the ego type only. */ ego_item_type *e_ptr = &e_info[o_ptr->name2]; +#ifdef JP + /* ¥¨¥´ÌäˤϡÖ^¡×¥Þ¡¼¥¯¤¬»È¤¨¤ë */ + sprintf(name_str, "^%s", e_name + e_ptr->name); +#else + /* We ommit the basename and cannot use the ^ mark */ strcpy(name_str, e_name + e_ptr->name); +#endif /* Don't use the object description */ name = FALSE; + + if (object_is_weapon_armour_ammo(o_ptr)) + { + /* Restrict to 'common' equipments */ + if (!object_is_rare(o_ptr)) ADD_FLG(FLG_COMMON); + } } ADD_FLG(FLG_EGO); } /* Artifact */ - else if (o_ptr->name1 || o_ptr->art_name) + else if (object_is_artifact(o_ptr)) ADD_FLG(FLG_ARTIFACT); /* Non-ego, non-artifact */ else { /* Wearable nameless object */ - if ((TV_EQUIP_BEGIN <= o_ptr->tval && o_ptr->tval <= TV_EQUIP_END)) + if (object_is_equipment(o_ptr)) ADD_FLG(FLG_NAMELESS); - bol_mark = TRUE; + bol_mark = TRUE; } } - - switch(o_ptr->tval) + /* Melee weapon with boosted dice */ + if (object_is_melee_weapon(o_ptr)) { - object_kind *k_ptr; - case TV_HAFTED: case TV_POLEARM: case TV_SWORD: case TV_DIGGING: - k_ptr = &k_info[o_ptr->k_idx]; + object_kind *k_ptr = &k_info[o_ptr->k_idx]; + if ((o_ptr->dd != k_ptr->dd) || (o_ptr->ds != k_ptr->ds)) ADD_FLG(FLG_BOOSTED); } - if (o_ptr->tval == TV_CORPSE && object_is_shoukinkubi(o_ptr)) + /* Wanted monster's corpse */ + if (object_is_shoukinkubi(o_ptr)) { REM_FLG(FLG_WORTHLESS); ADD_FLG(FLG_WANTED); @@ -677,8 +626,7 @@ static void autopick_entry_from_object(autopick_type *entry, object_type *o_ptr) if (o_ptr->tval >= TV_LIFE_BOOK && 3 == o_ptr->sval) ADD_FLG(FLG_FOURTH); - if (o_ptr->tval == TV_SHOT || o_ptr->tval == TV_BOLT - || o_ptr->tval == TV_ARROW) + if (object_is_ammo(o_ptr)) ADD_FLG(FLG_MISSILES); else if (o_ptr->tval == TV_SCROLL || o_ptr->tval == TV_STAFF || o_ptr->tval == TV_WAND || o_ptr->tval == TV_ROD) @@ -688,6 +636,8 @@ static void autopick_entry_from_object(autopick_type *entry, object_type *o_ptr) else if (o_ptr->tval == TV_SKELETON || o_ptr->tval == TV_BOTTLE || o_ptr->tval == TV_JUNK || o_ptr->tval == TV_STATUE) ADD_FLG(FLG_JUNKS); + else if (o_ptr->tval == TV_CORPSE) + ADD_FLG(FLG_CORPSES); else if (o_ptr->tval >= TV_LIFE_BOOK) ADD_FLG(FLG_SPELLBOOKS); else if (o_ptr->tval == TV_POLEARM || o_ptr->tval == TV_SWORD @@ -718,7 +668,7 @@ static void autopick_entry_from_object(autopick_type *entry, object_type *o_ptr) { char o_name[MAX_NLEN]; - object_desc(o_name, o_ptr, FALSE, 0); + object_desc(o_name, o_ptr, (OD_NO_FLAVOR | OD_OMIT_PREFIX | OD_NO_PLURAL | OD_NAME_ONLY)); /* * If necessary, add a '^' which indicates the @@ -745,12 +695,12 @@ static void autopick_free_entry(autopick_type *entry) } -/* - * Initialize auto-picker preference - */ #define MAX_AUTOPICK_DEFAULT 200 -void init_autopicker(void) +/* + * Initialize the autopick + */ +static void init_autopick(void) { static const char easy_autopick_inscription[] = "(:=g"; autopick_type entry; @@ -775,6 +725,93 @@ void init_autopicker(void) } +#define PT_DEFAULT 0 +#define PT_WITH_PNAME 1 + +/* + * Get file name for autopick preference + */ +static cptr pickpref_filename(int filename_mode) +{ +#ifdef JP + static const char namebase[] = "picktype"; +#else + static const char namebase[] = "pickpref"; +#endif + + switch (filename_mode) + { + case PT_DEFAULT: + return format("%s.prf", namebase); + + case PT_WITH_PNAME: + return format("%s-%s.prf", namebase, player_base); + + default: + return NULL; + } +} + + +/* + * Load an autopick preference file + */ +void autopick_load_pref(bool disp_mes) +{ + char buf[80]; + errr err; + + /* Free old entries */ + init_autopick(); + + /* Try a filename with player name */ + my_strcpy(buf, pickpref_filename(PT_WITH_PNAME), sizeof(buf)); + + /* Load the file */ + err = process_autopick_file(buf); + + if (err == 0 && disp_mes) + { + /* Success */ +#ifdef JP + msg_format("%s¤òÆɤ߹þ¤ß¤Þ¤·¤¿¡£", buf); +#else + msg_format("Loaded '%s'.", buf); +#endif + } + + /* No file found */ + if (0 > err) + { + /* Use default name */ + my_strcpy(buf, pickpref_filename(PT_DEFAULT), sizeof(buf)); + + /* Load the file */ + err = process_autopick_file(buf); + + if (err == 0 && disp_mes) + { + /* Success */ +#ifdef JP + msg_format("%s¤òÆɤ߹þ¤ß¤Þ¤·¤¿¡£", buf); +#else + msg_format("Loaded '%s'.", buf); +#endif + } + } + + if (err && disp_mes) + { + /* Failed */ +#ifdef JP + msg_print("¼«Æ°½¦¤¤ÀßÄê¥Õ¥¡¥¤¥ë¤ÎÆɤ߹þ¤ß¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£"); +#else + msg_print("Failed to reload autopick preference."); +#endif + } +} + + /* * Add one line to autopick_list[] */ @@ -809,7 +846,7 @@ static void add_autopick_list(autopick_type *entry) /* * Process line for auto picker/destroyer. */ -errr process_pickpref_file_line(char *buf) +errr process_autopick_file_command(char *buf) { autopick_type an_entry, *entry = &an_entry; int i; @@ -863,10 +900,10 @@ cptr autopick_line_from_entry(autopick_type *entry) if (IS_FLG(FLG_ALL)) ADD_KEY(KEY_ALL); if (IS_FLG(FLG_COLLECTING)) ADD_KEY(KEY_COLLECTING); + if (IS_FLG(FLG_UNAWARE)) ADD_KEY(KEY_UNAWARE); if (IS_FLG(FLG_UNIDENTIFIED)) ADD_KEY(KEY_UNIDENTIFIED); if (IS_FLG(FLG_IDENTIFIED)) ADD_KEY(KEY_IDENTIFIED); if (IS_FLG(FLG_STAR_IDENTIFIED)) ADD_KEY(KEY_STAR_IDENTIFIED); - if (IS_FLG(FLG_UNAWARE)) ADD_KEY(KEY_UNAWARE); if (IS_FLG(FLG_BOOSTED)) ADD_KEY(KEY_BOOSTED); if (IS_FLG(FLG_MORE_DICE)) @@ -894,18 +931,24 @@ cptr autopick_line_from_entry(autopick_type *entry) if (IS_FLG(FLG_UNIQUE)) ADD_KEY(KEY_UNIQUE); if (IS_FLG(FLG_HUMAN)) ADD_KEY(KEY_HUMAN); if (IS_FLG(FLG_WORTHLESS)) ADD_KEY(KEY_WORTHLESS); + if (IS_FLG(FLG_GOOD)) ADD_KEY(KEY_GOOD); if (IS_FLG(FLG_NAMELESS)) ADD_KEY(KEY_NAMELESS); + if (IS_FLG(FLG_AVERAGE)) ADD_KEY(KEY_AVERAGE); + if (IS_FLG(FLG_RARE)) ADD_KEY(KEY_RARE); + if (IS_FLG(FLG_COMMON)) ADD_KEY(KEY_COMMON); if (IS_FLG(FLG_EGO)) ADD_KEY(KEY_EGO); if (IS_FLG(FLG_ARTIFACT)) ADD_KEY(KEY_ARTIFACT); if (IS_FLG(FLG_ITEMS)) ADD_KEY2(KEY_ITEMS); else if (IS_FLG(FLG_WEAPONS)) ADD_KEY2(KEY_WEAPONS); + else if (IS_FLG(FLG_FAVORITE_WEAPONS)) ADD_KEY2(KEY_FAVORITE_WEAPONS); else if (IS_FLG(FLG_ARMORS)) ADD_KEY2(KEY_ARMORS); else if (IS_FLG(FLG_MISSILES)) ADD_KEY2(KEY_MISSILES); else if (IS_FLG(FLG_DEVICES)) ADD_KEY2(KEY_DEVICES); else if (IS_FLG(FLG_LIGHTS)) ADD_KEY2(KEY_LIGHTS); else if (IS_FLG(FLG_JUNKS)) ADD_KEY2(KEY_JUNKS); + else if (IS_FLG(FLG_CORPSES)) ADD_KEY2(KEY_CORPSES); else if (IS_FLG(FLG_SPELLBOOKS)) ADD_KEY2(KEY_SPELLBOOKS); else if (IS_FLG(FLG_HAFTED)) ADD_KEY2(KEY_HAFTED); else if (IS_FLG(FLG_SHIELDS)) ADD_KEY2(KEY_SHIELDS); @@ -917,7 +960,6 @@ cptr autopick_line_from_entry(autopick_type *entry) else if (IS_FLG(FLG_HELMS)) ADD_KEY2(KEY_HELMS); else if (IS_FLG(FLG_GLOVES)) ADD_KEY2(KEY_GLOVES); else if (IS_FLG(FLG_BOOTS)) ADD_KEY2(KEY_BOOTS); - else if (IS_FLG(FLG_FAVORITE)) ADD_KEY2(KEY_FAVORITE); /* You don't need sepalator after adjective */ /* 'artifact' is not true adjective */ @@ -986,38 +1028,36 @@ static bool is_autopick_aux(object_type *o_ptr, autopick_type *entry, cptr o_nam int j; cptr ptr = entry->name; + /*** Unaware items ***/ + if (IS_FLG(FLG_UNAWARE) && object_is_aware(o_ptr)) + return FALSE; + /*** Unidentified ***/ if (IS_FLG(FLG_UNIDENTIFIED) - && (object_known_p(o_ptr) || (o_ptr->ident & IDENT_SENSE))) + && (object_is_known(o_ptr) || (o_ptr->ident & IDENT_SENSE))) return FALSE; /*** Identified ***/ - if (IS_FLG(FLG_IDENTIFIED) && !object_known_p(o_ptr)) + if (IS_FLG(FLG_IDENTIFIED) && !object_is_known(o_ptr)) return FALSE; /*** *Identified* ***/ if (IS_FLG(FLG_STAR_IDENTIFIED) && - (!object_known_p(o_ptr) || !(o_ptr->ident & IDENT_MENTAL))) + (!object_is_known(o_ptr) || !(o_ptr->ident & IDENT_MENTAL))) return FALSE; /*** Dice boosted (weapon of slaying) ***/ if (IS_FLG(FLG_BOOSTED)) { object_kind *k_ptr = &k_info[o_ptr->k_idx]; - - switch( o_ptr->tval ) - { - case TV_HAFTED: - case TV_POLEARM: - case TV_SWORD: - case TV_DIGGING: - if ((o_ptr->dd != k_ptr->dd) || (o_ptr->ds != k_ptr->ds)) - break; - else - return FALSE; - default: + + /* Require melee weapon */ + if (!object_is_melee_weapon(o_ptr)) + return FALSE; + + /* Require boosted dice */ + if ((o_ptr->dd == k_ptr->dd) && (o_ptr->ds == k_ptr->ds)) return FALSE; - } } /*** Weapons which dd*ds is more than nn ***/ @@ -1030,7 +1070,7 @@ static bool is_autopick_aux(object_type *o_ptr, autopick_type *entry, cptr o_nam /*** Weapons whic dd*ds is more than nn ***/ if (IS_FLG(FLG_MORE_BONUS)) { - if (!object_known_p(o_ptr)) return FALSE; + if (!object_is_known(o_ptr)) return FALSE; if (o_ptr->pval) { @@ -1053,7 +1093,7 @@ static bool is_autopick_aux(object_type *o_ptr, autopick_type *entry, cptr o_nam /*** Artifact object ***/ if (IS_FLG(FLG_ARTIFACT)) { - if (!object_known_p(o_ptr) || (!o_ptr->name1 && !o_ptr->art_name)) + if (!object_is_known(o_ptr) || !object_is_artifact(o_ptr)) return FALSE; } @@ -1061,28 +1101,64 @@ static bool is_autopick_aux(object_type *o_ptr, autopick_type *entry, cptr o_nam if (IS_FLG(FLG_EGO)) { /* Need to be an ego item */ - if (!o_ptr->name2) return FALSE; + if (!object_is_ego(o_ptr)) return FALSE; /* Need to be known to be an ego */ - if (!object_known_p(o_ptr) && + if (!object_is_known(o_ptr) && !((o_ptr->ident & IDENT_SENSE) && o_ptr->feeling == FEEL_EXCELLENT)) return FALSE; } - /*** Nameless ***/ - if (IS_FLG(FLG_NAMELESS)) + /*** Good ***/ + if (IS_FLG(FLG_GOOD)) { - if (!(TV_EQUIP_BEGIN <= o_ptr->tval && o_ptr->tval <= TV_EQUIP_END)) + if (!object_is_equipment(o_ptr)) return FALSE; + + /* Identified */ + if (object_is_known(o_ptr)) + { + /* Artifacts and Ego objects are not okay */ + if (!object_is_nameless(o_ptr)) + return FALSE; + + /* Average are not okay */ + if (o_ptr->to_a <= 0 && (o_ptr->to_h + o_ptr->to_d) <= 0) + return FALSE; + } + + /* Pseudo-identified */ + else if (o_ptr->ident & IDENT_SENSE) + { + switch (o_ptr->feeling) + { + case FEEL_GOOD: + /* It's good */ + break; + + default: + /* It's not good */ + return FALSE; + } + } + + /* Unidentified */ + else + { + /* Not known to be good */ return FALSE; + } + } - /* Inscription is a some sort of 'name' */ - if (o_ptr->inscription) return FALSE; + /*** Nameless ***/ + if (IS_FLG(FLG_NAMELESS)) + { + if (!object_is_equipment(o_ptr)) return FALSE; /* Identified */ - if (object_known_p(o_ptr)) + if (object_is_known(o_ptr)) { /* Artifacts and Ego objects are not okay */ - if (o_ptr->name1 || o_ptr->art_name || o_ptr->name2) + if (!object_is_nameless(o_ptr)) return FALSE; } @@ -1112,13 +1188,60 @@ static bool is_autopick_aux(object_type *o_ptr, autopick_type *entry, cptr o_nam } } - /*** Unaware items ***/ - if (IS_FLG(FLG_UNAWARE) && object_aware_p(o_ptr)) + /*** Average ***/ + if (IS_FLG(FLG_AVERAGE)) + { + if (!object_is_equipment(o_ptr)) return FALSE; + + /* Identified */ + if (object_is_known(o_ptr)) + { + /* Artifacts and Ego objects are not okay */ + if (!object_is_nameless(o_ptr)) + return FALSE; + + /* Cursed or broken objects are not okay */ + if (object_is_cursed(o_ptr) || object_is_broken(o_ptr)) + return FALSE; + + /* Good are not okay */ + if (o_ptr->to_a > 0 || (o_ptr->to_h + o_ptr->to_d) > 0) + return FALSE; + } + + /* Pseudo-identified */ + else if (o_ptr->ident & IDENT_SENSE) + { + switch (o_ptr->feeling) + { + case FEEL_AVERAGE: + /* It's average */ + break; + + default: + /* It's not average */ + return FALSE; + } + } + + /* Unidentified */ + else + { + /* Not known to be average */ + return FALSE; + } + } + + /*** Rere equipments ***/ + if (IS_FLG(FLG_RARE) && !object_is_rare(o_ptr)) + return FALSE; + + /*** Common equipments ***/ + if (IS_FLG(FLG_COMMON) && object_is_rare(o_ptr)) return FALSE; /*** Wanted monster's corpse/skeletons ***/ - if (IS_FLG(FLG_WANTED) && - (o_ptr->tval != TV_CORPSE || !object_is_shoukinkubi(o_ptr))) + if (IS_FLG(FLG_WANTED) && !object_is_shoukinkubi(o_ptr)) return FALSE; /*** Unique monster's corpse/skeletons/statues ***/ @@ -1176,22 +1299,22 @@ static bool is_autopick_aux(object_type *o_ptr, autopick_type *entry, cptr o_nam /*** Items ***/ if (IS_FLG(FLG_WEAPONS)) { - if (!(TV_WEAPON_BEGIN <= o_ptr->tval && o_ptr->tval <= TV_WEAPON_END)) + if (!object_is_weapon(o_ptr)) + return FALSE; + } + else if (IS_FLG(FLG_FAVORITE_WEAPONS)) + { + if (!object_is_favorite(o_ptr)) return FALSE; } else if (IS_FLG(FLG_ARMORS)) { - if (!(TV_ARMOR_BEGIN <= o_ptr->tval && o_ptr->tval <= TV_ARMOR_END)) + if (!object_is_armour(o_ptr)) return FALSE; } else if (IS_FLG(FLG_MISSILES)) { - switch(o_ptr->tval) - { - case TV_SHOT: case TV_BOLT: case TV_ARROW: - break; - default: return FALSE; - } + if (!object_is_ammo(o_ptr)) return FALSE; } else if (IS_FLG(FLG_DEVICES)) { @@ -1217,6 +1340,11 @@ static bool is_autopick_aux(object_type *o_ptr, autopick_type *entry, cptr o_nam default: return FALSE; } } + else if (IS_FLG(FLG_CORPSES)) + { + if (o_ptr->tval != TV_CORPSE && o_ptr->tval != TV_SKELETON) + return FALSE; + } else if (IS_FLG(FLG_SPELLBOOKS)) { if (!(o_ptr->tval >= TV_LIFE_BOOK)) @@ -1274,11 +1402,6 @@ static bool is_autopick_aux(object_type *o_ptr, autopick_type *entry, cptr o_nam if (!(o_ptr->tval == TV_BOOTS)) return FALSE; } - else if (IS_FLG(FLG_FAVORITE)) - { - if (!is_favorite(o_ptr)) - return FALSE; - } /* Keyword don't match */ if (*ptr == '^') @@ -1324,7 +1447,7 @@ int is_autopick(object_type *o_ptr) if (o_ptr->tval == TV_GOLD) return -1; /* Prepare object name string first */ - object_desc(o_name, o_ptr, FALSE, 3); + object_desc(o_name, o_ptr, (OD_NO_FLAVOR | OD_OMIT_PREFIX | OD_NO_PLURAL)); /* Convert the string to lower case */ str_tolower(o_name); @@ -1371,22 +1494,21 @@ static bool is_opt_confirm_destroy(object_type *o_ptr) /* Known to be worthless? */ if (leave_worth) if (object_value(o_ptr) > 0) return FALSE; - + if (leave_equip) - if ((o_ptr->tval >= TV_MISSILE_BEGIN) && (o_ptr->tval <= TV_ARMOR_END)) return FALSE; - + if (object_is_weapon_armour_ammo(o_ptr)) return FALSE; + if (leave_chest) if ((o_ptr->tval == TV_CHEST) && o_ptr->pval) return FALSE; - + if (leave_wanted) { - if (o_ptr->tval == TV_CORPSE - && object_is_shoukinkubi(o_ptr)) return FALSE; + if (object_is_shoukinkubi(o_ptr)) return FALSE; } - + if (leave_corpse) if (o_ptr->tval == TV_CORPSE) return FALSE; - + if (leave_junk) if ((o_ptr->tval == TV_SKELETON) || (o_ptr->tval == TV_BOTTLE) || (o_ptr->tval == TV_JUNK) || (o_ptr->tval == TV_STATUE)) return FALSE; @@ -1409,20 +1531,20 @@ static bool is_opt_confirm_destroy(object_type *o_ptr) else if (p_ptr->pclass == CLASS_NINJA) { if (o_ptr->tval == TV_LITE && - o_ptr->name2 == EGO_LITE_DARKNESS) + o_ptr->name2 == EGO_LITE_DARKNESS && object_is_known(o_ptr)) return FALSE; } else if (p_ptr->pclass == CLASS_BEASTMASTER || p_ptr->pclass == CLASS_CAVALRY) { if (o_ptr->tval == TV_WAND && - o_ptr->sval == SV_WAND_HEAL_MONSTER) + o_ptr->sval == SV_WAND_HEAL_MONSTER && object_is_aware(o_ptr)) return FALSE; } } - + if (o_ptr->tval == TV_GOLD) return FALSE; - + return TRUE; } @@ -1469,7 +1591,7 @@ static void auto_destroy_item(object_type *o_ptr, int autopick_idx) char o_name[MAX_NLEN]; /* Describe the object (with {terrible/special}) */ - object_desc(o_name, o_ptr, TRUE, 3); + object_desc(o_name, o_ptr, 0); /* Message */ #ifdef JP @@ -1496,7 +1618,7 @@ static void auto_destroy_item(object_type *o_ptr, int autopick_idx) /* * Auto-destroy marked item */ -static void delayed_auto_destroy_aux(int item) +static void autopick_delayed_alter_aux(int item) { object_type *o_ptr; @@ -1506,12 +1628,12 @@ static void delayed_auto_destroy_aux(int item) /* Get the item (on the floor) */ else o_ptr = &o_list[0 - item]; - if (o_ptr->k_idx && o_ptr->marked & OM_AUTODESTROY) + if (o_ptr->k_idx && (o_ptr->marked & OM_AUTODESTROY)) { char o_name[MAX_NLEN]; /* Describe the object (with {terrible/special}) */ - object_desc(o_name, o_ptr, TRUE, 3); + object_desc(o_name, o_ptr, 0); /* Eliminate the item (from the pack) */ if (item >= 0) @@ -1539,7 +1661,7 @@ static void delayed_auto_destroy_aux(int item) /* * Auto-destroy marked items in inventry and on floor */ -void delayed_auto_destroy(void) +void autopick_delayed_alter(void) { int item; @@ -1548,14 +1670,14 @@ void delayed_auto_destroy(void) * skipping after inven_item_optimize() */ for (item = INVEN_TOTAL - 1; item >= 0 ; item--) - delayed_auto_destroy_aux(item); + autopick_delayed_alter_aux(item); /* Scan the pile of objects */ item = cave[py][px].o_idx; while (item) { int next = o_list[item].next_o_idx; - delayed_auto_destroy_aux(-item); + autopick_delayed_alter_aux(-item); item = next; } } @@ -1567,7 +1689,7 @@ void delayed_auto_destroy(void) * Auto-destroyer works only on inventory or on floor stack only when * requested. */ -void auto_do_item(int item, bool destroy) +void autopick_alter_item(int item, bool destroy) { object_type *o_ptr; int idx; @@ -1593,7 +1715,7 @@ void auto_do_item(int item, bool destroy) /* * Automatically pickup/destroy items in this grid. */ -void auto_pickup_items(cave_type *c_ptr) +void autopick_pickup_items(cave_type *c_ptr) { s16b this_o_idx, next_o_idx = 0; @@ -1623,7 +1745,7 @@ void auto_pickup_items(cave_type *c_ptr) char o_name[MAX_NLEN]; /* Describe the object */ - object_desc(o_name, o_ptr, TRUE, 3); + object_desc(o_name, o_ptr, 0); /* Message */ #ifdef JP @@ -1648,7 +1770,7 @@ void auto_pickup_items(cave_type *c_ptr) } /* Describe the object */ - object_desc(o_name, o_ptr, TRUE, 3); + object_desc(o_name, o_ptr, 0); #ifdef JP sprintf(out_val, "%s¤ò½¦¤¤¤Þ¤¹¤«? ", o_name); @@ -1681,34 +1803,6 @@ void auto_pickup_items(cave_type *c_ptr) } -#define PT_DEFAULT 0 -#define PT_WITH_PNAME 1 - -/* - * Get file name for autopick preference - */ -static cptr pickpref_filename(int filename_mode) -{ -#ifdef JP - static const char namebase[] = "picktype"; -#else - static const char namebase[] = "pickpref"; -#endif - - switch (filename_mode) - { - case PT_DEFAULT: - return format("%s.prf", namebase); - - case PT_WITH_PNAME: - return format("%s-%s.prf", namebase, player_name); - - default: - return NULL; - } -} - - static const char autoregister_header[] = "?:$AUTOREGISTER"; /* @@ -1842,7 +1936,7 @@ static bool clear_auto_register(void) /* * Automatically register an auto-destroy preference line */ -bool add_auto_register(object_type *o_ptr) +bool autopick_autoregister(object_type *o_ptr) { char buf[1024]; char pref_file[1024]; @@ -1877,15 +1971,14 @@ bool add_auto_register(object_type *o_ptr) } /* Known to be an artifact? */ - if ((object_known_p(o_ptr) && - (artifact_p(o_ptr) || o_ptr->art_name)) || + if ((object_is_known(o_ptr) && object_is_artifact(o_ptr)) || ((o_ptr->ident & IDENT_SENSE) && (o_ptr->feeling == FEEL_TERRIBLE || o_ptr->feeling == FEEL_SPECIAL))) { char o_name[MAX_NLEN]; /* Describe the object (with {terrible/special}) */ - object_desc(o_name, o_ptr, TRUE, 3); + object_desc(o_name, o_ptr, 0); /* Message */ #ifdef JP @@ -2084,6 +2177,10 @@ static void describe_autopick(char *buff, autopick_type *entry) if (IS_FLG(FLG_COLLECTING)) before_str[before_n++] = "¼ý½¸Ãæ¤Ç´û¤Ë»ý¤Ã¤Æ¤¤¤ë¥¹¥í¥Ã¥È¤Ë¤Þ¤È¤á¤é¤ì¤ë"; + /*** Unaware items ***/ + if (IS_FLG(FLG_UNAWARE)) + before_str[before_n++] = "̤´ÕÄê¤Ç¤½¤Î¸ú²Ì¤âȽÌÀ¤·¤Æ¤¤¤Ê¤¤"; + /*** Unidentified ***/ if (IS_FLG(FLG_UNIDENTIFIED)) before_str[before_n++] = "̤´ÕÄê¤Î"; @@ -2144,6 +2241,13 @@ static void describe_autopick(char *buff, autopick_type *entry) body_str = "ÁõÈ÷"; } + /*** Good ***/ + if (IS_FLG(FLG_GOOD)) + { + before_str[before_n++] = "¾å¼Á¤Î"; + body_str = "ÁõÈ÷"; + } + /*** Nameless ***/ if (IS_FLG(FLG_NAMELESS)) { @@ -2151,9 +2255,26 @@ static void describe_autopick(char *buff, autopick_type *entry) body_str = "ÁõÈ÷"; } - /*** Unaware items ***/ - if (IS_FLG(FLG_UNAWARE)) - before_str[before_n++] = "̤´ÕÄê¤Ç¤½¤Î¸ú²Ì¤âȽÌÀ¤·¤Æ¤¤¤Ê¤¤"; + /*** Average ***/ + if (IS_FLG(FLG_AVERAGE)) + { + before_str[before_n++] = "ʤÎ"; + body_str = "ÁõÈ÷"; + } + + /*** Rare equipments ***/ + if (IS_FLG(FLG_RARE)) + { + before_str[before_n++] = "¥É¥é¥´¥óÁõÈ÷¤ä¥«¥ª¥¹¡¦¥Ö¥ì¡¼¥ÉÅù¤ò´Þ¤àÄÁ¤·¤¤"; + body_str = "ÁõÈ÷"; + } + + /*** Common equipments ***/ + if (IS_FLG(FLG_COMMON)) + { + before_str[before_n++] = "¤¢¤ê¤Õ¤ì¤¿(¥É¥é¥´¥óÁõÈ÷¤ä¥«¥ª¥¹¡¦¥Ö¥ì¡¼¥ÉÅù¤ÎÄÁ¤·¤¤Êª¤Ç¤Ï¤Ê¤¤)"; + body_str = "ÁõÈ÷"; + } /*** Wanted monster's corpse/skeletons ***/ if (IS_FLG(FLG_WANTED)) @@ -2230,6 +2351,8 @@ static void describe_autopick(char *buff, autopick_type *entry) ; /* Nothing to do */ else if (IS_FLG(FLG_WEAPONS)) body_str = "Éð´ï"; + else if (IS_FLG(FLG_FAVORITE_WEAPONS)) + body_str = "ÆÀ°ÕÉð´ï"; else if (IS_FLG(FLG_ARMORS)) body_str = "Ëɶñ"; else if (IS_FLG(FLG_MISSILES)) @@ -2240,6 +2363,8 @@ static void describe_autopick(char *buff, autopick_type *entry) body_str = "¸÷¸»ÍѤΥ¢¥¤¥Æ¥à"; else if (IS_FLG(FLG_JUNKS)) body_str = "Àޤ줿ËÀÅù¤Î¥¬¥é¥¯¥¿"; + else if (IS_FLG(FLG_CORPSES)) + body_str = "»àÂΤä¹ü"; else if (IS_FLG(FLG_SPELLBOOKS)) body_str = "ËâË¡½ñ"; else if (IS_FLG(FLG_HAFTED)) @@ -2262,8 +2387,6 @@ static void describe_autopick(char *buff, autopick_type *entry) body_str = "äƼê"; else if (IS_FLG(FLG_BOOTS)) body_str = "¥Ö¡¼¥Ä"; - else if (IS_FLG(FLG_FAVORITE)) - body_str = "ÆÀ°ÕÉð´ï"; *buff = '\0'; if (!before_n) @@ -2340,6 +2463,13 @@ static void describe_autopick(char *buff, autopick_type *entry) if (IS_FLG(FLG_COLLECTING)) which_str[which_n++] = "can be absorbed into an existing inventory slot"; + /*** Unaware items ***/ + if (IS_FLG(FLG_UNAWARE)) + { + before_str[before_n++] = "unidentified"; + whose_str[whose_n++] = "basic abilities are not known"; + } + /*** Unidentified ***/ if (IS_FLG(FLG_UNIDENTIFIED)) before_str[before_n++] = "unidentified"; @@ -2352,6 +2482,22 @@ static void describe_autopick(char *buff, autopick_type *entry) if (IS_FLG(FLG_STAR_IDENTIFIED)) before_str[before_n++] = "fully identified"; + /*** Rare equipments ***/ + if (IS_FLG(FLG_RARE)) + { + before_str[before_n++] = "very rare"; + body_str = "equipments"; + after_str[after_n++] = "such like Dragon armors, Blades of Chaos, etc."; + } + + /*** Common equipments ***/ + if (IS_FLG(FLG_COMMON)) + { + before_str[before_n++] = "relatively common"; + body_str = "equipments"; + after_str[after_n++] = "compared to very rare Dragon armors, Blades of Chaos, etc."; + } + /*** Worthless items ***/ if (IS_FLG(FLG_WORTHLESS)) { @@ -2371,6 +2517,13 @@ static void describe_autopick(char *buff, autopick_type *entry) before_str[before_n++] = "ego"; } + /*** Good ***/ + if (IS_FLG(FLG_GOOD)) + { + body_str = "equipment"; + which_str[which_n++] = "have good quality"; + } + /*** Nameless ***/ if (IS_FLG(FLG_NAMELESS)) { @@ -2378,11 +2531,11 @@ static void describe_autopick(char *buff, autopick_type *entry) which_str[which_n++] = "is neither ego-item nor artifact"; } - /*** Unaware items ***/ - if (IS_FLG(FLG_UNAWARE)) + /*** Average ***/ + if (IS_FLG(FLG_AVERAGE)) { - before_str[before_n++] = "unidentified"; - whose_str[whose_n++] = "basic abilities are not known"; + body_str = "equipment"; + which_str[which_n++] = "have average quality"; } /*** Dice boosted (weapon of slaying) ***/ @@ -2491,6 +2644,8 @@ static void describe_autopick(char *buff, autopick_type *entry) ; /* Nothing to do */ else if (IS_FLG(FLG_WEAPONS)) body_str = "weapons"; + else if (IS_FLG(FLG_FAVORITE_WEAPONS)) + body_str = "favorite weapons"; else if (IS_FLG(FLG_ARMORS)) body_str = "armors"; else if (IS_FLG(FLG_MISSILES)) @@ -2501,6 +2656,8 @@ static void describe_autopick(char *buff, autopick_type *entry) body_str = "light sources"; else if (IS_FLG(FLG_JUNKS)) body_str = "junk such as broken sticks"; + else if (IS_FLG(FLG_CORPSES)) + body_str = "corpses or skeletons"; else if (IS_FLG(FLG_SPELLBOOKS)) body_str = "spellbooks"; else if (IS_FLG(FLG_HAFTED)) @@ -2523,8 +2680,6 @@ static void describe_autopick(char *buff, autopick_type *entry) body_str = "gloves"; else if (IS_FLG(FLG_BOOTS)) body_str = "boots"; - else if (IS_FLG(FLG_FAVORITE)) - body_str = "favorite weapons"; /* Prepare a string for item name */ if (*str) @@ -2643,7 +2798,7 @@ static void describe_autopick(char *buff, autopick_type *entry) /* * Read whole lines of a file to memory */ -static cptr *read_text_lines(cptr filename, bool user) +static cptr *read_text_lines(cptr filename) { cptr *lines_list = NULL; FILE *fff; @@ -2651,14 +2806,7 @@ static cptr *read_text_lines(cptr filename, bool user) int lines = 0; char buf[1024]; - if (user) - { - path_build(buf, sizeof(buf), ANGBAND_DIR_USER, filename); - } - else - { - path_build(buf, sizeof(buf), ANGBAND_DIR_PREF, filename); - } + path_build(buf, sizeof(buf), ANGBAND_DIR_USER, filename); /* Open the file */ fff = my_fopen(buf, "r"); @@ -2668,43 +2816,119 @@ static cptr *read_text_lines(cptr filename, bool user) /* Allocate list of pointers */ C_MAKE(lines_list, MAX_LINES, cptr); - /* Parse it */ - while (0 == my_fgets(fff, buf, sizeof(buf))) - { - lines_list[lines++] = string_make(buf); - if (lines >= MAX_LINES - 1) break; - } - if (lines == 0) - lines_list[0] = string_make(""); + /* Parse it */ + while (0 == my_fgets(fff, buf, sizeof(buf))) + { + lines_list[lines++] = string_make(buf); + if (lines >= MAX_LINES - 1) break; + } + if (lines == 0) + lines_list[0] = string_make(""); + + my_fclose(fff); + } + + if (!fff) return NULL; + return lines_list; +} + + +/* + * Copy the default autopick file to the user directory + */ +static void prepare_default_pickpref(void) +{ + static char *messages[] = { +#ifdef JP + "¤¢¤Ê¤¿¤Ï¡Ö¼«Æ°½¦¤¤¥¨¥Ç¥£¥¿¡×¤ò½é¤á¤Æµ¯Æ°¤·¤Þ¤·¤¿¡£", + "¼«Æ°½¦¤¤¤Î¥æ¡¼¥¶¡¼ÀßÄê¥Õ¥¡¥¤¥ë¤¬¤Þ¤À½ñ¤«¤ì¤Æ¤¤¤Ê¤¤¤Î¤Ç¡¢", + "´ðËÜŪ¤Ê¼«Æ°½¦¤¤ÀßÄê¥Õ¥¡¥¤¥ë¤òlib/pref/picktype.prf¤«¤é¥³¥Ô¡¼¤·¤Þ¤¹¡£", + NULL +#else + "You have activated the Auto-Picker Editor for the first time.", + "Since user pref file for autopick is not yet created,", + "the default setting is loaded from lib/pref/pickpref.prf .", + NULL +#endif + }; + + char buf[1024]; + FILE *pref_fp; + FILE *user_fp; + int i; + cptr filename = pickpref_filename(PT_DEFAULT); + + /* Display messages */ + for (i = 0; messages[i]; i++) msg_print(messages[i]); + msg_print(NULL); + + + /* Open new file */ + path_build(buf, sizeof(buf), ANGBAND_DIR_USER, filename); + user_fp = my_fopen(buf, "w"); + + /* Failed */ + if (!user_fp) return; + + /* Write header messages for a notification */ + fprintf(user_fp, "#***\n"); + for (i = 0; messages[i]; i++) + { + fprintf(user_fp, "#*** %s\n", messages[i]); + } + fprintf(user_fp, "#***\n\n\n"); + - my_fclose(fff); + /* Open the default file */ + path_build(buf, sizeof(buf), ANGBAND_DIR_PREF, filename); + pref_fp = my_fopen(buf, "r"); + + /* Failed */ + if (!pref_fp) + { + my_fclose(user_fp); + return; } - if (!fff) return NULL; - return lines_list; -} + /* Copy the contents of default file */ + while (!my_fgets(pref_fp, buf, sizeof(buf))) + fprintf(user_fp, "%s\n", buf); + my_fclose(user_fp); + my_fclose(pref_fp); +} +/* + * Read an autopick prefence file to memory + * Prepare default if no user file is found + */ static cptr *read_pickpref_text_lines(int *filename_mode_p) { char buf[1024]; cptr *lines_list; + /* Try a filename with player name */ *filename_mode_p = PT_WITH_PNAME; strcpy(buf, pickpref_filename(*filename_mode_p)); - lines_list = read_text_lines(buf, TRUE); + lines_list = read_text_lines(buf); if (!lines_list) { + /* Use default name */ *filename_mode_p = PT_DEFAULT; strcpy(buf, pickpref_filename(*filename_mode_p)); - lines_list = read_text_lines(buf, TRUE); + lines_list = read_text_lines(buf); } if (!lines_list) { - strcpy(buf, pickpref_filename(*filename_mode_p)); - lines_list = read_text_lines(buf, FALSE); + /* There is no preference file in the user directory */ + + /* Copy the default autopick file to the user directory */ + prepare_default_pickpref(); + + /* Use default name again */ + lines_list = read_text_lines(buf); } if (!lines_list) @@ -2819,10 +3043,18 @@ static void toggle_keyword(text_body_type *tb, int flg) } /* You can use only one flag in artifact/ego/nameless */ - else if (FLG_ARTIFACT <= flg && flg <= FLG_NAMELESS) + else if (FLG_ARTIFACT <= flg && flg <= FLG_AVERAGE) + { + int i; + for (i = FLG_ARTIFACT; i <= FLG_AVERAGE; i++) + REM_FLG(i); + } + + /* You can use only one flag in rare/common */ + else if (FLG_RARE <= flg && flg <= FLG_COMMON) { int i; - for (i = FLG_ARTIFACT; i <= FLG_NAMELESS; i++) + for (i = FLG_RARE; i <= FLG_COMMON; i++) REM_FLG(i); } @@ -3002,6 +3234,36 @@ static void check_expression_line(text_body_type *tb, int y) /* + * Add an empty line at the last of the file + */ +static bool add_empty_line(text_body_type *tb) +{ + int k; + + for (k = 0; tb->lines_list[k]; k++) + /* count number of lines */ ; + + /* Too many lines! */ + if (k >= MAX_LINES - 2) return FALSE; + + /* The last line is already empty */ + if (!tb->lines_list[k-1][0]) return FALSE; + + /* Create new empty line */ + tb->lines_list[k] = string_make(""); + + /* Expressions need re-evaluation */ + tb->dirty_flags |= DIRTY_EXPRESSION; + + /* Text is changed */ + tb->changed = TRUE; + + /* A line is added */ + return TRUE; +} + + +/* * Insert return code and split the line */ static bool insert_return_code(text_body_type *tb) @@ -3110,7 +3372,7 @@ static byte get_object_for_search(object_type **o_handle, cptr *search_strp) *o_handle = o_ptr; string_free(*search_strp); - object_desc(buf, *o_handle, FALSE, 3); + object_desc(buf, *o_handle, (OD_NO_FLAVOR | OD_OMIT_PREFIX | OD_NO_PLURAL)); *search_strp = string_make(format("<%s>", buf)); return 1; } @@ -3128,7 +3390,7 @@ static byte get_destroyed_object_for_search(object_type **o_handle, cptr *search *o_handle = &autopick_last_destroyed_object; string_free(*search_strp); - object_desc(buf, *o_handle, FALSE, 3); + object_desc(buf, *o_handle, (OD_NO_FLAVOR | OD_OMIT_PREFIX | OD_NO_PLURAL)); *search_strp = string_make(format("<%s>", buf)); return 1; } @@ -3157,9 +3419,16 @@ static byte get_string_for_search(object_type **o_handle, cptr *search_strp) #endif int col = sizeof(prompt) - 1; + /* Prepare string buffer for edit */ if (*search_strp) strcpy(buf, *search_strp); else buf[0] = '\0'; + /* Object searching mode */ + if (*o_handle) + { + color = TERM_L_GREEN; + } + /* Display prompt */ prt(prompt, 0, 0); @@ -3178,7 +3447,7 @@ static byte get_string_for_search(object_type **o_handle, cptr *search_strp) Term_gotoxy(col + pos, 0); /* Get a special key code */ - skey = inkey_special(); + skey = inkey_special(TRUE); /* Analyze the key */ switch (skey) @@ -3243,7 +3512,7 @@ static byte get_string_for_search(object_type **o_handle, cptr *search_strp) case '\n': case '\r': case KTRL('s'): - if (!pos && *o_handle) return (back ? -1 : 1); + if (*o_handle) return (back ? -1 : 1); string_free(*search_strp); *search_strp = string_make(buf); *o_handle = NULL; @@ -3334,8 +3603,20 @@ static byte get_string_for_search(object_type **o_handle, cptr *search_strp) /* Get a character code */ c = (char)skey; - if (color == TERM_YELLOW) + /* Was non insert mode? */ + if (color != TERM_WHITE) { + /* Was object searching mode */ + if (color == TERM_L_GREEN) + { + /* Cancel the mode */ + *o_handle = NULL; + + /* Remove indicating string */ + string_free(*search_strp); + *search_strp = NULL; + } + /* Overwrite default string */ buf[0] = '\0'; @@ -3392,6 +3673,20 @@ static byte get_string_for_search(object_type **o_handle, cptr *search_strp) } + /* Object searching mode was cancelled? */ + if (*o_handle && color != TERM_L_GREEN) + { + /* Cancel the mode */ + *o_handle = NULL; + + /* Remove indicating string */ + buf[0] = '\0'; + string_free(*search_strp); + *search_strp = NULL; + + } + + } /* while (TRUE) */ } @@ -3409,7 +3704,7 @@ static void search_for_object(text_body_type *tb, object_type *o_ptr, bool forwa int i = tb->cy; /* Prepare object name string first */ - object_desc(o_name, o_ptr, FALSE, 3); + object_desc(o_name, o_ptr, (OD_NO_FLAVOR | OD_OMIT_PREFIX | OD_NO_PLURAL)); /* Convert the string to lower case */ str_tolower(o_name); @@ -3612,190 +3907,183 @@ static void search_for_string(text_body_type *tb, cptr search_str, bool forward) #define EC_OK_WORTHLESS 46 #define EC_OK_ARTIFACT 47 #define EC_OK_EGO 48 -#define EC_OK_NAMELESS 49 -#define EC_OK_WANTED 50 -#define EC_OK_UNIQUE 51 -#define EC_OK_HUMAN 52 -#define EC_OK_UNREADABLE 53 -#define EC_OK_REALM1 54 -#define EC_OK_REALM2 55 -#define EC_OK_FIRST 56 -#define EC_OK_SECOND 57 -#define EC_OK_THIRD 58 -#define EC_OK_FOURTH 59 -#define EC_KK_WEAPONS 60 -#define EC_KK_FAVORITE 61 -#define EC_KK_ARMORS 62 -#define EC_KK_MISSILES 63 -#define EC_KK_DEVICES 64 -#define EC_KK_LIGHTS 65 -#define EC_KK_JUNKS 66 -#define EC_KK_SPELLBOOKS 67 -#define EC_KK_SHIELDS 68 -#define EC_KK_BOWS 69 -#define EC_KK_RINGS 70 -#define EC_KK_AMULETS 71 -#define EC_KK_SUITS 72 -#define EC_KK_CLOAKS 73 -#define EC_KK_HELMS 74 -#define EC_KK_GLOVES 75 -#define EC_KK_BOOTS 76 +#define EC_OK_GOOD 49 +#define EC_OK_NAMELESS 50 +#define EC_OK_AVERAGE 51 +#define EC_OK_RARE 52 +#define EC_OK_COMMON 53 +#define EC_OK_WANTED 54 +#define EC_OK_UNIQUE 55 +#define EC_OK_HUMAN 56 +#define EC_OK_UNREADABLE 57 +#define EC_OK_REALM1 58 +#define EC_OK_REALM2 59 +#define EC_OK_FIRST 60 +#define EC_OK_SECOND 61 +#define EC_OK_THIRD 62 +#define EC_OK_FOURTH 63 +#define EC_KK_WEAPONS 64 +#define EC_KK_FAVORITE_WEAPONS 65 +#define EC_KK_ARMORS 66 +#define EC_KK_MISSILES 67 +#define EC_KK_DEVICES 68 +#define EC_KK_LIGHTS 69 +#define EC_KK_JUNKS 70 +#define EC_KK_CORPSES 71 +#define EC_KK_SPELLBOOKS 72 +#define EC_KK_SHIELDS 73 +#define EC_KK_BOWS 74 +#define EC_KK_RINGS 75 +#define EC_KK_AMULETS 76 +#define EC_KK_SUITS 77 +#define EC_KK_CLOAKS 78 +#define EC_KK_HELMS 79 +#define EC_KK_GLOVES 80 +#define EC_KK_BOOTS 81 /* Manu names */ #ifdef JP -#define MN_QUIT "¥»¡¼¥Ö̵¤·¤Ç½ªÎ»" -#define MN_SAVEQUIT "¥»¡¼¥Ö¤·¤Æ½ªÎ»" -#define MN_REVERT "Á´¤Æ¤ÎÊѹ¹¤òÇË´þ" -#define MN_HELP "¥Ø¥ë¥×" - -#define MN_MOVE "¥«¡¼¥½¥ë°ÜÆ°" -#define MN_LEFT "º¸" -#define MN_DOWN "²¼" -#define MN_UP "¾å" -#define MN_RIGHT "±¦" -#define MN_BOL "¹Ô¤ÎÀèƬ" -#define MN_EOL "¹Ô¤Î½ªÃ¼" -#define MN_PGUP "¾å¤Î¥Ú¡¼¥¸" -#define MN_PGDOWN "²¼¤Î¥Ú¡¼¥¸" -#define MN_TOP "1¹ÔÌܤذÜÆ°" -#define MN_BOTTOM "ºÇ²¼¹Ô¤Ø°ÜÆ°" - -#define MN_EDIT "ÊÔ½¸" -#define MN_CUT "¥«¥Ã¥È" -#define MN_COPY "¥³¥Ô¡¼" -#define MN_PASTE "¥Ú¡¼¥¹¥È" -#define MN_BLOCK "ÁªÂòÈϰϤλØÄê" -#define MN_KILL_LINE "¹Ô¤Î»Ä¤ê¤òºï½ü" -#define MN_DELETE_CHAR "1ʸ»úºï½ü" -#define MN_BACKSPACE "¥Ð¥Ã¥¯¥¹¥Ú¡¼¥¹" -#define MN_RETURN "²þ¹Ô" -#define MN_RETURN "²þ¹Ô" - -#define MN_SEARCH "¸¡º÷" -#define MN_SEARCH_STR "ʸ»úÎó¤Ç¸¡º÷" -#define MN_SEARCH_FORW "Á°Êý¤ØºÆ¸¡º÷" -#define MN_SEARCH_BACK "¸åÊý¤ØºÆ¸¡º÷" -#define MN_SEARCH_OBJ "¥¢¥¤¥Æ¥à¤òÁªÂò¤·¤Æ¸¡º÷" -#define MN_SEARCH_DESTROYED "¼«Æ°Ç˲õ¤µ¤ì¤¿¥¢¥¤¥Æ¥à¤Ç¸¡º÷" - -#define MN_INSERT "¿§¡¹ÁÞÆþ" -#define MN_INSERT_OBJECT "ÁªÂò¤·¤¿¥¢¥¤¥Æ¥à¤Î̾Á°¤òÁÞÆþ" -#define MN_INSERT_DESTROYED "¼«Æ°Ç˲õ¤µ¤ì¤¿¥¢¥¤¥Æ¥à¤Î̾Á°¤òÁÞÆþ" -#define MN_INSERT_BLOCK "¾ò·ïʬ´ô¥Ö¥í¥Ã¥¯¤ÎÎã¤òÁÞÆþ" -#define MN_INSERT_MACRO "¥Þ¥¯¥íÄêµÁ¤òÁÞÆþ" -#define MN_INSERT_KEYMAP "¥­¡¼¥Þ¥Ã¥×ÄêµÁ¤òÁÞÆþ" - -#ifdef MAC_MPW -#define MN_COMMAND_LETTER "½¦¤¤/Ç˲õ/\x95\xfaÃÖ¤ÎÁªÂò" -#else -#define MN_COMMAND_LETTER "½¦¤¤/Ç˲õ/ÊüÃÖ¤ÎÁªÂò" -#endif -#define MN_CL_AUTOPICK "¡Ö ¡× (¼«Æ°½¦¤¤)" -#define MN_CL_DESTROY "¡Ö!¡× (¼«Æ°Ç˲õ)" -#ifdef MAC_MPW -#define MN_CL_LEAVE "¡Ö~¡× (\x95\xfaÃÖ)" -#else -#define MN_CL_LEAVE "¡Ö~¡× (ÊüÃÖ)" -#endif -#define MN_CL_QUERY "¡Ö;¡× (³Îǧ¤·¤Æ½¦¤¦)" -#define MN_CL_NO_DISP "¡Ö(¡× (¥Þ¥Ã¥×¥³¥Þ¥ó¥É¤Çɽ¼¨¤·¤Ê¤¤)" - -#define MN_ADJECTIVE_GEN "·ÁÍÆ»ì(°ìÈÌ)¤ÎÁªÂò" - -#define MN_ADJECTIVE_SPECIAL "·ÁÍÆ»ì(Æüì)¤ÎÁªÂò" -#define MN_BOOSTED "¥À¥¤¥¹Ìܤΰ㤦 (Éð´ï)" -#define MN_MORE_DICE "¥À¥¤¥¹ÌÜ # °Ê¾å¤Î (Éð´ï)" -#define MN_MORE_BONUS "½¤ÀµÃÍ # °Ê¾å¤Î (»ØÎØÅù)" -#define MN_ARTIFACT "¥¢¡¼¥Æ¥£¥Õ¥¡¥¯¥È (ÁõÈ÷)" -#define MN_EGO "¥¨¥´ (ÁõÈ÷)" -#define MN_NAMELESS "̵ÌäΠ(ÁõÈ÷)" -#define MN_WANTED "¾Þ¶â¼ó¤Î (»àÂÎ)" -#define MN_UNIQUE "¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¤Î (»àÂÎ)" -#define MN_HUMAN "¿Í´Ö¤Î (»àÂÎ)" -#define MN_UNREADABLE "Æɤá¤Ê¤¤ (ËâË¡½ñ)" -#define MN_REALM1 "Âè°ìÎΰè¤Î (ËâË¡½ñ)" -#define MN_REALM2 "ÂèÆóÎΰè¤Î (ËâË¡½ñ)" -#define MN_FIRST "1ºýÌܤΠ(ËâË¡½ñ)" -#define MN_SECOND "2ºýÌܤΠ(ËâË¡½ñ)" -#define MN_THIRD "3ºýÌܤΠ(ËâË¡½ñ)" -#define MN_FOURTH "4ºýÌܤΠ(ËâË¡½ñ)" - -#define MN_NOUN "̾»ì¤ÎÁªÂò" +static char MN_QUIT[] = "¥»¡¼¥Ö̵¤·¤Ç½ªÎ»"; +static char MN_SAVEQUIT[] = "¥»¡¼¥Ö¤·¤Æ½ªÎ»"; +static char MN_REVERT[] = "Á´¤Æ¤ÎÊѹ¹¤òÇË´þ"; +static char MN_HELP[] = "¥Ø¥ë¥×"; + +static char MN_MOVE[] = "¥«¡¼¥½¥ë°ÜÆ°"; +static char MN_LEFT[] = "º¸ (¢«Ìð°õ¥­¡¼)"; +static char MN_DOWN[] = "²¼ (¢­Ìð°õ¥­¡¼)"; +static char MN_UP[] = "¾å (¢¬Ìð°õ¥­¡¼)"; +static char MN_RIGHT[] = "±¦ (¢ªÌð°õ¥­¡¼)"; +static char MN_BOL[] = "¹Ô¤ÎÀèƬ"; +static char MN_EOL[] = "¹Ô¤Î½ªÃ¼"; +static char MN_PGUP[] = "¾å¤Î¥Ú¡¼¥¸ (PageUp¥­¡¼)"; +static char MN_PGDOWN[] = "²¼¤Î¥Ú¡¼¥¸ (PageDown¥­¡¼)"; +static char MN_TOP[] = "1¹ÔÌܤذÜÆ° (Home¥­¡¼)"; +static char MN_BOTTOM[] = "ºÇ²¼¹Ô¤Ø°ÜÆ°(End¥­¡¼)"; + +static char MN_EDIT[] = "ÊÔ½¸"; +static char MN_CUT[] = "¥«¥Ã¥È"; +static char MN_COPY[] = "¥³¥Ô¡¼"; +static char MN_PASTE[] = "¥Ú¡¼¥¹¥È"; +static char MN_BLOCK[] = "ÁªÂòÈϰϤλØÄê"; +static char MN_KILL_LINE[] = "¹Ô¤Î»Ä¤ê¤òºï½ü"; +static char MN_DELETE_CHAR[] = "1ʸ»úºï½ü"; +static char MN_BACKSPACE[] = "¥Ð¥Ã¥¯¥¹¥Ú¡¼¥¹"; +static char MN_RETURN[] = "²þ¹Ô"; + +static char MN_SEARCH[] = "¸¡º÷"; +static char MN_SEARCH_STR[] = "ʸ»úÎó¤Ç¸¡º÷"; +static char MN_SEARCH_FORW[] = "Á°Êý¤ØºÆ¸¡º÷"; +static char MN_SEARCH_BACK[] = "¸åÊý¤ØºÆ¸¡º÷"; +static char MN_SEARCH_OBJ[] = "¥¢¥¤¥Æ¥à¤òÁªÂò¤·¤Æ¸¡º÷"; +static char MN_SEARCH_DESTROYED[] = "¼«Æ°Ç˲õ¤µ¤ì¤¿¥¢¥¤¥Æ¥à¤Ç¸¡º÷"; + +static char MN_INSERT[] = "¿§¡¹ÁÞÆþ"; +static char MN_INSERT_OBJECT[] = "ÁªÂò¤·¤¿¥¢¥¤¥Æ¥à¤Î̾Á°¤òÁÞÆþ"; +static char MN_INSERT_DESTROYED[] = "¼«Æ°Ç˲õ¤µ¤ì¤¿¥¢¥¤¥Æ¥à¤Î̾Á°¤òÁÞÆþ"; +static char MN_INSERT_BLOCK[] = "¾ò·ïʬ´ô¥Ö¥í¥Ã¥¯¤ÎÎã¤òÁÞÆþ"; +static char MN_INSERT_MACRO[] = "¥Þ¥¯¥íÄêµÁ¤òÁÞÆþ"; +static char MN_INSERT_KEYMAP[] = "¥­¡¼¥Þ¥Ã¥×ÄêµÁ¤òÁÞÆþ"; + +static char MN_COMMAND_LETTER[] = "½¦¤¤/Ç˲õ/ÊüÃÖ¤ÎÁªÂò"; +static char MN_CL_AUTOPICK[] = "¡Ö ¡× (¼«Æ°½¦¤¤)"; +static char MN_CL_DESTROY[] = "¡Ö!¡× (¼«Æ°Ç˲õ)"; +static char MN_CL_LEAVE[] = "¡Ö~¡× (ÊüÃÖ)"; +static char MN_CL_QUERY[] = "¡Ö;¡× (³Îǧ¤·¤Æ½¦¤¦)"; +static char MN_CL_NO_DISP[] = "¡Ö(¡× (¥Þ¥Ã¥×¥³¥Þ¥ó¥É¤Çɽ¼¨¤·¤Ê¤¤)"; + +static char MN_ADJECTIVE_GEN[] = "·ÁÍÆ»ì(°ìÈÌ)¤ÎÁªÂò"; +static char MN_RARE[] = "¥ì¥¢¤Ê (ÁõÈ÷)"; +static char MN_COMMON[] = "¤¢¤ê¤Õ¤ì¤¿ (ÁõÈ÷)"; + +static char MN_ADJECTIVE_SPECIAL[] = "·ÁÍÆ»ì(Æüì)¤ÎÁªÂò"; +static char MN_BOOSTED[] = "¥À¥¤¥¹Ìܤΰ㤦 (Éð´ï)"; +static char MN_MORE_DICE[] = "¥À¥¤¥¹ÌÜ # °Ê¾å¤Î (Éð´ï)"; +static char MN_MORE_BONUS[] = "½¤ÀµÃÍ # °Ê¾å¤Î (»ØÎØÅù)"; +static char MN_WANTED[] = "¾Þ¶â¼ó¤Î (»àÂÎ)"; +static char MN_UNIQUE[] = "¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¤Î (»àÂÎ)"; +static char MN_HUMAN[] = "¿Í´Ö¤Î (»àÂÎ)"; +static char MN_UNREADABLE[] = "Æɤá¤Ê¤¤ (ËâË¡½ñ)"; +static char MN_REALM1[] = "Âè°ìÎΰè¤Î (ËâË¡½ñ)"; +static char MN_REALM2[] = "ÂèÆóÎΰè¤Î (ËâË¡½ñ)"; +static char MN_FIRST[] = "1ºýÌܤΠ(ËâË¡½ñ)"; +static char MN_SECOND[] = "2ºýÌܤΠ(ËâË¡½ñ)"; +static char MN_THIRD[] = "3ºýÌܤΠ(ËâË¡½ñ)"; +static char MN_FOURTH[] = "4ºýÌܤΠ(ËâË¡½ñ)"; + +static char MN_NOUN[] = "̾»ì¤ÎÁªÂò"; #else -#define MN_QUIT "Quit without save" -#define MN_SAVEQUIT "Save & Quit" -#define MN_REVERT "Revert all changes" -#define MN_HELP "Help" - -#define MN_MOVE "Move cursor" -#define MN_LEFT "Left" -#define MN_DOWN "Down" -#define MN_UP "Up" -#define MN_RIGHT "Right" -#define MN_BOL "Beggining of line" -#define MN_EOL "End of line" -#define MN_PGUP "Page up" -#define MN_PGDOWN "Page down" -#define MN_TOP "Top" -#define MN_BOTTOM "Bottom" - -#define MN_EDIT "Edit" -#define MN_CUT "Cut" -#define MN_COPY "Copy" -#define MN_PASTE "Paste" -#define MN_BLOCK "Select block" -#define MN_KILL_LINE "Kill rest of line" -#define MN_DELETE_CHAR "Delete character" -#define MN_BACKSPACE "Backspace" -#define MN_RETURN "Return" -#define MN_RETURN "Return" - -#define MN_SEARCH "Search" -#define MN_SEARCH_STR "Search by string" -#define MN_SEARCH_FORW "Search forward" -#define MN_SEARCH_BACK "Search backward" -#define MN_SEARCH_OBJ "Search by inventory object" -#define MN_SEARCH_DESTROYED "Search by destroyed object" - -#define MN_INSERT "Insert..." -#define MN_INSERT_OBJECT "Insert name of choosen object" -#define MN_INSERT_DESTROYED "Insert name of destroyed object" -#define MN_INSERT_BLOCK "Insert conditional block" -#define MN_INSERT_MACRO "Insert a macro definition" -#define MN_INSERT_KEYMAP "Insert a keymap definition" - -#define MN_COMMAND_LETTER "Command letter" -#define MN_CL_AUTOPICK "' ' (Auto pick)" -#define MN_CL_DESTROY "'!' (Auto destroy)" -#define MN_CL_LEAVE "'~' (Leave it on the floor)" -#define MN_CL_QUERY "';' (Query to pick up)" -#define MN_CL_NO_DISP "'(' (No display on the large map)" - -#define MN_ADJECTIVE_GEN "Adjective (general)" - -#define MN_ADJECTIVE_SPECIAL "Adjective (special)" -#define MN_BOOSTED "dice boosted (weapons)" -#define MN_MORE_DICE "more than # dice (weapons)" -#define MN_MORE_BONUS "more bonus than # (rings etc.)" -#define MN_ARTIFACT "artifact (equipments)" -#define MN_EGO "ego (equipments)" -#define MN_NAMELESS "nameless (equipments)" -#define MN_WANTED "wanted (corpse)" -#define MN_UNIQUE "unique (corpse)" -#define MN_HUMAN "human (corpse)" -#define MN_UNREADABLE "unreadable (spellbooks)" -#define MN_REALM1 "realm1 (spellbooks)" -#define MN_REALM2 "realm2 (spellbooks)" -#define MN_FIRST "first (spellbooks)" -#define MN_SECOND "second (spellbooks)" -#define MN_THIRD "third (spellbooks)" -#define MN_FOURTH "fourth (spellbooks)" - -#define MN_NOUN "Keywords (noun)" +static char MN_QUIT[] = "Quit without save"; +static char MN_SAVEQUIT[] = "Save & Quit"; +static char MN_REVERT[] = "Revert all changes"; +static char MN_HELP[] = "Help"; + +static char MN_MOVE[] = "Move cursor"; +static char MN_LEFT[] = "Left (Left Arrow key)"; +static char MN_DOWN[] = "Down (Down Arrow key)"; +static char MN_UP[] = "Up (Up Arrow key)"; +static char MN_RIGHT[] = "Right (Right Arrow key)"; +static char MN_BOL[] = "Beggining of line"; +static char MN_EOL[] = "End of line"; +static char MN_PGUP[] = "Page up (PageUp key)"; +static char MN_PGDOWN[] = "Page down(PageDown key)"; +static char MN_TOP[] = "Top (Home key)"; +static char MN_BOTTOM[] = "Bottom (End key)"; + +static char MN_EDIT[] = "Edit"; +static char MN_CUT[] = "Cut"; +static char MN_COPY[] = "Copy"; +static char MN_PASTE[] = "Paste"; +static char MN_BLOCK[] = "Select block"; +static char MN_KILL_LINE[] = "Kill rest of line"; +static char MN_DELETE_CHAR[] = "Delete character"; +static char MN_BACKSPACE[] = "Backspace"; +static char MN_RETURN[] = "Return"; + +static char MN_SEARCH[] = "Search"; +static char MN_SEARCH_STR[] = "Search by string"; +static char MN_SEARCH_FORW[] = "Search forward"; +static char MN_SEARCH_BACK[] = "Search backward"; +static char MN_SEARCH_OBJ[] = "Search by inventory object"; +static char MN_SEARCH_DESTROYED[] = "Search by destroyed object"; + +static char MN_INSERT[] = "Insert..."; +static char MN_INSERT_OBJECT[] = "Insert name of choosen object"; +static char MN_INSERT_DESTROYED[] = "Insert name of destroyed object"; +static char MN_INSERT_BLOCK[] = "Insert conditional block"; +static char MN_INSERT_MACRO[] = "Insert a macro definition"; +static char MN_INSERT_KEYMAP[] = "Insert a keymap definition"; + +static char MN_COMMAND_LETTER[] = "Command letter"; +static char MN_CL_AUTOPICK[] = "' ' (Auto pick)"; +static char MN_CL_DESTROY[] = "'!' (Auto destroy)"; +static char MN_CL_LEAVE[] = "'~' (Leave it on the floor)"; +static char MN_CL_QUERY[] = "';' (Query to pick up)"; +static char MN_CL_NO_DISP[] = "'(' (No display on the large map)"; + +static char MN_ADJECTIVE_GEN[] = "Adjective (general)"; +static char MN_RARE[] = "rare (equipments)"; +static char MN_COMMON[] = "common (equipments)"; + +static char MN_ADJECTIVE_SPECIAL[] = "Adjective (special)"; +static char MN_BOOSTED[] = "dice boosted (weapons)"; +static char MN_MORE_DICE[] = "more than # dice (weapons)"; +static char MN_MORE_BONUS[] = "more bonus than # (rings etc.)"; +static char MN_WANTED[] = "wanted (corpse)"; +static char MN_UNIQUE[] = "unique (corpse)"; +static char MN_HUMAN[] = "human (corpse)"; +static char MN_UNREADABLE[] = "unreadable (spellbooks)"; +static char MN_REALM1[] = "realm1 (spellbooks)"; +static char MN_REALM2[] = "realm2 (spellbooks)"; +static char MN_FIRST[] = "first (spellbooks)"; +static char MN_SECOND[] = "second (spellbooks)"; +static char MN_THIRD[] = "third (spellbooks)"; +static char MN_FOURTH[] = "fourth (spellbooks)"; + +static char MN_NOUN[] = "Keywords (noun)"; #endif @@ -3858,15 +4146,19 @@ command_menu_type menu_data[] = {KEY_IDENTIFIED, 1, -1, EC_IK_IDENTIFIED}, {KEY_STAR_IDENTIFIED, 1, -1, EC_IK_STAR_IDENTIFIED}, {KEY_COLLECTING, 1, -1, EC_OK_COLLECTING}, + {KEY_ARTIFACT, 1, -1, EC_OK_ARTIFACT}, + {KEY_EGO, 1, -1, EC_OK_EGO}, + {KEY_GOOD, 1, -1, EC_OK_GOOD}, + {KEY_NAMELESS, 1, -1, EC_OK_NAMELESS}, + {KEY_AVERAGE, 1, -1, EC_OK_AVERAGE}, {KEY_WORTHLESS, 1, -1, EC_OK_WORTHLESS}, + {MN_RARE, 1, -1, EC_OK_RARE}, + {MN_COMMON, 1, -1, EC_OK_COMMON}, {MN_ADJECTIVE_SPECIAL, 0, -1, -1}, {MN_BOOSTED, 1, -1, EC_OK_BOOSTED}, {MN_MORE_DICE, 1, -1, EC_OK_MORE_DICE}, {MN_MORE_BONUS, 1, -1, EC_OK_MORE_BONUS}, - {MN_ARTIFACT, 1, -1, EC_OK_ARTIFACT}, - {MN_EGO, 1, -1, EC_OK_EGO}, - {MN_NAMELESS, 1, -1, EC_OK_NAMELESS}, {MN_WANTED, 1, -1, EC_OK_WANTED}, {MN_UNIQUE, 1, -1, EC_OK_UNIQUE}, {MN_HUMAN, 1, -1, EC_OK_HUMAN}, @@ -3880,12 +4172,13 @@ command_menu_type menu_data[] = {MN_NOUN, 0, -1, -1}, {KEY_WEAPONS, 1, -1, EC_KK_WEAPONS}, - {KEY_FAVORITE, 1, -1, EC_KK_FAVORITE}, + {KEY_FAVORITE_WEAPONS, 1, -1, EC_KK_FAVORITE_WEAPONS}, {KEY_ARMORS, 1, -1, EC_KK_ARMORS}, {KEY_MISSILES, 1, -1, EC_KK_MISSILES}, {KEY_DEVICES, 1, -1, EC_KK_DEVICES}, {KEY_LIGHTS, 1, -1, EC_KK_LIGHTS}, {KEY_JUNKS, 1, -1, EC_KK_JUNKS}, + {KEY_CORPSES, 1, -1, EC_KK_CORPSES}, {KEY_SPELLBOOKS, 1, -1, EC_KK_SPELLBOOKS}, {KEY_SHIELDS, 1, -1, EC_KK_SHIELDS}, {KEY_BOWS, 1, -1, EC_KK_BOWS}, @@ -4135,6 +4428,91 @@ static void add_str_to_yank(text_body_type *tb, cptr str) } +/* + * Do work for the copy editor-command + */ +static void copy_text_to_yank(text_body_type *tb) +{ + int len = strlen(tb->lines_list[tb->cy]); + + /* Correct cursor location */ + if (tb->cx > len) tb->cx = len; + + /* Use single line? */ + if (!tb->mark) + { + /* Select a single line */ + tb->cx = 0; + tb->my = tb->cy; + tb->mx = len; + } + + /* Kill old yank buffer */ + kill_yank_chain(tb); + + + /* Single line case */ + if (tb->my == tb->cy) + { + int i; + char buf[MAX_LINELEN]; + int bx1 = MIN(tb->mx, tb->cx); + int bx2 = MAX(tb->mx, tb->cx); + + /* Correct fake cursor position */ + if (bx2 > len) bx2 = len; + + /* Whole part of this line is selected */ + if (bx1 == 0 && bx2 == len) + { + /* Copy this line */ + add_str_to_yank(tb, tb->lines_list[tb->cy]); + + /* Add end of line to the buffer */ + add_str_to_yank(tb, ""); + } + + /* Segment of this line is selected */ + else + { + for (i = 0; i < bx2 - bx1; i++) + { + buf[i] = tb->lines_list[tb->cy][bx1 + i]; + } + buf[i] = '\0'; + + /* Copy this segment of line */ + add_str_to_yank(tb, buf); + } + } + + /* Multiple lines case */ + else /* if (tb->my != tb->cy) */ + { + int y; + + int by1 = MIN(tb->my, tb->cy); + int by2 = MAX(tb->my, tb->cy); + + /* Copy lines */ + for (y = by1; y <= by2; y++) + { + /* Copy this line */ + add_str_to_yank(tb, tb->lines_list[y]); + } + + /* Add final end of line to the buffer */ + add_str_to_yank(tb, ""); + } + + /* Disable selection */ + tb->mark = 0; + + /* Now dirty */ + tb->dirty_flags |= DIRTY_ALL; +} + + #define DESCRIPT_HGT 3 /* @@ -4162,7 +4540,12 @@ static void draw_text_editor(text_body_type *tb) i++; if (i == tb->cx) { - tb->cx--; + /* + * Move to a correct position in the + * left or right + */ + if (i & 1) tb->cx--; + else tb->cx++; break; } } @@ -4220,6 +4603,8 @@ static void draw_text_editor(text_body_type *tb) char f; cptr v; cptr s = tb->lines_list[y]; + char *ss, *s_keep; + int s_len; /* Update this line's state */ tb->states[y] = state; @@ -4231,8 +4616,15 @@ static void draw_text_editor(text_body_type *tb) if (streq(s, "$AUTOREGISTER")) state |= LSTAT_AUTOREGISTER; + s_len = strlen(s); + ss = (char *)string_make(s); + s_keep = ss; + /* Parse the expr */ - v = process_pref_file_expr(&s, &f); + v = process_pref_file_expr(&ss, &f); + + /* Cannot use string_free() because the string was "destroyed" */ + C_FREE(s_keep, s_len + 1, char); /* Set flag */ if (streq(v, "0")) state |= LSTAT_BYPASS; @@ -4247,12 +4639,6 @@ static void draw_text_editor(text_body_type *tb) if (tb->mark) { - int tmp_cx = tb->cx; - int len = strlen(tb->lines_list[tb->cy]); - - /* Correct cursor location */ - if (tb->cx > len) tmp_cx = len; - tb->dirty_flags |= DIRTY_ALL; by1 = MIN(tb->my, tb->cy); @@ -4707,10 +5093,22 @@ static bool insert_keymap_line(text_body_type *tb) /* Look up the keymap */ act = keymap_act[mode][(byte)(buf[0])]; + if (act) + { + /* Analyze the current action */ + ascii_to_text(tmp, act); + } + else + { + /* No keymap defined -- Use trigger key itself as a default */ + + /* Nothing to do (use tmp) */ + } + /* Insert blank action preference line */ insert_return_code(tb); string_free(tb->lines_list[tb->cy]); - tb->lines_list[tb->cy] = string_make(format("A:%s", act)); + tb->lines_list[tb->cy] = string_make(format("A:%s", tmp)); return TRUE; } @@ -4792,10 +5190,30 @@ static bool do_editor_command(text_body_type *tb, int com_id) if (0 < tb->cx) { int len; +#ifdef JP + int i; +#endif tb->cx--; len = strlen(tb->lines_list[tb->cy]); if (len < tb->cx) tb->cx = len; + +#ifdef JP + /* Don't let cursor at second byte of kanji */ + for (i = 0; tb->lines_list[tb->cy][i]; i++) + { + if (iskanji(tb->lines_list[tb->cy][i])) + { + i++; + if (i == tb->cx) + { + /* Move to the left */ + tb->cx--; + break; + } + } + } +#endif } else if (tb->cy > 0) { @@ -4806,7 +5224,17 @@ static bool do_editor_command(text_body_type *tb, int com_id) case EC_DOWN: /* Next line */ - if (tb->lines_list[tb->cy + 1]) tb->cy++; + + /* Is this the last line? */ + if (!tb->lines_list[tb->cy + 1]) + { + /* Add one more empty line if possible */ + if (!add_empty_line(tb)) break; + } + + /* Go down */ + tb->cy++; + break; case EC_UP: @@ -4826,13 +5254,19 @@ static bool do_editor_command(text_body_type *tb, int com_id) len = strlen(tb->lines_list[tb->cy]); if (len < tb->cx) { - if (tb->lines_list[tb->cy + 1]) + /* Correct the cursor position */ + tb->cx = len; + + /* Is this the last line? */ + if (!tb->lines_list[tb->cy + 1]) { - tb->cy++; - tb->cx = 0; + /* Add one more empty line if possible */ + if (!add_empty_line(tb)) break; } - else - tb->cx = len; + + /* Move to the beginning of next line */ + tb->cy++; + tb->cx = 0; } break; } @@ -4856,8 +5290,18 @@ static bool do_editor_command(text_body_type *tb, int com_id) case EC_PGDOWN: /* Page down */ - while (tb->cy < tb->upper + tb->hgt && tb->lines_list[tb->cy + 1]) + while (tb->cy < tb->upper + tb->hgt) + { + /* Is this the last line? */ + if (!tb->lines_list[tb->cy + 1]) + { + /* Add one more empty line if possible */ + if (!add_empty_line(tb)) break; + } + tb->cy++; + } + tb->upper = tb->cy; break; @@ -4866,14 +5310,27 @@ static bool do_editor_command(text_body_type *tb, int com_id) break; case EC_BOTTOM: - while (tb->lines_list[tb->cy + 1]) + while (TRUE) + { + /* Is this the last line? */ + if (!tb->lines_list[tb->cy + 1]) + { + /* Add one more empty line if possible */ + if (!add_empty_line(tb)) break; + } + tb->cy++; + } + + /* Always at the biginning of the last line */ + tb->cx = 0; + break; case EC_CUT: { /* Copy the text first */ - do_editor_command(tb, EC_COPY); + copy_text_to_yank(tb); /* Single line case */ if (tb->my == tb->cy) @@ -4919,90 +5376,58 @@ static bool do_editor_command(text_body_type *tb, int com_id) /* Now dirty */ tb->dirty_flags |= DIRTY_ALL; + /* Text is changed */ + tb->changed = TRUE; + break; } case EC_COPY: - { - int len = strlen(tb->lines_list[tb->cy]); - - /* Correct cursor location */ - if (tb->cx > len) tb->cx = len; - - /* Use single line? */ - if (!tb->mark) - { - /* Select a single line */ - tb->cx = 0; - tb->my = tb->cy; - tb->mx = len; - } - - /* Kill old yank buffer */ - kill_yank_chain(tb); - + copy_text_to_yank(tb); - /* Single line case */ + /* + * Move cursor position to the end of the selection + * + * Pressing ^C ^V correctly duplicates the selection. + */ if (tb->my == tb->cy) { - int i; - char buf[MAX_LINELEN]; - int bx1 = MIN(tb->mx, tb->cx); - int bx2 = MAX(tb->mx, tb->cx); - - /* Correct fake cursor position */ - if (bx2 > len) bx2 = len; - - /* Whole part of this line is selected */ - if (bx1 == 0 && bx2 == len) - { - /* Copy this line */ - add_str_to_yank(tb, tb->lines_list[tb->cy]); + tb->cx = MAX(tb->cx, tb->mx); - /* Add end of line to the buffer */ - add_str_to_yank(tb, ""); - } - - /* Segment of this line is selected */ - else + /* + * When whole line is selected, the end of + * line code is also copyed. + */ + if (!tb->lines_list[tb->cy][tb->cx]) { - for (i = 0; i < bx2 - bx1; i++) + /* Is this the last line? */ + if (!tb->lines_list[tb->cy + 1]) { - buf[i] = tb->lines_list[tb->cy][bx1 + i]; + /* Add one more empty line if possible */ + if (!add_empty_line(tb)) break; } - buf[i] = '\0'; - /* Copy this segment of line */ - add_str_to_yank(tb, buf); + /* Go to the beginning of next line */ + tb->cy++; + tb->cx = 0; } } - - /* Multiple lines case */ - else /* if (tb->my != tb->cy) */ + else { - int y; - - int by1 = MIN(tb->my, tb->cy); - int by2 = MAX(tb->my, tb->cy); + tb->cy = MAX(tb->cy, tb->my); - /* Copy lines */ - for (y = by1; y <= by2; y++) + /* Is this the last line? */ + if (!tb->lines_list[tb->cy + 1]) { - /* Copy this line */ - add_str_to_yank(tb, tb->lines_list[y]); + /* Add one more empty line if possible */ + if (!add_empty_line(tb)) break; } - /* Add final end of line to the buffer */ - add_str_to_yank(tb, ""); + /* Go down */ + tb->cy++; } - /* Disable selection */ - tb->mark = 0; - - /* Now dirty */ - tb->dirty_flags |= DIRTY_ALL; break; - } case EC_PASTE: { @@ -5195,8 +5620,11 @@ static bool do_editor_command(text_body_type *tb, int com_id) } case EC_DELETE_CHAR: + { /* DELETE == go forward + BACK SPACE */ + int len; + /* Ignore selection */ if (tb->mark) { @@ -5211,8 +5639,25 @@ static bool do_editor_command(text_body_type *tb, int com_id) #endif tb->cx++; + /* Pass through the end of line to next line */ + len = strlen(tb->lines_list[tb->cy]); + if (len < tb->cx) + { + if (tb->lines_list[tb->cy + 1]) + { + tb->cy++; + tb->cx = 0; + } + else + { + tb->cx = len; + break; + } + } + do_editor_command(tb, EC_BACKSPACE); break; + } case EC_BACKSPACE: { @@ -5230,20 +5675,9 @@ static bool do_editor_command(text_body_type *tb, int com_id) tb->dirty_flags |= DIRTY_ALL; } + /* Move to correct collumn */ len = strlen(tb->lines_list[tb->cy]); - if (len < tb->cx) - { - if (tb->lines_list[tb->cy + 1]) - { - tb->cy++; - tb->cx = 0; - } - else - { - tb->cx = len; - break; - } - } + if (len < tb->cx) tb->cx = len; if (tb->cx == 0) { @@ -5327,7 +5761,7 @@ static bool do_editor_command(text_body_type *tb, int com_id) { search_for_object(tb, tb->search_o_ptr, TRUE); } - else if (tb->search_str) + else if (tb->search_str && tb->search_str[0]) { search_for_string(tb, tb->search_str, TRUE); } @@ -5342,7 +5776,7 @@ static bool do_editor_command(text_body_type *tb, int com_id) { search_for_object(tb, tb->search_o_ptr, FALSE); } - else if (tb->search_str) + else if (tb->search_str && tb->search_str[0]) { search_for_string(tb, tb->search_str, FALSE); } @@ -5512,12 +5946,13 @@ static bool do_editor_command(text_body_type *tb, int com_id) case EC_IK_IDENTIFIED: toggle_keyword(tb, FLG_IDENTIFIED); break; case EC_IK_STAR_IDENTIFIED: toggle_keyword(tb, FLG_STAR_IDENTIFIED); break; case EC_KK_WEAPONS: toggle_keyword(tb, FLG_WEAPONS); break; - case EC_KK_FAVORITE: toggle_keyword(tb, FLG_FAVORITE); break; + case EC_KK_FAVORITE_WEAPONS: toggle_keyword(tb, FLG_FAVORITE_WEAPONS); break; case EC_KK_ARMORS: toggle_keyword(tb, FLG_ARMORS); break; case EC_KK_MISSILES: toggle_keyword(tb, FLG_MISSILES); break; case EC_KK_DEVICES: toggle_keyword(tb, FLG_DEVICES); break; case EC_KK_LIGHTS: toggle_keyword(tb, FLG_LIGHTS); break; case EC_KK_JUNKS: toggle_keyword(tb, FLG_JUNKS); break; + case EC_KK_CORPSES: toggle_keyword(tb, FLG_CORPSES); break; case EC_KK_SPELLBOOKS: toggle_keyword(tb, FLG_SPELLBOOKS); break; case EC_KK_SHIELDS: toggle_keyword(tb, FLG_SHIELDS); break; case EC_KK_BOWS: toggle_keyword(tb, FLG_BOWS); break; @@ -5535,7 +5970,11 @@ static bool do_editor_command(text_body_type *tb, int com_id) case EC_OK_WORTHLESS: toggle_keyword(tb, FLG_WORTHLESS); break; case EC_OK_ARTIFACT: toggle_keyword(tb, FLG_ARTIFACT); break; case EC_OK_EGO: toggle_keyword(tb, FLG_EGO); break; + case EC_OK_GOOD: toggle_keyword(tb, FLG_GOOD); break; case EC_OK_NAMELESS: toggle_keyword(tb, FLG_NAMELESS); break; + case EC_OK_AVERAGE: toggle_keyword(tb, FLG_AVERAGE); break; + case EC_OK_RARE: toggle_keyword(tb, FLG_RARE); break; + case EC_OK_COMMON: toggle_keyword(tb, FLG_COMMON); break; case EC_OK_WANTED: toggle_keyword(tb, FLG_WANTED); break; case EC_OK_UNIQUE: toggle_keyword(tb, FLG_UNIQUE); break; case EC_OK_HUMAN: toggle_keyword(tb, FLG_HUMAN); break; @@ -5748,6 +6187,11 @@ void do_cmd_edit_autopick(void) tb->dirty_line = -1; tb->filename_mode = PT_DEFAULT; + if (turn < old_autosave_turn) + { + while (old_autosave_turn > turn) old_autosave_turn -= TURNS_PER_TICK * TOWN_DAWN; + } + /* Autosave */ if (turn > old_autosave_turn + 100L) { @@ -5759,7 +6203,7 @@ void do_cmd_edit_autopick(void) update_playtime(); /* Free old entries */ - init_autopicker(); + init_autopick(); /* Command Description of the 'Last Destroyed Item' */ if (autopick_last_destroyed_object.k_idx) @@ -5824,7 +6268,7 @@ void do_cmd_edit_autopick(void) tb->old_hgt = tb->hgt; /* Get a command */ - key = inkey_special(); + key = inkey_special(TRUE); /* Special keys */ if (key & SKEY_MASK) @@ -5886,7 +6330,7 @@ void do_cmd_edit_autopick(void) kill_yank_chain(tb); /* Reload autopick pref */ - process_pickpref_file(buf); + process_autopick_file(buf); /* HACK -- reset start_time so that playtime is not increase while edit */ start_time = time(NULL);