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.28 by root, Mon Nov 13 20:57:16 2006 UTC vs.
Revision 1.37 by root, Thu Dec 14 02:37:37 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>
322 * All we can really get in this is some settings like host and display 320 * All we can really get in this is some settings like host and display
323 * mode. 321 * mode.
324 */ 322 */
325 323
326int 324int
327add_player (NewSocket * ns) 325add_player (client_socket * ns)
328{ 326{
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;
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 {
1065 char buf[MAX_BUF]; 1062 char buf[MAX_BUF];
1066 1063
1067 /* this must before then initial items are given */ 1064 /* this must before then initial items are given */
1068 esrv_new_player (op->contr, op->weight + op->carrying); 1065 esrv_new_player (op->contr, op->weight + op->carrying);
1066
1069 create_treasure (find_treasurelist ("starting_wealth"), op, 0, 0, 0); 1067 treasurelist *tl = find_treasurelist ("starting_wealth");
1068 if (tl)
1069 create_treasure (tl, op, 0, 0, 0);
1070 1070
1071 INVOKE_PLAYER (BIRTH, op->contr); 1071 INVOKE_PLAYER (BIRTH, op->contr);
1072 INVOKE_PLAYER (LOGIN, op->contr); 1072 INVOKE_PLAYER (LOGIN, op->contr);
1073 1073
1074 op->contr->state = ST_PLAYING; 1074 op->contr->state = ST_PLAYING;
1099 { 1099 {
1100 object *tmp; 1100 object *tmp;
1101 char mapname[MAX_BUF]; 1101 char mapname[MAX_BUF];
1102 1102
1103 snprintf (mapname, MAX_BUF - 1, "%s/%s", first_map_ext_path, &op->arch->name); 1103 snprintf (mapname, MAX_BUF - 1, "%s/%s", first_map_ext_path, &op->arch->name);
1104 tmp = get_object (); 1104 tmp = object::create ();
1105 EXIT_PATH (tmp) = mapname; 1105 EXIT_PATH (tmp) = mapname;
1106 EXIT_X (tmp) = op->x; 1106 EXIT_X (tmp) = op->x;
1107 EXIT_Y (tmp) = op->y; 1107 EXIT_Y (tmp) = op->y;
1108 enter_exit (op, tmp); /* we don't really care if it succeeded; 1108 enter_exit (op, tmp); /* we don't really care if it succeeded;
1109 * if the map isn't there, then stay on the 1109 * if the map isn't there, then stay on the
1110 * default initial map */ 1110 * default initial map */
1111 free_object (tmp); 1111 tmp->destroy ();
1112 } 1112 }
1113 else 1113 else
1114 { 1114 {
1115 LOG (llevDebug, "first_map_ext_path not set\n"); 1115 LOG (llevDebug, "first_map_ext_path not set\n");
1116 } 1116 }
1126 { 1126 {
1127 shstr name = op->name; 1127 shstr name = op->name;
1128 int x = op->x, y = op->y; 1128 int x = op->x, y = op->y;
1129 1129
1130 remove_statbonus (op); 1130 remove_statbonus (op);
1131 remove_ob (op); 1131 op->remove ();
1132 op->arch = get_player_archetype (op->arch); 1132 op->arch = get_player_archetype (op->arch);
1133 copy_object (&op->arch->clone, op); 1133 op->arch->clone.copy_to (op);
1134 op->instantiate (); 1134 op->instantiate ();
1135 op->stats = op->contr->orig_stats; 1135 op->stats = op->contr->orig_stats;
1136 op->name = op->name_pl = name; 1136 op->name = op->name_pl = name;
1137 op->x = x; 1137 op->x = x;
1138 op->y = y; 1138 op->y = y;
1426 /* question: don't pick up known-poisonous stuff? */ 1426 /* question: don't pick up known-poisonous stuff? */
1427 if (op->contr->mode & PU_FOOD) 1427 if (op->contr->mode & PU_FOOD)
1428 if (tmp->type == FOOD) 1428 if (tmp->type == FOOD)
1429 { 1429 {
1430 pick_up (op, tmp); 1430 pick_up (op, tmp);
1431 if (0)
1432 fprintf (stderr, "FOOD\n");
1433 continue; 1431 continue;
1434 } 1432 }
1433
1435 if (op->contr->mode & PU_DRINK) 1434 if (op->contr->mode & PU_DRINK)
1436 if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))) 1435 if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)))
1437 { 1436 {
1438 pick_up (op, tmp); 1437 pick_up (op, tmp);
1439 if (0)
1440 fprintf (stderr, "DRINK\n");
1441 continue; 1438 continue;
1442 } 1439 }
1443 1440
1444 if (op->contr->mode & PU_POTION) 1441 if (op->contr->mode & PU_POTION)
1445 if (tmp->type == POTION) 1442 if (tmp->type == POTION)
1446 { 1443 {
1447 pick_up (op, tmp); 1444 pick_up (op, tmp);
1448 if (0)
1449 fprintf (stderr, "POTION\n");
1450 continue; 1445 continue;
1451 } 1446 }
1452 1447
1453 /* spellbooks, skillscrolls and normal books/scrolls */ 1448 /* spellbooks, skillscrolls and normal books/scrolls */
1454 if (op->contr->mode & PU_SPELLBOOK) 1449 if (op->contr->mode & PU_SPELLBOOK)
1455 if (tmp->type == SPELLBOOK) 1450 if (tmp->type == SPELLBOOK)
1456 { 1451 {
1457 pick_up (op, tmp); 1452 pick_up (op, tmp);
1458 if (0)
1459 fprintf (stderr, "SPELLBOOK\n");
1460 continue; 1453 continue;
1461 } 1454 }
1455
1462 if (op->contr->mode & PU_SKILLSCROLL) 1456 if (op->contr->mode & PU_SKILLSCROLL)
1463 if (tmp->type == SKILLSCROLL) 1457 if (tmp->type == SKILLSCROLL)
1464 { 1458 {
1465 pick_up (op, tmp); 1459 pick_up (op, tmp);
1466 if (0)
1467 fprintf (stderr, "SKILLSCROLL\n");
1468 continue; 1460 continue;
1469 } 1461 }
1462
1470 if (op->contr->mode & PU_READABLES) 1463 if (op->contr->mode & PU_READABLES)
1471 if (tmp->type == BOOK || tmp->type == SCROLL) 1464 if (tmp->type == BOOK || tmp->type == SCROLL)
1472 { 1465 {
1473 pick_up (op, tmp); 1466 pick_up (op, tmp);
1474 if (0)
1475 fprintf (stderr, "READABLES\n");
1476 continue; 1467 continue;
1477 } 1468 }
1478 1469
1479 /* wands/staves/rods/horns */ 1470 /* wands/staves/rods/horns */
1480 if (op->contr->mode & PU_MAGIC_DEVICE) 1471 if (op->contr->mode & PU_MAGIC_DEVICE)
1481 if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) 1472 if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN)
1482 { 1473 {
1483 pick_up (op, tmp); 1474 pick_up (op, tmp);
1484 if (0)
1485 fprintf (stderr, "MAGIC_DEVICE\n");
1486 continue; 1475 continue;
1487 } 1476 }
1488 1477
1489 /* pick up all magical items */ 1478 /* pick up all magical items */
1490 if (op->contr->mode & PU_MAGICAL) 1479 if (op->contr->mode & PU_MAGICAL)
1491 if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) 1480 if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))
1492 { 1481 {
1493 pick_up (op, tmp); 1482 pick_up (op, tmp);
1494 if (0)
1495 fprintf (stderr, "MAGICAL\n");
1496 continue; 1483 continue;
1497 } 1484 }
1498 1485
1499 if (op->contr->mode & PU_VALUABLES) 1486 if (op->contr->mode & PU_VALUABLES)
1500 { 1487 {
1501 if (tmp->type == MONEY || tmp->type == GEM) 1488 if (tmp->type == MONEY || tmp->type == GEM)
1502 { 1489 {
1503 pick_up (op, tmp); 1490 pick_up (op, tmp);
1504 if (0)
1505 fprintf (stderr, "MONEY/GEM\n");
1506 continue; 1491 continue;
1507 } 1492 }
1508 } 1493 }
1509 1494
1510 /* rings & amulets - talismans seems to be typed AMULET */ 1495 /* rings & amulets - talismans seems to be typed AMULET */
1511 if (op->contr->mode & PU_JEWELS) 1496 if (op->contr->mode & PU_JEWELS)
1512 if (tmp->type == RING || tmp->type == AMULET) 1497 if (tmp->type == RING || tmp->type == AMULET)
1513 { 1498 {
1514 pick_up (op, tmp); 1499 pick_up (op, tmp);
1500 continue;
1515 if (0) 1501 }
1516 fprintf (stderr, "JEWELS\n"); 1502
1503 /* we don't forget dragon food */
1504 if (op->contr->mode & PU_FLESH)
1505 if (tmp->type == FLESH)
1506 {
1507 pick_up (op, tmp);
1517 continue; 1508 continue;
1518 } 1509 }
1519 1510
1520 /* bows and arrows. Bows are good for selling! */ 1511 /* bows and arrows. Bows are good for selling! */
1521 if (op->contr->mode & PU_BOW) 1512 if (op->contr->mode & PU_BOW)
1522 if (tmp->type == BOW) 1513 if (tmp->type == BOW)
1523 { 1514 {
1524 pick_up (op, tmp); 1515 pick_up (op, tmp);
1525 if (0)
1526 fprintf (stderr, "BOW\n");
1527 continue; 1516 continue;
1528 } 1517 }
1518
1529 if (op->contr->mode & PU_ARROW) 1519 if (op->contr->mode & PU_ARROW)
1530 if (tmp->type == ARROW) 1520 if (tmp->type == ARROW)
1531 { 1521 {
1532 pick_up (op, tmp); 1522 pick_up (op, tmp);
1533 if (0)
1534 fprintf (stderr, "ARROW\n");
1535 continue; 1523 continue;
1536 } 1524 }
1537 1525
1538 /* all kinds of armor etc. */ 1526 /* all kinds of armor etc. */
1539 if (op->contr->mode & PU_ARMOUR) 1527 if (op->contr->mode & PU_ARMOUR)
1540 if (tmp->type == ARMOUR) 1528 if (tmp->type == ARMOUR)
1541 { 1529 {
1542 pick_up (op, tmp); 1530 pick_up (op, tmp);
1543 if (0)
1544 fprintf (stderr, "ARMOUR\n");
1545 continue; 1531 continue;
1546 } 1532 }
1533
1547 if (op->contr->mode & PU_HELMET) 1534 if (op->contr->mode & PU_HELMET)
1548 if (tmp->type == HELMET) 1535 if (tmp->type == HELMET)
1549 { 1536 {
1550 pick_up (op, tmp); 1537 pick_up (op, tmp);
1551 if (0)
1552 fprintf (stderr, "HELMET\n");
1553 continue; 1538 continue;
1554 } 1539 }
1540
1555 if (op->contr->mode & PU_SHIELD) 1541 if (op->contr->mode & PU_SHIELD)
1556 if (tmp->type == SHIELD) 1542 if (tmp->type == SHIELD)
1557 { 1543 {
1558 pick_up (op, tmp); 1544 pick_up (op, tmp);
1559 if (0)
1560 fprintf (stderr, "SHIELD\n");
1561 continue; 1545 continue;
1562 } 1546 }
1547
1563 if (op->contr->mode & PU_BOOTS) 1548 if (op->contr->mode & PU_BOOTS)
1564 if (tmp->type == BOOTS) 1549 if (tmp->type == BOOTS)
1565 { 1550 {
1566 pick_up (op, tmp); 1551 pick_up (op, tmp);
1567 if (0)
1568 fprintf (stderr, "BOOTS\n");
1569 continue; 1552 continue;
1570 } 1553 }
1554
1571 if (op->contr->mode & PU_GLOVES) 1555 if (op->contr->mode & PU_GLOVES)
1572 if (tmp->type == GLOVES) 1556 if (tmp->type == GLOVES)
1573 { 1557 {
1574 pick_up (op, tmp); 1558 pick_up (op, tmp);
1575 if (0)
1576 fprintf (stderr, "GLOVES\n");
1577 continue; 1559 continue;
1578 } 1560 }
1561
1579 if (op->contr->mode & PU_CLOAK) 1562 if (op->contr->mode & PU_CLOAK)
1580 if (tmp->type == CLOAK) 1563 if (tmp->type == CLOAK)
1581 { 1564 {
1582 pick_up (op, tmp); 1565 pick_up (op, tmp);
1583 if (0)
1584 fprintf (stderr, "GLOVES\n");
1585 continue; 1566 continue;
1586 } 1567 }
1587 1568
1588 /* hoping to catch throwing daggers here */ 1569 /* hoping to catch throwing daggers here */
1589 if (op->contr->mode & PU_MISSILEWEAPON) 1570 if (op->contr->mode & PU_MISSILEWEAPON)
1590 if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) 1571 if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN))
1591 { 1572 {
1592 pick_up (op, tmp); 1573 pick_up (op, tmp);
1593 if (0)
1594 fprintf (stderr, "MISSILEWEAPON\n");
1595 continue; 1574 continue;
1596 } 1575 }
1597 1576
1598 /* careful: chairs and tables are weapons! */ 1577 /* careful: chairs and tables are weapons! */
1599 if (op->contr->mode & PU_ALLWEAPON) 1578 if (op->contr->mode & PU_ALLWEAPON)
1602 { 1581 {
1603 if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->name, "table") == NULL && 1582 if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->name, "table") == NULL &&
1604 strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL) 1583 strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL)
1605 { 1584 {
1606 pick_up (op, tmp); 1585 pick_up (op, tmp);
1607 if (0)
1608 fprintf (stderr, "WEAPON\n");
1609 continue; 1586 continue;
1610 } 1587 }
1611 } 1588 }
1589
1612 if (tmp->type == WEAPON && tmp->name == NULL) 1590 if (tmp->type == WEAPON && tmp->name == NULL)
1613 { 1591 {
1614 if (strstr (tmp->arch->name, "table") == NULL && strstr (tmp->arch->name, "chair") == NULL) 1592 if (strstr (tmp->arch->name, "table") == NULL && strstr (tmp->arch->name, "chair") == NULL)
1615 { 1593 {
1616 pick_up (op, tmp); 1594 pick_up (op, tmp);
1617 if (0)
1618 fprintf (stderr, "WEAPON\n");
1619 continue; 1595 continue;
1620 } 1596 }
1621 } 1597 }
1622 } 1598 }
1623 1599
1624 /* misc stuff that's useful */ 1600 /* misc stuff that's useful */
1625 if (op->contr->mode & PU_KEY) 1601 if (op->contr->mode & PU_KEY)
1626 if (tmp->type == KEY || tmp->type == SPECIAL_KEY) 1602 if (tmp->type == KEY || tmp->type == SPECIAL_KEY)
1627 { 1603 {
1628 pick_up (op, tmp); 1604 pick_up (op, tmp);
1629 if (0)
1630 fprintf (stderr, "KEY\n");
1631 continue; 1605 continue;
1632 } 1606 }
1633 1607
1634 /* any of the last 4 bits set means we use the ratio for value 1608 /* any of the last 4 bits set means we use the ratio for value
1635 * pickups */ 1609 * pickups */
1657 continue; 1631 continue;
1658 } 1632 }
1659 } 1633 }
1660 } /* the new pickup model */ 1634 } /* the new pickup model */
1661 } 1635 }
1636
1662 return !stop; 1637 return !stop;
1663} 1638}
1664 1639
1665/* 1640/*
1666 * Find an arrow in the inventory and after that 1641 * Find an arrow in the inventory and after that
1900 } 1875 }
1901 1876
1902 /* this should not happen, but sometimes does */ 1877 /* this should not happen, but sometimes does */
1903 if (arrow->nrof == 0) 1878 if (arrow->nrof == 0)
1904 { 1879 {
1905 remove_ob (arrow); 1880 arrow->destroy ();
1906 free_object (arrow);
1907 return 0; 1881 return 0;
1908 } 1882 }
1909 1883
1910 left = arrow; /* these are arrows left to the player */ 1884 left = arrow; /* these are arrows left to the player */
1911 arrow = get_split_ob (arrow, 1); 1885 arrow = get_split_ob (arrow, 1);
1912 if (arrow == NULL) 1886 if (arrow == NULL)
1913 { 1887 {
1914 new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); 1888 new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race);
1915 return 0; 1889 return 0;
1916 } 1890 }
1917 set_owner (arrow, op); 1891 arrow->set_owner (op);
1918 arrow->skill = bow->skill; 1892 arrow->skill = bow->skill;
1919 1893
1920 arrow->direction = dir; 1894 arrow->direction = dir;
1921 arrow->x = sx; 1895 arrow->x = sx;
1922 arrow->y = sy; 1896 arrow->y = sy;
2130 case range_misc: 2104 case range_misc:
2131 fire_misc_object (op, dir); 2105 fire_misc_object (op, dir);
2132 return; 2106 return;
2133 2107
2134 case range_golem: /* Control summoned monsters from scrolls */ 2108 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) 2109 if (QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED))
2136 { 2110 {
2137 op->contr->ranges[range_golem] = NULL; 2111 op->contr->ranges[range_golem] = 0;
2138 op->contr->shoottype = range_none; 2112 op->contr->shoottype = range_none;
2139 op->contr->golem_count = 0;
2140 } 2113 }
2141 else 2114 else
2142 control_golem (op->contr->ranges[range_golem], dir); 2115 control_golem (op->contr->ranges[range_golem], dir);
2143 return; 2116 return;
2144 2117
2390 * player owns it and it is either friendly or unagressive. 2363 * player owns it and it is either friendly or unagressive.
2391 */ 2364 */
2392 if ((op->type == PLAYER) 2365 if ((op->type == PLAYER)
2393#if COZY_SERVER 2366#if COZY_SERVER
2394 && 2367 &&
2395 ((get_owner (mon) && get_owner (mon)->contr 2368 ((mon->owner && mon->owner->contr
2396 && same_party (get_owner (mon)->contr->party, op->contr->party)) || get_owner (mon) == op) 2369 && same_party (mon->owner->contr->party, op->contr->party)) || mon->owner == op)
2397#else 2370#else
2398 && get_owner (mon) == op 2371 && mon->owner == op
2399#endif 2372#endif
2400 && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) 2373 && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)))
2401 { 2374 {
2402 /* If we're braced, we don't want to switch places with it */ 2375 /* If we're braced, we don't want to switch places with it */
2403 if (op->contr->braced) 2376 if (op->contr->braced)
2590 /* I've been seeing crashes where the golem has been destroyed, but 2563 /* 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 2564 * 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 2565 * 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. 2566 * put this in a a workaround to clean up the golem pointer.
2594 */ 2567 */
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))) 2568 if (op->contr->ranges[range_golem] && QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED))
2597 {
2598 op->contr->ranges[range_golem] = NULL; 2569 op->contr->ranges[range_golem] = 0;
2599 op->contr->golem_count = 0;
2600 }
2601 2570
2602 /* call this here - we also will call this in do_ericserver, but 2571 /* call this here - we also will call this in do_ericserver, but
2603 * the players time has been increased when doericserver has been 2572 * the players time has been increased when doericserver has been
2604 * called, so we recheck it here. 2573 * called, so we recheck it here.
2605 */ 2574 */
2636 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 2605 for (tmp = op->inv; tmp != NULL; tmp = tmp->below)
2637 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) 2606 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE))
2638 { 2607 {
2639 play_sound_map (op->map, op->x, op->y, SOUND_OB_EVAPORATE); 2608 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)); 2609 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp));
2610
2641 if (op->contr) 2611 if (op->contr)
2642 esrv_del_item (op->contr, tmp->count); 2612 esrv_del_item (op->contr, tmp->count);
2643 remove_ob (tmp); 2613
2644 free_object (tmp); 2614 tmp->destroy ();
2645 CLEAR_FLAG (op, FLAG_LIFESAVE); 2615 CLEAR_FLAG (op, FLAG_LIFESAVE);
2616
2646 if (op->stats.hp < 0) 2617 if (op->stats.hp < 0)
2647 op->stats.hp = op->stats.maxhp; 2618 op->stats.hp = op->stats.maxhp;
2619
2648 if (op->stats.food < 0) 2620 if (op->stats.food < 0)
2649 op->stats.food = 999; 2621 op->stats.food = 999;
2622
2650 fix_player (op); 2623 fix_player (op);
2651 return 1; 2624 return 1;
2652 } 2625 }
2653 LOG (llevError, "Error: LIFESAVE set without applied object.\n"); 2626 LOG (llevError, "Error: LIFESAVE set without applied object.\n");
2654 CLEAR_FLAG (op, FLAG_LIFESAVE); 2627 CLEAR_FLAG (op, FLAG_LIFESAVE);
2671 next = op->below; /* Make sure we have a good value, in case 2644 next = op->below; /* Make sure we have a good value, in case
2672 * we remove object 'op' 2645 * we remove object 'op'
2673 */ 2646 */
2674 if (QUERY_FLAG (op, FLAG_UNPAID)) 2647 if (QUERY_FLAG (op, FLAG_UNPAID))
2675 { 2648 {
2676 remove_ob (op); 2649 op->remove ();
2677 op->x = env->x; 2650 op->x = env->x;
2678 op->y = env->y; 2651 op->y = env->y;
2679 if (env->type == PLAYER) 2652 if (env->type == PLAYER)
2680 esrv_del_item (env->contr, op->count); 2653 esrv_del_item (env->contr, op->count);
2681 insert_ob_in_map (op, env->map, NULL, 0); 2654 insert_ob_in_map (op, env->map, NULL, 0);
2978 /* restore player */ 2951 /* restore player */
2979 at = archetype::find ("poisoning"); 2952 at = archetype::find ("poisoning");
2980 tmp = present_arch_in_ob (at, op); 2953 tmp = present_arch_in_ob (at, op);
2981 if (tmp) 2954 if (tmp)
2982 { 2955 {
2983 remove_ob (tmp); 2956 tmp->destroy ();
2984 free_object (tmp);
2985 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); 2957 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed");
2986 } 2958 }
2987 2959
2988 at = archetype::find ("confusion"); 2960 at = archetype::find ("confusion");
2989 tmp = present_arch_in_ob (at, op); 2961 tmp = present_arch_in_ob (at, op);
2990 if (tmp) 2962 if (tmp)
2991 { 2963 {
2992 remove_ob (tmp); 2964 tmp->destroy ();
2993 free_object (tmp);
2994 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); 2965 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer");
2995 } 2966 }
2996 2967
2997 cure_disease (op, 0); /* remove any disease */ 2968 cure_disease (op, 0); /* remove any disease */
2998 op->stats.hp = op->stats.maxhp; 2969 op->stats.hp = op->stats.maxhp;
3208 3179
3209 /* remove any poisoning and confusion the character may be suffering. */ 3180 /* remove any poisoning and confusion the character may be suffering. */
3210 /* restore player */ 3181 /* restore player */
3211 at = archetype::find ("poisoning"); 3182 at = archetype::find ("poisoning");
3212 tmp = present_arch_in_ob (at, op); 3183 tmp = present_arch_in_ob (at, op);
3184
3213 if (tmp) 3185 if (tmp)
3214 { 3186 {
3215 remove_ob (tmp); 3187 tmp->destroy ();
3216 free_object (tmp);
3217 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); 3188 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed");
3218 } 3189 }
3219 3190
3220 at = archetype::find ("confusion"); 3191 at = archetype::find ("confusion");
3221 tmp = present_arch_in_ob (at, op); 3192 tmp = present_arch_in_ob (at, op);
3222 if (tmp) 3193 if (tmp)
3223 { 3194 {
3224 remove_ob (tmp); 3195 tmp->destroy ();
3225 free_object (tmp);
3226 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); 3196 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer");
3227 } 3197 }
3228 3198
3229 cure_disease (op, 0); /* remove any disease */ 3199 cure_disease (op, 0); /* remove any disease */
3230 3200
3301 op->contr->party = NULL; 3271 op->contr->party = NULL;
3302 if (settings.set_title == TRUE) 3272 if (settings.set_title == TRUE)
3303 op->contr->own_title[0] = '\0'; 3273 op->contr->own_title[0] = '\0';
3304 new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf); 3274 new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf);
3305 check_score (op); 3275 check_score (op);
3276
3306 if (op->contr->ranges[range_golem] != NULL) 3277 if (op->contr->ranges[range_golem])
3307 { 3278 {
3308 remove_friendly_object (op->contr->ranges[range_golem]); 3279 remove_friendly_object (op->contr->ranges[range_golem]);
3309 remove_ob (op->contr->ranges[range_golem]); 3280 op->contr->ranges[range_golem]->destroy ();
3310 free_object (op->contr->ranges[range_golem]);
3311 op->contr->ranges[range_golem] = NULL; 3281 op->contr->ranges[range_golem] = 0;
3312 op->contr->golem_count = 0;
3313 } 3282 }
3283
3314 loot_object (op); /* Remove some of the items for good */ 3284 loot_object (op); /* Remove some of the items for good */
3315 remove_ob (op); 3285 op->remove ();
3316 op->direction = 0; 3286 op->direction = 0;
3317 3287
3318 if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp) 3288 if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp)
3319 { 3289 {
3320 delete_character (op->name, 0); 3290 delete_character (op->name, 0);
3373 for (tmp = op->inv; tmp != NULL; tmp = next) 3343 for (tmp = op->inv; tmp != NULL; tmp = next)
3374 { 3344 {
3375 next = tmp->below; 3345 next = tmp->below;
3376 if (tmp->type == EXPERIENCE || tmp->invisible) 3346 if (tmp->type == EXPERIENCE || tmp->invisible)
3377 continue; 3347 continue;
3378 remove_ob (tmp); 3348 tmp->remove ();
3379 tmp->x = op->x, tmp->y = op->y; 3349 tmp->x = op->x, tmp->y = op->y;
3380 if (tmp->type == CONTAINER) 3350 if (tmp->type == CONTAINER)
3381 { /* empty container to ground */ 3351 { /* empty container to ground */
3382 loot_object (tmp); 3352 loot_object (tmp);
3383 } 3353 }
3384 if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(RANDOM () % 3))) 3354 if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(RANDOM () % 3)))
3385 { 3355 {
3386 if (tmp->nrof > 1) 3356 if (tmp->nrof > 1)
3387 { 3357 {
3388 tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); 3358 tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1));
3389 free_object (tmp2); 3359 tmp2->destroy ();
3390 insert_ob_in_map (tmp, op->map, NULL, 0); 3360 insert_ob_in_map (tmp, op->map, NULL, 0);
3391 } 3361 }
3392 else 3362 else
3393 free_object (tmp); 3363 tmp->destroy ();
3394 } 3364 }
3395 else 3365 else
3396 insert_ob_in_map (tmp, op->map, NULL, 0); 3366 insert_ob_in_map (tmp, op->map, NULL, 0);
3397 } 3367 }
3398} 3368}
3463 if (op->type == PLAYER) 3433 if (op->type == PLAYER)
3464 new_draw_info_format (NDI_UNIQUE, 0, op, "You cast %s.", &spob->name); 3434 new_draw_info_format (NDI_UNIQUE, 0, op, "You cast %s.", &spob->name);
3465 3435
3466 cast_spell (op, throw_ob, dir, spob, NULL); 3436 cast_spell (op, throw_ob, dir, spob, NULL);
3467 3437
3468 if (!QUERY_FLAG (throw_ob, FLAG_REMOVED)) 3438 throw_ob->destroy ();
3469 remove_ob (throw_ob);
3470 free_object (throw_ob);
3471} 3439}
3472 3440
3473void 3441void
3474make_visible (object *op) 3442make_visible (object *op)
3475{ 3443{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines