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.27 by root, Sat Dec 23 13:56:25 2006 UTC vs.
Revision 1.34 by root, Mon Feb 5 01:24:46 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 **/
244 } 243 }
245 244
246 return 1; 245 return 1;
247} 246}
248 247
248//TODO
249#if 0
249int 250int
250command_save_overlay (object *op, char *params) 251command_save_overlay (object *op, char *params)
251{ 252{
252 if (!op) 253 if (!op)
253 return 0; 254 return 0;
264 265
265 ready_map_name (op->map->path, 0); 266 ready_map_name (op->map->path, 0);
266 267
267 return 1; 268 return 1;
268} 269}
270#endif
269 271
270int 272int
271command_shutdown (object *op, char *params) 273command_shutdown (object *op, char *params)
272{ 274{
273 if (op != NULL && !QUERY_FLAG (op, FLAG_WIZ)) 275 if (op && !QUERY_FLAG (op, FLAG_WIZ))
274 { 276 {
275 new_draw_info (NDI_UNIQUE, 0, op, "Sorry, you can't shutdown the server."); 277 new_draw_info (NDI_UNIQUE, 0, op, "Sorry, you can't shutdown the server.");
276 return 1; 278 return 1;
277 } 279 }
278 280
279 cleanup (); 281 cleanup ("dm initiated shutdown", 0);
282
280 /* not reached */ 283 /* not reached */
281 return 1; 284 return 1;
282} 285}
283 286
284int 287int
323 object *dummy; 326 object *dummy;
324 player *pl; 327 player *pl;
325 328
326 if (!op) 329 if (!op)
327 return 0; 330 return 0;
331
328 if (params == NULL) 332 if (params == NULL)
329 { 333 {
330 new_draw_info (NDI_UNIQUE, 0, op, "Usage: arrest <player>."); 334 new_draw_info (NDI_UNIQUE, 0, op, "Usage: arrest <player>.");
331 return 1; 335 return 1;
332 } 336 }
337
333 pl = get_other_player_from_name (op, params); 338 pl = get_other_player_from_name (op, params);
334 if (!pl) 339 if (!pl)
335 return 1; 340 return 1;
341
336 dummy = get_jail_exit (pl->ob); 342 dummy = get_jail_exit (pl->ob);
337 if (!dummy) 343 if (!dummy)
338 { 344 {
339 /* we have nowhere to send the prisoner.... */ 345 /* we have nowhere to send the prisoner.... */
340 new_draw_info (NDI_UNIQUE, 0, op, "can't jail player, there is no map to hold them"); 346 new_draw_info (NDI_UNIQUE, 0, op, "can't jail player, there is no map to hold them");
341 return 0; 347 return 0;
342 } 348 }
343 enter_exit (pl->ob, dummy); 349
350 pl->ob->enter_exit (dummy);
344 dummy->destroy (); 351 dummy->destroy ();
345 new_draw_info (NDI_UNIQUE, 0, pl->ob, "You have been arrested."); 352 new_draw_info (NDI_UNIQUE, 0, pl->ob, "You have been arrested.");
346 new_draw_info (NDI_UNIQUE, 0, op, "OK."); 353 new_draw_info (NDI_UNIQUE, 0, op, "OK.");
347 LOG (llevInfo, "Player %s arrested by %s\n", &pl->ob->name, &op->name); 354 LOG (llevInfo, "Player %s arrested by %s\n", &pl->ob->name, &op->name);
348 return 1; 355 return 1;
377 384
378 dummy = object::create (); 385 dummy = object::create ();
379 EXIT_PATH (dummy) = op->map->path; 386 EXIT_PATH (dummy) = op->map->path;
380 EXIT_X (dummy) = op->x + freearr_x[i]; 387 EXIT_X (dummy) = op->x + freearr_x[i];
381 EXIT_Y (dummy) = op->y + freearr_y[i]; 388 EXIT_Y (dummy) = op->y + freearr_y[i];
382 enter_exit (pl->ob, dummy); 389 pl->ob->enter_exit (dummy);
383 dummy->destroy (); 390 dummy->destroy ();
384 new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned."); 391 new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned.");
385 new_draw_info (NDI_UNIQUE, 0, op, "OK."); 392 new_draw_info (NDI_UNIQUE, 0, op, "OK.");
386 393
387 return 1;
388}
389
390/**
391 * Teleport next to target player.
392 */
393
394/* mids 01/16/2002 */
395int
396command_teleport (object *op, char *params)
397{
398 int i;
399 object *dummy;
400 player *pl;
401
402 if (!op)
403 return 0;
404
405 if (params == NULL)
406 {
407 new_draw_info (NDI_UNIQUE, 0, op, "Usage: teleport <player>.");
408 return 1;
409 }
410
411 pl = get_other_player_from_name (op, params);
412 if (!pl)
413 return 1;
414
415 i = find_free_spot (pl->ob, pl->ob->map, pl->ob->x, pl->ob->y, 1, 9);
416 if (i == -1)
417 {
418 new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to teleport to.");
419 return 1;
420 }
421
422 dummy = object::create ();
423 EXIT_PATH (dummy) = pl->ob->map->path;
424 EXIT_X (dummy) = pl->ob->x + freearr_x[i];
425 EXIT_Y (dummy) = pl->ob->y + freearr_y[i];
426 enter_exit (op, dummy);
427 dummy->destroy ();
428 if (!op->contr->hidden)
429 new_draw_info (NDI_UNIQUE, 0, pl->ob, "You see a portal open.");
430 new_draw_info (NDI_UNIQUE, 0, op, "OK.");
431 return 1; 394 return 1;
432} 395}
433 396
434/** 397/**
435 * This function is a real mess, because we're stucking getting 398 * This function is a real mess, because we're stucking getting
529 at_spell = archetype::find (cp); 492 at_spell = archetype::find (cp);
530 if (!at_spell || at_spell->clone.type != SPELL) 493 if (!at_spell || at_spell->clone.type != SPELL)
531 at_spell = find_archetype_by_object_name (cp); 494 at_spell = find_archetype_by_object_name (cp);
532 if (!at_spell || at_spell->clone.type != SPELL) 495 if (!at_spell || at_spell->clone.type != SPELL)
533 { 496 {
534 strcpy (spell_name, cp); 497 assign (spell_name, cp);
535 fsp = strchr (spell_name, ' '); 498 fsp = strchr (spell_name, ' ');
536 if (fsp) 499 if (fsp)
537 { 500 {
538 *fsp = 0; 501 *fsp = 0;
539 fsp++; 502 fsp++;
1042 1005
1043 if (from != STACK_FROM_STACK) 1006 if (from != STACK_FROM_STACK)
1044 /* Item is either stack top, or is a number thus is now stack top, let's remove it */ 1007 /* Item is either stack top, or is a number thus is now stack top, let's remove it */
1045 dm_stack_pop (op->contr); 1008 dm_stack_pop (op->contr);
1046 1009
1047 if (!QUERY_FLAG (tmp, FLAG_REMOVED))
1048 {
1049 new_draw_info (NDI_UNIQUE, 0, op, "Warning, item wasn't removed.");
1050 tmp->remove ();
1051 }
1052
1053 if (tmp->head) 1010 if (tmp->head)
1054 tmp = tmp->head; 1011 tmp = tmp->head;
1055 1012
1056 tmp->destroy (); 1013 tmp->destroy ();
1057 return 1; 1014 return 1;
1210 new_draw_info (NDI_UNIQUE, 0, op, "No such player."); 1167 new_draw_info (NDI_UNIQUE, 0, op, "No such player.");
1211 return 1; 1168 return 1;
1212} 1169}
1213 1170
1214int 1171int
1215command_reset (object *op, char *params)
1216{
1217 maptile *m;
1218 object *dummy = NULL, *tmp = NULL;
1219
1220 if (params == NULL)
1221 {
1222 new_draw_info (NDI_UNIQUE, 0, op, "Reset what map [name]?");
1223 return 1;
1224 }
1225
1226 if (strcmp (params, ".") == 0)
1227 params = op->map->path;
1228
1229 m = has_been_loaded (params);
1230 if (m == NULL)
1231 {
1232 new_draw_info (NDI_UNIQUE, 0, op, "No such map.");
1233 return 1;
1234 }
1235
1236 if (m->in_memory != MAP_SWAPPED)
1237 {
1238 if (m->in_memory != MAP_IN_MEMORY)
1239 {
1240 LOG (llevError, "Tried to swap out map which was not in memory.\n");
1241 return 0;
1242 }
1243
1244 /*
1245 * Only attempt to remove the player that is doing the reset, and not other
1246 * players or wiz's.
1247 */
1248 if (op->map == m)
1249 {
1250 dummy = object::create ();
1251 dummy->map = NULL;
1252 EXIT_X (dummy) = op->x;
1253 EXIT_Y (dummy) = op->y;
1254 EXIT_PATH (dummy) = op->map->path;
1255 op->remove ();
1256 op->map = NULL;
1257 tmp = op;
1258 }
1259 swap_map (m);
1260 }
1261
1262 if (m->in_memory == MAP_SWAPPED)
1263 {
1264 LOG (llevDebug, "Resetting map %s.\n", m->path);
1265
1266 /* setting this effectively causes an immediate reload */
1267 m->reset_time = 1;
1268 flush_old_maps ();
1269 new_draw_info (NDI_UNIQUE, 0, op, "OK.");
1270
1271 if (tmp)
1272 {
1273 enter_exit (tmp, dummy);
1274 dummy->destroy ();
1275 }
1276
1277 return 1;
1278 }
1279 else
1280 {
1281 player *pl;
1282 int playercount = 0;
1283
1284 /* Need to re-insert player if swap failed for some reason */
1285 if (tmp)
1286 {
1287 insert_ob_in_map (op, m, NULL, 0);
1288 dummy->destroy ();
1289 }
1290
1291 new_draw_info (NDI_UNIQUE, 0, op, "Reset failed, couldn't swap map, the following players are on it:");
1292
1293 for_all_players (pl)
1294 if (pl->ob->map == m && pl->ob != op)
1295 {
1296 new_draw_info_format (NDI_UNIQUE, 0, op, "%s", &pl->ob->name);
1297 playercount++;
1298 }
1299
1300 if (!playercount)
1301 new_draw_info (NDI_UNIQUE, 0, op, "hmm, I don't see any other players on this map, something else is the problem.");
1302 return 1;
1303 }
1304}
1305
1306int
1307command_nowiz (object *op, char *params) 1172command_nowiz (object *op, char *params)
1308{ /* 'noadm' is alias */ 1173{ /* 'noadm' is alias */
1309 CLEAR_FLAG (op, FLAG_WIZ); 1174 CLEAR_FLAG (op, FLAG_WIZ);
1310 CLEAR_FLAG (op, FLAG_WIZPASS); 1175 CLEAR_FLAG (op, FLAG_WIZPASS);
1311 CLEAR_FLAG (op, FLAG_WIZCAST); 1176 CLEAR_FLAG (op, FLAG_WIZCAST);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines