ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/c_wiz.C
(Generate patch)

Comparing deliantra/server/server/c_wiz.C (file contents):
Revision 1.28 by root, Sat Dec 30 10:16:11 2006 UTC vs.
Revision 1.41 by root, Wed Mar 14 04:12:29 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 * CrossFire, A Multiplayer game for X-windows
3 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
4 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (C) 1992 Frank Tore Johansen
6 7 *
7 This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 11 * (at your 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 GNU General Public License
18 along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 21 *
21 The authors can be reached via e-mail at <crossfire@schmorp.de> 22 * The authors can be reached via e-mail at <crossfire@schmorp.de>
22*/ 23 */
23 24
24#include <global.h> 25#include <global.h>
25#ifndef __CEXTRACT__
26# include <sproto.h> 26#include <sproto.h>
27#endif
28#include <spells.h> 27#include <spells.h>
29#include <treasure.h> 28#include <treasure.h>
30#include <skills.h> 29#include <skills.h>
31 30
32/** Defines for DM item stack **/ 31/** Defines for DM item stack **/
87 op->contr->hidden = 0; 86 op->contr->hidden = 0;
88 op->invisible = 1; 87 op->invisible = 1;
89 new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players"); 88 new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players");
90 op->map->players++; 89 op->map->players++;
91 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s has entered the game.", &op->name); 90 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s has entered the game.", &op->name);
91
92 if (!silent_dm) 92 if (!silent_dm)
93 {
94 new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!"); 93 new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!");
95 }
96 } 94 }
97 else 95 else
98 { 96 {
99 op->contr->hidden = 1; 97 op->contr->hidden = 1;
100 new_draw_info (NDI_UNIQUE, 0, op, "Other players will no longer see you."); 98 new_draw_info (NDI_UNIQUE, 0, op, "Other players will no longer see you.");
101 op->map->players--; 99 op->map->players--;
100
102 if (!silent_dm) 101 if (!silent_dm)
103 {
104 new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master is gone.."); 102 new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master is gone..");
105 } 103
106 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s leaves the game.", &op->name); 104 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s leaves the game.", &op->name);
107 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s left the game.", &op->name); 105 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s left the game.", &op->name);
108 } 106 }
109} 107}
110 108
174 172
175 become_follower (ob, god); 173 become_follower (ob, god);
176 return 1; 174 return 1;
177} 175}
178 176
179/** 177// TODO: Rewrite banish in perl and get rid of the following two functions
180 * Add player's IP to ban_file and kick them off the server
181 * I know most people have dynamic IPs but this is more of a short term
182 * solution if they have to get a new IP to play maybe they'll calm down.
183 * This uses the banish_file in the local directory *not* the ban_file
184 * The action is logged with a ! for easy searching. -tm
185 */
186int
187command_banish (object *op, char *params)
188{
189 player *pl;
190 FILE *banishfile;
191 char buf[MAX_BUF];
192 time_t now;
193
194 if (!params)
195 {
196 new_draw_info (NDI_UNIQUE, 0, op, "Usage: banish <player>.");
197 return 1;
198 }
199
200 pl = get_other_player_from_name (op, params);
201 if (!pl)
202 return 1;
203
204 sprintf (buf, "%s/%s", settings.localdir, BANISHFILE);
205
206 if ((banishfile = fopen (buf, "a")) == NULL)
207 {
208 LOG (llevDebug, "Could not find file banish_file.\n");
209 new_draw_info (NDI_UNIQUE, 0, op, "Could not find banish_file.");
210 return 0;
211 }
212
213 now = time (NULL);
214 /*
215 * Record this as a comment - then we don't have to worry about changing
216 * the parsing code.
217 */
218 fprintf (banishfile, "# %s (%s) banned by %s at %s\n", &pl->ob->name, pl->ns->host, &op->name, ctime (&now));
219 fprintf (banishfile, "*@%s\n", pl->ns->host);
220 fclose (banishfile);
221
222 LOG (llevDebug, "! %s banned %s from IP: %s.\n", &op->name, &pl->ob->name, pl->ns->host);
223 new_draw_info_format (NDI_UNIQUE | NDI_RED, 0, op, "You banish %s", &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);
225 command_kick (op, (char *) &pl->ob->name);
226 return 1;
227}
228
229int 178int
230command_kick (object *op, char *params) 179command_kick (object *op, char *params)
231{ 180{
232 for_all_players (pl) 181 for_all_players (pl)
233 if ((params == NULL || !strcmp (&pl->ob->name, params)) && !INVOKE_PLAYER (KICK, pl, ARG_STRING (params))) 182 if ((params == NULL || !strcmp (&pl->ob->name, params)) && !INVOKE_PLAYER (KICK, pl, ARG_STRING (params)))
267 ready_map_name (op->map->path, 0); 216 ready_map_name (op->map->path, 0);
268 217
269 return 1; 218 return 1;
270} 219}
271#endif 220#endif
272
273int
274command_shutdown (object *op, char *params)
275{
276 if (op != NULL && !QUERY_FLAG (op, FLAG_WIZ))
277 {
278 new_draw_info (NDI_UNIQUE, 0, op, "Sorry, you can't shutdown the server.");
279 return 1;
280 }
281
282 cleanup (0);
283
284 /* not reached */
285 return 1;
286}
287 221
288int 222int
289command_freeze (object *op, char *params) 223command_freeze (object *op, char *params)
290{ 224{
291 int ticks; 225 int ticks;
390 pl->ob->enter_exit (dummy); 324 pl->ob->enter_exit (dummy);
391 dummy->destroy (); 325 dummy->destroy ();
392 new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned."); 326 new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned.");
393 new_draw_info (NDI_UNIQUE, 0, op, "OK."); 327 new_draw_info (NDI_UNIQUE, 0, op, "OK.");
394 328
395 return 1;
396}
397
398/**
399 * Teleport next to target player.
400 */
401
402/* mids 01/16/2002 */
403int
404command_teleport (object *op, char *params)
405{
406 int i;
407 object *dummy;
408 player *pl;
409
410 if (!op)
411 return 0;
412
413 if (params == NULL)
414 {
415 new_draw_info (NDI_UNIQUE, 0, op, "Usage: teleport <player>.");
416 return 1;
417 }
418
419 pl = get_other_player_from_name (op, params);
420 if (!pl)
421 return 1;
422
423 i = find_free_spot (pl->ob, pl->ob->map, pl->ob->x, pl->ob->y, 1, 9);
424 if (i == -1)
425 {
426 new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to teleport to.");
427 return 1;
428 }
429
430 dummy = object::create ();
431 EXIT_PATH (dummy) = pl->ob->map->path;
432 EXIT_X (dummy) = pl->ob->x + freearr_x[i];
433 EXIT_Y (dummy) = pl->ob->y + freearr_y[i];
434 op->enter_exit (dummy);
435 dummy->destroy ();
436 if (!op->contr->hidden)
437 new_draw_info (NDI_UNIQUE, 0, pl->ob, "You see a portal open.");
438 new_draw_info (NDI_UNIQUE, 0, op, "OK.");
439 return 1; 329 return 1;
440} 330}
441 331
442/** 332/**
443 * This function is a real mess, because we're stucking getting 333 * This function is a real mess, because we're stucking getting
537 at_spell = archetype::find (cp); 427 at_spell = archetype::find (cp);
538 if (!at_spell || at_spell->clone.type != SPELL) 428 if (!at_spell || at_spell->clone.type != SPELL)
539 at_spell = find_archetype_by_object_name (cp); 429 at_spell = find_archetype_by_object_name (cp);
540 if (!at_spell || at_spell->clone.type != SPELL) 430 if (!at_spell || at_spell->clone.type != SPELL)
541 { 431 {
542 strcpy (spell_name, cp); 432 assign (spell_name, cp);
543 fsp = strchr (spell_name, ' '); 433 fsp = strchr (spell_name, ' ');
544 if (fsp) 434 if (fsp)
545 { 435 {
546 *fsp = 0; 436 *fsp = 0;
547 fsp++; 437 fsp++;
860 new_draw_info (NDI_UNIQUE, 0, op, "Object is marked original"); 750 new_draw_info (NDI_UNIQUE, 0, op, "Object is marked original");
861 751
862 return 1; 752 return 1;
863} 753}
864 754
865/**
866 * When DM is possessing a monster, flip aggression on and off, to allow
867 * better motion.
868 */
869int
870command_mon_aggr (object *op, char *params)
871{
872 if (op->enemy || !QUERY_FLAG (op, FLAG_UNAGGRESSIVE))
873 {
874 op->enemy = NULL;
875 SET_FLAG (op, FLAG_UNAGGRESSIVE);
876 new_draw_info (NDI_UNIQUE, 0, op, "Aggression turned OFF");
877 }
878 else
879 {
880 CLEAR_FLAG (op, FLAG_FRIENDLY);
881 CLEAR_FLAG (op, FLAG_UNAGGRESSIVE);
882 new_draw_info (NDI_UNIQUE, 0, op, "Aggression turned ON");
883 }
884
885 return 1;
886}
887
888/** DM can possess a monster. Basically, this tricks the client into thinking
889 * a given monster, is actually the player it controls. This allows a DM
890 * to inhabit a monster's body, and run around the game with it.
891 * This function is severely broken - it has tons of hardcoded values,
892 */
893int
894command_possess (object *op, char *params)
895{
896 object *victim, *curinv, *nextinv;
897 player *pl;
898 int i;
899 char buf[MAX_BUF];
900
901 victim = NULL;
902 if (params != NULL)
903 {
904 if (sscanf (params, "%d", &i))
905 victim = find_object (i);
906 else if (sscanf (params, "%s", buf))
907 victim = find_object_name (buf);
908 }
909 if (victim == NULL)
910 {
911 new_draw_info (NDI_UNIQUE, 0, op, "Patch what object (nr)?");
912 return 1;
913 }
914
915 if (victim == op)
916 {
917 new_draw_info (NDI_UNIQUE, 0, op, "As insane as you are, I cannot " "allow you to possess yourself.");
918 return 1;
919 }
920
921 /* clear out the old inventory */
922 curinv = op->inv;
923 while (curinv != NULL)
924 {
925 nextinv = curinv->below;
926 esrv_del_item (op->contr, curinv->count);
927 curinv = nextinv;
928 }
929
930 /* make the switch */
931 pl = op->contr;
932 victim->contr = pl;
933 pl->ob = victim;
934 victim->type = PLAYER;
935 SET_FLAG (victim, FLAG_WIZ);
936
937 /* send the inventory to the client */
938 curinv = victim->inv;
939 while (curinv != NULL)
940 {
941 nextinv = curinv->below;
942 esrv_send_item (victim, curinv);
943 curinv = nextinv;
944 }
945 /* basic patchup */
946 /* The use of hard coded values is terrible. Note
947 * that really, to be fair, this shouldn't get changed at
948 * all - if you are possessing a kobold, you should have the
949 * same limitations. As it is, as more body locations are added,
950 * this will give this player more locations than perhaps
951 * they should be allowed.
952 */
953 for (i = 0; i < NUM_BODY_LOCATIONS; i++)
954 if (i == 1 || i == 6 || i == 8 || i == 9)
955 victim->body_info[i] = 2;
956 else
957 victim->body_info[i] = 1;
958
959 esrv_new_player (pl, 80); /* just pick a wieght, we don't care */
960 esrv_send_inventory (victim, victim);
961
962 victim->update_stats ();
963
964 do_some_living (victim);
965 return 1;
966}
967
968int 755int
969command_patch (object *op, char *params) 756command_patch (object *op, char *params)
970{ 757{
971 char *arg, *arg2; 758 char *arg, *arg2;
972 object *tmp; 759 object *tmp;
1049 } 836 }
1050 837
1051 if (from != STACK_FROM_STACK) 838 if (from != STACK_FROM_STACK)
1052 /* Item is either stack top, or is a number thus is now stack top, let's remove it */ 839 /* Item is either stack top, or is a number thus is now stack top, let's remove it */
1053 dm_stack_pop (op->contr); 840 dm_stack_pop (op->contr);
1054
1055 if (!QUERY_FLAG (tmp, FLAG_REMOVED))
1056 {
1057 new_draw_info (NDI_UNIQUE, 0, op, "Warning, item wasn't removed.");
1058 tmp->remove ();
1059 }
1060 841
1061 if (tmp->head) 842 if (tmp->head)
1062 tmp = tmp->head; 843 tmp = tmp->head;
1063 844
1064 tmp->destroy (); 845 tmp->destroy ();
1162int 943int
1163command_abil (object *op, char *params) 944command_abil (object *op, char *params)
1164{ 945{
1165 char thing[20], thing2[20]; 946 char thing[20], thing2[20];
1166 int iii; 947 int iii;
1167 player *pl;
1168 char buf[MAX_BUF]; 948 char buf[MAX_BUF];
1169 949
1170 iii = 0; 950 iii = 0;
1171 thing[0] = '\0'; 951 thing[0] = '\0';
1172 thing2[0] = '\0'; 952 thing2[0] = '\0';
1219 return 1; 999 return 1;
1220} 1000}
1221 1001
1222int 1002int
1223command_nowiz (object *op, char *params) 1003command_nowiz (object *op, char *params)
1224{ /* 'noadm' is alias */ 1004{ /* 'nodm' is alias */
1225 CLEAR_FLAG (op, FLAG_WIZ); 1005 CLEAR_FLAG (op, FLAG_WIZ);
1226 CLEAR_FLAG (op, FLAG_WIZPASS); 1006 CLEAR_FLAG (op, FLAG_WIZPASS);
1227 CLEAR_FLAG (op, FLAG_WIZCAST); 1007 CLEAR_FLAG (op, FLAG_WIZCAST);
1228 1008
1229 if (settings.real_wiz == TRUE) 1009 if (settings.real_wiz == TRUE)
1344command_invisible (object *op, char *params) 1124command_invisible (object *op, char *params)
1345{ 1125{
1346 if (op) 1126 if (op)
1347 { 1127 {
1348 op->invisible += 100; 1128 op->invisible += 100;
1349 update_object (op, UP_OBJ_FACE); 1129 update_object (op, UP_OBJ_CHANGE);
1350 new_draw_info (NDI_UNIQUE, 0, op, "You turn invisible."); 1130 new_draw_info (NDI_UNIQUE, 0, op, "You turn invisible.");
1351 } 1131 }
1352 1132
1353 return 0; 1133 return 0;
1354} 1134}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines