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.9 by root, Sat Dec 23 05:25:17 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 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);
59 } 65 }
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} 66}
71 67
72/* 68/*
73 * As dump_abilities(), but with an alternative way of output. 69 * As dump_abilities(), but with an alternative way of output.
74 */ 70 */
75 71
72void
76void print_monsters(void) { 73print_monsters (void)
74{
77 archetype *at; 75 archetype *at;
78 object *op; 76 object *op;
79 char attbuf[34]; 77 char attbuf[34];
80 int i; 78 int i;
81 79
80 printf
82 printf(" | | | | | attack | resistances |\n"); 81 (" | | | | | attack | resistances |\n");
82 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"); 83 ("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");
84 printf
84 printf("---------------------------------------------------------------------------------------------------------------------------------------------------\n"); 85 ("---------------------------------------------------------------------------------------------------------------------------------------------------\n");
85 for(at=first_archetype;at!=NULL;at=at->next) { 86 for (at = first_archetype; at != NULL; at = at->next)
87 {
86 op = arch_to_object(at); 88 op = arch_to_object (at);
89
87 if (QUERY_FLAG(op,FLAG_MONSTER)) { 90 if (QUERY_FLAG (op, FLAG_MONSTER))
91 {
88 bitstostring((long)op->attacktype, NROFATTACKS, attbuf); 92 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); 93 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++) 94 for (i = 0; i < NROFATTACKS; i++)
92 printf("%4d", op->resist[i]); 95 printf ("%4d", op->resist[i]);
93 printf("|%8lld|%9d|\n", (long long)op->stats.exp, new_exp(op)); 96 printf ("|%8lld|%9d|\n", (long long) op->stats.exp, new_exp (op));
97 }
98
99 op->destroy ();
94 } 100 }
95 free_object(op);
96 }
97} 101}
98 102
99/* 103/*
100 * Writes <num> ones and zeros to the given string based on the 104 * Writes <num> ones and zeros to the given string based on the
101 * <bits> variable. 105 * <bits> variable.
102 */ 106 */
103 107
108void
104void bitstostring(long bits, int num, char *str) 109bitstostring (long bits, int num, char *str)
105{ 110{
106 int i,j=0; 111 int i, j = 0;
107 112
108 if (num > 32) 113 if (num > 32)
109 num = 32; 114 num = 32;
110 115
111 for (i=0;i<num;i++) { 116 for (i = 0; i < num; i++)
117 {
112 if (i && (i%3)==0) { 118 if (i && (i % 3) == 0)
119 {
113 str[i+j] = ' '; 120 str[i + j] = ' ';
114 j++; 121 j++;
122 }
123
124 if (bits & 1)
125 str[i + j] = '1';
126 else
127 str[i + j] = '0';
128
129 bits >>= 1;
115 } 130 }
116 if (bits&1) 131
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;
124} 133}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines