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.38 by root, Thu Dec 14 04:30:32 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__
29# include <sproto.h> 26#include <sproto.h>
30#endif
31#include <sounds.h> 27#include <sounds.h>
32#include <living.h> 28#include <living.h>
33#include <object.h> 29#include <object.h>
34#include <spells.h> 30#include <spells.h>
35#include <skills.h> 31#include <skills.h>
208 * the one that is passed. 204 * the one that is passed.
209 */ 205 */
210static player * 206static player *
211get_player (player *p) 207get_player (player *p)
212{ 208{
213 object *op = arch_to_object (get_player_archetype (NULL)); 209 object *op = arch_to_object (get_player_archetype (0));
214 int i; 210 int i;
215
216 if (!p)
217 {
218 p = new player;
219
220 /* This adds the player in the linked list. There is extra
221 * complexity here because we want to add the new player at the
222 * end of the list - there is in fact no compelling reason that
223 * that needs to be done except for things like output of
224 * 'who'.
225 */
226 player *tmp = first_player;
227
228 while (tmp != NULL && tmp->next != NULL)
229 tmp = tmp->next;
230 if (tmp != NULL)
231 tmp->next = p;
232 else
233 first_player = p;
234
235 p->next = NULL;
236 }
237 211
238 /* Clears basically the entire player structure except 212 /* Clears basically the entire player structure except
239 * for next and socket. 213 * for next and socket.
240 */ 214 */
241 p->clear (); 215 p->clear ();
260 op->speed_left = 0.5; 234 op->speed_left = 0.5;
261 op->speed = 1.0; 235 op->speed = 1.0;
262 op->direction = 5; /* So player faces south */ 236 op->direction = 5; /* So player faces south */
263 op->stats.wc = 2; 237 op->stats.wc = 2;
264 op->run_away = 25; /* Then we panick... */ 238 op->run_away = 25; /* Then we panick... */
265 p->socket.monitor_spells = 0; /* Needed because esrv_update_spells( ) gets called by roll_stats */ 239 p->socket->monitor_spells = 0; /* Needed because esrv_update_spells( ) gets called by roll_stats */
266 240
267 roll_stats (op); 241 roll_stats (op);
268 p->state = ST_ROLL_STAT; 242 p->state = ST_ROLL_STAT;
269 clear_los (op); 243 clear_los (op);
270 244
294 for (i = 0; i < NUM_SKILLS; i++) 268 for (i = 0; i < NUM_SKILLS; i++)
295 { 269 {
296 p->last_skill_exp[i] = -1; 270 p->last_skill_exp[i] = -1;
297 p->last_skill_ob[i] = NULL; 271 p->last_skill_ob[i] = NULL;
298 } 272 }
273
299 for (i = 0; i < NROFATTACKS; i++) 274 for (i = 0; i < NROFATTACKS; i++)
300 {
301 p->last_resist[i] = -1; 275 p->last_resist[i] = -1;
302 } 276
303 p->last_stats.exp = -1; 277 p->last_stats.exp = -1;
304 p->last_weight = (uint32) - 1; 278 p->last_weight = (uint32) - 1;
305 279
306 p->socket.update_look = 0; 280 p->socket->update_look = 0;
307 p->socket.look_position = 0; 281 p->socket->look_position = 0;
282
308 return p; 283 return p;
309} 284}
310 285
311/* This loads the first map an puts the player on it. */ 286/* This loads the first map an puts the player on it. */
312static void 287static void
322 * All we can really get in this is some settings like host and display 297 * All we can really get in this is some settings like host and display
323 * mode. 298 * mode.
324 */ 299 */
325 300
326int 301int
327add_player (NewSocket * ns) 302add_player (client_socket *ns)
328{ 303{
329 player *p; 304 player *p = new player;
330 305
331 p = get_player (NULL);
332 p->socket = *ns; 306 p->socket = ns;
333 p->socket.faces_sent = (uint8 *) malloc (p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); 307 ns->pl = p;
334 308
335 if (p->socket.faces_sent == NULL) 309 p->next = first_player;
336 fatal (OUT_OF_MEMORY); 310 first_player = p;
337 311
338 memcpy (p->socket.faces_sent, ns->faces_sent, p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); 312 p = get_player (p);
339 /* Needed because the socket we just copied over needs to be cleared. 313
340 * Note that this can result in a client reset if there is partial data
341 * on the uncoming socket.
342 */
343 p->socket.inbuf.len = 0;
344 set_first_map (p->ob); 314 set_first_map (p->ob);
345 315
346 CLEAR_FLAG (p->ob, FLAG_FRIENDLY); 316 CLEAR_FLAG (p->ob, FLAG_FRIENDLY);
347 add_friendly_object (p->ob); 317 add_friendly_object (p->ob);
348 send_rules (p->ob); 318 send_rules (p->ob);
646 (op->type == ARMOUR || op->type == BOOTS || 616 (op->type == ARMOUR || op->type == BOOTS ||
647 op->type == CLOAK || op->type == HELMET || 617 op->type == CLOAK || op->type == HELMET ||
648 op->type == SHIELD || op->type == GLOVES || 618 op->type == SHIELD || op->type == GLOVES ||
649 op->type == BRACERS || op->type == GIRDLE)) || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON)) 619 op->type == BRACERS || op->type == GIRDLE)) || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON))
650 { 620 {
651 remove_ob (op); 621 op->destroy ();
652 free_object (op);
653 continue; 622 continue;
654 } 623 }
655 } 624 }
656 625
657 /* This really needs to be better - we should really give 626 /* This really needs to be better - we should really give
668 if (tmp->type == op->type && tmp->name == op->name) 637 if (tmp->type == op->type && tmp->name == op->name)
669 break; 638 break;
670 639
671 if (tmp) 640 if (tmp)
672 { 641 {
673 remove_ob (op); 642 op->destroy ();
674 free_object (op);
675 LOG (llevError, "give_initial_items: Removing duplicate object %s\n", &tmp->name); 643 LOG (llevError, "give_initial_items: Removing duplicate object %s\n", &tmp->name);
676 continue; 644 continue;
677 } 645 }
646
678 if (op->nrof > 1) 647 if (op->nrof > 1)
679 op->nrof = 1; 648 op->nrof = 1;
680 } 649 }
681 650
682 if (op->type == SPELLBOOK && op->inv) 651 if (op->type == SPELLBOOK && op->inv)
694 CLEAR_FLAG (op, FLAG_CURSED); 663 CLEAR_FLAG (op, FLAG_CURSED);
695 CLEAR_FLAG (op, FLAG_DAMNED); 664 CLEAR_FLAG (op, FLAG_DAMNED);
696 } 665 }
697 if (op->type == SPELL) 666 if (op->type == SPELL)
698 { 667 {
699 remove_ob (op); 668 op->destroy ();
700 free_object (op);
701 continue; 669 continue;
702 } 670 }
703 else if (op->type == SKILL) 671 else if (op->type == SKILL)
704 { 672 {
705 SET_FLAG (op, FLAG_CAN_USE_SKILL); 673 SET_FLAG (op, FLAG_CAN_USE_SKILL);
718void 686void
719get_name (object *op) 687get_name (object *op)
720{ 688{
721 op->contr->write_buf[0] = '\0'; 689 op->contr->write_buf[0] = '\0';
722 op->contr->state = ST_GET_NAME; 690 op->contr->state = ST_GET_NAME;
723 send_query (&op->contr->socket, 0, "What is your name?\n:"); 691 send_query (op->contr->socket, 0, "What is your name?\n:");
724} 692}
725 693
726void 694void
727get_password (object *op) 695get_password (object *op)
728{ 696{
729 op->contr->write_buf[0] = '\0'; 697 op->contr->write_buf[0] = '\0';
730 op->contr->state = ST_GET_PASSWORD; 698 op->contr->state = ST_GET_PASSWORD;
731 send_query (&op->contr->socket, CS_QUERY_HIDEINPUT, "What is your password?\n:"); 699 send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "What is your password?\n:");
732} 700}
733 701
734void 702void
735play_again (object *op) 703play_again (object *op)
736{ 704{
737 op->contr->state = ST_PLAY_AGAIN; 705 op->contr->state = ST_PLAY_AGAIN;
738 op->chosen_skill = NULL; 706 op->chosen_skill = NULL;
739 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Do you want to play again (a/q)?"); 707 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Do you want to play again (a/q)?");
740 /* a bit of a hack, but there are various places early in th 708 /* a bit of a hack, but there are various places early in th
741 * player creation process that a user can quit (eg, roll 709 * player creation process that a user can quit (eg, roll
742 * stats) that isn't removing the player. Taking a quick 710 * stats) that isn't removing the player. Taking a quick
743 * look, there are many places that call play_again without 711 * look, there are many places that call play_again without
744 * removing the player - it probably makes more sense 712 * removing the player - it probably makes more sense
745 * to leave it to play_again to remove the object in all 713 * to leave it to play_again to remove the object in all
746 * cases. 714 * cases.
747 */ 715 */
748 if (!QUERY_FLAG (op, FLAG_REMOVED)) 716 if (!QUERY_FLAG (op, FLAG_REMOVED))
749 remove_ob (op); 717 op->remove ();
750 /* Need to set this to null - otherwise, it could point to garbage, 718 /* 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 719 * and draw() doesn't check to see if the player is removed, only if
752 * the map is null or not swapped out. 720 * the map is null or not swapped out.
753 */ 721 */
754 op->map = NULL; 722 op->map = NULL;
793confirm_password (object *op) 761confirm_password (object *op)
794{ 762{
795 763
796 op->contr->write_buf[0] = '\0'; 764 op->contr->write_buf[0] = '\0';
797 op->contr->state = ST_CONFIRM_PASSWORD; 765 op->contr->state = ST_CONFIRM_PASSWORD;
798 send_query (&op->contr->socket, CS_QUERY_HIDEINPUT, "Please type your password again.\n:"); 766 send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "Please type your password again.\n:");
799} 767}
800 768
801void 769void
802get_party_password (object *op, partylist *party) 770get_party_password (object *op, partylist *party)
803{ 771{
807 return; 775 return;
808 } 776 }
809 op->contr->write_buf[0] = '\0'; 777 op->contr->write_buf[0] = '\0';
810 op->contr->state = ST_GET_PARTY_PASSWORD; 778 op->contr->state = ST_GET_PARTY_PASSWORD;
811 op->contr->party_to_join = party; 779 op->contr->party_to_join = party;
812 send_query (&op->contr->socket, CS_QUERY_HIDEINPUT, "What is the password?\n:"); 780 send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "What is the password?\n:");
813} 781}
814 782
815 783
816/* This rolls four 1-6 rolls and sums the best 3 of the 4. */ 784/* This rolls four 1-6 rolls and sums the best 3 of the 4. */
817int 785int
914 882
915void 883void
916Roll_Again (object *op) 884Roll_Again (object *op)
917{ 885{
918 esrv_new_player (op->contr, 0); 886 esrv_new_player (op->contr, 0);
919 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, 887 send_query (op->contr->socket, CS_QUERY_SINGLECHAR,
920 "[y] to roll new stats [n] to use stats\n[1-7] [1-7] to swap stats.\nRoll again (y/n/1-7)? "); 888 "[y] to roll new stats [n] to use stats\n[1-7] [1-7] to swap stats.\nRoll again (y/n/1-7)? ");
921} 889}
922 890
923void 891void
924Swap_Stat (object *op, int Swap_Second) 892Swap_Stat (object *op, int Swap_Second)
991 new_draw_info (NDI_UNIQUE, 0, op, buf); 959 new_draw_info (NDI_UNIQUE, 0, op, buf);
992 } 960 }
993 else 961 else
994 Swap_Stat (op, stat_trans[keynum]); 962 Swap_Stat (op, stat_trans[keynum]);
995 963
996 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, ""); 964 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "");
997 return 1; 965 return 1;
998 } 966 }
999 switch (key) 967 switch (key)
1000 { 968 {
1001 case 'n': 969 case 'n':
1015 enter_exit (op, NULL); 983 enter_exit (op, NULL);
1016#endif 984#endif
1017 SET_ANIMATION (op, 2); /* So player faces south */ 985 SET_ANIMATION (op, 2); /* So player faces south */
1018 /* Enter exit adds a player otherwise */ 986 /* Enter exit adds a player otherwise */
1019 add_statbonus (op); 987 add_statbonus (op);
1020 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, 988 send_query (op->contr->socket, CS_QUERY_SINGLECHAR,
1021 "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n"); 989 "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n");
1022 op->contr->state = ST_CHANGE_CLASS; 990 op->contr->state = ST_CHANGE_CLASS;
1023 if (op->msg) 991 if (op->msg)
1024 new_draw_info (NDI_BLUE, 0, op, op->msg); 992 new_draw_info (NDI_BLUE, 0, op, op->msg);
1025 return 0; 993 return 0;
1026 } 994 }
1027 case 'y': 995 case 'y':
1028 case 'Y': 996 case 'Y':
1029 roll_stats (op); 997 roll_stats (op);
1030 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, ""); 998 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "");
1031 return 1; 999 return 1;
1032 1000
1033 case 'q': 1001 case 'q':
1034 case 'Q': 1002 case 'Q':
1035 play_again (op); 1003 play_again (op);
1036 return 1; 1004 return 1;
1037 1005
1038 default: 1006 default:
1039 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?"); 1007 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?");
1040 return 0; 1008 return 0;
1041 } 1009 }
1042 return 0; 1010 return 0;
1043} 1011}
1044 1012
1054{ 1022{
1055 int tmp_loop; 1023 int tmp_loop;
1056 1024
1057 if (key == 'q' || key == 'Q') 1025 if (key == 'q' || key == 'Q')
1058 { 1026 {
1059 remove_ob (op); 1027 op->remove ();
1060 play_again (op); 1028 play_again (op);
1061 return 0; 1029 return 0;
1062 } 1030 }
1063 if (key == 'd' || key == 'D') 1031 if (key == 'd' || key == 'D')
1064 { 1032 {
1065 char buf[MAX_BUF]; 1033 char buf[MAX_BUF];
1066 1034
1067 /* this must before then initial items are given */ 1035 /* this must before then initial items are given */
1068 esrv_new_player (op->contr, op->weight + op->carrying); 1036 esrv_new_player (op->contr, op->weight + op->carrying);
1037
1069 create_treasure (find_treasurelist ("starting_wealth"), op, 0, 0, 0); 1038 treasurelist *tl = find_treasurelist ("starting_wealth");
1039 if (tl)
1040 create_treasure (tl, op, 0, 0, 0);
1070 1041
1071 INVOKE_PLAYER (BIRTH, op->contr); 1042 INVOKE_PLAYER (BIRTH, op->contr);
1072 INVOKE_PLAYER (LOGIN, op->contr); 1043 INVOKE_PLAYER (LOGIN, op->contr);
1073 1044
1074 op->contr->state = ST_PLAYING; 1045 op->contr->state = ST_PLAYING;
1099 { 1070 {
1100 object *tmp; 1071 object *tmp;
1101 char mapname[MAX_BUF]; 1072 char mapname[MAX_BUF];
1102 1073
1103 snprintf (mapname, MAX_BUF - 1, "%s/%s", first_map_ext_path, &op->arch->name); 1074 snprintf (mapname, MAX_BUF - 1, "%s/%s", first_map_ext_path, &op->arch->name);
1104 tmp = get_object (); 1075 tmp = object::create ();
1105 EXIT_PATH (tmp) = mapname; 1076 EXIT_PATH (tmp) = mapname;
1106 EXIT_X (tmp) = op->x; 1077 EXIT_X (tmp) = op->x;
1107 EXIT_Y (tmp) = op->y; 1078 EXIT_Y (tmp) = op->y;
1108 enter_exit (op, tmp); /* we don't really care if it succeeded; 1079 enter_exit (op, tmp); /* we don't really care if it succeeded;
1109 * if the map isn't there, then stay on the 1080 * if the map isn't there, then stay on the
1110 * default initial map */ 1081 * default initial map */
1111 free_object (tmp); 1082 tmp->destroy ();
1112 } 1083 }
1113 else 1084 else
1114 { 1085 {
1115 LOG (llevDebug, "first_map_ext_path not set\n"); 1086 LOG (llevDebug, "first_map_ext_path not set\n");
1116 } 1087 }
1126 { 1097 {
1127 shstr name = op->name; 1098 shstr name = op->name;
1128 int x = op->x, y = op->y; 1099 int x = op->x, y = op->y;
1129 1100
1130 remove_statbonus (op); 1101 remove_statbonus (op);
1131 remove_ob (op); 1102 op->remove ();
1132 op->arch = get_player_archetype (op->arch); 1103 op->arch = get_player_archetype (op->arch);
1133 copy_object (&op->arch->clone, op); 1104 op->arch->clone.copy_to (op);
1134 op->instantiate (); 1105 op->instantiate ();
1135 op->stats = op->contr->orig_stats; 1106 op->stats = op->contr->orig_stats;
1136 op->name = op->name_pl = name; 1107 op->name = op->name_pl = name;
1137 op->x = x; 1108 op->x = x;
1138 op->y = y; 1109 op->y = y;
1151 op->stats.grace = 0; 1122 op->stats.grace = 0;
1152 1123
1153 if (op->msg) 1124 if (op->msg)
1154 new_draw_info (NDI_BLUE, 0, op, op->msg); 1125 new_draw_info (NDI_BLUE, 0, op, op->msg);
1155 1126
1156 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Press any key for the next race.\nPress `d' to play this race.\n"); 1127 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Press any key for the next race.\nPress `d' to play this race.\n");
1157 return 0; 1128 return 0;
1158} 1129}
1159 1130
1160int 1131int
1161key_confirm_quit (object *op, char key) 1132key_confirm_quit (object *op, char key)
1426 /* question: don't pick up known-poisonous stuff? */ 1397 /* question: don't pick up known-poisonous stuff? */
1427 if (op->contr->mode & PU_FOOD) 1398 if (op->contr->mode & PU_FOOD)
1428 if (tmp->type == FOOD) 1399 if (tmp->type == FOOD)
1429 { 1400 {
1430 pick_up (op, tmp); 1401 pick_up (op, tmp);
1431 if (0)
1432 fprintf (stderr, "FOOD\n");
1433 continue; 1402 continue;
1434 } 1403 }
1404
1435 if (op->contr->mode & PU_DRINK) 1405 if (op->contr->mode & PU_DRINK)
1436 if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))) 1406 if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)))
1437 { 1407 {
1438 pick_up (op, tmp); 1408 pick_up (op, tmp);
1439 if (0)
1440 fprintf (stderr, "DRINK\n");
1441 continue; 1409 continue;
1442 } 1410 }
1443 1411
1444 if (op->contr->mode & PU_POTION) 1412 if (op->contr->mode & PU_POTION)
1445 if (tmp->type == POTION) 1413 if (tmp->type == POTION)
1446 { 1414 {
1447 pick_up (op, tmp); 1415 pick_up (op, tmp);
1448 if (0)
1449 fprintf (stderr, "POTION\n");
1450 continue; 1416 continue;
1451 } 1417 }
1452 1418
1453 /* spellbooks, skillscrolls and normal books/scrolls */ 1419 /* spellbooks, skillscrolls and normal books/scrolls */
1454 if (op->contr->mode & PU_SPELLBOOK) 1420 if (op->contr->mode & PU_SPELLBOOK)
1455 if (tmp->type == SPELLBOOK) 1421 if (tmp->type == SPELLBOOK)
1456 { 1422 {
1457 pick_up (op, tmp); 1423 pick_up (op, tmp);
1458 if (0)
1459 fprintf (stderr, "SPELLBOOK\n");
1460 continue; 1424 continue;
1461 } 1425 }
1426
1462 if (op->contr->mode & PU_SKILLSCROLL) 1427 if (op->contr->mode & PU_SKILLSCROLL)
1463 if (tmp->type == SKILLSCROLL) 1428 if (tmp->type == SKILLSCROLL)
1464 { 1429 {
1465 pick_up (op, tmp); 1430 pick_up (op, tmp);
1466 if (0)
1467 fprintf (stderr, "SKILLSCROLL\n");
1468 continue; 1431 continue;
1469 } 1432 }
1433
1470 if (op->contr->mode & PU_READABLES) 1434 if (op->contr->mode & PU_READABLES)
1471 if (tmp->type == BOOK || tmp->type == SCROLL) 1435 if (tmp->type == BOOK || tmp->type == SCROLL)
1472 { 1436 {
1473 pick_up (op, tmp); 1437 pick_up (op, tmp);
1474 if (0)
1475 fprintf (stderr, "READABLES\n");
1476 continue; 1438 continue;
1477 } 1439 }
1478 1440
1479 /* wands/staves/rods/horns */ 1441 /* wands/staves/rods/horns */
1480 if (op->contr->mode & PU_MAGIC_DEVICE) 1442 if (op->contr->mode & PU_MAGIC_DEVICE)
1481 if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) 1443 if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN)
1482 { 1444 {
1483 pick_up (op, tmp); 1445 pick_up (op, tmp);
1484 if (0)
1485 fprintf (stderr, "MAGIC_DEVICE\n");
1486 continue; 1446 continue;
1487 } 1447 }
1488 1448
1489 /* pick up all magical items */ 1449 /* pick up all magical items */
1490 if (op->contr->mode & PU_MAGICAL) 1450 if (op->contr->mode & PU_MAGICAL)
1491 if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) 1451 if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))
1492 { 1452 {
1493 pick_up (op, tmp); 1453 pick_up (op, tmp);
1494 if (0)
1495 fprintf (stderr, "MAGICAL\n");
1496 continue; 1454 continue;
1497 } 1455 }
1498 1456
1499 if (op->contr->mode & PU_VALUABLES) 1457 if (op->contr->mode & PU_VALUABLES)
1500 { 1458 {
1501 if (tmp->type == MONEY || tmp->type == GEM) 1459 if (tmp->type == MONEY || tmp->type == GEM)
1502 { 1460 {
1503 pick_up (op, tmp); 1461 pick_up (op, tmp);
1504 if (0)
1505 fprintf (stderr, "MONEY/GEM\n");
1506 continue; 1462 continue;
1507 } 1463 }
1508 } 1464 }
1509 1465
1510 /* rings & amulets - talismans seems to be typed AMULET */ 1466 /* rings & amulets - talismans seems to be typed AMULET */
1511 if (op->contr->mode & PU_JEWELS) 1467 if (op->contr->mode & PU_JEWELS)
1512 if (tmp->type == RING || tmp->type == AMULET) 1468 if (tmp->type == RING || tmp->type == AMULET)
1513 { 1469 {
1514 pick_up (op, tmp); 1470 pick_up (op, tmp);
1471 continue;
1515 if (0) 1472 }
1516 fprintf (stderr, "JEWELS\n"); 1473
1474 /* we don't forget dragon food */
1475 if (op->contr->mode & PU_FLESH)
1476 if (tmp->type == FLESH)
1477 {
1478 pick_up (op, tmp);
1517 continue; 1479 continue;
1518 } 1480 }
1519 1481
1520 /* bows and arrows. Bows are good for selling! */ 1482 /* bows and arrows. Bows are good for selling! */
1521 if (op->contr->mode & PU_BOW) 1483 if (op->contr->mode & PU_BOW)
1522 if (tmp->type == BOW) 1484 if (tmp->type == BOW)
1523 { 1485 {
1524 pick_up (op, tmp); 1486 pick_up (op, tmp);
1525 if (0)
1526 fprintf (stderr, "BOW\n");
1527 continue; 1487 continue;
1528 } 1488 }
1489
1529 if (op->contr->mode & PU_ARROW) 1490 if (op->contr->mode & PU_ARROW)
1530 if (tmp->type == ARROW) 1491 if (tmp->type == ARROW)
1531 { 1492 {
1532 pick_up (op, tmp); 1493 pick_up (op, tmp);
1533 if (0)
1534 fprintf (stderr, "ARROW\n");
1535 continue; 1494 continue;
1536 } 1495 }
1537 1496
1538 /* all kinds of armor etc. */ 1497 /* all kinds of armor etc. */
1539 if (op->contr->mode & PU_ARMOUR) 1498 if (op->contr->mode & PU_ARMOUR)
1540 if (tmp->type == ARMOUR) 1499 if (tmp->type == ARMOUR)
1541 { 1500 {
1542 pick_up (op, tmp); 1501 pick_up (op, tmp);
1543 if (0)
1544 fprintf (stderr, "ARMOUR\n");
1545 continue; 1502 continue;
1546 } 1503 }
1504
1547 if (op->contr->mode & PU_HELMET) 1505 if (op->contr->mode & PU_HELMET)
1548 if (tmp->type == HELMET) 1506 if (tmp->type == HELMET)
1549 { 1507 {
1550 pick_up (op, tmp); 1508 pick_up (op, tmp);
1551 if (0)
1552 fprintf (stderr, "HELMET\n");
1553 continue; 1509 continue;
1554 } 1510 }
1511
1555 if (op->contr->mode & PU_SHIELD) 1512 if (op->contr->mode & PU_SHIELD)
1556 if (tmp->type == SHIELD) 1513 if (tmp->type == SHIELD)
1557 { 1514 {
1558 pick_up (op, tmp); 1515 pick_up (op, tmp);
1559 if (0)
1560 fprintf (stderr, "SHIELD\n");
1561 continue; 1516 continue;
1562 } 1517 }
1518
1563 if (op->contr->mode & PU_BOOTS) 1519 if (op->contr->mode & PU_BOOTS)
1564 if (tmp->type == BOOTS) 1520 if (tmp->type == BOOTS)
1565 { 1521 {
1566 pick_up (op, tmp); 1522 pick_up (op, tmp);
1567 if (0)
1568 fprintf (stderr, "BOOTS\n");
1569 continue; 1523 continue;
1570 } 1524 }
1525
1571 if (op->contr->mode & PU_GLOVES) 1526 if (op->contr->mode & PU_GLOVES)
1572 if (tmp->type == GLOVES) 1527 if (tmp->type == GLOVES)
1573 { 1528 {
1574 pick_up (op, tmp); 1529 pick_up (op, tmp);
1575 if (0)
1576 fprintf (stderr, "GLOVES\n");
1577 continue; 1530 continue;
1578 } 1531 }
1532
1579 if (op->contr->mode & PU_CLOAK) 1533 if (op->contr->mode & PU_CLOAK)
1580 if (tmp->type == CLOAK) 1534 if (tmp->type == CLOAK)
1581 { 1535 {
1582 pick_up (op, tmp); 1536 pick_up (op, tmp);
1583 if (0)
1584 fprintf (stderr, "GLOVES\n");
1585 continue; 1537 continue;
1586 } 1538 }
1587 1539
1588 /* hoping to catch throwing daggers here */ 1540 /* hoping to catch throwing daggers here */
1589 if (op->contr->mode & PU_MISSILEWEAPON) 1541 if (op->contr->mode & PU_MISSILEWEAPON)
1590 if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) 1542 if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN))
1591 { 1543 {
1592 pick_up (op, tmp); 1544 pick_up (op, tmp);
1593 if (0)
1594 fprintf (stderr, "MISSILEWEAPON\n");
1595 continue; 1545 continue;
1596 } 1546 }
1597 1547
1598 /* careful: chairs and tables are weapons! */ 1548 /* careful: chairs and tables are weapons! */
1599 if (op->contr->mode & PU_ALLWEAPON) 1549 if (op->contr->mode & PU_ALLWEAPON)
1602 { 1552 {
1603 if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->name, "table") == NULL && 1553 if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->name, "table") == NULL &&
1604 strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL) 1554 strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL)
1605 { 1555 {
1606 pick_up (op, tmp); 1556 pick_up (op, tmp);
1607 if (0)
1608 fprintf (stderr, "WEAPON\n");
1609 continue; 1557 continue;
1610 } 1558 }
1611 } 1559 }
1560
1612 if (tmp->type == WEAPON && tmp->name == NULL) 1561 if (tmp->type == WEAPON && tmp->name == NULL)
1613 { 1562 {
1614 if (strstr (tmp->arch->name, "table") == NULL && strstr (tmp->arch->name, "chair") == NULL) 1563 if (strstr (tmp->arch->name, "table") == NULL && strstr (tmp->arch->name, "chair") == NULL)
1615 { 1564 {
1616 pick_up (op, tmp); 1565 pick_up (op, tmp);
1617 if (0)
1618 fprintf (stderr, "WEAPON\n");
1619 continue; 1566 continue;
1620 } 1567 }
1621 } 1568 }
1622 } 1569 }
1623 1570
1624 /* misc stuff that's useful */ 1571 /* misc stuff that's useful */
1625 if (op->contr->mode & PU_KEY) 1572 if (op->contr->mode & PU_KEY)
1626 if (tmp->type == KEY || tmp->type == SPECIAL_KEY) 1573 if (tmp->type == KEY || tmp->type == SPECIAL_KEY)
1627 { 1574 {
1628 pick_up (op, tmp); 1575 pick_up (op, tmp);
1629 if (0)
1630 fprintf (stderr, "KEY\n");
1631 continue; 1576 continue;
1632 } 1577 }
1633 1578
1634 /* any of the last 4 bits set means we use the ratio for value 1579 /* any of the last 4 bits set means we use the ratio for value
1635 * pickups */ 1580 * pickups */
1657 continue; 1602 continue;
1658 } 1603 }
1659 } 1604 }
1660 } /* the new pickup model */ 1605 } /* the new pickup model */
1661 } 1606 }
1607
1662 return !stop; 1608 return !stop;
1663} 1609}
1664 1610
1665/* 1611/*
1666 * Find an arrow in the inventory and after that 1612 * Find an arrow in the inventory and after that
1900 } 1846 }
1901 1847
1902 /* this should not happen, but sometimes does */ 1848 /* this should not happen, but sometimes does */
1903 if (arrow->nrof == 0) 1849 if (arrow->nrof == 0)
1904 { 1850 {
1905 remove_ob (arrow); 1851 arrow->destroy ();
1906 free_object (arrow);
1907 return 0; 1852 return 0;
1908 } 1853 }
1909 1854
1910 left = arrow; /* these are arrows left to the player */ 1855 left = arrow; /* these are arrows left to the player */
1911 arrow = get_split_ob (arrow, 1); 1856 arrow = get_split_ob (arrow, 1);
1912 if (arrow == NULL) 1857 if (arrow == NULL)
1913 { 1858 {
1914 new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); 1859 new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race);
1915 return 0; 1860 return 0;
1916 } 1861 }
1917 set_owner (arrow, op); 1862 arrow->set_owner (op);
1918 arrow->skill = bow->skill; 1863 arrow->skill = bow->skill;
1919 1864
1920 arrow->direction = dir; 1865 arrow->direction = dir;
1921 arrow->x = sx; 1866 arrow->x = sx;
1922 arrow->y = sy; 1867 arrow->y = sy;
2130 case range_misc: 2075 case range_misc:
2131 fire_misc_object (op, dir); 2076 fire_misc_object (op, dir);
2132 return; 2077 return;
2133 2078
2134 case range_golem: /* Control summoned monsters from scrolls */ 2079 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) 2080 if (QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED))
2136 { 2081 {
2137 op->contr->ranges[range_golem] = NULL; 2082 op->contr->ranges[range_golem] = 0;
2138 op->contr->shoottype = range_none; 2083 op->contr->shoottype = range_none;
2139 op->contr->golem_count = 0;
2140 } 2084 }
2141 else 2085 else
2142 control_golem (op->contr->ranges[range_golem], dir); 2086 control_golem (op->contr->ranges[range_golem], dir);
2143 return; 2087 return;
2144 2088
2390 * player owns it and it is either friendly or unagressive. 2334 * player owns it and it is either friendly or unagressive.
2391 */ 2335 */
2392 if ((op->type == PLAYER) 2336 if ((op->type == PLAYER)
2393#if COZY_SERVER 2337#if COZY_SERVER
2394 && 2338 &&
2395 ((get_owner (mon) && get_owner (mon)->contr 2339 ((mon->owner && mon->owner->contr
2396 && same_party (get_owner (mon)->contr->party, op->contr->party)) || get_owner (mon) == op) 2340 && same_party (mon->owner->contr->party, op->contr->party)) || mon->owner == op)
2397#else 2341#else
2398 && get_owner (mon) == op 2342 && mon->owner == op
2399#endif 2343#endif
2400 && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) 2344 && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)))
2401 { 2345 {
2402 /* If we're braced, we don't want to switch places with it */ 2346 /* If we're braced, we don't want to switch places with it */
2403 if (op->contr->braced) 2347 if (op->contr->braced)
2590 /* I've been seeing crashes where the golem has been destroyed, but 2534 /* 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 2535 * 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 2536 * 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. 2537 * put this in a a workaround to clean up the golem pointer.
2594 */ 2538 */
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))) 2539 if (op->contr->ranges[range_golem] && QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED))
2597 {
2598 op->contr->ranges[range_golem] = NULL; 2540 op->contr->ranges[range_golem] = 0;
2599 op->contr->golem_count = 0;
2600 }
2601 2541
2602 /* call this here - we also will call this in do_ericserver, but 2542 /* call this here - we also will call this in do_ericserver, but
2603 * the players time has been increased when doericserver has been 2543 * the players time has been increased when doericserver has been
2604 * called, so we recheck it here. 2544 * called, so we recheck it here.
2605 */ 2545 */
2606 HandleClient (&op->contr->socket, op->contr); 2546 HandleClient (op->contr->socket, op->contr);
2607 if (op->speed_left < 0) 2547 if (op->speed_left < 0)
2608 return 0; 2548 return 0;
2609 2549
2610 if (op->direction && (op->contr->run_on || op->contr->fire_on)) 2550 if (op->direction && (op->contr->run_on || op->contr->fire_on))
2611 { 2551 {
2636 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 2576 for (tmp = op->inv; tmp != NULL; tmp = tmp->below)
2637 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) 2577 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE))
2638 { 2578 {
2639 play_sound_map (op->map, op->x, op->y, SOUND_OB_EVAPORATE); 2579 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)); 2580 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp));
2581
2641 if (op->contr) 2582 if (op->contr)
2642 esrv_del_item (op->contr, tmp->count); 2583 esrv_del_item (op->contr, tmp->count);
2643 remove_ob (tmp); 2584
2644 free_object (tmp); 2585 tmp->destroy ();
2645 CLEAR_FLAG (op, FLAG_LIFESAVE); 2586 CLEAR_FLAG (op, FLAG_LIFESAVE);
2587
2646 if (op->stats.hp < 0) 2588 if (op->stats.hp < 0)
2647 op->stats.hp = op->stats.maxhp; 2589 op->stats.hp = op->stats.maxhp;
2590
2648 if (op->stats.food < 0) 2591 if (op->stats.food < 0)
2649 op->stats.food = 999; 2592 op->stats.food = 999;
2593
2650 fix_player (op); 2594 fix_player (op);
2651 return 1; 2595 return 1;
2652 } 2596 }
2653 LOG (llevError, "Error: LIFESAVE set without applied object.\n"); 2597 LOG (llevError, "Error: LIFESAVE set without applied object.\n");
2654 CLEAR_FLAG (op, FLAG_LIFESAVE); 2598 CLEAR_FLAG (op, FLAG_LIFESAVE);
2671 next = op->below; /* Make sure we have a good value, in case 2615 next = op->below; /* Make sure we have a good value, in case
2672 * we remove object 'op' 2616 * we remove object 'op'
2673 */ 2617 */
2674 if (QUERY_FLAG (op, FLAG_UNPAID)) 2618 if (QUERY_FLAG (op, FLAG_UNPAID))
2675 { 2619 {
2676 remove_ob (op); 2620 op->remove ();
2677 op->x = env->x; 2621 op->x = env->x;
2678 op->y = env->y; 2622 op->y = env->y;
2679 if (env->type == PLAYER) 2623 if (env->type == PLAYER)
2680 esrv_del_item (env->contr, op->count); 2624 esrv_del_item (env->contr, op->count);
2681 insert_ob_in_map (op, env->map, NULL, 0); 2625 insert_ob_in_map (op, env->map, NULL, 0);
2978 /* restore player */ 2922 /* restore player */
2979 at = archetype::find ("poisoning"); 2923 at = archetype::find ("poisoning");
2980 tmp = present_arch_in_ob (at, op); 2924 tmp = present_arch_in_ob (at, op);
2981 if (tmp) 2925 if (tmp)
2982 { 2926 {
2983 remove_ob (tmp); 2927 tmp->destroy ();
2984 free_object (tmp);
2985 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); 2928 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed");
2986 } 2929 }
2987 2930
2988 at = archetype::find ("confusion"); 2931 at = archetype::find ("confusion");
2989 tmp = present_arch_in_ob (at, op); 2932 tmp = present_arch_in_ob (at, op);
2990 if (tmp) 2933 if (tmp)
2991 { 2934 {
2992 remove_ob (tmp); 2935 tmp->destroy ();
2993 free_object (tmp);
2994 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); 2936 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer");
2995 } 2937 }
2996 2938
2997 cure_disease (op, 0); /* remove any disease */ 2939 cure_disease (op, 0); /* remove any disease */
2998 op->stats.hp = op->stats.maxhp; 2940 op->stats.hp = op->stats.maxhp;
3175 /* determine_god() seems to not work sometimes... why is this? 3117 /* determine_god() seems to not work sometimes... why is this?
3176 Should I be using something else? GD */ 3118 Should I be using something else? GD */
3177 const char *god = determine_god (op); 3119 const char *god = determine_god (op);
3178 3120
3179 if (god && (strcmp (god, "none"))) 3121 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); 3122 new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief moment you feel the holy presence of %s protecting" " you.", god);
3181 else 3123 else
3182 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you."); 3124 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you.");
3183 } 3125 }
3126#else
3127 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely.");
3184#endif 3128#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 3129
3187 /* Put a gravestone up where the character 'almost' died. List the 3130 /* Put a gravestone up where the character 'almost' died. List the
3188 * exp loss on the stone. 3131 * exp loss on the stone.
3189 */ 3132 */
3190 tmp = arch_to_object (archetype::find ("gravestone")); 3133 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); 3138 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; 3139 tmp->msg = buf;
3197 tmp->x = op->x, tmp->y = op->y; 3140 tmp->x = op->x, tmp->y = op->y;
3198 insert_ob_in_map (tmp, op->map, NULL, 0); 3141 insert_ob_in_map (tmp, op->map, NULL, 0);
3199 3142
3200 /**************************************/ 3143 /**************************************/
3201 /* */ 3144 /* */
3202 /* Subtract the experience points, */ 3145 /* Subtract the experience points, */
3203 /* if we died cause of food, give us */ 3146 /* if we died cause of food, give us */
3204 /* food, and reset HP's... */ 3147 /* food, and reset HP's... */
3205 /* */ 3148 /* */
3206
3207 /**************************************/ 3149 /**************************************/
3208 3150
3209 /* remove any poisoning and confusion the character may be suffering. */ 3151 /* remove any poisoning and confusion the character may be suffering. */
3210 /* restore player */ 3152 /* restore player */
3211 at = archetype::find ("poisoning"); 3153 at = archetype::find ("poisoning");
3212 tmp = present_arch_in_ob (at, op); 3154 tmp = present_arch_in_ob (at, op);
3155
3213 if (tmp) 3156 if (tmp)
3214 { 3157 {
3215 remove_ob (tmp); 3158 tmp->destroy ();
3216 free_object (tmp);
3217 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); 3159 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed");
3218 } 3160 }
3219 3161
3220 at = archetype::find ("confusion"); 3162 at = archetype::find ("confusion");
3221 tmp = present_arch_in_ob (at, op); 3163 tmp = present_arch_in_ob (at, op);
3222 if (tmp) 3164 if (tmp)
3223 { 3165 {
3224 remove_ob (tmp); 3166 tmp->destroy ();
3225 free_object (tmp);
3226 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); 3167 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer");
3227 } 3168 }
3169
3228 cure_disease (op, 0); /* remove any disease */ 3170 cure_disease (op, 0); /* remove any disease */
3229 3171
3230 /*add_exp(op, (op->stats.exp * -0.20)); */ 3172 /*add_exp(op, (op->stats.exp * -0.20)); */
3231 apply_death_exp_penalty (op); 3173 apply_death_exp_penalty (op);
3232 if (op->stats.food < 100) 3174 if (op->stats.food < 100)
3242 */ 3184 */
3243 3185
3244 if (is_in_shop (op)) 3186 if (is_in_shop (op))
3245 remove_unpaid_objects (op->inv, op); 3187 remove_unpaid_objects (op->inv, op);
3246 3188
3247 /****************************************/ 3189 /****************************************/
3248 /* */ 3190 /* */
3249 /* Move player to his current respawn- */ 3191 /* Move player to his current respawn- */
3250 /* position (usually last savebed) */ 3192 /* position (usually last savebed) */
3251 /* */ 3193 /* */
3252
3253 /****************************************/ 3194 /****************************************/
3254 3195
3255 enter_player_savebed (op); 3196 enter_player_savebed (op);
3256 3197
3257 /* Save the player before inserting the force to reduce 3198 /* Save the player before inserting the force to reduce
3258 * chance of abuse. 3199 * chance of abuse.
3265 * spell effects. So first see if there is a spell effect 3206 * spell effects. So first see if there is a spell effect
3266 * on the space that might harm the player. 3207 * on the space that might harm the player.
3267 */ 3208 */
3268 will_kill_again = 0; 3209 will_kill_again = 0;
3269 for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above) 3210 for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above)
3270 {
3271 if (tmp->type == SPELL_EFFECT) 3211 if (tmp->type == SPELL_EFFECT)
3272 will_kill_again |= tmp->attacktype; 3212 will_kill_again |= tmp->attacktype;
3273 } 3213
3274 if (will_kill_again) 3214 if (will_kill_again)
3275 { 3215 {
3276 object *force; 3216 object *force;
3277 int at; 3217 int at;
3278 3218
3280 /* 50 ticks should be enough time for the spell to abate */ 3220 /* 50 ticks should be enough time for the spell to abate */
3281 force->speed = 0.1; 3221 force->speed = 0.1;
3282 force->speed_left = -5.0; 3222 force->speed_left = -5.0;
3283 SET_FLAG (force, FLAG_APPLIED); 3223 SET_FLAG (force, FLAG_APPLIED);
3284 for (at = 0; at < NROFATTACKS; at++) 3224 for (at = 0; at < NROFATTACKS; at++)
3285 {
3286 if (will_kill_again & (1 << at)) 3225 if (will_kill_again & (1 << at))
3287 force->resist[at] = 100; 3226 force->resist[at] = 100;
3288 } 3227
3289 insert_ob_in_ob (force, op); 3228 insert_ob_in_ob (force, op);
3290 fix_player (op); 3229 fix_player (op);
3291 3230
3292 } 3231 }
3293 3232
3303 op->contr->party = NULL; 3242 op->contr->party = NULL;
3304 if (settings.set_title == TRUE) 3243 if (settings.set_title == TRUE)
3305 op->contr->own_title[0] = '\0'; 3244 op->contr->own_title[0] = '\0';
3306 new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf); 3245 new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf);
3307 check_score (op); 3246 check_score (op);
3247
3308 if (op->contr->ranges[range_golem] != NULL) 3248 if (op->contr->ranges[range_golem])
3309 { 3249 {
3310 remove_friendly_object (op->contr->ranges[range_golem]); 3250 remove_friendly_object (op->contr->ranges[range_golem]);
3311 remove_ob (op->contr->ranges[range_golem]); 3251 op->contr->ranges[range_golem]->destroy ();
3312 free_object (op->contr->ranges[range_golem]);
3313 op->contr->ranges[range_golem] = NULL; 3252 op->contr->ranges[range_golem] = 0;
3314 op->contr->golem_count = 0;
3315 } 3253 }
3254
3316 loot_object (op); /* Remove some of the items for good */ 3255 loot_object (op); /* Remove some of the items for good */
3317 remove_ob (op); 3256 op->remove ();
3318 op->direction = 0; 3257 op->direction = 0;
3319 3258
3320 if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp) 3259 if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp)
3321 { 3260 {
3322 delete_character (op->name, 0); 3261 delete_character (op->name, 0);
3375 for (tmp = op->inv; tmp != NULL; tmp = next) 3314 for (tmp = op->inv; tmp != NULL; tmp = next)
3376 { 3315 {
3377 next = tmp->below; 3316 next = tmp->below;
3378 if (tmp->type == EXPERIENCE || tmp->invisible) 3317 if (tmp->type == EXPERIENCE || tmp->invisible)
3379 continue; 3318 continue;
3380 remove_ob (tmp); 3319 tmp->remove ();
3381 tmp->x = op->x, tmp->y = op->y; 3320 tmp->x = op->x, tmp->y = op->y;
3382 if (tmp->type == CONTAINER) 3321 if (tmp->type == CONTAINER)
3383 { /* empty container to ground */ 3322 { /* empty container to ground */
3384 loot_object (tmp); 3323 loot_object (tmp);
3385 } 3324 }
3386 if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(RANDOM () % 3))) 3325 if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(RANDOM () % 3)))
3387 { 3326 {
3388 if (tmp->nrof > 1) 3327 if (tmp->nrof > 1)
3389 { 3328 {
3390 tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); 3329 tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1));
3391 free_object (tmp2); 3330 tmp2->destroy ();
3392 insert_ob_in_map (tmp, op->map, NULL, 0); 3331 insert_ob_in_map (tmp, op->map, NULL, 0);
3393 } 3332 }
3394 else 3333 else
3395 free_object (tmp); 3334 tmp->destroy ();
3396 } 3335 }
3397 else 3336 else
3398 insert_ob_in_map (tmp, op->map, NULL, 0); 3337 insert_ob_in_map (tmp, op->map, NULL, 0);
3399 } 3338 }
3400} 3339}
3465 if (op->type == PLAYER) 3404 if (op->type == PLAYER)
3466 new_draw_info_format (NDI_UNIQUE, 0, op, "You cast %s.", &spob->name); 3405 new_draw_info_format (NDI_UNIQUE, 0, op, "You cast %s.", &spob->name);
3467 3406
3468 cast_spell (op, throw_ob, dir, spob, NULL); 3407 cast_spell (op, throw_ob, dir, spob, NULL);
3469 3408
3470 if (!QUERY_FLAG (throw_ob, FLAG_REMOVED)) 3409 throw_ob->destroy ();
3471 remove_ob (throw_ob);
3472 free_object (throw_ob);
3473} 3410}
3474 3411
3475void 3412void
3476make_visible (object *op) 3413make_visible (object *op)
3477{ 3414{
3684 3621
3685 /* only the viewable area the player sees is updated by LOS 3622 /* only the viewable area the player sees is updated by LOS
3686 * code, so we need to restrict ourselves to that range of values 3623 * code, so we need to restrict ourselves to that range of values
3687 * for any meaningful values. 3624 * for any meaningful values.
3688 */ 3625 */
3689 if (FABS (dx) <= (pl->contr->socket.mapx / 2) && 3626 if (FABS (dx) <= (pl->contr->socket->mapx / 2) &&
3690 FABS (dy) <= (pl->contr->socket.mapy / 2) && 3627 FABS (dy) <= (pl->contr->socket->mapy / 2) &&
3691 !pl->contr->blocked_los[dx + (pl->contr->socket.mapx / 2)][dy + (pl->contr->socket.mapy / 2)]) 3628 !pl->contr->blocked_los[dx + (pl->contr->socket->mapx / 2)][dy + (pl->contr->socket->mapy / 2)])
3692 return 1; 3629 return 1;
3693 op = op->more; 3630 op = op->more;
3694 } 3631 }
3695 return 0; 3632 return 0;
3696} 3633}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines