… | |
… | |
1103 | * op is the player issuing the command. |
1103 | * op is the player issuing the command. |
1104 | */ |
1104 | */ |
1105 | static object * |
1105 | static object * |
1106 | get_spell_by_name (object *op, shstr_cmp spell_name) |
1106 | get_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 | |
|
|
1112 | /* First check for full name matches. */ |
|
|
1113 | conflict_found = 0; |
|
|
1114 | found = NULL; |
|
|
1115 | for_all_archetypes (at) |
1111 | for_all_archetypes (at) |
1116 | { |
1112 | { |
1117 | if (at->type != SPELL) |
1113 | if (at->type != SPELL) |
1118 | continue; |
1114 | continue; |
1119 | |
1115 | |
… | |
… | |
1128 | 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); |
1129 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->archname); |
1125 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->archname); |
1130 | } |
1126 | } |
1131 | |
1127 | |
1132 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->archname); |
1128 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->archname); |
1133 | continue; |
1129 | return 0; |
1134 | } |
1130 | } |
1135 | |
1131 | |
1136 | found = at; |
1132 | found = at; |
1137 | } |
1133 | } |
1138 | |
|
|
1139 | /* No match if more more than one archetype matches. */ |
|
|
1140 | if (conflict_found) |
|
|
1141 | return NULL; |
|
|
1142 | |
|
|
1143 | /* Return if exactly one archetype matches. */ |
|
|
1144 | if (found) |
|
|
1145 | return arch_to_object (found); |
|
|
1146 | |
|
|
1147 | /* No full match found: now check for partial matches. */ |
|
|
1148 | conflict_found = 0; |
|
|
1149 | found = NULL; |
|
|
1150 | for_all_archetypes (at) |
|
|
1151 | { |
|
|
1152 | if (at->type != SPELL) |
|
|
1153 | continue; |
|
|
1154 | |
|
|
1155 | if (at->object::name != spell_name) |
|
|
1156 | continue; |
|
|
1157 | |
|
|
1158 | if (strncmp (at->archname, "spelldirect_", 12) == 0) |
|
|
1159 | continue; |
|
|
1160 | |
|
|
1161 | if (found) |
|
|
1162 | { |
|
|
1163 | if (!conflict_found) |
|
|
1164 | { |
|
|
1165 | conflict_found = 1; |
|
|
1166 | new_draw_info_format (NDI_UNIQUE, 0, op, "More than one spell matches %s:", &spell_name); |
|
|
1167 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->object::name); |
|
|
1168 | } |
|
|
1169 | |
|
|
1170 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->object::name); |
|
|
1171 | continue; |
|
|
1172 | } |
|
|
1173 | |
|
|
1174 | found = at; |
|
|
1175 | } |
|
|
1176 | |
|
|
1177 | /* No match if more more than one archetype matches. */ |
|
|
1178 | if (conflict_found) |
|
|
1179 | return NULL; |
|
|
1180 | |
1134 | |
1181 | /* Return if exactly one archetype matches. */ |
1135 | /* Return if exactly one archetype matches. */ |
1182 | if (found) |
1136 | if (found) |
1183 | return arch_to_object (found); |
1137 | return arch_to_object (found); |
1184 | |
1138 | |