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.27 by root, Wed Sep 27 00:36:09 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>
338 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));
339 /* 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.
340 * 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
341 * on the uncoming socket. 339 * on the uncoming socket.
342 */ 340 */
341 //TODO socket copying is EVIL, do not do this
343 p->socket.inbuf.len = 0; 342 p->socket.inbuf_len = 0;
344 set_first_map (p->ob); 343 set_first_map (p->ob);
345 344
346 CLEAR_FLAG (p->ob, FLAG_FRIENDLY); 345 CLEAR_FLAG (p->ob, FLAG_FRIENDLY);
347 add_friendly_object (p->ob); 346 add_friendly_object (p->ob);
348 send_rules (p->ob); 347 send_rules (p->ob);
646 (op->type == ARMOUR || op->type == BOOTS || 645 (op->type == ARMOUR || op->type == BOOTS ||
647 op->type == CLOAK || op->type == HELMET || 646 op->type == CLOAK || op->type == HELMET ||
648 op->type == SHIELD || op->type == GLOVES || 647 op->type == SHIELD || op->type == GLOVES ||
649 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))
650 { 649 {
651 remove_ob (op); 650 op->destroy ();
652 free_object (op);
653 continue; 651 continue;
654 } 652 }
655 } 653 }
656 654
657 /* This really needs to be better - we should really give 655 /* This really needs to be better - we should really give
668 if (tmp->type == op->type && tmp->name == op->name) 666 if (tmp->type == op->type && tmp->name == op->name)
669 break; 667 break;
670 668
671 if (tmp) 669 if (tmp)
672 { 670 {
673 remove_ob (op); 671 op->destroy ();
674 free_object (op);
675 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);
676 continue; 673 continue;
677 } 674 }
675
678 if (op->nrof > 1) 676 if (op->nrof > 1)
679 op->nrof = 1; 677 op->nrof = 1;
680 } 678 }
681 679
682 if (op->type == SPELLBOOK && op->inv) 680 if (op->type == SPELLBOOK && op->inv)
694 CLEAR_FLAG (op, FLAG_CURSED); 692 CLEAR_FLAG (op, FLAG_CURSED);
695 CLEAR_FLAG (op, FLAG_DAMNED); 693 CLEAR_FLAG (op, FLAG_DAMNED);
696 } 694 }
697 if (op->type == SPELL) 695 if (op->type == SPELL)
698 { 696 {
699 remove_ob (op); 697 op->destroy ();
700 free_object (op);
701 continue; 698 continue;
702 } 699 }
703 else if (op->type == SKILL) 700 else if (op->type == SKILL)
704 { 701 {
705 SET_FLAG (op, FLAG_CAN_USE_SKILL); 702 SET_FLAG (op, FLAG_CAN_USE_SKILL);
744 * removing the player - it probably makes more sense 741 * removing the player - it probably makes more sense
745 * 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
746 * cases. 743 * cases.
747 */ 744 */
748 if (!QUERY_FLAG (op, FLAG_REMOVED)) 745 if (!QUERY_FLAG (op, FLAG_REMOVED))
749 remove_ob (op); 746 op->remove ();
750 /* 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,
751 * 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
752 * the map is null or not swapped out. 749 * the map is null or not swapped out.
753 */ 750 */
754 op->map = NULL; 751 op->map = NULL;
1054{ 1051{
1055 int tmp_loop; 1052 int tmp_loop;
1056 1053
1057 if (key == 'q' || key == 'Q') 1054 if (key == 'q' || key == 'Q')
1058 { 1055 {
1059 remove_ob (op); 1056 op->remove ();
1060 play_again (op); 1057 play_again (op);
1061 return 0; 1058 return 0;
1062 } 1059 }
1063 if (key == 'd' || key == 'D') 1060 if (key == 'd' || key == 'D')
1064 { 1061 {
1099 { 1096 {
1100 object *tmp; 1097 object *tmp;
1101 char mapname[MAX_BUF]; 1098 char mapname[MAX_BUF];
1102 1099
1103 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);
1104 tmp = get_object (); 1101 tmp = object::create ();
1105 EXIT_PATH (tmp) = mapname; 1102 EXIT_PATH (tmp) = mapname;
1106 EXIT_X (tmp) = op->x; 1103 EXIT_X (tmp) = op->x;
1107 EXIT_Y (tmp) = op->y; 1104 EXIT_Y (tmp) = op->y;
1108 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;
1109 * if the map isn't there, then stay on the 1106 * if the map isn't there, then stay on the
1110 * default initial map */ 1107 * default initial map */
1111 free_object (tmp); 1108 tmp->destroy ();
1112 } 1109 }
1113 else 1110 else
1114 { 1111 {
1115 LOG (llevDebug, "first_map_ext_path not set\n"); 1112 LOG (llevDebug, "first_map_ext_path not set\n");
1116 } 1113 }
1126 { 1123 {
1127 shstr name = op->name; 1124 shstr name = op->name;
1128 int x = op->x, y = op->y; 1125 int x = op->x, y = op->y;
1129 1126
1130 remove_statbonus (op); 1127 remove_statbonus (op);
1131 remove_ob (op); 1128 op->remove ();
1132 op->arch = get_player_archetype (op->arch); 1129 op->arch = get_player_archetype (op->arch);
1133 copy_object (&op->arch->clone, op); 1130 op->arch->clone.copy_to (op);
1134 op->instantiate (); 1131 op->instantiate ();
1135 op->stats = op->contr->orig_stats; 1132 op->stats = op->contr->orig_stats;
1136 op->name = op->name_pl = name; 1133 op->name = op->name_pl = name;
1137 op->x = x; 1134 op->x = x;
1138 op->y = y; 1135 op->y = y;
1426 /* question: don't pick up known-poisonous stuff? */ 1423 /* question: don't pick up known-poisonous stuff? */
1427 if (op->contr->mode & PU_FOOD) 1424 if (op->contr->mode & PU_FOOD)
1428 if (tmp->type == FOOD) 1425 if (tmp->type == FOOD)
1429 { 1426 {
1430 pick_up (op, tmp); 1427 pick_up (op, tmp);
1431 if (0)
1432 fprintf (stderr, "FOOD\n");
1433 continue; 1428 continue;
1434 } 1429 }
1430
1435 if (op->contr->mode & PU_DRINK) 1431 if (op->contr->mode & PU_DRINK)
1436 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)))
1437 { 1433 {
1438 pick_up (op, tmp); 1434 pick_up (op, tmp);
1439 if (0)
1440 fprintf (stderr, "DRINK\n");
1441 continue; 1435 continue;
1442 } 1436 }
1443 1437
1444 if (op->contr->mode & PU_POTION) 1438 if (op->contr->mode & PU_POTION)
1445 if (tmp->type == POTION) 1439 if (tmp->type == POTION)
1446 { 1440 {
1447 pick_up (op, tmp); 1441 pick_up (op, tmp);
1448 if (0)
1449 fprintf (stderr, "POTION\n");
1450 continue; 1442 continue;
1451 } 1443 }
1452 1444
1453 /* spellbooks, skillscrolls and normal books/scrolls */ 1445 /* spellbooks, skillscrolls and normal books/scrolls */
1454 if (op->contr->mode & PU_SPELLBOOK) 1446 if (op->contr->mode & PU_SPELLBOOK)
1455 if (tmp->type == SPELLBOOK) 1447 if (tmp->type == SPELLBOOK)
1456 { 1448 {
1457 pick_up (op, tmp); 1449 pick_up (op, tmp);
1458 if (0)
1459 fprintf (stderr, "SPELLBOOK\n");
1460 continue; 1450 continue;
1461 } 1451 }
1452
1462 if (op->contr->mode & PU_SKILLSCROLL) 1453 if (op->contr->mode & PU_SKILLSCROLL)
1463 if (tmp->type == SKILLSCROLL) 1454 if (tmp->type == SKILLSCROLL)
1464 { 1455 {
1465 pick_up (op, tmp); 1456 pick_up (op, tmp);
1466 if (0)
1467 fprintf (stderr, "SKILLSCROLL\n");
1468 continue; 1457 continue;
1469 } 1458 }
1459
1470 if (op->contr->mode & PU_READABLES) 1460 if (op->contr->mode & PU_READABLES)
1471 if (tmp->type == BOOK || tmp->type == SCROLL) 1461 if (tmp->type == BOOK || tmp->type == SCROLL)
1472 { 1462 {
1473 pick_up (op, tmp); 1463 pick_up (op, tmp);
1474 if (0)
1475 fprintf (stderr, "READABLES\n");
1476 continue; 1464 continue;
1477 } 1465 }
1478 1466
1479 /* wands/staves/rods/horns */ 1467 /* wands/staves/rods/horns */
1480 if (op->contr->mode & PU_MAGIC_DEVICE) 1468 if (op->contr->mode & PU_MAGIC_DEVICE)
1481 if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) 1469 if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN)
1482 { 1470 {
1483 pick_up (op, tmp); 1471 pick_up (op, tmp);
1484 if (0)
1485 fprintf (stderr, "MAGIC_DEVICE\n");
1486 continue; 1472 continue;
1487 } 1473 }
1488 1474
1489 /* pick up all magical items */ 1475 /* pick up all magical items */
1490 if (op->contr->mode & PU_MAGICAL) 1476 if (op->contr->mode & PU_MAGICAL)
1491 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))
1492 { 1478 {
1493 pick_up (op, tmp); 1479 pick_up (op, tmp);
1494 if (0)
1495 fprintf (stderr, "MAGICAL\n");
1496 continue; 1480 continue;
1497 } 1481 }
1498 1482
1499 if (op->contr->mode & PU_VALUABLES) 1483 if (op->contr->mode & PU_VALUABLES)
1500 { 1484 {
1501 if (tmp->type == MONEY || tmp->type == GEM) 1485 if (tmp->type == MONEY || tmp->type == GEM)
1502 { 1486 {
1503 pick_up (op, tmp); 1487 pick_up (op, tmp);
1504 if (0)
1505 fprintf (stderr, "MONEY/GEM\n");
1506 continue; 1488 continue;
1507 } 1489 }
1508 } 1490 }
1509 1491
1510 /* rings & amulets - talismans seems to be typed AMULET */ 1492 /* rings & amulets - talismans seems to be typed AMULET */
1511 if (op->contr->mode & PU_JEWELS) 1493 if (op->contr->mode & PU_JEWELS)
1512 if (tmp->type == RING || tmp->type == AMULET) 1494 if (tmp->type == RING || tmp->type == AMULET)
1513 { 1495 {
1514 pick_up (op, tmp); 1496 pick_up (op, tmp);
1497 continue;
1515 if (0) 1498 }
1516 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);
1517 continue; 1505 continue;
1518 } 1506 }
1519 1507
1520 /* bows and arrows. Bows are good for selling! */ 1508 /* bows and arrows. Bows are good for selling! */
1521 if (op->contr->mode & PU_BOW) 1509 if (op->contr->mode & PU_BOW)
1522 if (tmp->type == BOW) 1510 if (tmp->type == BOW)
1523 { 1511 {
1524 pick_up (op, tmp); 1512 pick_up (op, tmp);
1525 if (0)
1526 fprintf (stderr, "BOW\n");
1527 continue; 1513 continue;
1528 } 1514 }
1515
1529 if (op->contr->mode & PU_ARROW) 1516 if (op->contr->mode & PU_ARROW)
1530 if (tmp->type == ARROW) 1517 if (tmp->type == ARROW)
1531 { 1518 {
1532 pick_up (op, tmp); 1519 pick_up (op, tmp);
1533 if (0)
1534 fprintf (stderr, "ARROW\n");
1535 continue; 1520 continue;
1536 } 1521 }
1537 1522
1538 /* all kinds of armor etc. */ 1523 /* all kinds of armor etc. */
1539 if (op->contr->mode & PU_ARMOUR) 1524 if (op->contr->mode & PU_ARMOUR)
1540 if (tmp->type == ARMOUR) 1525 if (tmp->type == ARMOUR)
1541 { 1526 {
1542 pick_up (op, tmp); 1527 pick_up (op, tmp);
1543 if (0)
1544 fprintf (stderr, "ARMOUR\n");
1545 continue; 1528 continue;
1546 } 1529 }
1530
1547 if (op->contr->mode & PU_HELMET) 1531 if (op->contr->mode & PU_HELMET)
1548 if (tmp->type == HELMET) 1532 if (tmp->type == HELMET)
1549 { 1533 {
1550 pick_up (op, tmp); 1534 pick_up (op, tmp);
1551 if (0)
1552 fprintf (stderr, "HELMET\n");
1553 continue; 1535 continue;
1554 } 1536 }
1537
1555 if (op->contr->mode & PU_SHIELD) 1538 if (op->contr->mode & PU_SHIELD)
1556 if (tmp->type == SHIELD) 1539 if (tmp->type == SHIELD)
1557 { 1540 {
1558 pick_up (op, tmp); 1541 pick_up (op, tmp);
1559 if (0)
1560 fprintf (stderr, "SHIELD\n");
1561 continue; 1542 continue;
1562 } 1543 }
1544
1563 if (op->contr->mode & PU_BOOTS) 1545 if (op->contr->mode & PU_BOOTS)
1564 if (tmp->type == BOOTS) 1546 if (tmp->type == BOOTS)
1565 { 1547 {
1566 pick_up (op, tmp); 1548 pick_up (op, tmp);
1567 if (0)
1568 fprintf (stderr, "BOOTS\n");
1569 continue; 1549 continue;
1570 } 1550 }
1551
1571 if (op->contr->mode & PU_GLOVES) 1552 if (op->contr->mode & PU_GLOVES)
1572 if (tmp->type == GLOVES) 1553 if (tmp->type == GLOVES)
1573 { 1554 {
1574 pick_up (op, tmp); 1555 pick_up (op, tmp);
1575 if (0)
1576 fprintf (stderr, "GLOVES\n");
1577 continue; 1556 continue;
1578 } 1557 }
1558
1579 if (op->contr->mode & PU_CLOAK) 1559 if (op->contr->mode & PU_CLOAK)
1580 if (tmp->type == CLOAK) 1560 if (tmp->type == CLOAK)
1581 { 1561 {
1582 pick_up (op, tmp); 1562 pick_up (op, tmp);
1583 if (0)
1584 fprintf (stderr, "GLOVES\n");
1585 continue; 1563 continue;
1586 } 1564 }
1587 1565
1588 /* hoping to catch throwing daggers here */ 1566 /* hoping to catch throwing daggers here */
1589 if (op->contr->mode & PU_MISSILEWEAPON) 1567 if (op->contr->mode & PU_MISSILEWEAPON)
1590 if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) 1568 if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN))
1591 { 1569 {
1592 pick_up (op, tmp); 1570 pick_up (op, tmp);
1593 if (0)
1594 fprintf (stderr, "MISSILEWEAPON\n");
1595 continue; 1571 continue;
1596 } 1572 }
1597 1573
1598 /* careful: chairs and tables are weapons! */ 1574 /* careful: chairs and tables are weapons! */
1599 if (op->contr->mode & PU_ALLWEAPON) 1575 if (op->contr->mode & PU_ALLWEAPON)
1602 { 1578 {
1603 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 &&
1604 strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL) 1580 strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL)
1605 { 1581 {
1606 pick_up (op, tmp); 1582 pick_up (op, tmp);
1607 if (0)
1608 fprintf (stderr, "WEAPON\n");
1609 continue; 1583 continue;
1610 } 1584 }
1611 } 1585 }
1586
1612 if (tmp->type == WEAPON && tmp->name == NULL) 1587 if (tmp->type == WEAPON && tmp->name == NULL)
1613 { 1588 {
1614 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)
1615 { 1590 {
1616 pick_up (op, tmp); 1591 pick_up (op, tmp);
1617 if (0)
1618 fprintf (stderr, "WEAPON\n");
1619 continue; 1592 continue;
1620 } 1593 }
1621 } 1594 }
1622 } 1595 }
1623 1596
1624 /* misc stuff that's useful */ 1597 /* misc stuff that's useful */
1625 if (op->contr->mode & PU_KEY) 1598 if (op->contr->mode & PU_KEY)
1626 if (tmp->type == KEY || tmp->type == SPECIAL_KEY) 1599 if (tmp->type == KEY || tmp->type == SPECIAL_KEY)
1627 { 1600 {
1628 pick_up (op, tmp); 1601 pick_up (op, tmp);
1629 if (0)
1630 fprintf (stderr, "KEY\n");
1631 continue; 1602 continue;
1632 } 1603 }
1633 1604
1634 /* 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
1635 * pickups */ 1606 * pickups */
1657 continue; 1628 continue;
1658 } 1629 }
1659 } 1630 }
1660 } /* the new pickup model */ 1631 } /* the new pickup model */
1661 } 1632 }
1633
1662 return !stop; 1634 return !stop;
1663} 1635}
1664 1636
1665/* 1637/*
1666 * Find an arrow in the inventory and after that 1638 * Find an arrow in the inventory and after that
1900 } 1872 }
1901 1873
1902 /* this should not happen, but sometimes does */ 1874 /* this should not happen, but sometimes does */
1903 if (arrow->nrof == 0) 1875 if (arrow->nrof == 0)
1904 { 1876 {
1905 remove_ob (arrow); 1877 arrow->destroy ();
1906 free_object (arrow);
1907 return 0; 1878 return 0;
1908 } 1879 }
1909 1880
1910 left = arrow; /* these are arrows left to the player */ 1881 left = arrow; /* these are arrows left to the player */
1911 arrow = get_split_ob (arrow, 1); 1882 arrow = get_split_ob (arrow, 1);
1912 if (arrow == NULL) 1883 if (arrow == NULL)
1913 { 1884 {
1914 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);
1915 return 0; 1886 return 0;
1916 } 1887 }
1917 set_owner (arrow, op); 1888 arrow->set_owner (op);
1918 arrow->skill = bow->skill; 1889 arrow->skill = bow->skill;
1919 1890
1920 arrow->direction = dir; 1891 arrow->direction = dir;
1921 arrow->x = sx; 1892 arrow->x = sx;
1922 arrow->y = sy; 1893 arrow->y = sy;
2130 case range_misc: 2101 case range_misc:
2131 fire_misc_object (op, dir); 2102 fire_misc_object (op, dir);
2132 return; 2103 return;
2133 2104
2134 case range_golem: /* Control summoned monsters from scrolls */ 2105 case range_golem: /* Control summoned monsters from scrolls */
2135 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))
2136 { 2107 {
2137 op->contr->ranges[range_golem] = NULL; 2108 op->contr->ranges[range_golem] = 0;
2138 op->contr->shoottype = range_none; 2109 op->contr->shoottype = range_none;
2139 op->contr->golem_count = 0;
2140 } 2110 }
2141 else 2111 else
2142 control_golem (op->contr->ranges[range_golem], dir); 2112 control_golem (op->contr->ranges[range_golem], dir);
2143 return; 2113 return;
2144 2114
2390 * player owns it and it is either friendly or unagressive. 2360 * player owns it and it is either friendly or unagressive.
2391 */ 2361 */
2392 if ((op->type == PLAYER) 2362 if ((op->type == PLAYER)
2393#if COZY_SERVER 2363#if COZY_SERVER
2394 && 2364 &&
2395 ((get_owner (mon) && get_owner (mon)->contr 2365 ((mon->owner && mon->owner->contr
2396 && 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)
2397#else 2367#else
2398 && get_owner (mon) == op 2368 && mon->owner == op
2399#endif 2369#endif
2400 && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) 2370 && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)))
2401 { 2371 {
2402 /* 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 */
2403 if (op->contr->braced) 2373 if (op->contr->braced)
2590 /* 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
2591 * 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
2592 * 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
2593 * 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.
2594 */ 2564 */
2595 if (op->contr->ranges[range_golem] &&
2596 ((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))
2597 {
2598 op->contr->ranges[range_golem] = NULL; 2566 op->contr->ranges[range_golem] = 0;
2599 op->contr->golem_count = 0;
2600 }
2601 2567
2602 /* 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
2603 * the players time has been increased when doericserver has been 2569 * the players time has been increased when doericserver has been
2604 * called, so we recheck it here. 2570 * called, so we recheck it here.
2605 */ 2571 */
2636 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 2602 for (tmp = op->inv; tmp != NULL; tmp = tmp->below)
2637 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) 2603 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE))
2638 { 2604 {
2639 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);
2640 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
2641 if (op->contr) 2608 if (op->contr)
2642 esrv_del_item (op->contr, tmp->count); 2609 esrv_del_item (op->contr, tmp->count);
2643 remove_ob (tmp); 2610
2644 free_object (tmp); 2611 tmp->destroy ();
2645 CLEAR_FLAG (op, FLAG_LIFESAVE); 2612 CLEAR_FLAG (op, FLAG_LIFESAVE);
2613
2646 if (op->stats.hp < 0) 2614 if (op->stats.hp < 0)
2647 op->stats.hp = op->stats.maxhp; 2615 op->stats.hp = op->stats.maxhp;
2616
2648 if (op->stats.food < 0) 2617 if (op->stats.food < 0)
2649 op->stats.food = 999; 2618 op->stats.food = 999;
2619
2650 fix_player (op); 2620 fix_player (op);
2651 return 1; 2621 return 1;
2652 } 2622 }
2653 LOG (llevError, "Error: LIFESAVE set without applied object.\n"); 2623 LOG (llevError, "Error: LIFESAVE set without applied object.\n");
2654 CLEAR_FLAG (op, FLAG_LIFESAVE); 2624 CLEAR_FLAG (op, FLAG_LIFESAVE);
2671 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
2672 * we remove object 'op' 2642 * we remove object 'op'
2673 */ 2643 */
2674 if (QUERY_FLAG (op, FLAG_UNPAID)) 2644 if (QUERY_FLAG (op, FLAG_UNPAID))
2675 { 2645 {
2676 remove_ob (op); 2646 op->remove ();
2677 op->x = env->x; 2647 op->x = env->x;
2678 op->y = env->y; 2648 op->y = env->y;
2679 if (env->type == PLAYER) 2649 if (env->type == PLAYER)
2680 esrv_del_item (env->contr, op->count); 2650 esrv_del_item (env->contr, op->count);
2681 insert_ob_in_map (op, env->map, NULL, 0); 2651 insert_ob_in_map (op, env->map, NULL, 0);
2978 /* restore player */ 2948 /* restore player */
2979 at = archetype::find ("poisoning"); 2949 at = archetype::find ("poisoning");
2980 tmp = present_arch_in_ob (at, op); 2950 tmp = present_arch_in_ob (at, op);
2981 if (tmp) 2951 if (tmp)
2982 { 2952 {
2983 remove_ob (tmp); 2953 tmp->destroy ();
2984 free_object (tmp);
2985 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); 2954 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed");
2986 } 2955 }
2987 2956
2988 at = archetype::find ("confusion"); 2957 at = archetype::find ("confusion");
2989 tmp = present_arch_in_ob (at, op); 2958 tmp = present_arch_in_ob (at, op);
2990 if (tmp) 2959 if (tmp)
2991 { 2960 {
2992 remove_ob (tmp); 2961 tmp->destroy ();
2993 free_object (tmp);
2994 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); 2962 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer");
2995 } 2963 }
2996 2964
2997 cure_disease (op, 0); /* remove any disease */ 2965 cure_disease (op, 0); /* remove any disease */
2998 op->stats.hp = op->stats.maxhp; 2966 op->stats.hp = op->stats.maxhp;
3175 /* determine_god() seems to not work sometimes... why is this? 3143 /* determine_god() seems to not work sometimes... why is this?
3176 Should I be using something else? GD */ 3144 Should I be using something else? GD */
3177 const char *god = determine_god (op); 3145 const char *god = determine_god (op);
3178 3146
3179 if (god && (strcmp (god, "none"))) 3147 if (god && (strcmp (god, "none")))
3180 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);
3181 else 3149 else
3182 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.");
3183 } 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.");
3184#endif 3154#endif
3185 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely.");
3186 3155
3187 /* Put a gravestone up where the character 'almost' died. List the 3156 /* Put a gravestone up where the character 'almost' died. List the
3188 * exp loss on the stone. 3157 * exp loss on the stone.
3189 */ 3158 */
3190 tmp = arch_to_object (archetype::find ("gravestone")); 3159 tmp = arch_to_object (archetype::find ("gravestone"));
3195 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);
3196 tmp->msg = buf; 3165 tmp->msg = buf;
3197 tmp->x = op->x, tmp->y = op->y; 3166 tmp->x = op->x, tmp->y = op->y;
3198 insert_ob_in_map (tmp, op->map, NULL, 0); 3167 insert_ob_in_map (tmp, op->map, NULL, 0);
3199 3168
3200 /**************************************/ 3169 /**************************************/
3201 /* */ 3170 /* */
3202 /* Subtract the experience points, */ 3171 /* Subtract the experience points, */
3203 /* if we died cause of food, give us */ 3172 /* if we died cause of food, give us */
3204 /* food, and reset HP's... */ 3173 /* food, and reset HP's... */
3205 /* */ 3174 /* */
3206
3207 /**************************************/ 3175 /**************************************/
3208 3176
3209 /* remove any poisoning and confusion the character may be suffering. */ 3177 /* remove any poisoning and confusion the character may be suffering. */
3210 /* restore player */ 3178 /* restore player */
3211 at = archetype::find ("poisoning"); 3179 at = archetype::find ("poisoning");
3212 tmp = present_arch_in_ob (at, op); 3180 tmp = present_arch_in_ob (at, op);
3181
3213 if (tmp) 3182 if (tmp)
3214 { 3183 {
3215 remove_ob (tmp); 3184 tmp->destroy ();
3216 free_object (tmp);
3217 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); 3185 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed");
3218 } 3186 }
3219 3187
3220 at = archetype::find ("confusion"); 3188 at = archetype::find ("confusion");
3221 tmp = present_arch_in_ob (at, op); 3189 tmp = present_arch_in_ob (at, op);
3222 if (tmp) 3190 if (tmp)
3223 { 3191 {
3224 remove_ob (tmp); 3192 tmp->destroy ();
3225 free_object (tmp);
3226 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); 3193 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer");
3227 } 3194 }
3195
3228 cure_disease (op, 0); /* remove any disease */ 3196 cure_disease (op, 0); /* remove any disease */
3229 3197
3230 /*add_exp(op, (op->stats.exp * -0.20)); */ 3198 /*add_exp(op, (op->stats.exp * -0.20)); */
3231 apply_death_exp_penalty (op); 3199 apply_death_exp_penalty (op);
3232 if (op->stats.food < 100) 3200 if (op->stats.food < 100)
3242 */ 3210 */
3243 3211
3244 if (is_in_shop (op)) 3212 if (is_in_shop (op))
3245 remove_unpaid_objects (op->inv, op); 3213 remove_unpaid_objects (op->inv, op);
3246 3214
3247 /****************************************/ 3215 /****************************************/
3248 /* */ 3216 /* */
3249 /* Move player to his current respawn- */ 3217 /* Move player to his current respawn- */
3250 /* position (usually last savebed) */ 3218 /* position (usually last savebed) */
3251 /* */ 3219 /* */
3252
3253 /****************************************/ 3220 /****************************************/
3254 3221
3255 enter_player_savebed (op); 3222 enter_player_savebed (op);
3256 3223
3257 /* Save the player before inserting the force to reduce 3224 /* Save the player before inserting the force to reduce
3258 * chance of abuse. 3225 * chance of abuse.
3265 * spell effects. So first see if there is a spell effect 3232 * spell effects. So first see if there is a spell effect
3266 * on the space that might harm the player. 3233 * on the space that might harm the player.
3267 */ 3234 */
3268 will_kill_again = 0; 3235 will_kill_again = 0;
3269 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)
3270 {
3271 if (tmp->type == SPELL_EFFECT) 3237 if (tmp->type == SPELL_EFFECT)
3272 will_kill_again |= tmp->attacktype; 3238 will_kill_again |= tmp->attacktype;
3273 } 3239
3274 if (will_kill_again) 3240 if (will_kill_again)
3275 { 3241 {
3276 object *force; 3242 object *force;
3277 int at; 3243 int at;
3278 3244
3280 /* 50 ticks should be enough time for the spell to abate */ 3246 /* 50 ticks should be enough time for the spell to abate */
3281 force->speed = 0.1; 3247 force->speed = 0.1;
3282 force->speed_left = -5.0; 3248 force->speed_left = -5.0;
3283 SET_FLAG (force, FLAG_APPLIED); 3249 SET_FLAG (force, FLAG_APPLIED);
3284 for (at = 0; at < NROFATTACKS; at++) 3250 for (at = 0; at < NROFATTACKS; at++)
3285 {
3286 if (will_kill_again & (1 << at)) 3251 if (will_kill_again & (1 << at))
3287 force->resist[at] = 100; 3252 force->resist[at] = 100;
3288 } 3253
3289 insert_ob_in_ob (force, op); 3254 insert_ob_in_ob (force, op);
3290 fix_player (op); 3255 fix_player (op);
3291 3256
3292 } 3257 }
3293 3258
3303 op->contr->party = NULL; 3268 op->contr->party = NULL;
3304 if (settings.set_title == TRUE) 3269 if (settings.set_title == TRUE)
3305 op->contr->own_title[0] = '\0'; 3270 op->contr->own_title[0] = '\0';
3306 new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf); 3271 new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf);
3307 check_score (op); 3272 check_score (op);
3273
3308 if (op->contr->ranges[range_golem] != NULL) 3274 if (op->contr->ranges[range_golem])
3309 { 3275 {
3310 remove_friendly_object (op->contr->ranges[range_golem]); 3276 remove_friendly_object (op->contr->ranges[range_golem]);
3311 remove_ob (op->contr->ranges[range_golem]); 3277 op->contr->ranges[range_golem]->destroy ();
3312 free_object (op->contr->ranges[range_golem]);
3313 op->contr->ranges[range_golem] = NULL; 3278 op->contr->ranges[range_golem] = 0;
3314 op->contr->golem_count = 0;
3315 } 3279 }
3280
3316 loot_object (op); /* Remove some of the items for good */ 3281 loot_object (op); /* Remove some of the items for good */
3317 remove_ob (op); 3282 op->remove ();
3318 op->direction = 0; 3283 op->direction = 0;
3319 3284
3320 if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp) 3285 if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp)
3321 { 3286 {
3322 delete_character (op->name, 0); 3287 delete_character (op->name, 0);
3375 for (tmp = op->inv; tmp != NULL; tmp = next) 3340 for (tmp = op->inv; tmp != NULL; tmp = next)
3376 { 3341 {
3377 next = tmp->below; 3342 next = tmp->below;
3378 if (tmp->type == EXPERIENCE || tmp->invisible) 3343 if (tmp->type == EXPERIENCE || tmp->invisible)
3379 continue; 3344 continue;
3380 remove_ob (tmp); 3345 tmp->remove ();
3381 tmp->x = op->x, tmp->y = op->y; 3346 tmp->x = op->x, tmp->y = op->y;
3382 if (tmp->type == CONTAINER) 3347 if (tmp->type == CONTAINER)
3383 { /* empty container to ground */ 3348 { /* empty container to ground */
3384 loot_object (tmp); 3349 loot_object (tmp);
3385 } 3350 }
3386 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)))
3387 { 3352 {
3388 if (tmp->nrof > 1) 3353 if (tmp->nrof > 1)
3389 { 3354 {
3390 tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); 3355 tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1));
3391 free_object (tmp2); 3356 tmp2->destroy ();
3392 insert_ob_in_map (tmp, op->map, NULL, 0); 3357 insert_ob_in_map (tmp, op->map, NULL, 0);
3393 } 3358 }
3394 else 3359 else
3395 free_object (tmp); 3360 tmp->destroy ();
3396 } 3361 }
3397 else 3362 else
3398 insert_ob_in_map (tmp, op->map, NULL, 0); 3363 insert_ob_in_map (tmp, op->map, NULL, 0);
3399 } 3364 }
3400} 3365}
3465 if (op->type == PLAYER) 3430 if (op->type == PLAYER)
3466 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);
3467 3432
3468 cast_spell (op, throw_ob, dir, spob, NULL); 3433 cast_spell (op, throw_ob, dir, spob, NULL);
3469 3434
3470 if (!QUERY_FLAG (throw_ob, FLAG_REMOVED)) 3435 throw_ob->destroy ();
3471 remove_ob (throw_ob);
3472 free_object (throw_ob);
3473} 3436}
3474 3437
3475void 3438void
3476make_visible (object *op) 3439make_visible (object *op)
3477{ 3440{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines