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.1 by elmex, Sun Aug 13 17:16:00 2006 UTC vs.
Revision 1.14 by root, Mon May 28 21:21:40 2007 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines