ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/info.C
Revision: 1.13
Committed: Thu May 17 21:32:08 2007 UTC (17 years ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: rel-2_1
Changes since 1.12: +1 -1 lines
Log Message:
- prepare common/ for head_ => head change
- add some copyrights for files where they were missing

File Contents

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