ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/info.C
(Generate patch)

Comparing deliantra/server/common/info.C (file contents):
Revision 1.3 by root, Sun Sep 3 00:18:39 2006 UTC vs.
Revision 1.5 by root, Thu Sep 14 22:33:58 2006 UTC

1/*
2 * static char *rcsid_info_c =
3 * "$Id: info.C,v 1.3 2006/09/03 00:18:39 root Exp $";
4 */
5
6/* 1/*
7 CrossFire, A Multiplayer game for X-windows 2 CrossFire, A Multiplayer game for X-windows
8 3
9 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 4 Copyright (C) 2002 Mark Wedel & Crossfire Development Team
10 Copyright (C) 1992 Frank Tore Johansen 5 Copyright (C) 1992 Frank Tore Johansen
21 16
22 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
24 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 20
26 The authors can be reached via e-mail at crossfire-devel@real-time.com 21 The authors can be reached via e-mail at <crossfire@schmorp.de>
27*/ 22*/
28 23
29#include <global.h> 24#include <global.h>
30 25
31/* 26/*
35 30
36/* 31/*
37 * Dump to standard out the abilities of all monsters. 32 * Dump to standard out the abilities of all monsters.
38 */ 33 */
39 34
35void
40void dump_abilities(void) { 36dump_abilities (void)
37{
41 archetype *at; 38 archetype *at;
42 for(at = first_archetype; at; at=at->next) {
43 char *ch;
44 const char *gen_name = "";
45 archetype *gen;
46 39
47 if(!QUERY_FLAG(&at->clone,FLAG_MONSTER)) 40 for (at = first_archetype; at; at = at->next)
48 continue; 41 {
42 char *ch;
43 const char *gen_name = "";
44 archetype *gen;
49 45
50 /* Get rid of e.g. multiple black puddings */
51 if (QUERY_FLAG(&at->clone,FLAG_CHANGING)) 46 if (!QUERY_FLAG (&at->clone, FLAG_MONSTER))
52 continue; 47 continue;
53 48
49 /* Get rid of e.g. multiple black puddings */
50 if (QUERY_FLAG (&at->clone, FLAG_CHANGING))
51 continue;
52
54 for (gen = first_archetype; gen; gen = gen->next) { 53 for (gen = first_archetype; gen; gen = gen->next)
54 {
55 if (gen->clone.other_arch && gen->clone.other_arch == at) { 55 if (gen->clone.other_arch && gen->clone.other_arch == at)
56 {
56 gen_name = gen->name; 57 gen_name = gen->name;
57 break; 58 break;
59 }
58 } 60 }
61
62 ch = describe_item (&at->clone, NULL);
63#ifndef WIN32
64 printf ("%-16s|%6lld|%4d|%3d|%s|%s|%s\n", &at->clone.name, (long long) at->clone.stats.exp,
65 at->clone.stats.hp, at->clone.stats.ac, ch, &at->name, gen_name);
66#else
67 printf ("%-16s|%6I64d|%4d|%3d|%s|%s|%s\n", &at->clone.name, (long long) at->clone.stats.exp,
68 at->clone.stats.hp, at->clone.stats.ac, ch, &at->name, gen_name);
69#endif
59 } 70 }
60
61 ch = describe_item(&at->clone, NULL);
62#ifndef WIN32
63 printf("%-16s|%6lld|%4d|%3d|%s|%s|%s\n",&at->clone.name,(long long)at->clone.stats.exp,
64 at->clone.stats.hp,at->clone.stats.ac,ch,&at->name,gen_name);
65#else
66 printf("%-16s|%6I64d|%4d|%3d|%s|%s|%s\n",&at->clone.name,(long long)at->clone.stats.exp,
67 at->clone.stats.hp,at->clone.stats.ac,ch,&at->name,gen_name);
68#endif
69 }
70} 71}
71 72
72/* 73/*
73 * As dump_abilities(), but with an alternative way of output. 74 * As dump_abilities(), but with an alternative way of output.
74 */ 75 */
75 76
77void
76void print_monsters(void) { 78print_monsters (void)
79{
77 archetype *at; 80 archetype *at;
78 object *op; 81 object *op;
79 char attbuf[34]; 82 char attbuf[34];
80 int i; 83 int i;
81 84
85 printf
82 printf(" | | | | | attack | resistances |\n"); 86 (" | | | | | attack | resistances |\n");
87 printf
83 printf("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"); 88 ("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");
89 printf
84 printf("---------------------------------------------------------------------------------------------------------------------------------------------------\n"); 90 ("---------------------------------------------------------------------------------------------------------------------------------------------------\n");
85 for(at=first_archetype;at!=NULL;at=at->next) { 91 for (at = first_archetype; at != NULL; at = at->next)
92 {
86 op = arch_to_object(at); 93 op = arch_to_object (at);
87 if (QUERY_FLAG(op,FLAG_MONSTER)) { 94 if (QUERY_FLAG (op, FLAG_MONSTER))
95 {
88 bitstostring((long)op->attacktype, NROFATTACKS, attbuf); 96 bitstostring ((long) op->attacktype, NROFATTACKS, attbuf);
89 printf("%-15s|%5d|%3d|%4d|%4d|%s|",
90 &op->arch->name, op->stats.maxhp, op->stats.dam, op->stats.ac, op->stats.wc,attbuf); 97 printf ("%-15s|%5d|%3d|%4d|%4d|%s|", &op->arch->name, op->stats.maxhp, op->stats.dam, op->stats.ac, op->stats.wc, attbuf);
91 for (i=0; i<NROFATTACKS; i++) 98 for (i = 0; i < NROFATTACKS; i++)
92 printf("%4d", op->resist[i]); 99 printf ("%4d", op->resist[i]);
93 printf("|%8lld|%9d|\n", (long long)op->stats.exp, new_exp(op)); 100 printf ("|%8lld|%9d|\n", (long long) op->stats.exp, new_exp (op));
101 }
102 free_object (op);
94 } 103 }
95 free_object(op);
96 }
97} 104}
98 105
99/* 106/*
100 * Writes <num> ones and zeros to the given string based on the 107 * Writes <num> ones and zeros to the given string based on the
101 * <bits> variable. 108 * <bits> variable.
102 */ 109 */
103 110
111void
104void bitstostring(long bits, int num, char *str) 112bitstostring (long bits, int num, char *str)
105{ 113{
106 int i,j=0; 114 int i, j = 0;
107 115
108 if (num > 32) 116 if (num > 32)
109 num = 32; 117 num = 32;
110 118
111 for (i=0;i<num;i++) { 119 for (i = 0; i < num; i++)
120 {
112 if (i && (i%3)==0) { 121 if (i && (i % 3) == 0)
122 {
113 str[i+j] = ' '; 123 str[i + j] = ' ';
114 j++; 124 j++;
125 }
126 if (bits & 1)
127 str[i + j] = '1';
128 else
129 str[i + j] = '0';
130 bits >>= 1;
115 } 131 }
116 if (bits&1)
117 str[i+j] = '1';
118 else
119 str[i+j] = '0';
120 bits >>= 1;
121 }
122 str[i+j] = '\0'; 132 str[i + j] = '\0';
123 return; 133 return;
124} 134}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines