… | |
… | |
1124 | * name than other "spell_xxx" archetypes and would always conflict. |
1124 | * name than other "spell_xxx" archetypes and would always conflict. |
1125 | */ |
1125 | */ |
1126 | static object * |
1126 | static object * |
1127 | get_spell_by_name (object *op, const char *spell_name) |
1127 | get_spell_by_name (object *op, const char *spell_name) |
1128 | { |
1128 | { |
1129 | archetype *ar; |
1129 | archetype *at; |
1130 | archetype *found; |
1130 | archetype *found; |
1131 | int conflict_found; |
1131 | int conflict_found; |
1132 | size_t spell_name_length; |
1132 | size_t spell_name_length; |
1133 | |
1133 | |
1134 | /* First check for full name matches. */ |
1134 | /* First check for full name matches. */ |
1135 | conflict_found = 0; |
1135 | conflict_found = 0; |
1136 | found = NULL; |
1136 | found = NULL; |
1137 | for (ar = first_archetype; ar != NULL; ar = ar->next) |
1137 | for (at = first_archetype; at != NULL; at = at->next) |
1138 | { |
1138 | { |
1139 | if (ar->clone.type != SPELL) |
1139 | if (at->clone.type != SPELL) |
1140 | continue; |
1140 | continue; |
1141 | |
1141 | |
1142 | if (strncmp (ar->name, "spelldirect_", 12) == 0) |
1142 | if (strncmp (at->archname, "spelldirect_", 12) == 0) |
1143 | continue; |
1143 | continue; |
1144 | |
1144 | |
1145 | if (strcmp (ar->clone.name, spell_name) != 0) |
1145 | if (strcmp (at->clone.name, spell_name) != 0) |
1146 | continue; |
1146 | continue; |
1147 | |
1147 | |
1148 | if (found != NULL) |
1148 | if (found != NULL) |
1149 | { |
1149 | { |
1150 | if (!conflict_found) |
1150 | if (!conflict_found) |
1151 | { |
1151 | { |
1152 | conflict_found = 1; |
1152 | conflict_found = 1; |
1153 | new_draw_info_format (NDI_UNIQUE, 0, op, "More than one archetype matches the spell name %s:", spell_name); |
1153 | new_draw_info_format (NDI_UNIQUE, 0, op, "More than one archetype matches the spell name %s:", spell_name); |
1154 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->name); |
1154 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->archname); |
1155 | } |
1155 | } |
|
|
1156 | |
1156 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &ar->name); |
1157 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->archname); |
1157 | continue; |
1158 | continue; |
1158 | } |
1159 | } |
1159 | |
1160 | |
1160 | found = ar; |
1161 | found = at; |
1161 | } |
1162 | } |
1162 | |
1163 | |
1163 | /* No match if more more than one archetype matches. */ |
1164 | /* No match if more more than one archetype matches. */ |
1164 | if (conflict_found) |
1165 | if (conflict_found) |
1165 | return NULL; |
1166 | return NULL; |
… | |
… | |
1170 | |
1171 | |
1171 | /* No full match found: now check for partial matches. */ |
1172 | /* No full match found: now check for partial matches. */ |
1172 | spell_name_length = strlen (spell_name); |
1173 | spell_name_length = strlen (spell_name); |
1173 | conflict_found = 0; |
1174 | conflict_found = 0; |
1174 | found = NULL; |
1175 | found = NULL; |
1175 | for (ar = first_archetype; ar != NULL; ar = ar->next) |
1176 | for (at = first_archetype; at != NULL; at = at->next) |
1176 | { |
1177 | { |
1177 | if (ar->clone.type != SPELL) |
1178 | if (at->clone.type != SPELL) |
1178 | continue; |
1179 | continue; |
1179 | |
1180 | |
1180 | if (strncmp (ar->name, "spelldirect_", 12) == 0) |
1181 | if (strncmp (at->archname, "spelldirect_", 12) == 0) |
1181 | continue; |
1182 | continue; |
1182 | |
1183 | |
1183 | if (strncmp (ar->clone.name, spell_name, spell_name_length) != 0) |
1184 | if (strncmp (at->clone.name, spell_name, spell_name_length) != 0) |
1184 | continue; |
1185 | continue; |
1185 | |
1186 | |
1186 | if (found != NULL) |
1187 | if (found != NULL) |
1187 | { |
1188 | { |
1188 | if (!conflict_found) |
1189 | if (!conflict_found) |
1189 | { |
1190 | { |
1190 | conflict_found = 1; |
1191 | conflict_found = 1; |
1191 | new_draw_info_format (NDI_UNIQUE, 0, op, "More than one spell matches %s:", spell_name); |
1192 | new_draw_info_format (NDI_UNIQUE, 0, op, "More than one spell matches %s:", spell_name); |
1192 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->clone.name); |
1193 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->clone.name); |
1193 | } |
1194 | } |
1194 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &ar->clone.name); |
1195 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->clone.name); |
1195 | continue; |
1196 | continue; |
1196 | } |
1197 | } |
1197 | |
1198 | |
1198 | found = ar; |
1199 | found = at; |
1199 | } |
1200 | } |
1200 | |
1201 | |
1201 | /* No match if more more than one archetype matches. */ |
1202 | /* No match if more more than one archetype matches. */ |
1202 | if (conflict_found) |
1203 | if (conflict_found) |
1203 | return NULL; |
1204 | return NULL; |