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.21 by root, Tue Sep 12 19:20:08 2006 UTC vs.
Revision 1.41 by root, Fri Dec 15 04:21:29 2006 UTC

16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 20
21 The author can be reached via e-mail to crossfire-devel@real-time.com 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... */
239
240 {
241 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 */ 242 p->socket->monitor_spells = 0; /* Needed because esrv_update_spells( ) gets called by roll_stats */
266
267 roll_stats (op); 243 roll_stats (op);
244 p->socket->monitor_spells = oldmon;
245 }
268 p->state = ST_ROLL_STAT; 246 p->state = ST_ROLL_STAT;
269 clear_los (op); 247 clear_los (op);
270 248
271 p->gen_sp_armour = 10; 249 p->gen_sp_armour = 10;
272 p->last_speed = -1; 250 p->last_speed = -1;
294 for (i = 0; i < NUM_SKILLS; i++) 272 for (i = 0; i < NUM_SKILLS; i++)
295 { 273 {
296 p->last_skill_exp[i] = -1; 274 p->last_skill_exp[i] = -1;
297 p->last_skill_ob[i] = NULL; 275 p->last_skill_ob[i] = NULL;
298 } 276 }
277
299 for (i = 0; i < NROFATTACKS; i++) 278 for (i = 0; i < NROFATTACKS; i++)
300 {
301 p->last_resist[i] = -1; 279 p->last_resist[i] = -1;
302 } 280
303 p->last_stats.exp = -1; 281 p->last_stats.exp = -1;
304 p->last_weight = (uint32) - 1; 282 p->last_weight = (uint32) - 1;
305 283
306 p->socket.update_look = 0; 284 p->socket->update_look = 0;
307 p->socket.look_position = 0; 285 p->socket->look_position = 0;
286
308 return p; 287 return p;
309} 288}
310 289
311/* This loads the first map an puts the player on it. */ 290/* This loads the first map an puts the player on it. */
312static void 291static void
322 * All we can really get in this is some settings like host and display 301 * All we can really get in this is some settings like host and display
323 * mode. 302 * mode.
324 */ 303 */
325 304
326int 305int
327add_player (NewSocket * ns) 306add_player (client_socket *ns)
328{ 307{
329 player *p; 308 player *p = new player;
330 309
331 p = get_player (NULL);
332 p->socket = *ns; 310 p->socket = ns;
333 p->socket.faces_sent = (uint8 *) malloc (p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); 311 ns->pl = p;
334 if (p->socket.faces_sent == NULL) 312
335 fatal (OUT_OF_MEMORY); 313 p->next = first_player;
336 memcpy (p->socket.faces_sent, ns->faces_sent, p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); 314 first_player = p;
337 /* Needed because the socket we just copied over needs to be cleared. 315
338 * Note that this can result in a client reset if there is partial data 316 p = get_player (p);
339 * on the uncoming socket. 317
340 */
341 p->socket.inbuf.len = 0;
342 set_first_map (p->ob); 318 set_first_map (p->ob);
343 319
344 CLEAR_FLAG (p->ob, FLAG_FRIENDLY); 320 CLEAR_FLAG (p->ob, FLAG_FRIENDLY);
345 add_friendly_object (p->ob); 321 add_friendly_object (p->ob);
346 send_rules (p->ob); 322 send_rules (p->ob);
347 send_news (p->ob); 323 send_news (p->ob);
348 display_motd (p->ob); 324 display_motd (p->ob);
349 get_name (p->ob); 325 get_name (p->ob);
326
350 return 0; 327 return 0;
351} 328}
352 329
353/* 330/*
354 * get_player_archetype() return next player archetype from archetype 331 * get_player_archetype() return next player archetype from archetype
489path_to_player (object *mon, object *pl, unsigned mindiff) 466path_to_player (object *mon, object *pl, unsigned mindiff)
490{ 467{
491 rv_vector rv; 468 rv_vector rv;
492 sint16 x, y; 469 sint16 x, y;
493 int lastx, lasty, dir, i, diff, firstdir = 0, lastdir, max = MAX_SPACES, mflags, blocked; 470 int lastx, lasty, dir, i, diff, firstdir = 0, lastdir, max = MAX_SPACES, mflags, blocked;
494 mapstruct *m, *lastmap; 471 maptile *m, *lastmap;
495 472
496 get_rangevector (mon, pl, &rv, 0); 473 get_rangevector (mon, pl, &rv, 0);
497 474
498 if (rv.distance < mindiff) 475 if (rv.distance < mindiff)
499 return 0; 476 return 0;
643 (op->type == ARMOUR || op->type == BOOTS || 620 (op->type == ARMOUR || op->type == BOOTS ||
644 op->type == CLOAK || op->type == HELMET || 621 op->type == CLOAK || op->type == HELMET ||
645 op->type == SHIELD || op->type == GLOVES || 622 op->type == SHIELD || op->type == GLOVES ||
646 op->type == BRACERS || op->type == GIRDLE)) || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON)) 623 op->type == BRACERS || op->type == GIRDLE)) || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON))
647 { 624 {
648 remove_ob (op); 625 op->destroy ();
649 free_object (op);
650 continue; 626 continue;
651 } 627 }
652 } 628 }
653 629
654 /* This really needs to be better - we should really give 630 /* This really needs to be better - we should really give
665 if (tmp->type == op->type && tmp->name == op->name) 641 if (tmp->type == op->type && tmp->name == op->name)
666 break; 642 break;
667 643
668 if (tmp) 644 if (tmp)
669 { 645 {
670 remove_ob (op); 646 op->destroy ();
671 free_object (op);
672 LOG (llevError, "give_initial_items: Removing duplicate object %s\n", &tmp->name); 647 LOG (llevError, "give_initial_items: Removing duplicate object %s\n", &tmp->name);
673 continue; 648 continue;
674 } 649 }
650
675 if (op->nrof > 1) 651 if (op->nrof > 1)
676 op->nrof = 1; 652 op->nrof = 1;
677 } 653 }
678 654
679 if (op->type == SPELLBOOK && op->inv) 655 if (op->type == SPELLBOOK && op->inv)
691 CLEAR_FLAG (op, FLAG_CURSED); 667 CLEAR_FLAG (op, FLAG_CURSED);
692 CLEAR_FLAG (op, FLAG_DAMNED); 668 CLEAR_FLAG (op, FLAG_DAMNED);
693 } 669 }
694 if (op->type == SPELL) 670 if (op->type == SPELL)
695 { 671 {
696 remove_ob (op); 672 op->destroy ();
697 free_object (op);
698 continue; 673 continue;
699 } 674 }
700 else if (op->type == SKILL) 675 else if (op->type == SKILL)
701 { 676 {
702 SET_FLAG (op, FLAG_CAN_USE_SKILL); 677 SET_FLAG (op, FLAG_CAN_USE_SKILL);
715void 690void
716get_name (object *op) 691get_name (object *op)
717{ 692{
718 op->contr->write_buf[0] = '\0'; 693 op->contr->write_buf[0] = '\0';
719 op->contr->state = ST_GET_NAME; 694 op->contr->state = ST_GET_NAME;
720 send_query (&op->contr->socket, 0, "What is your name?\n:"); 695 send_query (op->contr->socket, 0, "What is your name?\n:");
721} 696}
722 697
723void 698void
724get_password (object *op) 699get_password (object *op)
725{ 700{
726 op->contr->write_buf[0] = '\0'; 701 op->contr->write_buf[0] = '\0';
727 op->contr->state = ST_GET_PASSWORD; 702 op->contr->state = ST_GET_PASSWORD;
728 send_query (&op->contr->socket, CS_QUERY_HIDEINPUT, "What is your password?\n:"); 703 send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "What is your password?\n:");
729} 704}
730 705
731void 706void
732play_again (object *op) 707play_again (object *op)
733{ 708{
734 op->contr->state = ST_PLAY_AGAIN; 709 op->contr->state = ST_PLAY_AGAIN;
735 op->chosen_skill = NULL; 710 op->chosen_skill = NULL;
736 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Do you want to play again (a/q)?"); 711 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 712 /* a bit of a hack, but there are various places early in th
738 * player creation process that a user can quit (eg, roll 713 * player creation process that a user can quit (eg, roll
739 * stats) that isn't removing the player. Taking a quick 714 * stats) that isn't removing the player. Taking a quick
740 * look, there are many places that call play_again without 715 * look, there are many places that call play_again without
741 * removing the player - it probably makes more sense 716 * removing the player - it probably makes more sense
742 * to leave it to play_again to remove the object in all 717 * to leave it to play_again to remove the object in all
743 * cases. 718 * cases.
744 */ 719 */
745 if (!QUERY_FLAG (op, FLAG_REMOVED)) 720 if (!QUERY_FLAG (op, FLAG_REMOVED))
746 remove_ob (op); 721 op->remove ();
747 /* Need to set this to null - otherwise, it could point to garbage, 722 /* 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 723 * and draw() doesn't check to see if the player is removed, only if
749 * the map is null or not swapped out. 724 * the map is null or not swapped out.
750 */ 725 */
751 op->map = NULL; 726 op->map = NULL;
765 player *pl = op->contr; 740 player *pl = op->contr;
766 shstr name = op->name; 741 shstr name = op->name;
767 742
768 op->contr = 0; 743 op->contr = 0;
769 op->type = 0; 744 op->type = 0;
770 op->free (1); 745 op->destroy (1);
771 pl = get_player (pl); 746 pl = get_player (pl);
772 op = pl->ob; 747 op = pl->ob;
773 add_friendly_object (op); 748 add_friendly_object (op);
774 op->contr->password[0] = '~'; 749 op->contr->password[0] = '~';
775 op->name = op->name_pl = 0; 750 op->name = op->name_pl = 0;
790confirm_password (object *op) 765confirm_password (object *op)
791{ 766{
792 767
793 op->contr->write_buf[0] = '\0'; 768 op->contr->write_buf[0] = '\0';
794 op->contr->state = ST_CONFIRM_PASSWORD; 769 op->contr->state = ST_CONFIRM_PASSWORD;
795 send_query (&op->contr->socket, CS_QUERY_HIDEINPUT, "Please type your password again.\n:"); 770 send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "Please type your password again.\n:");
796} 771}
797 772
798void 773void
799get_party_password (object *op, partylist *party) 774get_party_password (object *op, partylist *party)
800{ 775{
804 return; 779 return;
805 } 780 }
806 op->contr->write_buf[0] = '\0'; 781 op->contr->write_buf[0] = '\0';
807 op->contr->state = ST_GET_PARTY_PASSWORD; 782 op->contr->state = ST_GET_PARTY_PASSWORD;
808 op->contr->party_to_join = party; 783 op->contr->party_to_join = party;
809 send_query (&op->contr->socket, CS_QUERY_HIDEINPUT, "What is the password?\n:"); 784 send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "What is the password?\n:");
810} 785}
811 786
812 787
813/* This rolls four 1-6 rolls and sums the best 3 of the 4. */ 788/* This rolls four 1-6 rolls and sums the best 3 of the 4. */
814int 789int
911 886
912void 887void
913Roll_Again (object *op) 888Roll_Again (object *op)
914{ 889{
915 esrv_new_player (op->contr, 0); 890 esrv_new_player (op->contr, 0);
916 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, 891 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)? "); 892 "[y] to roll new stats [n] to use stats\n[1-7] [1-7] to swap stats.\nRoll again (y/n/1-7)? ");
918} 893}
919 894
920void 895void
921Swap_Stat (object *op, int Swap_Second) 896Swap_Stat (object *op, int Swap_Second)
988 new_draw_info (NDI_UNIQUE, 0, op, buf); 963 new_draw_info (NDI_UNIQUE, 0, op, buf);
989 } 964 }
990 else 965 else
991 Swap_Stat (op, stat_trans[keynum]); 966 Swap_Stat (op, stat_trans[keynum]);
992 967
993 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, ""); 968 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "");
994 return 1; 969 return 1;
995 } 970 }
996 switch (key) 971 switch (key)
997 { 972 {
998 case 'n': 973 case 'n':
1012 enter_exit (op, NULL); 987 enter_exit (op, NULL);
1013#endif 988#endif
1014 SET_ANIMATION (op, 2); /* So player faces south */ 989 SET_ANIMATION (op, 2); /* So player faces south */
1015 /* Enter exit adds a player otherwise */ 990 /* Enter exit adds a player otherwise */
1016 add_statbonus (op); 991 add_statbonus (op);
1017 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, 992 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"); 993 "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n");
1019 op->contr->state = ST_CHANGE_CLASS; 994 op->contr->state = ST_CHANGE_CLASS;
1020 if (op->msg) 995 if (op->msg)
1021 new_draw_info (NDI_BLUE, 0, op, op->msg); 996 new_draw_info (NDI_BLUE, 0, op, op->msg);
1022 return 0; 997 return 0;
1023 } 998 }
1024 case 'y': 999 case 'y':
1025 case 'Y': 1000 case 'Y':
1026 roll_stats (op); 1001 roll_stats (op);
1027 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, ""); 1002 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "");
1028 return 1; 1003 return 1;
1029 1004
1030 case 'q': 1005 case 'q':
1031 case 'Q': 1006 case 'Q':
1032 play_again (op); 1007 play_again (op);
1033 return 1; 1008 return 1;
1034 1009
1035 default: 1010 default:
1036 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?"); 1011 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?");
1037 return 0; 1012 return 0;
1038 } 1013 }
1039 return 0; 1014 return 0;
1040} 1015}
1041 1016
1051{ 1026{
1052 int tmp_loop; 1027 int tmp_loop;
1053 1028
1054 if (key == 'q' || key == 'Q') 1029 if (key == 'q' || key == 'Q')
1055 { 1030 {
1056 remove_ob (op); 1031 op->remove ();
1057 play_again (op); 1032 play_again (op);
1058 return 0; 1033 return 0;
1059 } 1034 }
1060 if (key == 'd' || key == 'D') 1035 if (key == 'd' || key == 'D')
1061 { 1036 {
1062 char buf[MAX_BUF]; 1037 char buf[MAX_BUF];
1063 1038
1064 /* this must before then initial items are given */ 1039 /* this must before then initial items are given */
1065 esrv_new_player (op->contr, op->weight + op->carrying); 1040 esrv_new_player (op->contr, op->weight + op->carrying);
1041
1066 create_treasure (find_treasurelist ("starting_wealth"), op, 0, 0, 0); 1042 treasurelist *tl = find_treasurelist ("starting_wealth");
1043 if (tl)
1044 create_treasure (tl, op, 0, 0, 0);
1067 1045
1068 INVOKE_PLAYER (BIRTH, op->contr); 1046 INVOKE_PLAYER (BIRTH, op->contr);
1069 INVOKE_PLAYER (LOGIN, op->contr); 1047 INVOKE_PLAYER (LOGIN, op->contr);
1070 1048
1071 op->contr->state = ST_PLAYING; 1049 op->contr->state = ST_PLAYING;
1096 { 1074 {
1097 object *tmp; 1075 object *tmp;
1098 char mapname[MAX_BUF]; 1076 char mapname[MAX_BUF];
1099 1077
1100 snprintf (mapname, MAX_BUF - 1, "%s/%s", first_map_ext_path, &op->arch->name); 1078 snprintf (mapname, MAX_BUF - 1, "%s/%s", first_map_ext_path, &op->arch->name);
1101 tmp = get_object (); 1079 tmp = object::create ();
1102 EXIT_PATH (tmp) = mapname; 1080 EXIT_PATH (tmp) = mapname;
1103 EXIT_X (tmp) = op->x; 1081 EXIT_X (tmp) = op->x;
1104 EXIT_Y (tmp) = op->y; 1082 EXIT_Y (tmp) = op->y;
1105 enter_exit (op, tmp); /* we don't really care if it succeeded; 1083 enter_exit (op, tmp); /* we don't really care if it succeeded;
1106 * if the map isn't there, then stay on the 1084 * if the map isn't there, then stay on the
1107 * default initial map */ 1085 * default initial map */
1108 free_object (tmp); 1086 tmp->destroy ();
1109 } 1087 }
1110 else 1088 else
1111 { 1089 {
1112 LOG (llevDebug, "first_map_ext_path not set\n"); 1090 LOG (llevDebug, "first_map_ext_path not set\n");
1113 } 1091 }
1123 { 1101 {
1124 shstr name = op->name; 1102 shstr name = op->name;
1125 int x = op->x, y = op->y; 1103 int x = op->x, y = op->y;
1126 1104
1127 remove_statbonus (op); 1105 remove_statbonus (op);
1128 remove_ob (op); 1106 op->remove ();
1129 op->arch = get_player_archetype (op->arch); 1107 op->arch = get_player_archetype (op->arch);
1130 copy_object (&op->arch->clone, op); 1108 op->arch->clone.copy_to (op);
1131 op->instantiate (); 1109 op->instantiate ();
1132 op->stats = op->contr->orig_stats; 1110 op->stats = op->contr->orig_stats;
1133 op->name = op->name_pl = name; 1111 op->name = op->name_pl = name;
1134 op->x = x; 1112 op->x = x;
1135 op->y = y; 1113 op->y = y;
1148 op->stats.grace = 0; 1126 op->stats.grace = 0;
1149 1127
1150 if (op->msg) 1128 if (op->msg)
1151 new_draw_info (NDI_BLUE, 0, op, op->msg); 1129 new_draw_info (NDI_BLUE, 0, op, op->msg);
1152 1130
1153 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Press any key for the next race.\nPress `d' to play this race.\n"); 1131 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; 1132 return 0;
1155} 1133}
1156 1134
1157int 1135int
1158key_confirm_quit (object *op, char key) 1136key_confirm_quit (object *op, char key)
1180 if (settings.set_title == TRUE) 1158 if (settings.set_title == TRUE)
1181 op->contr->own_title[0] = '\0'; 1159 op->contr->own_title[0] = '\0';
1182 1160
1183 if (!QUERY_FLAG (op, FLAG_WAS_WIZ)) 1161 if (!QUERY_FLAG (op, FLAG_WAS_WIZ))
1184 { 1162 {
1185 mapstruct *mp, *next; 1163 maptile *mp, *next;
1186 1164
1187 /* We need to hunt for any per player unique maps in memory and 1165 /* We need to hunt for any per player unique maps in memory and
1188 * get rid of them. The trailing slash in the path is intentional, 1166 * get rid of them. The trailing slash in the path is intentional,
1189 * so that players named 'Ab' won't match against players 'Abe' pathname 1167 * so that players named 'Ab' won't match against players 'Abe' pathname
1190 */ 1168 */
1264 */ 1242 */
1265int 1243int
1266check_pick (object *op) 1244check_pick (object *op)
1267{ 1245{
1268 object *tmp, *next; 1246 object *tmp, *next;
1269 tag_t next_tag = 0, op_tag;
1270 int stop = 0; 1247 int stop = 0;
1271 int j, k, wvratio; 1248 int j, k, wvratio;
1272 char putstring[128], tmpstr[16]; 1249 char putstring[128], tmpstr[16];
1273 1250
1274
1275 /* if you're flying, you cna't pick up anything */ 1251 /* if you're flying, you cna't pick up anything */
1276 if (op->move_type & MOVE_FLYING) 1252 if (op->move_type & MOVE_FLYING)
1277 return 1; 1253 return 1;
1278 1254
1279 op_tag = op->count;
1280
1281 next = op->below; 1255 next = op->below;
1282 if (next)
1283 next_tag = next->count;
1284 1256
1285 /* loop while there are items on the floor that are not marked as 1257 /* loop while there are items on the floor that are not marked as
1286 * destroyed */ 1258 * destroyed */
1287 while (next && !was_destroyed (next, next_tag)) 1259 while (next && !next->destroyed ())
1288 { 1260 {
1289 tmp = next; 1261 tmp = next;
1290 next = tmp->below; 1262 next = tmp->below;
1291 if (next)
1292 next_tag = next->count;
1293 1263
1294 if (was_destroyed (op, op_tag)) 1264 if (op->destroyed ())
1295 return 0; 1265 return 0;
1296 1266
1297 if (!can_pick (op, tmp)) 1267 if (!can_pick (op, tmp))
1298 continue; 1268 continue;
1299 1269
1431 /* question: don't pick up known-poisonous stuff? */ 1401 /* question: don't pick up known-poisonous stuff? */
1432 if (op->contr->mode & PU_FOOD) 1402 if (op->contr->mode & PU_FOOD)
1433 if (tmp->type == FOOD) 1403 if (tmp->type == FOOD)
1434 { 1404 {
1435 pick_up (op, tmp); 1405 pick_up (op, tmp);
1436 if (0)
1437 fprintf (stderr, "FOOD\n");
1438 continue; 1406 continue;
1439 } 1407 }
1408
1440 if (op->contr->mode & PU_DRINK) 1409 if (op->contr->mode & PU_DRINK)
1441 if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))) 1410 if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)))
1442 { 1411 {
1443 pick_up (op, tmp); 1412 pick_up (op, tmp);
1444 if (0)
1445 fprintf (stderr, "DRINK\n");
1446 continue; 1413 continue;
1447 } 1414 }
1448 1415
1449 if (op->contr->mode & PU_POTION) 1416 if (op->contr->mode & PU_POTION)
1450 if (tmp->type == POTION) 1417 if (tmp->type == POTION)
1451 { 1418 {
1452 pick_up (op, tmp); 1419 pick_up (op, tmp);
1453 if (0)
1454 fprintf (stderr, "POTION\n");
1455 continue; 1420 continue;
1456 } 1421 }
1457 1422
1458 /* spellbooks, skillscrolls and normal books/scrolls */ 1423 /* spellbooks, skillscrolls and normal books/scrolls */
1459 if (op->contr->mode & PU_SPELLBOOK) 1424 if (op->contr->mode & PU_SPELLBOOK)
1460 if (tmp->type == SPELLBOOK) 1425 if (tmp->type == SPELLBOOK)
1461 { 1426 {
1462 pick_up (op, tmp); 1427 pick_up (op, tmp);
1463 if (0)
1464 fprintf (stderr, "SPELLBOOK\n");
1465 continue; 1428 continue;
1466 } 1429 }
1430
1467 if (op->contr->mode & PU_SKILLSCROLL) 1431 if (op->contr->mode & PU_SKILLSCROLL)
1468 if (tmp->type == SKILLSCROLL) 1432 if (tmp->type == SKILLSCROLL)
1469 { 1433 {
1470 pick_up (op, tmp); 1434 pick_up (op, tmp);
1471 if (0)
1472 fprintf (stderr, "SKILLSCROLL\n");
1473 continue; 1435 continue;
1474 } 1436 }
1437
1475 if (op->contr->mode & PU_READABLES) 1438 if (op->contr->mode & PU_READABLES)
1476 if (tmp->type == BOOK || tmp->type == SCROLL) 1439 if (tmp->type == BOOK || tmp->type == SCROLL)
1477 { 1440 {
1478 pick_up (op, tmp); 1441 pick_up (op, tmp);
1479 if (0)
1480 fprintf (stderr, "READABLES\n");
1481 continue; 1442 continue;
1482 } 1443 }
1483 1444
1484 /* wands/staves/rods/horns */ 1445 /* wands/staves/rods/horns */
1485 if (op->contr->mode & PU_MAGIC_DEVICE) 1446 if (op->contr->mode & PU_MAGIC_DEVICE)
1486 if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) 1447 if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN)
1487 { 1448 {
1488 pick_up (op, tmp); 1449 pick_up (op, tmp);
1489 if (0)
1490 fprintf (stderr, "MAGIC_DEVICE\n");
1491 continue; 1450 continue;
1492 } 1451 }
1493 1452
1494 /* pick up all magical items */ 1453 /* pick up all magical items */
1495 if (op->contr->mode & PU_MAGICAL) 1454 if (op->contr->mode & PU_MAGICAL)
1496 if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) 1455 if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))
1497 { 1456 {
1498 pick_up (op, tmp); 1457 pick_up (op, tmp);
1499 if (0)
1500 fprintf (stderr, "MAGICAL\n");
1501 continue; 1458 continue;
1502 } 1459 }
1503 1460
1504 if (op->contr->mode & PU_VALUABLES) 1461 if (op->contr->mode & PU_VALUABLES)
1505 { 1462 {
1506 if (tmp->type == MONEY || tmp->type == GEM) 1463 if (tmp->type == MONEY || tmp->type == GEM)
1507 { 1464 {
1508 pick_up (op, tmp); 1465 pick_up (op, tmp);
1509 if (0)
1510 fprintf (stderr, "MONEY/GEM\n");
1511 continue; 1466 continue;
1512 } 1467 }
1513 } 1468 }
1514 1469
1515 /* rings & amulets - talismans seems to be typed AMULET */ 1470 /* rings & amulets - talismans seems to be typed AMULET */
1516 if (op->contr->mode & PU_JEWELS) 1471 if (op->contr->mode & PU_JEWELS)
1517 if (tmp->type == RING || tmp->type == AMULET) 1472 if (tmp->type == RING || tmp->type == AMULET)
1518 { 1473 {
1519 pick_up (op, tmp); 1474 pick_up (op, tmp);
1475 continue;
1520 if (0) 1476 }
1521 fprintf (stderr, "JEWELS\n"); 1477
1478 /* we don't forget dragon food */
1479 if (op->contr->mode & PU_FLESH)
1480 if (tmp->type == FLESH)
1481 {
1482 pick_up (op, tmp);
1522 continue; 1483 continue;
1523 } 1484 }
1524 1485
1525 /* bows and arrows. Bows are good for selling! */ 1486 /* bows and arrows. Bows are good for selling! */
1526 if (op->contr->mode & PU_BOW) 1487 if (op->contr->mode & PU_BOW)
1527 if (tmp->type == BOW) 1488 if (tmp->type == BOW)
1528 { 1489 {
1529 pick_up (op, tmp); 1490 pick_up (op, tmp);
1530 if (0)
1531 fprintf (stderr, "BOW\n");
1532 continue; 1491 continue;
1533 } 1492 }
1493
1534 if (op->contr->mode & PU_ARROW) 1494 if (op->contr->mode & PU_ARROW)
1535 if (tmp->type == ARROW) 1495 if (tmp->type == ARROW)
1536 { 1496 {
1537 pick_up (op, tmp); 1497 pick_up (op, tmp);
1538 if (0)
1539 fprintf (stderr, "ARROW\n");
1540 continue; 1498 continue;
1541 } 1499 }
1542 1500
1543 /* all kinds of armor etc. */ 1501 /* all kinds of armor etc. */
1544 if (op->contr->mode & PU_ARMOUR) 1502 if (op->contr->mode & PU_ARMOUR)
1545 if (tmp->type == ARMOUR) 1503 if (tmp->type == ARMOUR)
1546 { 1504 {
1547 pick_up (op, tmp); 1505 pick_up (op, tmp);
1548 if (0)
1549 fprintf (stderr, "ARMOUR\n");
1550 continue; 1506 continue;
1551 } 1507 }
1508
1552 if (op->contr->mode & PU_HELMET) 1509 if (op->contr->mode & PU_HELMET)
1553 if (tmp->type == HELMET) 1510 if (tmp->type == HELMET)
1554 { 1511 {
1555 pick_up (op, tmp); 1512 pick_up (op, tmp);
1556 if (0)
1557 fprintf (stderr, "HELMET\n");
1558 continue; 1513 continue;
1559 } 1514 }
1515
1560 if (op->contr->mode & PU_SHIELD) 1516 if (op->contr->mode & PU_SHIELD)
1561 if (tmp->type == SHIELD) 1517 if (tmp->type == SHIELD)
1562 { 1518 {
1563 pick_up (op, tmp); 1519 pick_up (op, tmp);
1564 if (0)
1565 fprintf (stderr, "SHIELD\n");
1566 continue; 1520 continue;
1567 } 1521 }
1522
1568 if (op->contr->mode & PU_BOOTS) 1523 if (op->contr->mode & PU_BOOTS)
1569 if (tmp->type == BOOTS) 1524 if (tmp->type == BOOTS)
1570 { 1525 {
1571 pick_up (op, tmp); 1526 pick_up (op, tmp);
1572 if (0)
1573 fprintf (stderr, "BOOTS\n");
1574 continue; 1527 continue;
1575 } 1528 }
1529
1576 if (op->contr->mode & PU_GLOVES) 1530 if (op->contr->mode & PU_GLOVES)
1577 if (tmp->type == GLOVES) 1531 if (tmp->type == GLOVES)
1578 { 1532 {
1579 pick_up (op, tmp); 1533 pick_up (op, tmp);
1580 if (0)
1581 fprintf (stderr, "GLOVES\n");
1582 continue; 1534 continue;
1583 } 1535 }
1536
1584 if (op->contr->mode & PU_CLOAK) 1537 if (op->contr->mode & PU_CLOAK)
1585 if (tmp->type == CLOAK) 1538 if (tmp->type == CLOAK)
1586 { 1539 {
1587 pick_up (op, tmp); 1540 pick_up (op, tmp);
1588 if (0)
1589 fprintf (stderr, "GLOVES\n");
1590 continue; 1541 continue;
1591 } 1542 }
1592 1543
1593 /* hoping to catch throwing daggers here */ 1544 /* hoping to catch throwing daggers here */
1594 if (op->contr->mode & PU_MISSILEWEAPON) 1545 if (op->contr->mode & PU_MISSILEWEAPON)
1595 if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) 1546 if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN))
1596 { 1547 {
1597 pick_up (op, tmp); 1548 pick_up (op, tmp);
1598 if (0)
1599 fprintf (stderr, "MISSILEWEAPON\n");
1600 continue; 1549 continue;
1601 } 1550 }
1602 1551
1603 /* careful: chairs and tables are weapons! */ 1552 /* careful: chairs and tables are weapons! */
1604 if (op->contr->mode & PU_ALLWEAPON) 1553 if (op->contr->mode & PU_ALLWEAPON)
1607 { 1556 {
1608 if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->name, "table") == NULL && 1557 if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->name, "table") == NULL &&
1609 strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL) 1558 strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL)
1610 { 1559 {
1611 pick_up (op, tmp); 1560 pick_up (op, tmp);
1612 if (0)
1613 fprintf (stderr, "WEAPON\n");
1614 continue; 1561 continue;
1615 } 1562 }
1616 } 1563 }
1564
1617 if (tmp->type == WEAPON && tmp->name == NULL) 1565 if (tmp->type == WEAPON && tmp->name == NULL)
1618 { 1566 {
1619 if (strstr (tmp->arch->name, "table") == NULL && strstr (tmp->arch->name, "chair") == NULL) 1567 if (strstr (tmp->arch->name, "table") == NULL && strstr (tmp->arch->name, "chair") == NULL)
1620 { 1568 {
1621 pick_up (op, tmp); 1569 pick_up (op, tmp);
1622 if (0)
1623 fprintf (stderr, "WEAPON\n");
1624 continue; 1570 continue;
1625 } 1571 }
1626 } 1572 }
1627 } 1573 }
1628 1574
1629 /* misc stuff that's useful */ 1575 /* misc stuff that's useful */
1630 if (op->contr->mode & PU_KEY) 1576 if (op->contr->mode & PU_KEY)
1631 if (tmp->type == KEY || tmp->type == SPECIAL_KEY) 1577 if (tmp->type == KEY || tmp->type == SPECIAL_KEY)
1632 { 1578 {
1633 pick_up (op, tmp); 1579 pick_up (op, tmp);
1634 if (0)
1635 fprintf (stderr, "KEY\n");
1636 continue; 1580 continue;
1637 } 1581 }
1638 1582
1639 /* any of the last 4 bits set means we use the ratio for value 1583 /* any of the last 4 bits set means we use the ratio for value
1640 * pickups */ 1584 * pickups */
1662 continue; 1606 continue;
1663 } 1607 }
1664 } 1608 }
1665 } /* the new pickup model */ 1609 } /* the new pickup model */
1666 } 1610 }
1611
1667 return !stop; 1612 return !stop;
1668} 1613}
1669 1614
1670/* 1615/*
1671 * Find an arrow in the inventory and after that 1616 * Find an arrow in the inventory and after that
1770 1715
1771object * 1716object *
1772pick_arrow_target (object *op, const char *type, int dir) 1717pick_arrow_target (object *op, const char *type, int dir)
1773{ 1718{
1774 object *tmp = NULL; 1719 object *tmp = NULL;
1775 mapstruct *m; 1720 maptile *m;
1776 int i, mflags, found, number; 1721 int i, mflags, found, number;
1777 sint16 x, y; 1722 sint16 x, y;
1778 1723
1779 if (op->map == NULL) 1724 if (op->map == NULL)
1780 return find_arrow (op, type); 1725 return find_arrow (op, type);
1840 */ 1785 */
1841int 1786int
1842fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy) 1787fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy)
1843{ 1788{
1844 object *left, *bow; 1789 object *left, *bow;
1845 tag_t left_tag, tag;
1846 int bowspeed, mflags; 1790 int bowspeed, mflags;
1847 mapstruct *m; 1791 maptile *m;
1848 1792
1849 if (!dir) 1793 if (!dir)
1850 { 1794 {
1851 new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); 1795 new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!");
1852 return 0; 1796 return 0;
1906 } 1850 }
1907 1851
1908 /* this should not happen, but sometimes does */ 1852 /* this should not happen, but sometimes does */
1909 if (arrow->nrof == 0) 1853 if (arrow->nrof == 0)
1910 { 1854 {
1911 remove_ob (arrow); 1855 arrow->destroy ();
1912 free_object (arrow);
1913 return 0; 1856 return 0;
1914 } 1857 }
1915 1858
1916 left = arrow; /* these are arrows left to the player */ 1859 left = arrow; /* these are arrows left to the player */
1917 left_tag = left->count;
1918 arrow = get_split_ob (arrow, 1); 1860 arrow = get_split_ob (arrow, 1);
1919 if (arrow == NULL) 1861 if (arrow == NULL)
1920 { 1862 {
1921 new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); 1863 new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race);
1922 return 0; 1864 return 0;
1923 } 1865 }
1924 set_owner (arrow, op); 1866 arrow->set_owner (op);
1925 arrow->skill = bow->skill; 1867 arrow->skill = bow->skill;
1926 1868
1927 arrow->direction = dir; 1869 arrow->direction = dir;
1928 arrow->x = sx; 1870 arrow->x = sx;
1929 arrow->y = sy; 1871 arrow->y = sy;
1937 SET_ANIMATION (arrow, arrow->direction); 1879 SET_ANIMATION (arrow, arrow->direction);
1938 arrow->stats.sp = arrow->stats.wc; /* save original wc and dam */ 1880 arrow->stats.sp = arrow->stats.wc; /* save original wc and dam */
1939 arrow->stats.hp = arrow->stats.dam; 1881 arrow->stats.hp = arrow->stats.dam;
1940 arrow->stats.grace = arrow->attacktype; 1882 arrow->stats.grace = arrow->attacktype;
1941 if (arrow->slaying != NULL) 1883 if (arrow->slaying != NULL)
1942 arrow->spellarg = strdup_local (arrow->slaying); 1884 arrow->spellarg = strdup (arrow->slaying);
1943 1885
1944 /* Note that this was different for monsters - they got their level 1886 /* Note that this was different for monsters - they got their level
1945 * added to the damage. I think the strength bonus is more proper. 1887 * added to the damage. I think the strength bonus is more proper.
1946 */ 1888 */
1947 1889
1965 arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level; 1907 arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level;
1966 } 1908 }
1967 else 1909 else
1968 { 1910 {
1969 arrow->stats.wc = op->stats.wc - bow->magic - arrow->magic - arrow->stats.wc + wc_mod; 1911 arrow->stats.wc = op->stats.wc - bow->magic - arrow->magic - arrow->stats.wc + wc_mod;
1970
1971 arrow->level = op->level; 1912 arrow->level = op->level;
1972 } 1913 }
1914
1973 if (arrow->attacktype == AT_PHYSICAL) 1915 if (arrow->attacktype == AT_PHYSICAL)
1974 arrow->attacktype |= bow->attacktype; 1916 arrow->attacktype |= bow->attacktype;
1917
1975 if (bow->slaying != NULL) 1918 if (bow->slaying != NULL)
1976 arrow->slaying = bow->slaying; 1919 arrow->slaying = bow->slaying;
1977 1920
1978 arrow->map = m; 1921 arrow->map = m;
1979 arrow->move_type = MOVE_FLY_LOW; 1922 arrow->move_type = MOVE_FLY_LOW;
1980 arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; 1923 arrow->move_on = MOVE_FLY_LOW | MOVE_WALK;
1981 1924
1982 play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW); 1925 play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW);
1983 tag = arrow->count;
1984 insert_ob_in_map (arrow, m, op, 0); 1926 insert_ob_in_map (arrow, m, op, 0);
1985 1927
1986 if (!was_destroyed (arrow, tag)) 1928 if (!arrow->destroyed ())
1987 move_arrow (arrow); 1929 move_arrow (arrow);
1988 1930
1989 if (op->type == PLAYER) 1931 if (op->type == PLAYER)
1990 { 1932 {
1991 if (was_destroyed (left, left_tag)) 1933 if (left->destroyed ())
1992 esrv_del_item (op->contr, left_tag); 1934 esrv_del_item (op->contr, left->count);
1993 else 1935 else
1994 esrv_send_item (op, left); 1936 esrv_send_item (op, left);
1995 } 1937 }
1938
1996 return 1; 1939 return 1;
1997} 1940}
1998 1941
1999/* Special fire code for players - this takes into 1942/* Special fire code for players - this takes into
2000 * account the special fire modes players can have 1943 * account the special fire modes players can have
2136 case range_misc: 2079 case range_misc:
2137 fire_misc_object (op, dir); 2080 fire_misc_object (op, dir);
2138 return; 2081 return;
2139 2082
2140 case range_golem: /* Control summoned monsters from scrolls */ 2083 case range_golem: /* Control summoned monsters from scrolls */
2141 if (op->contr->ranges[range_golem] == NULL || op->contr->golem_count != op->contr->ranges[range_golem]->count) 2084 if (QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED))
2142 { 2085 {
2143 op->contr->ranges[range_golem] = NULL; 2086 op->contr->ranges[range_golem] = 0;
2144 op->contr->shoottype = range_none; 2087 op->contr->shoottype = range_none;
2145 op->contr->golem_count = 0;
2146 } 2088 }
2147 else 2089 else
2148 control_golem (op->contr->ranges[range_golem], dir); 2090 control_golem (op->contr->ranges[range_golem], dir);
2149 return; 2091 return;
2150 2092
2312move_player_attack (object *op, int dir) 2254move_player_attack (object *op, int dir)
2313{ 2255{
2314 object *tmp, *mon; 2256 object *tmp, *mon;
2315 sint16 nx, ny; 2257 sint16 nx, ny;
2316 int on_battleground; 2258 int on_battleground;
2317 mapstruct *m; 2259 maptile *m;
2318 2260
2319 nx = freearr_x[dir] + op->x; 2261 nx = freearr_x[dir] + op->x;
2320 ny = freearr_y[dir] + op->y; 2262 ny = freearr_y[dir] + op->y;
2321 2263
2322 on_battleground = op_on_battleground (op, NULL, NULL); 2264 on_battleground = op_on_battleground (op, NULL, NULL);
2358 if (tmp == op) 2300 if (tmp == op)
2359 { 2301 {
2360 tmp = tmp->above; 2302 tmp = tmp->above;
2361 continue; 2303 continue;
2362 } 2304 }
2305
2363 if (QUERY_FLAG (tmp, FLAG_ALIVE)) 2306 if (QUERY_FLAG (tmp, FLAG_ALIVE))
2364 { 2307 {
2365 mon = tmp; 2308 mon = tmp;
2366 break; 2309 break;
2367 } 2310 }
2311
2368 if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL)) 2312 if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL))
2369 mon = tmp; 2313 mon = tmp;
2314
2370 tmp = tmp->above; 2315 tmp = tmp->above;
2371 } 2316 }
2372 2317
2373 if (mon == NULL) /* This happens anytime the player tries to move */ 2318 if (mon == NULL) /* This happens anytime the player tries to move */
2374 return; /* into a wall */ 2319 return; /* into a wall */
2393 * player owns it and it is either friendly or unagressive. 2338 * player owns it and it is either friendly or unagressive.
2394 */ 2339 */
2395 if ((op->type == PLAYER) 2340 if ((op->type == PLAYER)
2396#if COZY_SERVER 2341#if COZY_SERVER
2397 && 2342 &&
2398 ((get_owner (mon) && get_owner (mon)->contr 2343 ((mon->owner && mon->owner->contr
2399 && same_party (get_owner (mon)->contr->party, op->contr->party)) || get_owner (mon) == op) 2344 && same_party (mon->owner->contr->party, op->contr->party)) || mon->owner == op)
2400#else 2345#else
2401 && get_owner (mon) == op 2346 && mon->owner == op
2402#endif 2347#endif
2403 && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) 2348 && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)))
2404 { 2349 {
2405 /* If we're braced, we don't want to switch places with it */ 2350 /* If we're braced, we don't want to switch places with it */
2406 if (op->contr->braced) 2351 if (op->contr->braced)
2593 /* I've been seeing crashes where the golem has been destroyed, but 2538 /* I've been seeing crashes where the golem has been destroyed, but
2594 * the player object still points to the defunct golem. The code that 2539 * the player object still points to the defunct golem. The code that
2595 * destroys the golem looks correct, and it doesn't always happen, so 2540 * destroys the golem looks correct, and it doesn't always happen, so
2596 * put this in a a workaround to clean up the golem pointer. 2541 * put this in a a workaround to clean up the golem pointer.
2597 */ 2542 */
2598 if (op->contr->ranges[range_golem] &&
2599 ((op->contr->golem_count != op->contr->ranges[range_golem]->count) || QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED))) 2543 if (op->contr->ranges[range_golem] && QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED))
2600 {
2601 op->contr->ranges[range_golem] = NULL; 2544 op->contr->ranges[range_golem] = 0;
2602 op->contr->golem_count = 0;
2603 }
2604 2545
2605 /* call this here - we also will call this in do_ericserver, but 2546 /* call this here - we also will call this in do_ericserver, but
2606 * the players time has been increased when doericserver has been 2547 * the players time has been increased when doericserver has been
2607 * called, so we recheck it here. 2548 * called, so we recheck it here.
2608 */ 2549 */
2609 HandleClient (&op->contr->socket, op->contr); 2550 HandleClient (op->contr->socket, op->contr);
2610 if (op->speed_left < 0) 2551 if (op->speed_left < 0)
2611 return 0; 2552 return 0;
2612 2553
2613 if (op->direction && (op->contr->run_on || op->contr->fire_on)) 2554 if (op->direction && (op->contr->run_on || op->contr->fire_on))
2614 { 2555 {
2623 if (op->speed_left > 0) 2564 if (op->speed_left > 0)
2624 return 1; 2565 return 1;
2625 else 2566 else
2626 return 0; 2567 return 0;
2627 } 2568 }
2569
2628 return 0; 2570 return 0;
2629} 2571}
2630 2572
2631int 2573int
2632save_life (object *op) 2574save_life (object *op)
2633{ 2575{
2634 object *tmp;
2635
2636 if (!QUERY_FLAG (op, FLAG_LIFESAVE)) 2576 if (!QUERY_FLAG (op, FLAG_LIFESAVE))
2637 return 0; 2577 return 0;
2638 2578
2639 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 2579 for (object *tmp = op->inv; tmp; tmp = tmp->below)
2640 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) 2580 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE))
2641 { 2581 {
2642 play_sound_map (op->map, op->x, op->y, SOUND_OB_EVAPORATE); 2582 play_sound_map (op->map, op->x, op->y, SOUND_OB_EVAPORATE);
2643 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); 2583 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp));
2584
2644 if (op->contr) 2585 if (op->contr)
2645 esrv_del_item (op->contr, tmp->count); 2586 esrv_del_item (op->contr, tmp->count);
2646 remove_ob (tmp); 2587
2647 free_object (tmp); 2588 tmp->destroy ();
2648 CLEAR_FLAG (op, FLAG_LIFESAVE); 2589 CLEAR_FLAG (op, FLAG_LIFESAVE);
2590
2649 if (op->stats.hp < 0) 2591 if (op->stats.hp < 0)
2650 op->stats.hp = op->stats.maxhp; 2592 op->stats.hp = op->stats.maxhp;
2593
2651 if (op->stats.food < 0) 2594 if (op->stats.food < 0)
2652 op->stats.food = 999; 2595 op->stats.food = 999;
2596
2653 fix_player (op); 2597 fix_player (op);
2654 return 1; 2598 return 1;
2655 } 2599 }
2600
2656 LOG (llevError, "Error: LIFESAVE set without applied object.\n"); 2601 LOG (llevError, "Error: LIFESAVE set without applied object.\n");
2657 CLEAR_FLAG (op, FLAG_LIFESAVE); 2602 CLEAR_FLAG (op, FLAG_LIFESAVE);
2658 enter_player_savebed (op); /* bring him home. */ 2603 enter_player_savebed (op); /* bring him home. */
2659 return 0; 2604 return 0;
2660} 2605}
2674 next = op->below; /* Make sure we have a good value, in case 2619 next = op->below; /* Make sure we have a good value, in case
2675 * we remove object 'op' 2620 * we remove object 'op'
2676 */ 2621 */
2677 if (QUERY_FLAG (op, FLAG_UNPAID)) 2622 if (QUERY_FLAG (op, FLAG_UNPAID))
2678 { 2623 {
2679 remove_ob (op); 2624 op->remove ();
2680 op->x = env->x; 2625 op->x = env->x;
2681 op->y = env->y; 2626 op->y = env->y;
2682 if (env->type == PLAYER) 2627 if (env->type == PLAYER)
2683 esrv_del_item (env->contr, op->count); 2628 esrv_del_item (env->contr, op->count);
2684 insert_ob_in_map (op, env->map, NULL, 0); 2629 insert_ob_in_map (op, env->map, NULL, 0);
2685 } 2630 }
2686 else if (op->inv) 2631 else if (op->inv)
2687 remove_unpaid_objects (op->inv, env); 2632 remove_unpaid_objects (op->inv, env);
2633
2688 op = next; 2634 op = next;
2689 } 2635 }
2690} 2636}
2691 2637
2692 2638
2707 strcpy (buf2, " R.I.P.\n\n"); 2653 strcpy (buf2, " R.I.P.\n\n");
2708 if (op->type == PLAYER) 2654 if (op->type == PLAYER)
2709 sprintf (buf, "%s the %s\n", &op->name, op->contr->title); 2655 sprintf (buf, "%s the %s\n", &op->name, op->contr->title);
2710 else 2656 else
2711 sprintf (buf, "%s\n", &op->name); 2657 sprintf (buf, "%s\n", &op->name);
2658
2712 strncat (buf2, " ", 20 - strlen (buf) / 2); 2659 strncat (buf2, " ", 20 - strlen (buf) / 2);
2713 strcat (buf2, buf); 2660 strcat (buf2, buf);
2714 if (op->type == PLAYER) 2661 if (op->type == PLAYER)
2715 sprintf (buf, "who was in level %d when killed\n", op->level); 2662 sprintf (buf, "who was in level %d when killed\n", op->level);
2716 else 2663 else
2717 sprintf (buf, "who was in level %d when died.\n\n", op->level); 2664 sprintf (buf, "who was in level %d when died.\n\n", op->level);
2665
2718 strncat (buf2, " ", 20 - strlen (buf) / 2); 2666 strncat (buf2, " ", 20 - strlen (buf) / 2);
2719 strcat (buf2, buf); 2667 strcat (buf2, buf);
2720 if (op->type == PLAYER) 2668 if (op->type == PLAYER)
2721 { 2669 {
2722 sprintf (buf, "by %s.\n\n", op->contr->killer); 2670 sprintf (buf, "by %s.\n\n", op->contr->killer);
2723 strncat (buf2, " ", 21 - strlen (buf) / 2); 2671 strncat (buf2, " ", 21 - strlen (buf) / 2);
2724 strcat (buf2, buf); 2672 strcat (buf2, buf);
2725 } 2673 }
2674
2726 strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now)); 2675 strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now));
2727 strncat (buf2, " ", 20 - strlen (buf) / 2); 2676 strncat (buf2, " ", 20 - strlen (buf) / 2);
2728 strcat (buf2, buf); 2677 strcat (buf2, buf);
2678
2729 return buf2; 2679 return buf2;
2730} 2680}
2731 2681
2732 2682
2733 2683
2952{ 2902{
2953 char buf[MAX_BUF]; 2903 char buf[MAX_BUF];
2954 int x, y; 2904 int x, y;
2955 2905
2956 //int i; 2906 //int i;
2957 mapstruct *map; /* this is for resurrection */ 2907 maptile *map; /* this is for resurrection */
2958 2908
2959 /* int z; 2909 /* int z;
2960 int num_stats_lose; 2910 int num_stats_lose;
2961 int lost_a_stat; 2911 int lost_a_stat;
2962 int lose_this_stat; 2912 int lose_this_stat;
2977 { 2927 {
2978 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You have been defeated in combat!"); 2928 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You have been defeated in combat!");
2979 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Local medics have saved your life..."); 2929 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Local medics have saved your life...");
2980 2930
2981 /* restore player */ 2931 /* restore player */
2982 at = find_archetype ("poisoning"); 2932 at = archetype::find ("poisoning");
2983 tmp = present_arch_in_ob (at, op); 2933 tmp = present_arch_in_ob (at, op);
2984 if (tmp) 2934 if (tmp)
2985 { 2935 {
2986 remove_ob (tmp); 2936 tmp->destroy ();
2987 free_object (tmp);
2988 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); 2937 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed");
2989 } 2938 }
2990 2939
2991 at = find_archetype ("confusion"); 2940 at = archetype::find ("confusion");
2992 tmp = present_arch_in_ob (at, op); 2941 tmp = present_arch_in_ob (at, op);
2993 if (tmp) 2942 if (tmp)
2994 { 2943 {
2995 remove_ob (tmp); 2944 tmp->destroy ();
2996 free_object (tmp);
2997 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); 2945 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer");
2998 } 2946 }
2999 2947
3000 cure_disease (op, 0); /* remove any disease */ 2948 cure_disease (op, 0); /* remove any disease */
3001 op->stats.hp = op->stats.maxhp; 2949 op->stats.hp = op->stats.maxhp;
3002 if (op->stats.food <= 0) 2950 if (op->stats.food <= 0)
3003 op->stats.food = 999; 2951 op->stats.food = 999;
3004 2952
3005 /* create a bodypart-trophy to make the winner happy */ 2953 /* create a bodypart-trophy to make the winner happy */
3006 tmp = arch_to_object (find_archetype ("finger")); 2954 tmp = arch_to_object (archetype::find ("finger"));
3007 if (tmp != NULL) 2955 if (tmp != NULL)
3008 { 2956 {
3009 sprintf (buf, "%s's finger", &op->name); 2957 sprintf (buf, "%s's finger", &op->name);
3010 tmp->name = buf; 2958 tmp->name = buf;
3011 sprintf (buf, " This finger has been cut off %s\n" 2959 sprintf (buf, " This finger has been cut off %s\n"
3108 lost_a_stat = 1; 3056 lost_a_stat = 1;
3109 } 3057 }
3110 else 3058 else
3111 { 3059 {
3112 /* deplete a stat */ 3060 /* deplete a stat */
3113 archetype *deparch = find_archetype ("depletion"); 3061 archetype *deparch = archetype::find ("depletion");
3114 object *dep; 3062 object *dep;
3115 3063
3116 dep = present_arch_in_ob (deparch, op); 3064 dep = present_arch_in_ob (deparch, op);
3117 if (!dep) 3065 if (!dep)
3118 { 3066 {
3178 /* determine_god() seems to not work sometimes... why is this? 3126 /* determine_god() seems to not work sometimes... why is this?
3179 Should I be using something else? GD */ 3127 Should I be using something else? GD */
3180 const char *god = determine_god (op); 3128 const char *god = determine_god (op);
3181 3129
3182 if (god && (strcmp (god, "none"))) 3130 if (god && (strcmp (god, "none")))
3183 new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief " "moment you feel the holy presence of %s protecting" " you.", god); 3131 new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief moment you feel the holy presence of %s protecting" " you.", god);
3184 else 3132 else
3185 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you."); 3133 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you.");
3186 } 3134 }
3135#else
3136 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely.");
3187#endif 3137#endif
3188 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely.");
3189 3138
3190 /* Put a gravestone up where the character 'almost' died. List the 3139 /* Put a gravestone up where the character 'almost' died. List the
3191 * exp loss on the stone. 3140 * exp loss on the stone.
3192 */ 3141 */
3193 tmp = arch_to_object (find_archetype ("gravestone")); 3142 tmp = arch_to_object (archetype::find ("gravestone"));
3194 sprintf (buf, "%s's gravestone", &op->name); 3143 sprintf (buf, "%s's gravestone", &op->name);
3195 tmp->name = buf; 3144 tmp->name = buf;
3196 sprintf (buf, "%s's gravestones", &op->name); 3145 sprintf (buf, "%s's gravestones", &op->name);
3197 tmp->name_pl = buf; 3146 tmp->name_pl = buf;
3198 sprintf (buf, "RIP\nHere rests the hero %s the %s,\n" "who was killed\n" "by %s.\n", &op->name, op->contr->title, op->contr->killer); 3147 sprintf (buf, "RIP\nHere rests the hero %s the %s,\n" "who was killed\n" "by %s.\n", &op->name, op->contr->title, op->contr->killer);
3199 tmp->msg = buf; 3148 tmp->msg = buf;
3200 tmp->x = op->x, tmp->y = op->y; 3149 tmp->x = op->x, tmp->y = op->y;
3201 insert_ob_in_map (tmp, op->map, NULL, 0); 3150 insert_ob_in_map (tmp, op->map, NULL, 0);
3202 3151
3203 /**************************************/ 3152 /**************************************/
3204 /* */ 3153 /* */
3205 /* Subtract the experience points, */ 3154 /* Subtract the experience points, */
3206 /* if we died cause of food, give us */ 3155 /* if we died cause of food, give us */
3207 /* food, and reset HP's... */ 3156 /* food, and reset HP's... */
3208 /* */ 3157 /* */
3209
3210 /**************************************/ 3158 /**************************************/
3211 3159
3212 /* remove any poisoning and confusion the character may be suffering. */ 3160 /* remove any poisoning and confusion the character may be suffering. */
3213 /* restore player */ 3161 /* restore player */
3214 at = find_archetype ("poisoning"); 3162 at = archetype::find ("poisoning");
3163 tmp = present_arch_in_ob (at, op);
3164
3165 if (tmp)
3166 {
3167 tmp->destroy ();
3168 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed");
3169 }
3170
3171 at = archetype::find ("confusion");
3215 tmp = present_arch_in_ob (at, op); 3172 tmp = present_arch_in_ob (at, op);
3216 if (tmp) 3173 if (tmp)
3217 { 3174 {
3218 remove_ob (tmp); 3175 tmp->destroy ();
3219 free_object (tmp);
3220 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed");
3221 }
3222
3223 at = find_archetype ("confusion");
3224 tmp = present_arch_in_ob (at, op);
3225 if (tmp)
3226 {
3227 remove_ob (tmp);
3228 free_object (tmp);
3229 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); 3176 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer");
3230 } 3177 }
3178
3231 cure_disease (op, 0); /* remove any disease */ 3179 cure_disease (op, 0); /* remove any disease */
3232 3180
3233 /*add_exp(op, (op->stats.exp * -0.20)); */ 3181 /*add_exp(op, (op->stats.exp * -0.20)); */
3234 apply_death_exp_penalty (op); 3182 apply_death_exp_penalty (op);
3235 if (op->stats.food < 100) 3183 if (op->stats.food < 100)
3245 */ 3193 */
3246 3194
3247 if (is_in_shop (op)) 3195 if (is_in_shop (op))
3248 remove_unpaid_objects (op->inv, op); 3196 remove_unpaid_objects (op->inv, op);
3249 3197
3250 /****************************************/ 3198 /****************************************/
3251 /* */ 3199 /* */
3252 /* Move player to his current respawn- */ 3200 /* Move player to his current respawn- */
3253 /* position (usually last savebed) */ 3201 /* position (usually last savebed) */
3254 /* */ 3202 /* */
3255
3256 /****************************************/ 3203 /****************************************/
3257 3204
3258 enter_player_savebed (op); 3205 enter_player_savebed (op);
3259 3206
3260 /* Save the player before inserting the force to reduce 3207 /* Save the player before inserting the force to reduce
3261 * chance of abuse. 3208 * chance of abuse.
3268 * spell effects. So first see if there is a spell effect 3215 * spell effects. So first see if there is a spell effect
3269 * on the space that might harm the player. 3216 * on the space that might harm the player.
3270 */ 3217 */
3271 will_kill_again = 0; 3218 will_kill_again = 0;
3272 for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above) 3219 for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above)
3273 {
3274 if (tmp->type == SPELL_EFFECT) 3220 if (tmp->type == SPELL_EFFECT)
3275 will_kill_again |= tmp->attacktype; 3221 will_kill_again |= tmp->attacktype;
3276 } 3222
3277 if (will_kill_again) 3223 if (will_kill_again)
3278 { 3224 {
3279 object *force; 3225 object *force;
3280 int at; 3226 int at;
3281 3227
3283 /* 50 ticks should be enough time for the spell to abate */ 3229 /* 50 ticks should be enough time for the spell to abate */
3284 force->speed = 0.1; 3230 force->speed = 0.1;
3285 force->speed_left = -5.0; 3231 force->speed_left = -5.0;
3286 SET_FLAG (force, FLAG_APPLIED); 3232 SET_FLAG (force, FLAG_APPLIED);
3287 for (at = 0; at < NROFATTACKS; at++) 3233 for (at = 0; at < NROFATTACKS; at++)
3288 {
3289 if (will_kill_again & (1 << at)) 3234 if (will_kill_again & (1 << at))
3290 force->resist[at] = 100; 3235 force->resist[at] = 100;
3291 } 3236
3292 insert_ob_in_ob (force, op); 3237 insert_ob_in_ob (force, op);
3293 fix_player (op); 3238 fix_player (op);
3294 3239
3295 } 3240 }
3296 3241
3306 op->contr->party = NULL; 3251 op->contr->party = NULL;
3307 if (settings.set_title == TRUE) 3252 if (settings.set_title == TRUE)
3308 op->contr->own_title[0] = '\0'; 3253 op->contr->own_title[0] = '\0';
3309 new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf); 3254 new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf);
3310 check_score (op); 3255 check_score (op);
3256
3311 if (op->contr->ranges[range_golem] != NULL) 3257 if (op->contr->ranges[range_golem])
3312 { 3258 {
3313 remove_friendly_object (op->contr->ranges[range_golem]); 3259 remove_friendly_object (op->contr->ranges[range_golem]);
3314 remove_ob (op->contr->ranges[range_golem]); 3260 op->contr->ranges[range_golem]->destroy ();
3315 free_object (op->contr->ranges[range_golem]);
3316 op->contr->ranges[range_golem] = NULL; 3261 op->contr->ranges[range_golem] = 0;
3317 op->contr->golem_count = 0;
3318 } 3262 }
3263
3319 loot_object (op); /* Remove some of the items for good */ 3264 loot_object (op); /* Remove some of the items for good */
3320 remove_ob (op); 3265 op->remove ();
3321 op->direction = 0; 3266 op->direction = 0;
3322 3267
3323 if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp) 3268 if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp)
3324 { 3269 {
3325 delete_character (op->name, 0); 3270 delete_character (op->name, 0);
3350 } 3295 }
3351 3296
3352 play_again (op); 3297 play_again (op);
3353 3298
3354 /* peterm: added to create a corpse at deathsite. */ 3299 /* peterm: added to create a corpse at deathsite. */
3355 tmp = arch_to_object (find_archetype ("corpse_pl")); 3300 tmp = arch_to_object (archetype::find ("corpse_pl"));
3356 sprintf (buf, "%s", &op->name); 3301 sprintf (buf, "%s", &op->name);
3357 tmp->name = tmp->name_pl = buf; 3302 tmp->name = tmp->name_pl = buf;
3358 tmp->level = op->level; 3303 tmp->level = op->level;
3359 tmp->x = x; 3304 tmp->x = x;
3360 tmp->y = y; 3305 tmp->y = y;
3378 for (tmp = op->inv; tmp != NULL; tmp = next) 3323 for (tmp = op->inv; tmp != NULL; tmp = next)
3379 { 3324 {
3380 next = tmp->below; 3325 next = tmp->below;
3381 if (tmp->type == EXPERIENCE || tmp->invisible) 3326 if (tmp->type == EXPERIENCE || tmp->invisible)
3382 continue; 3327 continue;
3383 remove_ob (tmp); 3328 tmp->remove ();
3384 tmp->x = op->x, tmp->y = op->y; 3329 tmp->x = op->x, tmp->y = op->y;
3385 if (tmp->type == CONTAINER) 3330 if (tmp->type == CONTAINER)
3386 { /* empty container to ground */ 3331 { /* empty container to ground */
3387 loot_object (tmp); 3332 loot_object (tmp);
3388 } 3333 }
3389 if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(RANDOM () % 3))) 3334 if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(RANDOM () % 3)))
3390 { 3335 {
3391 if (tmp->nrof > 1) 3336 if (tmp->nrof > 1)
3392 { 3337 {
3393 tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); 3338 tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1));
3394 free_object (tmp2); 3339 tmp2->destroy ();
3395 insert_ob_in_map (tmp, op->map, NULL, 0); 3340 insert_ob_in_map (tmp, op->map, NULL, 0);
3396 } 3341 }
3397 else 3342 else
3398 free_object (tmp); 3343 tmp->destroy ();
3399 } 3344 }
3400 else 3345 else
3401 insert_ob_in_map (tmp, op->map, NULL, 0); 3346 insert_ob_in_map (tmp, op->map, NULL, 0);
3402 } 3347 }
3403} 3348}
3468 if (op->type == PLAYER) 3413 if (op->type == PLAYER)
3469 new_draw_info_format (NDI_UNIQUE, 0, op, "You cast %s.", &spob->name); 3414 new_draw_info_format (NDI_UNIQUE, 0, op, "You cast %s.", &spob->name);
3470 3415
3471 cast_spell (op, throw_ob, dir, spob, NULL); 3416 cast_spell (op, throw_ob, dir, spob, NULL);
3472 3417
3473 if (!QUERY_FLAG (throw_ob, FLAG_REMOVED)) 3418 throw_ob->destroy ();
3474 remove_ob (throw_ob);
3475 free_object (throw_ob);
3476} 3419}
3477 3420
3478void 3421void
3479make_visible (object *op) 3422make_visible (object *op)
3480{ 3423{
3596int 3539int
3597stand_near_hostile (object *who) 3540stand_near_hostile (object *who)
3598{ 3541{
3599 object *tmp = NULL; 3542 object *tmp = NULL;
3600 int i, friendly = 0, player = 0, mflags; 3543 int i, friendly = 0, player = 0, mflags;
3601 mapstruct *m; 3544 maptile *m;
3602 sint16 x, y; 3545 sint16 x, y;
3603 3546
3604 if (!who) 3547 if (!who)
3605 return 0; 3548 return 0;
3606 3549
3687 3630
3688 /* only the viewable area the player sees is updated by LOS 3631 /* only the viewable area the player sees is updated by LOS
3689 * code, so we need to restrict ourselves to that range of values 3632 * code, so we need to restrict ourselves to that range of values
3690 * for any meaningful values. 3633 * for any meaningful values.
3691 */ 3634 */
3692 if (FABS (dx) <= (pl->contr->socket.mapx / 2) && 3635 if (FABS (dx) <= (pl->contr->socket->mapx / 2) &&
3693 FABS (dy) <= (pl->contr->socket.mapy / 2) && 3636 FABS (dy) <= (pl->contr->socket->mapy / 2) &&
3694 !pl->contr->blocked_los[dx + (pl->contr->socket.mapx / 2)][dy + (pl->contr->socket.mapy / 2)]) 3637 !pl->contr->blocked_los[dx + (pl->contr->socket->mapx / 2)][dy + (pl->contr->socket->mapy / 2)])
3695 return 1; 3638 return 1;
3696 op = op->more; 3639 op = op->more;
3697 } 3640 }
3698 return 0; 3641 return 0;
3699} 3642}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines