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.53 by root, Thu Nov 8 19:43:26 2007 UTC vs.
Revision 1.67 by root, Thu Jan 1 16:05:13 2009 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 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify
9 * 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
178command_kick (object *op, char *params) 178command_kick (object *op, char *params)
179{ 179{
180 for_all_players (pl) 180 for_all_players (pl)
181 if ((params == NULL || !strcmp (&pl->ob->name, params)) && !INVOKE_PLAYER (KICK, pl, ARG_STRING (params))) 181 if ((params == NULL || !strcmp (&pl->ob->name, params)) && !INVOKE_PLAYER (KICK, pl, ARG_STRING (params)))
182 { 182 {
183 object *op = pl->ob; 183 object *plop = pl->ob;
184 184
185 if (!QUERY_FLAG (op, FLAG_REMOVED) && !QUERY_FLAG (op, FLAG_FREED)) 185 if (!QUERY_FLAG (plop, FLAG_REMOVED) && !QUERY_FLAG (plop, FLAG_FREED))
186 { 186 {
187 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 5, op, "%s is kicked out of the game.", &op->name); 187 new_draw_info_format (NDI_UNIQUE | NDI_ALL | NDI_RED, 5, op, "%s is kicked out of the game.", &plop->name);
188 strcpy (op->contr->killer, "kicked"); 188 plop->contr->killer = op;
189 } 189 }
190 190
191 pl->ns->destroy (); 191 pl->ns->destroy ();
192 } 192 }
193 193
279 /* we have nowhere to send the prisoner.... */ 279 /* we have nowhere to send the prisoner.... */
280 new_draw_info (NDI_UNIQUE, 0, op, "can't jail player, there is no map to hold them"); 280 new_draw_info (NDI_UNIQUE, 0, op, "can't jail player, there is no map to hold them");
281 return 0; 281 return 0;
282 } 282 }
283 283
284 pl->ob->enter_exit (dummy); 284 pl->ob->player_goto (dummy->slaying, dummy->stats.hp, dummy->stats.sp);//TODO
285 dummy->destroy (); 285 dummy->destroy ();
286
286 new_draw_info (NDI_UNIQUE, 0, pl->ob, "You have been arrested."); 287 new_draw_info (NDI_UNIQUE, 0, pl->ob, "You have been arrested.");
287 new_draw_info (NDI_UNIQUE, 0, op, "OK."); 288 new_draw_info (NDI_UNIQUE, 0, op, "OK.");
288 LOG (llevInfo, "Player %s arrested by %s\n", &pl->ob->name, &op->name); 289 LOG (llevInfo, "Player %s arrested by %s\n", &pl->ob->name, &op->name);
289 return 1; 290 return 1;
290} 291}
314 { 315 {
315 new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to place summoned player."); 316 new_draw_info (NDI_UNIQUE, 0, op, "Can not find a free spot to place summoned player.");
316 return 1; 317 return 1;
317 } 318 }
318 319
319 dummy = object::create (); 320 pl->ob->player_goto (op->map->path, op->x + freearr_x[i], op->y + freearr_y[i]);
320 EXIT_PATH (dummy) = op->map->path;
321 EXIT_X (dummy) = op->x + freearr_x[i];
322 EXIT_Y (dummy) = op->y + freearr_y[i];
323 pl->ob->enter_exit (dummy);
324 dummy->destroy ();
325 new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned."); 321 new_draw_info (NDI_UNIQUE, 0, pl->ob, "You are summoned.");
326 new_draw_info (NDI_UNIQUE, 0, op, "OK."); 322 new_draw_info (NDI_UNIQUE, 0, op, "OK.");
327 323
328 return 1; 324 return 1;
329} 325}
455 { 451 {
456 art = find_artifactlist (at->type)->items; 452 art = find_artifactlist (at->type)->items;
457 453
458 while (art) 454 while (art)
459 { 455 {
460 if (!strcmp (art->item->name, cp)) 456 if (!strcmp (&art->item->name, cp))
461 break; 457 break;
462 458
463 art = art->next; 459 art = art->next;
464 } 460 }
465 461
574 } 570 }
575 571
576 if (at->nrof) 572 if (at->nrof)
577 { 573 {
578 if (at_spell) 574 if (at_spell)
579 insert_ob_in_ob (arch_to_object (at_spell), tmp); 575 tmp->insert (arch_to_object (at_spell));
580 576
581 tmp->x = op->x; 577 tmp->x = op->x;
582 tmp->y = op->y; 578 tmp->y = op->y;
579 tmp->map = op->map;
583 580
584 if (set_nrof) 581 if (set_nrof)
585 tmp->nrof = nrof; 582 tmp->nrof = nrof;
586 583
587 tmp->map = op->map; 584 op->insert (tmp);
588
589 tmp = insert_ob_in_ob (tmp, op);
590 esrv_send_item (op, tmp);
591 585
592 /* Let's put this created item on stack so dm can access it easily. */ 586 /* Let's put this created item on stack so dm can access it easily. */
593 dm_stack_push (op->contr, tmp->count); 587 dm_stack_push (op->contr, tmp->count);
594 588
595 return 1; 589 return 1;
673 /* Wonder if we really want to push all of these, but since 667 /* Wonder if we really want to push all of these, but since
674 * things like rods have nrof 0, we want to cover those. 668 * things like rods have nrof 0, we want to cover those.
675 */ 669 */
676 dm_stack_push (op->contr, head->count); 670 dm_stack_push (op->contr, head->count);
677 671
678 if (at->randomitems != NULL && !at_spell) 672 if (at->randomitems && !at_spell)
679 create_treasure (at->randomitems, head, GT_APPLY, op->map->difficulty, 0); 673 create_treasure (at->randomitems, head, GT_APPLY, op->map->difficulty, 0);
680
681 esrv_send_item (op, head);
682 } 674 }
683 675
684 /* free the one we used to copy */ 676 /* free the one we used to copy */
685 tmp->destroy (); 677 tmp->destroy ();
686 } 678 }
897 new_draw_info (NDI_UNIQUE, 0, op, "Who?"); 889 new_draw_info (NDI_UNIQUE, 0, op, "Who?");
898 return 1; 890 return 1;
899 } 891 }
900 892
901 for_all_players (pl) 893 for_all_players (pl)
902 if (!strcmp (pl->ob->name, thing)) 894 if (!strcmp (&pl->ob->name, thing))
903 { 895 {
904 sprintf (buf, "Str : %-2d H.P. : %-4d MAX : %d", pl->ob->stats.Str, pl->ob->stats.hp, pl->ob->stats.maxhp); 896 sprintf (buf, "Str : %-2d H.P. : %-4d MAX : %d", pl->ob->stats.Str, pl->ob->stats.hp, pl->ob->stats.maxhp);
905 new_draw_info (NDI_UNIQUE, 0, op, buf); 897 new_draw_info (NDI_UNIQUE, 0, op, buf);
906 sprintf (buf, "Dex : %-2d S.P. : %-4d MAX : %d", pl->ob->stats.Dex, pl->ob->stats.sp, pl->ob->stats.maxsp); 898 sprintf (buf, "Dex : %-2d S.P. : %-4d MAX : %d", pl->ob->stats.Dex, pl->ob->stats.sp, pl->ob->stats.maxsp);
907 new_draw_info (NDI_UNIQUE, 0, op, buf); 899 new_draw_info (NDI_UNIQUE, 0, op, buf);
950 return 1; 942 return 1;
951 } 943 }
952 944
953 for_all_players (pl) 945 for_all_players (pl)
954 { 946 {
955 if (!strcmp (pl->ob->name, thing)) 947 if (!strcmp (&pl->ob->name, thing))
956 { 948 {
957 if (!strcmp ("str", thing2)) pl->ob->stats.Str = iii, pl->orig_stats.Str = iii; 949 if (!strcmp ("str", thing2)) pl->ob->stats.Str = iii, pl->orig_stats.Str = iii;
958 if (!strcmp ("dex", thing2)) pl->ob->stats.Dex = iii, pl->orig_stats.Dex = iii; 950 if (!strcmp ("dex", thing2)) pl->ob->stats.Dex = iii, pl->orig_stats.Dex = iii;
959 if (!strcmp ("con", thing2)) pl->ob->stats.Con = iii, pl->orig_stats.Con = iii; 951 if (!strcmp ("con", thing2)) pl->ob->stats.Con = iii, pl->orig_stats.Con = iii;
960 if (!strcmp ("wis", thing2)) pl->ob->stats.Wis = iii, pl->orig_stats.Wis = iii; 952 if (!strcmp ("wis", thing2)) pl->ob->stats.Wis = iii, pl->orig_stats.Wis = iii;
977command_nowiz (object *op, char *params) 969command_nowiz (object *op, char *params)
978{ /* 'nodm' is alias */ 970{ /* 'nodm' is alias */
979 CLEAR_FLAG (op, FLAG_WIZ); 971 CLEAR_FLAG (op, FLAG_WIZ);
980 CLEAR_FLAG (op, FLAG_WIZPASS); 972 CLEAR_FLAG (op, FLAG_WIZPASS);
981 CLEAR_FLAG (op, FLAG_WIZCAST); 973 CLEAR_FLAG (op, FLAG_WIZCAST);
974 CLEAR_FLAG (op, FLAG_WIZLOOK);
975 op->contr->do_los = 1;
982 976
983 if (op->contr->hidden) 977 if (op->contr->hidden)
984 { 978 {
985 new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players"); 979 new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players");
986 op->map->players++; 980 op->map->players++;
988 op->contr->hidden = 0; 982 op->contr->hidden = 0;
989 op->invisible = 1; 983 op->invisible = 1;
990 } 984 }
991 else 985 else
992 new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master is gone.."); 986 new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master is gone..");
987
993 return 1; 988 return 1;
994} 989}
995 990
996/** 991/**
997 * object *op is trying to become dm. 992 * object *op is trying to become dm.
1051 if (checkdm (op, op->name, (params ? params : "*"), op->contr->ns->host)) 1046 if (checkdm (op, op->name, (params ? params : "*"), op->contr->ns->host))
1052 { 1047 {
1053 SET_FLAG (op, FLAG_WIZ); 1048 SET_FLAG (op, FLAG_WIZ);
1054 SET_FLAG (op, FLAG_WIZPASS); 1049 SET_FLAG (op, FLAG_WIZPASS);
1055 SET_FLAG (op, FLAG_WIZCAST); 1050 SET_FLAG (op, FLAG_WIZCAST);
1051 SET_FLAG (op, FLAG_WIZLOOK);
1052 op->contr->do_los = 1;
1056 1053
1057 new_draw_info (NDI_UNIQUE, 0, op, "Ok, you are the Dungeon Master!"); 1054 new_draw_info (NDI_UNIQUE, 0, op, "Ok, you are the Dungeon Master!");
1058 /*
1059 * Remove setting flying here - that won't work, because next
1060 * fix_player() is called that will get cleared - proper solution
1061 * is probably something like a wiz_force which gives that and any
1062 * other desired abilities.
1063 */
1064 clear_los (op->contr);
1065 op->contr->write_buf[0] = '\0'; 1055 op->contr->write_buf[0] = '\0';
1066 1056
1067 if (!silent) 1057 if (!silent)
1068 new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!"); 1058 new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!");
1069 1059
1109 * Returns spell object (from archetypes) by name. 1099 * Returns spell object (from archetypes) by name.
1110 * Returns NULL if 0 or more than one spell matches. 1100 * Returns NULL if 0 or more than one spell matches.
1111 * Used for wizard's learn spell/prayer. 1101 * Used for wizard's learn spell/prayer.
1112 * 1102 *
1113 * op is the player issuing the command. 1103 * op is the player issuing the command.
1114 *
1115 * Ignores archetypes "spelldirect_xxx" since these archetypes are not used
1116 * anymore (but may still be present in some player's inventories and thus
1117 * cannot be removed). We have to ignore them here since they have the same
1118 * name than other "spell_xxx" archetypes and would always conflict.
1119 */ 1104 */
1120static object * 1105static object *
1121get_spell_by_name (object *op, const char *spell_name) 1106get_spell_by_name (object *op, shstr_cmp spell_name)
1122{ 1107{
1123 archetype *at; 1108 archetype *at;
1124 archetype *found; 1109 archetype *found;
1125 int conflict_found; 1110 int conflict_found;
1126 size_t spell_name_length; 1111 size_t spell_name_length;
1131 for_all_archetypes (at) 1116 for_all_archetypes (at)
1132 { 1117 {
1133 if (at->type != SPELL) 1118 if (at->type != SPELL)
1134 continue; 1119 continue;
1135 1120
1136 if (strncmp (at->archname, "spelldirect_", 12) == 0) 1121 if (at->object::name != spell_name)
1137 continue; 1122 continue;
1138 1123
1139 if (strcmp (at->object::name, spell_name) != 0)
1140 continue;
1141
1142 if (found != NULL) 1124 if (found)
1143 { 1125 {
1144 if (!conflict_found) 1126 if (!conflict_found)
1145 { 1127 {
1146 conflict_found = 1; 1128 conflict_found = 1;
1147 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one archetype matches the spell name %s:", spell_name); 1129 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one archetype matches the spell name %s:", &spell_name);
1148 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->archname); 1130 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->archname);
1149 } 1131 }
1150 1132
1151 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->archname); 1133 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->archname);
1152 continue; 1134 continue;
1181 if (found != NULL) 1163 if (found != NULL)
1182 { 1164 {
1183 if (!conflict_found) 1165 if (!conflict_found)
1184 { 1166 {
1185 conflict_found = 1; 1167 conflict_found = 1;
1186 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one spell matches %s:", spell_name); 1168 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one spell matches %s:", &spell_name);
1187 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->object::name); 1169 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->object::name);
1188 } 1170 }
1189 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->object::name); 1171 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->object::name);
1190 continue; 1172 continue;
1191 } 1173 }
1200 /* Return if exactly one archetype matches. */ 1182 /* Return if exactly one archetype matches. */
1201 if (found != NULL) 1183 if (found != NULL)
1202 return arch_to_object (found); 1184 return arch_to_object (found);
1203 1185
1204 /* No spell found: just print an error message. */ 1186 /* No spell found: just print an error message. */
1205 new_draw_info_format (NDI_UNIQUE, 0, op, "The spell %s does not exist.", spell_name); 1187 new_draw_info_format (NDI_UNIQUE, 0, op, "The spell %s does not exist.", &spell_name);
1206 return NULL; 1188 return NULL;
1207} 1189}
1208 1190
1209static int 1191static int
1210command_learn_spell_or_prayer (object *op, char *params, int special_prayer) 1192command_learn_spell_or_prayer (object *op, char *params, int special_prayer)
1593 return 0; 1575 return 0;
1594 } 1576 }
1595 1577
1596 if (!QUERY_FLAG (right, FLAG_REMOVED)) 1578 if (!QUERY_FLAG (right, FLAG_REMOVED))
1597 right->remove (); 1579 right->remove ();
1580
1598 inserted = insert_ob_in_ob (right, left); 1581 insert_ob_in_ob (right, left);
1599 if (left->type == PLAYER)
1600 if (inserted == right)
1601 esrv_send_item (left, right);
1602 else
1603 esrv_update_item (UPD_WEIGHT | UPD_NAME | UPD_NROF, left, inserted);
1604 1582
1605 new_draw_info_format (NDI_UNIQUE, 0, op, "Inserted %s in %s", query_name (inserted), query_name (left)); 1583 new_draw_info_format (NDI_UNIQUE, 0, op, "Inserted %s in %s", query_name (inserted), query_name (left));
1606 1584
1607 return 0; 1585 return 0;
1608 1586

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines