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.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;
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 {
1062 char buf[MAX_BUF]; 1062 char buf[MAX_BUF];
1063 1063
1064 /* this must before then initial items are given */ 1064 /* this must before then initial items are given */
1065 esrv_new_player (op->contr, op->weight + op->carrying); 1065 esrv_new_player (op->contr, op->weight + op->carrying);
1066
1066 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);
1067 1070
1068 INVOKE_PLAYER (BIRTH, op->contr); 1071 INVOKE_PLAYER (BIRTH, op->contr);
1069 INVOKE_PLAYER (LOGIN, op->contr); 1072 INVOKE_PLAYER (LOGIN, op->contr);
1070 1073
1071 op->contr->state = ST_PLAYING; 1074 op->contr->state = ST_PLAYING;
1096 { 1099 {
1097 object *tmp; 1100 object *tmp;
1098 char mapname[MAX_BUF]; 1101 char mapname[MAX_BUF];
1099 1102
1100 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);
1101 tmp = get_object (); 1104 tmp = object::create ();
1102 EXIT_PATH (tmp) = mapname; 1105 EXIT_PATH (tmp) = mapname;
1103 EXIT_X (tmp) = op->x; 1106 EXIT_X (tmp) = op->x;
1104 EXIT_Y (tmp) = op->y; 1107 EXIT_Y (tmp) = op->y;
1105 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;
1106 * if the map isn't there, then stay on the 1109 * if the map isn't there, then stay on the
1107 * default initial map */ 1110 * default initial map */
1108 free_object (tmp); 1111 tmp->destroy ();
1109 } 1112 }
1110 else 1113 else
1111 { 1114 {
1112 LOG (llevDebug, "first_map_ext_path not set\n"); 1115 LOG (llevDebug, "first_map_ext_path not set\n");
1113 } 1116 }
1123 { 1126 {
1124 shstr name = op->name; 1127 shstr name = op->name;
1125 int x = op->x, y = op->y; 1128 int x = op->x, y = op->y;
1126 1129
1127 remove_statbonus (op); 1130 remove_statbonus (op);
1128 remove_ob (op); 1131 op->remove ();
1129 op->arch = get_player_archetype (op->arch); 1132 op->arch = get_player_archetype (op->arch);
1130 copy_object (&op->arch->clone, op); 1133 op->arch->clone.copy_to (op);
1131 op->instantiate (); 1134 op->instantiate ();
1132 op->stats = op->contr->orig_stats; 1135 op->stats = op->contr->orig_stats;
1133 op->name = op->name_pl = name; 1136 op->name = op->name_pl = name;
1134 op->x = x; 1137 op->x = x;
1135 op->y = y; 1138 op->y = y;
1180 if (settings.set_title == TRUE) 1183 if (settings.set_title == TRUE)
1181 op->contr->own_title[0] = '\0'; 1184 op->contr->own_title[0] = '\0';
1182 1185
1183 if (!QUERY_FLAG (op, FLAG_WAS_WIZ)) 1186 if (!QUERY_FLAG (op, FLAG_WAS_WIZ))
1184 { 1187 {
1185 mapstruct *mp, *next; 1188 maptile *mp, *next;
1186 1189
1187 /* We need to hunt for any per player unique maps in memory and 1190 /* 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, 1191 * 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 1192 * so that players named 'Ab' won't match against players 'Abe' pathname
1190 */ 1193 */
1264 */ 1267 */
1265int 1268int
1266check_pick (object *op) 1269check_pick (object *op)
1267{ 1270{
1268 object *tmp, *next; 1271 object *tmp, *next;
1269 tag_t next_tag = 0, op_tag;
1270 int stop = 0; 1272 int stop = 0;
1271 int j, k, wvratio; 1273 int j, k, wvratio;
1272 char putstring[128], tmpstr[16]; 1274 char putstring[128], tmpstr[16];
1273 1275
1274
1275 /* if you're flying, you cna't pick up anything */ 1276 /* if you're flying, you cna't pick up anything */
1276 if (op->move_type & MOVE_FLYING) 1277 if (op->move_type & MOVE_FLYING)
1277 return 1; 1278 return 1;
1278 1279
1279 op_tag = op->count;
1280
1281 next = op->below; 1280 next = op->below;
1282 if (next)
1283 next_tag = next->count;
1284 1281
1285 /* loop while there are items on the floor that are not marked as 1282 /* loop while there are items on the floor that are not marked as
1286 * destroyed */ 1283 * destroyed */
1287 while (next && !was_destroyed (next, next_tag)) 1284 while (next && !next->destroyed ())
1288 { 1285 {
1289 tmp = next; 1286 tmp = next;
1290 next = tmp->below; 1287 next = tmp->below;
1291 if (next)
1292 next_tag = next->count;
1293 1288
1294 if (was_destroyed (op, op_tag)) 1289 if (op->destroyed ())
1295 return 0; 1290 return 0;
1296 1291
1297 if (!can_pick (op, tmp)) 1292 if (!can_pick (op, tmp))
1298 continue; 1293 continue;
1299 1294
1431 /* question: don't pick up known-poisonous stuff? */ 1426 /* question: don't pick up known-poisonous stuff? */
1432 if (op->contr->mode & PU_FOOD) 1427 if (op->contr->mode & PU_FOOD)
1433 if (tmp->type == FOOD) 1428 if (tmp->type == FOOD)
1434 { 1429 {
1435 pick_up (op, tmp); 1430 pick_up (op, tmp);
1436 if (0)
1437 fprintf (stderr, "FOOD\n");
1438 continue; 1431 continue;
1439 } 1432 }
1433
1440 if (op->contr->mode & PU_DRINK) 1434 if (op->contr->mode & PU_DRINK)
1441 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)))
1442 { 1436 {
1443 pick_up (op, tmp); 1437 pick_up (op, tmp);
1444 if (0)
1445 fprintf (stderr, "DRINK\n");
1446 continue; 1438 continue;
1447 } 1439 }
1448 1440
1449 if (op->contr->mode & PU_POTION) 1441 if (op->contr->mode & PU_POTION)
1450 if (tmp->type == POTION) 1442 if (tmp->type == POTION)
1451 { 1443 {
1452 pick_up (op, tmp); 1444 pick_up (op, tmp);
1453 if (0)
1454 fprintf (stderr, "POTION\n");
1455 continue; 1445 continue;
1456 } 1446 }
1457 1447
1458 /* spellbooks, skillscrolls and normal books/scrolls */ 1448 /* spellbooks, skillscrolls and normal books/scrolls */
1459 if (op->contr->mode & PU_SPELLBOOK) 1449 if (op->contr->mode & PU_SPELLBOOK)
1460 if (tmp->type == SPELLBOOK) 1450 if (tmp->type == SPELLBOOK)
1461 { 1451 {
1462 pick_up (op, tmp); 1452 pick_up (op, tmp);
1463 if (0)
1464 fprintf (stderr, "SPELLBOOK\n");
1465 continue; 1453 continue;
1466 } 1454 }
1455
1467 if (op->contr->mode & PU_SKILLSCROLL) 1456 if (op->contr->mode & PU_SKILLSCROLL)
1468 if (tmp->type == SKILLSCROLL) 1457 if (tmp->type == SKILLSCROLL)
1469 { 1458 {
1470 pick_up (op, tmp); 1459 pick_up (op, tmp);
1471 if (0)
1472 fprintf (stderr, "SKILLSCROLL\n");
1473 continue; 1460 continue;
1474 } 1461 }
1462
1475 if (op->contr->mode & PU_READABLES) 1463 if (op->contr->mode & PU_READABLES)
1476 if (tmp->type == BOOK || tmp->type == SCROLL) 1464 if (tmp->type == BOOK || tmp->type == SCROLL)
1477 { 1465 {
1478 pick_up (op, tmp); 1466 pick_up (op, tmp);
1479 if (0)
1480 fprintf (stderr, "READABLES\n");
1481 continue; 1467 continue;
1482 } 1468 }
1483 1469
1484 /* wands/staves/rods/horns */ 1470 /* wands/staves/rods/horns */
1485 if (op->contr->mode & PU_MAGIC_DEVICE) 1471 if (op->contr->mode & PU_MAGIC_DEVICE)
1486 if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) 1472 if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN)
1487 { 1473 {
1488 pick_up (op, tmp); 1474 pick_up (op, tmp);
1489 if (0)
1490 fprintf (stderr, "MAGIC_DEVICE\n");
1491 continue; 1475 continue;
1492 } 1476 }
1493 1477
1494 /* pick up all magical items */ 1478 /* pick up all magical items */
1495 if (op->contr->mode & PU_MAGICAL) 1479 if (op->contr->mode & PU_MAGICAL)
1496 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))
1497 { 1481 {
1498 pick_up (op, tmp); 1482 pick_up (op, tmp);
1499 if (0)
1500 fprintf (stderr, "MAGICAL\n");
1501 continue; 1483 continue;
1502 } 1484 }
1503 1485
1504 if (op->contr->mode & PU_VALUABLES) 1486 if (op->contr->mode & PU_VALUABLES)
1505 { 1487 {
1506 if (tmp->type == MONEY || tmp->type == GEM) 1488 if (tmp->type == MONEY || tmp->type == GEM)
1507 { 1489 {
1508 pick_up (op, tmp); 1490 pick_up (op, tmp);
1509 if (0)
1510 fprintf (stderr, "MONEY/GEM\n");
1511 continue; 1491 continue;
1512 } 1492 }
1513 } 1493 }
1514 1494
1515 /* rings & amulets - talismans seems to be typed AMULET */ 1495 /* rings & amulets - talismans seems to be typed AMULET */
1516 if (op->contr->mode & PU_JEWELS) 1496 if (op->contr->mode & PU_JEWELS)
1517 if (tmp->type == RING || tmp->type == AMULET) 1497 if (tmp->type == RING || tmp->type == AMULET)
1518 { 1498 {
1519 pick_up (op, tmp); 1499 pick_up (op, tmp);
1500 continue;
1520 if (0) 1501 }
1521 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);
1522 continue; 1508 continue;
1523 } 1509 }
1524 1510
1525 /* bows and arrows. Bows are good for selling! */ 1511 /* bows and arrows. Bows are good for selling! */
1526 if (op->contr->mode & PU_BOW) 1512 if (op->contr->mode & PU_BOW)
1527 if (tmp->type == BOW) 1513 if (tmp->type == BOW)
1528 { 1514 {
1529 pick_up (op, tmp); 1515 pick_up (op, tmp);
1530 if (0)
1531 fprintf (stderr, "BOW\n");
1532 continue; 1516 continue;
1533 } 1517 }
1518
1534 if (op->contr->mode & PU_ARROW) 1519 if (op->contr->mode & PU_ARROW)
1535 if (tmp->type == ARROW) 1520 if (tmp->type == ARROW)
1536 { 1521 {
1537 pick_up (op, tmp); 1522 pick_up (op, tmp);
1538 if (0)
1539 fprintf (stderr, "ARROW\n");
1540 continue; 1523 continue;
1541 } 1524 }
1542 1525
1543 /* all kinds of armor etc. */ 1526 /* all kinds of armor etc. */
1544 if (op->contr->mode & PU_ARMOUR) 1527 if (op->contr->mode & PU_ARMOUR)
1545 if (tmp->type == ARMOUR) 1528 if (tmp->type == ARMOUR)
1546 { 1529 {
1547 pick_up (op, tmp); 1530 pick_up (op, tmp);
1548 if (0)
1549 fprintf (stderr, "ARMOUR\n");
1550 continue; 1531 continue;
1551 } 1532 }
1533
1552 if (op->contr->mode & PU_HELMET) 1534 if (op->contr->mode & PU_HELMET)
1553 if (tmp->type == HELMET) 1535 if (tmp->type == HELMET)
1554 { 1536 {
1555 pick_up (op, tmp); 1537 pick_up (op, tmp);
1556 if (0)
1557 fprintf (stderr, "HELMET\n");
1558 continue; 1538 continue;
1559 } 1539 }
1540
1560 if (op->contr->mode & PU_SHIELD) 1541 if (op->contr->mode & PU_SHIELD)
1561 if (tmp->type == SHIELD) 1542 if (tmp->type == SHIELD)
1562 { 1543 {
1563 pick_up (op, tmp); 1544 pick_up (op, tmp);
1564 if (0)
1565 fprintf (stderr, "SHIELD\n");
1566 continue; 1545 continue;
1567 } 1546 }
1547
1568 if (op->contr->mode & PU_BOOTS) 1548 if (op->contr->mode & PU_BOOTS)
1569 if (tmp->type == BOOTS) 1549 if (tmp->type == BOOTS)
1570 { 1550 {
1571 pick_up (op, tmp); 1551 pick_up (op, tmp);
1572 if (0)
1573 fprintf (stderr, "BOOTS\n");
1574 continue; 1552 continue;
1575 } 1553 }
1554
1576 if (op->contr->mode & PU_GLOVES) 1555 if (op->contr->mode & PU_GLOVES)
1577 if (tmp->type == GLOVES) 1556 if (tmp->type == GLOVES)
1578 { 1557 {
1579 pick_up (op, tmp); 1558 pick_up (op, tmp);
1580 if (0)
1581 fprintf (stderr, "GLOVES\n");
1582 continue; 1559 continue;
1583 } 1560 }
1561
1584 if (op->contr->mode & PU_CLOAK) 1562 if (op->contr->mode & PU_CLOAK)
1585 if (tmp->type == CLOAK) 1563 if (tmp->type == CLOAK)
1586 { 1564 {
1587 pick_up (op, tmp); 1565 pick_up (op, tmp);
1588 if (0)
1589 fprintf (stderr, "GLOVES\n");
1590 continue; 1566 continue;
1591 } 1567 }
1592 1568
1593 /* hoping to catch throwing daggers here */ 1569 /* hoping to catch throwing daggers here */
1594 if (op->contr->mode & PU_MISSILEWEAPON) 1570 if (op->contr->mode & PU_MISSILEWEAPON)
1595 if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) 1571 if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN))
1596 { 1572 {
1597 pick_up (op, tmp); 1573 pick_up (op, tmp);
1598 if (0)
1599 fprintf (stderr, "MISSILEWEAPON\n");
1600 continue; 1574 continue;
1601 } 1575 }
1602 1576
1603 /* careful: chairs and tables are weapons! */ 1577 /* careful: chairs and tables are weapons! */
1604 if (op->contr->mode & PU_ALLWEAPON) 1578 if (op->contr->mode & PU_ALLWEAPON)
1607 { 1581 {
1608 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 &&
1609 strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL) 1583 strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL)
1610 { 1584 {
1611 pick_up (op, tmp); 1585 pick_up (op, tmp);
1612 if (0)
1613 fprintf (stderr, "WEAPON\n");
1614 continue; 1586 continue;
1615 } 1587 }
1616 } 1588 }
1589
1617 if (tmp->type == WEAPON && tmp->name == NULL) 1590 if (tmp->type == WEAPON && tmp->name == NULL)
1618 { 1591 {
1619 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)
1620 { 1593 {
1621 pick_up (op, tmp); 1594 pick_up (op, tmp);
1622 if (0)
1623 fprintf (stderr, "WEAPON\n");
1624 continue; 1595 continue;
1625 } 1596 }
1626 } 1597 }
1627 } 1598 }
1628 1599
1629 /* misc stuff that's useful */ 1600 /* misc stuff that's useful */
1630 if (op->contr->mode & PU_KEY) 1601 if (op->contr->mode & PU_KEY)
1631 if (tmp->type == KEY || tmp->type == SPECIAL_KEY) 1602 if (tmp->type == KEY || tmp->type == SPECIAL_KEY)
1632 { 1603 {
1633 pick_up (op, tmp); 1604 pick_up (op, tmp);
1634 if (0)
1635 fprintf (stderr, "KEY\n");
1636 continue; 1605 continue;
1637 } 1606 }
1638 1607
1639 /* 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
1640 * pickups */ 1609 * pickups */
1662 continue; 1631 continue;
1663 } 1632 }
1664 } 1633 }
1665 } /* the new pickup model */ 1634 } /* the new pickup model */
1666 } 1635 }
1636
1667 return !stop; 1637 return !stop;
1668} 1638}
1669 1639
1670/* 1640/*
1671 * Find an arrow in the inventory and after that 1641 * Find an arrow in the inventory and after that
1770 1740
1771object * 1741object *
1772pick_arrow_target (object *op, const char *type, int dir) 1742pick_arrow_target (object *op, const char *type, int dir)
1773{ 1743{
1774 object *tmp = NULL; 1744 object *tmp = NULL;
1775 mapstruct *m; 1745 maptile *m;
1776 int i, mflags, found, number; 1746 int i, mflags, found, number;
1777 sint16 x, y; 1747 sint16 x, y;
1778 1748
1779 if (op->map == NULL) 1749 if (op->map == NULL)
1780 return find_arrow (op, type); 1750 return find_arrow (op, type);
1840 */ 1810 */
1841int 1811int
1842fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy) 1812fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy)
1843{ 1813{
1844 object *left, *bow; 1814 object *left, *bow;
1845 tag_t left_tag, tag;
1846 int bowspeed, mflags; 1815 int bowspeed, mflags;
1847 mapstruct *m; 1816 maptile *m;
1848 1817
1849 if (!dir) 1818 if (!dir)
1850 { 1819 {
1851 new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); 1820 new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!");
1852 return 0; 1821 return 0;
1906 } 1875 }
1907 1876
1908 /* this should not happen, but sometimes does */ 1877 /* this should not happen, but sometimes does */
1909 if (arrow->nrof == 0) 1878 if (arrow->nrof == 0)
1910 { 1879 {
1911 remove_ob (arrow); 1880 arrow->destroy ();
1912 free_object (arrow);
1913 return 0; 1881 return 0;
1914 } 1882 }
1915 1883
1916 left = arrow; /* these are arrows left to the player */ 1884 left = arrow; /* these are arrows left to the player */
1917 left_tag = left->count;
1918 arrow = get_split_ob (arrow, 1); 1885 arrow = get_split_ob (arrow, 1);
1919 if (arrow == NULL) 1886 if (arrow == NULL)
1920 { 1887 {
1921 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);
1922 return 0; 1889 return 0;
1923 } 1890 }
1924 set_owner (arrow, op); 1891 arrow->set_owner (op);
1925 arrow->skill = bow->skill; 1892 arrow->skill = bow->skill;
1926 1893
1927 arrow->direction = dir; 1894 arrow->direction = dir;
1928 arrow->x = sx; 1895 arrow->x = sx;
1929 arrow->y = sy; 1896 arrow->y = sy;
1965 arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level; 1932 arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level;
1966 } 1933 }
1967 else 1934 else
1968 { 1935 {
1969 arrow->stats.wc = op->stats.wc - bow->magic - arrow->magic - arrow->stats.wc + wc_mod; 1936 arrow->stats.wc = op->stats.wc - bow->magic - arrow->magic - arrow->stats.wc + wc_mod;
1970
1971 arrow->level = op->level; 1937 arrow->level = op->level;
1972 } 1938 }
1939
1973 if (arrow->attacktype == AT_PHYSICAL) 1940 if (arrow->attacktype == AT_PHYSICAL)
1974 arrow->attacktype |= bow->attacktype; 1941 arrow->attacktype |= bow->attacktype;
1942
1975 if (bow->slaying != NULL) 1943 if (bow->slaying != NULL)
1976 arrow->slaying = bow->slaying; 1944 arrow->slaying = bow->slaying;
1977 1945
1978 arrow->map = m; 1946 arrow->map = m;
1979 arrow->move_type = MOVE_FLY_LOW; 1947 arrow->move_type = MOVE_FLY_LOW;
1980 arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; 1948 arrow->move_on = MOVE_FLY_LOW | MOVE_WALK;
1981 1949
1982 play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW); 1950 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); 1951 insert_ob_in_map (arrow, m, op, 0);
1985 1952
1986 if (!was_destroyed (arrow, tag)) 1953 if (!arrow->destroyed ())
1987 move_arrow (arrow); 1954 move_arrow (arrow);
1988 1955
1989 if (op->type == PLAYER) 1956 if (op->type == PLAYER)
1990 { 1957 {
1991 if (was_destroyed (left, left_tag)) 1958 if (left->destroyed ())
1992 esrv_del_item (op->contr, left_tag); 1959 esrv_del_item (op->contr, left->count);
1993 else 1960 else
1994 esrv_send_item (op, left); 1961 esrv_send_item (op, left);
1995 } 1962 }
1963
1996 return 1; 1964 return 1;
1997} 1965}
1998 1966
1999/* Special fire code for players - this takes into 1967/* Special fire code for players - this takes into
2000 * account the special fire modes players can have 1968 * account the special fire modes players can have
2136 case range_misc: 2104 case range_misc:
2137 fire_misc_object (op, dir); 2105 fire_misc_object (op, dir);
2138 return; 2106 return;
2139 2107
2140 case range_golem: /* Control summoned monsters from scrolls */ 2108 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) 2109 if (QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED))
2142 { 2110 {
2143 op->contr->ranges[range_golem] = NULL; 2111 op->contr->ranges[range_golem] = 0;
2144 op->contr->shoottype = range_none; 2112 op->contr->shoottype = range_none;
2145 op->contr->golem_count = 0;
2146 } 2113 }
2147 else 2114 else
2148 control_golem (op->contr->ranges[range_golem], dir); 2115 control_golem (op->contr->ranges[range_golem], dir);
2149 return; 2116 return;
2150 2117
2312move_player_attack (object *op, int dir) 2279move_player_attack (object *op, int dir)
2313{ 2280{
2314 object *tmp, *mon; 2281 object *tmp, *mon;
2315 sint16 nx, ny; 2282 sint16 nx, ny;
2316 int on_battleground; 2283 int on_battleground;
2317 mapstruct *m; 2284 maptile *m;
2318 2285
2319 nx = freearr_x[dir] + op->x; 2286 nx = freearr_x[dir] + op->x;
2320 ny = freearr_y[dir] + op->y; 2287 ny = freearr_y[dir] + op->y;
2321 2288
2322 on_battleground = op_on_battleground (op, NULL, NULL); 2289 on_battleground = op_on_battleground (op, NULL, NULL);
2358 if (tmp == op) 2325 if (tmp == op)
2359 { 2326 {
2360 tmp = tmp->above; 2327 tmp = tmp->above;
2361 continue; 2328 continue;
2362 } 2329 }
2330
2363 if (QUERY_FLAG (tmp, FLAG_ALIVE)) 2331 if (QUERY_FLAG (tmp, FLAG_ALIVE))
2364 { 2332 {
2365 mon = tmp; 2333 mon = tmp;
2366 break; 2334 break;
2367 } 2335 }
2336
2368 if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL)) 2337 if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL))
2369 mon = tmp; 2338 mon = tmp;
2339
2370 tmp = tmp->above; 2340 tmp = tmp->above;
2371 } 2341 }
2372 2342
2373 if (mon == NULL) /* This happens anytime the player tries to move */ 2343 if (mon == NULL) /* This happens anytime the player tries to move */
2374 return; /* into a wall */ 2344 return; /* into a wall */
2393 * player owns it and it is either friendly or unagressive. 2363 * player owns it and it is either friendly or unagressive.
2394 */ 2364 */
2395 if ((op->type == PLAYER) 2365 if ((op->type == PLAYER)
2396#if COZY_SERVER 2366#if COZY_SERVER
2397 && 2367 &&
2398 ((get_owner (mon) && get_owner (mon)->contr 2368 ((mon->owner && mon->owner->contr
2399 && 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)
2400#else 2370#else
2401 && get_owner (mon) == op 2371 && mon->owner == op
2402#endif 2372#endif
2403 && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) 2373 && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)))
2404 { 2374 {
2405 /* 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 */
2406 if (op->contr->braced) 2376 if (op->contr->braced)
2593 /* 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
2594 * 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
2595 * 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
2596 * 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.
2597 */ 2567 */
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))) 2568 if (op->contr->ranges[range_golem] && QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED))
2600 {
2601 op->contr->ranges[range_golem] = NULL; 2569 op->contr->ranges[range_golem] = 0;
2602 op->contr->golem_count = 0;
2603 }
2604 2570
2605 /* 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
2606 * the players time has been increased when doericserver has been 2572 * the players time has been increased when doericserver has been
2607 * called, so we recheck it here. 2573 * called, so we recheck it here.
2608 */ 2574 */
2639 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 2605 for (tmp = op->inv; tmp != NULL; tmp = tmp->below)
2640 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) 2606 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE))
2641 { 2607 {
2642 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);
2643 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
2644 if (op->contr) 2611 if (op->contr)
2645 esrv_del_item (op->contr, tmp->count); 2612 esrv_del_item (op->contr, tmp->count);
2646 remove_ob (tmp); 2613
2647 free_object (tmp); 2614 tmp->destroy ();
2648 CLEAR_FLAG (op, FLAG_LIFESAVE); 2615 CLEAR_FLAG (op, FLAG_LIFESAVE);
2616
2649 if (op->stats.hp < 0) 2617 if (op->stats.hp < 0)
2650 op->stats.hp = op->stats.maxhp; 2618 op->stats.hp = op->stats.maxhp;
2619
2651 if (op->stats.food < 0) 2620 if (op->stats.food < 0)
2652 op->stats.food = 999; 2621 op->stats.food = 999;
2622
2653 fix_player (op); 2623 fix_player (op);
2654 return 1; 2624 return 1;
2655 } 2625 }
2656 LOG (llevError, "Error: LIFESAVE set without applied object.\n"); 2626 LOG (llevError, "Error: LIFESAVE set without applied object.\n");
2657 CLEAR_FLAG (op, FLAG_LIFESAVE); 2627 CLEAR_FLAG (op, FLAG_LIFESAVE);
2674 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
2675 * we remove object 'op' 2645 * we remove object 'op'
2676 */ 2646 */
2677 if (QUERY_FLAG (op, FLAG_UNPAID)) 2647 if (QUERY_FLAG (op, FLAG_UNPAID))
2678 { 2648 {
2679 remove_ob (op); 2649 op->remove ();
2680 op->x = env->x; 2650 op->x = env->x;
2681 op->y = env->y; 2651 op->y = env->y;
2682 if (env->type == PLAYER) 2652 if (env->type == PLAYER)
2683 esrv_del_item (env->contr, op->count); 2653 esrv_del_item (env->contr, op->count);
2684 insert_ob_in_map (op, env->map, NULL, 0); 2654 insert_ob_in_map (op, env->map, NULL, 0);
2952{ 2922{
2953 char buf[MAX_BUF]; 2923 char buf[MAX_BUF];
2954 int x, y; 2924 int x, y;
2955 2925
2956 //int i; 2926 //int i;
2957 mapstruct *map; /* this is for resurrection */ 2927 maptile *map; /* this is for resurrection */
2958 2928
2959 /* int z; 2929 /* int z;
2960 int num_stats_lose; 2930 int num_stats_lose;
2961 int lost_a_stat; 2931 int lost_a_stat;
2962 int lose_this_stat; 2932 int lose_this_stat;
2981 /* restore player */ 2951 /* restore player */
2982 at = archetype::find ("poisoning"); 2952 at = archetype::find ("poisoning");
2983 tmp = present_arch_in_ob (at, op); 2953 tmp = present_arch_in_ob (at, op);
2984 if (tmp) 2954 if (tmp)
2985 { 2955 {
2986 remove_ob (tmp); 2956 tmp->destroy ();
2987 free_object (tmp);
2988 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); 2957 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed");
2989 } 2958 }
2990 2959
2991 at = archetype::find ("confusion"); 2960 at = archetype::find ("confusion");
2992 tmp = present_arch_in_ob (at, op); 2961 tmp = present_arch_in_ob (at, op);
2993 if (tmp) 2962 if (tmp)
2994 { 2963 {
2995 remove_ob (tmp); 2964 tmp->destroy ();
2996 free_object (tmp);
2997 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); 2965 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer");
2998 } 2966 }
2999 2967
3000 cure_disease (op, 0); /* remove any disease */ 2968 cure_disease (op, 0); /* remove any disease */
3001 op->stats.hp = op->stats.maxhp; 2969 op->stats.hp = op->stats.maxhp;
3178 /* determine_god() seems to not work sometimes... why is this? 3146 /* determine_god() seems to not work sometimes... why is this?
3179 Should I be using something else? GD */ 3147 Should I be using something else? GD */
3180 const char *god = determine_god (op); 3148 const char *god = determine_god (op);
3181 3149
3182 if (god && (strcmp (god, "none"))) 3150 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); 3151 new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief moment you feel the holy presence of %s protecting" " you.", god);
3184 else 3152 else
3185 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you."); 3153 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you.");
3186 } 3154 }
3155#else
3156 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely.");
3187#endif 3157#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 3158
3190 /* Put a gravestone up where the character 'almost' died. List the 3159 /* Put a gravestone up where the character 'almost' died. List the
3191 * exp loss on the stone. 3160 * exp loss on the stone.
3192 */ 3161 */
3193 tmp = arch_to_object (archetype::find ("gravestone")); 3162 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); 3167 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; 3168 tmp->msg = buf;
3200 tmp->x = op->x, tmp->y = op->y; 3169 tmp->x = op->x, tmp->y = op->y;
3201 insert_ob_in_map (tmp, op->map, NULL, 0); 3170 insert_ob_in_map (tmp, op->map, NULL, 0);
3202 3171
3203 /**************************************/ 3172 /**************************************/
3204 /* */ 3173 /* */
3205 /* Subtract the experience points, */ 3174 /* Subtract the experience points, */
3206 /* if we died cause of food, give us */ 3175 /* if we died cause of food, give us */
3207 /* food, and reset HP's... */ 3176 /* food, and reset HP's... */
3208 /* */ 3177 /* */
3209
3210 /**************************************/ 3178 /**************************************/
3211 3179
3212 /* remove any poisoning and confusion the character may be suffering. */ 3180 /* remove any poisoning and confusion the character may be suffering. */
3213 /* restore player */ 3181 /* restore player */
3214 at = archetype::find ("poisoning"); 3182 at = archetype::find ("poisoning");
3215 tmp = present_arch_in_ob (at, op); 3183 tmp = present_arch_in_ob (at, op);
3184
3216 if (tmp) 3185 if (tmp)
3217 { 3186 {
3218 remove_ob (tmp); 3187 tmp->destroy ();
3219 free_object (tmp);
3220 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); 3188 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed");
3221 } 3189 }
3222 3190
3223 at = archetype::find ("confusion"); 3191 at = archetype::find ("confusion");
3224 tmp = present_arch_in_ob (at, op); 3192 tmp = present_arch_in_ob (at, op);
3225 if (tmp) 3193 if (tmp)
3226 { 3194 {
3227 remove_ob (tmp); 3195 tmp->destroy ();
3228 free_object (tmp);
3229 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); 3196 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer");
3230 } 3197 }
3198
3231 cure_disease (op, 0); /* remove any disease */ 3199 cure_disease (op, 0); /* remove any disease */
3232 3200
3233 /*add_exp(op, (op->stats.exp * -0.20)); */ 3201 /*add_exp(op, (op->stats.exp * -0.20)); */
3234 apply_death_exp_penalty (op); 3202 apply_death_exp_penalty (op);
3235 if (op->stats.food < 100) 3203 if (op->stats.food < 100)
3245 */ 3213 */
3246 3214
3247 if (is_in_shop (op)) 3215 if (is_in_shop (op))
3248 remove_unpaid_objects (op->inv, op); 3216 remove_unpaid_objects (op->inv, op);
3249 3217
3250 /****************************************/ 3218 /****************************************/
3251 /* */ 3219 /* */
3252 /* Move player to his current respawn- */ 3220 /* Move player to his current respawn- */
3253 /* position (usually last savebed) */ 3221 /* position (usually last savebed) */
3254 /* */ 3222 /* */
3255
3256 /****************************************/ 3223 /****************************************/
3257 3224
3258 enter_player_savebed (op); 3225 enter_player_savebed (op);
3259 3226
3260 /* Save the player before inserting the force to reduce 3227 /* Save the player before inserting the force to reduce
3261 * chance of abuse. 3228 * chance of abuse.
3268 * spell effects. So first see if there is a spell effect 3235 * spell effects. So first see if there is a spell effect
3269 * on the space that might harm the player. 3236 * on the space that might harm the player.
3270 */ 3237 */
3271 will_kill_again = 0; 3238 will_kill_again = 0;
3272 for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above) 3239 for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above)
3273 {
3274 if (tmp->type == SPELL_EFFECT) 3240 if (tmp->type == SPELL_EFFECT)
3275 will_kill_again |= tmp->attacktype; 3241 will_kill_again |= tmp->attacktype;
3276 } 3242
3277 if (will_kill_again) 3243 if (will_kill_again)
3278 { 3244 {
3279 object *force; 3245 object *force;
3280 int at; 3246 int at;
3281 3247
3283 /* 50 ticks should be enough time for the spell to abate */ 3249 /* 50 ticks should be enough time for the spell to abate */
3284 force->speed = 0.1; 3250 force->speed = 0.1;
3285 force->speed_left = -5.0; 3251 force->speed_left = -5.0;
3286 SET_FLAG (force, FLAG_APPLIED); 3252 SET_FLAG (force, FLAG_APPLIED);
3287 for (at = 0; at < NROFATTACKS; at++) 3253 for (at = 0; at < NROFATTACKS; at++)
3288 {
3289 if (will_kill_again & (1 << at)) 3254 if (will_kill_again & (1 << at))
3290 force->resist[at] = 100; 3255 force->resist[at] = 100;
3291 } 3256
3292 insert_ob_in_ob (force, op); 3257 insert_ob_in_ob (force, op);
3293 fix_player (op); 3258 fix_player (op);
3294 3259
3295 } 3260 }
3296 3261
3306 op->contr->party = NULL; 3271 op->contr->party = NULL;
3307 if (settings.set_title == TRUE) 3272 if (settings.set_title == TRUE)
3308 op->contr->own_title[0] = '\0'; 3273 op->contr->own_title[0] = '\0';
3309 new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf); 3274 new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf);
3310 check_score (op); 3275 check_score (op);
3276
3311 if (op->contr->ranges[range_golem] != NULL) 3277 if (op->contr->ranges[range_golem])
3312 { 3278 {
3313 remove_friendly_object (op->contr->ranges[range_golem]); 3279 remove_friendly_object (op->contr->ranges[range_golem]);
3314 remove_ob (op->contr->ranges[range_golem]); 3280 op->contr->ranges[range_golem]->destroy ();
3315 free_object (op->contr->ranges[range_golem]);
3316 op->contr->ranges[range_golem] = NULL; 3281 op->contr->ranges[range_golem] = 0;
3317 op->contr->golem_count = 0;
3318 } 3282 }
3283
3319 loot_object (op); /* Remove some of the items for good */ 3284 loot_object (op); /* Remove some of the items for good */
3320 remove_ob (op); 3285 op->remove ();
3321 op->direction = 0; 3286 op->direction = 0;
3322 3287
3323 if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp) 3288 if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp)
3324 { 3289 {
3325 delete_character (op->name, 0); 3290 delete_character (op->name, 0);
3378 for (tmp = op->inv; tmp != NULL; tmp = next) 3343 for (tmp = op->inv; tmp != NULL; tmp = next)
3379 { 3344 {
3380 next = tmp->below; 3345 next = tmp->below;
3381 if (tmp->type == EXPERIENCE || tmp->invisible) 3346 if (tmp->type == EXPERIENCE || tmp->invisible)
3382 continue; 3347 continue;
3383 remove_ob (tmp); 3348 tmp->remove ();
3384 tmp->x = op->x, tmp->y = op->y; 3349 tmp->x = op->x, tmp->y = op->y;
3385 if (tmp->type == CONTAINER) 3350 if (tmp->type == CONTAINER)
3386 { /* empty container to ground */ 3351 { /* empty container to ground */
3387 loot_object (tmp); 3352 loot_object (tmp);
3388 } 3353 }
3389 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)))
3390 { 3355 {
3391 if (tmp->nrof > 1) 3356 if (tmp->nrof > 1)
3392 { 3357 {
3393 tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); 3358 tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1));
3394 free_object (tmp2); 3359 tmp2->destroy ();
3395 insert_ob_in_map (tmp, op->map, NULL, 0); 3360 insert_ob_in_map (tmp, op->map, NULL, 0);
3396 } 3361 }
3397 else 3362 else
3398 free_object (tmp); 3363 tmp->destroy ();
3399 } 3364 }
3400 else 3365 else
3401 insert_ob_in_map (tmp, op->map, NULL, 0); 3366 insert_ob_in_map (tmp, op->map, NULL, 0);
3402 } 3367 }
3403} 3368}
3468 if (op->type == PLAYER) 3433 if (op->type == PLAYER)
3469 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);
3470 3435
3471 cast_spell (op, throw_ob, dir, spob, NULL); 3436 cast_spell (op, throw_ob, dir, spob, NULL);
3472 3437
3473 if (!QUERY_FLAG (throw_ob, FLAG_REMOVED)) 3438 throw_ob->destroy ();
3474 remove_ob (throw_ob);
3475 free_object (throw_ob);
3476} 3439}
3477 3440
3478void 3441void
3479make_visible (object *op) 3442make_visible (object *op)
3480{ 3443{
3596int 3559int
3597stand_near_hostile (object *who) 3560stand_near_hostile (object *who)
3598{ 3561{
3599 object *tmp = NULL; 3562 object *tmp = NULL;
3600 int i, friendly = 0, player = 0, mflags; 3563 int i, friendly = 0, player = 0, mflags;
3601 mapstruct *m; 3564 maptile *m;
3602 sint16 x, y; 3565 sint16 x, y;
3603 3566
3604 if (!who) 3567 if (!who)
3605 return 0; 3568 return 0;
3606 3569

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines