1 | /* |
1 | /* |
2 | * static char *rcsid_c_misc_c = |
2 | * static char *rcsid_c_misc_c = |
3 | * "$Id: c_misc.C,v 1.5 2006/09/03 00:18:42 root Exp $"; |
3 | * "$Id: c_misc.C,v 1.6 2006/09/04 11:08:00 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
114 | bug_report(buf); |
114 | bug_report(buf); |
115 | LOG(llevError,"%s\n",buf); |
115 | LOG(llevError,"%s\n",buf); |
116 | new_draw_info(NDI_ALL | NDI_UNIQUE, 1, NULL, buf); |
116 | new_draw_info(NDI_ALL | NDI_UNIQUE, 1, NULL, buf); |
117 | new_draw_info(NDI_UNIQUE, 0,op, "OK, thanks!"); |
117 | new_draw_info(NDI_UNIQUE, 0,op, "OK, thanks!"); |
118 | return 1; |
118 | return 1; |
119 | } |
|
|
120 | |
|
|
121 | |
|
|
122 | void malloc_info(object *op) { |
|
|
123 | int ob_used=count_used(),ob_free=count_free(),players,nrofmaps; |
|
|
124 | int nrm=0,mapmem=0,anr,anims,sum_alloc=0,sum_used=0,i,tlnr, alnr; |
|
|
125 | treasurelist *tl; |
|
|
126 | player *pl; |
|
|
127 | mapstruct *m; |
|
|
128 | archetype *at; |
|
|
129 | artifactlist *al; |
|
|
130 | |
|
|
131 | for(tl=first_treasurelist,tlnr=0;tl!=NULL;tl=tl->next,tlnr++); |
|
|
132 | for(al=first_artifactlist, alnr=0; al!=NULL; al=al->next, alnr++); |
|
|
133 | |
|
|
134 | for(at=first_archetype,anr=0,anims=0;at!=NULL; |
|
|
135 | at=at->more==NULL?at->next:at->more,anr++); |
|
|
136 | |
|
|
137 | for (i=1; i<num_animations; i++) |
|
|
138 | anims += animations[i].num_animations; |
|
|
139 | |
|
|
140 | for(pl=first_player,players=0;pl!=NULL;pl=pl->next,players++); |
|
|
141 | for(m=first_map,nrofmaps=0;m!=NULL;m=m->next,nrofmaps++) |
|
|
142 | if(m->in_memory == MAP_IN_MEMORY) { |
|
|
143 | mapmem+=MAP_WIDTH(m)*MAP_HEIGHT(m)*(sizeof(object *)+sizeof(MapSpace)); |
|
|
144 | nrm++; |
|
|
145 | } |
|
|
146 | sprintf(errmsg,"Sizeof: object=%ld player=%ld map=%ld", |
|
|
147 | (long)sizeof(object),(long)sizeof(player),(long)sizeof(mapstruct)); |
|
|
148 | new_draw_info(NDI_UNIQUE, 0,op,errmsg); |
|
|
149 | sprintf(errmsg,"%4d used objects: %8d",ob_used,i=(ob_used*sizeof(object))); |
|
|
150 | new_draw_info(NDI_UNIQUE, 0,op,errmsg); |
|
|
151 | sum_used+=i; sum_alloc+=i; |
|
|
152 | sprintf(errmsg,"%4d free objects: %8d",ob_free,i=(ob_free*sizeof(object))); |
|
|
153 | new_draw_info(NDI_UNIQUE, 0,op,errmsg); |
|
|
154 | sprintf(errmsg,"%4d active objects: %8d",count_active(), 0); |
|
|
155 | new_draw_info(NDI_UNIQUE, 0,op,errmsg); |
|
|
156 | sum_alloc+=i; |
|
|
157 | sprintf(errmsg,"%4d players: %8d",players,i=(players*sizeof(player))); |
|
|
158 | new_draw_info(NDI_UNIQUE, 0,op,errmsg); |
|
|
159 | sum_alloc+=i; sum_used+=i; |
|
|
160 | |
|
|
161 | |
|
|
162 | sprintf(errmsg,"%4d maps allocated: %8d",nrofmaps, |
|
|
163 | i=(nrofmaps*sizeof(mapstruct))); |
|
|
164 | new_draw_info(NDI_UNIQUE, 0,op,errmsg); |
|
|
165 | sum_alloc+=i; sum_used+=nrm*sizeof(mapstruct); |
|
|
166 | sprintf(errmsg,"%4d maps in memory: %8d",nrm,mapmem); |
|
|
167 | new_draw_info(NDI_UNIQUE, 0,op,errmsg); |
|
|
168 | sum_alloc+=mapmem; sum_used+=mapmem; |
|
|
169 | sprintf(errmsg,"%4d archetypes: %8d",anr,i=(anr*sizeof(archetype))); |
|
|
170 | new_draw_info(NDI_UNIQUE, 0,op,errmsg); |
|
|
171 | sum_alloc+=i; sum_used+=i; |
|
|
172 | sprintf(errmsg,"%4d animations: %8d",anims,i=(anims*sizeof(Fontindex))); |
|
|
173 | new_draw_info(NDI_UNIQUE, 0,op,errmsg); |
|
|
174 | sum_alloc+=i; sum_used+=i; |
|
|
175 | |
|
|
176 | sprintf(errmsg,"%4d treasurelists %8d",tlnr,i=(tlnr*sizeof(treasurelist))); |
|
|
177 | new_draw_info(NDI_UNIQUE, 0,op,errmsg); |
|
|
178 | sum_alloc+=i; sum_used+=i; |
|
|
179 | sprintf(errmsg,"%4ld treasures %8d",nroftreasures, |
|
|
180 | i=(nroftreasures*sizeof(treasure))); |
|
|
181 | new_draw_info(NDI_UNIQUE, 0,op,errmsg); |
|
|
182 | sum_alloc+=i; sum_used+=i; |
|
|
183 | sprintf(errmsg,"%4ld artifacts %8d", nrofartifacts, |
|
|
184 | i=(nrofartifacts*sizeof(artifact))); |
|
|
185 | new_draw_info(NDI_UNIQUE, 0,op, errmsg); |
|
|
186 | sum_alloc+=i; sum_used +=i; |
|
|
187 | sprintf(errmsg,"%4ld artifacts strngs %8d", nrofallowedstr, |
|
|
188 | i=(nrofallowedstr*sizeof(linked_char))); |
|
|
189 | new_draw_info(NDI_UNIQUE, 0,op, errmsg); |
|
|
190 | sum_alloc += i;sum_used+=i; |
|
|
191 | sprintf(errmsg,"%4d artifactlists %8d",alnr,i=(alnr*sizeof(artifactlist))); |
|
|
192 | new_draw_info(NDI_UNIQUE, 0,op,errmsg); |
|
|
193 | sum_alloc += i; sum_used += i; |
|
|
194 | |
|
|
195 | sprintf(errmsg,"Total space allocated:%8d",sum_alloc); |
|
|
196 | new_draw_info(NDI_UNIQUE, 0,op,errmsg); |
|
|
197 | sprintf(errmsg,"Total space used: %8d",sum_used); |
|
|
198 | new_draw_info(NDI_UNIQUE, 0,op,errmsg); |
|
|
199 | } |
119 | } |
200 | |
120 | |
201 | /* |
121 | /* |
202 | * Pretty much identical to current map_info, but on a bigger scale |
122 | * Pretty much identical to current map_info, but on a bigger scale |
203 | * This function returns the name of the players current region, and |
123 | * This function returns the name of the players current region, and |
… | |
… | |
472 | new_draw_info(NDI_UNIQUE, 0, op, "You are now AFK"); |
392 | new_draw_info(NDI_UNIQUE, 0, op, "You are now AFK"); |
473 | } |
393 | } |
474 | return 1; |
394 | return 1; |
475 | } |
395 | } |
476 | |
396 | |
477 | int command_malloc (object *op, char *params) |
|
|
478 | { |
|
|
479 | malloc_info(op); |
|
|
480 | return 1; |
|
|
481 | } |
|
|
482 | |
|
|
483 | int command_mapinfo (object *op, char *params) |
397 | int command_mapinfo (object *op, char *params) |
484 | { |
398 | { |
485 | current_map_info(op); |
399 | current_map_info(op); |
486 | return 1; |
400 | return 1; |
487 | } |
401 | } |