ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/info.C
Revision: 1.3
Committed: Sun Sep 3 00:18:39 2006 UTC (17 years, 8 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.2: +7 -8 lines
Log Message:
THIS CODE WILL NOT COMPILE
use the STABLE tag instead.

- major changes in object lifetime and memory management
- replaced manual refcounting by shstr class
- removed quest system
- many optimisations
- major changes

File Contents

# User Rev Content
1 elmex 1.1 /*
2     * static char *rcsid_info_c =
3 root 1.3 * "$Id: info.C,v 1.2 2006-08-29 08:01:35 root Exp $";
4 elmex 1.1 */
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    
29     #include <global.h>
30    
31     /*
32     * The functions in this file are purely mean to generate information
33     * in differently formatted output, mainly about monsters.
34     */
35    
36     /*
37     * Dump to standard out the abilities of all monsters.
38     */
39    
40     void dump_abilities(void) {
41     archetype *at;
42     for(at = first_archetype; at; at=at->next) {
43     char *ch;
44     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     if (gen->clone.other_arch && gen->clone.other_arch == at) {
56     gen_name = gen->name;
57 root 1.2 break;
58 elmex 1.1 }
59     }
60    
61     ch = describe_item(&at->clone, NULL);
62     #ifndef WIN32
63 root 1.3 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 elmex 1.1 #else
66 root 1.3 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 elmex 1.1 #endif
69     }
70     }
71    
72     /*
73     * As dump_abilities(), but with an alternative way of output.
74     */
75    
76     void print_monsters(void) {
77     archetype *at;
78     object *op;
79     char attbuf[34];
80     int i;
81    
82     printf(" | | | | | attack | resistances |\n");
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");
84     printf("---------------------------------------------------------------------------------------------------------------------------------------------------\n");
85     for(at=first_archetype;at!=NULL;at=at->next) {
86 root 1.2 op = arch_to_object(at);
87     if (QUERY_FLAG(op,FLAG_MONSTER)) {
88     bitstostring((long)op->attacktype, NROFATTACKS, attbuf);
89     printf("%-15s|%5d|%3d|%4d|%4d|%s|",
90 root 1.3 &op->arch->name, op->stats.maxhp, op->stats.dam, op->stats.ac, op->stats.wc,attbuf);
91 root 1.2 for (i=0; i<NROFATTACKS; i++)
92     printf("%4d", op->resist[i]);
93 root 1.3 printf("|%8lld|%9d|\n", (long long)op->stats.exp, new_exp(op));
94 elmex 1.1 }
95     free_object(op);
96     }
97     }
98    
99     /*
100     * Writes <num> ones and zeros to the given string based on the
101     * <bits> variable.
102     */
103    
104     void bitstostring(long bits, int num, char *str)
105     {
106     int i,j=0;
107    
108     if (num > 32)
109     num = 32;
110    
111     for (i=0;i<num;i++) {
112     if (i && (i%3)==0) {
113     str[i+j] = ' ';
114     j++;
115     }
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';
123     return;
124     }