1 | /* |
1 | /* |
2 | CrossFire, A Multiplayer game for X-windows |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | |
3 | * |
|
|
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | |
7 | * |
7 | This program is free software; you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | it under the terms of the GNU General Public License as published by |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | the Free Software Foundation; either version 2 of the License, or |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | (at your option) any later version. |
11 | * option) any later version. |
11 | |
12 | * |
12 | This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
16 | |
17 | * |
17 | You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the Affero GNU General Public License |
18 | along with this program; if not, write to the Free Software |
19 | * and the GNU General Public License along with this program. If not, see |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * <http://www.gnu.org/licenses/>. |
20 | |
21 | * |
21 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | */ |
23 | */ |
23 | |
24 | |
24 | #include <global.h> |
25 | #include <global.h> |
25 | #include <loader.h> |
26 | #include <loader.h> |
26 | #ifndef __CEXTRACT__ |
|
|
27 | # include <sproto.h> |
27 | #include <sproto.h> |
28 | #endif |
|
|
29 | |
28 | |
30 | extern weathermap_t **weathermap; |
|
|
31 | |
|
|
32 | /* Handles misc. input request - things like hash table, malloc, maps, |
29 | /* Handles misc. input request - things like hash table, malloc, maps, etc */ |
33 | * who, etc. |
|
|
34 | */ |
|
|
35 | |
|
|
36 | void |
|
|
37 | map_info (object *op, char *search) |
|
|
38 | { |
|
|
39 | maptile *m; |
|
|
40 | char buf[MAX_BUF], map_path[MAX_BUF]; |
|
|
41 | long sec = seconds (); |
|
|
42 | |
|
|
43 | new_draw_info_format (NDI_UNIQUE, 0, op, "Current time is: %02ld:%02ld:%02ld.", (sec % 86400) / 3600, (sec % 3600) / 60, sec % 60); |
|
|
44 | new_draw_info (NDI_UNIQUE, 0, op, "Path Pl PlM IM TO Dif Reset"); |
|
|
45 | for (m = first_map; m != NULL; m = m->next) |
|
|
46 | { |
|
|
47 | |
|
|
48 | if (search && strstr (m->path, search) == NULL) |
|
|
49 | continue; /* Skip unwanted maps */ |
|
|
50 | /* Print out the last 18 characters of the map name... */ |
|
|
51 | if (strlen (m->path) <= 18) |
|
|
52 | strcpy (map_path, m->path); |
|
|
53 | else |
|
|
54 | strcpy (map_path, m->path + strlen (m->path) - 18); |
|
|
55 | sprintf (buf, "%-18.18s %2d %2d %1d %4d %2d %02d:%02d:%02d", |
|
|
56 | map_path, m->players, players_on_map (m, FALSE), |
|
|
57 | m->in_memory, m->timeout, m->difficulty, |
|
|
58 | (MAP_WHEN_RESET (m) % 86400) / 3600, (MAP_WHEN_RESET (m) % 3600) / 60, MAP_WHEN_RESET (m) % 60); |
|
|
59 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
60 | } |
|
|
61 | } |
|
|
62 | |
|
|
63 | /* This command dumps the body information for object *op. |
|
|
64 | * it doesn't care what the params are. |
|
|
65 | * This is mostly meant as a debug command. |
|
|
66 | */ |
|
|
67 | int |
|
|
68 | command_body (object *op, char *params) |
|
|
69 | { |
|
|
70 | int i; |
|
|
71 | |
|
|
72 | /* Too hard to try and make a header that lines everything up, so just |
|
|
73 | * give a description. |
|
|
74 | */ |
|
|
75 | new_draw_info (NDI_UNIQUE, 0, op, "The first column is the name of the body location."); |
|
|
76 | new_draw_info (NDI_UNIQUE, 0, op, "The second column is how many of those locations your body has."); |
|
|
77 | new_draw_info (NDI_UNIQUE, 0, op, "The third column is how many slots in that location are available."); |
|
|
78 | for (i = 0; i < NUM_BODY_LOCATIONS; i++) |
|
|
79 | { |
|
|
80 | /* really debugging - normally body_used should not be set to anything |
|
|
81 | * if body_info isn't also set. |
|
|
82 | */ |
|
|
83 | if (op->body_info[i] || op->body_used[i]) |
|
|
84 | { |
|
|
85 | new_draw_info_format (NDI_UNIQUE, 0, op, "%-30s %5d %5d", body_locations[i].use_name, op->body_info[i], op->body_used[i]); |
|
|
86 | } |
|
|
87 | } |
|
|
88 | if (!QUERY_FLAG (op, FLAG_USE_ARMOUR)) |
|
|
89 | new_draw_info (NDI_UNIQUE, 0, op, "You are not allowed to wear armor"); |
|
|
90 | if (!QUERY_FLAG (op, FLAG_USE_WEAPON)) |
|
|
91 | new_draw_info (NDI_UNIQUE, 0, op, "You are not allowed to use weapons"); |
|
|
92 | |
|
|
93 | return 1; |
|
|
94 | } |
|
|
95 | |
|
|
96 | |
|
|
97 | int |
|
|
98 | command_motd (object *op, char *params) |
|
|
99 | { |
|
|
100 | display_motd (op); |
|
|
101 | return 1; |
|
|
102 | } |
|
|
103 | |
|
|
104 | int |
|
|
105 | command_bug (object *op, char *params) |
|
|
106 | { |
|
|
107 | char buf[MAX_BUF]; |
|
|
108 | |
|
|
109 | if (params == NULL) |
|
|
110 | { |
|
|
111 | new_draw_info (NDI_UNIQUE, 0, op, "what bugs?"); |
|
|
112 | return 1; |
|
|
113 | } |
|
|
114 | strcpy (buf, op->name); |
|
|
115 | strcat (buf, " bug-reports: "); |
|
|
116 | strncat (buf, ++params, MAX_BUF - strlen (buf)); |
|
|
117 | buf[MAX_BUF - 1] = '\0'; |
|
|
118 | bug_report (buf); |
|
|
119 | LOG (llevError, "%s\n", buf); |
|
|
120 | new_draw_info (NDI_ALL | NDI_UNIQUE, 1, NULL, buf); |
|
|
121 | new_draw_info (NDI_UNIQUE, 0, op, "OK, thanks!"); |
|
|
122 | return 1; |
|
|
123 | } |
|
|
124 | |
|
|
125 | /* |
|
|
126 | * Pretty much identical to current map_info, but on a bigger scale |
|
|
127 | * This function returns the name of the players current region, and |
|
|
128 | * a description of it. It is there merely for flavour text. |
|
|
129 | */ |
|
|
130 | void |
|
|
131 | current_region_info (object *op) |
|
|
132 | { |
|
|
133 | /* |
|
|
134 | * Ok I /suppose/ I should write a seperate function for this, but it isn't |
|
|
135 | * going to be /that/ slow, and won't get called much |
|
|
136 | */ |
|
|
137 | region *r = get_region_by_name (get_name_of_region_for_map (op->map)); |
|
|
138 | |
|
|
139 | if (!r) |
|
|
140 | return; |
|
|
141 | /* This should only be possible if regions are not operating on this server. */ |
|
|
142 | |
|
|
143 | new_draw_info_format (NDI_UNIQUE, 0, op, "You are in %s. \n %s", get_region_longname (r), get_region_msg (r)); |
|
|
144 | } |
|
|
145 | |
|
|
146 | void |
|
|
147 | current_map_info (object *op) |
|
|
148 | { |
|
|
149 | maptile *m = op->map; |
|
|
150 | |
|
|
151 | if (!m) |
|
|
152 | return; |
|
|
153 | |
|
|
154 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s (%s) in %s", m->name, m->path, get_name_of_region_for_map (m)); |
|
|
155 | |
|
|
156 | if (QUERY_FLAG (op, FLAG_WIZ)) |
|
|
157 | { |
|
|
158 | new_draw_info_format (NDI_UNIQUE, 0, op, |
|
|
159 | "players:%d difficulty:%d size:%dx%d start:%dx%d timeout %ld", |
|
|
160 | m->players, m->difficulty, MAP_WIDTH (m), MAP_HEIGHT (m), MAP_ENTER_X (m), MAP_ENTER_Y (m), MAP_TIMEOUT (m)); |
|
|
161 | |
|
|
162 | } |
|
|
163 | if (m->msg) |
|
|
164 | new_draw_info (NDI_UNIQUE, NDI_NAVY, op, m->msg); |
|
|
165 | } |
|
|
166 | |
|
|
167 | #ifdef DEBUG_MALLOC_LEVEL |
|
|
168 | int |
|
|
169 | command_malloc_verify (object *op, char *parms) |
|
|
170 | { |
|
|
171 | extern int malloc_verify (void); |
|
|
172 | |
|
|
173 | if (!malloc_verify ()) |
|
|
174 | new_draw_info (NDI_UNIQUE, 0, op, "Heap is corrupted."); |
|
|
175 | else |
|
|
176 | new_draw_info (NDI_UNIQUE, 0, op, "Heap checks out OK."); |
|
|
177 | return 1; |
|
|
178 | } |
|
|
179 | #endif |
|
|
180 | |
|
|
181 | int |
|
|
182 | command_whereabouts (object *op, char *params) |
|
|
183 | { |
|
|
184 | |
|
|
185 | region *reg; |
|
|
186 | player *pl; |
|
|
187 | |
|
|
188 | /* |
|
|
189 | * reset the counter on the region, then use it to store the number of |
|
|
190 | * players there. |
|
|
191 | * I don't know how thread-safe this would be, I suspect not very.... |
|
|
192 | */ |
|
|
193 | for (reg = first_region; reg != NULL; reg = reg->next) |
|
|
194 | { |
|
|
195 | reg->counter = 0; |
|
|
196 | } |
|
|
197 | for (pl = first_player; pl != NULL; pl = pl->next) |
|
|
198 | if (pl->ob->map != NULL) |
|
|
199 | get_region_by_map (pl->ob->map)->counter++; |
|
|
200 | |
|
|
201 | /* we only want to print out by places with a 'longname' field... */ |
|
|
202 | for (reg = first_region; reg != NULL; reg = reg->next) |
|
|
203 | { |
|
|
204 | if (reg->longname == NULL && reg->counter > 0) |
|
|
205 | { |
|
|
206 | if (reg->parent != NULL) |
|
|
207 | { |
|
|
208 | reg->parent->counter += reg->counter; |
|
|
209 | reg->counter = 0; |
|
|
210 | } |
|
|
211 | else /*uh oh, we shouldn't be here. */ |
|
|
212 | LOG (llevError, "command_whereabouts() Region %s with no longname has no parent", reg->name); |
|
|
213 | } |
|
|
214 | } |
|
|
215 | new_draw_info_format (NDI_UNIQUE, 0, op, "In the world currently there are:"); |
|
|
216 | for (reg = first_region; reg != NULL; reg = reg->next) |
|
|
217 | if (reg->counter > 0) |
|
|
218 | new_draw_info_format (NDI_UNIQUE, 0, op, "%u players in %s", reg->counter, get_region_longname (reg)); |
|
|
219 | return 1; |
|
|
220 | } |
|
|
221 | |
30 | |
222 | typedef struct |
31 | typedef struct |
223 | { |
32 | { |
224 | char namebuf[MAX_BUF]; |
33 | char namebuf[MAX_BUF]; |
225 | int login_order; |
34 | int login_order; |
226 | } chars_names; |
35 | } chars_names; |
227 | |
36 | |
228 | /*local functon for qsort comparison*/ |
|
|
229 | static int |
|
|
230 | name_cmp (const chars_names * c1, const chars_names * c2) |
|
|
231 | { |
|
|
232 | return strcasecmp (c1->namebuf, c2->namebuf); |
|
|
233 | } |
|
|
234 | |
|
|
235 | int |
|
|
236 | command_afk (object *op, char *params) |
|
|
237 | { |
|
|
238 | if QUERY_FLAG |
|
|
239 | (op, FLAG_AFK) |
|
|
240 | { |
|
|
241 | CLEAR_FLAG (op, FLAG_AFK); |
|
|
242 | new_draw_info (NDI_UNIQUE, 0, op, "You are no longer AFK"); |
|
|
243 | } |
|
|
244 | else |
|
|
245 | { |
|
|
246 | SET_FLAG (op, FLAG_AFK); |
|
|
247 | new_draw_info (NDI_UNIQUE, 0, op, "You are now AFK"); |
|
|
248 | } |
|
|
249 | return 1; |
|
|
250 | } |
|
|
251 | |
|
|
252 | int |
|
|
253 | command_mapinfo (object *op, char *params) |
|
|
254 | { |
|
|
255 | current_map_info (op); |
|
|
256 | return 1; |
|
|
257 | } |
|
|
258 | |
|
|
259 | int |
|
|
260 | command_whereami (object *op, char *params) |
|
|
261 | { |
|
|
262 | current_region_info (op); |
|
|
263 | return 1; |
|
|
264 | } |
|
|
265 | |
|
|
266 | int |
|
|
267 | command_maps (object *op, char *params) |
|
|
268 | { |
|
|
269 | map_info (op, params); |
|
|
270 | return 1; |
|
|
271 | } |
|
|
272 | |
|
|
273 | int |
37 | int |
274 | command_time (object *op, char *params) |
38 | command_time (object *op, char *params) |
275 | { |
39 | { |
276 | print_tod (op); |
40 | print_tod (op); |
277 | return 1; |
|
|
278 | } |
|
|
279 | |
|
|
280 | int |
|
|
281 | command_weather (object *op, char *params) |
|
|
282 | { |
|
|
283 | int wx, wy, temp, sky; |
|
|
284 | char buf[MAX_BUF]; |
|
|
285 | |
|
|
286 | if (settings.dynamiclevel < 1) |
|
|
287 | return 1; |
|
|
288 | |
|
|
289 | if (op->map == NULL) |
|
|
290 | return 1; |
|
|
291 | |
|
|
292 | if (worldmap_to_weathermap (op->x, op->y, &wx, &wy, op->map) != 0) |
|
|
293 | return 1; |
|
|
294 | |
|
|
295 | if (QUERY_FLAG (op, FLAG_WIZ)) |
|
|
296 | { |
|
|
297 | /* dump the weather, Dm style! Yo! */ |
|
|
298 | new_draw_info_format (NDI_UNIQUE, 0, op, "Real temp: %d", real_world_temperature (op->x, op->y, op->map)); |
|
|
299 | new_draw_info_format (NDI_UNIQUE, 0, op, "Base temp: %d", weathermap[wx][wy].temp); |
|
|
300 | new_draw_info_format (NDI_UNIQUE, 0, op, "Humid: %d", weathermap[wx][wy].humid); |
|
|
301 | new_draw_info_format (NDI_UNIQUE, 0, op, "Wind: dir=%d speed=%d", weathermap[wx][wy].winddir, weathermap[wx][wy].windspeed); |
|
|
302 | new_draw_info_format (NDI_UNIQUE, 0, op, "Pressure: %d", weathermap[wx][wy].pressure); |
|
|
303 | new_draw_info_format (NDI_UNIQUE, 0, op, "Avg Elevation: %d", weathermap[wx][wy].avgelev); |
|
|
304 | new_draw_info_format (NDI_UNIQUE, 0, op, "Rainfall: %d Water: %d", weathermap[wx][wy].rainfall, weathermap[wx][wy].water); |
|
|
305 | } |
|
|
306 | |
|
|
307 | temp = real_world_temperature (op->x, op->y, op->map); |
|
|
308 | new_draw_info_format (NDI_UNIQUE, 0, op, "It's currently %d degrees " "Centigrade out.", temp); |
|
|
309 | |
|
|
310 | /* humid */ |
|
|
311 | if (weathermap[wx][wy].humid < 20) |
|
|
312 | new_draw_info (NDI_UNIQUE, 0, op, "It is very dry."); |
|
|
313 | else if (weathermap[wx][wy].humid < 40) |
|
|
314 | new_draw_info (NDI_UNIQUE, 0, op, "It is very comfortable today."); |
|
|
315 | else if (weathermap[wx][wy].humid < 60) |
|
|
316 | new_draw_info (NDI_UNIQUE, 0, op, "It is a bit muggy."); |
|
|
317 | else if (weathermap[wx][wy].humid < 80) |
|
|
318 | new_draw_info (NDI_UNIQUE, 0, op, "It is muggy."); |
|
|
319 | else |
|
|
320 | new_draw_info (NDI_UNIQUE, 0, op, "It is uncomfortably muggy."); |
|
|
321 | |
|
|
322 | /* wind */ |
|
|
323 | switch (weathermap[wx][wy].winddir) |
|
|
324 | { |
|
|
325 | case 1: |
|
|
326 | sprintf (buf, "north"); |
|
|
327 | break; |
|
|
328 | case 2: |
|
|
329 | sprintf (buf, "northeast"); |
|
|
330 | break; |
|
|
331 | case 3: |
|
|
332 | sprintf (buf, "east"); |
|
|
333 | break; |
|
|
334 | case 4: |
|
|
335 | sprintf (buf, "southeast"); |
|
|
336 | break; |
|
|
337 | case 5: |
|
|
338 | sprintf (buf, "south"); |
|
|
339 | break; |
|
|
340 | case 6: |
|
|
341 | sprintf (buf, "southwest"); |
|
|
342 | break; |
|
|
343 | case 7: |
|
|
344 | sprintf (buf, "west"); |
|
|
345 | break; |
|
|
346 | case 8: |
|
|
347 | sprintf (buf, "northwest"); |
|
|
348 | break; |
|
|
349 | } |
|
|
350 | if (weathermap[wx][wy].windspeed < 5) |
|
|
351 | new_draw_info_format (NDI_UNIQUE, 0, op, "There is a mild breeze " "coming from the %s.", buf); |
|
|
352 | else if (weathermap[wx][wy].windspeed < 10) |
|
|
353 | new_draw_info_format (NDI_UNIQUE, 0, op, "There is a strong breeze " "coming from the %s.", buf); |
|
|
354 | else if (weathermap[wx][wy].windspeed < 15) |
|
|
355 | new_draw_info_format (NDI_UNIQUE, 0, op, "There is a light wind " "coming from the %s.", buf); |
|
|
356 | else if (weathermap[wx][wy].windspeed < 25) |
|
|
357 | new_draw_info_format (NDI_UNIQUE, 0, op, "There is a strong wind " "coming from the %s.", buf); |
|
|
358 | else if (weathermap[wx][wy].windspeed < 35) |
|
|
359 | new_draw_info_format (NDI_UNIQUE, 0, op, "There is a heavy wind " "coming from the %s.", buf); |
|
|
360 | else |
|
|
361 | new_draw_info_format (NDI_UNIQUE, 0, op, "The wind from the %s is " "incredibly strong!", buf); |
|
|
362 | |
|
|
363 | sky = weathermap[wx][wy].sky; |
|
|
364 | if (temp <= 0 && sky > SKY_OVERCAST && sky < SKY_FOG) |
|
|
365 | sky += 10; /*let it snow */ |
|
|
366 | switch (sky) |
|
|
367 | { |
|
|
368 | case SKY_CLEAR: |
|
|
369 | new_draw_info (NDI_UNIQUE, 0, op, "There isn''t a cloud in the sky."); |
|
|
370 | break; |
|
|
371 | case SKY_LIGHTCLOUD: |
|
|
372 | new_draw_info (NDI_UNIQUE, 0, op, "There are a few light clouds in the sky."); |
|
|
373 | break; |
|
|
374 | case SKY_OVERCAST: |
|
|
375 | new_draw_info (NDI_UNIQUE, 0, op, "The sky is cloudy and dreary."); |
|
|
376 | break; |
|
|
377 | case SKY_LIGHT_RAIN: |
|
|
378 | new_draw_info (NDI_UNIQUE, 0, op, "It is raining softly."); |
|
|
379 | break; |
|
|
380 | case SKY_RAIN: |
|
|
381 | new_draw_info (NDI_UNIQUE, 0, op, "It is raining."); |
|
|
382 | break; |
|
|
383 | case SKY_HEAVY_RAIN: |
|
|
384 | new_draw_info (NDI_UNIQUE, 0, op, "It is raining heavily."); |
|
|
385 | break; |
|
|
386 | case SKY_HURRICANE: |
|
|
387 | new_draw_info (NDI_UNIQUE, 0, op, "There is a heavy storm! You should go inside!"); |
|
|
388 | break; |
|
|
389 | case SKY_FOG: |
|
|
390 | new_draw_info (NDI_UNIQUE, 0, op, "It''s foggy and miserable."); |
|
|
391 | break; |
|
|
392 | case SKY_HAIL: |
|
|
393 | new_draw_info (NDI_UNIQUE, 0, op, "It''s hailing out! Take cover!"); |
|
|
394 | break; |
|
|
395 | case SKY_LIGHT_SNOW: |
|
|
396 | new_draw_info (NDI_UNIQUE, 0, op, "Snow is gently falling from the sky."); |
|
|
397 | break; |
|
|
398 | case SKY_SNOW: |
|
|
399 | new_draw_info (NDI_UNIQUE, 0, op, "It''s snowing out."); |
|
|
400 | break; |
|
|
401 | case SKY_HEAVY_SNOW: |
|
|
402 | new_draw_info (NDI_UNIQUE, 0, op, "The snow is falling very heavily now."); |
|
|
403 | break; |
|
|
404 | case SKY_BLIZZARD: |
|
|
405 | new_draw_info (NDI_UNIQUE, 0, op, "A full blown blizzard is in effect. You might want to take cover!"); |
|
|
406 | break; |
|
|
407 | } |
|
|
408 | return 1; |
|
|
409 | } |
|
|
410 | |
|
|
411 | int |
|
|
412 | command_archs (object *op, char *params) |
|
|
413 | { |
|
|
414 | arch_info (op); |
|
|
415 | return 1; |
|
|
416 | } |
|
|
417 | |
|
|
418 | int |
|
|
419 | command_hiscore (object *op, char *params) |
|
|
420 | { |
|
|
421 | display_high_score (op, op == NULL ? 9999 : 50, params); |
|
|
422 | return 1; |
41 | return 1; |
423 | } |
42 | } |
424 | |
43 | |
425 | int |
44 | int |
426 | command_debug (object *op, char *params) |
45 | command_debug (object *op, char *params) |
… | |
… | |
432 | { |
51 | { |
433 | sprintf (buf, "Global debug level is %d.", settings.debug); |
52 | sprintf (buf, "Global debug level is %d.", settings.debug); |
434 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
53 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
435 | return 1; |
54 | return 1; |
436 | } |
55 | } |
437 | if (op != NULL && !QUERY_FLAG (op, FLAG_WIZ)) |
56 | |
438 | { |
57 | settings.debug = i; |
439 | new_draw_info (NDI_UNIQUE, 0, op, "Privileged command."); |
58 | |
440 | return 1; |
|
|
441 | } |
|
|
442 | settings.debug = (enum LogLevel) FABS (i); |
|
|
443 | sprintf (buf, "Set debug level to %d.", i); |
59 | sprintf (buf, "Set debug level to %d.", i); |
444 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
60 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
445 | return 1; |
61 | return 1; |
446 | } |
62 | } |
447 | |
|
|
448 | |
63 | |
449 | /* |
64 | /* |
450 | * Those dumps should be just one dump with good parser |
65 | * Those dumps should be just one dump with good parser |
451 | */ |
66 | */ |
452 | |
67 | |
… | |
… | |
463 | } |
78 | } |
464 | return 0; |
79 | return 0; |
465 | } |
80 | } |
466 | |
81 | |
467 | int |
82 | int |
468 | command_dumpfriendlyobjects (object *op, char *params) |
|
|
469 | { |
|
|
470 | dump_friendly_objects (); |
|
|
471 | return 0; |
|
|
472 | } |
|
|
473 | |
|
|
474 | int |
|
|
475 | command_dumpmap (object *op, char *params) |
|
|
476 | { |
|
|
477 | if (op) |
|
|
478 | dump_map (op->map); |
|
|
479 | return 0; |
|
|
480 | } |
|
|
481 | |
|
|
482 | int |
|
|
483 | command_dumpallmaps (object *op, char *params) |
|
|
484 | { |
|
|
485 | dump_all_maps (); |
|
|
486 | return 0; |
|
|
487 | } |
|
|
488 | |
|
|
489 | int |
|
|
490 | command_printlos (object *op, char *params) |
|
|
491 | { |
|
|
492 | if (op) |
|
|
493 | print_los (op); |
|
|
494 | return 0; |
|
|
495 | } |
|
|
496 | |
|
|
497 | |
|
|
498 | int |
|
|
499 | command_version (object *op, char *params) |
83 | command_version (object *op, char *params) |
500 | { |
84 | { |
501 | version (op); |
85 | version (op); |
502 | return 0; |
86 | return 0; |
503 | } |
|
|
504 | |
|
|
505 | |
|
|
506 | #ifndef BUG_LOG |
|
|
507 | # define BUG_LOG "bug_log" |
|
|
508 | #endif |
|
|
509 | void |
|
|
510 | bug_report (const char *reportstring) |
|
|
511 | { |
|
|
512 | FILE *fp; |
|
|
513 | |
|
|
514 | if ((fp = fopen (BUG_LOG, "a")) != NULL) |
|
|
515 | { |
|
|
516 | fprintf (fp, "%s\n", reportstring); |
|
|
517 | fclose (fp); |
|
|
518 | } |
|
|
519 | else |
|
|
520 | { |
|
|
521 | LOG (llevError, "Cannot write bugs file %s: %s\n", BUG_LOG, strerror (errno)); |
|
|
522 | } |
|
|
523 | } |
|
|
524 | |
|
|
525 | int |
|
|
526 | command_output_sync (object *op, char *params) |
|
|
527 | { |
|
|
528 | int val; |
|
|
529 | |
|
|
530 | if (!params) |
|
|
531 | { |
|
|
532 | new_draw_info_format (NDI_UNIQUE, 0, op, "Output sync time is presently %d", op->contr->outputs_sync); |
|
|
533 | return 1; |
|
|
534 | } |
|
|
535 | val = atoi (params); |
|
|
536 | if (val > 0) |
|
|
537 | { |
|
|
538 | op->contr->outputs_sync = val; |
|
|
539 | new_draw_info_format (NDI_UNIQUE, 0, op, "Output sync time now set to %d", op->contr->outputs_sync); |
|
|
540 | } |
|
|
541 | else |
|
|
542 | new_draw_info (NDI_UNIQUE, 0, op, "Invalid value for output_sync."); |
|
|
543 | |
|
|
544 | return 1; |
|
|
545 | } |
|
|
546 | |
|
|
547 | int |
|
|
548 | command_output_count (object *op, char *params) |
|
|
549 | { |
|
|
550 | int val; |
|
|
551 | |
|
|
552 | if (!params) |
|
|
553 | { |
|
|
554 | new_draw_info_format (NDI_UNIQUE, 0, op, "Output count is presently %d", op->contr->outputs_count); |
|
|
555 | return 1; |
|
|
556 | } |
|
|
557 | val = atoi (params); |
|
|
558 | if (val > 0) |
|
|
559 | { |
|
|
560 | op->contr->outputs_count = val; |
|
|
561 | new_draw_info_format (NDI_UNIQUE, 0, op, "Output count now set to %d", op->contr->outputs_count); |
|
|
562 | } |
|
|
563 | else |
|
|
564 | new_draw_info (NDI_UNIQUE, 0, op, "Invalid value for output_count."); |
|
|
565 | |
|
|
566 | return 1; |
|
|
567 | } |
|
|
568 | |
|
|
569 | int |
|
|
570 | command_listen (object *op, char *params) |
|
|
571 | { |
|
|
572 | int i; |
|
|
573 | |
|
|
574 | if (params == NULL || !sscanf (params, "%d", &i)) |
|
|
575 | { |
|
|
576 | new_draw_info_format (NDI_UNIQUE, 0, op, "Set listen to what (presently %d)?", op->contr->listening); |
|
|
577 | return 1; |
|
|
578 | } |
|
|
579 | op->contr->listening = (char) i; |
|
|
580 | new_draw_info_format (NDI_UNIQUE, 0, op, "Your verbose level is now %d.", i); |
|
|
581 | return 1; |
|
|
582 | } |
87 | } |
583 | |
88 | |
584 | /* Prints out some useful information for the character. Everything we print |
89 | /* Prints out some useful information for the character. Everything we print |
585 | * out can be determined by the docs, so we aren't revealing anything extra - |
90 | * out can be determined by the docs, so we aren't revealing anything extra - |
586 | * rather, we are making it convenient to find the values. params have |
91 | * rather, we are making it convenient to find the values. params have |
… | |
… | |
589 | int |
94 | int |
590 | command_statistics (object *pl, char *params) |
95 | command_statistics (object *pl, char *params) |
591 | { |
96 | { |
592 | if (!pl->contr) |
97 | if (!pl->contr) |
593 | return 1; |
98 | return 1; |
594 | #ifndef WIN32 |
|
|
595 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Experience: %lld", pl->stats.exp); |
|
|
596 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Next Level: %lld", level_exp (pl->level + 1, pl->expmul)); |
|
|
597 | #else |
|
|
598 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Experience: %I64d", pl->stats.exp); |
|
|
599 | new_draw_info_format (NDI_UNIQUE, 0, pl, " Next Level: %I64d", level_exp (pl->level + 1, pl->expmul)); |
|
|
600 | #endif |
|
|
601 | new_draw_info (NDI_UNIQUE, 0, pl, "\nStat Nat/Real/Max"); |
|
|
602 | |
99 | |
603 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Str %2d/ %3d/%3d", |
100 | dynbuf_text &msg = msg_dynbuf; msg.clear (); |
604 | pl->contr->orig_stats.Str, pl->stats.Str, 20 + pl->arch->clone.stats.Str); |
101 | |
605 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Dex %2d/ %3d/%3d", |
102 | msg << " Experience: " << pl->stats.exp << '\n' |
606 | pl->contr->orig_stats.Dex, pl->stats.Dex, 20 + pl->arch->clone.stats.Dex); |
103 | << " Next Level: " << level_exp (pl->level + 1, pl->expmul) << '\n' |
607 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Con %2d/ %3d/%3d", |
104 | << "\n Stat Nat/Real/Max\n"; |
608 | pl->contr->orig_stats.Con, pl->stats.Con, 20 + pl->arch->clone.stats.Con); |
105 | |
609 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Int %2d/ %3d/%3d", |
106 | for (int i = 0; i < NUM_STATS; ++i) |
610 | pl->contr->orig_stats.Int, pl->stats.Int, 20 + pl->arch->clone.stats.Int); |
107 | msg.printf (" %s %2d/ %3d/%3d\n", short_stat_name [i], pl->contr->orig_stats.stat (i), pl->stats.stat (i), 20 + pl->arch->stats.stat (i)); |
611 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Wis %2d/ %3d/%3d", |
108 | |
612 | pl->contr->orig_stats.Wis, pl->stats.Wis, 20 + pl->arch->clone.stats.Wis); |
109 | msg << "\nYou are " << (pl->contr->peaceful ? "peaceful" : "hostile") << '.'; |
613 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Pow %2d/ %3d/%3d", |
110 | |
614 | pl->contr->orig_stats.Pow, pl->stats.Pow, 20 + pl->arch->clone.stats.Pow); |
111 | pl->contr->infobox (MSG_CHANNEL ("statistics"), msg); |
615 | new_draw_info_format (NDI_UNIQUE, 0, pl, "Cha %2d/ %3d/%3d", |
|
|
616 | pl->contr->orig_stats.Cha, pl->stats.Cha, 20 + pl->arch->clone.stats.Cha); |
|
|
617 | new_draw_info_format (NDI_UNIQUE, 0, pl, "\nAttack Mode: %s", pl->contr->peaceful ? "Peaceful" : "Hostile"); |
|
|
618 | |
112 | |
619 | /* Can't think of anything else to print right now */ |
113 | /* Can't think of anything else to print right now */ |
620 | return 0; |
114 | return 0; |
621 | } |
115 | } |
622 | |
116 | |
623 | int |
117 | int |
624 | command_fix_me (object *op, char *params) |
118 | command_fix_me (object *op, char *params) |
625 | { |
119 | { |
626 | sum_weight (op); |
120 | op->update_weight (); |
627 | fix_player (op); |
121 | op->update_stats (); |
628 | return 1; |
122 | new_draw_info (NDI_UNIQUE, 0, op, "Your character was fixed."); |
629 | } |
|
|
630 | |
123 | |
631 | int |
|
|
632 | command_players (object *op, char *paramss) |
|
|
633 | { |
|
|
634 | char buf[MAX_BUF]; |
|
|
635 | char *t; |
|
|
636 | DIR *Dir; |
|
|
637 | |
|
|
638 | sprintf (buf, "%s/%s/", settings.localdir, settings.playerdir); |
|
|
639 | t = buf + strlen (buf); |
|
|
640 | if ((Dir = opendir (buf)) != NULL) |
|
|
641 | { |
|
|
642 | const struct dirent *Entry; |
|
|
643 | |
|
|
644 | while ((Entry = readdir (Dir)) != NULL) |
|
|
645 | { |
|
|
646 | /* skip '.' , '..' */ |
|
|
647 | if (!((Entry->d_name[0] == '.' && Entry->d_name[1] == '\0') || |
|
|
648 | (Entry->d_name[0] == '.' && Entry->d_name[1] == '.' && Entry->d_name[2] == '\0'))) |
|
|
649 | { |
|
|
650 | struct stat Stat; |
|
|
651 | |
|
|
652 | strcpy (t, Entry->d_name); |
|
|
653 | if (stat (buf, &Stat) == 0) |
|
|
654 | { |
|
|
655 | /* This was not posix compatible |
|
|
656 | * if ((Stat.st_mode & S_IFMT)==S_IFDIR) { |
|
|
657 | */ |
|
|
658 | if (S_ISDIR (Stat.st_mode)) |
|
|
659 | { |
|
|
660 | char buf2[MAX_BUF]; |
|
|
661 | struct tm *tm = localtime (&Stat.st_mtime); |
|
|
662 | |
|
|
663 | sprintf (buf2, "%s\t%04d %02d %02d %02d %02d %02d", |
|
|
664 | Entry->d_name, 1900 + tm->tm_year, 1 + tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec); |
|
|
665 | new_draw_info (NDI_UNIQUE, 0, op, buf2); |
|
|
666 | } |
|
|
667 | } |
|
|
668 | } |
|
|
669 | } |
|
|
670 | } |
|
|
671 | closedir (Dir); |
|
|
672 | return 0; |
|
|
673 | } |
|
|
674 | |
|
|
675 | |
|
|
676 | |
|
|
677 | int |
|
|
678 | command_logs (object *op, char *params) |
|
|
679 | { |
|
|
680 | new_draw_info (NDI_UNIQUE, 0, op, "Nobody is currently logging kills."); |
|
|
681 | |
|
|
682 | return 1; |
|
|
683 | } |
|
|
684 | |
|
|
685 | int |
|
|
686 | command_applymode (object *op, char *params) |
|
|
687 | { |
|
|
688 | unapplymode unapply = op->contr->unapply; |
|
|
689 | static const char *const types[] = { "nochoice", "never", "always" }; |
|
|
690 | |
|
|
691 | if (!params) |
|
|
692 | { |
|
|
693 | new_draw_info_format (NDI_UNIQUE, 0, op, "applymode is set to %s", types[op->contr->unapply]); |
|
|
694 | return 1; |
|
|
695 | } |
|
|
696 | |
|
|
697 | if (!strcmp (params, "nochoice")) |
|
|
698 | op->contr->unapply = unapply_nochoice; |
|
|
699 | else if (!strcmp (params, "never")) |
|
|
700 | op->contr->unapply = unapply_never; |
|
|
701 | else if (!strcmp (params, "always")) |
|
|
702 | op->contr->unapply = unapply_always; |
|
|
703 | else |
|
|
704 | { |
|
|
705 | new_draw_info_format (NDI_UNIQUE, 0, op, "applymode: Unknown options %s, valid options are nochoice, never, always", params); |
|
|
706 | return 0; |
|
|
707 | } |
|
|
708 | new_draw_info_format (NDI_UNIQUE, 0, op, "Applymode %s set to %s", |
|
|
709 | (unapply == op->contr->unapply ? "" : " now"), types[op->contr->unapply]); |
|
|
710 | return 1; |
124 | return 1; |
711 | } |
125 | } |
712 | |
126 | |
713 | int |
127 | int |
714 | command_bowmode (object *op, char *params) |
128 | command_bowmode (object *op, char *params) |
715 | { |
129 | { |
716 | bowtype_t oldtype = op->contr->bowtype; |
130 | bowtype_t oldtype = op->contr->bowtype; |
717 | static const char *const types[] = { "normal", "threewide", "spreadshot", "firenorth", |
131 | static const char *const types[] = { |
|
|
132 | "normal", "threewide", "spreadshot", "firenorth", |
718 | "firene", "fireeast", "firese", "firesouth", |
133 | "firene", "fireeast", "firese", "firesouth", |
719 | "firesw", "firewest", "firenw", "bestarrow" |
134 | "firesw", "firewest", "firenw", "bestarrow" |
720 | }; |
135 | }; |
721 | char buf[MAX_BUF]; |
136 | char buf[MAX_BUF]; |
722 | int i, found; |
137 | int i, found; |
… | |
… | |
734 | found++; |
149 | found++; |
735 | op->contr->bowtype = (bowtype_t) i; |
150 | op->contr->bowtype = (bowtype_t) i; |
736 | break; |
151 | break; |
737 | } |
152 | } |
738 | } |
153 | } |
|
|
154 | |
739 | if (!found) |
155 | if (!found) |
740 | { |
156 | { |
741 | sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
157 | sprintf (buf, "bowmode: Unknown options %s, valid options are:", params); |
|
|
158 | |
742 | for (i = 0; i <= bow_bestarrow; i++) |
159 | for (i = 0; i <= bow_bestarrow; i++) |
743 | { |
160 | { |
744 | strcat (buf, " "); |
161 | strcat (buf, " "); |
745 | strcat (buf, types[i]); |
162 | strcat (buf, types[i]); |
746 | if (i < bow_nw) |
163 | if (i < bow_nw) |
… | |
… | |
749 | strcat (buf, "."); |
166 | strcat (buf, "."); |
750 | } |
167 | } |
751 | new_draw_info_format (NDI_UNIQUE, 0, op, buf); |
168 | new_draw_info_format (NDI_UNIQUE, 0, op, buf); |
752 | return 0; |
169 | return 0; |
753 | } |
170 | } |
|
|
171 | |
754 | new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode %s set to %s", (oldtype == op->contr->bowtype ? "" : "now"), types[op->contr->bowtype]); |
172 | new_draw_info_format (NDI_UNIQUE, 0, op, "bowmode %s set to %s", (oldtype == op->contr->bowtype ? "" : "now"), types[op->contr->bowtype]); |
755 | return 1; |
173 | return 1; |
756 | } |
174 | } |
757 | |
175 | |
758 | int |
176 | int |
759 | command_petmode (object *op, char *params) |
|
|
760 | { |
|
|
761 | petmode_t oldtype = op->contr->petmode; |
|
|
762 | static const char *const types[] = { "normal", "sad", "defend", "arena" }; |
|
|
763 | |
|
|
764 | if (!params) |
|
|
765 | { |
|
|
766 | new_draw_info_format (NDI_UNIQUE, 0, op, "petmode is set to %s", types[op->contr->petmode]); |
|
|
767 | return 1; |
|
|
768 | } |
|
|
769 | |
|
|
770 | if (!strcmp (params, "normal")) |
|
|
771 | op->contr->petmode = pet_normal; |
|
|
772 | else if (!strcmp (params, "sad")) |
|
|
773 | op->contr->petmode = pet_sad; |
|
|
774 | else if (!strcmp (params, "defend")) |
|
|
775 | op->contr->petmode = pet_defend; |
|
|
776 | else if (!strcmp (params, "arena")) |
|
|
777 | op->contr->petmode = pet_arena; |
|
|
778 | else |
|
|
779 | { |
|
|
780 | new_draw_info_format (NDI_UNIQUE, 0, op, |
|
|
781 | "petmode: Unknown options %s, valid options are normal," "sad (seek and destroy), defend, arena", params); |
|
|
782 | return 0; |
|
|
783 | } |
|
|
784 | new_draw_info_format (NDI_UNIQUE, 0, op, "petmode %s set to %s", (oldtype == op->contr->petmode ? "" : "now"), types[op->contr->petmode]); |
|
|
785 | return 1; |
|
|
786 | } |
|
|
787 | |
|
|
788 | int |
|
|
789 | command_showpets (object *op, char *params) |
177 | command_showpets (object *op, char *params) |
790 | { |
178 | { |
791 | objectlink *obl, *next; |
|
|
792 | int counter = 0, target = 0; |
179 | int counter = 0, target = 0; |
793 | int have_shown_pet = 0; |
180 | int have_shown_pet = 0; |
794 | |
181 | |
|
|
182 | dynbuf_text &msg = msg_dynbuf; msg.clear (); |
|
|
183 | |
795 | if (params != NULL) |
184 | if (params) |
796 | target = atoi (params); |
185 | target = atoi (params); |
|
|
186 | |
797 | for (obl = first_friendly_object; obl != NULL; obl = next) |
187 | for (objectlink *obl = first_friendly_object; obl; obl = obl->next) |
798 | { |
188 | { |
799 | object *ob = obl->ob; |
189 | object *ob = obl->ob; |
800 | |
190 | |
801 | next = obl->next; |
|
|
802 | if (get_owner (ob) == op) |
191 | if (ob->owner == op) |
803 | { |
192 | { |
804 | if (target == 0) |
193 | if (target == 0) |
805 | { |
194 | { |
806 | if (counter == 0) |
195 | if (counter == 0) |
807 | new_draw_info (NDI_UNIQUE, 0, op, "Pets:"); |
196 | msg << "T<Pets>\n\n"; |
|
|
197 | |
808 | new_draw_info_format (NDI_UNIQUE, 0, op, "%d %s - level %d", ++counter, &ob->name, ob->level); |
198 | msg.printf (" %3d %s, level %d\n", ++counter, &ob->name, ob->level); |
809 | } |
199 | } |
810 | else if (!have_shown_pet && ++counter == target) |
200 | else if (!have_shown_pet && ++counter == target) |
811 | { |
201 | { |
812 | new_draw_info_format (NDI_UNIQUE, 0, op, "level %d %s", ob->level, &ob->name); |
202 | msg.printf ("T<%s>\n\n" |
813 | new_draw_info_format (NDI_UNIQUE, 0, op, "%d/%d HP, %d/%d SP", ob->stats.hp, ob->stats.maxhp, ob->stats.sp, ob->stats.maxsp); |
203 | " level %d\n" |
814 | /* this is not a nice way to do this, it should be made to be more like the statistics command */ |
204 | " %d/%d HP, %d/%d SP\n" |
815 | new_draw_info_format (NDI_UNIQUE, 0, op, "Str %d", ob->stats.Str); |
205 | " Str %2d\n" |
816 | new_draw_info_format (NDI_UNIQUE, 0, op, "Dex %d", ob->stats.Dex); |
206 | " Dex %2d\n" |
817 | new_draw_info_format (NDI_UNIQUE, 0, op, "Con %d", ob->stats.Con); |
207 | " Con %2d\n" |
818 | new_draw_info_format (NDI_UNIQUE, 0, op, "Int %d", ob->stats.Int); |
208 | " Int %2d\n" |
819 | new_draw_info_format (NDI_UNIQUE, 0, op, "Wis %d", ob->stats.Wis); |
209 | " Wis %2d\n" |
820 | new_draw_info_format (NDI_UNIQUE, 0, op, "Cha %d", ob->stats.Cha); |
210 | " Cha %2d\n" |
821 | new_draw_info_format (NDI_UNIQUE, 0, op, "Pow %d", ob->stats.Pow); |
211 | " Pow %2d\n" |
822 | new_draw_info_format (NDI_UNIQUE, 0, op, "wc %d damage %d ac %d ", ob->stats.wc, ob->stats.dam, ob->stats.ac); |
212 | " wc %d damage %d ac %d\n", |
|
|
213 | &ob->name, |
|
|
214 | &ob->name, |
|
|
215 | ob->stats.hp, ob->stats.maxhp, ob->stats.sp, ob->stats.maxsp, |
|
|
216 | ob->stats.Str, |
|
|
217 | ob->stats.Dex, |
|
|
218 | ob->stats.Con, |
|
|
219 | ob->stats.Int, |
|
|
220 | ob->stats.Wis, |
|
|
221 | ob->stats.Cha, |
|
|
222 | ob->stats.Pow, |
|
|
223 | ob->stats.wc, ob->stats.dam, ob->stats.ac); |
|
|
224 | |
823 | have_shown_pet = 1; |
225 | have_shown_pet = 1; |
824 | } |
226 | } |
825 | } |
227 | } |
826 | } |
228 | } |
|
|
229 | |
827 | if (counter == 0) |
230 | if (counter == 0) |
828 | new_draw_info (NDI_UNIQUE, 0, op, "you have no pets."); |
231 | msg << "you have no pets."; |
829 | else if (target != 0 && have_shown_pet == 0) |
232 | else if (target != 0 && have_shown_pet == 0) |
830 | new_draw_info (NDI_UNIQUE, 0, op, "no such pet."); |
233 | msg << "no such pet."; |
831 | return 0; |
|
|
832 | } |
|
|
833 | |
234 | |
834 | int |
235 | op->contr->infobox (MSG_CHANNEL ("pets"), msg); |
835 | command_usekeys (object *op, char *params) |
|
|
836 | { |
|
|
837 | usekeytype oldtype = op->contr->usekeys; |
|
|
838 | static const char *const types[] = { "inventory", "keyrings", "containers" }; |
|
|
839 | |
236 | |
840 | if (!params) |
|
|
841 | { |
|
|
842 | new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys is set to %s", types[op->contr->usekeys]); |
|
|
843 | return 1; |
|
|
844 | } |
|
|
845 | |
|
|
846 | if (!strcmp (params, "inventory")) |
|
|
847 | op->contr->usekeys = key_inventory; |
|
|
848 | else if (!strcmp (params, "keyrings")) |
|
|
849 | op->contr->usekeys = keyrings; |
|
|
850 | else if (!strcmp (params, "containers")) |
|
|
851 | op->contr->usekeys = containers; |
|
|
852 | else |
|
|
853 | { |
|
|
854 | new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys: Unknown options %s, valid options are inventory, keyrings, containers", params); |
|
|
855 | return 0; |
|
|
856 | } |
|
|
857 | new_draw_info_format (NDI_UNIQUE, 0, op, "usekeys %s set to %s", (oldtype == op->contr->usekeys ? "" : "now"), types[op->contr->usekeys]); |
|
|
858 | return 1; |
237 | return 0; |
859 | } |
238 | } |
860 | |
239 | |
861 | int |
240 | int |
862 | command_resistances (object *op, char *params) |
241 | command_resistances (object *op, char *params) |
863 | { |
242 | { |
864 | int i; |
243 | dynbuf_text &msg = msg_dynbuf; msg.clear (); |
865 | |
244 | |
866 | if (!op) |
245 | msg << "Resistances:\n\n"; |
867 | return 0; |
|
|
868 | |
246 | |
869 | for (i = 0; i < NROFATTACKS; i++) |
247 | for (int i = 0; i < NROFATTACKS; i++) |
870 | { |
|
|
871 | if (i == ATNR_INTERNAL) |
248 | if (i != ATNR_INTERNAL) |
872 | continue; |
249 | msg.printf (" %-20s %+4d\n", attacktype_desc [i], op->resist [i]); |
873 | |
|
|
874 | new_draw_info_format (NDI_UNIQUE, 0, op, "%-20s %+5d", attacktype_desc[i], op->resist[i]); |
|
|
875 | } |
|
|
876 | |
250 | |
877 | /* If dragon player, let's display natural resistances */ |
251 | /* If dragon player, let's display natural resistances */ |
878 | if (is_dragon_pl (op)) |
252 | if (is_dragon_pl (op)) |
879 | { |
|
|
880 | int attack; |
|
|
881 | object *tmp; |
|
|
882 | |
|
|
883 | for (tmp = op->inv; tmp != NULL; tmp = tmp->below) |
253 | for (object *tmp = op->inv; tmp; tmp = tmp->below) |
884 | { |
|
|
885 | if ((tmp->type == FORCE) && (strcmp (tmp->arch->name, "dragon_skin_force") == 0)) |
254 | if ((tmp->type == FORCE) && tmp->arch->archname == shstr_dragon_skin_force) |
886 | { |
255 | { |
887 | new_draw_info (NDI_UNIQUE, 0, op, "\nNatural skin resistances:"); |
256 | msg << "\nOf those, these are natural skin resistances:\n\n"; |
|
|
257 | |
888 | for (attack = 0; attack < NROFATTACKS; attack++) |
258 | for (int attack = 0; attack < NROFATTACKS; attack++) |
889 | { |
|
|
890 | if (atnr_is_dragon_enabled (attack)) |
259 | if (atnr_is_dragon_enabled (attack)) |
891 | { |
260 | msg.printf (" %-20s %+4d\n", change_resist_msg [attack], tmp->resist [attack]); |
892 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s: %d", change_resist_msg[attack], tmp->resist[attack]); |
|
|
893 | } |
|
|
894 | } |
|
|
895 | break; |
|
|
896 | } |
|
|
897 | } |
|
|
898 | } |
|
|
899 | |
261 | |
900 | return 0; |
|
|
901 | } |
|
|
902 | |
|
|
903 | /* |
|
|
904 | * Actual commands. |
|
|
905 | * Those should be in small separate files (c_object.c, c_wiz.c, cmove.c,...) |
|
|
906 | */ |
|
|
907 | |
|
|
908 | |
|
|
909 | static void |
|
|
910 | help_topics (object *op, int what) |
|
|
911 | { |
|
|
912 | DIR *dirp; |
|
|
913 | struct dirent *de; |
|
|
914 | char filename[MAX_BUF], line[80]; |
|
|
915 | int namelen, linelen = 0; |
|
|
916 | |
|
|
917 | switch (what) |
|
|
918 | { |
|
|
919 | case 1: |
|
|
920 | sprintf (filename, "%s/wizhelp", settings.datadir); |
|
|
921 | new_draw_info (NDI_UNIQUE, 0, op, " Wiz commands:"); |
|
|
922 | break; |
262 | break; |
923 | case 3: |
|
|
924 | sprintf (filename, "%s/mischelp", settings.datadir); |
|
|
925 | new_draw_info (NDI_UNIQUE, 0, op, " Misc help:"); |
|
|
926 | break; |
|
|
927 | default: |
|
|
928 | sprintf (filename, "%s/help", settings.datadir); |
|
|
929 | new_draw_info (NDI_UNIQUE, 0, op, " Commands:"); |
|
|
930 | break; |
|
|
931 | } |
|
|
932 | if (!(dirp = opendir (filename))) |
|
|
933 | return; |
|
|
934 | |
|
|
935 | line[0] = '\0'; |
|
|
936 | for (de = readdir (dirp); de; de = readdir (dirp)) |
|
|
937 | { |
|
|
938 | namelen = NAMLEN (de); |
|
|
939 | if (namelen <= 2 && *de->d_name == '.' && (namelen == 1 || de->d_name[1] == '.')) |
|
|
940 | continue; |
|
|
941 | linelen += namelen + 1; |
|
|
942 | if (linelen > 42) |
|
|
943 | { |
263 | } |
944 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
945 | sprintf (line, " %s", de->d_name); |
|
|
946 | linelen = namelen + 1; |
|
|
947 | continue; |
|
|
948 | } |
|
|
949 | strcat (line, " "); |
|
|
950 | strcat (line, de->d_name); |
|
|
951 | } |
|
|
952 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
953 | closedir (dirp); |
|
|
954 | } |
|
|
955 | |
264 | |
956 | static void |
265 | op->contr->infobox (MSG_CHANNEL ("resistances"), msg); |
957 | show_commands (object *op, int what) |
|
|
958 | { |
|
|
959 | char line[80]; |
|
|
960 | int i, size, namelen, linelen = 0; |
|
|
961 | CommArray_s *ap; |
|
|
962 | extern CommArray_s Commands[], WizCommands[]; |
|
|
963 | extern const int CommandsSize, WizCommandsSize; |
|
|
964 | |
266 | |
965 | switch (what) |
|
|
966 | { |
|
|
967 | case 1: |
|
|
968 | ap = WizCommands; |
|
|
969 | size = WizCommandsSize; |
|
|
970 | new_draw_info (NDI_UNIQUE, 0, op, " Wiz commands:"); |
|
|
971 | break; |
|
|
972 | case 2: |
|
|
973 | ap = CommunicationCommands; |
|
|
974 | size = CommunicationCommandSize; |
|
|
975 | new_draw_info (NDI_UNIQUE, 0, op, " Communication commands:"); |
|
|
976 | break; |
|
|
977 | default: |
|
|
978 | ap = Commands; |
|
|
979 | size = CommandsSize; |
|
|
980 | new_draw_info (NDI_UNIQUE, 0, op, " Commands:"); |
|
|
981 | break; |
|
|
982 | } |
|
|
983 | |
|
|
984 | line[0] = '\0'; |
|
|
985 | for (i = 0; i < size; i++) |
|
|
986 | { |
|
|
987 | namelen = strlen (ap[i].name); |
|
|
988 | linelen += namelen + 1; |
|
|
989 | if (linelen > 42) |
|
|
990 | { |
|
|
991 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
992 | sprintf (line, " %s", ap[i].name); |
|
|
993 | linelen = namelen + 1; |
|
|
994 | continue; |
|
|
995 | } |
|
|
996 | strcat (line, " "); |
|
|
997 | strcat (line, ap[i].name); |
|
|
998 | } |
|
|
999 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
1000 | } |
|
|
1001 | |
|
|
1002 | |
|
|
1003 | int |
|
|
1004 | command_help (object *op, char *params) |
|
|
1005 | { |
|
|
1006 | struct stat st; |
|
|
1007 | FILE *fp; |
|
|
1008 | char filename[MAX_BUF], line[MAX_BUF]; |
|
|
1009 | int len; |
|
|
1010 | |
|
|
1011 | if (op != NULL) |
|
|
1012 | clear_win_info (op); |
|
|
1013 | |
|
|
1014 | /* |
|
|
1015 | * Main help page? |
|
|
1016 | */ |
|
|
1017 | if (!params) |
|
|
1018 | { |
|
|
1019 | sprintf (filename, "%s/def_help", settings.datadir); |
|
|
1020 | if ((fp = fopen (filename, "r")) == NULL) |
|
|
1021 | { |
|
|
1022 | LOG (llevError, "Cannot open help file %s: %s\n", filename, strerror (errno)); |
|
|
1023 | return 0; |
|
|
1024 | } |
|
|
1025 | while (fgets (line, MAX_BUF, fp)) |
|
|
1026 | { |
|
|
1027 | line[MAX_BUF - 1] = '\0'; |
|
|
1028 | len = strlen (line) - 1; |
|
|
1029 | if (line[len] == '\n') |
|
|
1030 | line[len] = '\0'; |
|
|
1031 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
1032 | } |
|
|
1033 | fclose (fp); |
|
|
1034 | return 0; |
|
|
1035 | } |
|
|
1036 | |
|
|
1037 | /* |
|
|
1038 | * Topics list |
|
|
1039 | */ |
|
|
1040 | if (!strcmp (params, "topics")) |
|
|
1041 | { |
|
|
1042 | help_topics (op, 3); |
|
|
1043 | help_topics (op, 0); |
|
|
1044 | if (QUERY_FLAG (op, FLAG_WIZ)) |
|
|
1045 | help_topics (op, 1); |
|
|
1046 | return 0; |
|
|
1047 | } |
|
|
1048 | |
|
|
1049 | /* |
|
|
1050 | * Commands list |
|
|
1051 | */ |
|
|
1052 | if (!strcmp (params, "commands")) |
|
|
1053 | { |
|
|
1054 | show_commands (op, 0); |
|
|
1055 | show_commands (op, 2); /* show comm commands */ |
|
|
1056 | if (QUERY_FLAG (op, FLAG_WIZ)) |
|
|
1057 | show_commands (op, 1); |
|
|
1058 | return 0; |
|
|
1059 | } |
|
|
1060 | |
|
|
1061 | /* |
|
|
1062 | * User wants info about command |
|
|
1063 | */ |
|
|
1064 | if (strchr (params, '.') || strchr (params, ' ') || strchr (params, '/')) |
|
|
1065 | { |
|
|
1066 | sprintf (line, "Illegal characters in '%s'", params); |
|
|
1067 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
1068 | return 0; |
|
|
1069 | } |
|
|
1070 | |
|
|
1071 | sprintf (filename, "%s/mischelp/%s", settings.datadir, params); |
|
|
1072 | if (stat (filename, &st) || !S_ISREG (st.st_mode)) |
|
|
1073 | { |
|
|
1074 | if (op) |
|
|
1075 | { |
|
|
1076 | sprintf (filename, "%s/help/%s", settings.datadir, params); |
|
|
1077 | if (stat (filename, &st) || !S_ISREG (st.st_mode)) |
|
|
1078 | { |
|
|
1079 | if (QUERY_FLAG (op, FLAG_WIZ)) |
|
|
1080 | { |
|
|
1081 | sprintf (filename, "%s/wizhelp/%s", settings.datadir, params); |
|
|
1082 | if (stat (filename, &st) || !S_ISREG (st.st_mode)) |
|
|
1083 | goto nohelp; |
|
|
1084 | } |
|
|
1085 | else |
|
|
1086 | goto nohelp; |
|
|
1087 | } |
|
|
1088 | } |
|
|
1089 | } |
|
|
1090 | |
|
|
1091 | /* |
|
|
1092 | * Found that. Just cat it to screen. |
|
|
1093 | */ |
|
|
1094 | if ((fp = fopen (filename, "r")) == NULL) |
|
|
1095 | { |
|
|
1096 | LOG (llevError, "Cannot open help file %s: %s\n", filename, strerror (errno)); |
|
|
1097 | return 0; |
|
|
1098 | } |
|
|
1099 | sprintf (line, "Help about '%s'", params); |
|
|
1100 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
1101 | while (fgets (line, MAX_BUF, fp)) |
|
|
1102 | { |
|
|
1103 | line[MAX_BUF - 1] = '\0'; |
|
|
1104 | len = strlen (line) - 1; |
|
|
1105 | if (line[len] == '\n') |
|
|
1106 | line[len] = '\0'; |
|
|
1107 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
1108 | } |
|
|
1109 | fclose (fp); |
|
|
1110 | return 0; |
|
|
1111 | |
|
|
1112 | /* |
|
|
1113 | * No_help -escape |
|
|
1114 | */ |
|
|
1115 | nohelp: |
|
|
1116 | sprintf (line, "No help available on '%s'", params); |
|
|
1117 | new_draw_info (NDI_UNIQUE, 0, op, line); |
|
|
1118 | return 0; |
|
|
1119 | } |
|
|
1120 | |
|
|
1121 | |
|
|
1122 | int |
|
|
1123 | onoff_value (const char *line) |
|
|
1124 | { |
|
|
1125 | int i; |
|
|
1126 | |
|
|
1127 | if (sscanf (line, "%d", &i)) |
|
|
1128 | return (i != 0); |
|
|
1129 | switch (line[0]) |
|
|
1130 | { |
|
|
1131 | case 'o': |
|
|
1132 | switch (line[1]) |
|
|
1133 | { |
|
|
1134 | case 'n': |
|
|
1135 | return 1; /* on */ |
|
|
1136 | default: |
|
|
1137 | return 0; /* o[ff] */ |
|
|
1138 | } |
|
|
1139 | case 'y': /* y[es] */ |
|
|
1140 | case 'k': /* k[ylla] */ |
|
|
1141 | case 's': |
|
|
1142 | case 'd': |
|
|
1143 | return 1; |
|
|
1144 | case 'n': /* n[o] */ |
|
|
1145 | case 'e': /* e[i] */ |
|
|
1146 | case 'u': |
|
|
1147 | default: |
|
|
1148 | return 0; |
|
|
1149 | } |
|
|
1150 | } |
|
|
1151 | |
|
|
1152 | int |
|
|
1153 | command_quit (object *op, char *params) |
|
|
1154 | { |
|
|
1155 | new_draw_info (NDI_UNIQUE, 0, op, |
|
|
1156 | "Quitting will delete your character PERMANENTLY. If you are sure you want to do this, then use the quit_character command instead of quit."); |
|
|
1157 | return 1; |
267 | return 0; |
1158 | } |
268 | } |
1159 | |
|
|
1160 | int |
|
|
1161 | command_real_quit (object *op, char *params) |
|
|
1162 | { |
|
|
1163 | send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Quitting will delete your character.\nAre you sure you want to quit (y/n):"); |
|
|
1164 | |
|
|
1165 | op->contr->state = ST_CONFIRM_QUIT; |
|
|
1166 | return 1; |
|
|
1167 | } |
|
|
1168 | |
|
|
1169 | /* |
|
|
1170 | * don't allow people to exit explore mode. It otherwise becomes |
|
|
1171 | * really easy to abuse this. |
|
|
1172 | */ |
|
|
1173 | int |
|
|
1174 | command_explore (object *op, char *params) |
|
|
1175 | { |
|
|
1176 | if (settings.explore_mode == FALSE) |
|
|
1177 | return 1; |
|
|
1178 | /* |
|
|
1179 | * I guess this is the best way to see if we are solo or not. Actually, |
|
|
1180 | * are there any cases when first_player->next==NULL and we are not solo? |
|
|
1181 | */ |
|
|
1182 | if ((first_player != op->contr) || (first_player->next != NULL)) |
|
|
1183 | { |
|
|
1184 | new_draw_info (NDI_UNIQUE, 0, op, "You can not enter explore mode if you are in a party"); |
|
|
1185 | } |
|
|
1186 | else if (op->contr->explore) |
|
|
1187 | new_draw_info (NDI_UNIQUE, 0, op, "There is no return from explore mode"); |
|
|
1188 | else |
|
|
1189 | { |
|
|
1190 | op->contr->explore = 1; |
|
|
1191 | new_draw_info (NDI_UNIQUE, 0, op, "You are now in explore mode"); |
|
|
1192 | } |
|
|
1193 | return 1; |
|
|
1194 | } |
|
|
1195 | |
|
|
1196 | int |
|
|
1197 | command_sound (object *op, char *params) |
|
|
1198 | { |
|
|
1199 | if (op->contr->socket.sound) |
|
|
1200 | { |
|
|
1201 | op->contr->socket.sound = 0; |
|
|
1202 | new_draw_info (NDI_UNIQUE, 0, op, "Silence is golden..."); |
|
|
1203 | } |
|
|
1204 | else |
|
|
1205 | { |
|
|
1206 | op->contr->socket.sound = 1; |
|
|
1207 | new_draw_info (NDI_UNIQUE, 0, op, "The sounds are enabled."); |
|
|
1208 | } |
|
|
1209 | return 1; |
|
|
1210 | } |
|
|
1211 | |
|
|
1212 | /* Perhaps these should be in player.c, but that file is |
|
|
1213 | * already a bit big. |
|
|
1214 | */ |
|
|
1215 | |
|
|
1216 | void |
|
|
1217 | receive_player_name (object *op, char k) |
|
|
1218 | { |
|
|
1219 | |
|
|
1220 | if (!check_name (op->contr, op->contr->write_buf + 1)) |
|
|
1221 | { |
|
|
1222 | get_name (op); |
|
|
1223 | return; |
|
|
1224 | } |
|
|
1225 | op->name = op->contr->write_buf + 1; |
|
|
1226 | op->name_pl = op->contr->write_buf + 1; |
|
|
1227 | new_draw_info (NDI_UNIQUE, 0, op, op->contr->write_buf); |
|
|
1228 | op->contr->name_changed = 1; |
|
|
1229 | get_password (op); |
|
|
1230 | } |
|
|
1231 | |
|
|
1232 | void |
|
|
1233 | receive_player_password (object *op, char k) |
|
|
1234 | { |
|
|
1235 | |
|
|
1236 | unsigned int pwd_len = strlen (op->contr->write_buf); |
|
|
1237 | |
|
|
1238 | if (pwd_len <= 1 || pwd_len > 17) |
|
|
1239 | { |
|
|
1240 | get_name (op); |
|
|
1241 | return; |
|
|
1242 | } |
|
|
1243 | new_draw_info (NDI_UNIQUE, 0, op, " "); /* To hide the password better */ |
|
|
1244 | |
|
|
1245 | if (checkbanned (op->name, op->contr->socket.host)) |
|
|
1246 | { |
|
|
1247 | LOG (llevInfo, "Banned player tried to add: [%s@%s]\n", &op->name, op->contr->socket.host); |
|
|
1248 | new_draw_info (NDI_UNIQUE | NDI_RED, 0, op, "You are not allowed to play."); |
|
|
1249 | get_name (op); |
|
|
1250 | return; |
|
|
1251 | } |
|
|
1252 | |
|
|
1253 | if (op->contr->state == ST_CONFIRM_PASSWORD) |
|
|
1254 | { |
|
|
1255 | if (!check_password (op->contr->write_buf + 1, op->contr->password)) |
|
|
1256 | { |
|
|
1257 | new_draw_info (NDI_UNIQUE, 0, op, "The passwords did not match."); |
|
|
1258 | get_name (op); |
|
|
1259 | return; |
|
|
1260 | } |
|
|
1261 | clear_win_info (op); |
|
|
1262 | display_motd (op); |
|
|
1263 | new_draw_info (NDI_UNIQUE, 0, op, " "); |
|
|
1264 | new_draw_info (NDI_UNIQUE, 0, op, "Welcome, Brave New Warrior!"); |
|
|
1265 | new_draw_info (NDI_UNIQUE, 0, op, " "); |
|
|
1266 | Roll_Again (op); |
|
|
1267 | op->contr->state = ST_ROLL_STAT; |
|
|
1268 | return; |
|
|
1269 | } |
|
|
1270 | strcpy (op->contr->password, crypt_string (op->contr->write_buf + 1, NULL)); |
|
|
1271 | op->contr->state = ST_ROLL_STAT; |
|
|
1272 | check_login (op); |
|
|
1273 | return; |
|
|
1274 | } |
|
|
1275 | |
|
|
1276 | |
|
|
1277 | int |
|
|
1278 | explore_mode (void) |
|
|
1279 | { |
|
|
1280 | player *pl; |
|
|
1281 | |
|
|
1282 | if (settings.explore_mode == TRUE) |
|
|
1283 | { |
|
|
1284 | for (pl = first_player; pl != (player *) NULL; pl = pl->next) |
|
|
1285 | if (pl->explore) |
|
|
1286 | return 1; |
|
|
1287 | } |
|
|
1288 | return 0; |
|
|
1289 | } |
|
|
1290 | |
|
|
1291 | |
269 | |
1292 | int |
270 | int |
1293 | command_title (object *op, char *params) |
271 | command_title (object *op, char *params) |
1294 | { |
272 | { |
1295 | char buf[MAX_BUF]; |
273 | char buf[MAX_BUF]; |
… | |
… | |
1334 | strcpy (op->contr->own_title, params); |
312 | strcpy (op->contr->own_title, params); |
1335 | return 1; |
313 | return 1; |
1336 | } |
314 | } |
1337 | |
315 | |
1338 | int |
316 | int |
1339 | command_save (object *op, char *params) |
|
|
1340 | { |
|
|
1341 | // if (get_map_flags(op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_CLERIC) { |
|
|
1342 | // new_draw_info(NDI_UNIQUE, 0, op, "You can not save on unholy ground"); |
|
|
1343 | // } else |
|
|
1344 | if (!op->stats.exp) |
|
|
1345 | { |
|
|
1346 | new_draw_info (NDI_UNIQUE, 0, op, "You don't deserve to save yet."); |
|
|
1347 | } |
|
|
1348 | else |
|
|
1349 | { |
|
|
1350 | if (save_player (op, 1)) |
|
|
1351 | new_draw_info (NDI_UNIQUE, 0, op, "You have been saved."); |
|
|
1352 | else |
|
|
1353 | new_draw_info (NDI_UNIQUE, 0, op, "SAVE FAILED!"); |
|
|
1354 | } |
|
|
1355 | return 1; |
|
|
1356 | } |
|
|
1357 | |
|
|
1358 | |
|
|
1359 | int |
|
|
1360 | command_peaceful (object *op, char *params) |
|
|
1361 | { |
|
|
1362 | new_draw_info (NDI_UNIQUE, 0, op, |
|
|
1363 | "You cannot change your peaceful setting with this command." |
|
|
1364 | " Please speak to the priest in the temple of Gorokh" |
|
|
1365 | " if you want to become hostile or in temple of Valriel" " if you want to become peaceful again."); |
|
|
1366 | |
|
|
1367 | /* |
|
|
1368 | if((op->contr->peaceful=!op->contr->peaceful)) |
|
|
1369 | new_draw_info(NDI_UNIQUE, 0,op,"You will not attack other players."); |
|
|
1370 | else |
|
|
1371 | new_draw_info(NDI_UNIQUE, 0,op,"You will attack other players."); |
|
|
1372 | */ |
|
|
1373 | return 1; |
|
|
1374 | } |
|
|
1375 | |
|
|
1376 | |
|
|
1377 | |
|
|
1378 | int |
|
|
1379 | command_wimpy (object *op, char *params) |
|
|
1380 | { |
|
|
1381 | int i; |
|
|
1382 | char buf[MAX_BUF]; |
|
|
1383 | |
|
|
1384 | if (params == NULL || !sscanf (params, "%d", &i)) |
|
|
1385 | { |
|
|
1386 | sprintf (buf, "Your current wimpy level is %d.", op->run_away); |
|
|
1387 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
1388 | return 1; |
|
|
1389 | } |
|
|
1390 | sprintf (buf, "Your new wimpy level is %d.", i); |
|
|
1391 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
|
|
1392 | op->run_away = i; |
|
|
1393 | return 1; |
|
|
1394 | } |
|
|
1395 | |
|
|
1396 | |
|
|
1397 | int |
|
|
1398 | command_brace (object *op, char *params) |
|
|
1399 | { |
|
|
1400 | if (!params) |
|
|
1401 | op->contr->braced = !op->contr->braced; |
|
|
1402 | else |
|
|
1403 | op->contr->braced = onoff_value (params); |
|
|
1404 | |
|
|
1405 | if (op->contr->braced) |
|
|
1406 | new_draw_info (NDI_UNIQUE, 0, op, "You are braced."); |
|
|
1407 | else |
|
|
1408 | new_draw_info (NDI_UNIQUE, 0, op, "Not braced."); |
|
|
1409 | |
|
|
1410 | fix_player (op); |
|
|
1411 | return 0; |
|
|
1412 | } |
|
|
1413 | |
|
|
1414 | int |
|
|
1415 | command_style_map_info (object *op, char *params) |
|
|
1416 | { |
|
|
1417 | extern maptile *styles; |
|
|
1418 | maptile *mp; |
|
|
1419 | int maps_used = 0, mapmem = 0, objects_used = 0, x, y; |
|
|
1420 | object *tmp; |
|
|
1421 | |
|
|
1422 | for (mp = styles; mp != NULL; mp = mp->next) |
|
|
1423 | { |
|
|
1424 | maps_used++; |
|
|
1425 | mapmem += MAP_WIDTH (mp) * MAP_HEIGHT (mp) * (sizeof (object *) + sizeof (MapSpace)) + sizeof (maptile); |
|
|
1426 | for (x = 0; x < MAP_WIDTH (mp); x++) |
|
|
1427 | { |
|
|
1428 | for (y = 0; y < MAP_HEIGHT (mp); y++) |
|
|
1429 | { |
|
|
1430 | for (tmp = get_map_ob (mp, x, y); tmp != NULL; tmp = tmp->above) |
|
|
1431 | objects_used++; |
|
|
1432 | } |
|
|
1433 | } |
|
|
1434 | } |
|
|
1435 | new_draw_info_format (NDI_UNIQUE, 0, op, "Style maps loaded: %d", maps_used); |
|
|
1436 | new_draw_info (NDI_UNIQUE, 0, op, "Memory used, not"); |
|
|
1437 | new_draw_info_format (NDI_UNIQUE, 0, op, "including objects: %d", mapmem); |
|
|
1438 | new_draw_info_format (NDI_UNIQUE, 0, op, "Style objects: %d", objects_used); |
|
|
1439 | new_draw_info_format (NDI_UNIQUE, 0, op, "Mem for objects: %d", objects_used * sizeof (object)); |
|
|
1440 | return 0; |
|
|
1441 | } |
|
|
1442 | |
|
|
1443 | int |
|
|
1444 | command_kill_pets (object *op, char *params) |
317 | command_kill_pets (object *op, char *params) |
1445 | { |
318 | { |
1446 | objectlink *obl, *next; |
319 | objectlink *obl, *next; |
1447 | int counter = 0, removecount = 0; |
320 | int counter = 0, removecount = 0; |
1448 | |
321 | |
1449 | if (params == NULL) |
322 | if (!params) |
1450 | { |
323 | { |
1451 | terminate_all_pets (op); |
324 | terminate_all_pets (op); |
1452 | new_draw_info (NDI_UNIQUE, 0, op, "Your pets have been killed."); |
325 | new_draw_info (NDI_UNIQUE, 0, op, "Your pets have been killed."); |
1453 | } |
326 | } |
1454 | else |
327 | else |
1455 | { |
328 | { |
1456 | int target = atoi (params); |
329 | int target = atoi (params); |
1457 | |
330 | |
1458 | for (obl = first_friendly_object; obl != NULL; obl = next) |
331 | for (obl = first_friendly_object; obl; obl = next) |
1459 | { |
332 | { |
1460 | object *ob = obl->ob; |
333 | object *ob = obl->ob; |
1461 | |
334 | |
1462 | next = obl->next; |
335 | next = obl->next; |
|
|
336 | |
1463 | if (get_owner (ob) == op) |
337 | if (ob->owner == op) |
1464 | if (++counter == target || (target == 0 && !strcasecmp (ob->name, params))) |
338 | if (++counter == target || (target == 0 && !strcasecmp (ob->name, params))) |
1465 | { |
339 | { |
1466 | if (!QUERY_FLAG (ob, FLAG_REMOVED)) |
|
|
1467 | remove_ob (ob); |
|
|
1468 | remove_friendly_object (ob); |
|
|
1469 | free_object (ob); |
340 | ob->destroy (); |
1470 | removecount++; |
341 | removecount++; |
1471 | } |
342 | } |
1472 | } |
343 | } |
|
|
344 | |
1473 | if (removecount != 0) |
345 | if (removecount != 0) |
1474 | new_draw_info_format (NDI_UNIQUE, 0, op, "killed %d pets.\n", removecount); |
346 | new_draw_info_format (NDI_UNIQUE, 0, op, "killed %d pets.\n", removecount); |
1475 | else |
347 | else |
1476 | new_draw_info (NDI_UNIQUE, 0, op, "Couldn't find any suitable pets to kill.\n"); |
348 | new_draw_info (NDI_UNIQUE, 0, op, "Couldn't find any suitable pets to kill.\n"); |
1477 | } |
349 | } |
|
|
350 | |
1478 | return 0; |
351 | return 0; |
1479 | } |
352 | } |