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.25 by root, Sat Sep 16 22:24:13 2006 UTC vs.
Revision 1.43 by root, Sat Dec 16 03:08:26 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>
36#include <newclient.h>
37 32
38#ifdef COZY_SERVER 33#ifdef COZY_SERVER
39extern int same_party (partylist *a, partylist *b); 34extern int same_party (partylist *a, partylist *b);
40#endif 35#endif
41 36
208 * the one that is passed. 203 * the one that is passed.
209 */ 204 */
210static player * 205static player *
211get_player (player *p) 206get_player (player *p)
212{ 207{
213 object *op = arch_to_object (get_player_archetype (NULL)); 208 object *op = arch_to_object (get_player_archetype (0));
214 int i; 209 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 210
238 /* Clears basically the entire player structure except 211 /* Clears basically the entire player structure except
239 * for next and socket. 212 * for next and socket.
240 */ 213 */
241 p->clear (); 214 p->clear ();
260 op->speed_left = 0.5; 233 op->speed_left = 0.5;
261 op->speed = 1.0; 234 op->speed = 1.0;
262 op->direction = 5; /* So player faces south */ 235 op->direction = 5; /* So player faces south */
263 op->stats.wc = 2; 236 op->stats.wc = 2;
264 op->run_away = 25; /* Then we panick... */ 237 op->run_away = 25; /* Then we panick... */
238
239 {
240 int oldmon = p->socket->monitor_spells; // what a hack
265 p->socket.monitor_spells = 0; /* Needed because esrv_update_spells( ) gets called by roll_stats */ 241 p->socket->monitor_spells = 0; /* Needed because esrv_update_spells( ) gets called by roll_stats */
266
267 roll_stats (op); 242 roll_stats (op);
243 p->socket->monitor_spells = oldmon;
244 }
268 p->state = ST_ROLL_STAT; 245 p->state = ST_ROLL_STAT;
269 clear_los (op); 246 clear_los (op);
270 247
271 p->gen_sp_armour = 10; 248 p->gen_sp_armour = 10;
272 p->last_speed = -1; 249 p->last_speed = -1;
294 for (i = 0; i < NUM_SKILLS; i++) 271 for (i = 0; i < NUM_SKILLS; i++)
295 { 272 {
296 p->last_skill_exp[i] = -1; 273 p->last_skill_exp[i] = -1;
297 p->last_skill_ob[i] = NULL; 274 p->last_skill_ob[i] = NULL;
298 } 275 }
276
299 for (i = 0; i < NROFATTACKS; i++) 277 for (i = 0; i < NROFATTACKS; i++)
300 {
301 p->last_resist[i] = -1; 278 p->last_resist[i] = -1;
302 } 279
303 p->last_stats.exp = -1; 280 p->last_stats.exp = -1;
304 p->last_weight = (uint32) - 1; 281 p->last_weight = (uint32) - 1;
305 282
306 p->socket.update_look = 0; 283 p->socket->update_look = 0;
307 p->socket.look_position = 0; 284 p->socket->look_position = 0;
285
308 return p; 286 return p;
309} 287}
310 288
311/* This loads the first map an puts the player on it. */ 289/* This loads the first map an puts the player on it. */
312static void 290static void
322 * All we can really get in this is some settings like host and display 300 * All we can really get in this is some settings like host and display
323 * mode. 301 * mode.
324 */ 302 */
325 303
326int 304int
327add_player (NewSocket * ns) 305add_player (client *ns)
328{ 306{
329 player *p; 307 player *p = new player;
330 308
331 p = get_player (NULL);
332 p->socket = *ns; 309 p->socket = ns;
333 p->socket.faces_sent = (uint8 *) malloc (p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); 310 ns->pl = p;
334 if (p->socket.faces_sent == NULL) 311
335 fatal (OUT_OF_MEMORY); 312 p->next = first_player;
336 memcpy (p->socket.faces_sent, ns->faces_sent, p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); 313 first_player = p;
337 /* Needed because the socket we just copied over needs to be cleared. 314
338 * Note that this can result in a client reset if there is partial data 315 p = get_player (p);
339 * on the uncoming socket. 316
340 */
341 p->socket.inbuf.len = 0;
342 set_first_map (p->ob); 317 set_first_map (p->ob);
343 318
344 CLEAR_FLAG (p->ob, FLAG_FRIENDLY); 319 CLEAR_FLAG (p->ob, FLAG_FRIENDLY);
345 add_friendly_object (p->ob); 320 add_friendly_object (p->ob);
346 send_rules (p->ob); 321 send_rules (p->ob);
347 send_news (p->ob); 322 send_news (p->ob);
348 display_motd (p->ob); 323 display_motd (p->ob);
349 get_name (p->ob); 324 get_name (p->ob);
325
350 return 0; 326 return 0;
351} 327}
352 328
353/* 329/*
354 * get_player_archetype() return next player archetype from archetype 330 * get_player_archetype() return next player archetype from archetype
643 (op->type == ARMOUR || op->type == BOOTS || 619 (op->type == ARMOUR || op->type == BOOTS ||
644 op->type == CLOAK || op->type == HELMET || 620 op->type == CLOAK || op->type == HELMET ||
645 op->type == SHIELD || op->type == GLOVES || 621 op->type == SHIELD || op->type == GLOVES ||
646 op->type == BRACERS || op->type == GIRDLE)) || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON)) 622 op->type == BRACERS || op->type == GIRDLE)) || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON))
647 { 623 {
648 remove_ob (op); 624 op->destroy ();
649 free_object (op);
650 continue; 625 continue;
651 } 626 }
652 } 627 }
653 628
654 /* This really needs to be better - we should really give 629 /* This really needs to be better - we should really give
665 if (tmp->type == op->type && tmp->name == op->name) 640 if (tmp->type == op->type && tmp->name == op->name)
666 break; 641 break;
667 642
668 if (tmp) 643 if (tmp)
669 { 644 {
670 remove_ob (op); 645 op->destroy ();
671 free_object (op);
672 LOG (llevError, "give_initial_items: Removing duplicate object %s\n", &tmp->name); 646 LOG (llevError, "give_initial_items: Removing duplicate object %s\n", &tmp->name);
673 continue; 647 continue;
674 } 648 }
649
675 if (op->nrof > 1) 650 if (op->nrof > 1)
676 op->nrof = 1; 651 op->nrof = 1;
677 } 652 }
678 653
679 if (op->type == SPELLBOOK && op->inv) 654 if (op->type == SPELLBOOK && op->inv)
691 CLEAR_FLAG (op, FLAG_CURSED); 666 CLEAR_FLAG (op, FLAG_CURSED);
692 CLEAR_FLAG (op, FLAG_DAMNED); 667 CLEAR_FLAG (op, FLAG_DAMNED);
693 } 668 }
694 if (op->type == SPELL) 669 if (op->type == SPELL)
695 { 670 {
696 remove_ob (op); 671 op->destroy ();
697 free_object (op);
698 continue; 672 continue;
699 } 673 }
700 else if (op->type == SKILL) 674 else if (op->type == SKILL)
701 { 675 {
702 SET_FLAG (op, FLAG_CAN_USE_SKILL); 676 SET_FLAG (op, FLAG_CAN_USE_SKILL);
715void 689void
716get_name (object *op) 690get_name (object *op)
717{ 691{
718 op->contr->write_buf[0] = '\0'; 692 op->contr->write_buf[0] = '\0';
719 op->contr->state = ST_GET_NAME; 693 op->contr->state = ST_GET_NAME;
720 send_query (&op->contr->socket, 0, "What is your name?\n:"); 694 send_query (op->contr->socket, 0, "What is your name?\n:");
721} 695}
722 696
723void 697void
724get_password (object *op) 698get_password (object *op)
725{ 699{
726 op->contr->write_buf[0] = '\0'; 700 op->contr->write_buf[0] = '\0';
727 op->contr->state = ST_GET_PASSWORD; 701 op->contr->state = ST_GET_PASSWORD;
728 send_query (&op->contr->socket, CS_QUERY_HIDEINPUT, "What is your password?\n:"); 702 send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "What is your password?\n:");
729} 703}
730 704
731void 705void
732play_again (object *op) 706play_again (object *op)
733{ 707{
734 op->contr->state = ST_PLAY_AGAIN; 708 op->contr->state = ST_PLAY_AGAIN;
735 op->chosen_skill = NULL; 709 op->chosen_skill = NULL;
736 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Do you want to play again (a/q)?"); 710 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Do you want to play again (a/q)?");
737 /* a bit of a hack, but there are various places early in th 711 /* a bit of a hack, but there are various places early in th
738 * player creation process that a user can quit (eg, roll 712 * player creation process that a user can quit (eg, roll
739 * stats) that isn't removing the player. Taking a quick 713 * stats) that isn't removing the player. Taking a quick
740 * look, there are many places that call play_again without 714 * look, there are many places that call play_again without
741 * removing the player - it probably makes more sense 715 * removing the player - it probably makes more sense
742 * to leave it to play_again to remove the object in all 716 * to leave it to play_again to remove the object in all
743 * cases. 717 * cases.
744 */ 718 */
745 if (!QUERY_FLAG (op, FLAG_REMOVED)) 719 if (!QUERY_FLAG (op, FLAG_REMOVED))
746 remove_ob (op); 720 op->remove ();
747 /* Need to set this to null - otherwise, it could point to garbage, 721 /* 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 722 * and draw() doesn't check to see if the player is removed, only if
749 * the map is null or not swapped out. 723 * the map is null or not swapped out.
750 */ 724 */
751 op->map = NULL; 725 op->map = NULL;
765 player *pl = op->contr; 739 player *pl = op->contr;
766 shstr name = op->name; 740 shstr name = op->name;
767 741
768 op->contr = 0; 742 op->contr = 0;
769 op->type = 0; 743 op->type = 0;
770 op->free (1); 744 op->destroy (1);
771 pl = get_player (pl); 745 pl = get_player (pl);
772 op = pl->ob; 746 op = pl->ob;
773 add_friendly_object (op); 747 add_friendly_object (op);
774 op->contr->password[0] = '~'; 748 op->contr->password[0] = '~';
775 op->name = op->name_pl = 0; 749 op->name = op->name_pl = 0;
790confirm_password (object *op) 764confirm_password (object *op)
791{ 765{
792 766
793 op->contr->write_buf[0] = '\0'; 767 op->contr->write_buf[0] = '\0';
794 op->contr->state = ST_CONFIRM_PASSWORD; 768 op->contr->state = ST_CONFIRM_PASSWORD;
795 send_query (&op->contr->socket, CS_QUERY_HIDEINPUT, "Please type your password again.\n:"); 769 send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "Please type your password again.\n:");
796} 770}
797 771
798void 772void
799get_party_password (object *op, partylist *party) 773get_party_password (object *op, partylist *party)
800{ 774{
804 return; 778 return;
805 } 779 }
806 op->contr->write_buf[0] = '\0'; 780 op->contr->write_buf[0] = '\0';
807 op->contr->state = ST_GET_PARTY_PASSWORD; 781 op->contr->state = ST_GET_PARTY_PASSWORD;
808 op->contr->party_to_join = party; 782 op->contr->party_to_join = party;
809 send_query (&op->contr->socket, CS_QUERY_HIDEINPUT, "What is the password?\n:"); 783 send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "What is the password?\n:");
810} 784}
811 785
812 786
813/* This rolls four 1-6 rolls and sums the best 3 of the 4. */ 787/* This rolls four 1-6 rolls and sums the best 3 of the 4. */
814int 788int
911 885
912void 886void
913Roll_Again (object *op) 887Roll_Again (object *op)
914{ 888{
915 esrv_new_player (op->contr, 0); 889 esrv_new_player (op->contr, 0);
916 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, 890 send_query (op->contr->socket, CS_QUERY_SINGLECHAR,
917 "[y] to roll new stats [n] to use stats\n[1-7] [1-7] to swap stats.\nRoll again (y/n/1-7)? "); 891 "[y] to roll new stats [n] to use stats\n[1-7] [1-7] to swap stats.\nRoll again (y/n/1-7)? ");
918} 892}
919 893
920void 894void
921Swap_Stat (object *op, int Swap_Second) 895Swap_Stat (object *op, int Swap_Second)
988 new_draw_info (NDI_UNIQUE, 0, op, buf); 962 new_draw_info (NDI_UNIQUE, 0, op, buf);
989 } 963 }
990 else 964 else
991 Swap_Stat (op, stat_trans[keynum]); 965 Swap_Stat (op, stat_trans[keynum]);
992 966
993 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, ""); 967 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "");
994 return 1; 968 return 1;
995 } 969 }
996 switch (key) 970 switch (key)
997 { 971 {
998 case 'n': 972 case 'n':
1012 enter_exit (op, NULL); 986 enter_exit (op, NULL);
1013#endif 987#endif
1014 SET_ANIMATION (op, 2); /* So player faces south */ 988 SET_ANIMATION (op, 2); /* So player faces south */
1015 /* Enter exit adds a player otherwise */ 989 /* Enter exit adds a player otherwise */
1016 add_statbonus (op); 990 add_statbonus (op);
1017 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, 991 send_query (op->contr->socket, CS_QUERY_SINGLECHAR,
1018 "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n"); 992 "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n");
1019 op->contr->state = ST_CHANGE_CLASS; 993 op->contr->state = ST_CHANGE_CLASS;
1020 if (op->msg) 994 if (op->msg)
1021 new_draw_info (NDI_BLUE, 0, op, op->msg); 995 new_draw_info (NDI_BLUE, 0, op, op->msg);
1022 return 0; 996 return 0;
1023 } 997 }
1024 case 'y': 998 case 'y':
1025 case 'Y': 999 case 'Y':
1026 roll_stats (op); 1000 roll_stats (op);
1027 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, ""); 1001 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "");
1028 return 1; 1002 return 1;
1029 1003
1030 case 'q': 1004 case 'q':
1031 case 'Q': 1005 case 'Q':
1032 play_again (op); 1006 play_again (op);
1033 return 1; 1007 return 1;
1034 1008
1035 default: 1009 default:
1036 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?"); 1010 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?");
1037 return 0; 1011 return 0;
1038 } 1012 }
1039 return 0; 1013 return 0;
1040} 1014}
1041 1015
1051{ 1025{
1052 int tmp_loop; 1026 int tmp_loop;
1053 1027
1054 if (key == 'q' || key == 'Q') 1028 if (key == 'q' || key == 'Q')
1055 { 1029 {
1056 remove_ob (op); 1030 op->remove ();
1057 play_again (op); 1031 play_again (op);
1058 return 0; 1032 return 0;
1059 } 1033 }
1060 if (key == 'd' || key == 'D') 1034 if (key == 'd' || key == 'D')
1061 { 1035 {
1062 char buf[MAX_BUF]; 1036 char buf[MAX_BUF];
1063 1037
1064 /* this must before then initial items are given */ 1038 /* this must before then initial items are given */
1065 esrv_new_player (op->contr, op->weight + op->carrying); 1039 esrv_new_player (op->contr, op->weight + op->carrying);
1040
1066 create_treasure (find_treasurelist ("starting_wealth"), op, 0, 0, 0); 1041 treasurelist *tl = find_treasurelist ("starting_wealth");
1042 if (tl)
1043 create_treasure (tl, op, 0, 0, 0);
1067 1044
1068 INVOKE_PLAYER (BIRTH, op->contr); 1045 INVOKE_PLAYER (BIRTH, op->contr);
1069 INVOKE_PLAYER (LOGIN, op->contr); 1046 INVOKE_PLAYER (LOGIN, op->contr);
1070 1047
1071 op->contr->state = ST_PLAYING; 1048 op->contr->state = ST_PLAYING;
1096 { 1073 {
1097 object *tmp; 1074 object *tmp;
1098 char mapname[MAX_BUF]; 1075 char mapname[MAX_BUF];
1099 1076
1100 snprintf (mapname, MAX_BUF - 1, "%s/%s", first_map_ext_path, &op->arch->name); 1077 snprintf (mapname, MAX_BUF - 1, "%s/%s", first_map_ext_path, &op->arch->name);
1101 tmp = get_object (); 1078 tmp = object::create ();
1102 EXIT_PATH (tmp) = mapname; 1079 EXIT_PATH (tmp) = mapname;
1103 EXIT_X (tmp) = op->x; 1080 EXIT_X (tmp) = op->x;
1104 EXIT_Y (tmp) = op->y; 1081 EXIT_Y (tmp) = op->y;
1105 enter_exit (op, tmp); /* we don't really care if it succeeded; 1082 enter_exit (op, tmp); /* we don't really care if it succeeded;
1106 * if the map isn't there, then stay on the 1083 * if the map isn't there, then stay on the
1107 * default initial map */ 1084 * default initial map */
1108 free_object (tmp); 1085 tmp->destroy ();
1109 } 1086 }
1110 else 1087 else
1111 { 1088 {
1112 LOG (llevDebug, "first_map_ext_path not set\n"); 1089 LOG (llevDebug, "first_map_ext_path not set\n");
1113 } 1090 }
1123 { 1100 {
1124 shstr name = op->name; 1101 shstr name = op->name;
1125 int x = op->x, y = op->y; 1102 int x = op->x, y = op->y;
1126 1103
1127 remove_statbonus (op); 1104 remove_statbonus (op);
1128 remove_ob (op); 1105 op->remove ();
1129 op->arch = get_player_archetype (op->arch); 1106 op->arch = get_player_archetype (op->arch);
1130 copy_object (&op->arch->clone, op); 1107 op->arch->clone.copy_to (op);
1131 op->instantiate (); 1108 op->instantiate ();
1132 op->stats = op->contr->orig_stats; 1109 op->stats = op->contr->orig_stats;
1133 op->name = op->name_pl = name; 1110 op->name = op->name_pl = name;
1134 op->x = x; 1111 op->x = x;
1135 op->y = y; 1112 op->y = y;
1148 op->stats.grace = 0; 1125 op->stats.grace = 0;
1149 1126
1150 if (op->msg) 1127 if (op->msg)
1151 new_draw_info (NDI_BLUE, 0, op, op->msg); 1128 new_draw_info (NDI_BLUE, 0, op, op->msg);
1152 1129
1153 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Press any key for the next race.\nPress `d' to play this race.\n"); 1130 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Press any key for the next race.\nPress `d' to play this race.\n");
1154 return 0; 1131 return 0;
1155} 1132}
1156 1133
1157int 1134int
1158key_confirm_quit (object *op, char key) 1135key_confirm_quit (object *op, char key)
1423 /* question: don't pick up known-poisonous stuff? */ 1400 /* question: don't pick up known-poisonous stuff? */
1424 if (op->contr->mode & PU_FOOD) 1401 if (op->contr->mode & PU_FOOD)
1425 if (tmp->type == FOOD) 1402 if (tmp->type == FOOD)
1426 { 1403 {
1427 pick_up (op, tmp); 1404 pick_up (op, tmp);
1428 if (0)
1429 fprintf (stderr, "FOOD\n");
1430 continue; 1405 continue;
1431 } 1406 }
1407
1432 if (op->contr->mode & PU_DRINK) 1408 if (op->contr->mode & PU_DRINK)
1433 if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))) 1409 if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)))
1434 { 1410 {
1435 pick_up (op, tmp); 1411 pick_up (op, tmp);
1436 if (0)
1437 fprintf (stderr, "DRINK\n");
1438 continue; 1412 continue;
1439 } 1413 }
1440 1414
1441 if (op->contr->mode & PU_POTION) 1415 if (op->contr->mode & PU_POTION)
1442 if (tmp->type == POTION) 1416 if (tmp->type == POTION)
1443 { 1417 {
1444 pick_up (op, tmp); 1418 pick_up (op, tmp);
1445 if (0)
1446 fprintf (stderr, "POTION\n");
1447 continue; 1419 continue;
1448 } 1420 }
1449 1421
1450 /* spellbooks, skillscrolls and normal books/scrolls */ 1422 /* spellbooks, skillscrolls and normal books/scrolls */
1451 if (op->contr->mode & PU_SPELLBOOK) 1423 if (op->contr->mode & PU_SPELLBOOK)
1452 if (tmp->type == SPELLBOOK) 1424 if (tmp->type == SPELLBOOK)
1453 { 1425 {
1454 pick_up (op, tmp); 1426 pick_up (op, tmp);
1455 if (0)
1456 fprintf (stderr, "SPELLBOOK\n");
1457 continue; 1427 continue;
1458 } 1428 }
1429
1459 if (op->contr->mode & PU_SKILLSCROLL) 1430 if (op->contr->mode & PU_SKILLSCROLL)
1460 if (tmp->type == SKILLSCROLL) 1431 if (tmp->type == SKILLSCROLL)
1461 { 1432 {
1462 pick_up (op, tmp); 1433 pick_up (op, tmp);
1463 if (0)
1464 fprintf (stderr, "SKILLSCROLL\n");
1465 continue; 1434 continue;
1466 } 1435 }
1436
1467 if (op->contr->mode & PU_READABLES) 1437 if (op->contr->mode & PU_READABLES)
1468 if (tmp->type == BOOK || tmp->type == SCROLL) 1438 if (tmp->type == BOOK || tmp->type == SCROLL)
1469 { 1439 {
1470 pick_up (op, tmp); 1440 pick_up (op, tmp);
1471 if (0)
1472 fprintf (stderr, "READABLES\n");
1473 continue; 1441 continue;
1474 } 1442 }
1475 1443
1476 /* wands/staves/rods/horns */ 1444 /* wands/staves/rods/horns */
1477 if (op->contr->mode & PU_MAGIC_DEVICE) 1445 if (op->contr->mode & PU_MAGIC_DEVICE)
1478 if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) 1446 if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN)
1479 { 1447 {
1480 pick_up (op, tmp); 1448 pick_up (op, tmp);
1481 if (0)
1482 fprintf (stderr, "MAGIC_DEVICE\n");
1483 continue; 1449 continue;
1484 } 1450 }
1485 1451
1486 /* pick up all magical items */ 1452 /* pick up all magical items */
1487 if (op->contr->mode & PU_MAGICAL) 1453 if (op->contr->mode & PU_MAGICAL)
1488 if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) 1454 if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))
1489 { 1455 {
1490 pick_up (op, tmp); 1456 pick_up (op, tmp);
1491 if (0)
1492 fprintf (stderr, "MAGICAL\n");
1493 continue; 1457 continue;
1494 } 1458 }
1495 1459
1496 if (op->contr->mode & PU_VALUABLES) 1460 if (op->contr->mode & PU_VALUABLES)
1497 { 1461 {
1498 if (tmp->type == MONEY || tmp->type == GEM) 1462 if (tmp->type == MONEY || tmp->type == GEM)
1499 { 1463 {
1500 pick_up (op, tmp); 1464 pick_up (op, tmp);
1501 if (0)
1502 fprintf (stderr, "MONEY/GEM\n");
1503 continue; 1465 continue;
1504 } 1466 }
1505 } 1467 }
1506 1468
1507 /* rings & amulets - talismans seems to be typed AMULET */ 1469 /* rings & amulets - talismans seems to be typed AMULET */
1508 if (op->contr->mode & PU_JEWELS) 1470 if (op->contr->mode & PU_JEWELS)
1509 if (tmp->type == RING || tmp->type == AMULET) 1471 if (tmp->type == RING || tmp->type == AMULET)
1510 { 1472 {
1511 pick_up (op, tmp); 1473 pick_up (op, tmp);
1474 continue;
1512 if (0) 1475 }
1513 fprintf (stderr, "JEWELS\n"); 1476
1477 /* we don't forget dragon food */
1478 if (op->contr->mode & PU_FLESH)
1479 if (tmp->type == FLESH)
1480 {
1481 pick_up (op, tmp);
1514 continue; 1482 continue;
1515 } 1483 }
1516 1484
1517 /* bows and arrows. Bows are good for selling! */ 1485 /* bows and arrows. Bows are good for selling! */
1518 if (op->contr->mode & PU_BOW) 1486 if (op->contr->mode & PU_BOW)
1519 if (tmp->type == BOW) 1487 if (tmp->type == BOW)
1520 { 1488 {
1521 pick_up (op, tmp); 1489 pick_up (op, tmp);
1522 if (0)
1523 fprintf (stderr, "BOW\n");
1524 continue; 1490 continue;
1525 } 1491 }
1492
1526 if (op->contr->mode & PU_ARROW) 1493 if (op->contr->mode & PU_ARROW)
1527 if (tmp->type == ARROW) 1494 if (tmp->type == ARROW)
1528 { 1495 {
1529 pick_up (op, tmp); 1496 pick_up (op, tmp);
1530 if (0)
1531 fprintf (stderr, "ARROW\n");
1532 continue; 1497 continue;
1533 } 1498 }
1534 1499
1535 /* all kinds of armor etc. */ 1500 /* all kinds of armor etc. */
1536 if (op->contr->mode & PU_ARMOUR) 1501 if (op->contr->mode & PU_ARMOUR)
1537 if (tmp->type == ARMOUR) 1502 if (tmp->type == ARMOUR)
1538 { 1503 {
1539 pick_up (op, tmp); 1504 pick_up (op, tmp);
1540 if (0)
1541 fprintf (stderr, "ARMOUR\n");
1542 continue; 1505 continue;
1543 } 1506 }
1507
1544 if (op->contr->mode & PU_HELMET) 1508 if (op->contr->mode & PU_HELMET)
1545 if (tmp->type == HELMET) 1509 if (tmp->type == HELMET)
1546 { 1510 {
1547 pick_up (op, tmp); 1511 pick_up (op, tmp);
1548 if (0)
1549 fprintf (stderr, "HELMET\n");
1550 continue; 1512 continue;
1551 } 1513 }
1514
1552 if (op->contr->mode & PU_SHIELD) 1515 if (op->contr->mode & PU_SHIELD)
1553 if (tmp->type == SHIELD) 1516 if (tmp->type == SHIELD)
1554 { 1517 {
1555 pick_up (op, tmp); 1518 pick_up (op, tmp);
1556 if (0)
1557 fprintf (stderr, "SHIELD\n");
1558 continue; 1519 continue;
1559 } 1520 }
1521
1560 if (op->contr->mode & PU_BOOTS) 1522 if (op->contr->mode & PU_BOOTS)
1561 if (tmp->type == BOOTS) 1523 if (tmp->type == BOOTS)
1562 { 1524 {
1563 pick_up (op, tmp); 1525 pick_up (op, tmp);
1564 if (0)
1565 fprintf (stderr, "BOOTS\n");
1566 continue; 1526 continue;
1567 } 1527 }
1528
1568 if (op->contr->mode & PU_GLOVES) 1529 if (op->contr->mode & PU_GLOVES)
1569 if (tmp->type == GLOVES) 1530 if (tmp->type == GLOVES)
1570 { 1531 {
1571 pick_up (op, tmp); 1532 pick_up (op, tmp);
1572 if (0)
1573 fprintf (stderr, "GLOVES\n");
1574 continue; 1533 continue;
1575 } 1534 }
1535
1576 if (op->contr->mode & PU_CLOAK) 1536 if (op->contr->mode & PU_CLOAK)
1577 if (tmp->type == CLOAK) 1537 if (tmp->type == CLOAK)
1578 { 1538 {
1579 pick_up (op, tmp); 1539 pick_up (op, tmp);
1580 if (0)
1581 fprintf (stderr, "GLOVES\n");
1582 continue; 1540 continue;
1583 } 1541 }
1584 1542
1585 /* hoping to catch throwing daggers here */ 1543 /* hoping to catch throwing daggers here */
1586 if (op->contr->mode & PU_MISSILEWEAPON) 1544 if (op->contr->mode & PU_MISSILEWEAPON)
1587 if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) 1545 if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN))
1588 { 1546 {
1589 pick_up (op, tmp); 1547 pick_up (op, tmp);
1590 if (0)
1591 fprintf (stderr, "MISSILEWEAPON\n");
1592 continue; 1548 continue;
1593 } 1549 }
1594 1550
1595 /* careful: chairs and tables are weapons! */ 1551 /* careful: chairs and tables are weapons! */
1596 if (op->contr->mode & PU_ALLWEAPON) 1552 if (op->contr->mode & PU_ALLWEAPON)
1599 { 1555 {
1600 if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->name, "table") == NULL && 1556 if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->name, "table") == NULL &&
1601 strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL) 1557 strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL)
1602 { 1558 {
1603 pick_up (op, tmp); 1559 pick_up (op, tmp);
1604 if (0)
1605 fprintf (stderr, "WEAPON\n");
1606 continue; 1560 continue;
1607 } 1561 }
1608 } 1562 }
1563
1609 if (tmp->type == WEAPON && tmp->name == NULL) 1564 if (tmp->type == WEAPON && tmp->name == NULL)
1610 { 1565 {
1611 if (strstr (tmp->arch->name, "table") == NULL && strstr (tmp->arch->name, "chair") == NULL) 1566 if (strstr (tmp->arch->name, "table") == NULL && strstr (tmp->arch->name, "chair") == NULL)
1612 { 1567 {
1613 pick_up (op, tmp); 1568 pick_up (op, tmp);
1614 if (0)
1615 fprintf (stderr, "WEAPON\n");
1616 continue; 1569 continue;
1617 } 1570 }
1618 } 1571 }
1619 } 1572 }
1620 1573
1621 /* misc stuff that's useful */ 1574 /* misc stuff that's useful */
1622 if (op->contr->mode & PU_KEY) 1575 if (op->contr->mode & PU_KEY)
1623 if (tmp->type == KEY || tmp->type == SPECIAL_KEY) 1576 if (tmp->type == KEY || tmp->type == SPECIAL_KEY)
1624 { 1577 {
1625 pick_up (op, tmp); 1578 pick_up (op, tmp);
1626 if (0)
1627 fprintf (stderr, "KEY\n");
1628 continue; 1579 continue;
1629 } 1580 }
1630 1581
1631 /* any of the last 4 bits set means we use the ratio for value 1582 /* any of the last 4 bits set means we use the ratio for value
1632 * pickups */ 1583 * pickups */
1654 continue; 1605 continue;
1655 } 1606 }
1656 } 1607 }
1657 } /* the new pickup model */ 1608 } /* the new pickup model */
1658 } 1609 }
1610
1659 return !stop; 1611 return !stop;
1660} 1612}
1661 1613
1662/* 1614/*
1663 * Find an arrow in the inventory and after that 1615 * Find an arrow in the inventory and after that
1897 } 1849 }
1898 1850
1899 /* this should not happen, but sometimes does */ 1851 /* this should not happen, but sometimes does */
1900 if (arrow->nrof == 0) 1852 if (arrow->nrof == 0)
1901 { 1853 {
1902 remove_ob (arrow); 1854 arrow->destroy ();
1903 free_object (arrow);
1904 return 0; 1855 return 0;
1905 } 1856 }
1906 1857
1907 left = arrow; /* these are arrows left to the player */ 1858 left = arrow; /* these are arrows left to the player */
1908 arrow = get_split_ob (arrow, 1); 1859 arrow = get_split_ob (arrow, 1);
1909 if (arrow == NULL) 1860 if (arrow == NULL)
1910 { 1861 {
1911 new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); 1862 new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race);
1912 return 0; 1863 return 0;
1913 } 1864 }
1914 set_owner (arrow, op); 1865 arrow->set_owner (op);
1915 arrow->skill = bow->skill; 1866 arrow->skill = bow->skill;
1916 1867
1917 arrow->direction = dir; 1868 arrow->direction = dir;
1918 arrow->x = sx; 1869 arrow->x = sx;
1919 arrow->y = sy; 1870 arrow->y = sy;
1927 SET_ANIMATION (arrow, arrow->direction); 1878 SET_ANIMATION (arrow, arrow->direction);
1928 arrow->stats.sp = arrow->stats.wc; /* save original wc and dam */ 1879 arrow->stats.sp = arrow->stats.wc; /* save original wc and dam */
1929 arrow->stats.hp = arrow->stats.dam; 1880 arrow->stats.hp = arrow->stats.dam;
1930 arrow->stats.grace = arrow->attacktype; 1881 arrow->stats.grace = arrow->attacktype;
1931 if (arrow->slaying != NULL) 1882 if (arrow->slaying != NULL)
1932 arrow->spellarg = strdup_local (arrow->slaying); 1883 arrow->spellarg = strdup (arrow->slaying);
1933 1884
1934 /* Note that this was different for monsters - they got their level 1885 /* Note that this was different for monsters - they got their level
1935 * added to the damage. I think the strength bonus is more proper. 1886 * added to the damage. I think the strength bonus is more proper.
1936 */ 1887 */
1937 1888
2127 case range_misc: 2078 case range_misc:
2128 fire_misc_object (op, dir); 2079 fire_misc_object (op, dir);
2129 return; 2080 return;
2130 2081
2131 case range_golem: /* Control summoned monsters from scrolls */ 2082 case range_golem: /* Control summoned monsters from scrolls */
2132 if (op->contr->ranges[range_golem] == NULL || op->contr->golem_count != op->contr->ranges[range_golem]->count) 2083 if (QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED))
2133 { 2084 {
2134 op->contr->ranges[range_golem] = NULL; 2085 op->contr->ranges[range_golem] = 0;
2135 op->contr->shoottype = range_none; 2086 op->contr->shoottype = range_none;
2136 op->contr->golem_count = 0;
2137 } 2087 }
2138 else 2088 else
2139 control_golem (op->contr->ranges[range_golem], dir); 2089 control_golem (op->contr->ranges[range_golem], dir);
2140 return; 2090 return;
2141 2091
2349 if (tmp == op) 2299 if (tmp == op)
2350 { 2300 {
2351 tmp = tmp->above; 2301 tmp = tmp->above;
2352 continue; 2302 continue;
2353 } 2303 }
2304
2354 if (QUERY_FLAG (tmp, FLAG_ALIVE)) 2305 if (QUERY_FLAG (tmp, FLAG_ALIVE))
2355 { 2306 {
2356 mon = tmp; 2307 mon = tmp;
2357 break; 2308 break;
2358 } 2309 }
2310
2359 if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL)) 2311 if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL))
2360 mon = tmp; 2312 mon = tmp;
2313
2361 tmp = tmp->above; 2314 tmp = tmp->above;
2362 } 2315 }
2363 2316
2364 if (mon == NULL) /* This happens anytime the player tries to move */ 2317 if (mon == NULL) /* This happens anytime the player tries to move */
2365 return; /* into a wall */ 2318 return; /* into a wall */
2384 * player owns it and it is either friendly or unagressive. 2337 * player owns it and it is either friendly or unagressive.
2385 */ 2338 */
2386 if ((op->type == PLAYER) 2339 if ((op->type == PLAYER)
2387#if COZY_SERVER 2340#if COZY_SERVER
2388 && 2341 &&
2389 ((get_owner (mon) && get_owner (mon)->contr 2342 ((mon->owner && mon->owner->contr
2390 && same_party (get_owner (mon)->contr->party, op->contr->party)) || get_owner (mon) == op) 2343 && same_party (mon->owner->contr->party, op->contr->party)) || mon->owner == op)
2391#else 2344#else
2392 && get_owner (mon) == op 2345 && mon->owner == op
2393#endif 2346#endif
2394 && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) 2347 && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)))
2395 { 2348 {
2396 /* If we're braced, we don't want to switch places with it */ 2349 /* If we're braced, we don't want to switch places with it */
2397 if (op->contr->braced) 2350 if (op->contr->braced)
2584 /* I've been seeing crashes where the golem has been destroyed, but 2537 /* I've been seeing crashes where the golem has been destroyed, but
2585 * the player object still points to the defunct golem. The code that 2538 * the player object still points to the defunct golem. The code that
2586 * destroys the golem looks correct, and it doesn't always happen, so 2539 * destroys the golem looks correct, and it doesn't always happen, so
2587 * put this in a a workaround to clean up the golem pointer. 2540 * put this in a a workaround to clean up the golem pointer.
2588 */ 2541 */
2589 if (op->contr->ranges[range_golem] &&
2590 ((op->contr->golem_count != op->contr->ranges[range_golem]->count) || QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED))) 2542 if (op->contr->ranges[range_golem] && QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED))
2591 {
2592 op->contr->ranges[range_golem] = NULL; 2543 op->contr->ranges[range_golem] = 0;
2593 op->contr->golem_count = 0;
2594 }
2595 2544
2596 /* call this here - we also will call this in do_ericserver, but 2545 /* call this here - we also will call this in do_ericserver, but
2597 * the players time has been increased when doericserver has been 2546 * the players time has been increased when doericserver has been
2598 * called, so we recheck it here. 2547 * called, so we recheck it here.
2599 */ 2548 */
2600 HandleClient (&op->contr->socket, op->contr); 2549 op->contr->socket->handle_command ();
2601 if (op->speed_left < 0) 2550 if (op->speed_left < 0)
2602 return 0; 2551 return 0;
2603 2552
2604 if (op->direction && (op->contr->run_on || op->contr->fire_on)) 2553 if (op->direction && (op->contr->run_on || op->contr->fire_on))
2605 { 2554 {
2614 if (op->speed_left > 0) 2563 if (op->speed_left > 0)
2615 return 1; 2564 return 1;
2616 else 2565 else
2617 return 0; 2566 return 0;
2618 } 2567 }
2568
2619 return 0; 2569 return 0;
2620} 2570}
2621 2571
2622int 2572int
2623save_life (object *op) 2573save_life (object *op)
2624{ 2574{
2625 object *tmp;
2626
2627 if (!QUERY_FLAG (op, FLAG_LIFESAVE)) 2575 if (!QUERY_FLAG (op, FLAG_LIFESAVE))
2628 return 0; 2576 return 0;
2629 2577
2630 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 2578 for (object *tmp = op->inv; tmp; tmp = tmp->below)
2631 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) 2579 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE))
2632 { 2580 {
2633 play_sound_map (op->map, op->x, op->y, SOUND_OB_EVAPORATE); 2581 play_sound_map (op->map, op->x, op->y, SOUND_OB_EVAPORATE);
2634 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); 2582 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp));
2583
2635 if (op->contr) 2584 if (op->contr)
2636 esrv_del_item (op->contr, tmp->count); 2585 esrv_del_item (op->contr, tmp->count);
2637 remove_ob (tmp); 2586
2638 free_object (tmp); 2587 tmp->destroy ();
2639 CLEAR_FLAG (op, FLAG_LIFESAVE); 2588 CLEAR_FLAG (op, FLAG_LIFESAVE);
2589
2640 if (op->stats.hp < 0) 2590 if (op->stats.hp < 0)
2641 op->stats.hp = op->stats.maxhp; 2591 op->stats.hp = op->stats.maxhp;
2592
2642 if (op->stats.food < 0) 2593 if (op->stats.food < 0)
2643 op->stats.food = 999; 2594 op->stats.food = 999;
2595
2644 fix_player (op); 2596 fix_player (op);
2645 return 1; 2597 return 1;
2646 } 2598 }
2599
2647 LOG (llevError, "Error: LIFESAVE set without applied object.\n"); 2600 LOG (llevError, "Error: LIFESAVE set without applied object.\n");
2648 CLEAR_FLAG (op, FLAG_LIFESAVE); 2601 CLEAR_FLAG (op, FLAG_LIFESAVE);
2649 enter_player_savebed (op); /* bring him home. */ 2602 enter_player_savebed (op); /* bring him home. */
2650 return 0; 2603 return 0;
2651} 2604}
2665 next = op->below; /* Make sure we have a good value, in case 2618 next = op->below; /* Make sure we have a good value, in case
2666 * we remove object 'op' 2619 * we remove object 'op'
2667 */ 2620 */
2668 if (QUERY_FLAG (op, FLAG_UNPAID)) 2621 if (QUERY_FLAG (op, FLAG_UNPAID))
2669 { 2622 {
2670 remove_ob (op); 2623 op->remove ();
2671 op->x = env->x; 2624 op->x = env->x;
2672 op->y = env->y; 2625 op->y = env->y;
2673 if (env->type == PLAYER) 2626 if (env->type == PLAYER)
2674 esrv_del_item (env->contr, op->count); 2627 esrv_del_item (env->contr, op->count);
2675 insert_ob_in_map (op, env->map, NULL, 0); 2628 insert_ob_in_map (op, env->map, NULL, 0);
2676 } 2629 }
2677 else if (op->inv) 2630 else if (op->inv)
2678 remove_unpaid_objects (op->inv, env); 2631 remove_unpaid_objects (op->inv, env);
2632
2679 op = next; 2633 op = next;
2680 } 2634 }
2681} 2635}
2682 2636
2683 2637
2698 strcpy (buf2, " R.I.P.\n\n"); 2652 strcpy (buf2, " R.I.P.\n\n");
2699 if (op->type == PLAYER) 2653 if (op->type == PLAYER)
2700 sprintf (buf, "%s the %s\n", &op->name, op->contr->title); 2654 sprintf (buf, "%s the %s\n", &op->name, op->contr->title);
2701 else 2655 else
2702 sprintf (buf, "%s\n", &op->name); 2656 sprintf (buf, "%s\n", &op->name);
2657
2703 strncat (buf2, " ", 20 - strlen (buf) / 2); 2658 strncat (buf2, " ", 20 - strlen (buf) / 2);
2704 strcat (buf2, buf); 2659 strcat (buf2, buf);
2705 if (op->type == PLAYER) 2660 if (op->type == PLAYER)
2706 sprintf (buf, "who was in level %d when killed\n", op->level); 2661 sprintf (buf, "who was in level %d when killed\n", op->level);
2707 else 2662 else
2708 sprintf (buf, "who was in level %d when died.\n\n", op->level); 2663 sprintf (buf, "who was in level %d when died.\n\n", op->level);
2664
2709 strncat (buf2, " ", 20 - strlen (buf) / 2); 2665 strncat (buf2, " ", 20 - strlen (buf) / 2);
2710 strcat (buf2, buf); 2666 strcat (buf2, buf);
2711 if (op->type == PLAYER) 2667 if (op->type == PLAYER)
2712 { 2668 {
2713 sprintf (buf, "by %s.\n\n", op->contr->killer); 2669 sprintf (buf, "by %s.\n\n", op->contr->killer);
2714 strncat (buf2, " ", 21 - strlen (buf) / 2); 2670 strncat (buf2, " ", 21 - strlen (buf) / 2);
2715 strcat (buf2, buf); 2671 strcat (buf2, buf);
2716 } 2672 }
2673
2717 strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now)); 2674 strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now));
2718 strncat (buf2, " ", 20 - strlen (buf) / 2); 2675 strncat (buf2, " ", 20 - strlen (buf) / 2);
2719 strcat (buf2, buf); 2676 strcat (buf2, buf);
2677
2720 return buf2; 2678 return buf2;
2721} 2679}
2722 2680
2723 2681
2724 2682
2972 /* restore player */ 2930 /* restore player */
2973 at = archetype::find ("poisoning"); 2931 at = archetype::find ("poisoning");
2974 tmp = present_arch_in_ob (at, op); 2932 tmp = present_arch_in_ob (at, op);
2975 if (tmp) 2933 if (tmp)
2976 { 2934 {
2977 remove_ob (tmp); 2935 tmp->destroy ();
2978 free_object (tmp);
2979 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); 2936 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed");
2980 } 2937 }
2981 2938
2982 at = archetype::find ("confusion"); 2939 at = archetype::find ("confusion");
2983 tmp = present_arch_in_ob (at, op); 2940 tmp = present_arch_in_ob (at, op);
2984 if (tmp) 2941 if (tmp)
2985 { 2942 {
2986 remove_ob (tmp); 2943 tmp->destroy ();
2987 free_object (tmp);
2988 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); 2944 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer");
2989 } 2945 }
2990 2946
2991 cure_disease (op, 0); /* remove any disease */ 2947 cure_disease (op, 0); /* remove any disease */
2992 op->stats.hp = op->stats.maxhp; 2948 op->stats.hp = op->stats.maxhp;
3169 /* determine_god() seems to not work sometimes... why is this? 3125 /* determine_god() seems to not work sometimes... why is this?
3170 Should I be using something else? GD */ 3126 Should I be using something else? GD */
3171 const char *god = determine_god (op); 3127 const char *god = determine_god (op);
3172 3128
3173 if (god && (strcmp (god, "none"))) 3129 if (god && (strcmp (god, "none")))
3174 new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief " "moment you feel the holy presence of %s protecting" " you.", god); 3130 new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief moment you feel the holy presence of %s protecting" " you.", god);
3175 else 3131 else
3176 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you."); 3132 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you.");
3177 } 3133 }
3134#else
3135 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely.");
3178#endif 3136#endif
3179 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely.");
3180 3137
3181 /* Put a gravestone up where the character 'almost' died. List the 3138 /* Put a gravestone up where the character 'almost' died. List the
3182 * exp loss on the stone. 3139 * exp loss on the stone.
3183 */ 3140 */
3184 tmp = arch_to_object (archetype::find ("gravestone")); 3141 tmp = arch_to_object (archetype::find ("gravestone"));
3189 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); 3146 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);
3190 tmp->msg = buf; 3147 tmp->msg = buf;
3191 tmp->x = op->x, tmp->y = op->y; 3148 tmp->x = op->x, tmp->y = op->y;
3192 insert_ob_in_map (tmp, op->map, NULL, 0); 3149 insert_ob_in_map (tmp, op->map, NULL, 0);
3193 3150
3194 /**************************************/ 3151 /**************************************/
3195 /* */ 3152 /* */
3196 /* Subtract the experience points, */ 3153 /* Subtract the experience points, */
3197 /* if we died cause of food, give us */ 3154 /* if we died cause of food, give us */
3198 /* food, and reset HP's... */ 3155 /* food, and reset HP's... */
3199 /* */ 3156 /* */
3200
3201 /**************************************/ 3157 /**************************************/
3202 3158
3203 /* remove any poisoning and confusion the character may be suffering. */ 3159 /* remove any poisoning and confusion the character may be suffering. */
3204 /* restore player */ 3160 /* restore player */
3205 at = archetype::find ("poisoning"); 3161 at = archetype::find ("poisoning");
3206 tmp = present_arch_in_ob (at, op); 3162 tmp = present_arch_in_ob (at, op);
3163
3207 if (tmp) 3164 if (tmp)
3208 { 3165 {
3209 remove_ob (tmp); 3166 tmp->destroy ();
3210 free_object (tmp);
3211 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); 3167 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed");
3212 } 3168 }
3213 3169
3214 at = archetype::find ("confusion"); 3170 at = archetype::find ("confusion");
3215 tmp = present_arch_in_ob (at, op); 3171 tmp = present_arch_in_ob (at, op);
3216 if (tmp) 3172 if (tmp)
3217 { 3173 {
3218 remove_ob (tmp); 3174 tmp->destroy ();
3219 free_object (tmp);
3220 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); 3175 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer");
3221 } 3176 }
3177
3222 cure_disease (op, 0); /* remove any disease */ 3178 cure_disease (op, 0); /* remove any disease */
3223 3179
3224 /*add_exp(op, (op->stats.exp * -0.20)); */ 3180 /*add_exp(op, (op->stats.exp * -0.20)); */
3225 apply_death_exp_penalty (op); 3181 apply_death_exp_penalty (op);
3226 if (op->stats.food < 100) 3182 if (op->stats.food < 100)
3236 */ 3192 */
3237 3193
3238 if (is_in_shop (op)) 3194 if (is_in_shop (op))
3239 remove_unpaid_objects (op->inv, op); 3195 remove_unpaid_objects (op->inv, op);
3240 3196
3241 /****************************************/ 3197 /****************************************/
3242 /* */ 3198 /* */
3243 /* Move player to his current respawn- */ 3199 /* Move player to his current respawn- */
3244 /* position (usually last savebed) */ 3200 /* position (usually last savebed) */
3245 /* */ 3201 /* */
3246
3247 /****************************************/ 3202 /****************************************/
3248 3203
3249 enter_player_savebed (op); 3204 enter_player_savebed (op);
3250 3205
3251 /* Save the player before inserting the force to reduce 3206 /* Save the player before inserting the force to reduce
3252 * chance of abuse. 3207 * chance of abuse.
3259 * spell effects. So first see if there is a spell effect 3214 * spell effects. So first see if there is a spell effect
3260 * on the space that might harm the player. 3215 * on the space that might harm the player.
3261 */ 3216 */
3262 will_kill_again = 0; 3217 will_kill_again = 0;
3263 for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above) 3218 for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above)
3264 {
3265 if (tmp->type == SPELL_EFFECT) 3219 if (tmp->type == SPELL_EFFECT)
3266 will_kill_again |= tmp->attacktype; 3220 will_kill_again |= tmp->attacktype;
3267 } 3221
3268 if (will_kill_again) 3222 if (will_kill_again)
3269 { 3223 {
3270 object *force; 3224 object *force;
3271 int at; 3225 int at;
3272 3226
3274 /* 50 ticks should be enough time for the spell to abate */ 3228 /* 50 ticks should be enough time for the spell to abate */
3275 force->speed = 0.1; 3229 force->speed = 0.1;
3276 force->speed_left = -5.0; 3230 force->speed_left = -5.0;
3277 SET_FLAG (force, FLAG_APPLIED); 3231 SET_FLAG (force, FLAG_APPLIED);
3278 for (at = 0; at < NROFATTACKS; at++) 3232 for (at = 0; at < NROFATTACKS; at++)
3279 {
3280 if (will_kill_again & (1 << at)) 3233 if (will_kill_again & (1 << at))
3281 force->resist[at] = 100; 3234 force->resist[at] = 100;
3282 } 3235
3283 insert_ob_in_ob (force, op); 3236 insert_ob_in_ob (force, op);
3284 fix_player (op); 3237 fix_player (op);
3285 3238
3286 } 3239 }
3287 3240
3297 op->contr->party = NULL; 3250 op->contr->party = NULL;
3298 if (settings.set_title == TRUE) 3251 if (settings.set_title == TRUE)
3299 op->contr->own_title[0] = '\0'; 3252 op->contr->own_title[0] = '\0';
3300 new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf); 3253 new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf);
3301 check_score (op); 3254 check_score (op);
3255
3302 if (op->contr->ranges[range_golem] != NULL) 3256 if (op->contr->ranges[range_golem])
3303 { 3257 {
3304 remove_friendly_object (op->contr->ranges[range_golem]); 3258 remove_friendly_object (op->contr->ranges[range_golem]);
3305 remove_ob (op->contr->ranges[range_golem]); 3259 op->contr->ranges[range_golem]->destroy ();
3306 free_object (op->contr->ranges[range_golem]);
3307 op->contr->ranges[range_golem] = NULL; 3260 op->contr->ranges[range_golem] = 0;
3308 op->contr->golem_count = 0;
3309 } 3261 }
3262
3310 loot_object (op); /* Remove some of the items for good */ 3263 loot_object (op); /* Remove some of the items for good */
3311 remove_ob (op); 3264 op->remove ();
3312 op->direction = 0; 3265 op->direction = 0;
3313 3266
3314 if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp) 3267 if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp)
3315 { 3268 {
3316 delete_character (op->name, 0); 3269 delete_character (op->name, 0);
3369 for (tmp = op->inv; tmp != NULL; tmp = next) 3322 for (tmp = op->inv; tmp != NULL; tmp = next)
3370 { 3323 {
3371 next = tmp->below; 3324 next = tmp->below;
3372 if (tmp->type == EXPERIENCE || tmp->invisible) 3325 if (tmp->type == EXPERIENCE || tmp->invisible)
3373 continue; 3326 continue;
3374 remove_ob (tmp); 3327 tmp->remove ();
3375 tmp->x = op->x, tmp->y = op->y; 3328 tmp->x = op->x, tmp->y = op->y;
3376 if (tmp->type == CONTAINER) 3329 if (tmp->type == CONTAINER)
3377 { /* empty container to ground */ 3330 { /* empty container to ground */
3378 loot_object (tmp); 3331 loot_object (tmp);
3379 } 3332 }
3380 if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(RANDOM () % 3))) 3333 if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(RANDOM () % 3)))
3381 { 3334 {
3382 if (tmp->nrof > 1) 3335 if (tmp->nrof > 1)
3383 { 3336 {
3384 tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); 3337 tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1));
3385 free_object (tmp2); 3338 tmp2->destroy ();
3386 insert_ob_in_map (tmp, op->map, NULL, 0); 3339 insert_ob_in_map (tmp, op->map, NULL, 0);
3387 } 3340 }
3388 else 3341 else
3389 free_object (tmp); 3342 tmp->destroy ();
3390 } 3343 }
3391 else 3344 else
3392 insert_ob_in_map (tmp, op->map, NULL, 0); 3345 insert_ob_in_map (tmp, op->map, NULL, 0);
3393 } 3346 }
3394} 3347}
3459 if (op->type == PLAYER) 3412 if (op->type == PLAYER)
3460 new_draw_info_format (NDI_UNIQUE, 0, op, "You cast %s.", &spob->name); 3413 new_draw_info_format (NDI_UNIQUE, 0, op, "You cast %s.", &spob->name);
3461 3414
3462 cast_spell (op, throw_ob, dir, spob, NULL); 3415 cast_spell (op, throw_ob, dir, spob, NULL);
3463 3416
3464 if (!QUERY_FLAG (throw_ob, FLAG_REMOVED)) 3417 throw_ob->destroy ();
3465 remove_ob (throw_ob);
3466 free_object (throw_ob);
3467} 3418}
3468 3419
3469void 3420void
3470make_visible (object *op) 3421make_visible (object *op)
3471{ 3422{
3678 3629
3679 /* only the viewable area the player sees is updated by LOS 3630 /* only the viewable area the player sees is updated by LOS
3680 * code, so we need to restrict ourselves to that range of values 3631 * code, so we need to restrict ourselves to that range of values
3681 * for any meaningful values. 3632 * for any meaningful values.
3682 */ 3633 */
3683 if (FABS (dx) <= (pl->contr->socket.mapx / 2) && 3634 if (FABS (dx) <= (pl->contr->socket->mapx / 2) &&
3684 FABS (dy) <= (pl->contr->socket.mapy / 2) && 3635 FABS (dy) <= (pl->contr->socket->mapy / 2) &&
3685 !pl->contr->blocked_los[dx + (pl->contr->socket.mapx / 2)][dy + (pl->contr->socket.mapy / 2)]) 3636 !pl->contr->blocked_los[dx + (pl->contr->socket->mapx / 2)][dy + (pl->contr->socket->mapy / 2)])
3686 return 1; 3637 return 1;
3687 op = op->more; 3638 op = op->more;
3688 } 3639 }
3689 return 0; 3640 return 0;
3690} 3641}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines