ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/info.C
Revision: 1.4
Committed: Sun Sep 10 16:00:23 2006 UTC (17 years, 9 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.3: +75 -59 lines
Log Message:
indent

File Contents

# Content
1
2 /*
3 * static char *rcsid_info_c =
4 * "$Id: info.C,v 1.3 2006-09-03 00:18:39 root Exp $";
5 */
6
7 /*
8 CrossFire, A Multiplayer game for X-windows
9
10 Copyright (C) 2002 Mark Wedel & Crossfire Development Team
11 Copyright (C) 1992 Frank Tore Johansen
12
13 This program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26
27 The authors can be reached via e-mail at crossfire-devel@real-time.com
28 */
29
30 #include <global.h>
31
32 /*
33 * The functions in this file are purely mean to generate information
34 * in differently formatted output, mainly about monsters.
35 */
36
37 /*
38 * Dump to standard out the abilities of all monsters.
39 */
40
41 void
42 dump_abilities (void)
43 {
44 archetype *at;
45
46 for (at = first_archetype; at; at = at->next)
47 {
48 char *ch;
49 const char *gen_name = "";
50 archetype *gen;
51
52 if (!QUERY_FLAG (&at->clone, FLAG_MONSTER))
53 continue;
54
55 /* Get rid of e.g. multiple black puddings */
56 if (QUERY_FLAG (&at->clone, FLAG_CHANGING))
57 continue;
58
59 for (gen = first_archetype; gen; gen = gen->next)
60 {
61 if (gen->clone.other_arch && gen->clone.other_arch == at)
62 {
63 gen_name = gen->name;
64 break;
65 }
66 }
67
68 ch = describe_item (&at->clone, NULL);
69 #ifndef WIN32
70 printf ("%-16s|%6lld|%4d|%3d|%s|%s|%s\n", &at->clone.name, (long long) at->clone.stats.exp,
71 at->clone.stats.hp, at->clone.stats.ac, ch, &at->name, gen_name);
72 #else
73 printf ("%-16s|%6I64d|%4d|%3d|%s|%s|%s\n", &at->clone.name, (long long) at->clone.stats.exp,
74 at->clone.stats.hp, at->clone.stats.ac, ch, &at->name, gen_name);
75 #endif
76 }
77 }
78
79 /*
80 * As dump_abilities(), but with an alternative way of output.
81 */
82
83 void
84 print_monsters (void)
85 {
86 archetype *at;
87 object *op;
88 char attbuf[34];
89 int i;
90
91 printf
92 (" | | | | | attack | resistances |\n");
93 printf
94 ("monster | hp |dam| ac | wc |pmf ecw adw gpd ptf|phy mag fir ele cld cfs acd drn wmg ght poi slo par tud fer cnc dep dth chs csp gpw hwd bln int | exp | new exp |\n");
95 printf
96 ("---------------------------------------------------------------------------------------------------------------------------------------------------\n");
97 for (at = first_archetype; at != NULL; at = at->next)
98 {
99 op = arch_to_object (at);
100 if (QUERY_FLAG (op, FLAG_MONSTER))
101 {
102 bitstostring ((long) op->attacktype, NROFATTACKS, attbuf);
103 printf ("%-15s|%5d|%3d|%4d|%4d|%s|", &op->arch->name, op->stats.maxhp, op->stats.dam, op->stats.ac, op->stats.wc, attbuf);
104 for (i = 0; i < NROFATTACKS; i++)
105 printf ("%4d", op->resist[i]);
106 printf ("|%8lld|%9d|\n", (long long) op->stats.exp, new_exp (op));
107 }
108 free_object (op);
109 }
110 }
111
112 /*
113 * Writes <num> ones and zeros to the given string based on the
114 * <bits> variable.
115 */
116
117 void
118 bitstostring (long bits, int num, char *str)
119 {
120 int i, j = 0;
121
122 if (num > 32)
123 num = 32;
124
125 for (i = 0; i < num; i++)
126 {
127 if (i && (i % 3) == 0)
128 {
129 str[i + j] = ' ';
130 j++;
131 }
132 if (bits & 1)
133 str[i + j] = '1';
134 else
135 str[i + j] = '0';
136 bits >>= 1;
137 }
138 str[i + j] = '\0';
139 return;
140 }