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.61 by root, Sat Dec 20 02:32:31 2008 UTC vs.
Revision 1.72 by root, Mon Oct 12 14:00:59 2009 UTC

3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008 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 it under
9 * it under the terms of the GNU General Public License as published by 9 * the terms of the Affero GNU General Public License as published by the
10 * the Free Software Foundation, either version 3 of the License, or 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * (at your option) any later version. 11 * option) 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,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License 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 Affero GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>.
20 * 21 *
21 * The authors can be reached via e-mail to <support@deliantra.net> 22 * The authors can be reached via e-mail to <support@deliantra.net>
22 */ 23 */
23 24
24#include <global.h> 25#include <global.h>
451 { 452 {
452 art = find_artifactlist (at->type)->items; 453 art = find_artifactlist (at->type)->items;
453 454
454 while (art) 455 while (art)
455 { 456 {
456 if (!strcmp (art->item->name, cp)) 457 if (!strcmp (&art->item->name, cp))
457 break; 458 break;
458 459
459 art = art->next; 460 art = art->next;
460 } 461 }
461 462
889 new_draw_info (NDI_UNIQUE, 0, op, "Who?"); 890 new_draw_info (NDI_UNIQUE, 0, op, "Who?");
890 return 1; 891 return 1;
891 } 892 }
892 893
893 for_all_players (pl) 894 for_all_players (pl)
894 if (!strcmp (pl->ob->name, thing)) 895 if (!strcmp (&pl->ob->name, thing))
895 { 896 {
896 sprintf (buf, "Str : %-2d H.P. : %-4d MAX : %d", pl->ob->stats.Str, pl->ob->stats.hp, pl->ob->stats.maxhp); 897 sprintf (buf, "Str : %-2d H.P. : %-4d MAX : %d", pl->ob->stats.Str, pl->ob->stats.hp, pl->ob->stats.maxhp);
897 new_draw_info (NDI_UNIQUE, 0, op, buf); 898 new_draw_info (NDI_UNIQUE, 0, op, buf);
898 sprintf (buf, "Dex : %-2d S.P. : %-4d MAX : %d", pl->ob->stats.Dex, pl->ob->stats.sp, pl->ob->stats.maxsp); 899 sprintf (buf, "Dex : %-2d S.P. : %-4d MAX : %d", pl->ob->stats.Dex, pl->ob->stats.sp, pl->ob->stats.maxsp);
899 new_draw_info (NDI_UNIQUE, 0, op, buf); 900 new_draw_info (NDI_UNIQUE, 0, op, buf);
942 return 1; 943 return 1;
943 } 944 }
944 945
945 for_all_players (pl) 946 for_all_players (pl)
946 { 947 {
947 if (!strcmp (pl->ob->name, thing)) 948 if (!strcmp (&pl->ob->name, thing))
948 { 949 {
949 if (!strcmp ("str", thing2)) pl->ob->stats.Str = iii, pl->orig_stats.Str = iii; 950 if (!strcmp ("str", thing2)) pl->ob->stats.Str = iii, pl->orig_stats.Str = iii;
950 if (!strcmp ("dex", thing2)) pl->ob->stats.Dex = iii, pl->orig_stats.Dex = iii; 951 if (!strcmp ("dex", thing2)) pl->ob->stats.Dex = iii, pl->orig_stats.Dex = iii;
951 if (!strcmp ("con", thing2)) pl->ob->stats.Con = iii, pl->orig_stats.Con = iii; 952 if (!strcmp ("con", thing2)) pl->ob->stats.Con = iii, pl->orig_stats.Con = iii;
952 if (!strcmp ("wis", thing2)) pl->ob->stats.Wis = iii, pl->orig_stats.Wis = iii; 953 if (!strcmp ("wis", thing2)) pl->ob->stats.Wis = iii, pl->orig_stats.Wis = iii;
969command_nowiz (object *op, char *params) 970command_nowiz (object *op, char *params)
970{ /* 'nodm' is alias */ 971{ /* 'nodm' is alias */
971 CLEAR_FLAG (op, FLAG_WIZ); 972 CLEAR_FLAG (op, FLAG_WIZ);
972 CLEAR_FLAG (op, FLAG_WIZPASS); 973 CLEAR_FLAG (op, FLAG_WIZPASS);
973 CLEAR_FLAG (op, FLAG_WIZCAST); 974 CLEAR_FLAG (op, FLAG_WIZCAST);
975 CLEAR_FLAG (op, FLAG_WIZLOOK);
976 op->contr->do_los = 1;
974 977
975 if (op->contr->hidden) 978 if (op->contr->hidden)
976 { 979 {
977 new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players"); 980 new_draw_info (NDI_UNIQUE, 0, op, "You are no longer hidden from other players");
978 op->map->players++; 981 op->map->players++;
980 op->contr->hidden = 0; 983 op->contr->hidden = 0;
981 op->invisible = 1; 984 op->invisible = 1;
982 } 985 }
983 else 986 else
984 new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master is gone.."); 987 new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master is gone..");
988
985 return 1; 989 return 1;
986} 990}
987 991
988/** 992/**
989 * object *op is trying to become dm. 993 * object *op is trying to become dm.
1043 if (checkdm (op, op->name, (params ? params : "*"), op->contr->ns->host)) 1047 if (checkdm (op, op->name, (params ? params : "*"), op->contr->ns->host))
1044 { 1048 {
1045 SET_FLAG (op, FLAG_WIZ); 1049 SET_FLAG (op, FLAG_WIZ);
1046 SET_FLAG (op, FLAG_WIZPASS); 1050 SET_FLAG (op, FLAG_WIZPASS);
1047 SET_FLAG (op, FLAG_WIZCAST); 1051 SET_FLAG (op, FLAG_WIZCAST);
1052 SET_FLAG (op, FLAG_WIZLOOK);
1053 op->contr->do_los = 1;
1048 1054
1049 new_draw_info (NDI_UNIQUE, 0, op, "Ok, you are the Dungeon Master!"); 1055 new_draw_info (NDI_UNIQUE, 0, op, "Ok, you are the Dungeon Master!");
1050 /*
1051 * Remove setting flying here - that won't work, because next
1052 * fix_player() is called that will get cleared - proper solution
1053 * is probably something like a wiz_force which gives that and any
1054 * other desired abilities.
1055 */
1056 op->contr->clear_los (0);
1057 op->contr->write_buf[0] = '\0'; 1056 op->contr->write_buf[0] = '\0';
1058 1057
1059 if (!silent) 1058 if (!silent)
1060 new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!"); 1059 new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!");
1061 1060
1101 * Returns spell object (from archetypes) by name. 1100 * Returns spell object (from archetypes) by name.
1102 * Returns NULL if 0 or more than one spell matches. 1101 * Returns NULL if 0 or more than one spell matches.
1103 * Used for wizard's learn spell/prayer. 1102 * Used for wizard's learn spell/prayer.
1104 * 1103 *
1105 * op is the player issuing the command. 1104 * op is the player issuing the command.
1106 *
1107 * Ignores archetypes "spelldirect_xxx" since these archetypes are not used
1108 * anymore (but may still be present in some player's inventories and thus
1109 * cannot be removed). We have to ignore them here since they have the same
1110 * name than other "spell_xxx" archetypes and would always conflict.
1111 */ 1105 */
1112static object * 1106static object *
1113get_spell_by_name (object *op, const char *spell_name) 1107get_spell_by_name (object *op, shstr_cmp spell_name)
1114{ 1108{
1115 archetype *at; 1109 /* First check for full name matches. */
1110 int conflict_found = 0;
1116 archetype *found; 1111 archetype *found;
1117 int conflict_found;
1118 size_t spell_name_length;
1119
1120 /* First check for full name matches. */
1121 conflict_found = 0;
1122 found = NULL;
1123 for_all_archetypes (at) 1112 for_all_archetypes (at)
1124 { 1113 {
1125 if (at->type != SPELL) 1114 if (at->type != SPELL)
1126 continue; 1115 continue;
1127 1116
1128 if (strncmp (at->archname, "spelldirect_", 12) == 0) 1117 if (at->object::name != spell_name)
1129 continue; 1118 continue;
1130 1119
1131 if (strcmp (at->object::name, spell_name) != 0)
1132 continue;
1133
1134 if (found != NULL) 1120 if (found)
1135 { 1121 {
1136 if (!conflict_found) 1122 if (!conflict_found)
1137 { 1123 {
1138 conflict_found = 1; 1124 conflict_found = 1;
1139 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one archetype matches the spell name %s:", spell_name); 1125 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one archetype matches the spell name %s:", &spell_name);
1140 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->archname); 1126 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->archname);
1141 } 1127 }
1142 1128
1143 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->archname); 1129 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->archname);
1144 continue; 1130 return 0;
1145 } 1131 }
1146 1132
1147 found = at; 1133 found = at;
1148 } 1134 }
1149 1135
1150 /* No match if more more than one archetype matches. */
1151 if (conflict_found)
1152 return NULL;
1153
1154 /* Return if exactly one archetype matches. */ 1136 /* Return if exactly one archetype matches. */
1155 if (found != NULL) 1137 if (found)
1156 return arch_to_object (found); 1138 return arch_to_object (found);
1157 1139
1158 /* No full match found: now check for partial matches. */
1159 spell_name_length = strlen (spell_name);
1160 conflict_found = 0;
1161 found = NULL;
1162 for_all_archetypes (at)
1163 {
1164 if (at->type != SPELL)
1165 continue;
1166
1167 if (strncmp (at->archname, "spelldirect_", 12) == 0)
1168 continue;
1169
1170 if (strncmp (at->object::name, spell_name, spell_name_length) != 0)
1171 continue;
1172
1173 if (found != NULL)
1174 {
1175 if (!conflict_found)
1176 {
1177 conflict_found = 1;
1178 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one spell matches %s:", spell_name);
1179 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->object::name);
1180 }
1181 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->object::name);
1182 continue;
1183 }
1184
1185 found = at;
1186 }
1187
1188 /* No match if more more than one archetype matches. */
1189 if (conflict_found)
1190 return NULL;
1191
1192 /* Return if exactly one archetype matches. */
1193 if (found != NULL)
1194 return arch_to_object (found);
1195
1196 /* No spell found: just print an error message. */ 1140 /* No spell found: just print an error message. */
1197 new_draw_info_format (NDI_UNIQUE, 0, op, "The spell %s does not exist.", spell_name); 1141 new_draw_info_format (NDI_UNIQUE, 0, op, "The spell does not exist.");
1142
1198 return NULL; 1143 return 0;
1199} 1144}
1200 1145
1201static int 1146static int
1202command_learn_spell_or_prayer (object *op, char *params, int special_prayer) 1147command_learn_spell_or_prayer (object *op, char *params, int special_prayer)
1203{ 1148{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines