1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
… | |
… | |
561 | * returned is good forever.) However, it makes printing statements that |
561 | * returned is good forever.) However, it makes printing statements that |
562 | * use several names much easier (don't need to store them to temp variables.) |
562 | * use several names much easier (don't need to store them to temp variables.) |
563 | * |
563 | * |
564 | * It is used extensively within messages, so should return only a prose |
564 | * It is used extensively within messages, so should return only a prose |
565 | * and short description of the item. |
565 | * and short description of the item. |
|
|
566 | * It is also used by examine/ex and similar functions. |
566 | */ |
567 | */ |
567 | const char * |
568 | const char * |
568 | query_name (const object *op) |
569 | query_name (const object *op) |
569 | { |
570 | { |
570 | int len = 0; |
571 | int len = 0; |
… | |
… | |
686 | * and sending to client. |
687 | * and sending to client. |
687 | * If plural is set, we generate the plural name of this. |
688 | * If plural is set, we generate the plural name of this. |
688 | * |
689 | * |
689 | * It is sometimes used to display messages, and usually only used to match stuff, |
690 | * It is sometimes used to display messages, and usually only used to match stuff, |
690 | * so maybe this function should be removed. |
691 | * so maybe this function should be removed. |
|
|
692 | * It is also used for client-side inventory/item descriptions. |
691 | */ |
693 | */ |
692 | const char * |
694 | const char * |
693 | query_base_name (const object *op, int plural) |
695 | query_base_name (const object *op, int plural) |
694 | { |
696 | { |
695 | if ((!plural && !op->name) || (plural && !op->name_pl)) |
697 | if ((!plural && !op->name) || (plural && !op->name_pl)) |
696 | return "(null)"; |
698 | return "(null)"; |
697 | |
699 | |
698 | if (!op->nrof && !op->weight && !op->title && !is_magical (op)) |
700 | if (!op->nrof && !op->weight && !op->title && !is_magical (op) |
|
|
701 | && op->type != EXIT) |
699 | return op->name; /* To speed things up (or make things slower?) */ |
702 | return op->name; /* To speed things up (or make things slower?) */ |
700 | |
703 | |
701 | static dynbuf_text buf; buf.clear (); |
704 | static dynbuf_text buf; buf.clear (); |
702 | |
705 | |
703 | #if 0 |
706 | #if 0 |
… | |
… | |
737 | const char *s = ring_desc (op); |
740 | const char *s = ring_desc (op); |
738 | |
741 | |
739 | if (s && *s) |
742 | if (s && *s) |
740 | buf << ' ' << s; |
743 | buf << ' ' << s; |
741 | } |
744 | } |
|
|
745 | break; |
|
|
746 | |
|
|
747 | case EXIT: |
|
|
748 | // random map exits "unfortunately" get patched, so this only works before entering |
|
|
749 | if (EXIT_PATH (op) == shstr_random_map_exit) |
|
|
750 | buf << " (random map)"; |
|
|
751 | else if (!EXIT_PATH (op)) |
|
|
752 | buf << " (closed)"; |
742 | break; |
753 | break; |
743 | |
754 | |
744 | default: |
755 | default: |
745 | if (op->magic && ((QUERY_FLAG (op, FLAG_BEEN_APPLIED) && need_identify (op)) || QUERY_FLAG (op, FLAG_IDENTIFIED))) |
756 | if (op->magic && ((QUERY_FLAG (op, FLAG_BEEN_APPLIED) && need_identify (op)) || QUERY_FLAG (op, FLAG_IDENTIFIED))) |
746 | buf.printf (" %+d", op->magic); |
757 | buf.printf (" %+d", op->magic); |
… | |
… | |
1189 | { |
1200 | { |
1190 | static dynbuf_text buf; buf.clear (); |
1201 | static dynbuf_text buf; buf.clear (); |
1191 | |
1202 | |
1192 | for (object *tmp = inv; tmp; tmp = tmp->below) |
1203 | for (object *tmp = inv; tmp; tmp = tmp->below) |
1193 | if (who && QUERY_FLAG (who, FLAG_WIZ)) |
1204 | if (who && QUERY_FLAG (who, FLAG_WIZ)) |
1194 | buf.printf ("%s- %-28.28s (%5d) %-8s\n", indent, tmp->query_name (), tmp->count, tmp->query_weight ()); |
1205 | buf.printf ("%s- %-28.28s %-8s (%9d) %s\n", indent, tmp->query_name (), tmp->query_weight (), tmp->count, tmp->uuid.c_str ()); |
1195 | else if (!tmp->invisible && (type == CONTAINER || QUERY_FLAG (tmp, FLAG_APPLIED))) |
1206 | else if (!tmp->invisible && (type == CONTAINER || QUERY_FLAG (tmp, FLAG_APPLIED))) |
1196 | buf.printf ("%s- %-36.36s %-8s\n", indent, tmp->query_name (), tmp->query_weight ()); |
1207 | buf.printf ("%s- %-36.36s %-8s\n", indent, tmp->query_name (), tmp->query_weight ()); |
1197 | |
1208 | |
1198 | if (buf.size ()) |
1209 | if (buf.size ()) |
1199 | buf.printf ("%s(total weight: %s)\n", indent, query_weight ()); |
1210 | buf.printf ("%s(total weight: %s)\n", indent, query_weight ()); |