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.76 by root, Fri Nov 6 13:31:47 2009 UTC vs.
Revision 1.88 by root, Fri Jan 27 22:00:40 2012 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 9 * the terms of the Affero GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 11 * option) any later version.
356 { 356 {
357 new_draw_info_format (NDI_UNIQUE, 0, op, "No such god %s.", str); 357 new_draw_info_format (NDI_UNIQUE, 0, op, "No such god %s.", str);
358 return 1; 358 return 1;
359 } 359 }
360 360
361 become_follower (ob, god); 361 ob->become_follower (god);
362 return 1; 362 return 1;
363} 363}
364 364
365int 365int
366command_freeze (object *op, char *params) 366command_freeze (object *op, char *params)
436 436
437int 437int
438command_summon (object *op, char *params) 438command_summon (object *op, char *params)
439{ 439{
440 int i; 440 int i;
441 object *dummy;
442 player *pl; 441 player *pl;
443 442
444 if (!op) 443 if (!op)
445 return 0; 444 return 0;
446 445
452 451
453 pl = get_other_player_from_name (op, params); 452 pl = get_other_player_from_name (op, params);
454 if (!pl) 453 if (!pl)
455 return 1; 454 return 1;
456 455
457 i = find_free_spot (op, op->map, op->x, op->y, 1, 9); 456 maptile *m = op->map;
457 sint16 nx = op->x;
458 sint16 ny = op->y;
459
460 i = find_free_spot (op, m, nx, ny, 1, SIZEOFFREE1+1);
458 if (i == -1) 461 if (i == -1)
459 { 462 {
460 new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to place summoned player."); 463 new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to place summoned player.");
461 return 1; 464 return 1;
462 } 465 }
463 466
464 pl->ob->player_goto (op->map->path, op->x + freearr_x[i], op->y + freearr_y[i]); 467 nx += freearr_x [i];
468 ny += freearr_y [i];
469
470 if (!xy_normalise (m, nx, ny))
471 {
472 new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to place summoned player.");
473 return 1;
474 }
475
476 pl->ob->player_goto (m->path, nx, ny);
465 new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned."); 477 new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned.");
466 new_draw_info (NDI_UNIQUE, 0, op, "OK."); 478 new_draw_info (NDI_UNIQUE, 0, op, "OK.");
467 479
468 return 1; 480 return 1;
469} 481}
486int 498int
487command_create (object *op, char *params) 499command_create (object *op, char *params)
488{ 500{
489 object *tmp = NULL; 501 object *tmp = NULL;
490 int nrof, i, magic, set_magic = 0, set_nrof = 0, gotquote, gotspace; 502 int nrof, i, magic, set_magic = 0, set_nrof = 0, gotquote, gotspace;
491 char buf[MAX_BUF], *cp, *bp = buf, *bp2, *bp3, *bp4, *endline; 503 char buf[MAX_BUF], *cp, *bp = buf, *bp2, *bp3, *endline;
492 archetype *at, *at_spell = NULL; 504 archetype *at, *at_spell = NULL;
493 artifact *art = NULL; 505 artifact *art = NULL;
494 506
495 if (!op) 507 if (!op)
496 return 0; 508 return 0;
621 /* 633 /*
622 * Rather than have two different blocks with a lot of similar code, 634 * Rather than have two different blocks with a lot of similar code,
623 * just create one object, do all the processing, and then determine 635 * just create one object, do all the processing, and then determine
624 * if that one object should be inserted or if we need to make copies. 636 * if that one object should be inserted or if we need to make copies.
625 */ 637 */
626 tmp = arch_to_object (at); 638 tmp = at->instance ();
627 639
628 if (set_magic) 640 if (set_magic)
629 set_abs_magic (tmp, magic); 641 set_abs_magic (tmp, magic);
630 642
631 if (art) 643 if (art)
632 give_artifact_abilities (tmp, art->item); 644 give_artifact_abilities (tmp, art->item);
633 645
634 if (need_identify (tmp)) 646 if (tmp->need_identify ())
635 { 647 {
636 SET_FLAG (tmp, FLAG_IDENTIFIED); 648 tmp->set_flag (FLAG_IDENTIFIED);
637 CLEAR_FLAG (tmp, FLAG_KNOWN_MAGICAL); 649 tmp->clr_flag (FLAG_KNOWN_MAGICAL);
638 } 650 }
639 651
640 /* 652 /*
641 * This entire block here tries to find variable pairings, 653 * This entire block here tries to find variable pairings,
642 * eg, 'hp 4' or the like. The mess here is that values 654 * eg, 'hp 4' or the like. The mess here is that values
644 * is we want to find two spaces, but if we got a quote, 656 * is we want to find two spaces, but if we got a quote,
645 * any spaces there don't count. 657 * any spaces there don't count.
646 */ 658 */
647 while (*bp2 && bp2 <= endline) 659 while (*bp2 && bp2 <= endline)
648 { 660 {
649 bp4 = NULL;
650 gotspace = 0; 661 gotspace = 0;
651 gotquote = 0; 662 gotquote = 0;
652 663
653 /* find the first quote */ 664 /* find the first quote */
654 for (bp3 = bp2; *bp3 && gotspace < 2 && gotquote < 2; bp3++) 665 for (bp3 = bp2; *bp3 && gotspace < 2 && gotquote < 2; bp3++)
714 } 725 }
715 726
716 if (at->nrof) 727 if (at->nrof)
717 { 728 {
718 if (at_spell) 729 if (at_spell)
719 tmp->insert (arch_to_object (at_spell)); 730 tmp->insert (at_spell->instance ());
720 731
721 tmp->x = op->x; 732 tmp->x = op->x;
722 tmp->y = op->y; 733 tmp->y = op->y;
723 tmp->map = op->map; 734 tmp->map = op->map;
724 735
738 { 749 {
739 object *prev = 0, *head = 0; 750 object *prev = 0, *head = 0;
740 751
741 for (archetype *atmp = at; atmp; atmp = (archetype *)atmp->more) 752 for (archetype *atmp = at; atmp; atmp = (archetype *)atmp->more)
742 { 753 {
743 object *dup = arch_to_object (atmp); 754 object *dup = atmp->instance ();
744 755
745 if (at_spell) 756 if (at_spell)
746 insert_ob_in_ob (arch_to_object (at_spell), dup); 757 insert_ob_in_ob (at_spell->instance (), dup);
747 758
748 /* 759 /*
749 * The head is what contains all the important bits, 760 * The head is what contains all the important bits,
750 * so just copying it over should be fine. 761 * so just copying it over should be fine.
751 */ 762 */
766 } 777 }
767 778
768 prev = dup; 779 prev = dup;
769 } 780 }
770 781
771 if (QUERY_FLAG (head, FLAG_ALIVE)) 782 if (head->flag [FLAG_ALIVE])
772 { 783 {
773 object *check = head; 784 object *check = head;
774 int size_x = 0; 785 int size_x = 0;
775 int size_y = 0; 786 int size_y = 0;
776 787
777 while (check) 788 while (check)
778 { 789 {
779 size_x = MAX (size_x, check->arch->x); 790 size_x = max (size_x, check->arch->x);
780 size_y = MAX (size_y, check->arch->y); 791 size_y = max (size_y, check->arch->y);
781 check = check->more; 792 check = check->more;
782 } 793 }
783 794
784 if (out_of_map (op->map, head->x + size_x, head->y + size_y)) 795 if (out_of_map (op->map, head->x + size_x, head->y + size_y))
785 { 796 {
867 878
868 char *dump = dump_object (tmp); 879 char *dump = dump_object (tmp);
869 new_draw_info (NDI_UNIQUE, 0, op, dump); 880 new_draw_info (NDI_UNIQUE, 0, op, dump);
870 free (dump); 881 free (dump);
871 882
872 if (QUERY_FLAG (tmp, FLAG_OBJ_ORIGINAL)) 883 if (tmp->flag [FLAG_OBJ_ORIGINAL])
873 new_draw_info (NDI_UNIQUE, 0, op, "Object is marked original"); 884 new_draw_info (NDI_UNIQUE, 0, op, "Object is marked original");
874 885
875 return 1; 886 return 1;
876} 887}
877 888
922 { 933 {
923 new_draw_info (NDI_UNIQUE, 0, op, "Unable to remove a player!"); 934 new_draw_info (NDI_UNIQUE, 0, op, "Unable to remove a player!");
924 return 1; 935 return 1;
925 } 936 }
926 937
927 if (QUERY_FLAG (tmp, FLAG_REMOVED)) 938 if (tmp->flag [FLAG_REMOVED])
928 { 939 {
929 new_draw_info_format (NDI_UNIQUE, 0, op, "%s is already removed!", query_name (tmp)); 940 new_draw_info_format (NDI_UNIQUE, 0, op, "%s is already removed!", query_name (tmp));
930 return 1; 941 return 1;
931 } 942 }
932 943
1110} 1121}
1111 1122
1112int 1123int
1113command_nowiz (object *op, char *params) 1124command_nowiz (object *op, char *params)
1114{ /* 'nodm' is alias */ 1125{ /* 'nodm' is alias */
1115 CLEAR_FLAG (op, FLAG_WIZ); 1126 op->clr_flag (FLAG_WIZ);
1116 CLEAR_FLAG (op, FLAG_WIZPASS); 1127 op->clr_flag (FLAG_WIZPASS);
1117 CLEAR_FLAG (op, FLAG_WIZCAST); 1128 op->clr_flag (FLAG_WIZCAST);
1118 CLEAR_FLAG (op, FLAG_WIZLOOK); 1129 op->clr_flag (FLAG_WIZLOOK);
1119 op->contr->do_los = 1; 1130 op->contr->do_los = 1;
1120 1131
1121 if (op->contr->hidden) 1132 if (op->contr->hidden)
1122 { 1133 {
1123 new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players"); 1134 new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players");
1179do_wizard_dm (object *op, char *params, int silent) 1190do_wizard_dm (object *op, char *params, int silent)
1180{ 1191{
1181 if (!op->contr) 1192 if (!op->contr)
1182 return 0; 1193 return 0;
1183 1194
1184 if (QUERY_FLAG (op, FLAG_WIZ)) 1195 if (op->flag [FLAG_WIZ])
1185 { 1196 {
1186 new_draw_info (NDI_UNIQUE, 0, op, "You are already the Dungeon Master!"); 1197 new_draw_info (NDI_UNIQUE, 0, op, "You are already the Dungeon Master!");
1187 return 0; 1198 return 0;
1188 } 1199 }
1189 1200
1190 if (checkdm (op, op->name, (params ? params : "*"), op->contr->ns->host)) 1201 if (checkdm (op, op->name, (params ? params : "*"), op->contr->ns->host))
1191 { 1202 {
1192 SET_FLAG (op, FLAG_WIZ); 1203 op->set_flag (FLAG_WIZ);
1193 SET_FLAG (op, FLAG_WIZPASS); 1204 op->set_flag (FLAG_WIZPASS);
1194 SET_FLAG (op, FLAG_WIZCAST); 1205 op->set_flag (FLAG_WIZCAST);
1195 SET_FLAG (op, FLAG_WIZLOOK); 1206 op->set_flag (FLAG_WIZLOOK);
1196 op->contr->do_los = 1; 1207 op->contr->do_los = 1;
1197 1208
1198 new_draw_info (NDI_UNIQUE, 0, op, "Ok, you are the Dungeon Master!"); 1209 new_draw_info (NDI_UNIQUE, 0, op, "Ok, you are the Dungeon Master!");
1199 op->contr->write_buf[0] = '\0'; 1210 op->contr->write_buf[0] = '\0';
1200 1211
1249static object * 1260static object *
1250get_spell_by_name (object *op, shstr_cmp spell_name) 1261get_spell_by_name (object *op, shstr_cmp spell_name)
1251{ 1262{
1252 /* First check for full name matches. */ 1263 /* First check for full name matches. */
1253 int conflict_found = 0; 1264 int conflict_found = 0;
1254 archetype *found; 1265 archetype *found = 0;
1266
1255 for_all_archetypes (at) 1267 for_all_archetypes (at)
1256 { 1268 {
1257 if (at->type != SPELL) 1269 if (at->type != SPELL)
1258 continue; 1270 continue;
1259 1271
1276 found = at; 1288 found = at;
1277 } 1289 }
1278 1290
1279 /* Return if exactly one archetype matches. */ 1291 /* Return if exactly one archetype matches. */
1280 if (found) 1292 if (found)
1281 return arch_to_object (found); 1293 return found->instance ();
1282 1294
1283 /* No spell found: just print an error message. */ 1295 /* No spell found: just print an error message. */
1284 new_draw_info_format (NDI_UNIQUE, 0, op, "The spell does not exist."); 1296 new_draw_info_format (NDI_UNIQUE, 0, op, "The spell does not exist.");
1285 1297
1286 return 0; 1298 return 0;
1429} 1441}
1430 1442
1431int 1443int
1432command_insert_into (object *op, char *params) 1444command_insert_into (object *op, char *params)
1433{ 1445{
1434 object *left, *right, *inserted; 1446 object *left, *right;
1435 int left_from, right_from; 1447 int left_from, right_from;
1436 1448
1437 left = get_dm_object (op->contr, &params, &left_from); 1449 left = get_dm_object (op->contr, &params, &left_from);
1438 if (!left) 1450 if (!left)
1439 { 1451 {
1482 { 1494 {
1483 new_draw_info (NDI_UNIQUE, 0, op, "Can't insert a player into something!"); 1495 new_draw_info (NDI_UNIQUE, 0, op, "Can't insert a player into something!");
1484 return 0; 1496 return 0;
1485 } 1497 }
1486 1498
1487 if (!QUERY_FLAG (right, FLAG_REMOVED)) 1499 if (!right->flag [FLAG_REMOVED])
1488 right->remove (); 1500 right->remove ();
1489 1501
1490 insert_ob_in_ob (right, left); 1502 object *inserted = insert_ob_in_ob (right, left);
1491 1503
1492 new_draw_info_format (NDI_UNIQUE, 0, op, "Inserted %s in %s", query_name (inserted), query_name (left)); 1504 new_draw_info_format (NDI_UNIQUE, 0, op, "Inserted %s in %s", query_name (inserted), query_name (left));
1493 1505
1494 return 0; 1506 return 0;
1495 1507

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines