Changeset 338
- Timestamp:
- 07/14/07 08:43:03 (1 year ago)
- Files:
-
- branches/angband-3.0.8/src/cmd4.c (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/angband-3.0.8/src/cmd4.c
r293 r338 343 343 } 344 344 345 static const char *recall_prompt(int oid) 346 { 347 return ", 'r' to recall"; 348 } 345 349 346 350 #define swap(a, b) (swapspace = (void*)(a)), ((a) = (b)), ((b) = swapspace) … … 548 552 else if (o_funcs.xattr) pvs = ", 'v' for visuals"; 549 553 550 prt(format("<dir>, 'r' to recall%s%s%s, ESC", pvs, pedit, xtra), hgt - 1, 0); 554 555 556 prt(format("<dir>%s%s%s, ESC", pvs, pedit, xtra), hgt - 1, 0); 551 557 } 552 558 … … 1035 1041 static byte *m_xattr(int oid) { return &r_info[default_join[oid].oid].x_attr; } 1036 1042 static const char *race_name(int gid) { return monster_group[gid].name; } 1037 static void mon_lore(int oid) { screen_roff(default_join[oid].oid); inkey_ex(); } 1043 1044 static void mon_lore(int oid) 1045 { 1046 /* Save the screen */ 1047 screen_save(); 1048 1049 /* Describe */ 1050 text_out_hook = text_out_to_screen; 1051 1052 /* Recall monster */ 1053 roff_top(default_join[oid].oid); 1054 Term_gotoxy(0,2); 1055 describe_monster(oid, FALSE); 1056 1057 text_out_c(TERM_L_BLUE, "\n[Press any key to continue]\n"); 1058 (void)anykey(); 1059 1060 /* Load the screen */ 1061 screen_load(); 1062 } 1038 1063 1039 1064 static void mon_summary(int gid, const int *object_list, int n, int top, int row, int col) … … 1099 1124 m_cmp_race, default_group, mon_summary}; 1100 1125 1101 member_funcs m_funcs = {display_monster, mon_lore, m_xchar, m_xattr, 0, 0, 0};1126 member_funcs m_funcs = {display_monster, mon_lore, m_xchar, m_xattr, recall_prompt, 0, 0}; 1102 1127 1103 1128 … … 1155 1180 /* Many-to-one grouping */ 1156 1181 1157 /* 1158 * Display an artifact label 1159 */ 1160 static void display_artifact(int col, int row, bool cursor, int oid) 1161 { 1162 char o_name[80]; 1182 static void get_artifact_display_name(char *o_name, size_t namelen, int a_idx) 1183 { 1163 1184 object_type object_type_body; 1164 1185 object_type *o_ptr = &object_type_body; 1165 1186 1187 /* Make fake artifact */ 1188 o_ptr = &object_type_body; 1189 object_wipe(o_ptr); 1190 make_fake_artifact(o_ptr, a_idx); 1191 1192 /* Get its name */ 1193 object_desc_spoil(o_name, namelen, o_ptr, TRUE, 0); 1194 } 1195 1196 /* 1197 * Display an artifact label 1198 */ 1199 static void display_artifact(int col, int row, bool cursor, int oid) 1200 { 1201 char o_name[80]; 1202 1166 1203 /* Choose a color */ 1167 1204 byte attr = curs_attrs[CURS_KNOWN][(int)cursor]; 1168 1205 1169 /* Get local object */ 1170 o_ptr = &object_type_body; 1171 1172 /* Wipe the object */ 1173 object_wipe(o_ptr); 1174 1175 /* Make fake artifact */ 1176 make_fake_artifact(o_ptr, oid); 1177 1178 /* Get its name */ 1179 object_desc_spoil(o_name, sizeof(o_name), o_ptr, TRUE, 0); 1206 get_artifact_display_name(o_name, sizeof o_name, oid); 1180 1207 1181 1208 /* Display the name */ … … 1208 1235 screen_save(); 1209 1236 1237 Term_gotoxy(0, 0); 1210 1238 object_info_screen(o_ptr); 1211 1239 … … 1233 1261 static int art2gid(int oid) { return obj_group_order[a_info[oid].tval]; } 1234 1262 1263 /* Check if the given artifact idx is something we should "Know" about */ 1264 static bool artifact_is_known(int a_idx) 1265 { 1266 int i; 1267 1268 /* Artifact doesn't exist at all, or not created yet */ 1269 if (!a_info[a_idx].name || a_info[a_idx].cur_num == 0) return FALSE; 1270 1271 /* Check all objects to see if it exists but hasn't been IDed */ 1272 for (i = 0; i < z_info->o_max; i++) 1273 { 1274 int a = o_list[i].name1; 1275 1276 /* If we haven't actually identified the artifact yet */ 1277 if (a && a == a_idx && !object_known_p(&o_list[i])) 1278 { 1279 return FALSE; 1280 } 1281 } 1282 1283 /* Check inventory for the same */ 1284 for (i = 0; i < INVEN_TOTAL; i++) 1285 { 1286 object_type *o_ptr = &inventory[i]; 1287 1288 /* Ignore non-objects */ 1289 if (!o_ptr->k_idx) continue; 1290 1291 1292 if (o_ptr->name1 && o_ptr->name1 == a_idx && 1293 !object_known_p(o_ptr)) 1294 { 1295 return FALSE; 1296 } 1297 } 1298 1299 return TRUE; 1300 } 1301 1235 1302 1236 1303 /* If 'artifacts' is NULL, it counts the number of known artifacts, otherwise … … 1239 1306 { 1240 1307 int a_count = 0; 1241 int i,j;1308 int j; 1242 1309 1243 1310 if (artifacts) … … 1246 1313 for (j = 0; j < z_info->a_max; j++) 1247 1314 { 1248 /* If the artifact has been created (or we're cheating) */ 1249 if ((cheat_xtra || a_info[j].cur_num) && a_info[j].name) 1250 { 1251 bool valid = TRUE; 1252 1253 for (i = 0; !cheat_xtra && i < z_info->o_max; i++) 1254 { 1255 int a = o_list[i].name1; 1256 1257 /* If we haven't actually identified the artifact yet */ 1258 if (a && a == j && !object_known_p(&o_list[i])) 1259 { 1260 valid = FALSE; 1261 } 1262 } 1263 1264 if (valid) 1265 { 1266 if (artifacts) 1267 artifacts[a_count++] = j; 1268 else 1269 a_count++; 1270 } 1315 /* Artifact doesn't exist */ 1316 if (!a_info[j].name) continue; 1317 1318 if (cheat_xtra || artifact_is_known(j)) 1319 { 1320 if (artifacts) 1321 artifacts[a_count++] = j; 1322 else 1323 a_count++; 1271 1324 } 1272 1325 } … … 1282 1335 /* HACK -- should be TV_MAX */ 1283 1336 group_funcs obj_f = {TV_GOLD, FALSE, kind_name, a_cmp_tval, art2gid, 0}; 1284 member_funcs art_f = {display_artifact, desc_art_fake, 0, 0, 0, 0, 0};1337 member_funcs art_f = {display_artifact, desc_art_fake, 0, 0, recall_prompt, 0, 0}; 1285 1338 1286 1339 int *artifacts; … … 1342 1395 /* Begin recall */ 1343 1396 Term_gotoxy(0, 1); 1397 text_out("\n"); 1398 1344 1399 if (e_ptr->text) 1345 1400 { … … 1369 1424 Term_flush(); 1370 1425 1371 (void)inkey_ex(); 1426 text_out_c(TERM_L_BLUE, "\n\n[Press any key to continue]\n"); 1427 (void)anykey(); 1372 1428 1373 1429 screen_load(); … … 1396 1452 {TV_GOLD, FALSE, ego_grp_name, e_cmp_tval, default_group, 0}; 1397 1453 1398 member_funcs ego_f = {display_ego_item, desc_ego_fake, 0, 0, 0, 0, 0};1454 member_funcs ego_f = {display_ego_item, desc_ego_fake, 0, 0, recall_prompt, 0, 0}; 1399 1455 1400 1456 int *egoitems; … … 1432 1488 /* =================== ORDINARY OBJECTS ==================================== */ 1433 1489 /* Many-to-one grouping */ 1490 1491 /* 1492 * Looks up an artifact idx given an object_kind *that's already known 1493 * to be an artifact*. Behaviour is distinctly unfriendly if passed 1494 * flavours which don't correspond to an artifact. 1495 */ 1496 static int get_artifact_from_kind(object_kind *k_ptr) 1497 { 1498 int i; 1499 1500 assert(k_ptr->flags3 & TR3_INSTA_ART); 1501 1502 /* Look for the corresponding artifact */ 1503 for (i = 0; i < z_info->a_max; i++) 1504 { 1505 if (k_ptr->tval == a_info[i].tval && 1506 k_ptr->sval == a_info[i].sval) 1507 { 1508 break; 1509 } 1510 } 1511 1512 assert(i < z_info->a_max); 1513 return i; 1514 } 1434 1515 1435 1516 /* … … 1460 1541 } 1461 1542 1462 /* Tidy name */ 1463 object_kind_name(o_name, sizeof o_name, k_idx, cheat_know); 1543 /* Display known artifacts differently */ 1544 if ((k_ptr->flags3 & TR3_INSTA_ART) && artifact_is_known(get_artifact_from_kind(k_ptr))) 1545 { 1546 get_artifact_display_name(o_name, sizeof(o_name), get_artifact_from_kind(k_ptr)); 1547 } 1548 else 1549 { 1550 /* Tidy name */ 1551 object_kind_name(o_name, sizeof o_name, k_idx, cheat_know); 1552 } 1464 1553 1465 1554 /* Display the name */ … … 1485 1574 static void desc_obj_fake(int k_idx) 1486 1575 { 1576 object_kind *k_ptr = &k_info[k_idx]; 1487 1577 object_type object_type_body; 1488 1578 object_type *o_ptr = &object_type_body; 1579 1580 /* Check for known artifacts, display them as artifacts */ 1581 if ((k_ptr->flags3 & TR3_INSTA_ART) && artifact_is_known(get_artifact_from_kind(k_ptr))) 1582 { 1583 desc_art_fake(get_artifact_from_kind(k_ptr)); 1584 return; 1585 } 1489 1586 1490 1587 /* Wipe the object */ … … 1568 1665 object_kind *k_ptr = &k_info[oid]; 1569 1666 s16b idx = get_autoinscription_index(oid); 1570 1571 const char *no_insc = ", ' {'";1572 const char *with_insc = ", ' {', '}'";1667 1668 const char *no_insc = ", 'r' to recall, '{'"; 1669 const char *with_insc = ", 'r' to recall, '{', '}'"; 1573 1670 1574 1671
