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.39 by pippijn, Fri Mar 2 15:04:35 2007 UTC vs.
Revision 1.44 by root, Mon May 28 21:28:36 2007 UTC

1/* 1/*
2 * CrossFire, A Multiplayer game for X-windows 2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG.
3 * 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * Crossfire TRT is free software; you can redistribute it and/or modify it
9 * it under the terms of the GNU General Public License as published by 9 * under the terms of the GNU General Public License as published by the Free
10 * the Free Software Foundation; either version 2 of the License, or 10 * Software Foundation; either version 2 of the License, or (at your option)
11 * (at your option) any later version. 11 * any later version.
12 * 12 *
13 * 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, but
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 * GNU General Public License for more details. 16 * for more details.
17 * 17 *
18 * 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 along
19 * along with this program; if not, write to the Free Software 19 * with Crossfire TRT; if not, write to the Free Software Foundation, Inc. 51
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 * 21 *
22 * The authors can be reached via e-mail at <crossfire@schmorp.de> 22 * The authors can be reached via e-mail to <crossfire@schmorp.de>
23 */ 23 */
24 24
25#include <global.h> 25#include <global.h>
26#include <sproto.h> 26#include <sproto.h>
27#include <spells.h> 27#include <spells.h>
190 } 190 }
191 191
192 pl->ns->destroy (); 192 pl->ns->destroy ();
193 } 193 }
194 194
195 return 1;
196}
197
198/**
199 * Add player's IP to ban_file and kick them off the server
200 * I know most people have dynamic IPs but this is more of a short term
201 * solution if they have to get a new IP to play maybe they'll calm down.
202 * This uses the banish_file in the local directory *not* the ban_file
203 * The action is logged with a ! for easy searching. -tm
204 */
205int
206command_banish (object *op, char *params)
207{
208 player *pl;
209 FILE *banishfile;
210 char buf[MAX_BUF];
211 time_t now;
212
213 if (!params)
214 {
215 new_draw_info (NDI_UNIQUE, 0, op, "Usage: banish <player>.");
216 return 1;
217 }
218
219 pl = get_other_player_from_name (op, params);
220 if (!pl)
221 return 1;
222
223 sprintf (buf, "%s/%s", settings.localdir, BANISHFILE);
224
225 if ((banishfile = fopen (buf, "a")) == NULL)
226 {
227 LOG (llevDebug, "Could not find file banish_file.\n");
228 new_draw_info (NDI_UNIQUE, 0, op, "Could not find banish_file.");
229 return 0;
230 }
231
232 now = time (NULL);
233 /*
234 * Record this as a comment - then we don't have to worry about changing
235 * the parsing code.
236 */
237 fprintf (banishfile, "# %s (%s) banned by %s at %s\n", &pl->ob->name, pl->ns->host, &op->name, ctime (&now));
238 fprintf (banishfile, "*@%s\n", pl->ns->host);
239 fclose (banishfile);
240
241 LOG (llevDebug, "! %s banned %s from IP: %s.\n", &op->name, &pl->ob->name, pl->ns->host);
242 new_draw_info_format (NDI_UNIQUE | NDI_RED, 0, op, "You banish %s", &pl->ob->name);
243 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 5, op, "%s banishes %s from the land!", &op->name, &pl->ob->name);
244 command_kick (op, (char *) &pl->ob->name);
245 return 1; 195 return 1;
246} 196}
247 197
248//TODO 198//TODO
249#if 0 199#if 0
504 new_draw_info_format (NDI_UNIQUE, 0, op, "No artifact list for type %d\n", at->clone.type); 454 new_draw_info_format (NDI_UNIQUE, 0, op, "No artifact list for type %d\n", at->clone.type);
505 else 455 else
506 { 456 {
507 art = find_artifactlist (at->clone.type)->items; 457 art = find_artifactlist (at->clone.type)->items;
508 458
509 do 459 while (art)
510 { 460 {
511 if (!strcmp (art->item->name, cp)) 461 if (!strcmp (art->item->name, cp))
512 break; 462 break;
463
513 art = art->next; 464 art = art->next;
514 } 465 }
515 while (art != NULL);
516 466
517 if (!art) 467 if (!art)
518 new_draw_info_format (NDI_UNIQUE, 0, op, "No such artifact ([%d] of %s)", at->clone.type, cp); 468 new_draw_info_format (NDI_UNIQUE, 0, op, "No such artifact ([%d] of %s)", at->clone.type, cp);
519 } 469 }
520 470
533 * Rather than have two different blocks with a lot of similar code, 483 * Rather than have two different blocks with a lot of similar code,
534 * just create one object, do all the processing, and then determine 484 * just create one object, do all the processing, and then determine
535 * if that one object should be inserted or if we need to make copies. 485 * if that one object should be inserted or if we need to make copies.
536 */ 486 */
537 tmp = arch_to_object (at); 487 tmp = arch_to_object (at);
538
539 if (settings.real_wiz == FALSE)
540 SET_FLAG (tmp, FLAG_WAS_WIZ);
541 488
542 if (set_magic) 489 if (set_magic)
543 set_abs_magic (tmp, magic); 490 set_abs_magic (tmp, magic);
544 491
545 if (art) 492 if (art)
670 { 617 {
671 head = dup; 618 head = dup;
672 tmp->copy_to (dup); 619 tmp->copy_to (dup);
673 } 620 }
674 621
675 if (settings.real_wiz == FALSE)
676 SET_FLAG (dup, FLAG_WAS_WIZ);
677
678 dup->x = op->x + dup->arch->clone.x; 622 dup->x = op->x + dup->arch->clone.x;
679 dup->y = op->y + dup->arch->clone.y; 623 dup->y = op->y + dup->arch->clone.y;
680 dup->map = op->map; 624 dup->map = op->map;
681 625
682 if (head != dup) 626 if (head != dup)
821 return 1; 765 return 1;
822 } 766 }
823 767
824 if ((arg2 = strchr (arg, ' '))) 768 if ((arg2 = strchr (arg, ' ')))
825 arg2++; 769 arg2++;
826 if (settings.real_wiz == FALSE) 770
827 SET_FLAG (tmp, FLAG_WAS_WIZ); /* To avoid cheating */
828 if (set_variable (tmp, arg) == -1) 771 if (set_variable (tmp, arg) == -1)
829 new_draw_info_format (NDI_UNIQUE, 0, op, "Unknown variable %s", arg); 772 new_draw_info_format (NDI_UNIQUE, 0, op, "Unknown variable %s", arg);
830 else 773 else
831 {
832 new_draw_info_format (NDI_UNIQUE, 0, op, "(%s#%d)->%s=%s", &tmp->name, tmp->count, arg, arg2); 774 new_draw_info_format (NDI_UNIQUE, 0, op, "(%s#%d)->%s=%s", &tmp->name, tmp->count, arg, arg2);
833 }
834 775
835 return 1; 776 return 1;
836} 777}
837 778
838int 779int
932 } 873 }
933 874
934 pl->ob->stats.exp += i; 875 pl->ob->stats.exp += i;
935 calc_perm_exp (pl->ob); 876 calc_perm_exp (pl->ob);
936 player_lvl_adj (pl->ob, NULL); 877 player_lvl_adj (pl->ob, NULL);
937
938 if (settings.real_wiz == FALSE)
939 SET_FLAG (pl->ob, FLAG_WAS_WIZ);
940 878
941 return 1; 879 return 1;
942 } 880 }
943 881
944 new_draw_info (NDI_UNIQUE, 0, op, "No such player."); 882 new_draw_info (NDI_UNIQUE, 0, op, "No such player.");
1020 958
1021 for_all_players (pl) 959 for_all_players (pl)
1022 { 960 {
1023 if (!strcmp (pl->ob->name, thing)) 961 if (!strcmp (pl->ob->name, thing))
1024 { 962 {
1025 if (settings.real_wiz == FALSE)
1026 SET_FLAG (pl->ob, FLAG_WAS_WIZ);
1027 if (!strcmp ("str", thing2))
1028 pl->ob->stats.Str = iii, pl->orig_stats.Str = iii; 963 if (!strcmp ("str", thing2)) pl->ob->stats.Str = iii, pl->orig_stats.Str = iii;
1029 if (!strcmp ("dex", thing2))
1030 pl->ob->stats.Dex = iii, pl->orig_stats.Dex = iii; 964 if (!strcmp ("dex", thing2)) pl->ob->stats.Dex = iii, pl->orig_stats.Dex = iii;
1031 if (!strcmp ("con", thing2))
1032 pl->ob->stats.Con = iii, pl->orig_stats.Con = iii; 965 if (!strcmp ("con", thing2)) pl->ob->stats.Con = iii, pl->orig_stats.Con = iii;
1033 if (!strcmp ("wis", thing2))
1034 pl->ob->stats.Wis = iii, pl->orig_stats.Wis = iii; 966 if (!strcmp ("wis", thing2)) pl->ob->stats.Wis = iii, pl->orig_stats.Wis = iii;
1035 if (!strcmp ("cha", thing2))
1036 pl->ob->stats.Cha = iii, pl->orig_stats.Cha = iii; 967 if (!strcmp ("cha", thing2)) pl->ob->stats.Cha = iii, pl->orig_stats.Cha = iii;
1037 if (!strcmp ("int", thing2))
1038 pl->ob->stats.Int = iii, pl->orig_stats.Int = iii; 968 if (!strcmp ("int", thing2)) pl->ob->stats.Int = iii, pl->orig_stats.Int = iii;
1039 if (!strcmp ("pow", thing2))
1040 pl->ob->stats.Pow = iii, pl->orig_stats.Pow = iii; 969 if (!strcmp ("pow", thing2)) pl->ob->stats.Pow = iii, pl->orig_stats.Pow = iii;
970
1041 sprintf (buf, "%s has been altered.", &pl->ob->name); 971 sprintf (buf, "%s has been altered.", &pl->ob->name);
1042 new_draw_info (NDI_UNIQUE, 0, op, buf); 972 new_draw_info (NDI_UNIQUE, 0, op, buf);
1043 pl->ob->update_stats (); 973 pl->ob->update_stats ();
1044 return 1; 974 return 1;
1045 } 975 }
1054{ /* 'nodm' is alias */ 984{ /* 'nodm' is alias */
1055 CLEAR_FLAG (op, FLAG_WIZ); 985 CLEAR_FLAG (op, FLAG_WIZ);
1056 CLEAR_FLAG (op, FLAG_WIZPASS); 986 CLEAR_FLAG (op, FLAG_WIZPASS);
1057 CLEAR_FLAG (op, FLAG_WIZCAST); 987 CLEAR_FLAG (op, FLAG_WIZCAST);
1058 988
1059 if (settings.real_wiz == TRUE)
1060 CLEAR_FLAG (op, FLAG_WAS_WIZ);
1061 if (op->contr->hidden) 989 if (op->contr->hidden)
1062 { 990 {
1063 new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players"); 991 new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players");
1064 op->map->players++; 992 op->map->players++;
1065 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s has entered the game.", &op->name); 993 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_DK_ORANGE, 5, NULL, "%s has entered the game.", &op->name);
1127 } 1055 }
1128 1056
1129 if (checkdm (op, op->name, (params ? params : "*"), op->contr->ns->host)) 1057 if (checkdm (op, op->name, (params ? params : "*"), op->contr->ns->host))
1130 { 1058 {
1131 SET_FLAG (op, FLAG_WIZ); 1059 SET_FLAG (op, FLAG_WIZ);
1132 SET_FLAG (op, FLAG_WAS_WIZ);
1133 SET_FLAG (op, FLAG_WIZPASS); 1060 SET_FLAG (op, FLAG_WIZPASS);
1134 SET_FLAG (op, FLAG_WIZCAST); 1061 SET_FLAG (op, FLAG_WIZCAST);
1062
1135 new_draw_info (NDI_UNIQUE, 0, op, "Ok, you are the Dungeon Master!"); 1063 new_draw_info (NDI_UNIQUE, 0, op, "Ok, you are the Dungeon Master!");
1136 /* 1064 /*
1137 * Remove setting flying here - that won't work, because next 1065 * Remove setting flying here - that won't work, because next
1138 * fix_player() is called that will get cleared - proper solution 1066 * fix_player() is called that will get cleared - proper solution
1139 * is probably something like a wiz_force which gives that and any 1067 * is probably something like a wiz_force which gives that and any
1174command_invisible (object *op, char *params) 1102command_invisible (object *op, char *params)
1175{ 1103{
1176 if (op) 1104 if (op)
1177 { 1105 {
1178 op->invisible += 100; 1106 op->invisible += 100;
1179 update_object (op, UP_OBJ_FACE); 1107 update_object (op, UP_OBJ_CHANGE);
1180 new_draw_info (NDI_UNIQUE, 0, op, "You turn invisible."); 1108 new_draw_info (NDI_UNIQUE, 0, op, "You turn invisible.");
1181 } 1109 }
1182 1110
1183 return 0; 1111 return 0;
1184} 1112}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines