ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/time.C
(Generate patch)

Comparing deliantra/server/server/time.C (file contents):
Revision 1.13 by root, Sat Sep 16 22:24:13 2006 UTC vs.
Revision 1.24 by root, Mon Dec 25 11:25:50 2006 UTC

58 tmp->y = op->y; 58 tmp->y = op->y;
59 tmp->map = op->map; 59 tmp->map = op->map;
60 tmp->level = op->level; 60 tmp->level = op->level;
61 insert_ob_in_map (tmp, op->map, op, 0); 61 insert_ob_in_map (tmp, op->map, op, 0);
62 } 62 }
63 remove_ob (op); 63
64 free_object (op); 64 op->destroy ();
65} 65}
66 66
67void 67void
68remove_door2 (object *op) 68remove_door2 (object *op)
69{ 69{
87 tmp->y = op->y; 87 tmp->y = op->y;
88 tmp->map = op->map; 88 tmp->map = op->map;
89 tmp->level = op->level; 89 tmp->level = op->level;
90 insert_ob_in_map (tmp, op->map, op, 0); 90 insert_ob_in_map (tmp, op->map, op, 0);
91 } 91 }
92 remove_ob (op); 92
93 free_object (op); 93 op->destroy ();
94} 94}
95 95
96/* Will generate a monster according to content 96/* Will generate a monster according to content
97 * of generator. 97 * of generator.
98 */ 98 */
133 if (rndm (0, 9)) 133 if (rndm (0, 9))
134 generate_artifact (head, gen->map->difficulty); 134 generate_artifact (head, gen->map->difficulty);
135 insert_ob_in_map_at (head, gen->map, gen, 0, gen->x + freearr_x[i], gen->y + freearr_y[i]); 135 insert_ob_in_map_at (head, gen->map, gen, 0, gen->x + freearr_x[i], gen->y + freearr_y[i]);
136 if (QUERY_FLAG (head, FLAG_FREED)) 136 if (QUERY_FLAG (head, FLAG_FREED))
137 return; 137 return;
138 if (HAS_RANDOM_ITEMS (head)) 138 if (head->has_random_items ())
139 create_treasure (head->randomitems, head, GT_APPLY, gen->map->difficulty, 0); 139 create_treasure (head->randomitems, head, GT_APPLY, gen->map->difficulty, 0);
140} 140}
141 141
142void 142void
143generate_monster_arch (object *gen) 143generate_monster_arch (object *gen)
144{ 144{
145 int i; 145 int i;
146 object *op, *head = NULL, *prev = NULL; 146 object *op, *head = NULL, *prev = NULL;
147 archetype *at = gen->other_arch; 147 archetype *at = gen->other_arch;
148 148
149 if (gen->other_arch == NULL) 149 if (!gen->other_arch)
150 {
151 //LOG(llevError,"Generator without other_arch: %s\n",gen->name);
152 return; 150 return;
153 } 151
154 /* Code below assumes the generator is on a map, as it tries 152 /* Code below assumes the generator is on a map, as it tries
155 * to place the monster on the map. So if the generator 153 * to place the monster on the map. So if the generator
156 * isn't on a map, complain and exit. 154 * isn't on a map, complain and exit.
157 */ 155 */
158 if (gen->map == NULL) 156 if (!gen->map)
159 {
160 //LOG(llevError,"Generator (%s) not on a map?\n", gen->name);
161 return; 157 return;
162 } 158
163 i = find_free_spot (&at->clone, gen->map, gen->x, gen->y, 1, 9); 159 i = find_free_spot (&at->clone, gen->map, gen->x, gen->y, 1, 9);
164 if (i == -1) 160 if (i == -1)
165 return; 161 return;
162
166 while (at != NULL) 163 while (at)
167 { 164 {
168 op = arch_to_object (at); 165 op = arch_to_object (at);
169 op->x = gen->x + freearr_x[i] + at->clone.x; 166 op->x = gen->x + freearr_x[i] + at->clone.x;
170 op->y = gen->y + freearr_y[i] + at->clone.y; 167 op->y = gen->y + freearr_y[i] + at->clone.y;
171 168
172 if (head != NULL) 169 if (head)
173 op->head = head, prev->more = op; 170 op->head = head, prev->more = op;
174 171
175 if (rndm (0, 9)) 172 if (rndm (0, 9))
176 generate_artifact (op, gen->map->difficulty); 173 generate_artifact (op, gen->map->difficulty);
174
177 insert_ob_in_map (op, gen->map, gen, 0); 175 insert_ob_in_map (op, gen->map, gen, 0);
178 if (QUERY_FLAG (op, FLAG_FREED)) 176 if (QUERY_FLAG (op, FLAG_FREED))
179 return; 177 return;
180 if (HAS_RANDOM_ITEMS (op)) 178
179 if (op->has_random_items ())
181 create_treasure (op->randomitems, op, GT_APPLY, gen->map->difficulty, 0); 180 create_treasure (op->randomitems, op, GT_APPLY, gen->map->difficulty, 0);
181
182 if (head == NULL) 182 if (head == NULL)
183 head = op; 183 head = op;
184
184 prev = op; 185 prev = op;
185 at = at->more; 186 at = at->more;
186 } 187 }
187} 188}
188 189
190generate_monster (object *gen) 191generate_monster (object *gen)
191{ 192{
192 193
193 if (GENERATE_SPEED (gen) && rndm (0, GENERATE_SPEED (gen) - 1)) 194 if (GENERATE_SPEED (gen) && rndm (0, GENERATE_SPEED (gen) - 1))
194 return; 195 return;
196
195 if (QUERY_FLAG (gen, FLAG_CONTENT_ON_GEN)) 197 if (QUERY_FLAG (gen, FLAG_CONTENT_ON_GEN))
196 generate_monster_inv (gen); 198 generate_monster_inv (gen);
197 else 199 else
198 generate_monster_arch (gen); 200 generate_monster_arch (gen);
199 201
217 default: 219 default:
218 if (op->env != NULL) 220 if (op->env != NULL)
219 { 221 {
220 CLEAR_FLAG (op, FLAG_APPLIED); 222 CLEAR_FLAG (op, FLAG_APPLIED);
221 change_abil (op->env, op); 223 change_abil (op->env, op);
222 fix_player (op->env); 224 op->env->update_stats ();
223 } 225 }
224 } 226 }
225 remove_ob (op); 227
226 free_object (op); 228 op->destroy ();
227} 229}
228 230
229void 231void
230remove_blindness (object *op) 232remove_blindness (object *op)
231{ 233{
232 if (--op->stats.food > 0) 234 if (--op->stats.food > 0)
233 return; 235 return;
236
234 CLEAR_FLAG (op, FLAG_APPLIED); 237 CLEAR_FLAG (op, FLAG_APPLIED);
238
235 if (op->env != NULL) 239 if (op->env != NULL)
236 { 240 {
237 change_abil (op->env, op); 241 change_abil (op->env, op);
238 fix_player (op->env); 242 op->env->update_stats ();
239 } 243 }
240 remove_ob (op); 244
241 free_object (op); 245 op->destroy ();
242} 246}
243 247
244void 248void
245poison_more (object *op) 249poison_more (object *op)
246{ 250{
247 if (op->env == NULL || !QUERY_FLAG (op->env, FLAG_ALIVE) || op->env->stats.hp < 0) 251 if (op->env == NULL || !QUERY_FLAG (op->env, FLAG_ALIVE) || op->env->stats.hp < 0)
248 { 252 {
249 remove_ob (op); 253 op->destroy ();
250 free_object (op);
251 return; 254 return;
252 } 255 }
256
253 if (op->stats.food == 1) 257 if (op->stats.food == 1)
254 { 258 {
255 /* need to remove the object before fix_player is called, else fix_player 259 /* need to remove the object before fix_player is called, else fix_player
256 * will not do anything. 260 * will not do anything.
257 */ 261 */
258 if (op->env->type == PLAYER) 262 if (op->env->type == PLAYER)
259 { 263 {
260 CLEAR_FLAG (op, FLAG_APPLIED); 264 CLEAR_FLAG (op, FLAG_APPLIED);
261 fix_player (op->env); 265 op->env->update_stats ();
262 new_draw_info (NDI_UNIQUE, 0, op->env, "You feel much better now."); 266 new_draw_info (NDI_UNIQUE, 0, op->env, "You feel much better now.");
263 } 267 }
264 remove_ob (op); 268
265 free_object (op); 269 op->destroy ();
266 return; 270 return;
267 } 271 }
272
268 if (op->env->type == PLAYER) 273 if (op->env->type == PLAYER)
269 { 274 {
270 op->env->stats.food--; 275 op->env->stats.food--;
271 new_draw_info (NDI_UNIQUE, 0, op->env, "You feel very sick..."); 276 new_draw_info (NDI_UNIQUE, 0, op->env, "You feel very sick...");
272 } 277 }
280 object *tmp; 285 object *tmp;
281 286
282 if (op->stats.wc < 0 || (int) op->stats.wc >= NUM_ANIMATIONS (op)) 287 if (op->stats.wc < 0 || (int) op->stats.wc >= NUM_ANIMATIONS (op))
283 { 288 {
284 LOG (llevError, "Gate error: animation was %d, max=%d\n", op->stats.wc, NUM_ANIMATIONS (op)); 289 LOG (llevError, "Gate error: animation was %d, max=%d\n", op->stats.wc, NUM_ANIMATIONS (op));
285 dump_object (op);
286 LOG (llevError, "%s\n", errmsg);
287 op->stats.wc = 0; 290 op->stats.wc = 0;
288 } 291 }
289 292
290 /* We're going down */ 293 /* We're going down */
291 if (op->value) 294 if (op->value)
384 int i = find_free_spot (tmp, op->map, op->x, op->y, 1, 9); 387 int i = find_free_spot (tmp, op->map, op->x, op->y, 1, 9);
385 388
386 /* If there is a free spot, move the object someplace */ 389 /* If there is a free spot, move the object someplace */
387 if (i != -1) 390 if (i != -1)
388 { 391 {
389 remove_ob (tmp); 392 tmp->remove ();
390 tmp->x += freearr_x[i], tmp->y += freearr_y[i]; 393 tmp->x += freearr_x[i], tmp->y += freearr_y[i];
391 insert_ob_in_map (tmp, op->map, op, 0); 394 insert_ob_in_map (tmp, op->map, op, 0);
392 } 395 }
393 } 396 }
394 } 397 }
458 int last = op->value; 461 int last = op->value;
459 int detected; 462 int detected;
460 463
461 detected = 0; 464 detected = 0;
462 465
463 for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL && !detected; tmp = tmp->above) 466 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL && !detected; tmp = tmp->above)
464 { 467 {
465 object *tmp2; 468 object *tmp2;
466 469
467 if (op->stats.hp) 470 if (op->stats.hp)
468 { 471 {
593 { 596 {
594 object *payload = op->inv; 597 object *payload = op->inv;
595 598
596 if (payload == NULL) 599 if (payload == NULL)
597 return NULL; 600 return NULL;
598 remove_ob (payload); 601 payload->remove ();
599 remove_ob (op); 602 op->destroy ();
600 free_object (op);
601 return payload; 603 return payload;
602 } 604 }
603 605
604 case ARROW: 606 case ARROW:
605 if (op->speed >= MIN_ACTIVE_SPEED) 607 if (op->speed >= MIN_ACTIVE_SPEED)
632fix_stopped_arrow (object *op) 634fix_stopped_arrow (object *op)
633{ 635{
634 if (rndm (0, 99) < op->stats.food) 636 if (rndm (0, 99) < op->stats.food)
635 { 637 {
636 /* Small chance of breaking */ 638 /* Small chance of breaking */
637 remove_ob (op); 639 op->destroy ();
638 free_object (op);
639 return NULL; 640 return NULL;
640 } 641 }
641 642
642 op->direction = 0; 643 op->direction = 0;
643 op->move_on = 0; 644 op->move_on = 0;
657 op->spellarg = NULL; 658 op->spellarg = NULL;
658 } 659 }
659 else 660 else
660 op->slaying = NULL; 661 op->slaying = NULL;
661 662
662 /* Reset these to zero, so that CAN_MERGE will work properly */ 663 /* Reset these to zero, so that object::can_merge will work properly */
663 op->spellarg = NULL; 664 op->spellarg = NULL;
664 op->stats.sp = 0; 665 op->stats.sp = 0;
665 op->stats.hp = 0; 666 op->stats.hp = 0;
666 op->stats.grace = 0; 667 op->stats.grace = 0;
667 op->level = 0; 668 op->level = 0;
687 688
688 if (op->inv) 689 if (op->inv)
689 { 690 {
690 object *payload = op->inv; 691 object *payload = op->inv;
691 692
692 remove_ob (payload); 693 payload->remove ();
693 clear_owner (payload); 694 payload->owner = 0;
694 insert_ob_in_map (payload, op->map, payload, 0); 695 insert_ob_in_map (payload, op->map, payload, 0);
695 remove_ob (op); 696 op->destroy ();
696 free_object (op);
697 } 697 }
698 else 698 else
699 { 699 {
700 op = fix_stopped_arrow (op); 700 op = fix_stopped_arrow (op);
701 if (op) 701 if (op)
715 maptile *m; 715 maptile *m;
716 716
717 if (op->map == NULL) 717 if (op->map == NULL)
718 { 718 {
719 LOG (llevError, "BUG: Arrow had no map.\n"); 719 LOG (llevError, "BUG: Arrow had no map.\n");
720 remove_ob (op); 720 op->destroy ();
721 free_object (op);
722 return; 721 return;
723 } 722 }
724 723
725 /* we need to stop thrown objects at some point. Like here. */ 724 /* we need to stop thrown objects at some point. Like here. */
726 if (op->type == THROWN_OBJ) 725 if (op->type == THROWN_OBJ)
733 * bomb code, but there are potential other cases where that could happen, 732 * bomb code, but there are potential other cases where that could happen,
734 * and it is easy enough to clean it up here. 733 * and it is easy enough to clean it up here.
735 */ 734 */
736 if (op->inv == NULL) 735 if (op->inv == NULL)
737 { 736 {
738 remove_ob (op); 737 op->destroy ();
739 free_object (op);
740 return; 738 return;
741 } 739 }
740
742 if (op->last_sp-- < 0) 741 if (op->last_sp-- < 0)
743 { 742 {
744 stop_arrow (op); 743 stop_arrow (op);
745 return; 744 return;
746 } 745 }
769 } 768 }
770 769
771 /* only need to look for living creatures if this flag is set */ 770 /* only need to look for living creatures if this flag is set */
772 if (mflags & P_IS_ALIVE) 771 if (mflags & P_IS_ALIVE)
773 { 772 {
774 for (tmp = get_map_ob (m, new_x, new_y); tmp != NULL; tmp = tmp->above) 773 for (tmp = GET_MAP_OB (m, new_x, new_y); tmp != NULL; tmp = tmp->above)
775 if (QUERY_FLAG (tmp, FLAG_ALIVE)) 774 if (QUERY_FLAG (tmp, FLAG_ALIVE))
776 break; 775 break;
777
778 776
779 /* Not really fair, but don't let monsters hit themselves with 777 /* Not really fair, but don't let monsters hit themselves with
780 * their own arrow - this can be because they fire it then 778 * their own arrow - this can be because they fire it then
781 * move into it. 779 * move into it.
782 */ 780 */
783
784 if (tmp != NULL && tmp != op->owner) 781 if (tmp && tmp != op->owner)
785 { 782 {
786 /* Found living object, but it is reflecting the missile. Update 783 /* Found living object, but it is reflecting the missile. Update
787 * as below. (Note that for living creatures there is a small 784 * as below. (Note that for living creatures there is a small
788 * chance that reflect_missile fails.) 785 * chance that reflect_missile fails.)
789 */ 786 */
790
791 if (QUERY_FLAG (tmp, FLAG_REFL_MISSILE) && (rndm (0, 99)) < (90 - op->level / 10)) 787 if (QUERY_FLAG (tmp, FLAG_REFL_MISSILE) && (rndm (0, 99)) < (90 - op->level / 10))
792 { 788 {
793
794 int number = op->face->number; 789 int number = op->face->number;
795 790
796 op->direction = absdir (op->direction + 4); 791 op->direction = absdir (op->direction + 4);
797 op->state = 0; 792 op->state = 0;
793
798 if (GET_ANIM_ID (op)) 794 if (GET_ANIM_ID (op))
799 { 795 {
800 number += 4; 796 number += 4;
797
801 if (number > GET_ANIMATION (op, 8)) 798 if (number > GET_ANIMATION (op, 8))
802 number -= 8; 799 number -= 8;
800
803 op->face = &new_faces[number]; 801 op->face = &new_faces[number];
804 } 802 }
803
805 was_reflected = 1; /* skip normal movement calculations */ 804 was_reflected = 1; /* skip normal movement calculations */
806 } 805 }
807 else 806 else
808 { 807 {
809 /* Attack the object. */ 808 /* Attack the object. */
810 op = hit_with_arrow (op, tmp); 809 op = hit_with_arrow (op, tmp);
810
811 if (op == NULL) 811 if (!op)
812 return; 812 return;
813 } 813 }
814 } /* if this is not hitting its owner */ 814 } /* if this is not hitting its owner */
815 } /* if there is something alive on this space */ 815 } /* if there is something alive on this space */
816
817 816
818 if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y))) 817 if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y)))
819 { 818 {
820 int retry = 0; 819 int retry = 0;
821 820
893 SET_ANIMATION (op, op->direction); 892 SET_ANIMATION (op, op->direction);
894 } /* object is reflected */ 893 } /* object is reflected */
895 } /* object ran into a wall */ 894 } /* object ran into a wall */
896 895
897 /* Move the arrow. */ 896 /* Move the arrow. */
898 remove_ob (op); 897 op->remove ();
899 op->x = new_x; 898 op->x = new_x;
900 op->y = new_y; 899 op->y = new_y;
901 900
902 /* decrease the speed as it flies. 0.05 means a standard bow will shoot 901 /* decrease the speed as it flies. 0.05 means a standard bow will shoot
903 * about 17 squares. Tune as needed. 902 * about 17 squares. Tune as needed.
911 * Modified this routine to allow held objects. b.t. */ 910 * Modified this routine to allow held objects. b.t. */
912 911
913void 912void
914change_object (object *op) 913change_object (object *op)
915{ /* Doesn`t handle linked objs yet */ 914{ /* Doesn`t handle linked objs yet */
916 object *tmp, *env, *pl;
917 int i, j; 915 int i, j;
918 916
919 if (op->other_arch == NULL) 917 if (op->other_arch == NULL)
920 { 918 {
921 LOG (llevError, "Change object (%s) without other_arch error.\n", &op->name); 919 LOG (llevError, "Change object (%s) without other_arch error.\n", &op->name);
928 if (op->stats.food-- > 0) 926 if (op->stats.food-- > 0)
929 return; 927 return;
930 else 928 else
931 op->stats.food = 1; /* so 1 other_arch is made */ 929 op->stats.food = 1; /* so 1 other_arch is made */
932 } 930 }
931
932 object *pl = op->in_player ();
933 env = op->env; 933 object *env = op->env;
934 remove_ob (op); 934
935 op->remove ();
935 for (i = 0; i < NROFNEWOBJS (op); i++) 936 for (i = 0; i < NROFNEWOBJS (op); i++)
936 { 937 {
937 tmp = arch_to_object (op->other_arch); 938 object *tmp = arch_to_object (op->other_arch);
939
938 if (op->type == LAMP) 940 if (op->type == LAMP)
939 tmp->stats.food = op->stats.food - 1; 941 tmp->stats.food = op->stats.food - 1;
942
940 tmp->stats.hp = op->stats.hp; /* The only variable it keeps. */ 943 tmp->stats.hp = op->stats.hp; /* The only variable it keeps. */
941 if (env) 944 if (env)
942 { 945 {
943 tmp->x = env->x, tmp->y = env->y; 946 tmp->x = env->x, tmp->y = env->y;
944 tmp = insert_ob_in_ob (tmp, env); 947 tmp = insert_ob_in_ob (tmp, env);
948
945 /* If this object is the players inventory, we need to tell the 949 /* If this object is the players inventory, we need to tell the
946 * client of the change. Insert_ob_in_map takes care of the 950 * client of the change. Insert_ob_in_map takes care of the
947 * updating the client, so we don't need to do that below. 951 * updating the client, so we don't need to do that below.
948 */ 952 */
949 if ((pl = is_player_inv (env)) != NULL) 953 if (pl)
950 { 954 {
951 esrv_del_item (pl->contr, op->count); 955 esrv_del_item (pl->contr, op->count);
952 esrv_send_item (pl, tmp); 956 esrv_send_item (pl, tmp);
953 } 957 }
954 } 958 }
955 else 959 else
956 { 960 {
957 j = find_first_free_spot (tmp, op->map, op->x, op->y); 961 j = find_first_free_spot (tmp, op->map, op->x, op->y);
958 if (j == -1) /* No free spot */ 962 if (j == -1) /* No free spot */
959 free_object (tmp); 963 tmp->destroy ();
960 else 964 else
961 { 965 {
962 tmp->x = op->x + freearr_x[j], tmp->y = op->y + freearr_y[j]; 966 tmp->x = op->x + freearr_x[j], tmp->y = op->y + freearr_y[j];
963 insert_ob_in_map (tmp, op->map, op, 0); 967 insert_ob_in_map (tmp, op->map, op, 0);
964 } 968 }
965 } 969 }
966 } 970 }
967 free_object (op); 971
972 op->destroy ();
968} 973}
969 974
970void 975void
971move_teleporter (object *op) 976move_teleporter (object *op)
972{ 977{
1009 else if (EXIT_X (head) || EXIT_Y (head)) 1014 else if (EXIT_X (head) || EXIT_Y (head))
1010 { 1015 {
1011 if (out_of_map (head->map, EXIT_X (head), EXIT_Y (head))) 1016 if (out_of_map (head->map, EXIT_X (head), EXIT_Y (head)))
1012 { 1017 {
1013 LOG (llevError, "Removed illegal teleporter.\n"); 1018 LOG (llevError, "Removed illegal teleporter.\n");
1014 remove_ob (head); 1019 head->destroy ();
1015 free_object (head);
1016 return; 1020 return;
1017 } 1021 }
1022
1018 if (INVOKE_OBJECT (TRIGGER, op, ARG_OBJECT (tmp))) 1023 if (INVOKE_OBJECT (TRIGGER, op, ARG_OBJECT (tmp)))
1019 return; 1024 return;
1025
1020 transfer_ob (tmp, EXIT_X (head), EXIT_Y (head), 0, head); 1026 transfer_ob (tmp, EXIT_X (head), EXIT_Y (head), 0, head);
1021 } 1027 }
1022 else 1028 else
1023 { 1029 {
1024 /* Random teleporter */ 1030 /* Random teleporter */
1055 player = op->above; 1061 player = op->above;
1056 1062
1057 for (walk = op->inv; walk != NULL; walk = walk->below) 1063 for (walk = op->inv; walk != NULL; walk = walk->below)
1058 apply_changes_to_player (player, walk); 1064 apply_changes_to_player (player, walk);
1059 1065
1060 fix_player (player); 1066 player->update_stats ();
1061 1067
1062 esrv_send_inventory (op->above, op->above); 1068 esrv_send_inventory (op->above, op->above);
1063 esrv_update_item (UPD_FACE, op->above, op->above); 1069 esrv_update_item (UPD_FACE, op->above, op->above);
1064 1070
1065 /* update players death & WoR home-position */ 1071 /* update players death & WoR home-position */
1072 } 1078 }
1073 else 1079 else
1074 LOG (llevDebug, "WARNING: destination '%s' in player_changer must be an absolute path!\n", &EXIT_PATH (op)); 1080 LOG (llevDebug, "WARNING: destination '%s' in player_changer must be an absolute path!\n", &EXIT_PATH (op));
1075 1081
1076 enter_exit (op->above, op); 1082 enter_exit (op->above, op);
1077 save_player (player, 1); 1083 player->contr->save ();
1078 } 1084 }
1079} 1085}
1080 1086
1081/* firewalls fire other spells. 1087/* firewalls fire other spells.
1082 * The direction of the wall is stored in op->stats.sp. 1088 * The direction of the wall is stored in op->stats.sp.
1089 1095
1090 if (!op->map) 1096 if (!op->map)
1091 return; /* dm has created a firewall in his inventory */ 1097 return; /* dm has created a firewall in his inventory */
1092 1098
1093 spell = op->inv; 1099 spell = op->inv;
1100
1094 if (!spell || spell->type != SPELL) 1101 if (!spell || spell->type != SPELL)
1095 spell = &op->other_arch->clone; 1102 spell = &op->other_arch->clone;
1103
1096 if (!spell) 1104 if (!spell)
1097 { 1105 {
1098 LOG (llevError, "move_firewall: no spell specified (%s, %s, %d, %d)\n", &op->name, op->map->name, op->x, op->y); 1106 LOG (llevError, "move_firewall: no spell specified (%s, %s, %d, %d)\n", &op->name, op->map->name, op->x, op->y);
1099 return; 1107 return;
1100 } 1108 }
1101 1109
1102 cast_spell (op, op, op->stats.sp ? op->stats.sp : rndm (1, 8), spell, NULL); 1110 cast_spell (op, op, op->stats.sp ? op->stats.sp : rndm (1, 8), spell, NULL);
1103} 1111}
1104
1105 1112
1106/* move_player_mover: this function takes a "player mover" as an 1113/* move_player_mover: this function takes a "player mover" as an
1107 * argument, and performs the function of a player mover, which is: 1114 * argument, and performs the function of a player mover, which is:
1108 * 1115 *
1109 * a player mover finds any players that are sitting on it. It 1116 * a player mover finds any players that are sitting on it. It
1122 1129
1123 /* Determine direction now for random movers so we do the right thing */ 1130 /* Determine direction now for random movers so we do the right thing */
1124 if (!dir) 1131 if (!dir)
1125 dir = rndm (1, 8); 1132 dir = rndm (1, 8);
1126 1133
1127 for (victim = get_map_ob (op->map, op->x, op->y); victim != NULL; victim = victim->above) 1134 for (victim = GET_MAP_OB (op->map, op->x, op->y); victim != NULL; victim = victim->above)
1128 { 1135 {
1129 if (QUERY_FLAG (victim, FLAG_ALIVE) && !QUERY_FLAG (victim, FLAG_WIZPASS) && 1136 if (QUERY_FLAG (victim, FLAG_ALIVE) && !QUERY_FLAG (victim, FLAG_WIZPASS) &&
1130 (victim->move_type & op->move_type || !victim->move_type)) 1137 (victim->move_type & op->move_type || !victim->move_type))
1131 { 1138 {
1132 1139
1133 if (victim->head) 1140 if (victim->head)
1134 victim = victim->head; 1141 victim = victim->head;
1135 1142
1136 if (QUERY_FLAG (op, FLAG_LIFESAVE) && op->stats.hp-- < 0) 1143 if (QUERY_FLAG (op, FLAG_LIFESAVE) && op->stats.hp-- < 0)
1137 { 1144 {
1138 remove_ob (op); 1145 op->remove ();
1139 free_object (op);
1140 return; 1146 return;
1141 } 1147 }
1148
1142 nx = op->x + freearr_x[dir]; 1149 nx = op->x + freearr_x[dir];
1143 ny = op->y + freearr_y[dir]; 1150 ny = op->y + freearr_y[dir];
1144 m = op->map; 1151 m = op->map;
1145 if (get_map_flags (m, &m, nx, ny, &nx, &ny) & P_OUT_OF_MAP) 1152 if (get_map_flags (m, &m, nx, ny, &nx, &ny) & P_OUT_OF_MAP)
1146 { 1153 {
1149 } 1156 }
1150 1157
1151 if (should_director_abort (op, victim)) 1158 if (should_director_abort (op, victim))
1152 return; 1159 return;
1153 1160
1154 for (nextmover = get_map_ob (m, nx, ny); nextmover != NULL; nextmover = nextmover->above) 1161 for (nextmover = GET_MAP_OB (m, nx, ny); nextmover != NULL; nextmover = nextmover->above)
1155 { 1162 {
1156 if (nextmover->type == PLAYERMOVER) 1163 if (nextmover->type == PLAYERMOVER)
1157 nextmover->speed_left = -.99; 1164 nextmover->speed_left = -.99;
1158 if (QUERY_FLAG (nextmover, FLAG_ALIVE)) 1165 if (QUERY_FLAG (nextmover, FLAG_ALIVE))
1159 { 1166 {
1224 for (tmp = op->above; tmp != NULL; tmp = tmp->above) 1231 for (tmp = op->above; tmp != NULL; tmp = tmp->above)
1225 { 1232 {
1226 if (strcmp (op->other_arch->name, tmp->arch->name) == 0) 1233 if (strcmp (op->other_arch->name, tmp->arch->name) == 0)
1227 { 1234 {
1228 if (op->level <= 0) 1235 if (op->level <= 0)
1229 { 1236 tmp->destroy ();
1230 remove_ob (tmp);
1231 free_object (tmp);
1232 }
1233 else 1237 else
1234 { 1238 {
1235 uint64 new_nrof = (uint64) tmp->nrof * op->level; 1239 uint64 new_nrof = (uint64) tmp->nrof * op->level;
1236 1240
1237 if (new_nrof >= 1UL << 31) 1241 if (new_nrof >= 1UL << 31)
1238 new_nrof = 1UL << 31; 1242 new_nrof = 1UL << 31;
1243
1239 tmp->nrof = new_nrof; 1244 tmp->nrof = new_nrof;
1240 } 1245 }
1246
1241 break; 1247 break;
1242 } 1248 }
1243 } 1249 }
1244} 1250}
1245 1251
1301 } 1307 }
1302 1308
1303 /* Make sure this multipart object fits */ 1309 /* Make sure this multipart object fits */
1304 if (new_ob->arch->more && ob_blocked (new_ob, creator->map, creator->x, creator->y)) 1310 if (new_ob->arch->more && ob_blocked (new_ob, creator->map, creator->x, creator->y))
1305 { 1311 {
1306 free_object (new_ob); 1312 new_ob->destroy ();
1307 return; 1313 return;
1308 } 1314 }
1309 1315
1310 insert_ob_in_map_at (new_ob, creator->map, creator, 0, creator->x, creator->y); 1316 insert_ob_in_map_at (new_ob, creator->map, creator, 0, creator->x, creator->y);
1311 if (QUERY_FLAG (new_ob, FLAG_FREED)) 1317 if (QUERY_FLAG (new_ob, FLAG_FREED))
1327 unless hp was zero to start with, in which case it is infinite.*/ 1333 unless hp was zero to start with, in which case it is infinite.*/
1328 1334
1329void 1335void
1330move_marker (object *op) 1336move_marker (object *op)
1331{ 1337{
1338 if (object *tmp = op->ms ().player ())
1339 {
1332 object *tmp, *tmp2; 1340 object *tmp2;
1333 1341
1334 for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above)
1335 {
1336 if (tmp->type == PLAYER)
1337 { /* we've got someone to MARK */
1338
1339 /* remove an old force with a slaying field == op->name */ 1342 /* remove an old force with a slaying field == op->name */
1340 for (tmp2 = tmp->inv; tmp2 != NULL; tmp2 = tmp2->below) 1343 for (tmp2 = tmp->inv; tmp2; tmp2 = tmp2->below)
1341 {
1342 if (tmp2->type == FORCE && tmp2->slaying && !strcmp (tmp2->slaying, op->name)) 1344 if (tmp2->type == FORCE && tmp2->slaying && !strcmp (tmp2->slaying, op->name))
1343 break;
1344 }
1345
1346 if (tmp2)
1347 { 1345 {
1348 remove_ob (tmp2); 1346 tmp2->destroy ();
1349 free_object (tmp2); 1347 break;
1350 } 1348 }
1351 1349
1352 /* cycle through his inventory to look for the MARK we want to 1350 /* cycle through his inventory to look for the MARK we want to
1353 * place 1351 * place
1354 */ 1352 */
1355 for (tmp2 = tmp->inv; tmp2 != NULL; tmp2 = tmp2->below) 1353 for (tmp2 = tmp->inv; tmp2; tmp2 = tmp2->below)
1356 {
1357 if (tmp2->type == FORCE && tmp2->slaying && !strcmp (tmp2->slaying, op->slaying)) 1354 if (tmp2->type == FORCE && tmp2->slaying && !strcmp (tmp2->slaying, op->slaying))
1358 break; 1355 break;
1359 }
1360 1356
1361 /* if we didn't find our own MARK */ 1357 /* if we didn't find our own MARK */
1362 if (tmp2 == NULL) 1358 if (tmp2 == NULL)
1363 { 1359 {
1364 object *force = get_archetype (FORCE_NAME); 1360 object *force = get_archetype (FORCE_NAME);
1365 1361
1362 force->speed = 0;
1363 if (op->stats.food)
1364 {
1366 force->speed = 0; 1365 force->speed = 0.01;
1366 force->speed_left = -op->stats.food;
1367 }
1368 update_ob_speed (force);
1369 /* put in the lock code */
1370 force->slaying = op->slaying;
1371
1372 if (op->lore)
1373 force->lore = op->lore;
1374
1375 insert_ob_in_ob (force, tmp);
1376 if (op->msg)
1377 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, tmp, op->msg);
1378
1379 if (op->stats.hp > 0)
1380 {
1381 op->stats.hp--;
1367 if (op->stats.food) 1382 if (op->stats.hp == 0)
1368 { 1383 {
1369 force->speed = 0.01; 1384 /* marker expires--granted mark number limit */
1370 force->speed_left = -op->stats.food; 1385 op->destroy ();
1386 return;
1371 } 1387 }
1372 update_ob_speed (force);
1373 /* put in the lock code */
1374 force->slaying = op->slaying;
1375
1376 if (op->lore)
1377 force->lore = op->lore;
1378
1379 insert_ob_in_ob (force, tmp);
1380 if (op->msg)
1381 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, tmp, op->msg);
1382
1383 if (op->stats.hp > 0)
1384 {
1385 op->stats.hp--;
1386 if (op->stats.hp == 0)
1387 {
1388 /* marker expires--granted mark number limit */
1389 remove_ob (op);
1390 free_object (op);
1391 return;
1392 }
1393 } 1388 }
1394 } /* if tmp2 == NULL */ 1389 }
1395 } /* if tmp->type == PLAYER */ 1390 }
1396 } /* For all objects on this space */
1397} 1391}
1398 1392
1399int 1393int
1400process_object (object *op) 1394process_object (object *op)
1401{ 1395{
1434 if (QUERY_FLAG (op, FLAG_APPLIED)) 1428 if (QUERY_FLAG (op, FLAG_APPLIED))
1435 remove_force (op); 1429 remove_force (op);
1436 else 1430 else
1437 { 1431 {
1438 /* IF necessary, delete the item from the players inventory */ 1432 /* IF necessary, delete the item from the players inventory */
1439 object *pl = is_player_inv (op); 1433 object *pl = op->in_player ();
1440 1434
1441 if (pl) 1435 if (pl)
1442 esrv_del_item (pl->contr, op->count); 1436 esrv_del_item (pl->contr, op->count);
1443 1437
1444 remove_ob (op); 1438 op->remove ();
1445 1439
1446 if (QUERY_FLAG (op, FLAG_SEE_ANYWHERE)) 1440 if (QUERY_FLAG (op, FLAG_SEE_ANYWHERE))
1447 make_sure_not_seen (op); 1441 make_sure_not_seen (op);
1448 1442
1449 free_object (op); 1443 op->destroy ();
1450 } 1444 }
1451 1445
1452 return 1; 1446 return 1;
1453 } 1447 }
1454 1448
1485 return 0; 1479 return 0;
1486 1480
1487 case THROWN_OBJ: 1481 case THROWN_OBJ:
1488 case ARROW: 1482 case ARROW:
1489 move_arrow (op); 1483 move_arrow (op);
1490 return 0;
1491
1492 case LIGHTNING: /* It now moves twice as fast */
1493 move_bolt (op);
1494 return 0; 1484 return 0;
1495 1485
1496 case DOOR: 1486 case DOOR:
1497 remove_door (op); 1487 remove_door (op);
1498 return 0; 1488 return 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines