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.67 by root, Thu Jan 1 16:05:13 2009 UTC vs.
Revision 1.70 by root, Sun Apr 5 20:38:20 2009 UTC

1103 * op is the player issuing the command. 1103 * op is the player issuing the command.
1104 */ 1104 */
1105static object * 1105static object *
1106get_spell_by_name (object *op, shstr_cmp spell_name) 1106get_spell_by_name (object *op, shstr_cmp spell_name)
1107{ 1107{
1108 archetype *at; 1108 /* First check for full name matches. */
1109 int conflict_found = 0;
1109 archetype *found; 1110 archetype *found;
1110 int conflict_found;
1111 size_t spell_name_length;
1112
1113 /* First check for full name matches. */
1114 conflict_found = 0;
1115 found = NULL;
1116 for_all_archetypes (at) 1111 for_all_archetypes (at)
1117 { 1112 {
1118 if (at->type != SPELL) 1113 if (at->type != SPELL)
1119 continue; 1114 continue;
1120 1115
1129 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one archetype matches the spell name %s:", &spell_name); 1124 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one archetype matches the spell name %s:", &spell_name);
1130 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->archname); 1125 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->archname);
1131 } 1126 }
1132 1127
1133 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->archname); 1128 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->archname);
1134 continue; 1129 return 0;
1135 } 1130 }
1136 1131
1137 found = at; 1132 found = at;
1138 } 1133 }
1139 1134
1140 /* No match if more more than one archetype matches. */
1141 if (conflict_found)
1142 return NULL;
1143
1144 /* Return if exactly one archetype matches. */ 1135 /* Return if exactly one archetype matches. */
1145 if (found != NULL) 1136 if (found)
1146 return arch_to_object (found); 1137 return arch_to_object (found);
1147 1138
1148 /* No full match found: now check for partial matches. */
1149 spell_name_length = strlen (spell_name);
1150 conflict_found = 0;
1151 found = NULL;
1152 for_all_archetypes (at)
1153 {
1154 if (at->type != SPELL)
1155 continue;
1156
1157 if (strncmp (at->archname, "spelldirect_", 12) == 0)
1158 continue;
1159
1160 if (strncmp (at->object::name, spell_name, spell_name_length) != 0)
1161 continue;
1162
1163 if (found != NULL)
1164 {
1165 if (!conflict_found)
1166 {
1167 conflict_found = 1;
1168 new_draw_info_format (NDI_UNIQUE, 0, op, "More than one spell matches %s:", &spell_name);
1169 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->object::name);
1170 }
1171 new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->object::name);
1172 continue;
1173 }
1174
1175 found = at;
1176 }
1177
1178 /* No match if more more than one archetype matches. */
1179 if (conflict_found)
1180 return NULL;
1181
1182 /* Return if exactly one archetype matches. */
1183 if (found != NULL)
1184 return arch_to_object (found);
1185
1186 /* No spell found: just print an error message. */ 1139 /* No spell found: just print an error message. */
1187 new_draw_info_format (NDI_UNIQUE, 0, op, "The spell %s does not exist.", &spell_name); 1140 new_draw_info_format (NDI_UNIQUE, 0, op, "The spell does not exist.");
1141
1188 return NULL; 1142 return NULL;
1189} 1143}
1190 1144
1191static int 1145static int
1192command_learn_spell_or_prayer (object *op, char *params, int special_prayer) 1146command_learn_spell_or_prayer (object *op, char *params, int special_prayer)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines