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.19 by root, Mon Dec 18 03:00:02 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)
175 if (rndm (0, 9)) 175 if (rndm (0, 9))
176 generate_artifact (op, gen->map->difficulty); 176 generate_artifact (op, gen->map->difficulty);
177 insert_ob_in_map (op, gen->map, gen, 0); 177 insert_ob_in_map (op, gen->map, gen, 0);
178 if (QUERY_FLAG (op, FLAG_FREED)) 178 if (QUERY_FLAG (op, FLAG_FREED))
179 return; 179 return;
180 if (HAS_RANDOM_ITEMS (op)) 180 if (op->has_random_items ())
181 create_treasure (op->randomitems, op, GT_APPLY, gen->map->difficulty, 0); 181 create_treasure (op->randomitems, op, GT_APPLY, gen->map->difficulty, 0);
182 if (head == NULL) 182 if (head == NULL)
183 head = op; 183 head = op;
184 prev = op; 184 prev = op;
185 at = at->more; 185 at = at->more;
220 CLEAR_FLAG (op, FLAG_APPLIED); 220 CLEAR_FLAG (op, FLAG_APPLIED);
221 change_abil (op->env, op); 221 change_abil (op->env, op);
222 fix_player (op->env); 222 fix_player (op->env);
223 } 223 }
224 } 224 }
225 remove_ob (op); 225
226 free_object (op); 226 op->destroy ();
227} 227}
228 228
229void 229void
230remove_blindness (object *op) 230remove_blindness (object *op)
231{ 231{
232 if (--op->stats.food > 0) 232 if (--op->stats.food > 0)
233 return; 233 return;
234
234 CLEAR_FLAG (op, FLAG_APPLIED); 235 CLEAR_FLAG (op, FLAG_APPLIED);
236
235 if (op->env != NULL) 237 if (op->env != NULL)
236 { 238 {
237 change_abil (op->env, op); 239 change_abil (op->env, op);
238 fix_player (op->env); 240 fix_player (op->env);
239 } 241 }
240 remove_ob (op); 242
241 free_object (op); 243 op->destroy ();
242} 244}
243 245
244void 246void
245poison_more (object *op) 247poison_more (object *op)
246{ 248{
247 if (op->env == NULL || !QUERY_FLAG (op->env, FLAG_ALIVE) || op->env->stats.hp < 0) 249 if (op->env == NULL || !QUERY_FLAG (op->env, FLAG_ALIVE) || op->env->stats.hp < 0)
248 { 250 {
249 remove_ob (op); 251 op->destroy ();
250 free_object (op);
251 return; 252 return;
252 } 253 }
254
253 if (op->stats.food == 1) 255 if (op->stats.food == 1)
254 { 256 {
255 /* need to remove the object before fix_player is called, else fix_player 257 /* need to remove the object before fix_player is called, else fix_player
256 * will not do anything. 258 * will not do anything.
257 */ 259 */
259 { 261 {
260 CLEAR_FLAG (op, FLAG_APPLIED); 262 CLEAR_FLAG (op, FLAG_APPLIED);
261 fix_player (op->env); 263 fix_player (op->env);
262 new_draw_info (NDI_UNIQUE, 0, op->env, "You feel much better now."); 264 new_draw_info (NDI_UNIQUE, 0, op->env, "You feel much better now.");
263 } 265 }
264 remove_ob (op); 266
265 free_object (op); 267 op->destroy ();
266 return; 268 return;
267 } 269 }
270
268 if (op->env->type == PLAYER) 271 if (op->env->type == PLAYER)
269 { 272 {
270 op->env->stats.food--; 273 op->env->stats.food--;
271 new_draw_info (NDI_UNIQUE, 0, op->env, "You feel very sick..."); 274 new_draw_info (NDI_UNIQUE, 0, op->env, "You feel very sick...");
272 } 275 }
280 object *tmp; 283 object *tmp;
281 284
282 if (op->stats.wc < 0 || (int) op->stats.wc >= NUM_ANIMATIONS (op)) 285 if (op->stats.wc < 0 || (int) op->stats.wc >= NUM_ANIMATIONS (op))
283 { 286 {
284 LOG (llevError, "Gate error: animation was %d, max=%d\n", op->stats.wc, NUM_ANIMATIONS (op)); 287 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; 288 op->stats.wc = 0;
288 } 289 }
289 290
290 /* We're going down */ 291 /* We're going down */
291 if (op->value) 292 if (op->value)
384 int i = find_free_spot (tmp, op->map, op->x, op->y, 1, 9); 385 int i = find_free_spot (tmp, op->map, op->x, op->y, 1, 9);
385 386
386 /* If there is a free spot, move the object someplace */ 387 /* If there is a free spot, move the object someplace */
387 if (i != -1) 388 if (i != -1)
388 { 389 {
389 remove_ob (tmp); 390 tmp->remove ();
390 tmp->x += freearr_x[i], tmp->y += freearr_y[i]; 391 tmp->x += freearr_x[i], tmp->y += freearr_y[i];
391 insert_ob_in_map (tmp, op->map, op, 0); 392 insert_ob_in_map (tmp, op->map, op, 0);
392 } 393 }
393 } 394 }
394 } 395 }
593 { 594 {
594 object *payload = op->inv; 595 object *payload = op->inv;
595 596
596 if (payload == NULL) 597 if (payload == NULL)
597 return NULL; 598 return NULL;
598 remove_ob (payload); 599 payload->remove ();
599 remove_ob (op); 600 op->destroy ();
600 free_object (op);
601 return payload; 601 return payload;
602 } 602 }
603 603
604 case ARROW: 604 case ARROW:
605 if (op->speed >= MIN_ACTIVE_SPEED) 605 if (op->speed >= MIN_ACTIVE_SPEED)
632fix_stopped_arrow (object *op) 632fix_stopped_arrow (object *op)
633{ 633{
634 if (rndm (0, 99) < op->stats.food) 634 if (rndm (0, 99) < op->stats.food)
635 { 635 {
636 /* Small chance of breaking */ 636 /* Small chance of breaking */
637 remove_ob (op); 637 op->destroy ();
638 free_object (op);
639 return NULL; 638 return NULL;
640 } 639 }
641 640
642 op->direction = 0; 641 op->direction = 0;
643 op->move_on = 0; 642 op->move_on = 0;
657 op->spellarg = NULL; 656 op->spellarg = NULL;
658 } 657 }
659 else 658 else
660 op->slaying = NULL; 659 op->slaying = NULL;
661 660
662 /* Reset these to zero, so that CAN_MERGE will work properly */ 661 /* Reset these to zero, so that object::can_merge will work properly */
663 op->spellarg = NULL; 662 op->spellarg = NULL;
664 op->stats.sp = 0; 663 op->stats.sp = 0;
665 op->stats.hp = 0; 664 op->stats.hp = 0;
666 op->stats.grace = 0; 665 op->stats.grace = 0;
667 op->level = 0; 666 op->level = 0;
687 686
688 if (op->inv) 687 if (op->inv)
689 { 688 {
690 object *payload = op->inv; 689 object *payload = op->inv;
691 690
692 remove_ob (payload); 691 payload->remove ();
693 clear_owner (payload); 692 payload->owner = 0;
694 insert_ob_in_map (payload, op->map, payload, 0); 693 insert_ob_in_map (payload, op->map, payload, 0);
695 remove_ob (op); 694 op->destroy ();
696 free_object (op);
697 } 695 }
698 else 696 else
699 { 697 {
700 op = fix_stopped_arrow (op); 698 op = fix_stopped_arrow (op);
701 if (op) 699 if (op)
715 maptile *m; 713 maptile *m;
716 714
717 if (op->map == NULL) 715 if (op->map == NULL)
718 { 716 {
719 LOG (llevError, "BUG: Arrow had no map.\n"); 717 LOG (llevError, "BUG: Arrow had no map.\n");
720 remove_ob (op); 718 op->destroy ();
721 free_object (op);
722 return; 719 return;
723 } 720 }
724 721
725 /* we need to stop thrown objects at some point. Like here. */ 722 /* we need to stop thrown objects at some point. Like here. */
726 if (op->type == THROWN_OBJ) 723 if (op->type == THROWN_OBJ)
733 * bomb code, but there are potential other cases where that could happen, 730 * bomb code, but there are potential other cases where that could happen,
734 * and it is easy enough to clean it up here. 731 * and it is easy enough to clean it up here.
735 */ 732 */
736 if (op->inv == NULL) 733 if (op->inv == NULL)
737 { 734 {
738 remove_ob (op); 735 op->destroy ();
739 free_object (op);
740 return; 736 return;
741 } 737 }
738
742 if (op->last_sp-- < 0) 739 if (op->last_sp-- < 0)
743 { 740 {
744 stop_arrow (op); 741 stop_arrow (op);
745 return; 742 return;
746 } 743 }
773 { 770 {
774 for (tmp = get_map_ob (m, new_x, new_y); tmp != NULL; tmp = tmp->above) 771 for (tmp = get_map_ob (m, new_x, new_y); tmp != NULL; tmp = tmp->above)
775 if (QUERY_FLAG (tmp, FLAG_ALIVE)) 772 if (QUERY_FLAG (tmp, FLAG_ALIVE))
776 break; 773 break;
777 774
778
779 /* Not really fair, but don't let monsters hit themselves with 775 /* Not really fair, but don't let monsters hit themselves with
780 * their own arrow - this can be because they fire it then 776 * their own arrow - this can be because they fire it then
781 * move into it. 777 * move into it.
782 */ 778 */
783
784 if (tmp != NULL && tmp != op->owner) 779 if (tmp && tmp != op->owner)
785 { 780 {
786 /* Found living object, but it is reflecting the missile. Update 781 /* Found living object, but it is reflecting the missile. Update
787 * as below. (Note that for living creatures there is a small 782 * as below. (Note that for living creatures there is a small
788 * chance that reflect_missile fails.) 783 * chance that reflect_missile fails.)
789 */ 784 */
790
791 if (QUERY_FLAG (tmp, FLAG_REFL_MISSILE) && (rndm (0, 99)) < (90 - op->level / 10)) 785 if (QUERY_FLAG (tmp, FLAG_REFL_MISSILE) && (rndm (0, 99)) < (90 - op->level / 10))
792 { 786 {
793
794 int number = op->face->number; 787 int number = op->face->number;
795 788
796 op->direction = absdir (op->direction + 4); 789 op->direction = absdir (op->direction + 4);
797 op->state = 0; 790 op->state = 0;
791
798 if (GET_ANIM_ID (op)) 792 if (GET_ANIM_ID (op))
799 { 793 {
800 number += 4; 794 number += 4;
795
801 if (number > GET_ANIMATION (op, 8)) 796 if (number > GET_ANIMATION (op, 8))
802 number -= 8; 797 number -= 8;
798
803 op->face = &new_faces[number]; 799 op->face = &new_faces[number];
804 } 800 }
801
805 was_reflected = 1; /* skip normal movement calculations */ 802 was_reflected = 1; /* skip normal movement calculations */
806 } 803 }
807 else 804 else
808 { 805 {
809 /* Attack the object. */ 806 /* Attack the object. */
810 op = hit_with_arrow (op, tmp); 807 op = hit_with_arrow (op, tmp);
808
811 if (op == NULL) 809 if (!op)
812 return; 810 return;
813 } 811 }
814 } /* if this is not hitting its owner */ 812 } /* if this is not hitting its owner */
815 } /* if there is something alive on this space */ 813 } /* if there is something alive on this space */
816
817 814
818 if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y))) 815 if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y)))
819 { 816 {
820 int retry = 0; 817 int retry = 0;
821 818
893 SET_ANIMATION (op, op->direction); 890 SET_ANIMATION (op, op->direction);
894 } /* object is reflected */ 891 } /* object is reflected */
895 } /* object ran into a wall */ 892 } /* object ran into a wall */
896 893
897 /* Move the arrow. */ 894 /* Move the arrow. */
898 remove_ob (op); 895 op->remove ();
899 op->x = new_x; 896 op->x = new_x;
900 op->y = new_y; 897 op->y = new_y;
901 898
902 /* decrease the speed as it flies. 0.05 means a standard bow will shoot 899 /* decrease the speed as it flies. 0.05 means a standard bow will shoot
903 * about 17 squares. Tune as needed. 900 * about 17 squares. Tune as needed.
929 return; 926 return;
930 else 927 else
931 op->stats.food = 1; /* so 1 other_arch is made */ 928 op->stats.food = 1; /* so 1 other_arch is made */
932 } 929 }
933 env = op->env; 930 env = op->env;
934 remove_ob (op); 931 op->remove ();
935 for (i = 0; i < NROFNEWOBJS (op); i++) 932 for (i = 0; i < NROFNEWOBJS (op); i++)
936 { 933 {
937 tmp = arch_to_object (op->other_arch); 934 tmp = arch_to_object (op->other_arch);
938 if (op->type == LAMP) 935 if (op->type == LAMP)
939 tmp->stats.food = op->stats.food - 1; 936 tmp->stats.food = op->stats.food - 1;
954 } 951 }
955 else 952 else
956 { 953 {
957 j = find_first_free_spot (tmp, op->map, op->x, op->y); 954 j = find_first_free_spot (tmp, op->map, op->x, op->y);
958 if (j == -1) /* No free spot */ 955 if (j == -1) /* No free spot */
959 free_object (tmp); 956 tmp->destroy ();
960 else 957 else
961 { 958 {
962 tmp->x = op->x + freearr_x[j], tmp->y = op->y + freearr_y[j]; 959 tmp->x = op->x + freearr_x[j], tmp->y = op->y + freearr_y[j];
963 insert_ob_in_map (tmp, op->map, op, 0); 960 insert_ob_in_map (tmp, op->map, op, 0);
964 } 961 }
965 } 962 }
966 } 963 }
967 free_object (op); 964
965 op->destroy ();
968} 966}
969 967
970void 968void
971move_teleporter (object *op) 969move_teleporter (object *op)
972{ 970{
1009 else if (EXIT_X (head) || EXIT_Y (head)) 1007 else if (EXIT_X (head) || EXIT_Y (head))
1010 { 1008 {
1011 if (out_of_map (head->map, EXIT_X (head), EXIT_Y (head))) 1009 if (out_of_map (head->map, EXIT_X (head), EXIT_Y (head)))
1012 { 1010 {
1013 LOG (llevError, "Removed illegal teleporter.\n"); 1011 LOG (llevError, "Removed illegal teleporter.\n");
1014 remove_ob (head); 1012 head->destroy ();
1015 free_object (head);
1016 return; 1013 return;
1017 } 1014 }
1015
1018 if (INVOKE_OBJECT (TRIGGER, op, ARG_OBJECT (tmp))) 1016 if (INVOKE_OBJECT (TRIGGER, op, ARG_OBJECT (tmp)))
1019 return; 1017 return;
1018
1020 transfer_ob (tmp, EXIT_X (head), EXIT_Y (head), 0, head); 1019 transfer_ob (tmp, EXIT_X (head), EXIT_Y (head), 0, head);
1021 } 1020 }
1022 else 1021 else
1023 { 1022 {
1024 /* Random teleporter */ 1023 /* Random teleporter */
1133 if (victim->head) 1132 if (victim->head)
1134 victim = victim->head; 1133 victim = victim->head;
1135 1134
1136 if (QUERY_FLAG (op, FLAG_LIFESAVE) && op->stats.hp-- < 0) 1135 if (QUERY_FLAG (op, FLAG_LIFESAVE) && op->stats.hp-- < 0)
1137 { 1136 {
1138 remove_ob (op); 1137 op->remove ();
1139 free_object (op);
1140 return; 1138 return;
1141 } 1139 }
1140
1142 nx = op->x + freearr_x[dir]; 1141 nx = op->x + freearr_x[dir];
1143 ny = op->y + freearr_y[dir]; 1142 ny = op->y + freearr_y[dir];
1144 m = op->map; 1143 m = op->map;
1145 if (get_map_flags (m, &m, nx, ny, &nx, &ny) & P_OUT_OF_MAP) 1144 if (get_map_flags (m, &m, nx, ny, &nx, &ny) & P_OUT_OF_MAP)
1146 { 1145 {
1224 for (tmp = op->above; tmp != NULL; tmp = tmp->above) 1223 for (tmp = op->above; tmp != NULL; tmp = tmp->above)
1225 { 1224 {
1226 if (strcmp (op->other_arch->name, tmp->arch->name) == 0) 1225 if (strcmp (op->other_arch->name, tmp->arch->name) == 0)
1227 { 1226 {
1228 if (op->level <= 0) 1227 if (op->level <= 0)
1229 { 1228 tmp->destroy ();
1230 remove_ob (tmp);
1231 free_object (tmp);
1232 }
1233 else 1229 else
1234 { 1230 {
1235 uint64 new_nrof = (uint64) tmp->nrof * op->level; 1231 uint64 new_nrof = (uint64) tmp->nrof * op->level;
1236 1232
1237 if (new_nrof >= 1UL << 31) 1233 if (new_nrof >= 1UL << 31)
1238 new_nrof = 1UL << 31; 1234 new_nrof = 1UL << 31;
1235
1239 tmp->nrof = new_nrof; 1236 tmp->nrof = new_nrof;
1240 } 1237 }
1238
1241 break; 1239 break;
1242 } 1240 }
1243 } 1241 }
1244} 1242}
1245 1243
1301 } 1299 }
1302 1300
1303 /* Make sure this multipart object fits */ 1301 /* Make sure this multipart object fits */
1304 if (new_ob->arch->more && ob_blocked (new_ob, creator->map, creator->x, creator->y)) 1302 if (new_ob->arch->more && ob_blocked (new_ob, creator->map, creator->x, creator->y))
1305 { 1303 {
1306 free_object (new_ob); 1304 new_ob->destroy ();
1307 return; 1305 return;
1308 } 1306 }
1309 1307
1310 insert_ob_in_map_at (new_ob, creator->map, creator, 0, creator->x, creator->y); 1308 insert_ob_in_map_at (new_ob, creator->map, creator, 0, creator->x, creator->y);
1311 if (QUERY_FLAG (new_ob, FLAG_FREED)) 1309 if (QUERY_FLAG (new_ob, FLAG_FREED))
1342 if (tmp2->type == FORCE && tmp2->slaying && !strcmp (tmp2->slaying, op->name)) 1340 if (tmp2->type == FORCE && tmp2->slaying && !strcmp (tmp2->slaying, op->name))
1343 break; 1341 break;
1344 } 1342 }
1345 1343
1346 if (tmp2) 1344 if (tmp2)
1347 { 1345 tmp2->destroy ();
1348 remove_ob (tmp2);
1349 free_object (tmp2);
1350 }
1351 1346
1352 /* cycle through his inventory to look for the MARK we want to 1347 /* cycle through his inventory to look for the MARK we want to
1353 * place 1348 * place
1354 */ 1349 */
1355 for (tmp2 = tmp->inv; tmp2 != NULL; tmp2 = tmp2->below) 1350 for (tmp2 = tmp->inv; tmp2 != NULL; tmp2 = tmp2->below)
1384 { 1379 {
1385 op->stats.hp--; 1380 op->stats.hp--;
1386 if (op->stats.hp == 0) 1381 if (op->stats.hp == 0)
1387 { 1382 {
1388 /* marker expires--granted mark number limit */ 1383 /* marker expires--granted mark number limit */
1389 remove_ob (op); 1384 op->destroy ();
1390 free_object (op);
1391 return; 1385 return;
1392 } 1386 }
1393 } 1387 }
1394 } /* if tmp2 == NULL */ 1388 } /* if tmp2 == NULL */
1395 } /* if tmp->type == PLAYER */ 1389 } /* if tmp->type == PLAYER */
1439 object *pl = is_player_inv (op); 1433 object *pl = is_player_inv (op);
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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines