… | |
… | |
423 | * we also set up spell_name which is only |
423 | * we also set up spell_name which is only |
424 | * the first word. |
424 | * the first word. |
425 | */ |
425 | */ |
426 | |
426 | |
427 | at_spell = archetype::find (cp); |
427 | at_spell = archetype::find (cp); |
428 | if (!at_spell || at_spell->clone.type != SPELL) |
428 | if (!at_spell || at_spell->type != SPELL) |
429 | at_spell = find_archetype_by_object_name (cp); |
429 | at_spell = find_archetype_by_object_name (cp); |
430 | if (!at_spell || at_spell->clone.type != SPELL) |
430 | if (!at_spell || at_spell->type != SPELL) |
431 | { |
431 | { |
432 | assign (spell_name, cp); |
432 | assign (spell_name, cp); |
433 | fsp = strchr (spell_name, ' '); |
433 | fsp = strchr (spell_name, ' '); |
434 | if (fsp) |
434 | if (fsp) |
435 | { |
435 | { |
436 | *fsp = 0; |
436 | *fsp = 0; |
437 | fsp++; |
437 | fsp++; |
438 | at_spell = archetype::find (spell_name); |
438 | at_spell = archetype::find (spell_name); |
439 | |
439 | |
440 | /* Got a spell, update the first string pointer */ |
440 | /* Got a spell, update the first string pointer */ |
441 | if (at_spell && at_spell->clone.type == SPELL) |
441 | if (at_spell && at_spell->type == SPELL) |
442 | bp2 = cp + strlen (spell_name) + 1; |
442 | bp2 = cp + strlen (spell_name) + 1; |
443 | else |
443 | else |
444 | at_spell = NULL; |
444 | at_spell = NULL; |
445 | } |
445 | } |
446 | } |
446 | } |
… | |
… | |
448 | /* OK - we didn't find a spell - presume the 'of' |
448 | /* OK - we didn't find a spell - presume the 'of' |
449 | * in this case means its an artifact. |
449 | * in this case means its an artifact. |
450 | */ |
450 | */ |
451 | if (!at_spell) |
451 | if (!at_spell) |
452 | { |
452 | { |
453 | if (find_artifactlist (at->clone.type) == NULL) |
453 | if (find_artifactlist (at->type) == NULL) |
454 | new_draw_info_format (NDI_UNIQUE, 0, op, "No artifact list for type %d\n", at->clone.type); |
454 | new_draw_info_format (NDI_UNIQUE, 0, op, "No artifact list for type %d\n", at->type); |
455 | else |
455 | else |
456 | { |
456 | { |
457 | art = find_artifactlist (at->clone.type)->items; |
457 | art = find_artifactlist (at->type)->items; |
458 | |
458 | |
459 | while (art) |
459 | while (art) |
460 | { |
460 | { |
461 | if (!strcmp (art->item->name, cp)) |
461 | if (!strcmp (art->item->name, cp)) |
462 | break; |
462 | break; |
463 | |
463 | |
464 | art = art->next; |
464 | art = art->next; |
465 | } |
465 | } |
466 | |
466 | |
467 | if (!art) |
467 | if (!art) |
468 | new_draw_info_format (NDI_UNIQUE, 0, op, "No such artifact ([%d] of %s)", at->clone.type, cp); |
468 | new_draw_info_format (NDI_UNIQUE, 0, op, "No such artifact ([%d] of %s)", at->type, cp); |
469 | } |
469 | } |
470 | |
470 | |
471 | LOG (llevDebug, "%s creates: (%d) (%d) (%s) of (%s)\n", &op->name, set_nrof ? nrof : 0, set_magic ? magic : 0, bp, cp); |
471 | LOG (llevDebug, "%s creates: (%d) (%d) (%s) of (%s)\n", &op->name, set_nrof ? nrof : 0, set_magic ? magic : 0, bp, cp); |
472 | } |
472 | } |
473 | } /* if cp */ |
473 | } /* if cp */ |
474 | |
474 | |
475 | if ((at->clone.type == ROD || at->clone.type == WAND || at->clone.type == SCROLL || |
475 | if ((at->type == ROD || at->type == WAND || at->type == SCROLL || |
476 | at->clone.type == HORN || at->clone.type == SPELLBOOK) && !at_spell) |
476 | at->type == HORN || at->type == SPELLBOOK) && !at_spell) |
477 | { |
477 | { |
478 | new_draw_info_format (NDI_UNIQUE, 0, op, "Unable to find spell %s for object that needs it, or it is of wrong type", cp); |
478 | new_draw_info_format (NDI_UNIQUE, 0, op, "Unable to find spell %s for object that needs it, or it is of wrong type", cp); |
479 | return 1; |
479 | return 1; |
480 | } |
480 | } |
481 | |
481 | |
… | |
… | |
572 | new_draw_info_format (NDI_UNIQUE, 0, op, "(%s#%d)->%s", &tmp->name, tmp->count, bp2); |
572 | new_draw_info_format (NDI_UNIQUE, 0, op, "(%s#%d)->%s", &tmp->name, tmp->count, bp2); |
573 | |
573 | |
574 | bp2 = bp3 + 1; |
574 | bp2 = bp3 + 1; |
575 | } |
575 | } |
576 | |
576 | |
577 | if (at->clone.nrof) |
577 | if (at->nrof) |
578 | { |
578 | { |
579 | if (at_spell) |
579 | if (at_spell) |
580 | insert_ob_in_ob (arch_to_object (at_spell), tmp); |
580 | insert_ob_in_ob (arch_to_object (at_spell), tmp); |
581 | |
581 | |
582 | tmp->x = op->x; |
582 | tmp->x = op->x; |
… | |
… | |
597 | } |
597 | } |
598 | else |
598 | else |
599 | { |
599 | { |
600 | for (i = 0; i < (set_nrof ? nrof : 1); i++) |
600 | for (i = 0; i < (set_nrof ? nrof : 1); i++) |
601 | { |
601 | { |
602 | archetype *atmp; |
|
|
603 | object *prev = 0, *head = 0; |
602 | object *prev = 0, *head = 0; |
604 | |
603 | |
605 | for (atmp = at; atmp; atmp = atmp->more) |
604 | for (archetype *atmp = at; atmp; atmp = (archetype *)atmp->more) |
606 | { |
605 | { |
607 | object *dup = arch_to_object (atmp); |
606 | object *dup = arch_to_object (atmp); |
608 | |
607 | |
609 | if (at_spell) |
608 | if (at_spell) |
610 | insert_ob_in_ob (arch_to_object (at_spell), dup); |
609 | insert_ob_in_ob (arch_to_object (at_spell), dup); |
… | |
… | |
617 | { |
616 | { |
618 | head = dup; |
617 | head = dup; |
619 | tmp->copy_to (dup); |
618 | tmp->copy_to (dup); |
620 | } |
619 | } |
621 | |
620 | |
622 | dup->x = op->x + dup->arch->clone.x; |
621 | dup->x = op->x + dup->arch->x; |
623 | dup->y = op->y + dup->arch->clone.y; |
622 | dup->y = op->y + dup->arch->y; |
624 | dup->map = op->map; |
623 | dup->map = op->map; |
625 | |
624 | |
626 | if (head != dup) |
625 | if (head != dup) |
627 | { |
626 | { |
628 | dup->head = head; |
627 | dup->head = head; |
… | |
… | |
638 | int size_x = 0; |
637 | int size_x = 0; |
639 | int size_y = 0; |
638 | int size_y = 0; |
640 | |
639 | |
641 | while (check) |
640 | while (check) |
642 | { |
641 | { |
643 | size_x = MAX (size_x, check->arch->clone.x); |
642 | size_x = MAX (size_x, check->arch->x); |
644 | size_y = MAX (size_y, check->arch->clone.y); |
643 | size_y = MAX (size_y, check->arch->y); |
645 | check = check->more; |
644 | check = check->more; |
646 | } |
645 | } |
647 | |
646 | |
648 | if (out_of_map (op->map, head->x + size_x, head->y + size_y)) |
647 | if (out_of_map (op->map, head->x + size_x, head->y + size_y)) |
649 | { |
648 | { |
… | |
… | |
675 | /* Wonder if we really want to push all of these, but since |
674 | /* Wonder if we really want to push all of these, but since |
676 | * things like rods have nrof 0, we want to cover those. |
675 | * things like rods have nrof 0, we want to cover those. |
677 | */ |
676 | */ |
678 | dm_stack_push (op->contr, head->count); |
677 | dm_stack_push (op->contr, head->count); |
679 | |
678 | |
680 | if (at->clone.randomitems != NULL && !at_spell) |
679 | if (at->randomitems != NULL && !at_spell) |
681 | create_treasure (at->clone.randomitems, head, GT_APPLY, op->map->difficulty, 0); |
680 | create_treasure (at->randomitems, head, GT_APPLY, op->map->difficulty, 0); |
682 | |
681 | |
683 | esrv_send_item (op, head); |
682 | esrv_send_item (op, head); |
684 | } |
683 | } |
685 | |
684 | |
686 | /* free the one we used to copy */ |
685 | /* free the one we used to copy */ |
… | |
… | |
1065 | * Remove setting flying here - that won't work, because next |
1064 | * Remove setting flying here - that won't work, because next |
1066 | * fix_player() is called that will get cleared - proper solution |
1065 | * fix_player() is called that will get cleared - proper solution |
1067 | * is probably something like a wiz_force which gives that and any |
1066 | * is probably something like a wiz_force which gives that and any |
1068 | * other desired abilities. |
1067 | * other desired abilities. |
1069 | */ |
1068 | */ |
1070 | clear_los (op); |
1069 | clear_los (op->contr); |
1071 | op->contr->write_buf[0] = '\0'; |
1070 | op->contr->write_buf[0] = '\0'; |
1072 | |
1071 | |
1073 | if (!silent) |
1072 | if (!silent) |
1074 | new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!"); |
1073 | new_draw_info (NDI_UNIQUE | NDI_ALL | NDI_LT_GREEN, 1, NULL, "The Dungeon Master has arrived!"); |
1075 | |
1074 | |
… | |
… | |
1124 | * name than other "spell_xxx" archetypes and would always conflict. |
1123 | * name than other "spell_xxx" archetypes and would always conflict. |
1125 | */ |
1124 | */ |
1126 | static object * |
1125 | static object * |
1127 | get_spell_by_name (object *op, const char *spell_name) |
1126 | get_spell_by_name (object *op, const char *spell_name) |
1128 | { |
1127 | { |
1129 | archetype *ar; |
1128 | archetype *at; |
1130 | archetype *found; |
1129 | archetype *found; |
1131 | int conflict_found; |
1130 | int conflict_found; |
1132 | size_t spell_name_length; |
1131 | size_t spell_name_length; |
1133 | |
1132 | |
1134 | /* First check for full name matches. */ |
1133 | /* First check for full name matches. */ |
1135 | conflict_found = 0; |
1134 | conflict_found = 0; |
1136 | found = NULL; |
1135 | found = NULL; |
1137 | for (ar = first_archetype; ar != NULL; ar = ar->next) |
1136 | for_all_archetypes (at) |
1138 | { |
1137 | { |
1139 | if (ar->clone.type != SPELL) |
1138 | if (at->type != SPELL) |
1140 | continue; |
1139 | continue; |
1141 | |
1140 | |
1142 | if (strncmp (ar->name, "spelldirect_", 12) == 0) |
1141 | if (strncmp (at->archname, "spelldirect_", 12) == 0) |
1143 | continue; |
1142 | continue; |
1144 | |
1143 | |
1145 | if (strcmp (ar->clone.name, spell_name) != 0) |
1144 | if (strcmp (at->object::name, spell_name) != 0) |
1146 | continue; |
1145 | continue; |
1147 | |
1146 | |
1148 | if (found != NULL) |
1147 | if (found != NULL) |
1149 | { |
1148 | { |
1150 | if (!conflict_found) |
1149 | if (!conflict_found) |
1151 | { |
1150 | { |
1152 | conflict_found = 1; |
1151 | conflict_found = 1; |
1153 | new_draw_info_format (NDI_UNIQUE, 0, op, "More than one archetype matches the spell name %s:", spell_name); |
1152 | 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); |
1153 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->archname); |
1155 | } |
1154 | } |
|
|
1155 | |
1156 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &ar->name); |
1156 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->archname); |
1157 | continue; |
1157 | continue; |
1158 | } |
1158 | } |
1159 | |
1159 | |
1160 | found = ar; |
1160 | found = at; |
1161 | } |
1161 | } |
1162 | |
1162 | |
1163 | /* No match if more more than one archetype matches. */ |
1163 | /* No match if more more than one archetype matches. */ |
1164 | if (conflict_found) |
1164 | if (conflict_found) |
1165 | return NULL; |
1165 | return NULL; |
… | |
… | |
1170 | |
1170 | |
1171 | /* No full match found: now check for partial matches. */ |
1171 | /* No full match found: now check for partial matches. */ |
1172 | spell_name_length = strlen (spell_name); |
1172 | spell_name_length = strlen (spell_name); |
1173 | conflict_found = 0; |
1173 | conflict_found = 0; |
1174 | found = NULL; |
1174 | found = NULL; |
1175 | for (ar = first_archetype; ar != NULL; ar = ar->next) |
1175 | for_all_archetypes (at) |
1176 | { |
1176 | { |
1177 | if (ar->clone.type != SPELL) |
1177 | if (at->type != SPELL) |
1178 | continue; |
1178 | continue; |
1179 | |
1179 | |
1180 | if (strncmp (ar->name, "spelldirect_", 12) == 0) |
1180 | if (strncmp (at->archname, "spelldirect_", 12) == 0) |
1181 | continue; |
1181 | continue; |
1182 | |
1182 | |
1183 | if (strncmp (ar->clone.name, spell_name, spell_name_length) != 0) |
1183 | if (strncmp (at->object::name, spell_name, spell_name_length) != 0) |
1184 | continue; |
1184 | continue; |
1185 | |
1185 | |
1186 | if (found != NULL) |
1186 | if (found != NULL) |
1187 | { |
1187 | { |
1188 | if (!conflict_found) |
1188 | if (!conflict_found) |
1189 | { |
1189 | { |
1190 | conflict_found = 1; |
1190 | conflict_found = 1; |
1191 | new_draw_info_format (NDI_UNIQUE, 0, op, "More than one spell matches %s:", spell_name); |
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, "- %s", &found->clone.name); |
1192 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &found->object::name); |
1193 | } |
1193 | } |
1194 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &ar->clone.name); |
1194 | new_draw_info_format (NDI_UNIQUE, 0, op, "- %s", &at->object::name); |
1195 | continue; |
1195 | continue; |
1196 | } |
1196 | } |
1197 | |
1197 | |
1198 | found = ar; |
1198 | found = at; |
1199 | } |
1199 | } |
1200 | |
1200 | |
1201 | /* No match if more more than one archetype matches. */ |
1201 | /* No match if more more than one archetype matches. */ |
1202 | if (conflict_found) |
1202 | if (conflict_found) |
1203 | return NULL; |
1203 | return NULL; |