… | |
… | |
950 | } |
950 | } |
951 | |
951 | |
952 | return 0; |
952 | return 0; |
953 | } |
953 | } |
954 | |
954 | |
955 | /* op should be a player. |
|
|
956 | * we return the object the player has marked with the 'mark' command |
|
|
957 | * below. If no match is found (or object has changed), we return |
|
|
958 | * NULL. We leave it up to the calling function to print messages if |
|
|
959 | * nothing is found. |
|
|
960 | */ |
|
|
961 | object * |
|
|
962 | find_marked_object (object *op) |
|
|
963 | { |
|
|
964 | object *tmp; |
|
|
965 | |
|
|
966 | if (!op || !op->contr) |
|
|
967 | return NULL; |
|
|
968 | |
|
|
969 | if (!op->contr->mark) |
|
|
970 | { |
|
|
971 | /* new_draw_info(NDI_UNIQUE,0,op,"You have no marked object");*/ |
|
|
972 | return 0; |
|
|
973 | } |
|
|
974 | |
|
|
975 | /* This may seem like overkill, but we need to make sure that they |
|
|
976 | * player hasn't dropped the item. We use count on the off chance that |
|
|
977 | * an item got reincarnated at some point. |
|
|
978 | */ |
|
|
979 | for (tmp = op->inv; tmp; tmp = tmp->below) |
|
|
980 | { |
|
|
981 | if (tmp->invisible) |
|
|
982 | continue; |
|
|
983 | |
|
|
984 | if (tmp == op->contr->mark) |
|
|
985 | { |
|
|
986 | if (!tmp->destroyed ()) |
|
|
987 | return tmp; |
|
|
988 | else |
|
|
989 | { |
|
|
990 | op->contr->mark = 0; |
|
|
991 | /* new_draw_info(NDI_UNIQUE,0,op,"You have no marked object");*/ |
|
|
992 | return 0; |
|
|
993 | } |
|
|
994 | } |
|
|
995 | } |
|
|
996 | |
|
|
997 | return 0; |
|
|
998 | } |
|
|
999 | |
|
|
1000 | std::string |
955 | std::string |
1001 | object::describe_monster (object *who) |
956 | object::describe_monster (object *who) |
1002 | { |
957 | { |
1003 | dynbuf_text buf (512, 512); |
958 | dynbuf_text buf (512, 512); |
1004 | |
959 | |
… | |
… | |
1313 | int |
1268 | int |
1314 | command_mark (object *op, char *params) |
1269 | command_mark (object *op, char *params) |
1315 | { |
1270 | { |
1316 | if (!params) |
1271 | if (!params) |
1317 | { |
1272 | { |
1318 | if (object *mark = find_marked_object (op)) |
1273 | if (object *mark = op->mark ()) |
1319 | op->statusmsg (format ("%s is marked.", query_name (mark))); |
1274 | op->statusmsg (format ("%s is marked.", query_name (mark))); |
1320 | else |
1275 | else |
1321 | op->failmsg ("You have no marked object."); |
1276 | op->failmsg ("You have no marked object."); |
1322 | } |
1277 | } |
1323 | else |
1278 | else |