1 | |
|
|
2 | /* |
|
|
3 | * static char *rcsid_c_wiz_c = |
|
|
4 | * "$Id: c_wiz.C,v 1.11 2006/09/14 21:16:12 root Exp $"; |
|
|
5 | */ |
|
|
6 | |
|
|
7 | /* |
1 | /* |
8 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
9 | |
3 | |
10 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
11 | Copyright (C) 1992 Frank Tore Johansen |
5 | Copyright (C) 1992 Frank Tore Johansen |
… | |
… | |
22 | |
16 | |
23 | 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 |
24 | along with this program; if not, write to the Free Software |
18 | along with this program; if not, write to the Free Software |
25 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
26 | |
20 | |
27 | 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> |
28 | */ |
22 | */ |
29 | |
23 | |
30 | #include <global.h> |
24 | #include <global.h> |
31 | #ifndef __CEXTRACT__ |
25 | #ifndef __CEXTRACT__ |
32 | # include <sproto.h> |
26 | # include <sproto.h> |
… | |
… | |
53 | * other player, or NULL otherwise. |
47 | * other player, or NULL otherwise. |
54 | */ |
48 | */ |
55 | static player * |
49 | static player * |
56 | get_other_player_from_name (object *op, char *name) |
50 | get_other_player_from_name (object *op, char *name) |
57 | { |
51 | { |
58 | player *pl; |
|
|
59 | |
|
|
60 | if (!name) |
52 | if (!name) |
61 | return NULL; |
53 | return NULL; |
62 | |
54 | |
63 | for (pl = first_player; pl != NULL; pl = pl->next) |
55 | for_all_players (pl) |
64 | if (!strncmp (pl->ob->name, name, MAX_NAME)) |
56 | if (!strncmp (pl->ob->name, name, MAX_NAME)) |
65 | break; |
|
|
66 | |
|
|
67 | if (pl == NULL) |
|
|
68 | { |
57 | { |
69 | new_draw_info (NDI_UNIQUE, 0, op, "No such player."); |
|
|
70 | return NULL; |
|
|
71 | } |
|
|
72 | |
|
|
73 | if (pl->ob == op) |
58 | if (pl->ob == op) |
74 | { |
59 | { |
75 | new_draw_info (NDI_UNIQUE, 0, op, "You can't do that to yourself."); |
60 | new_draw_info (NDI_UNIQUE, 0, op, "You can't do that to yourself."); |
76 | return NULL; |
61 | return NULL; |
77 | } |
62 | } |
|
|
63 | |
78 | if (pl->state != ST_PLAYING) |
64 | if (pl->ns->state != ST_PLAYING) |
79 | { |
65 | { |
80 | new_draw_info (NDI_UNIQUE, 0, op, "That player is in no state for that right now."); |
66 | new_draw_info (NDI_UNIQUE, 0, op, "That player is in no state for that right now."); |
81 | return NULL; |
67 | return NULL; |
82 | } |
|
|
83 | return pl; |
|
|
84 | } |
|
|
85 | |
|
|
86 | /** |
|
|
87 | * This command will stress server. |
|
|
88 | */ |
|
|
89 | int |
|
|
90 | command_loadtest (object *op, char *params) |
|
|
91 | { |
|
|
92 | uint32 x, y; |
|
|
93 | char buf[1024]; |
|
|
94 | |
|
|
95 | new_draw_info (NDI_UNIQUE, 0, op, "loadtest will stress server through teleporting"); |
|
|
96 | new_draw_info (NDI_UNIQUE, 0, op, "at different map places."); |
|
|
97 | new_draw_info (NDI_UNIQUE, 0, op, "use at your own risks."); |
|
|
98 | new_draw_info (NDI_UNIQUE, 0, op, "Very long loop used so server may have to be reset."); |
|
|
99 | new_draw_info (NDI_UNIQUE, 0, op, "type loadtest TRUE to run"); |
|
|
100 | new_draw_info_format (NDI_UNIQUE, 0, op, "{%s}", params); |
|
|
101 | |
|
|
102 | if (!params) |
|
|
103 | return 0; |
|
|
104 | |
|
|
105 | if (strncmp (params, "TRUE", 4)) |
|
|
106 | return 0; |
|
|
107 | |
|
|
108 | new_draw_info_format (NDI_UNIQUE, 0, op, "gogogo"); |
|
|
109 | |
|
|
110 | for (x = 0; x < settings.worldmaptilesx; x++) |
|
|
111 | { |
|
|
112 | for (y = 0; y < settings.worldmaptilesy; y++) |
|
|
113 | { |
|
|
114 | sprintf (buf, "/world/world_%d_%d", x + settings.worldmapstartx, y + settings.worldmapstarty); |
|
|
115 | command_goto (op, buf); |
|
|
116 | } |
68 | } |
|
|
69 | |
|
|
70 | return pl; |
117 | } |
71 | } |
118 | |
72 | |
|
|
73 | new_draw_info (NDI_UNIQUE, 0, op, "No such player."); |
119 | return 0; |
74 | return 0; |
120 | } |
75 | } |
121 | |
76 | |
122 | /** |
77 | /** |
123 | * Actually hides specified player (obviously a DM). |
78 | * Actually hides specified player (obviously a DM). |
… | |
… | |
258 | now = time (NULL); |
213 | now = time (NULL); |
259 | /* |
214 | /* |
260 | * Record this as a comment - then we don't have to worry about changing |
215 | * Record this as a comment - then we don't have to worry about changing |
261 | * the parsing code. |
216 | * the parsing code. |
262 | */ |
217 | */ |
263 | fprintf (banishfile, "# %s (%s) banned by %s at %s\n", &pl->ob->name, pl->socket.host, &op->name, ctime (&now)); |
218 | fprintf (banishfile, "# %s (%s) banned by %s at %s\n", &pl->ob->name, pl->ns->host, &op->name, ctime (&now)); |
264 | fprintf (banishfile, "*@%s\n", pl->socket.host); |
219 | fprintf (banishfile, "*@%s\n", pl->ns->host); |
265 | fclose (banishfile); |
220 | fclose (banishfile); |
266 | |
221 | |
267 | LOG (llevDebug, "! %s banned %s from IP: %s.\n", &op->name, &pl->ob->name, pl->socket.host); |
222 | LOG (llevDebug, "! %s banned %s from IP: %s.\n", &op->name, &pl->ob->name, pl->ns->host); |
268 | new_draw_info_format (NDI_UNIQUE | NDI_RED, 0, op, "You banish %s", &pl->ob->name); |
223 | new_draw_info_format (NDI_UNIQUE | NDI_RED, 0, op, "You banish %s", &pl->ob->name); |
269 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 5, op, "%s banishes %s from the land!", &op->name, &pl->ob->name); |
224 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 5, op, "%s banishes %s from the land!", &op->name, &pl->ob->name); |
270 | command_kick (op, (char *) &pl->ob->name); |
225 | command_kick (op, (char *) &pl->ob->name); |
271 | return 1; |
226 | return 1; |
272 | } |
227 | } |
273 | |
228 | |
274 | int |
229 | int |
275 | command_kick (object *op, char *params) |
230 | command_kick (object *op, char *params) |
276 | { |
231 | { |
277 | struct pl *pl; |
232 | for_all_players (pl) |
278 | |
|
|
279 | for (pl = first_player; pl != NULL; pl = pl->next) |
|
|
280 | if ((params == NULL || !strcmp (&pl->ob->name, params)) && !INVOKE_PLAYER (KICK, pl, ARG_STRING (params))) |
233 | if ((params == NULL || !strcmp (&pl->ob->name, params)) && !INVOKE_PLAYER (KICK, pl, ARG_STRING (params))) |
281 | { |
234 | { |
282 | object *op = pl->ob; |
235 | object *op = pl->ob; |
283 | |
236 | |
284 | if (!QUERY_FLAG (op, FLAG_REMOVED) && !QUERY_FLAG (op, FLAG_FREED)) |
237 | if (!QUERY_FLAG (op, FLAG_REMOVED) && !QUERY_FLAG (op, FLAG_FREED)) |
285 | { |
238 | { |
286 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 5, op, "%s is kicked out of the game.", &op->name); |
239 | new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 5, op, "%s is kicked out of the game.", &op->name); |
287 | strcpy (op->contr->killer, "kicked"); |
240 | strcpy (op->contr->killer, "kicked"); |
288 | } |
241 | } |
289 | |
242 | |
290 | pl->socket.status = Ns_Dead; |
243 | pl->ns->destroy (); |
291 | } |
244 | } |
292 | |
245 | |
293 | return 1; |
246 | return 1; |
294 | } |
247 | } |
295 | |
248 | |
|
|
249 | //TODO |
|
|
250 | #if 0 |
296 | int |
251 | int |
297 | command_save_overlay (object *op, char *params) |
252 | command_save_overlay (object *op, char *params) |
298 | { |
253 | { |
299 | if (!op) |
254 | if (!op) |
300 | return 0; |
255 | return 0; |
… | |
… | |
311 | |
266 | |
312 | ready_map_name (op->map->path, 0); |
267 | ready_map_name (op->map->path, 0); |
313 | |
268 | |
314 | return 1; |
269 | return 1; |
315 | } |
270 | } |
|
|
271 | #endif |
316 | |
272 | |
317 | int |
273 | int |
318 | command_shutdown (object *op, char *params) |
274 | command_shutdown (object *op, char *params) |
319 | { |
275 | { |
320 | struct pl *pl; |
|
|
321 | |
|
|
322 | if (op != NULL && !QUERY_FLAG (op, FLAG_WIZ)) |
276 | if (op != NULL && !QUERY_FLAG (op, FLAG_WIZ)) |
323 | { |
277 | { |
324 | new_draw_info (NDI_UNIQUE, 0, op, "Sorry, you can't shutdown the server."); |
278 | new_draw_info (NDI_UNIQUE, 0, op, "Sorry, you can't shutdown the server."); |
325 | return 1; |
279 | return 1; |
326 | } |
280 | } |
327 | |
281 | |
328 | for (pl = first_player; pl != NULL; pl = pl->next) |
|
|
329 | save_player (pl->ob, 0); |
|
|
330 | |
|
|
331 | for (pl = first_player; pl != NULL; pl = pl->next) |
|
|
332 | if (!QUERY_FLAG (pl->ob, FLAG_REMOVED)) |
|
|
333 | leave_map (pl->ob); |
|
|
334 | |
|
|
335 | cleanup (); |
282 | cleanup (0); |
|
|
283 | |
336 | /* not reached */ |
284 | /* not reached */ |
337 | return 1; |
|
|
338 | } |
|
|
339 | |
|
|
340 | int |
|
|
341 | command_goto (object *op, char *params) |
|
|
342 | { |
|
|
343 | char *name; |
|
|
344 | object *dummy; |
|
|
345 | |
|
|
346 | if (!op) |
|
|
347 | return 0; |
|
|
348 | |
|
|
349 | if (params == NULL) |
|
|
350 | { |
|
|
351 | new_draw_info (NDI_UNIQUE, 0, op, "Go to what level?"); |
|
|
352 | return 1; |
|
|
353 | } |
|
|
354 | |
|
|
355 | name = params; |
|
|
356 | dummy = get_object (); |
|
|
357 | dummy->map = op->map; |
|
|
358 | EXIT_PATH (dummy) = name; |
|
|
359 | dummy->name = name; |
|
|
360 | |
|
|
361 | enter_exit (op, dummy); |
|
|
362 | free_object (dummy); |
|
|
363 | if (op->contr->loading == NULL) |
|
|
364 | { |
|
|
365 | new_draw_info_format (NDI_UNIQUE, 0, op, "Difficulty: %d.", op->map->difficulty); |
|
|
366 | } |
|
|
367 | |
|
|
368 | return 1; |
|
|
369 | } |
|
|
370 | |
|
|
371 | /* is this function called from somewhere ? -Tero */ |
|
|
372 | int |
|
|
373 | command_generate (object *op, char *params) |
|
|
374 | { |
|
|
375 | object *tmp; |
|
|
376 | int nr = 1, i, retry; |
|
|
377 | |
|
|
378 | if (!op) |
|
|
379 | return 0; |
|
|
380 | |
|
|
381 | if (params != NULL) |
|
|
382 | sscanf (params, "%d", &nr); |
|
|
383 | for (i = 0; i < nr; i++) |
|
|
384 | { |
|
|
385 | retry = 50; |
|
|
386 | while ((tmp = generate_treasure (0, op->map->difficulty)) == NULL && --retry) |
|
|
387 | ; |
|
|
388 | if (tmp != NULL) |
|
|
389 | { |
|
|
390 | tmp = insert_ob_in_ob (tmp, op); |
|
|
391 | if (op->type == PLAYER) |
|
|
392 | esrv_send_item (op, tmp); |
|
|
393 | } |
|
|
394 | } |
|
|
395 | |
|
|
396 | return 1; |
285 | return 1; |
397 | } |
286 | } |
398 | |
287 | |
399 | int |
288 | int |
400 | command_freeze (object *op, char *params) |
289 | command_freeze (object *op, char *params) |
… | |
… | |
438 | object *dummy; |
327 | object *dummy; |
439 | player *pl; |
328 | player *pl; |
440 | |
329 | |
441 | if (!op) |
330 | if (!op) |
442 | return 0; |
331 | return 0; |
|
|
332 | |
443 | if (params == NULL) |
333 | if (params == NULL) |
444 | { |
334 | { |
445 | new_draw_info (NDI_UNIQUE, 0, op, "Usage: arrest <player>."); |
335 | new_draw_info (NDI_UNIQUE, 0, op, "Usage: arrest <player>."); |
446 | return 1; |
336 | return 1; |
447 | } |
337 | } |
|
|
338 | |
448 | pl = get_other_player_from_name (op, params); |
339 | pl = get_other_player_from_name (op, params); |
449 | if (!pl) |
340 | if (!pl) |
450 | return 1; |
341 | return 1; |
|
|
342 | |
451 | dummy = get_jail_exit (pl->ob); |
343 | dummy = get_jail_exit (pl->ob); |
452 | if (!dummy) |
344 | if (!dummy) |
453 | { |
345 | { |
454 | /* we have nowhere to send the prisoner.... */ |
346 | /* we have nowhere to send the prisoner.... */ |
455 | new_draw_info (NDI_UNIQUE, 0, op, "can't jail player, there is no map to hold them"); |
347 | new_draw_info (NDI_UNIQUE, 0, op, "can't jail player, there is no map to hold them"); |
456 | return 0; |
348 | return 0; |
457 | } |
349 | } |
458 | enter_exit (pl->ob, dummy); |
350 | |
459 | free_object (dummy); |
351 | pl->ob->enter_exit (dummy); |
|
|
352 | dummy->destroy (); |
460 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You have been arrested."); |
353 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You have been arrested."); |
461 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
354 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
462 | LOG (llevInfo, "Player %s arrested by %s\n", &pl->ob->name, &op->name); |
355 | LOG (llevInfo, "Player %s arrested by %s\n", &pl->ob->name, &op->name); |
463 | return 1; |
356 | return 1; |
464 | } |
357 | } |
… | |
… | |
488 | { |
381 | { |
489 | new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to place summoned player."); |
382 | new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to place summoned player."); |
490 | return 1; |
383 | return 1; |
491 | } |
384 | } |
492 | |
385 | |
493 | dummy = get_object (); |
386 | dummy = object::create (); |
494 | EXIT_PATH (dummy) = op->map->path; |
387 | EXIT_PATH (dummy) = op->map->path; |
495 | EXIT_X (dummy) = op->x + freearr_x[i]; |
388 | EXIT_X (dummy) = op->x + freearr_x[i]; |
496 | EXIT_Y (dummy) = op->y + freearr_y[i]; |
389 | EXIT_Y (dummy) = op->y + freearr_y[i]; |
497 | enter_exit (pl->ob, dummy); |
390 | pl->ob->enter_exit (dummy); |
498 | free_object (dummy); |
391 | dummy->destroy (); |
499 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned."); |
392 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned."); |
500 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
393 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
501 | |
394 | |
502 | return 1; |
395 | return 1; |
503 | } |
396 | } |
… | |
… | |
532 | { |
425 | { |
533 | new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to teleport to."); |
426 | new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to teleport to."); |
534 | return 1; |
427 | return 1; |
535 | } |
428 | } |
536 | |
429 | |
537 | dummy = get_object (); |
430 | dummy = object::create (); |
538 | EXIT_PATH (dummy) = pl->ob->map->path; |
431 | EXIT_PATH (dummy) = pl->ob->map->path; |
539 | EXIT_X (dummy) = pl->ob->x + freearr_x[i]; |
432 | EXIT_X (dummy) = pl->ob->x + freearr_x[i]; |
540 | EXIT_Y (dummy) = pl->ob->y + freearr_y[i]; |
433 | EXIT_Y (dummy) = pl->ob->y + freearr_y[i]; |
541 | enter_exit (op, dummy); |
434 | op->enter_exit (dummy); |
542 | free_object (dummy); |
435 | dummy->destroy (); |
543 | if (!op->contr->hidden) |
436 | if (!op->contr->hidden) |
544 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You see a portal open."); |
437 | new_draw_info (NDI_UNIQUE, 0, pl->ob, "You see a portal open."); |
545 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
438 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
546 | return 1; |
439 | return 1; |
547 | } |
440 | } |
… | |
… | |
834 | * so just copying it over should be fine. |
727 | * so just copying it over should be fine. |
835 | */ |
728 | */ |
836 | if (!head) |
729 | if (!head) |
837 | { |
730 | { |
838 | head = dup; |
731 | head = dup; |
839 | copy_object (tmp, dup); |
732 | tmp->copy_to (dup); |
840 | } |
733 | } |
841 | |
734 | |
842 | if (settings.real_wiz == FALSE) |
735 | if (settings.real_wiz == FALSE) |
843 | SET_FLAG (dup, FLAG_WAS_WIZ); |
736 | SET_FLAG (dup, FLAG_WAS_WIZ); |
844 | |
737 | |
… | |
… | |
871 | if (out_of_map (op->map, head->x + size_x, head->y + size_y)) |
764 | if (out_of_map (op->map, head->x + size_x, head->y + size_y)) |
872 | { |
765 | { |
873 | if (head->x < size_x || head->y < size_y) |
766 | if (head->x < size_x || head->y < size_y) |
874 | { |
767 | { |
875 | dm_stack_pop (op->contr); |
768 | dm_stack_pop (op->contr); |
876 | free_object (head); |
769 | head->destroy (); |
877 | new_draw_info (NDI_UNIQUE, 0, op, "Object too big to insert in map, or wrong position."); |
770 | new_draw_info (NDI_UNIQUE, 0, op, "Object too big to insert in map, or wrong position."); |
878 | free_object (tmp); |
771 | tmp->destroy (); |
879 | return 1; |
772 | return 1; |
880 | } |
773 | } |
881 | |
774 | |
882 | check = head; |
775 | check = head; |
883 | |
776 | |
… | |
… | |
905 | |
798 | |
906 | esrv_send_item (op, head); |
799 | esrv_send_item (op, head); |
907 | } |
800 | } |
908 | |
801 | |
909 | /* free the one we used to copy */ |
802 | /* free the one we used to copy */ |
910 | free_object (tmp); |
803 | tmp->destroy (); |
911 | } |
804 | } |
912 | |
805 | |
913 | return 1; |
806 | return 1; |
914 | } |
807 | } |
915 | |
808 | |
… | |
… | |
957 | |
850 | |
958 | tmp = get_dm_object (op->contr, ¶ms, NULL); |
851 | tmp = get_dm_object (op->contr, ¶ms, NULL); |
959 | if (!tmp) |
852 | if (!tmp) |
960 | return 1; |
853 | return 1; |
961 | |
854 | |
962 | dump_object (tmp); |
855 | char *dump = dump_object (tmp); |
963 | new_draw_info (NDI_UNIQUE, 0, op, errmsg); |
856 | new_draw_info (NDI_UNIQUE, 0, op, dump); |
|
|
857 | free (dump); |
|
|
858 | |
964 | if (QUERY_FLAG (tmp, FLAG_OBJ_ORIGINAL)) |
859 | if (QUERY_FLAG (tmp, FLAG_OBJ_ORIGINAL)) |
965 | new_draw_info (NDI_UNIQUE, 0, op, "Object is marked original"); |
860 | new_draw_info (NDI_UNIQUE, 0, op, "Object is marked original"); |
|
|
861 | |
966 | return 1; |
862 | return 1; |
967 | } |
863 | } |
968 | |
864 | |
969 | /** |
865 | /** |
970 | * When DM is possessing a monster, flip aggression on and off, to allow |
866 | * When DM is possessing a monster, flip aggression on and off, to allow |
… | |
… | |
1061 | victim->body_info[i] = 1; |
957 | victim->body_info[i] = 1; |
1062 | |
958 | |
1063 | esrv_new_player (pl, 80); /* just pick a wieght, we don't care */ |
959 | esrv_new_player (pl, 80); /* just pick a wieght, we don't care */ |
1064 | esrv_send_inventory (victim, victim); |
960 | esrv_send_inventory (victim, victim); |
1065 | |
961 | |
1066 | fix_player (victim); |
962 | victim->update_stats (); |
1067 | |
963 | |
1068 | do_some_living (victim); |
964 | do_some_living (victim); |
1069 | return 1; |
965 | return 1; |
1070 | } |
966 | } |
1071 | |
967 | |
… | |
… | |
1132 | dm_stack_pop (op->contr); |
1028 | dm_stack_pop (op->contr); |
1133 | |
1029 | |
1134 | /* Always work on the head - otherwise object will get in odd state */ |
1030 | /* Always work on the head - otherwise object will get in odd state */ |
1135 | if (tmp->head) |
1031 | if (tmp->head) |
1136 | tmp = tmp->head; |
1032 | tmp = tmp->head; |
1137 | remove_ob (tmp); |
1033 | tmp->remove (); |
1138 | return 1; |
1034 | return 1; |
1139 | } |
1035 | } |
1140 | |
1036 | |
1141 | int |
1037 | int |
1142 | command_free (object *op, char *params) |
1038 | command_free (object *op, char *params) |
… | |
… | |
1157 | dm_stack_pop (op->contr); |
1053 | dm_stack_pop (op->contr); |
1158 | |
1054 | |
1159 | if (!QUERY_FLAG (tmp, FLAG_REMOVED)) |
1055 | if (!QUERY_FLAG (tmp, FLAG_REMOVED)) |
1160 | { |
1056 | { |
1161 | new_draw_info (NDI_UNIQUE, 0, op, "Warning, item wasn't removed."); |
1057 | new_draw_info (NDI_UNIQUE, 0, op, "Warning, item wasn't removed."); |
1162 | remove_ob (tmp); |
1058 | tmp->remove (); |
1163 | } |
1059 | } |
1164 | |
1060 | |
1165 | if (tmp->head) |
1061 | if (tmp->head) |
1166 | tmp = tmp->head; |
1062 | tmp = tmp->head; |
1167 | free_object (tmp); |
1063 | |
|
|
1064 | tmp->destroy (); |
1168 | return 1; |
1065 | return 1; |
1169 | } |
1066 | } |
1170 | |
1067 | |
1171 | /** |
1068 | /** |
1172 | * This adds exp to a player. We now allow adding to a specific skill. |
1069 | * This adds exp to a player. We now allow adding to a specific skill. |
… | |
… | |
1175 | command_addexp (object *op, char *params) |
1072 | command_addexp (object *op, char *params) |
1176 | { |
1073 | { |
1177 | char buf[MAX_BUF], skill[MAX_BUF]; |
1074 | char buf[MAX_BUF], skill[MAX_BUF]; |
1178 | int i, q; |
1075 | int i, q; |
1179 | object *skillob = NULL; |
1076 | object *skillob = NULL; |
1180 | player *pl; |
|
|
1181 | |
1077 | |
1182 | skill[0] = '\0'; |
1078 | skill[0] = '\0'; |
1183 | if ((params == NULL) || (strlen (params) > MAX_BUF) || ((q = sscanf (params, "%s %d %s", buf, &i, skill)) < 2)) |
1079 | if ((params == NULL) || (strlen (params) > MAX_BUF) || ((q = sscanf (params, "%s %d %s", buf, &i, skill)) < 2)) |
1184 | { |
1080 | { |
1185 | new_draw_info (NDI_UNIQUE, 0, op, "Usage: addexp <who> <how much> [<skill>]."); |
1081 | new_draw_info (NDI_UNIQUE, 0, op, "Usage: addexp <who> <how much> [<skill>]."); |
1186 | return 1; |
1082 | return 1; |
1187 | } |
1083 | } |
1188 | |
1084 | |
1189 | for (pl = first_player; pl != NULL; pl = pl->next) |
1085 | for_all_players (pl) |
1190 | if (!strncmp (pl->ob->name, buf, MAX_NAME)) |
1086 | if (!strncmp (pl->ob->name, buf, MAX_NAME)) |
1191 | break; |
|
|
1192 | |
|
|
1193 | if (pl == NULL) |
|
|
1194 | { |
1087 | { |
1195 | new_draw_info (NDI_UNIQUE, 0, op, "No such player."); |
|
|
1196 | return 1; |
|
|
1197 | } |
|
|
1198 | |
|
|
1199 | if (q >= 3) |
1088 | if (q >= 3) |
1200 | { |
1089 | { |
1201 | skillob = find_skill_by_name (pl->ob, skill); |
1090 | skillob = find_skill_by_name (pl->ob, skill); |
1202 | if (!skillob) |
1091 | if (!skillob) |
1203 | { |
1092 | { |
1204 | new_draw_info_format (NDI_UNIQUE, 0, op, "Unable to find skill %s in %s", skill, buf); |
1093 | new_draw_info_format (NDI_UNIQUE, 0, op, "Unable to find skill %s in %s", skill, buf); |
|
|
1094 | return 1; |
|
|
1095 | } |
|
|
1096 | |
|
|
1097 | i = check_exp_adjust (skillob, i); |
|
|
1098 | skillob->stats.exp += i; |
|
|
1099 | calc_perm_exp (skillob); |
|
|
1100 | player_lvl_adj (pl->ob, skillob); |
|
|
1101 | } |
|
|
1102 | |
|
|
1103 | pl->ob->stats.exp += i; |
|
|
1104 | calc_perm_exp (pl->ob); |
|
|
1105 | player_lvl_adj (pl->ob, NULL); |
|
|
1106 | |
|
|
1107 | if (settings.real_wiz == FALSE) |
|
|
1108 | SET_FLAG (pl->ob, FLAG_WAS_WIZ); |
|
|
1109 | |
1205 | return 1; |
1110 | return 1; |
1206 | } |
1111 | } |
1207 | |
1112 | |
1208 | i = check_exp_adjust (skillob, i); |
1113 | new_draw_info (NDI_UNIQUE, 0, op, "No such player."); |
1209 | skillob->stats.exp += i; |
|
|
1210 | calc_perm_exp (skillob); |
|
|
1211 | player_lvl_adj (pl->ob, skillob); |
|
|
1212 | } |
|
|
1213 | |
|
|
1214 | pl->ob->stats.exp += i; |
|
|
1215 | calc_perm_exp (pl->ob); |
|
|
1216 | player_lvl_adj (pl->ob, NULL); |
|
|
1217 | |
|
|
1218 | if (settings.real_wiz == FALSE) |
|
|
1219 | SET_FLAG (pl->ob, FLAG_WAS_WIZ); |
|
|
1220 | return 1; |
1114 | return 1; |
1221 | } |
1115 | } |
1222 | |
1116 | |
1223 | /**************************************************************************/ |
1117 | /**************************************************************************/ |
1224 | |
1118 | |
… | |
… | |
1230 | |
1124 | |
1231 | int |
1125 | int |
1232 | command_stats (object *op, char *params) |
1126 | command_stats (object *op, char *params) |
1233 | { |
1127 | { |
1234 | char thing[20]; |
1128 | char thing[20]; |
1235 | player *pl; |
|
|
1236 | char buf[MAX_BUF]; |
1129 | char buf[MAX_BUF]; |
1237 | |
1130 | |
1238 | thing[0] = '\0'; |
1131 | thing[0] = '\0'; |
1239 | if (params == NULL || !sscanf (params, "%s", thing) || thing == NULL) |
1132 | if (params == NULL || !sscanf (params, "%s", thing) || thing == NULL) |
1240 | { |
1133 | { |
1241 | new_draw_info (NDI_UNIQUE, 0, op, "Who?"); |
1134 | new_draw_info (NDI_UNIQUE, 0, op, "Who?"); |
1242 | return 1; |
1135 | return 1; |
1243 | } |
1136 | } |
1244 | |
1137 | |
1245 | for (pl = first_player; pl != NULL; pl = pl->next) |
1138 | for_all_players (pl) |
1246 | if (!strcmp (pl->ob->name, thing)) |
1139 | if (!strcmp (pl->ob->name, thing)) |
1247 | { |
1140 | { |
1248 | sprintf (buf, "Str : %-2d H.P. : %-4d MAX : %d", pl->ob->stats.Str, pl->ob->stats.hp, pl->ob->stats.maxhp); |
1141 | sprintf (buf, "Str : %-2d H.P. : %-4d MAX : %d", pl->ob->stats.Str, pl->ob->stats.hp, pl->ob->stats.maxhp); |
1249 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1142 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1250 | sprintf (buf, "Dex : %-2d S.P. : %-4d MAX : %d", pl->ob->stats.Dex, pl->ob->stats.sp, pl->ob->stats.maxsp); |
1143 | sprintf (buf, "Dex : %-2d S.P. : %-4d MAX : %d", pl->ob->stats.Dex, pl->ob->stats.sp, pl->ob->stats.maxsp); |
1251 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1144 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1252 | sprintf (buf, "Con : %-2d AC : %-4d WC : %d", pl->ob->stats.Con, pl->ob->stats.ac, pl->ob->stats.wc); |
1145 | sprintf (buf, "Con : %-2d AC : %-4d WC : %d", pl->ob->stats.Con, pl->ob->stats.ac, pl->ob->stats.wc); |
1253 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1146 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1254 | sprintf (buf, "Int : %-2d Damage : %d", pl->ob->stats.Int, pl->ob->stats.dam); |
1147 | sprintf (buf, "Int : %-2d Damage : %d", pl->ob->stats.Int, pl->ob->stats.dam); |
1255 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1148 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1256 | sprintf (buf, "Wis : %-2d EXP : %lld", pl->ob->stats.Wis, (long long) pl->ob->stats.exp); |
1149 | sprintf (buf, "Wis : %-2d EXP : %" PRId64, pl->ob->stats.Wis, pl->ob->stats.exp); |
1257 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1150 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1258 | sprintf (buf, "Pow : %-2d Grace : %d", pl->ob->stats.Pow, pl->ob->stats.grace); |
1151 | sprintf (buf, "Pow : %-2d Grace : %d", pl->ob->stats.Pow, pl->ob->stats.grace); |
1259 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1152 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1260 | sprintf (buf, "Cha : %-2d Food : %d", pl->ob->stats.Cha, pl->ob->stats.food); |
1153 | sprintf (buf, "Cha : %-2d Food : %d", pl->ob->stats.Cha, pl->ob->stats.food); |
1261 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1154 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1262 | break; |
1155 | return 1; |
1263 | } |
1156 | } |
1264 | if (pl == NULL) |
1157 | |
1265 | new_draw_info (NDI_UNIQUE, 0, op, "No such player."); |
1158 | new_draw_info (NDI_UNIQUE, 0, op, "No such player."); |
1266 | return 1; |
1159 | return 1; |
1267 | } |
1160 | } |
1268 | |
1161 | |
1269 | int |
1162 | int |
1270 | command_abil (object *op, char *params) |
1163 | command_abil (object *op, char *params) |
… | |
… | |
1293 | { |
1186 | { |
1294 | new_draw_info (NDI_UNIQUE, 0, op, "Illegal range of stat.\n"); |
1187 | new_draw_info (NDI_UNIQUE, 0, op, "Illegal range of stat.\n"); |
1295 | return 1; |
1188 | return 1; |
1296 | } |
1189 | } |
1297 | |
1190 | |
1298 | for (pl = first_player; pl != NULL; pl = pl->next) |
1191 | for_all_players (pl) |
1299 | { |
1192 | { |
1300 | if (!strcmp (pl->ob->name, thing)) |
1193 | if (!strcmp (pl->ob->name, thing)) |
1301 | { |
1194 | { |
1302 | if (settings.real_wiz == FALSE) |
1195 | if (settings.real_wiz == FALSE) |
1303 | SET_FLAG (pl->ob, FLAG_WAS_WIZ); |
1196 | SET_FLAG (pl->ob, FLAG_WAS_WIZ); |
… | |
… | |
1315 | pl->ob->stats.Int = iii, pl->orig_stats.Int = iii; |
1208 | pl->ob->stats.Int = iii, pl->orig_stats.Int = iii; |
1316 | if (!strcmp ("pow", thing2)) |
1209 | if (!strcmp ("pow", thing2)) |
1317 | pl->ob->stats.Pow = iii, pl->orig_stats.Pow = iii; |
1210 | pl->ob->stats.Pow = iii, pl->orig_stats.Pow = iii; |
1318 | sprintf (buf, "%s has been altered.", &pl->ob->name); |
1211 | sprintf (buf, "%s has been altered.", &pl->ob->name); |
1319 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1212 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
1320 | fix_player (pl->ob); |
1213 | pl->ob->update_stats (); |
1321 | return 1; |
1214 | return 1; |
1322 | } |
1215 | } |
1323 | } |
1216 | } |
1324 | |
1217 | |
1325 | new_draw_info (NDI_UNIQUE, 0, op, "No such player."); |
1218 | new_draw_info (NDI_UNIQUE, 0, op, "No such player."); |
1326 | return 1; |
1219 | return 1; |
1327 | } |
|
|
1328 | |
|
|
1329 | int |
|
|
1330 | command_reset (object *op, char *params) |
|
|
1331 | { |
|
|
1332 | mapstruct *m; |
|
|
1333 | object *dummy = NULL, *tmp = NULL; |
|
|
1334 | |
|
|
1335 | if (params == NULL) |
|
|
1336 | { |
|
|
1337 | new_draw_info (NDI_UNIQUE, 0, op, "Reset what map [name]?"); |
|
|
1338 | return 1; |
|
|
1339 | } |
|
|
1340 | |
|
|
1341 | if (strcmp (params, ".") == 0) |
|
|
1342 | params = op->map->path; |
|
|
1343 | m = has_been_loaded (params); |
|
|
1344 | if (m == NULL) |
|
|
1345 | { |
|
|
1346 | new_draw_info (NDI_UNIQUE, 0, op, "No such map."); |
|
|
1347 | return 1; |
|
|
1348 | } |
|
|
1349 | |
|
|
1350 | if (m->in_memory != MAP_SWAPPED) |
|
|
1351 | { |
|
|
1352 | if (m->in_memory != MAP_IN_MEMORY) |
|
|
1353 | { |
|
|
1354 | LOG (llevError, "Tried to swap out map which was not in memory.\n"); |
|
|
1355 | return 0; |
|
|
1356 | } |
|
|
1357 | |
|
|
1358 | /* |
|
|
1359 | * Only attempt to remove the player that is doing the reset, and not other |
|
|
1360 | * players or wiz's. |
|
|
1361 | */ |
|
|
1362 | if (op->map == m) |
|
|
1363 | { |
|
|
1364 | dummy = get_object (); |
|
|
1365 | dummy->map = NULL; |
|
|
1366 | EXIT_X (dummy) = op->x; |
|
|
1367 | EXIT_Y (dummy) = op->y; |
|
|
1368 | EXIT_PATH (dummy) = op->map->path; |
|
|
1369 | remove_ob (op); |
|
|
1370 | op->map = NULL; |
|
|
1371 | tmp = op; |
|
|
1372 | } |
|
|
1373 | swap_map (m); |
|
|
1374 | } |
|
|
1375 | |
|
|
1376 | if (m->in_memory == MAP_SWAPPED) |
|
|
1377 | { |
|
|
1378 | LOG (llevDebug, "Resetting map %s.\n", m->path); |
|
|
1379 | |
|
|
1380 | /* setting this effectively causes an immediate reload */ |
|
|
1381 | m->reset_time = 1; |
|
|
1382 | flush_old_maps (); |
|
|
1383 | new_draw_info (NDI_UNIQUE, 0, op, "OK."); |
|
|
1384 | if (tmp) |
|
|
1385 | { |
|
|
1386 | enter_exit (tmp, dummy); |
|
|
1387 | free_object (dummy); |
|
|
1388 | } |
|
|
1389 | return 1; |
|
|
1390 | } |
|
|
1391 | else |
|
|
1392 | { |
|
|
1393 | player *pl; |
|
|
1394 | int playercount = 0; |
|
|
1395 | |
|
|
1396 | /* Need to re-insert player if swap failed for some reason */ |
|
|
1397 | if (tmp) |
|
|
1398 | { |
|
|
1399 | insert_ob_in_map (op, m, NULL, 0); |
|
|
1400 | free_object (dummy); |
|
|
1401 | } |
|
|
1402 | |
|
|
1403 | new_draw_info (NDI_UNIQUE, 0, op, "Reset failed, couldn't swap map, the following players are on it:"); |
|
|
1404 | for (pl = first_player; pl != NULL; pl = pl->next) |
|
|
1405 | { |
|
|
1406 | if (pl->ob->map == m && pl->ob != op) |
|
|
1407 | { |
|
|
1408 | new_draw_info_format (NDI_UNIQUE, 0, op, "%s", &pl->ob->name); |
|
|
1409 | playercount++; |
|
|
1410 | } |
|
|
1411 | } |
|
|
1412 | if (!playercount) |
|
|
1413 | new_draw_info (NDI_UNIQUE, 0, op, "hmm, I don't see any other players on this map, something else is the problem."); |
|
|
1414 | return 1; |
|
|
1415 | } |
|
|
1416 | } |
1220 | } |
1417 | |
1221 | |
1418 | int |
1222 | int |
1419 | command_nowiz (object *op, char *params) |
1223 | command_nowiz (object *op, char *params) |
1420 | { /* 'noadm' is alias */ |
1224 | { /* 'noadm' is alias */ |
… | |
… | |
1490 | { |
1294 | { |
1491 | new_draw_info (NDI_UNIQUE, 0, op, "You are already the Dungeon Master!"); |
1295 | new_draw_info (NDI_UNIQUE, 0, op, "You are already the Dungeon Master!"); |
1492 | return 0; |
1296 | return 0; |
1493 | } |
1297 | } |
1494 | |
1298 | |
1495 | if (checkdm (op, op->name, (params ? params : "*"), op->contr->socket.host)) |
1299 | if (checkdm (op, op->name, (params ? params : "*"), op->contr->ns->host)) |
1496 | { |
1300 | { |
1497 | SET_FLAG (op, FLAG_WIZ); |
1301 | SET_FLAG (op, FLAG_WIZ); |
1498 | SET_FLAG (op, FLAG_WAS_WIZ); |
1302 | SET_FLAG (op, FLAG_WAS_WIZ); |
1499 | SET_FLAG (op, FLAG_WIZPASS); |
1303 | SET_FLAG (op, FLAG_WIZPASS); |
1500 | SET_FLAG (op, FLAG_WIZCAST); |
1304 | SET_FLAG (op, FLAG_WIZCAST); |
… | |
… | |
1671 | new_draw_info_format (NDI_UNIQUE, 0, op, "You already know the spell %s.", &tmp->name); |
1475 | new_draw_info_format (NDI_UNIQUE, 0, op, "You already know the spell %s.", &tmp->name); |
1672 | return 0; |
1476 | return 0; |
1673 | } |
1477 | } |
1674 | |
1478 | |
1675 | do_learn_spell (op, tmp, special_prayer); |
1479 | do_learn_spell (op, tmp, special_prayer); |
1676 | free_object (tmp); |
1480 | tmp->destroy (); |
1677 | return 1; |
1481 | return 1; |
1678 | } |
1482 | } |
1679 | |
1483 | |
1680 | int |
1484 | int |
1681 | command_learn_spell (object *op, char *params) |
1485 | command_learn_spell (object *op, char *params) |
… | |
… | |
2093 | new_draw_info (NDI_UNIQUE, 0, op, "Can't insert a player into something!"); |
1897 | new_draw_info (NDI_UNIQUE, 0, op, "Can't insert a player into something!"); |
2094 | return 0; |
1898 | return 0; |
2095 | } |
1899 | } |
2096 | |
1900 | |
2097 | if (!QUERY_FLAG (right, FLAG_REMOVED)) |
1901 | if (!QUERY_FLAG (right, FLAG_REMOVED)) |
2098 | remove_ob (right); |
1902 | right->remove (); |
2099 | inserted = insert_ob_in_ob (right, left); |
1903 | inserted = insert_ob_in_ob (right, left); |
2100 | if (left->type == PLAYER) |
1904 | if (left->type == PLAYER) |
2101 | if (inserted == right) |
1905 | if (inserted == right) |
2102 | esrv_send_item (left, right); |
1906 | esrv_send_item (left, right); |
2103 | else |
1907 | else |