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

Comparing deliantra/server/server/player.C (file contents):
Revision 1.23 by root, Thu Sep 14 22:34:04 2006 UTC vs.
Revision 1.35 by root, Thu Dec 14 00:01:35 2006 UTC

20 20
21 The author can be reached via e-mail to <crossfire@schmorp.de> 21 The author can be reached via e-mail to <crossfire@schmorp.de>
22*/ 22*/
23 23
24#include <global.h> 24#include <global.h>
25#ifndef WIN32 /* ---win32 remove headers */
26# include <pwd.h> 25#include <pwd.h>
27#endif
28#ifndef __CEXTRACT__ 26#ifndef __CEXTRACT__
29# include <sproto.h> 27# include <sproto.h>
30#endif 28#endif
31#include <sounds.h> 29#include <sounds.h>
32#include <living.h> 30#include <living.h>
329 player *p; 327 player *p;
330 328
331 p = get_player (NULL); 329 p = get_player (NULL);
332 p->socket = *ns; 330 p->socket = *ns;
333 p->socket.faces_sent = (uint8 *) malloc (p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); 331 p->socket.faces_sent = (uint8 *) malloc (p->socket.faces_sent_len * sizeof (*p->socket.faces_sent));
332
334 if (p->socket.faces_sent == NULL) 333 if (p->socket.faces_sent == NULL)
335 fatal (OUT_OF_MEMORY); 334 fatal (OUT_OF_MEMORY);
335
336 memcpy (p->socket.faces_sent, ns->faces_sent, p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); 336 memcpy (p->socket.faces_sent, ns->faces_sent, p->socket.faces_sent_len * sizeof (*p->socket.faces_sent));
337 /* Needed because the socket we just copied over needs to be cleared. 337 /* Needed because the socket we just copied over needs to be cleared.
338 * Note that this can result in a client reset if there is partial data 338 * Note that this can result in a client reset if there is partial data
339 * on the uncoming socket. 339 * on the uncoming socket.
340 */ 340 */
341 //TODO socket copying is EVIL, do not do this
341 p->socket.inbuf.len = 0; 342 p->socket.inbuf_len = 0;
342 set_first_map (p->ob); 343 set_first_map (p->ob);
343 344
344 CLEAR_FLAG (p->ob, FLAG_FRIENDLY); 345 CLEAR_FLAG (p->ob, FLAG_FRIENDLY);
345 add_friendly_object (p->ob); 346 add_friendly_object (p->ob);
346 send_rules (p->ob); 347 send_rules (p->ob);
347 send_news (p->ob); 348 send_news (p->ob);
348 display_motd (p->ob); 349 display_motd (p->ob);
349 get_name (p->ob); 350 get_name (p->ob);
351
350 return 0; 352 return 0;
351} 353}
352 354
353/* 355/*
354 * get_player_archetype() return next player archetype from archetype 356 * get_player_archetype() return next player archetype from archetype
489path_to_player (object *mon, object *pl, unsigned mindiff) 491path_to_player (object *mon, object *pl, unsigned mindiff)
490{ 492{
491 rv_vector rv; 493 rv_vector rv;
492 sint16 x, y; 494 sint16 x, y;
493 int lastx, lasty, dir, i, diff, firstdir = 0, lastdir, max = MAX_SPACES, mflags, blocked; 495 int lastx, lasty, dir, i, diff, firstdir = 0, lastdir, max = MAX_SPACES, mflags, blocked;
494 mapstruct *m, *lastmap; 496 maptile *m, *lastmap;
495 497
496 get_rangevector (mon, pl, &rv, 0); 498 get_rangevector (mon, pl, &rv, 0);
497 499
498 if (rv.distance < mindiff) 500 if (rv.distance < mindiff)
499 return 0; 501 return 0;
643 (op->type == ARMOUR || op->type == BOOTS || 645 (op->type == ARMOUR || op->type == BOOTS ||
644 op->type == CLOAK || op->type == HELMET || 646 op->type == CLOAK || op->type == HELMET ||
645 op->type == SHIELD || op->type == GLOVES || 647 op->type == SHIELD || op->type == GLOVES ||
646 op->type == BRACERS || op->type == GIRDLE)) || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON)) 648 op->type == BRACERS || op->type == GIRDLE)) || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON))
647 { 649 {
648 remove_ob (op); 650 op->destroy ();
649 free_object (op);
650 continue; 651 continue;
651 } 652 }
652 } 653 }
653 654
654 /* This really needs to be better - we should really give 655 /* This really needs to be better - we should really give
665 if (tmp->type == op->type && tmp->name == op->name) 666 if (tmp->type == op->type && tmp->name == op->name)
666 break; 667 break;
667 668
668 if (tmp) 669 if (tmp)
669 { 670 {
670 remove_ob (op); 671 op->destroy ();
671 free_object (op);
672 LOG (llevError, "give_initial_items: Removing duplicate object %s\n", &tmp->name); 672 LOG (llevError, "give_initial_items: Removing duplicate object %s\n", &tmp->name);
673 continue; 673 continue;
674 } 674 }
675
675 if (op->nrof > 1) 676 if (op->nrof > 1)
676 op->nrof = 1; 677 op->nrof = 1;
677 } 678 }
678 679
679 if (op->type == SPELLBOOK && op->inv) 680 if (op->type == SPELLBOOK && op->inv)
691 CLEAR_FLAG (op, FLAG_CURSED); 692 CLEAR_FLAG (op, FLAG_CURSED);
692 CLEAR_FLAG (op, FLAG_DAMNED); 693 CLEAR_FLAG (op, FLAG_DAMNED);
693 } 694 }
694 if (op->type == SPELL) 695 if (op->type == SPELL)
695 { 696 {
696 remove_ob (op); 697 op->destroy ();
697 free_object (op);
698 continue; 698 continue;
699 } 699 }
700 else if (op->type == SKILL) 700 else if (op->type == SKILL)
701 { 701 {
702 SET_FLAG (op, FLAG_CAN_USE_SKILL); 702 SET_FLAG (op, FLAG_CAN_USE_SKILL);
741 * removing the player - it probably makes more sense 741 * removing the player - it probably makes more sense
742 * to leave it to play_again to remove the object in all 742 * to leave it to play_again to remove the object in all
743 * cases. 743 * cases.
744 */ 744 */
745 if (!QUERY_FLAG (op, FLAG_REMOVED)) 745 if (!QUERY_FLAG (op, FLAG_REMOVED))
746 remove_ob (op); 746 op->remove ();
747 /* Need to set this to null - otherwise, it could point to garbage, 747 /* Need to set this to null - otherwise, it could point to garbage,
748 * and draw() doesn't check to see if the player is removed, only if 748 * and draw() doesn't check to see if the player is removed, only if
749 * the map is null or not swapped out. 749 * the map is null or not swapped out.
750 */ 750 */
751 op->map = NULL; 751 op->map = NULL;
765 player *pl = op->contr; 765 player *pl = op->contr;
766 shstr name = op->name; 766 shstr name = op->name;
767 767
768 op->contr = 0; 768 op->contr = 0;
769 op->type = 0; 769 op->type = 0;
770 op->free (1); 770 op->destroy (1);
771 pl = get_player (pl); 771 pl = get_player (pl);
772 op = pl->ob; 772 op = pl->ob;
773 add_friendly_object (op); 773 add_friendly_object (op);
774 op->contr->password[0] = '~'; 774 op->contr->password[0] = '~';
775 op->name = op->name_pl = 0; 775 op->name = op->name_pl = 0;
1051{ 1051{
1052 int tmp_loop; 1052 int tmp_loop;
1053 1053
1054 if (key == 'q' || key == 'Q') 1054 if (key == 'q' || key == 'Q')
1055 { 1055 {
1056 remove_ob (op); 1056 op->remove ();
1057 play_again (op); 1057 play_again (op);
1058 return 0; 1058 return 0;
1059 } 1059 }
1060 if (key == 'd' || key == 'D') 1060 if (key == 'd' || key == 'D')
1061 { 1061 {
1096 { 1096 {
1097 object *tmp; 1097 object *tmp;
1098 char mapname[MAX_BUF]; 1098 char mapname[MAX_BUF];
1099 1099
1100 snprintf (mapname, MAX_BUF - 1, "%s/%s", first_map_ext_path, &op->arch->name); 1100 snprintf (mapname, MAX_BUF - 1, "%s/%s", first_map_ext_path, &op->arch->name);
1101 tmp = get_object (); 1101 tmp = object::create ();
1102 EXIT_PATH (tmp) = mapname; 1102 EXIT_PATH (tmp) = mapname;
1103 EXIT_X (tmp) = op->x; 1103 EXIT_X (tmp) = op->x;
1104 EXIT_Y (tmp) = op->y; 1104 EXIT_Y (tmp) = op->y;
1105 enter_exit (op, tmp); /* we don't really care if it succeeded; 1105 enter_exit (op, tmp); /* we don't really care if it succeeded;
1106 * if the map isn't there, then stay on the 1106 * if the map isn't there, then stay on the
1107 * default initial map */ 1107 * default initial map */
1108 free_object (tmp); 1108 tmp->destroy ();
1109 } 1109 }
1110 else 1110 else
1111 { 1111 {
1112 LOG (llevDebug, "first_map_ext_path not set\n"); 1112 LOG (llevDebug, "first_map_ext_path not set\n");
1113 } 1113 }
1123 { 1123 {
1124 shstr name = op->name; 1124 shstr name = op->name;
1125 int x = op->x, y = op->y; 1125 int x = op->x, y = op->y;
1126 1126
1127 remove_statbonus (op); 1127 remove_statbonus (op);
1128 remove_ob (op); 1128 op->remove ();
1129 op->arch = get_player_archetype (op->arch); 1129 op->arch = get_player_archetype (op->arch);
1130 copy_object (&op->arch->clone, op); 1130 op->arch->clone.copy_to (op);
1131 op->instantiate (); 1131 op->instantiate ();
1132 op->stats = op->contr->orig_stats; 1132 op->stats = op->contr->orig_stats;
1133 op->name = op->name_pl = name; 1133 op->name = op->name_pl = name;
1134 op->x = x; 1134 op->x = x;
1135 op->y = y; 1135 op->y = y;
1180 if (settings.set_title == TRUE) 1180 if (settings.set_title == TRUE)
1181 op->contr->own_title[0] = '\0'; 1181 op->contr->own_title[0] = '\0';
1182 1182
1183 if (!QUERY_FLAG (op, FLAG_WAS_WIZ)) 1183 if (!QUERY_FLAG (op, FLAG_WAS_WIZ))
1184 { 1184 {
1185 mapstruct *mp, *next; 1185 maptile *mp, *next;
1186 1186
1187 /* We need to hunt for any per player unique maps in memory and 1187 /* We need to hunt for any per player unique maps in memory and
1188 * get rid of them. The trailing slash in the path is intentional, 1188 * get rid of them. The trailing slash in the path is intentional,
1189 * so that players named 'Ab' won't match against players 'Abe' pathname 1189 * so that players named 'Ab' won't match against players 'Abe' pathname
1190 */ 1190 */
1264 */ 1264 */
1265int 1265int
1266check_pick (object *op) 1266check_pick (object *op)
1267{ 1267{
1268 object *tmp, *next; 1268 object *tmp, *next;
1269 tag_t next_tag = 0, op_tag;
1270 int stop = 0; 1269 int stop = 0;
1271 int j, k, wvratio; 1270 int j, k, wvratio;
1272 char putstring[128], tmpstr[16]; 1271 char putstring[128], tmpstr[16];
1273 1272
1274
1275 /* if you're flying, you cna't pick up anything */ 1273 /* if you're flying, you cna't pick up anything */
1276 if (op->move_type & MOVE_FLYING) 1274 if (op->move_type & MOVE_FLYING)
1277 return 1; 1275 return 1;
1278 1276
1279 op_tag = op->count;
1280
1281 next = op->below; 1277 next = op->below;
1282 if (next)
1283 next_tag = next->count;
1284 1278
1285 /* loop while there are items on the floor that are not marked as 1279 /* loop while there are items on the floor that are not marked as
1286 * destroyed */ 1280 * destroyed */
1287 while (next && !was_destroyed (next, next_tag)) 1281 while (next && !next->destroyed ())
1288 { 1282 {
1289 tmp = next; 1283 tmp = next;
1290 next = tmp->below; 1284 next = tmp->below;
1291 if (next)
1292 next_tag = next->count;
1293 1285
1294 if (was_destroyed (op, op_tag)) 1286 if (op->destroyed ())
1295 return 0; 1287 return 0;
1296 1288
1297 if (!can_pick (op, tmp)) 1289 if (!can_pick (op, tmp))
1298 continue; 1290 continue;
1299 1291
1431 /* question: don't pick up known-poisonous stuff? */ 1423 /* question: don't pick up known-poisonous stuff? */
1432 if (op->contr->mode & PU_FOOD) 1424 if (op->contr->mode & PU_FOOD)
1433 if (tmp->type == FOOD) 1425 if (tmp->type == FOOD)
1434 { 1426 {
1435 pick_up (op, tmp); 1427 pick_up (op, tmp);
1436 if (0)
1437 fprintf (stderr, "FOOD\n");
1438 continue; 1428 continue;
1439 } 1429 }
1430
1440 if (op->contr->mode & PU_DRINK) 1431 if (op->contr->mode & PU_DRINK)
1441 if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))) 1432 if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)))
1442 { 1433 {
1443 pick_up (op, tmp); 1434 pick_up (op, tmp);
1444 if (0)
1445 fprintf (stderr, "DRINK\n");
1446 continue; 1435 continue;
1447 } 1436 }
1448 1437
1449 if (op->contr->mode & PU_POTION) 1438 if (op->contr->mode & PU_POTION)
1450 if (tmp->type == POTION) 1439 if (tmp->type == POTION)
1451 { 1440 {
1452 pick_up (op, tmp); 1441 pick_up (op, tmp);
1453 if (0)
1454 fprintf (stderr, "POTION\n");
1455 continue; 1442 continue;
1456 } 1443 }
1457 1444
1458 /* spellbooks, skillscrolls and normal books/scrolls */ 1445 /* spellbooks, skillscrolls and normal books/scrolls */
1459 if (op->contr->mode & PU_SPELLBOOK) 1446 if (op->contr->mode & PU_SPELLBOOK)
1460 if (tmp->type == SPELLBOOK) 1447 if (tmp->type == SPELLBOOK)
1461 { 1448 {
1462 pick_up (op, tmp); 1449 pick_up (op, tmp);
1463 if (0)
1464 fprintf (stderr, "SPELLBOOK\n");
1465 continue; 1450 continue;
1466 } 1451 }
1452
1467 if (op->contr->mode & PU_SKILLSCROLL) 1453 if (op->contr->mode & PU_SKILLSCROLL)
1468 if (tmp->type == SKILLSCROLL) 1454 if (tmp->type == SKILLSCROLL)
1469 { 1455 {
1470 pick_up (op, tmp); 1456 pick_up (op, tmp);
1471 if (0)
1472 fprintf (stderr, "SKILLSCROLL\n");
1473 continue; 1457 continue;
1474 } 1458 }
1459
1475 if (op->contr->mode & PU_READABLES) 1460 if (op->contr->mode & PU_READABLES)
1476 if (tmp->type == BOOK || tmp->type == SCROLL) 1461 if (tmp->type == BOOK || tmp->type == SCROLL)
1477 { 1462 {
1478 pick_up (op, tmp); 1463 pick_up (op, tmp);
1479 if (0)
1480 fprintf (stderr, "READABLES\n");
1481 continue; 1464 continue;
1482 } 1465 }
1483 1466
1484 /* wands/staves/rods/horns */ 1467 /* wands/staves/rods/horns */
1485 if (op->contr->mode & PU_MAGIC_DEVICE) 1468 if (op->contr->mode & PU_MAGIC_DEVICE)
1486 if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) 1469 if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN)
1487 { 1470 {
1488 pick_up (op, tmp); 1471 pick_up (op, tmp);
1489 if (0)
1490 fprintf (stderr, "MAGIC_DEVICE\n");
1491 continue; 1472 continue;
1492 } 1473 }
1493 1474
1494 /* pick up all magical items */ 1475 /* pick up all magical items */
1495 if (op->contr->mode & PU_MAGICAL) 1476 if (op->contr->mode & PU_MAGICAL)
1496 if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) 1477 if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))
1497 { 1478 {
1498 pick_up (op, tmp); 1479 pick_up (op, tmp);
1499 if (0)
1500 fprintf (stderr, "MAGICAL\n");
1501 continue; 1480 continue;
1502 } 1481 }
1503 1482
1504 if (op->contr->mode & PU_VALUABLES) 1483 if (op->contr->mode & PU_VALUABLES)
1505 { 1484 {
1506 if (tmp->type == MONEY || tmp->type == GEM) 1485 if (tmp->type == MONEY || tmp->type == GEM)
1507 { 1486 {
1508 pick_up (op, tmp); 1487 pick_up (op, tmp);
1509 if (0)
1510 fprintf (stderr, "MONEY/GEM\n");
1511 continue; 1488 continue;
1512 } 1489 }
1513 } 1490 }
1514 1491
1515 /* rings & amulets - talismans seems to be typed AMULET */ 1492 /* rings & amulets - talismans seems to be typed AMULET */
1516 if (op->contr->mode & PU_JEWELS) 1493 if (op->contr->mode & PU_JEWELS)
1517 if (tmp->type == RING || tmp->type == AMULET) 1494 if (tmp->type == RING || tmp->type == AMULET)
1518 { 1495 {
1519 pick_up (op, tmp); 1496 pick_up (op, tmp);
1497 continue;
1520 if (0) 1498 }
1521 fprintf (stderr, "JEWELS\n"); 1499
1500 /* we don't forget dragon food */
1501 if (op->contr->mode & PU_FLESH)
1502 if (tmp->type == FLESH)
1503 {
1504 pick_up (op, tmp);
1522 continue; 1505 continue;
1523 } 1506 }
1524 1507
1525 /* bows and arrows. Bows are good for selling! */ 1508 /* bows and arrows. Bows are good for selling! */
1526 if (op->contr->mode & PU_BOW) 1509 if (op->contr->mode & PU_BOW)
1527 if (tmp->type == BOW) 1510 if (tmp->type == BOW)
1528 { 1511 {
1529 pick_up (op, tmp); 1512 pick_up (op, tmp);
1530 if (0)
1531 fprintf (stderr, "BOW\n");
1532 continue; 1513 continue;
1533 } 1514 }
1515
1534 if (op->contr->mode & PU_ARROW) 1516 if (op->contr->mode & PU_ARROW)
1535 if (tmp->type == ARROW) 1517 if (tmp->type == ARROW)
1536 { 1518 {
1537 pick_up (op, tmp); 1519 pick_up (op, tmp);
1538 if (0)
1539 fprintf (stderr, "ARROW\n");
1540 continue; 1520 continue;
1541 } 1521 }
1542 1522
1543 /* all kinds of armor etc. */ 1523 /* all kinds of armor etc. */
1544 if (op->contr->mode & PU_ARMOUR) 1524 if (op->contr->mode & PU_ARMOUR)
1545 if (tmp->type == ARMOUR) 1525 if (tmp->type == ARMOUR)
1546 { 1526 {
1547 pick_up (op, tmp); 1527 pick_up (op, tmp);
1548 if (0)
1549 fprintf (stderr, "ARMOUR\n");
1550 continue; 1528 continue;
1551 } 1529 }
1530
1552 if (op->contr->mode & PU_HELMET) 1531 if (op->contr->mode & PU_HELMET)
1553 if (tmp->type == HELMET) 1532 if (tmp->type == HELMET)
1554 { 1533 {
1555 pick_up (op, tmp); 1534 pick_up (op, tmp);
1556 if (0)
1557 fprintf (stderr, "HELMET\n");
1558 continue; 1535 continue;
1559 } 1536 }
1537
1560 if (op->contr->mode & PU_SHIELD) 1538 if (op->contr->mode & PU_SHIELD)
1561 if (tmp->type == SHIELD) 1539 if (tmp->type == SHIELD)
1562 { 1540 {
1563 pick_up (op, tmp); 1541 pick_up (op, tmp);
1564 if (0)
1565 fprintf (stderr, "SHIELD\n");
1566 continue; 1542 continue;
1567 } 1543 }
1544
1568 if (op->contr->mode & PU_BOOTS) 1545 if (op->contr->mode & PU_BOOTS)
1569 if (tmp->type == BOOTS) 1546 if (tmp->type == BOOTS)
1570 { 1547 {
1571 pick_up (op, tmp); 1548 pick_up (op, tmp);
1572 if (0)
1573 fprintf (stderr, "BOOTS\n");
1574 continue; 1549 continue;
1575 } 1550 }
1551
1576 if (op->contr->mode & PU_GLOVES) 1552 if (op->contr->mode & PU_GLOVES)
1577 if (tmp->type == GLOVES) 1553 if (tmp->type == GLOVES)
1578 { 1554 {
1579 pick_up (op, tmp); 1555 pick_up (op, tmp);
1580 if (0)
1581 fprintf (stderr, "GLOVES\n");
1582 continue; 1556 continue;
1583 } 1557 }
1558
1584 if (op->contr->mode & PU_CLOAK) 1559 if (op->contr->mode & PU_CLOAK)
1585 if (tmp->type == CLOAK) 1560 if (tmp->type == CLOAK)
1586 { 1561 {
1587 pick_up (op, tmp); 1562 pick_up (op, tmp);
1588 if (0)
1589 fprintf (stderr, "GLOVES\n");
1590 continue; 1563 continue;
1591 } 1564 }
1592 1565
1593 /* hoping to catch throwing daggers here */ 1566 /* hoping to catch throwing daggers here */
1594 if (op->contr->mode & PU_MISSILEWEAPON) 1567 if (op->contr->mode & PU_MISSILEWEAPON)
1595 if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) 1568 if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN))
1596 { 1569 {
1597 pick_up (op, tmp); 1570 pick_up (op, tmp);
1598 if (0)
1599 fprintf (stderr, "MISSILEWEAPON\n");
1600 continue; 1571 continue;
1601 } 1572 }
1602 1573
1603 /* careful: chairs and tables are weapons! */ 1574 /* careful: chairs and tables are weapons! */
1604 if (op->contr->mode & PU_ALLWEAPON) 1575 if (op->contr->mode & PU_ALLWEAPON)
1607 { 1578 {
1608 if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->name, "table") == NULL && 1579 if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->name, "table") == NULL &&
1609 strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL) 1580 strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL)
1610 { 1581 {
1611 pick_up (op, tmp); 1582 pick_up (op, tmp);
1612 if (0)
1613 fprintf (stderr, "WEAPON\n");
1614 continue; 1583 continue;
1615 } 1584 }
1616 } 1585 }
1586
1617 if (tmp->type == WEAPON && tmp->name == NULL) 1587 if (tmp->type == WEAPON && tmp->name == NULL)
1618 { 1588 {
1619 if (strstr (tmp->arch->name, "table") == NULL && strstr (tmp->arch->name, "chair") == NULL) 1589 if (strstr (tmp->arch->name, "table") == NULL && strstr (tmp->arch->name, "chair") == NULL)
1620 { 1590 {
1621 pick_up (op, tmp); 1591 pick_up (op, tmp);
1622 if (0)
1623 fprintf (stderr, "WEAPON\n");
1624 continue; 1592 continue;
1625 } 1593 }
1626 } 1594 }
1627 } 1595 }
1628 1596
1629 /* misc stuff that's useful */ 1597 /* misc stuff that's useful */
1630 if (op->contr->mode & PU_KEY) 1598 if (op->contr->mode & PU_KEY)
1631 if (tmp->type == KEY || tmp->type == SPECIAL_KEY) 1599 if (tmp->type == KEY || tmp->type == SPECIAL_KEY)
1632 { 1600 {
1633 pick_up (op, tmp); 1601 pick_up (op, tmp);
1634 if (0)
1635 fprintf (stderr, "KEY\n");
1636 continue; 1602 continue;
1637 } 1603 }
1638 1604
1639 /* any of the last 4 bits set means we use the ratio for value 1605 /* any of the last 4 bits set means we use the ratio for value
1640 * pickups */ 1606 * pickups */
1662 continue; 1628 continue;
1663 } 1629 }
1664 } 1630 }
1665 } /* the new pickup model */ 1631 } /* the new pickup model */
1666 } 1632 }
1633
1667 return !stop; 1634 return !stop;
1668} 1635}
1669 1636
1670/* 1637/*
1671 * Find an arrow in the inventory and after that 1638 * Find an arrow in the inventory and after that
1770 1737
1771object * 1738object *
1772pick_arrow_target (object *op, const char *type, int dir) 1739pick_arrow_target (object *op, const char *type, int dir)
1773{ 1740{
1774 object *tmp = NULL; 1741 object *tmp = NULL;
1775 mapstruct *m; 1742 maptile *m;
1776 int i, mflags, found, number; 1743 int i, mflags, found, number;
1777 sint16 x, y; 1744 sint16 x, y;
1778 1745
1779 if (op->map == NULL) 1746 if (op->map == NULL)
1780 return find_arrow (op, type); 1747 return find_arrow (op, type);
1840 */ 1807 */
1841int 1808int
1842fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy) 1809fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy)
1843{ 1810{
1844 object *left, *bow; 1811 object *left, *bow;
1845 tag_t left_tag, tag;
1846 int bowspeed, mflags; 1812 int bowspeed, mflags;
1847 mapstruct *m; 1813 maptile *m;
1848 1814
1849 if (!dir) 1815 if (!dir)
1850 { 1816 {
1851 new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); 1817 new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!");
1852 return 0; 1818 return 0;
1906 } 1872 }
1907 1873
1908 /* this should not happen, but sometimes does */ 1874 /* this should not happen, but sometimes does */
1909 if (arrow->nrof == 0) 1875 if (arrow->nrof == 0)
1910 { 1876 {
1911 remove_ob (arrow); 1877 arrow->destroy ();
1912 free_object (arrow);
1913 return 0; 1878 return 0;
1914 } 1879 }
1915 1880
1916 left = arrow; /* these are arrows left to the player */ 1881 left = arrow; /* these are arrows left to the player */
1917 left_tag = left->count;
1918 arrow = get_split_ob (arrow, 1); 1882 arrow = get_split_ob (arrow, 1);
1919 if (arrow == NULL) 1883 if (arrow == NULL)
1920 { 1884 {
1921 new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); 1885 new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race);
1922 return 0; 1886 return 0;
1923 } 1887 }
1924 set_owner (arrow, op); 1888 arrow->set_owner (op);
1925 arrow->skill = bow->skill; 1889 arrow->skill = bow->skill;
1926 1890
1927 arrow->direction = dir; 1891 arrow->direction = dir;
1928 arrow->x = sx; 1892 arrow->x = sx;
1929 arrow->y = sy; 1893 arrow->y = sy;
1965 arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level; 1929 arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level;
1966 } 1930 }
1967 else 1931 else
1968 { 1932 {
1969 arrow->stats.wc = op->stats.wc - bow->magic - arrow->magic - arrow->stats.wc + wc_mod; 1933 arrow->stats.wc = op->stats.wc - bow->magic - arrow->magic - arrow->stats.wc + wc_mod;
1970
1971 arrow->level = op->level; 1934 arrow->level = op->level;
1972 } 1935 }
1936
1973 if (arrow->attacktype == AT_PHYSICAL) 1937 if (arrow->attacktype == AT_PHYSICAL)
1974 arrow->attacktype |= bow->attacktype; 1938 arrow->attacktype |= bow->attacktype;
1939
1975 if (bow->slaying != NULL) 1940 if (bow->slaying != NULL)
1976 arrow->slaying = bow->slaying; 1941 arrow->slaying = bow->slaying;
1977 1942
1978 arrow->map = m; 1943 arrow->map = m;
1979 arrow->move_type = MOVE_FLY_LOW; 1944 arrow->move_type = MOVE_FLY_LOW;
1980 arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; 1945 arrow->move_on = MOVE_FLY_LOW | MOVE_WALK;
1981 1946
1982 play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW); 1947 play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW);
1983 tag = arrow->count;
1984 insert_ob_in_map (arrow, m, op, 0); 1948 insert_ob_in_map (arrow, m, op, 0);
1985 1949
1986 if (!was_destroyed (arrow, tag)) 1950 if (!arrow->destroyed ())
1987 move_arrow (arrow); 1951 move_arrow (arrow);
1988 1952
1989 if (op->type == PLAYER) 1953 if (op->type == PLAYER)
1990 { 1954 {
1991 if (was_destroyed (left, left_tag)) 1955 if (left->destroyed ())
1992 esrv_del_item (op->contr, left_tag); 1956 esrv_del_item (op->contr, left->count);
1993 else 1957 else
1994 esrv_send_item (op, left); 1958 esrv_send_item (op, left);
1995 } 1959 }
1960
1996 return 1; 1961 return 1;
1997} 1962}
1998 1963
1999/* Special fire code for players - this takes into 1964/* Special fire code for players - this takes into
2000 * account the special fire modes players can have 1965 * account the special fire modes players can have
2136 case range_misc: 2101 case range_misc:
2137 fire_misc_object (op, dir); 2102 fire_misc_object (op, dir);
2138 return; 2103 return;
2139 2104
2140 case range_golem: /* Control summoned monsters from scrolls */ 2105 case range_golem: /* Control summoned monsters from scrolls */
2141 if (op->contr->ranges[range_golem] == NULL || op->contr->golem_count != op->contr->ranges[range_golem]->count) 2106 if (QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED))
2142 { 2107 {
2143 op->contr->ranges[range_golem] = NULL; 2108 op->contr->ranges[range_golem] = 0;
2144 op->contr->shoottype = range_none; 2109 op->contr->shoottype = range_none;
2145 op->contr->golem_count = 0;
2146 } 2110 }
2147 else 2111 else
2148 control_golem (op->contr->ranges[range_golem], dir); 2112 control_golem (op->contr->ranges[range_golem], dir);
2149 return; 2113 return;
2150 2114
2312move_player_attack (object *op, int dir) 2276move_player_attack (object *op, int dir)
2313{ 2277{
2314 object *tmp, *mon; 2278 object *tmp, *mon;
2315 sint16 nx, ny; 2279 sint16 nx, ny;
2316 int on_battleground; 2280 int on_battleground;
2317 mapstruct *m; 2281 maptile *m;
2318 2282
2319 nx = freearr_x[dir] + op->x; 2283 nx = freearr_x[dir] + op->x;
2320 ny = freearr_y[dir] + op->y; 2284 ny = freearr_y[dir] + op->y;
2321 2285
2322 on_battleground = op_on_battleground (op, NULL, NULL); 2286 on_battleground = op_on_battleground (op, NULL, NULL);
2358 if (tmp == op) 2322 if (tmp == op)
2359 { 2323 {
2360 tmp = tmp->above; 2324 tmp = tmp->above;
2361 continue; 2325 continue;
2362 } 2326 }
2327
2363 if (QUERY_FLAG (tmp, FLAG_ALIVE)) 2328 if (QUERY_FLAG (tmp, FLAG_ALIVE))
2364 { 2329 {
2365 mon = tmp; 2330 mon = tmp;
2366 break; 2331 break;
2367 } 2332 }
2333
2368 if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL)) 2334 if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL))
2369 mon = tmp; 2335 mon = tmp;
2336
2370 tmp = tmp->above; 2337 tmp = tmp->above;
2371 } 2338 }
2372 2339
2373 if (mon == NULL) /* This happens anytime the player tries to move */ 2340 if (mon == NULL) /* This happens anytime the player tries to move */
2374 return; /* into a wall */ 2341 return; /* into a wall */
2393 * player owns it and it is either friendly or unagressive. 2360 * player owns it and it is either friendly or unagressive.
2394 */ 2361 */
2395 if ((op->type == PLAYER) 2362 if ((op->type == PLAYER)
2396#if COZY_SERVER 2363#if COZY_SERVER
2397 && 2364 &&
2398 ((get_owner (mon) && get_owner (mon)->contr 2365 ((mon->owner && mon->owner->contr
2399 && same_party (get_owner (mon)->contr->party, op->contr->party)) || get_owner (mon) == op) 2366 && same_party (mon->owner->contr->party, op->contr->party)) || mon->owner == op)
2400#else 2367#else
2401 && get_owner (mon) == op 2368 && mon->owner == op
2402#endif 2369#endif
2403 && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) 2370 && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)))
2404 { 2371 {
2405 /* If we're braced, we don't want to switch places with it */ 2372 /* If we're braced, we don't want to switch places with it */
2406 if (op->contr->braced) 2373 if (op->contr->braced)
2593 /* I've been seeing crashes where the golem has been destroyed, but 2560 /* I've been seeing crashes where the golem has been destroyed, but
2594 * the player object still points to the defunct golem. The code that 2561 * the player object still points to the defunct golem. The code that
2595 * destroys the golem looks correct, and it doesn't always happen, so 2562 * destroys the golem looks correct, and it doesn't always happen, so
2596 * put this in a a workaround to clean up the golem pointer. 2563 * put this in a a workaround to clean up the golem pointer.
2597 */ 2564 */
2598 if (op->contr->ranges[range_golem] &&
2599 ((op->contr->golem_count != op->contr->ranges[range_golem]->count) || QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED))) 2565 if (op->contr->ranges[range_golem] && QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED))
2600 {
2601 op->contr->ranges[range_golem] = NULL; 2566 op->contr->ranges[range_golem] = 0;
2602 op->contr->golem_count = 0;
2603 }
2604 2567
2605 /* call this here - we also will call this in do_ericserver, but 2568 /* call this here - we also will call this in do_ericserver, but
2606 * the players time has been increased when doericserver has been 2569 * the players time has been increased when doericserver has been
2607 * called, so we recheck it here. 2570 * called, so we recheck it here.
2608 */ 2571 */
2639 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 2602 for (tmp = op->inv; tmp != NULL; tmp = tmp->below)
2640 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) 2603 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE))
2641 { 2604 {
2642 play_sound_map (op->map, op->x, op->y, SOUND_OB_EVAPORATE); 2605 play_sound_map (op->map, op->x, op->y, SOUND_OB_EVAPORATE);
2643 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); 2606 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp));
2607
2644 if (op->contr) 2608 if (op->contr)
2645 esrv_del_item (op->contr, tmp->count); 2609 esrv_del_item (op->contr, tmp->count);
2646 remove_ob (tmp); 2610
2647 free_object (tmp); 2611 tmp->destroy ();
2648 CLEAR_FLAG (op, FLAG_LIFESAVE); 2612 CLEAR_FLAG (op, FLAG_LIFESAVE);
2613
2649 if (op->stats.hp < 0) 2614 if (op->stats.hp < 0)
2650 op->stats.hp = op->stats.maxhp; 2615 op->stats.hp = op->stats.maxhp;
2616
2651 if (op->stats.food < 0) 2617 if (op->stats.food < 0)
2652 op->stats.food = 999; 2618 op->stats.food = 999;
2619
2653 fix_player (op); 2620 fix_player (op);
2654 return 1; 2621 return 1;
2655 } 2622 }
2656 LOG (llevError, "Error: LIFESAVE set without applied object.\n"); 2623 LOG (llevError, "Error: LIFESAVE set without applied object.\n");
2657 CLEAR_FLAG (op, FLAG_LIFESAVE); 2624 CLEAR_FLAG (op, FLAG_LIFESAVE);
2674 next = op->below; /* Make sure we have a good value, in case 2641 next = op->below; /* Make sure we have a good value, in case
2675 * we remove object 'op' 2642 * we remove object 'op'
2676 */ 2643 */
2677 if (QUERY_FLAG (op, FLAG_UNPAID)) 2644 if (QUERY_FLAG (op, FLAG_UNPAID))
2678 { 2645 {
2679 remove_ob (op); 2646 op->remove ();
2680 op->x = env->x; 2647 op->x = env->x;
2681 op->y = env->y; 2648 op->y = env->y;
2682 if (env->type == PLAYER) 2649 if (env->type == PLAYER)
2683 esrv_del_item (env->contr, op->count); 2650 esrv_del_item (env->contr, op->count);
2684 insert_ob_in_map (op, env->map, NULL, 0); 2651 insert_ob_in_map (op, env->map, NULL, 0);
2952{ 2919{
2953 char buf[MAX_BUF]; 2920 char buf[MAX_BUF];
2954 int x, y; 2921 int x, y;
2955 2922
2956 //int i; 2923 //int i;
2957 mapstruct *map; /* this is for resurrection */ 2924 maptile *map; /* this is for resurrection */
2958 2925
2959 /* int z; 2926 /* int z;
2960 int num_stats_lose; 2927 int num_stats_lose;
2961 int lost_a_stat; 2928 int lost_a_stat;
2962 int lose_this_stat; 2929 int lose_this_stat;
2981 /* restore player */ 2948 /* restore player */
2982 at = archetype::find ("poisoning"); 2949 at = archetype::find ("poisoning");
2983 tmp = present_arch_in_ob (at, op); 2950 tmp = present_arch_in_ob (at, op);
2984 if (tmp) 2951 if (tmp)
2985 { 2952 {
2986 remove_ob (tmp); 2953 tmp->destroy ();
2987 free_object (tmp);
2988 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); 2954 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed");
2989 } 2955 }
2990 2956
2991 at = archetype::find ("confusion"); 2957 at = archetype::find ("confusion");
2992 tmp = present_arch_in_ob (at, op); 2958 tmp = present_arch_in_ob (at, op);
2993 if (tmp) 2959 if (tmp)
2994 { 2960 {
2995 remove_ob (tmp); 2961 tmp->destroy ();
2996 free_object (tmp);
2997 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); 2962 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer");
2998 } 2963 }
2999 2964
3000 cure_disease (op, 0); /* remove any disease */ 2965 cure_disease (op, 0); /* remove any disease */
3001 op->stats.hp = op->stats.maxhp; 2966 op->stats.hp = op->stats.maxhp;
3178 /* determine_god() seems to not work sometimes... why is this? 3143 /* determine_god() seems to not work sometimes... why is this?
3179 Should I be using something else? GD */ 3144 Should I be using something else? GD */
3180 const char *god = determine_god (op); 3145 const char *god = determine_god (op);
3181 3146
3182 if (god && (strcmp (god, "none"))) 3147 if (god && (strcmp (god, "none")))
3183 new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief " "moment you feel the holy presence of %s protecting" " you.", god); 3148 new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief moment you feel the holy presence of %s protecting" " you.", god);
3184 else 3149 else
3185 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you."); 3150 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you.");
3186 } 3151 }
3152#else
3153 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely.");
3187#endif 3154#endif
3188 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely.");
3189 3155
3190 /* Put a gravestone up where the character 'almost' died. List the 3156 /* Put a gravestone up where the character 'almost' died. List the
3191 * exp loss on the stone. 3157 * exp loss on the stone.
3192 */ 3158 */
3193 tmp = arch_to_object (archetype::find ("gravestone")); 3159 tmp = arch_to_object (archetype::find ("gravestone"));
3198 sprintf (buf, "RIP\nHere rests the hero %s the %s,\n" "who was killed\n" "by %s.\n", &op->name, op->contr->title, op->contr->killer); 3164 sprintf (buf, "RIP\nHere rests the hero %s the %s,\n" "who was killed\n" "by %s.\n", &op->name, op->contr->title, op->contr->killer);
3199 tmp->msg = buf; 3165 tmp->msg = buf;
3200 tmp->x = op->x, tmp->y = op->y; 3166 tmp->x = op->x, tmp->y = op->y;
3201 insert_ob_in_map (tmp, op->map, NULL, 0); 3167 insert_ob_in_map (tmp, op->map, NULL, 0);
3202 3168
3203 /**************************************/ 3169 /**************************************/
3204 /* */ 3170 /* */
3205 /* Subtract the experience points, */ 3171 /* Subtract the experience points, */
3206 /* if we died cause of food, give us */ 3172 /* if we died cause of food, give us */
3207 /* food, and reset HP's... */ 3173 /* food, and reset HP's... */
3208 /* */ 3174 /* */
3209
3210 /**************************************/ 3175 /**************************************/
3211 3176
3212 /* remove any poisoning and confusion the character may be suffering. */ 3177 /* remove any poisoning and confusion the character may be suffering. */
3213 /* restore player */ 3178 /* restore player */
3214 at = archetype::find ("poisoning"); 3179 at = archetype::find ("poisoning");
3215 tmp = present_arch_in_ob (at, op); 3180 tmp = present_arch_in_ob (at, op);
3181
3216 if (tmp) 3182 if (tmp)
3217 { 3183 {
3218 remove_ob (tmp); 3184 tmp->destroy ();
3219 free_object (tmp);
3220 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); 3185 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed");
3221 } 3186 }
3222 3187
3223 at = archetype::find ("confusion"); 3188 at = archetype::find ("confusion");
3224 tmp = present_arch_in_ob (at, op); 3189 tmp = present_arch_in_ob (at, op);
3225 if (tmp) 3190 if (tmp)
3226 { 3191 {
3227 remove_ob (tmp); 3192 tmp->destroy ();
3228 free_object (tmp);
3229 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); 3193 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer");
3230 } 3194 }
3195
3231 cure_disease (op, 0); /* remove any disease */ 3196 cure_disease (op, 0); /* remove any disease */
3232 3197
3233 /*add_exp(op, (op->stats.exp * -0.20)); */ 3198 /*add_exp(op, (op->stats.exp * -0.20)); */
3234 apply_death_exp_penalty (op); 3199 apply_death_exp_penalty (op);
3235 if (op->stats.food < 100) 3200 if (op->stats.food < 100)
3245 */ 3210 */
3246 3211
3247 if (is_in_shop (op)) 3212 if (is_in_shop (op))
3248 remove_unpaid_objects (op->inv, op); 3213 remove_unpaid_objects (op->inv, op);
3249 3214
3250 /****************************************/ 3215 /****************************************/
3251 /* */ 3216 /* */
3252 /* Move player to his current respawn- */ 3217 /* Move player to his current respawn- */
3253 /* position (usually last savebed) */ 3218 /* position (usually last savebed) */
3254 /* */ 3219 /* */
3255
3256 /****************************************/ 3220 /****************************************/
3257 3221
3258 enter_player_savebed (op); 3222 enter_player_savebed (op);
3259 3223
3260 /* Save the player before inserting the force to reduce 3224 /* Save the player before inserting the force to reduce
3261 * chance of abuse. 3225 * chance of abuse.
3268 * spell effects. So first see if there is a spell effect 3232 * spell effects. So first see if there is a spell effect
3269 * on the space that might harm the player. 3233 * on the space that might harm the player.
3270 */ 3234 */
3271 will_kill_again = 0; 3235 will_kill_again = 0;
3272 for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above) 3236 for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above)
3273 {
3274 if (tmp->type == SPELL_EFFECT) 3237 if (tmp->type == SPELL_EFFECT)
3275 will_kill_again |= tmp->attacktype; 3238 will_kill_again |= tmp->attacktype;
3276 } 3239
3277 if (will_kill_again) 3240 if (will_kill_again)
3278 { 3241 {
3279 object *force; 3242 object *force;
3280 int at; 3243 int at;
3281 3244
3283 /* 50 ticks should be enough time for the spell to abate */ 3246 /* 50 ticks should be enough time for the spell to abate */
3284 force->speed = 0.1; 3247 force->speed = 0.1;
3285 force->speed_left = -5.0; 3248 force->speed_left = -5.0;
3286 SET_FLAG (force, FLAG_APPLIED); 3249 SET_FLAG (force, FLAG_APPLIED);
3287 for (at = 0; at < NROFATTACKS; at++) 3250 for (at = 0; at < NROFATTACKS; at++)
3288 {
3289 if (will_kill_again & (1 << at)) 3251 if (will_kill_again & (1 << at))
3290 force->resist[at] = 100; 3252 force->resist[at] = 100;
3291 } 3253
3292 insert_ob_in_ob (force, op); 3254 insert_ob_in_ob (force, op);
3293 fix_player (op); 3255 fix_player (op);
3294 3256
3295 } 3257 }
3296 3258
3306 op->contr->party = NULL; 3268 op->contr->party = NULL;
3307 if (settings.set_title == TRUE) 3269 if (settings.set_title == TRUE)
3308 op->contr->own_title[0] = '\0'; 3270 op->contr->own_title[0] = '\0';
3309 new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf); 3271 new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf);
3310 check_score (op); 3272 check_score (op);
3273
3311 if (op->contr->ranges[range_golem] != NULL) 3274 if (op->contr->ranges[range_golem])
3312 { 3275 {
3313 remove_friendly_object (op->contr->ranges[range_golem]); 3276 remove_friendly_object (op->contr->ranges[range_golem]);
3314 remove_ob (op->contr->ranges[range_golem]); 3277 op->contr->ranges[range_golem]->destroy ();
3315 free_object (op->contr->ranges[range_golem]);
3316 op->contr->ranges[range_golem] = NULL; 3278 op->contr->ranges[range_golem] = 0;
3317 op->contr->golem_count = 0;
3318 } 3279 }
3280
3319 loot_object (op); /* Remove some of the items for good */ 3281 loot_object (op); /* Remove some of the items for good */
3320 remove_ob (op); 3282 op->remove ();
3321 op->direction = 0; 3283 op->direction = 0;
3322 3284
3323 if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp) 3285 if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp)
3324 { 3286 {
3325 delete_character (op->name, 0); 3287 delete_character (op->name, 0);
3378 for (tmp = op->inv; tmp != NULL; tmp = next) 3340 for (tmp = op->inv; tmp != NULL; tmp = next)
3379 { 3341 {
3380 next = tmp->below; 3342 next = tmp->below;
3381 if (tmp->type == EXPERIENCE || tmp->invisible) 3343 if (tmp->type == EXPERIENCE || tmp->invisible)
3382 continue; 3344 continue;
3383 remove_ob (tmp); 3345 tmp->remove ();
3384 tmp->x = op->x, tmp->y = op->y; 3346 tmp->x = op->x, tmp->y = op->y;
3385 if (tmp->type == CONTAINER) 3347 if (tmp->type == CONTAINER)
3386 { /* empty container to ground */ 3348 { /* empty container to ground */
3387 loot_object (tmp); 3349 loot_object (tmp);
3388 } 3350 }
3389 if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(RANDOM () % 3))) 3351 if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(RANDOM () % 3)))
3390 { 3352 {
3391 if (tmp->nrof > 1) 3353 if (tmp->nrof > 1)
3392 { 3354 {
3393 tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); 3355 tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1));
3394 free_object (tmp2); 3356 tmp2->destroy ();
3395 insert_ob_in_map (tmp, op->map, NULL, 0); 3357 insert_ob_in_map (tmp, op->map, NULL, 0);
3396 } 3358 }
3397 else 3359 else
3398 free_object (tmp); 3360 tmp->destroy ();
3399 } 3361 }
3400 else 3362 else
3401 insert_ob_in_map (tmp, op->map, NULL, 0); 3363 insert_ob_in_map (tmp, op->map, NULL, 0);
3402 } 3364 }
3403} 3365}
3468 if (op->type == PLAYER) 3430 if (op->type == PLAYER)
3469 new_draw_info_format (NDI_UNIQUE, 0, op, "You cast %s.", &spob->name); 3431 new_draw_info_format (NDI_UNIQUE, 0, op, "You cast %s.", &spob->name);
3470 3432
3471 cast_spell (op, throw_ob, dir, spob, NULL); 3433 cast_spell (op, throw_ob, dir, spob, NULL);
3472 3434
3473 if (!QUERY_FLAG (throw_ob, FLAG_REMOVED)) 3435 throw_ob->destroy ();
3474 remove_ob (throw_ob);
3475 free_object (throw_ob);
3476} 3436}
3477 3437
3478void 3438void
3479make_visible (object *op) 3439make_visible (object *op)
3480{ 3440{
3596int 3556int
3597stand_near_hostile (object *who) 3557stand_near_hostile (object *who)
3598{ 3558{
3599 object *tmp = NULL; 3559 object *tmp = NULL;
3600 int i, friendly = 0, player = 0, mflags; 3560 int i, friendly = 0, player = 0, mflags;
3601 mapstruct *m; 3561 maptile *m;
3602 sint16 x, y; 3562 sint16 x, y;
3603 3563
3604 if (!who) 3564 if (!who)
3605 return 0; 3565 return 0;
3606 3566

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines