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.11 by root, Thu Sep 14 21:16:12 2006 UTC vs.
Revision 1.18 by pippijn, Sat Dec 9 17:28:37 2006 UTC

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>
79 { 73 {
80 new_draw_info (NDI_UNIQUE, 0, op, "That player is in no state for that right now."); 74 new_draw_info (NDI_UNIQUE, 0, op, "That player is in no state for that right now.");
81 return NULL; 75 return NULL;
82 } 76 }
83 return pl; 77 return pl;
84}
85
86/**
87 * This command will stress server.
88 */
89int
90command_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 }
117 }
118
119 return 0;
120} 78}
121 79
122/** 80/**
123 * Actually hides specified player (obviously a DM). 81 * Actually hides specified player (obviously a DM).
124 * If 'silent_dm' is non zero, other players are informed of DM entering/leaving, 82 * If 'silent_dm' is non zero, other players are informed of DM entering/leaving,
272} 230}
273 231
274int 232int
275command_kick (object *op, char *params) 233command_kick (object *op, char *params)
276{ 234{
277 struct pl *pl;
278
279 for (pl = first_player; pl != NULL; pl = pl->next) 235 for (player *pl = first_player; pl; pl = pl->next)
280 if ((params == NULL || !strcmp (&pl->ob->name, params)) && !INVOKE_PLAYER (KICK, pl, ARG_STRING (params))) 236 if ((params == NULL || !strcmp (&pl->ob->name, params)) && !INVOKE_PLAYER (KICK, pl, ARG_STRING (params)))
281 { 237 {
282 object *op = pl->ob; 238 object *op = pl->ob;
283 239
284 if (!QUERY_FLAG (op, FLAG_REMOVED) && !QUERY_FLAG (op, FLAG_FREED)) 240 if (!QUERY_FLAG (op, FLAG_REMOVED) && !QUERY_FLAG (op, FLAG_FREED))
315} 271}
316 272
317int 273int
318command_shutdown (object *op, char *params) 274command_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
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 281
335 cleanup (); 282 cleanup ();
336 /* not reached */ 283 /* not reached */
337 return 1;
338}
339
340int
341command_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 */
372int
373command_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; 284 return 1;
397} 285}
398 286
399int 287int
400command_freeze (object *op, char *params) 288command_freeze (object *op, char *params)
957 845
958 tmp = get_dm_object (op->contr, &params, NULL); 846 tmp = get_dm_object (op->contr, &params, NULL);
959 if (!tmp) 847 if (!tmp)
960 return 1; 848 return 1;
961 849
962 dump_object (tmp); 850 char *dump = dump_object (tmp);
963 new_draw_info (NDI_UNIQUE, 0, op, errmsg); 851 new_draw_info (NDI_UNIQUE, 0, op, dump);
852 free (dump);
853
964 if (QUERY_FLAG (tmp, FLAG_OBJ_ORIGINAL)) 854 if (QUERY_FLAG (tmp, FLAG_OBJ_ORIGINAL))
965 new_draw_info (NDI_UNIQUE, 0, op, "Object is marked original"); 855 new_draw_info (NDI_UNIQUE, 0, op, "Object is marked original");
856
966 return 1; 857 return 1;
967} 858}
968 859
969/** 860/**
970 * When DM is possessing a monster, flip aggression on and off, to allow 861 * When DM is possessing a monster, flip aggression on and off, to allow
1327} 1218}
1328 1219
1329int 1220int
1330command_reset (object *op, char *params) 1221command_reset (object *op, char *params)
1331{ 1222{
1332 mapstruct *m; 1223 maptile *m;
1333 object *dummy = NULL, *tmp = NULL; 1224 object *dummy = NULL, *tmp = NULL;
1334 1225
1335 if (params == NULL) 1226 if (params == NULL)
1336 { 1227 {
1337 new_draw_info (NDI_UNIQUE, 0, op, "Reset what map [name]?"); 1228 new_draw_info (NDI_UNIQUE, 0, op, "Reset what map [name]?");
1338 return 1; 1229 return 1;
1339 } 1230 }
1340 1231
1341 if (strcmp (params, ".") == 0) 1232 if (strcmp (params, ".") == 0)
1342 params = op->map->path; 1233 params = op->map->path;
1234
1343 m = has_been_loaded (params); 1235 m = has_been_loaded (params);
1344 if (m == NULL) 1236 if (m == NULL)
1345 { 1237 {
1346 new_draw_info (NDI_UNIQUE, 0, op, "No such map."); 1238 new_draw_info (NDI_UNIQUE, 0, op, "No such map.");
1347 return 1; 1239 return 1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines