ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/player.C
(Generate patch)

Comparing deliantra/server/server/player.C (file contents):
Revision 1.23 by root, Thu Sep 14 22:34:04 2006 UTC vs.
Revision 1.53 by root, Fri Dec 22 16:03:21 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
42player * 37player *
43find_player (const char *plname) 38find_player (const char *plname)
44{ 39{
45 player *pl; 40 player *pl;
46 41
47 for (pl = first_player; pl != NULL; pl = pl->next) 42 for (pl = first_player; pl; pl = pl->next)
48 { 43 {
49 if (pl->ob != NULL && !strcmp (query_name (pl->ob), plname)) 44 if (pl->obL && !strcmp (query_name (pl->ob), plname))
50 return pl; 45 return pl;
51 }; 46 };
47
52 return NULL; 48 return 0;
53} 49}
54 50
55player * 51player *
56find_player_partial_name (const char *plname) 52find_player_partial_name (const char *plname)
57{ 53{
58 player *pl; 54 player *pl;
59 player *found = NULL; 55 player *found = NULL;
60 size_t namelen = strlen (plname); 56 size_t namelen = strlen (plname);
61 57
62 for (pl = first_player; pl != NULL; pl = pl->next) 58 for (pl = first_player; pl; pl = pl->next)
63 { 59 {
64 if ((size_t) strlen (pl->ob->name) < namelen) 60 if ((size_t) strlen (pl->ob->name) < namelen)
65 continue; 61 continue;
66 62
67 if (!strcmp (pl->ob->name, plname)) 63 if (!strcmp (pl->ob->name, plname))
68 return pl; 64 return pl;
69 65
70 if (!strncasecmp (pl->ob->name, plname, namelen)) 66 if (!strncasecmp (pl->ob->name, plname, namelen))
71 { 67 {
72 if (found) 68 if (found)
73 return NULL; 69 return 0;
74 70
75 found = pl; 71 found = pl;
76 } 72 }
77 } 73 }
74
78 return found; 75 return found;
79} 76}
80 77
81void 78void
82display_motd (const object *op) 79display_motd (const object *op)
87 int comp; 84 int comp;
88 int size; 85 int size;
89 86
90 sprintf (buf, "%s/%s", settings.confdir, settings.motd); 87 sprintf (buf, "%s/%s", settings.confdir, settings.motd);
91 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) 88 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL)
92 {
93 return; 89 return;
94 } 90
95 motd[0] = '\0'; 91 motd[0] = '\0';
96 size = 0; 92 size = 0;
93
97 while (fgets (buf, MAX_BUF, fp) != NULL) 94 while (fgets (buf, MAX_BUF, fp))
98 { 95 {
99 if (*buf == '#') 96 if (*buf == '#')
100 continue; 97 continue;
98
101 strncat (motd + size, buf, HUGE_BUF - size); 99 strncat (motd + size, buf, HUGE_BUF - size);
102 size += strlen (buf); 100 size += strlen (buf);
103 } 101 }
102
104 draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_MOTD, MSG_SUBTYPE_NONE, motd, NULL); 103 draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_MOTD, MSG_SUBTYPE_NONE, motd, NULL);
105 close_and_delete (fp, comp); 104 close_and_delete (fp, comp);
106} 105}
107 106
108void 107void
114 int comp; 113 int comp;
115 int size; 114 int size;
116 115
117 sprintf (buf, "%s/%s", settings.confdir, settings.rules); 116 sprintf (buf, "%s/%s", settings.confdir, settings.rules);
118 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) 117 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL)
119 {
120 return; 118 return;
121 } 119
122 rules[0] = '\0'; 120 rules[0] = '\0';
123 size = 0; 121 size = 0;
122
124 while (fgets (buf, MAX_BUF, fp) != NULL) 123 while (fgets (buf, MAX_BUF, fp))
125 { 124 {
126 if (*buf == '#') 125 if (*buf == '#')
127 continue; 126 continue;
127
128 if (size + strlen (buf) >= HUGE_BUF) 128 if (size + strlen (buf) >= HUGE_BUF)
129 { 129 {
130 LOG (llevDebug, "Warning, rules size is > %d bytes.\n", HUGE_BUF); 130 LOG (llevDebug, "Warning, rules size is > %d bytes.\n", HUGE_BUF);
131 break; 131 break;
132 } 132 }
133
133 strncat (rules + size, buf, HUGE_BUF - size); 134 strncat (rules + size, buf, HUGE_BUF - size);
134 size += strlen (buf); 135 size += strlen (buf);
135 } 136 }
137
136 draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_RULES, rules, NULL); 138 draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_RULES, rules, NULL);
137 close_and_delete (fp, comp); 139 close_and_delete (fp, comp);
138} 140}
139 141
140void 142void
148 int size; 150 int size;
149 151
150 sprintf (buf, "%s/%s", settings.confdir, settings.news); 152 sprintf (buf, "%s/%s", settings.confdir, settings.news);
151 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) 153 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL)
152 return; 154 return;
155
153 news[0] = '\0'; 156 news[0] = '\0';
154 subject[0] = '\0'; 157 subject[0] = '\0';
155 size = 0; 158 size = 0;
159
156 while (fgets (buf, MAX_BUF, fp) != NULL) 160 while (fgets (buf, MAX_BUF, fp) != NULL)
157 { 161 {
158 if (*buf == '#') 162 if (*buf == '#')
159 continue; 163 continue;
164
160 if (*buf == '%') 165 if (*buf == '%')
161 { /* send one news */ 166 { /* send one news */
162 if (size > 0) 167 if (size > 0)
163 draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, "INFORMATION: %s\n%s", "%s\n%s", subject, news); /*send previously read news */ 168 draw_ext_info_format (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_NEWS, "INFORMATION: %s\n%s", "%s\n%s", subject, news); /*send previously read news */
164 strcpy (subject, buf + 1); 169 strcpy (subject, buf + 1);
191 return 0; 196 return 0;
192 197
193 for (; *cp != '\0'; cp++) 198 for (; *cp != '\0'; cp++)
194 if (!((*cp >= 'a' && *cp <= 'z') || (*cp >= 'A' && *cp <= 'Z')) && *cp != '-' && *cp != '_') 199 if (!((*cp >= 'a' && *cp <= 'z') || (*cp >= 'A' && *cp <= 'Z')) && *cp != '-' && *cp != '_')
195 return 0; 200 return 0;
201
196 return 1; 202 return 1;
197} 203}
198 204
199/* This no longer sets the player map. Also, it now updates 205/* This no longer sets the player map. Also, it now updates
200 * all the pointers so the caller doesn't need to do that. 206 * all the pointers so the caller doesn't need to do that.
208 * the one that is passed. 214 * the one that is passed.
209 */ 215 */
210static player * 216static player *
211get_player (player *p) 217get_player (player *p)
212{ 218{
213 object *op = arch_to_object (get_player_archetype (NULL)); 219 object *op = arch_to_object (get_player_archetype (0));
214 int i; 220 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 221
238 /* Clears basically the entire player structure except 222 /* Clears basically the entire player structure except
239 * for next and socket. 223 * for next and socket.
240 */ 224 */
241 p->clear (); 225 p->clear ();
260 op->speed_left = 0.5; 244 op->speed_left = 0.5;
261 op->speed = 1.0; 245 op->speed = 1.0;
262 op->direction = 5; /* So player faces south */ 246 op->direction = 5; /* So player faces south */
263 op->stats.wc = 2; 247 op->stats.wc = 2;
264 op->run_away = 25; /* Then we panick... */ 248 op->run_away = 25; /* Then we panick... */
249
250 {
251 int oldmon = p->ns->monitor_spells; // what a hack
265 p->socket.monitor_spells = 0; /* Needed because esrv_update_spells( ) gets called by roll_stats */ 252 p->ns->monitor_spells = 0; /* Needed because esrv_update_spells( ) gets called by roll_stats */
266
267 roll_stats (op); 253 roll_stats (op);
254 p->ns->monitor_spells = oldmon;
255 }
268 p->state = ST_ROLL_STAT; 256 p->ns->state = ST_ROLL_STAT;
269 clear_los (op); 257 clear_los (op);
270 258
271 p->gen_sp_armour = 10; 259 p->gen_sp_armour = 10;
272 p->last_speed = -1; 260 p->last_speed = -1;
273 p->shoottype = range_none; 261 p->shoottype = range_none;
277 p->usekeys = containers; 265 p->usekeys = containers;
278 p->last_weapon_sp = -1; 266 p->last_weapon_sp = -1;
279 p->peaceful = 1; /* default peaceful */ 267 p->peaceful = 1; /* default peaceful */
280 p->do_los = 1; 268 p->do_los = 1;
281 p->explore = 0; 269 p->explore = 0;
282 p->no_shout = 0; /* default can shout */
283 270
284 assign (p->title, op->arch->clone.name); 271 assign (p->title, op->arch->clone.name);
285 op->race = op->arch->clone.race; 272 op->race = op->arch->clone.race;
286 273
287 CLEAR_FLAG (op, FLAG_READY_SKILL); 274 CLEAR_FLAG (op, FLAG_READY_SKILL);
294 for (i = 0; i < NUM_SKILLS; i++) 281 for (i = 0; i < NUM_SKILLS; i++)
295 { 282 {
296 p->last_skill_exp[i] = -1; 283 p->last_skill_exp[i] = -1;
297 p->last_skill_ob[i] = NULL; 284 p->last_skill_ob[i] = NULL;
298 } 285 }
286
299 for (i = 0; i < NROFATTACKS; i++) 287 for (i = 0; i < NROFATTACKS; i++)
300 {
301 p->last_resist[i] = -1; 288 p->last_resist[i] = -1;
302 } 289
303 p->last_stats.exp = -1; 290 p->last_stats.exp = -1;
304 p->last_weight = (uint32) - 1; 291 p->last_weight = (uint32) - 1;
305 292
306 p->socket.update_look = 0; 293 p->ns->update_look = 0;
307 p->socket.look_position = 0; 294 p->ns->look_position = 0;
295
308 return p; 296 return p;
309} 297}
310 298
311/* This loads the first map an puts the player on it. */ 299/* This loads the first map an puts the player on it. */
312static void 300static void
313set_first_map (object *op) 301set_first_map (object *op)
314{ 302{
315 strcpy (op->contr->maplevel, first_map_path); 303 strcpy (op->contr->maplevel, first_map_path);
316 op->x = -1; 304 op->x = -1;
317 op->y = -1; 305 op->y = -1;
318 enter_exit (op, NULL); 306 enter_exit (op, 0);
319} 307}
320 308
321/* Tries to add player on the connection passwd in ns. 309/* Tries to add player on the connection passwd in ns.
322 * All we can really get in this is some settings like host and display 310 * All we can really get in this is some settings like host and display
323 * mode. 311 * mode.
324 */ 312 */
325 313
326int 314int
327add_player (NewSocket * ns) 315add_player (client *ns)
328{ 316{
329 player *p; 317 player *p = new player;
330 318
319 p->ns = ns;
320 ns->pl = p;
321
322 p->next = first_player;
323 first_player = p;
324
331 p = get_player (NULL); 325 p = get_player (p);
332 p->socket = *ns; 326
333 p->socket.faces_sent = (uint8 *) malloc (p->socket.faces_sent_len * sizeof (*p->socket.faces_sent));
334 if (p->socket.faces_sent == NULL)
335 fatal (OUT_OF_MEMORY);
336 memcpy (p->socket.faces_sent, ns->faces_sent, p->socket.faces_sent_len * sizeof (*p->socket.faces_sent));
337 /* Needed because the socket we just copied over needs to be cleared.
338 * Note that this can result in a client reset if there is partial data
339 * on the uncoming socket.
340 */
341 p->socket.inbuf.len = 0;
342 set_first_map (p->ob); 327 set_first_map (p->ob);
343 328
344 CLEAR_FLAG (p->ob, FLAG_FRIENDLY); 329 CLEAR_FLAG (p->ob, FLAG_FRIENDLY);
345 add_friendly_object (p->ob); 330 add_friendly_object (p->ob);
346 send_rules (p->ob); 331 send_rules (p->ob);
347 send_news (p->ob); 332 send_news (p->ob);
348 display_motd (p->ob); 333 display_motd (p->ob);
334
349 get_name (p->ob); 335 get_name (p->ob);
336
350 return 0; 337 return 0;
351} 338}
352 339
353/* 340/*
354 * get_player_archetype() return next player archetype from archetype 341 * get_player_archetype() return next player archetype from archetype
364 { 351 {
365 if (at == NULL || at->next == NULL) 352 if (at == NULL || at->next == NULL)
366 at = first_archetype; 353 at = first_archetype;
367 else 354 else
368 at = at->next; 355 at = at->next;
356
369 if (at->clone.type == PLAYER) 357 if (at->clone.type == PLAYER)
370 return at; 358 return at;
359
371 if (at == start) 360 if (at == start)
372 { 361 {
373 LOG (llevError, "No Player archetypes\n"); 362 LOG (llevError, "No Player archetypes\n");
374 exit (-1); 363 exit (-1);
375 } 364 }
376 } 365 }
377} 366}
378
379 367
380object * 368object *
381get_nearest_player (object *mon) 369get_nearest_player (object *mon)
382{ 370{
383 object *op = NULL; 371 object *op = NULL;
489path_to_player (object *mon, object *pl, unsigned mindiff) 477path_to_player (object *mon, object *pl, unsigned mindiff)
490{ 478{
491 rv_vector rv; 479 rv_vector rv;
492 sint16 x, y; 480 sint16 x, y;
493 int lastx, lasty, dir, i, diff, firstdir = 0, lastdir, max = MAX_SPACES, mflags, blocked; 481 int lastx, lasty, dir, i, diff, firstdir = 0, lastdir, max = MAX_SPACES, mflags, blocked;
494 mapstruct *m, *lastmap; 482 maptile *m, *lastmap;
495 483
496 get_rangevector (mon, pl, &rv, 0); 484 get_rangevector (mon, pl, &rv, 0);
497 485
498 if (rv.distance < mindiff) 486 if (rv.distance < mindiff)
499 return 0; 487 return 0;
643 (op->type == ARMOUR || op->type == BOOTS || 631 (op->type == ARMOUR || op->type == BOOTS ||
644 op->type == CLOAK || op->type == HELMET || 632 op->type == CLOAK || op->type == HELMET ||
645 op->type == SHIELD || op->type == GLOVES || 633 op->type == SHIELD || op->type == GLOVES ||
646 op->type == BRACERS || op->type == GIRDLE)) || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON)) 634 op->type == BRACERS || op->type == GIRDLE)) || (!QUERY_FLAG (pl, FLAG_USE_WEAPON) && op->type == WEAPON))
647 { 635 {
648 remove_ob (op); 636 op->destroy ();
649 free_object (op);
650 continue; 637 continue;
651 } 638 }
652 } 639 }
653 640
654 /* This really needs to be better - we should really give 641 /* This really needs to be better - we should really give
665 if (tmp->type == op->type && tmp->name == op->name) 652 if (tmp->type == op->type && tmp->name == op->name)
666 break; 653 break;
667 654
668 if (tmp) 655 if (tmp)
669 { 656 {
670 remove_ob (op); 657 op->destroy ();
671 free_object (op);
672 LOG (llevError, "give_initial_items: Removing duplicate object %s\n", &tmp->name); 658 LOG (llevError, "give_initial_items: Removing duplicate object %s\n", &tmp->name);
673 continue; 659 continue;
674 } 660 }
661
675 if (op->nrof > 1) 662 if (op->nrof > 1)
676 op->nrof = 1; 663 op->nrof = 1;
677 } 664 }
678 665
679 if (op->type == SPELLBOOK && op->inv) 666 if (op->type == SPELLBOOK && op->inv)
691 CLEAR_FLAG (op, FLAG_CURSED); 678 CLEAR_FLAG (op, FLAG_CURSED);
692 CLEAR_FLAG (op, FLAG_DAMNED); 679 CLEAR_FLAG (op, FLAG_DAMNED);
693 } 680 }
694 if (op->type == SPELL) 681 if (op->type == SPELL)
695 { 682 {
696 remove_ob (op); 683 op->destroy ();
697 free_object (op);
698 continue; 684 continue;
699 } 685 }
700 else if (op->type == SKILL) 686 else if (op->type == SKILL)
701 { 687 {
702 SET_FLAG (op, FLAG_CAN_USE_SKILL); 688 SET_FLAG (op, FLAG_CAN_USE_SKILL);
714 700
715void 701void
716get_name (object *op) 702get_name (object *op)
717{ 703{
718 op->contr->write_buf[0] = '\0'; 704 op->contr->write_buf[0] = '\0';
719 op->contr->state = ST_GET_NAME; 705 op->contr->ns->state = ST_GET_NAME;
720 send_query (&op->contr->socket, 0, "What is your name?\n:"); 706 send_query (op->contr->ns, 0, "What is your name?\n:");
721} 707}
722 708
723void 709void
724get_password (object *op) 710get_password (object *op)
725{ 711{
726 op->contr->write_buf[0] = '\0'; 712 op->contr->write_buf[0] = '\0';
727 op->contr->state = ST_GET_PASSWORD; 713 op->contr->ns->state = ST_GET_PASSWORD;
728 send_query (&op->contr->socket, CS_QUERY_HIDEINPUT, "What is your password?\n:"); 714 send_query (op->contr->ns, CS_QUERY_HIDEINPUT, "What is your password?\n:");
729} 715}
730 716
731void 717void
732play_again (object *op) 718play_again (object *op)
733{ 719{
734 op->contr->state = ST_PLAY_AGAIN; 720 op->contr->ns->state = ST_PLAY_AGAIN;
735 op->chosen_skill = NULL; 721 op->chosen_skill = NULL;
736 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Do you want to play again (a/q)?"); 722 send_query (op->contr->ns, 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 723 /* a bit of a hack, but there are various places early in th
738 * player creation process that a user can quit (eg, roll 724 * player creation process that a user can quit (eg, roll
739 * stats) that isn't removing the player. Taking a quick 725 * stats) that isn't removing the player. Taking a quick
740 * look, there are many places that call play_again without 726 * look, there are many places that call play_again without
741 * removing the player - it probably makes more sense 727 * removing the player - it probably makes more sense
742 * to leave it to play_again to remove the object in all 728 * to leave it to play_again to remove the object in all
743 * cases. 729 * cases.
744 */ 730 */
745 if (!QUERY_FLAG (op, FLAG_REMOVED)) 731 if (!QUERY_FLAG (op, FLAG_REMOVED))
746 remove_ob (op); 732 op->remove ();
733
747 /* Need to set this to null - otherwise, it could point to garbage, 734 /* 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 735 * and draw() doesn't check to see if the player is removed, only if
749 * the map is null or not swapped out. 736 * the map is null or not swapped out.
750 */ 737 */
751 op->map = NULL; 738 op->map = NULL;
765 player *pl = op->contr; 752 player *pl = op->contr;
766 shstr name = op->name; 753 shstr name = op->name;
767 754
768 op->contr = 0; 755 op->contr = 0;
769 op->type = 0; 756 op->type = 0;
770 op->free (1); 757 op->destroy (1);
771 pl = get_player (pl); 758 pl = get_player (pl);
772 op = pl->ob; 759 op = pl->ob;
773 add_friendly_object (op); 760 add_friendly_object (op);
774 op->contr->password[0] = '~'; 761 op->contr->password[0] = '~';
775 op->name = op->name_pl = 0; 762 op->name = op->name_pl = 0;
789void 776void
790confirm_password (object *op) 777confirm_password (object *op)
791{ 778{
792 779
793 op->contr->write_buf[0] = '\0'; 780 op->contr->write_buf[0] = '\0';
794 op->contr->state = ST_CONFIRM_PASSWORD; 781 op->contr->ns->state = ST_CONFIRM_PASSWORD;
795 send_query (&op->contr->socket, CS_QUERY_HIDEINPUT, "Please type your password again.\n:"); 782 send_query (op->contr->ns, CS_QUERY_HIDEINPUT, "Please type your password again.\n:");
796} 783}
797 784
798void 785void
799get_party_password (object *op, partylist *party) 786get_party_password (object *op, partylist *party)
800{ 787{
802 { 789 {
803 LOG (llevError, "get_party_password(): tried to make player %s join a NULL party", &op->name); 790 LOG (llevError, "get_party_password(): tried to make player %s join a NULL party", &op->name);
804 return; 791 return;
805 } 792 }
806 op->contr->write_buf[0] = '\0'; 793 op->contr->write_buf[0] = '\0';
807 op->contr->state = ST_GET_PARTY_PASSWORD; 794 op->contr->ns->state = ST_GET_PARTY_PASSWORD;
808 op->contr->party_to_join = party; 795 op->contr->party_to_join = party;
809 send_query (&op->contr->socket, CS_QUERY_HIDEINPUT, "What is the password?\n:"); 796 send_query (op->contr->ns, CS_QUERY_HIDEINPUT, "What is the password?\n:");
810} 797}
811 798
812 799
813/* This rolls four 1-6 rolls and sums the best 3 of the 4. */ 800/* This rolls four 1-6 rolls and sums the best 3 of the 4. */
814int 801int
911 898
912void 899void
913Roll_Again (object *op) 900Roll_Again (object *op)
914{ 901{
915 esrv_new_player (op->contr, 0); 902 esrv_new_player (op->contr, 0);
916 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, 903 send_query (op->contr->ns, 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)? "); 904 "[y] to roll new stats [n] to use stats\n[1-7] [1-7] to swap stats.\nRoll again (y/n/1-7)? ");
918} 905}
919 906
920void 907void
921Swap_Stat (object *op, int Swap_Second) 908Swap_Stat (object *op, int Swap_Second)
988 new_draw_info (NDI_UNIQUE, 0, op, buf); 975 new_draw_info (NDI_UNIQUE, 0, op, buf);
989 } 976 }
990 else 977 else
991 Swap_Stat (op, stat_trans[keynum]); 978 Swap_Stat (op, stat_trans[keynum]);
992 979
993 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, ""); 980 send_query (op->contr->ns, CS_QUERY_SINGLECHAR, "");
994 return 1; 981 return 1;
995 } 982 }
996 switch (key) 983 switch (key)
997 { 984 {
998 case 'n': 985 case 'n':
1012 enter_exit (op, NULL); 999 enter_exit (op, NULL);
1013#endif 1000#endif
1014 SET_ANIMATION (op, 2); /* So player faces south */ 1001 SET_ANIMATION (op, 2); /* So player faces south */
1015 /* Enter exit adds a player otherwise */ 1002 /* Enter exit adds a player otherwise */
1016 add_statbonus (op); 1003 add_statbonus (op);
1017 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, 1004 send_query (op->contr->ns, CS_QUERY_SINGLECHAR,
1018 "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n"); 1005 "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n");
1019 op->contr->state = ST_CHANGE_CLASS; 1006 op->contr->ns->state = ST_CHANGE_CLASS;
1020 if (op->msg) 1007 if (op->msg)
1021 new_draw_info (NDI_BLUE, 0, op, op->msg); 1008 new_draw_info (NDI_BLUE, 0, op, op->msg);
1022 return 0; 1009 return 0;
1023 } 1010 }
1024 case 'y': 1011 case 'y':
1025 case 'Y': 1012 case 'Y':
1026 roll_stats (op); 1013 roll_stats (op);
1027 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, ""); 1014 send_query (op->contr->ns, CS_QUERY_SINGLECHAR, "");
1028 return 1; 1015 return 1;
1029 1016
1030 case 'q': 1017 case 'q':
1031 case 'Q': 1018 case 'Q':
1032 play_again (op); 1019 play_again (op);
1033 return 1; 1020 return 1;
1034 1021
1035 default: 1022 default:
1036 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?"); 1023 send_query (op->contr->ns, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?");
1037 return 0; 1024 return 0;
1038 } 1025 }
1039 return 0; 1026 return 0;
1040} 1027}
1041 1028
1051{ 1038{
1052 int tmp_loop; 1039 int tmp_loop;
1053 1040
1054 if (key == 'q' || key == 'Q') 1041 if (key == 'q' || key == 'Q')
1055 { 1042 {
1056 remove_ob (op); 1043 op->remove ();
1057 play_again (op); 1044 play_again (op);
1058 return 0; 1045 return 0;
1059 } 1046 }
1060 if (key == 'd' || key == 'D') 1047 if (key == 'd' || key == 'D')
1061 { 1048 {
1062 char buf[MAX_BUF]; 1049 char buf[MAX_BUF];
1063 1050
1064 /* this must before then initial items are given */ 1051 /* this must before then initial items are given */
1065 esrv_new_player (op->contr, op->weight + op->carrying); 1052 esrv_new_player (op->contr, op->weight + op->carrying);
1053
1066 create_treasure (find_treasurelist ("starting_wealth"), op, 0, 0, 0); 1054 treasurelist *tl = find_treasurelist ("starting_wealth");
1055 if (tl)
1056 create_treasure (tl, op, 0, 0, 0);
1067 1057
1068 INVOKE_PLAYER (BIRTH, op->contr); 1058 INVOKE_PLAYER (BIRTH, op->contr);
1069 INVOKE_PLAYER (LOGIN, op->contr); 1059 INVOKE_PLAYER (LOGIN, op->contr);
1070 1060
1071 op->contr->state = ST_PLAYING; 1061 op->contr->ns->state = ST_PLAYING;
1072 1062
1073 if (op->msg) 1063 if (op->msg)
1074 op->msg = NULL; 1064 op->msg = NULL;
1075 1065
1076 /* We create this now because some of the unique maps will need it 1066 /* We create this now because some of the unique maps will need it
1096 { 1086 {
1097 object *tmp; 1087 object *tmp;
1098 char mapname[MAX_BUF]; 1088 char mapname[MAX_BUF];
1099 1089
1100 snprintf (mapname, MAX_BUF - 1, "%s/%s", first_map_ext_path, &op->arch->name); 1090 snprintf (mapname, MAX_BUF - 1, "%s/%s", first_map_ext_path, &op->arch->name);
1101 tmp = get_object (); 1091 tmp = object::create ();
1102 EXIT_PATH (tmp) = mapname; 1092 EXIT_PATH (tmp) = mapname;
1103 EXIT_X (tmp) = op->x; 1093 EXIT_X (tmp) = op->x;
1104 EXIT_Y (tmp) = op->y; 1094 EXIT_Y (tmp) = op->y;
1105 enter_exit (op, tmp); /* we don't really care if it succeeded; 1095 enter_exit (op, tmp); /* we don't really care if it succeeded;
1106 * if the map isn't there, then stay on the 1096 * if the map isn't there, then stay on the
1107 * default initial map */ 1097 * default initial map */
1108 free_object (tmp); 1098 tmp->destroy ();
1109 } 1099 }
1110 else 1100 else
1111 {
1112 LOG (llevDebug, "first_map_ext_path not set\n"); 1101 LOG (llevDebug, "first_map_ext_path not set\n");
1113 } 1102
1114 return 0; 1103 return 0;
1115 } 1104 }
1116 1105
1117 /* Following actually changes the race - this is the default command 1106 /* Following actually changes the race - this is the default command
1118 * if we don't match with one of the options above. 1107 * if we don't match with one of the options above.
1123 { 1112 {
1124 shstr name = op->name; 1113 shstr name = op->name;
1125 int x = op->x, y = op->y; 1114 int x = op->x, y = op->y;
1126 1115
1127 remove_statbonus (op); 1116 remove_statbonus (op);
1128 remove_ob (op); 1117 op->remove ();
1129 op->arch = get_player_archetype (op->arch); 1118 op->arch = get_player_archetype (op->arch);
1130 copy_object (&op->arch->clone, op); 1119 op->arch->clone.copy_to (op);
1131 op->instantiate (); 1120 op->instantiate ();
1132 op->stats = op->contr->orig_stats; 1121 op->stats = op->contr->orig_stats;
1133 op->name = op->name_pl = name; 1122 op->name = op->name_pl = name;
1134 op->x = x; 1123 op->x = x;
1135 op->y = y; 1124 op->y = y;
1148 op->stats.grace = 0; 1137 op->stats.grace = 0;
1149 1138
1150 if (op->msg) 1139 if (op->msg)
1151 new_draw_info (NDI_BLUE, 0, op, op->msg); 1140 new_draw_info (NDI_BLUE, 0, op, op->msg);
1152 1141
1153 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Press any key for the next race.\nPress `d' to play this race.\n"); 1142 send_query (op->contr->ns, CS_QUERY_SINGLECHAR, "Press any key for the next race.\nPress `d' to play this race.\n");
1154 return 0; 1143 return 0;
1155} 1144}
1156 1145
1157int 1146int
1158key_confirm_quit (object *op, char key) 1147key_confirm_quit (object *op, char key)
1159{ 1148{
1160 char buf[MAX_BUF]; 1149 char buf[MAX_BUF];
1161 1150
1162 if (key != 'y' && key != 'Y' && key != 'q' && key != 'Q') 1151 if (key != 'y' && key != 'Y' && key != 'q' && key != 'Q')
1163 { 1152 {
1164 op->contr->state = ST_PLAYING; 1153 op->contr->ns->state = ST_PLAYING;
1165 new_draw_info (NDI_UNIQUE, 0, op, "OK, continuing to play."); 1154 new_draw_info (NDI_UNIQUE, 0, op, "OK, continuing to play.");
1166 return 1; 1155 return 1;
1167 } 1156 }
1168 1157
1169 INVOKE_PLAYER (LOGOUT, op->contr); 1158 INVOKE_PLAYER (LOGOUT, op->contr);
1180 if (settings.set_title == TRUE) 1169 if (settings.set_title == TRUE)
1181 op->contr->own_title[0] = '\0'; 1170 op->contr->own_title[0] = '\0';
1182 1171
1183 if (!QUERY_FLAG (op, FLAG_WAS_WIZ)) 1172 if (!QUERY_FLAG (op, FLAG_WAS_WIZ))
1184 { 1173 {
1185 mapstruct *mp, *next; 1174 maptile *mp, *next;
1186 1175
1187 /* We need to hunt for any per player unique maps in memory and 1176 /* 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, 1177 * 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 1178 * so that players named 'Ab' won't match against players 'Abe' pathname
1190 */ 1179 */
1238 { 1227 {
1239 op->enemy = NULL; 1228 op->enemy = NULL;
1240 CLEAR_FLAG (op, FLAG_SCARED); 1229 CLEAR_FLAG (op, FLAG_SCARED);
1241 return; 1230 return;
1242 } 1231 }
1232
1243 get_rangevector (op, op->enemy, &rv, 0); 1233 get_rangevector (op, op->enemy, &rv, 0);
1244 1234
1245 dir = absdir (4 + rv.direction); 1235 dir = absdir (4 + rv.direction);
1246 for (diff = 0; diff < 3; diff++) 1236 for (diff = 0; diff < 3; diff++)
1247 { 1237 {
1248 int m = 1 - (RANDOM () & 2); 1238 int m = 1 - (RANDOM () & 2);
1249 1239
1250 if (move_ob (op, absdir (dir + diff * m), op) || (diff == 0 && move_ob (op, absdir (dir - diff * m), op))) 1240 if (move_ob (op, absdir (dir + diff * m), op) || (diff == 0 && move_ob (op, absdir (dir - diff * m), op)))
1251 {
1252 return; 1241 return;
1253 }
1254 } 1242 }
1243
1255 /* Cornered, get rid of scared */ 1244 /* Cornered, get rid of scared */
1256 CLEAR_FLAG (op, FLAG_SCARED); 1245 CLEAR_FLAG (op, FLAG_SCARED);
1257 op->enemy = NULL; 1246 op->enemy = NULL;
1258} 1247}
1259 1248
1264 */ 1253 */
1265int 1254int
1266check_pick (object *op) 1255check_pick (object *op)
1267{ 1256{
1268 object *tmp, *next; 1257 object *tmp, *next;
1269 tag_t next_tag = 0, op_tag;
1270 int stop = 0; 1258 int stop = 0;
1271 int j, k, wvratio; 1259 int j, k, wvratio;
1272 char putstring[128], tmpstr[16]; 1260 char putstring[128], tmpstr[16];
1273 1261
1274
1275 /* if you're flying, you cna't pick up anything */ 1262 /* if you're flying, you cna't pick up anything */
1276 if (op->move_type & MOVE_FLYING) 1263 if (op->move_type & MOVE_FLYING)
1277 return 1; 1264 return 1;
1278 1265
1279 op_tag = op->count;
1280
1281 next = op->below; 1266 next = op->below;
1282 if (next)
1283 next_tag = next->count;
1284 1267
1285 /* loop while there are items on the floor that are not marked as 1268 /* loop while there are items on the floor that are not marked as
1286 * destroyed */ 1269 * destroyed */
1287 while (next && !was_destroyed (next, next_tag)) 1270 while (next && !next->destroyed ())
1288 { 1271 {
1289 tmp = next; 1272 tmp = next;
1290 next = tmp->below; 1273 next = tmp->below;
1291 if (next)
1292 next_tag = next->count;
1293 1274
1294 if (was_destroyed (op, op_tag)) 1275 if (op->destroyed ())
1295 return 0; 1276 return 0;
1296 1277
1297 if (!can_pick (op, tmp)) 1278 if (!can_pick (op, tmp))
1298 continue; 1279 continue;
1299 1280
1431 /* question: don't pick up known-poisonous stuff? */ 1412 /* question: don't pick up known-poisonous stuff? */
1432 if (op->contr->mode & PU_FOOD) 1413 if (op->contr->mode & PU_FOOD)
1433 if (tmp->type == FOOD) 1414 if (tmp->type == FOOD)
1434 { 1415 {
1435 pick_up (op, tmp); 1416 pick_up (op, tmp);
1436 if (0)
1437 fprintf (stderr, "FOOD\n");
1438 continue; 1417 continue;
1439 } 1418 }
1419
1440 if (op->contr->mode & PU_DRINK) 1420 if (op->contr->mode & PU_DRINK)
1441 if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))) 1421 if (tmp->type == DRINK || (tmp->type == POISON && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)))
1442 { 1422 {
1443 pick_up (op, tmp); 1423 pick_up (op, tmp);
1444 if (0)
1445 fprintf (stderr, "DRINK\n");
1446 continue; 1424 continue;
1447 } 1425 }
1448 1426
1449 if (op->contr->mode & PU_POTION) 1427 if (op->contr->mode & PU_POTION)
1450 if (tmp->type == POTION) 1428 if (tmp->type == POTION)
1451 { 1429 {
1452 pick_up (op, tmp); 1430 pick_up (op, tmp);
1453 if (0)
1454 fprintf (stderr, "POTION\n");
1455 continue; 1431 continue;
1456 } 1432 }
1457 1433
1458 /* spellbooks, skillscrolls and normal books/scrolls */ 1434 /* spellbooks, skillscrolls and normal books/scrolls */
1459 if (op->contr->mode & PU_SPELLBOOK) 1435 if (op->contr->mode & PU_SPELLBOOK)
1460 if (tmp->type == SPELLBOOK) 1436 if (tmp->type == SPELLBOOK)
1461 { 1437 {
1462 pick_up (op, tmp); 1438 pick_up (op, tmp);
1463 if (0)
1464 fprintf (stderr, "SPELLBOOK\n");
1465 continue; 1439 continue;
1466 } 1440 }
1441
1467 if (op->contr->mode & PU_SKILLSCROLL) 1442 if (op->contr->mode & PU_SKILLSCROLL)
1468 if (tmp->type == SKILLSCROLL) 1443 if (tmp->type == SKILLSCROLL)
1469 { 1444 {
1470 pick_up (op, tmp); 1445 pick_up (op, tmp);
1471 if (0)
1472 fprintf (stderr, "SKILLSCROLL\n");
1473 continue; 1446 continue;
1474 } 1447 }
1448
1475 if (op->contr->mode & PU_READABLES) 1449 if (op->contr->mode & PU_READABLES)
1476 if (tmp->type == BOOK || tmp->type == SCROLL) 1450 if (tmp->type == BOOK || tmp->type == SCROLL)
1477 { 1451 {
1478 pick_up (op, tmp); 1452 pick_up (op, tmp);
1479 if (0)
1480 fprintf (stderr, "READABLES\n");
1481 continue; 1453 continue;
1482 } 1454 }
1483 1455
1484 /* wands/staves/rods/horns */ 1456 /* wands/staves/rods/horns */
1485 if (op->contr->mode & PU_MAGIC_DEVICE) 1457 if (op->contr->mode & PU_MAGIC_DEVICE)
1486 if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN) 1458 if (tmp->type == WAND || tmp->type == ROD || tmp->type == HORN)
1487 { 1459 {
1488 pick_up (op, tmp); 1460 pick_up (op, tmp);
1489 if (0)
1490 fprintf (stderr, "MAGIC_DEVICE\n");
1491 continue; 1461 continue;
1492 } 1462 }
1493 1463
1494 /* pick up all magical items */ 1464 /* pick up all magical items */
1495 if (op->contr->mode & PU_MAGICAL) 1465 if (op->contr->mode & PU_MAGICAL)
1496 if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED)) 1466 if (QUERY_FLAG (tmp, FLAG_KNOWN_MAGICAL) && !QUERY_FLAG (tmp, FLAG_KNOWN_CURSED))
1497 { 1467 {
1498 pick_up (op, tmp); 1468 pick_up (op, tmp);
1499 if (0)
1500 fprintf (stderr, "MAGICAL\n");
1501 continue; 1469 continue;
1502 } 1470 }
1503 1471
1504 if (op->contr->mode & PU_VALUABLES) 1472 if (op->contr->mode & PU_VALUABLES)
1505 { 1473 {
1506 if (tmp->type == MONEY || tmp->type == GEM) 1474 if (tmp->type == MONEY || tmp->type == GEM)
1507 { 1475 {
1508 pick_up (op, tmp); 1476 pick_up (op, tmp);
1509 if (0)
1510 fprintf (stderr, "MONEY/GEM\n");
1511 continue; 1477 continue;
1512 } 1478 }
1513 } 1479 }
1514 1480
1515 /* rings & amulets - talismans seems to be typed AMULET */ 1481 /* rings & amulets - talismans seems to be typed AMULET */
1516 if (op->contr->mode & PU_JEWELS) 1482 if (op->contr->mode & PU_JEWELS)
1517 if (tmp->type == RING || tmp->type == AMULET) 1483 if (tmp->type == RING || tmp->type == AMULET)
1518 { 1484 {
1519 pick_up (op, tmp); 1485 pick_up (op, tmp);
1486 continue;
1520 if (0) 1487 }
1521 fprintf (stderr, "JEWELS\n"); 1488
1489 /* we don't forget dragon food */
1490 if (op->contr->mode & PU_FLESH)
1491 if (tmp->type == FLESH)
1492 {
1493 pick_up (op, tmp);
1522 continue; 1494 continue;
1523 } 1495 }
1524 1496
1525 /* bows and arrows. Bows are good for selling! */ 1497 /* bows and arrows. Bows are good for selling! */
1526 if (op->contr->mode & PU_BOW) 1498 if (op->contr->mode & PU_BOW)
1527 if (tmp->type == BOW) 1499 if (tmp->type == BOW)
1528 { 1500 {
1529 pick_up (op, tmp); 1501 pick_up (op, tmp);
1530 if (0)
1531 fprintf (stderr, "BOW\n");
1532 continue; 1502 continue;
1533 } 1503 }
1504
1534 if (op->contr->mode & PU_ARROW) 1505 if (op->contr->mode & PU_ARROW)
1535 if (tmp->type == ARROW) 1506 if (tmp->type == ARROW)
1536 { 1507 {
1537 pick_up (op, tmp); 1508 pick_up (op, tmp);
1538 if (0)
1539 fprintf (stderr, "ARROW\n");
1540 continue; 1509 continue;
1541 } 1510 }
1542 1511
1543 /* all kinds of armor etc. */ 1512 /* all kinds of armor etc. */
1544 if (op->contr->mode & PU_ARMOUR) 1513 if (op->contr->mode & PU_ARMOUR)
1545 if (tmp->type == ARMOUR) 1514 if (tmp->type == ARMOUR)
1546 { 1515 {
1547 pick_up (op, tmp); 1516 pick_up (op, tmp);
1548 if (0)
1549 fprintf (stderr, "ARMOUR\n");
1550 continue; 1517 continue;
1551 } 1518 }
1519
1552 if (op->contr->mode & PU_HELMET) 1520 if (op->contr->mode & PU_HELMET)
1553 if (tmp->type == HELMET) 1521 if (tmp->type == HELMET)
1554 { 1522 {
1555 pick_up (op, tmp); 1523 pick_up (op, tmp);
1556 if (0)
1557 fprintf (stderr, "HELMET\n");
1558 continue; 1524 continue;
1559 } 1525 }
1526
1560 if (op->contr->mode & PU_SHIELD) 1527 if (op->contr->mode & PU_SHIELD)
1561 if (tmp->type == SHIELD) 1528 if (tmp->type == SHIELD)
1562 { 1529 {
1563 pick_up (op, tmp); 1530 pick_up (op, tmp);
1564 if (0)
1565 fprintf (stderr, "SHIELD\n");
1566 continue; 1531 continue;
1567 } 1532 }
1533
1568 if (op->contr->mode & PU_BOOTS) 1534 if (op->contr->mode & PU_BOOTS)
1569 if (tmp->type == BOOTS) 1535 if (tmp->type == BOOTS)
1570 { 1536 {
1571 pick_up (op, tmp); 1537 pick_up (op, tmp);
1572 if (0)
1573 fprintf (stderr, "BOOTS\n");
1574 continue; 1538 continue;
1575 } 1539 }
1540
1576 if (op->contr->mode & PU_GLOVES) 1541 if (op->contr->mode & PU_GLOVES)
1577 if (tmp->type == GLOVES) 1542 if (tmp->type == GLOVES)
1578 { 1543 {
1579 pick_up (op, tmp); 1544 pick_up (op, tmp);
1580 if (0)
1581 fprintf (stderr, "GLOVES\n");
1582 continue; 1545 continue;
1583 } 1546 }
1547
1584 if (op->contr->mode & PU_CLOAK) 1548 if (op->contr->mode & PU_CLOAK)
1585 if (tmp->type == CLOAK) 1549 if (tmp->type == CLOAK)
1586 { 1550 {
1587 pick_up (op, tmp); 1551 pick_up (op, tmp);
1588 if (0)
1589 fprintf (stderr, "GLOVES\n");
1590 continue; 1552 continue;
1591 } 1553 }
1592 1554
1593 /* hoping to catch throwing daggers here */ 1555 /* hoping to catch throwing daggers here */
1594 if (op->contr->mode & PU_MISSILEWEAPON) 1556 if (op->contr->mode & PU_MISSILEWEAPON)
1595 if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN)) 1557 if (tmp->type == WEAPON && QUERY_FLAG (tmp, FLAG_IS_THROWN))
1596 { 1558 {
1597 pick_up (op, tmp); 1559 pick_up (op, tmp);
1598 if (0)
1599 fprintf (stderr, "MISSILEWEAPON\n");
1600 continue; 1560 continue;
1601 } 1561 }
1602 1562
1603 /* careful: chairs and tables are weapons! */ 1563 /* careful: chairs and tables are weapons! */
1604 if (op->contr->mode & PU_ALLWEAPON) 1564 if (op->contr->mode & PU_ALLWEAPON)
1607 { 1567 {
1608 if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->name, "table") == NULL && 1568 if (strstr (tmp->name, "table") == NULL && strstr (tmp->arch->name, "table") == NULL &&
1609 strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL) 1569 strstr (tmp->name, "chair") && strstr (tmp->arch->name, "chair") == NULL)
1610 { 1570 {
1611 pick_up (op, tmp); 1571 pick_up (op, tmp);
1612 if (0)
1613 fprintf (stderr, "WEAPON\n");
1614 continue; 1572 continue;
1615 } 1573 }
1616 } 1574 }
1575
1617 if (tmp->type == WEAPON && tmp->name == NULL) 1576 if (tmp->type == WEAPON && tmp->name == NULL)
1618 { 1577 {
1619 if (strstr (tmp->arch->name, "table") == NULL && strstr (tmp->arch->name, "chair") == NULL) 1578 if (strstr (tmp->arch->name, "table") == NULL && strstr (tmp->arch->name, "chair") == NULL)
1620 { 1579 {
1621 pick_up (op, tmp); 1580 pick_up (op, tmp);
1622 if (0)
1623 fprintf (stderr, "WEAPON\n");
1624 continue; 1581 continue;
1625 } 1582 }
1626 } 1583 }
1627 } 1584 }
1628 1585
1629 /* misc stuff that's useful */ 1586 /* misc stuff that's useful */
1630 if (op->contr->mode & PU_KEY) 1587 if (op->contr->mode & PU_KEY)
1631 if (tmp->type == KEY || tmp->type == SPECIAL_KEY) 1588 if (tmp->type == KEY || tmp->type == SPECIAL_KEY)
1632 { 1589 {
1633 pick_up (op, tmp); 1590 pick_up (op, tmp);
1634 if (0)
1635 fprintf (stderr, "KEY\n");
1636 continue; 1591 continue;
1637 } 1592 }
1638 1593
1639 /* any of the last 4 bits set means we use the ratio for value 1594 /* any of the last 4 bits set means we use the ratio for value
1640 * pickups */ 1595 * pickups */
1662 continue; 1617 continue;
1663 } 1618 }
1664 } 1619 }
1665 } /* the new pickup model */ 1620 } /* the new pickup model */
1666 } 1621 }
1622
1667 return !stop; 1623 return !stop;
1668} 1624}
1669 1625
1670/* 1626/*
1671 * Find an arrow in the inventory and after that 1627 * Find an arrow in the inventory and after that
1770 1726
1771object * 1727object *
1772pick_arrow_target (object *op, const char *type, int dir) 1728pick_arrow_target (object *op, const char *type, int dir)
1773{ 1729{
1774 object *tmp = NULL; 1730 object *tmp = NULL;
1775 mapstruct *m; 1731 maptile *m;
1776 int i, mflags, found, number; 1732 int i, mflags, found, number;
1777 sint16 x, y; 1733 sint16 x, y;
1778 1734
1779 if (op->map == NULL) 1735 if (op->map == NULL)
1780 return find_arrow (op, type); 1736 return find_arrow (op, type);
1840 */ 1796 */
1841int 1797int
1842fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy) 1798fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy)
1843{ 1799{
1844 object *left, *bow; 1800 object *left, *bow;
1845 tag_t left_tag, tag;
1846 int bowspeed, mflags; 1801 int bowspeed, mflags;
1847 mapstruct *m; 1802 maptile *m;
1848 1803
1849 if (!dir) 1804 if (!dir)
1850 { 1805 {
1851 new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); 1806 new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!");
1852 return 0; 1807 return 0;
1853 } 1808 }
1809
1854 if (op->type == PLAYER) 1810 if (op->type == PLAYER)
1855 bow = op->contr->ranges[range_bow]; 1811 bow = op->contr->ranges[range_bow];
1856 else 1812 else
1857 { 1813 {
1858 for (bow = op->inv; bow; bow = bow->below) 1814 for (bow = op->inv; bow; bow = bow->below)
1866 { 1822 {
1867 LOG (llevError, "Range: bow without activated bow (%s).\n", &op->name); 1823 LOG (llevError, "Range: bow without activated bow (%s).\n", &op->name);
1868 return 0; 1824 return 0;
1869 } 1825 }
1870 } 1826 }
1827
1871 if (!bow->race || !bow->skill) 1828 if (!bow->race || !bow->skill)
1872 { 1829 {
1873 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name); 1830 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name);
1874 return 0; 1831 return 0;
1875 } 1832 }
1877 bowspeed = bow->stats.sp + dex_bonus[op->stats.Dex]; 1834 bowspeed = bow->stats.sp + dex_bonus[op->stats.Dex];
1878 1835
1879 /* penalize ROF for bestarrow */ 1836 /* penalize ROF for bestarrow */
1880 if (op->type == PLAYER && op->contr->bowtype == bow_bestarrow) 1837 if (op->type == PLAYER && op->contr->bowtype == bow_bestarrow)
1881 bowspeed -= dex_bonus[op->stats.Dex] + 5; 1838 bowspeed -= dex_bonus[op->stats.Dex] + 5;
1839
1882 if (bowspeed < 1) 1840 if (bowspeed < 1)
1883 bowspeed = 1; 1841 bowspeed = 1;
1884 1842
1885 if (arrow == NULL) 1843 if (arrow == NULL)
1886 { 1844 {
1892 else 1850 else
1893 CLEAR_FLAG (op, FLAG_READY_BOW); 1851 CLEAR_FLAG (op, FLAG_READY_BOW);
1894 return 0; 1852 return 0;
1895 } 1853 }
1896 } 1854 }
1855
1897 mflags = get_map_flags (op->map, &m, sx, sy, &sx, &sy); 1856 mflags = get_map_flags (op->map, &m, sx, sy, &sx, &sy);
1898 if (mflags & P_OUT_OF_MAP) 1857 if (mflags & P_OUT_OF_MAP)
1899 {
1900 return 0; 1858 return 0;
1901 } 1859
1902 if (GET_MAP_MOVE_BLOCK (m, sx, sy) == MOVE_FLY_LOW) 1860 if (GET_MAP_MOVE_BLOCK (m, sx, sy) == MOVE_FLY_LOW)
1903 { 1861 {
1904 new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); 1862 new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way.");
1905 return 0; 1863 return 0;
1906 } 1864 }
1907 1865
1908 /* this should not happen, but sometimes does */ 1866 /* this should not happen, but sometimes does */
1909 if (arrow->nrof == 0) 1867 if (arrow->nrof == 0)
1910 { 1868 {
1911 remove_ob (arrow); 1869 arrow->destroy ();
1912 free_object (arrow);
1913 return 0; 1870 return 0;
1914 } 1871 }
1915 1872
1916 left = arrow; /* these are arrows left to the player */ 1873 left = arrow; /* these are arrows left to the player */
1917 left_tag = left->count;
1918 arrow = get_split_ob (arrow, 1); 1874 arrow = get_split_ob (arrow, 1);
1919 if (arrow == NULL) 1875 if (!arrow)
1920 { 1876 {
1921 new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); 1877 new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race);
1922 return 0; 1878 return 0;
1923 } 1879 }
1924 set_owner (arrow, op); 1880
1881 arrow->set_owner (op);
1925 arrow->skill = bow->skill; 1882 arrow->skill = bow->skill;
1926 1883
1927 arrow->direction = dir; 1884 arrow->direction = dir;
1928 arrow->x = sx; 1885 arrow->x = sx;
1929 arrow->y = sy; 1886 arrow->y = sy;
1937 SET_ANIMATION (arrow, arrow->direction); 1894 SET_ANIMATION (arrow, arrow->direction);
1938 arrow->stats.sp = arrow->stats.wc; /* save original wc and dam */ 1895 arrow->stats.sp = arrow->stats.wc; /* save original wc and dam */
1939 arrow->stats.hp = arrow->stats.dam; 1896 arrow->stats.hp = arrow->stats.dam;
1940 arrow->stats.grace = arrow->attacktype; 1897 arrow->stats.grace = arrow->attacktype;
1941 if (arrow->slaying != NULL) 1898 if (arrow->slaying != NULL)
1942 arrow->spellarg = strdup_local (arrow->slaying); 1899 arrow->spellarg = strdup (arrow->slaying);
1943 1900
1944 /* Note that this was different for monsters - they got their level 1901 /* Note that this was different for monsters - they got their level
1945 * added to the damage. I think the strength bonus is more proper. 1902 * added to the damage. I think the strength bonus is more proper.
1946 */ 1903 */
1947 1904
1965 arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level; 1922 arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level;
1966 } 1923 }
1967 else 1924 else
1968 { 1925 {
1969 arrow->stats.wc = op->stats.wc - bow->magic - arrow->magic - arrow->stats.wc + wc_mod; 1926 arrow->stats.wc = op->stats.wc - bow->magic - arrow->magic - arrow->stats.wc + wc_mod;
1970
1971 arrow->level = op->level; 1927 arrow->level = op->level;
1972 } 1928 }
1929
1973 if (arrow->attacktype == AT_PHYSICAL) 1930 if (arrow->attacktype == AT_PHYSICAL)
1974 arrow->attacktype |= bow->attacktype; 1931 arrow->attacktype |= bow->attacktype;
1932
1975 if (bow->slaying != NULL) 1933 if (bow->slaying)
1976 arrow->slaying = bow->slaying; 1934 arrow->slaying = bow->slaying;
1977 1935
1978 arrow->map = m; 1936 arrow->map = m;
1979 arrow->move_type = MOVE_FLY_LOW; 1937 arrow->move_type = MOVE_FLY_LOW;
1980 arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; 1938 arrow->move_on = MOVE_FLY_LOW | MOVE_WALK;
1981 1939
1982 play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW); 1940 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); 1941 insert_ob_in_map (arrow, m, op, 0);
1985 1942
1986 if (!was_destroyed (arrow, tag)) 1943 if (!arrow->destroyed ())
1987 move_arrow (arrow); 1944 move_arrow (arrow);
1988 1945
1989 if (op->type == PLAYER) 1946 if (op->type == PLAYER)
1990 { 1947 {
1991 if (was_destroyed (left, left_tag)) 1948 if (left->destroyed ())
1992 esrv_del_item (op->contr, left_tag); 1949 esrv_del_item (op->contr, left->count);
1993 else 1950 else
1994 esrv_send_item (op, left); 1951 esrv_send_item (op, left);
1995 } 1952 }
1953
1996 return 1; 1954 return 1;
1997} 1955}
1998 1956
1999/* Special fire code for players - this takes into 1957/* Special fire code for players - this takes into
2000 * account the special fire modes players can have 1958 * account the special fire modes players can have
2096 CLEAR_FLAG (item, FLAG_ANIMATE); 2054 CLEAR_FLAG (item, FLAG_ANIMATE);
2097 item->face = item->arch->clone.face; 2055 item->face = item->arch->clone.face;
2098 item->speed = 0; 2056 item->speed = 0;
2099 update_ob_speed (item); 2057 update_ob_speed (item);
2100 } 2058 }
2101 if ((tmp = is_player_inv (item))) 2059 if ((tmp = item->in_player ()))
2102 esrv_update_item (UPD_ANIM, tmp, item); 2060 esrv_update_item (UPD_ANIM, tmp, item);
2103 } 2061 }
2104 } 2062 }
2105 else if (item->type == ROD || item->type == HORN) 2063 else if (item->type == ROD || item->type == HORN)
2106 { 2064 {
2136 case range_misc: 2094 case range_misc:
2137 fire_misc_object (op, dir); 2095 fire_misc_object (op, dir);
2138 return; 2096 return;
2139 2097
2140 case range_golem: /* Control summoned monsters from scrolls */ 2098 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) 2099 if (QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED))
2142 { 2100 {
2143 op->contr->ranges[range_golem] = NULL; 2101 op->contr->ranges[range_golem] = 0;
2144 op->contr->shoottype = range_none; 2102 op->contr->shoottype = range_none;
2145 op->contr->golem_count = 0;
2146 } 2103 }
2147 else 2104 else
2148 control_golem (op->contr->ranges[range_golem], dir); 2105 control_golem (op->contr->ranges[range_golem], dir);
2149 return; 2106 return;
2150 2107
2257 * 0 otherwise 2214 * 0 otherwise
2258 */ 2215 */
2259static int 2216static int
2260player_attack_door (object *op, object *door) 2217player_attack_door (object *op, object *door)
2261{ 2218{
2262
2263 /* If its a door, try to find a use a key. If we do destroy the door, 2219 /* If its a door, try to find a use a key. If we do destroy the door,
2264 * might as well return immediately as there is nothing more to do - 2220 * might as well return immediately as there is nothing more to do -
2265 * otherwise, we fall through to the rest of the code. 2221 * otherwise, we fall through to the rest of the code.
2266 */ 2222 */
2267 object *key = find_key (op, op, door); 2223 object *key = find_key (op, op, door);
2305 * It should keep the code cleaner. 2261 * It should keep the code cleaner.
2306 * When this is called, the players direction has been updated 2262 * When this is called, the players direction has been updated
2307 * (taking into account confusion.) The player is also actually 2263 * (taking into account confusion.) The player is also actually
2308 * going to try and move (not fire weapons). 2264 * going to try and move (not fire weapons).
2309 */ 2265 */
2310
2311void 2266void
2312move_player_attack (object *op, int dir) 2267move_player_attack (object *op, int dir)
2313{ 2268{
2314 object *tmp, *mon; 2269 object *tmp, *mon;
2315 sint16 nx, ny; 2270 sint16 nx, ny;
2316 int on_battleground; 2271 int on_battleground;
2317 mapstruct *m; 2272 maptile *m;
2318 2273
2319 nx = freearr_x[dir] + op->x; 2274 nx = freearr_x[dir] + op->x;
2320 ny = freearr_y[dir] + op->y; 2275 ny = freearr_y[dir] + op->y;
2321 2276
2322 on_battleground = op_on_battleground (op, NULL, NULL); 2277 on_battleground = op_on_battleground (op, 0, 0);
2323 2278
2324 /* If braced, or can't move to the square, and it is not out of the 2279 /* If braced, or can't move to the square, and it is not out of the
2325 * map, attack it. Note order of if statement is important - don't 2280 * map, attack it. Note order of if statement is important - don't
2326 * want to be calling move_ob if braced, because move_ob will move the 2281 * want to be calling move_ob if braced, because move_ob will move the
2327 * player. This is a pretty nasty hack, because if we could 2282 * player. This is a pretty nasty hack, because if we could
2339 return; /* Don't think this should happen */ 2294 return; /* Don't think this should happen */
2340 } 2295 }
2341 else 2296 else
2342 m = op->map; 2297 m = op->map;
2343 2298
2344 if ((tmp = get_map_ob (m, nx, ny)) == NULL) 2299 if ((tmp = GET_MAP_OB (m, nx, ny)) == NULL)
2345 { 2300 {
2346 /* LOG(llevError,"player_move_attack: get_map_ob returns NULL, but player can not more there.\n"); */ 2301 /* LOG(llevError,"player_move_attack: GET_MAP_OB returns NULL, but player can not move there.\n"); */
2347 return; 2302 return;
2348 } 2303 }
2349 2304
2350 mon = NULL; 2305 mon = 0;
2351 /* Go through all the objects, and find ones of interest. Only stop if 2306 /* Go through all the objects, and find ones of interest. Only stop if
2352 * we find a monster - that is something we know we want to attack. 2307 * we find a monster - that is something we know we want to attack.
2353 * if its a door or barrel (can roll) see if there may be monsters 2308 * if its a door or barrel (can roll) see if there may be monsters
2354 * on the space 2309 * on the space
2355 */ 2310 */
2356 while (tmp != NULL) 2311 while (tmp)
2357 { 2312 {
2358 if (tmp == op) 2313 if (tmp == op)
2359 { 2314 {
2360 tmp = tmp->above; 2315 tmp = tmp->above;
2361 continue; 2316 continue;
2362 } 2317 }
2318
2363 if (QUERY_FLAG (tmp, FLAG_ALIVE)) 2319 if (QUERY_FLAG (tmp, FLAG_ALIVE))
2364 { 2320 {
2365 mon = tmp; 2321 mon = tmp;
2366 break; 2322 break;
2367 } 2323 }
2324
2368 if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL)) 2325 if (tmp->type == LOCKED_DOOR || QUERY_FLAG (tmp, FLAG_CAN_ROLL))
2369 mon = tmp; 2326 mon = tmp;
2327
2370 tmp = tmp->above; 2328 tmp = tmp->above;
2371 } 2329 }
2372 2330
2373 if (mon == NULL) /* This happens anytime the player tries to move */ 2331 if (!mon) /* This happens anytime the player tries to move */
2374 return; /* into a wall */ 2332 return; /* into a wall */
2375 2333
2376 if (mon->head != NULL) 2334 if (mon->head)
2377 mon = mon->head; 2335 mon = mon->head;
2378 2336
2379 if ((mon->type == DOOR && mon->stats.hp >= 0) || (mon->type == LOCKED_DOOR)) 2337 if ((mon->type == DOOR && mon->stats.hp >= 0) || (mon->type == LOCKED_DOOR))
2380 if (player_attack_door (op, mon)) 2338 if (player_attack_door (op, mon))
2381 return; 2339 return;
2393 * player owns it and it is either friendly or unagressive. 2351 * player owns it and it is either friendly or unagressive.
2394 */ 2352 */
2395 if ((op->type == PLAYER) 2353 if ((op->type == PLAYER)
2396#if COZY_SERVER 2354#if COZY_SERVER
2397 && 2355 &&
2398 ((get_owner (mon) && get_owner (mon)->contr 2356 ((mon->owner && mon->owner->contr
2399 && same_party (get_owner (mon)->contr->party, op->contr->party)) || get_owner (mon) == op) 2357 && same_party (mon->owner->contr->party, op->contr->party)) || mon->owner == op)
2400#else 2358#else
2401 && get_owner (mon) == op 2359 && mon->owner == op
2402#endif 2360#endif
2403 && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY))) 2361 && (QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)))
2404 { 2362 {
2405 /* If we're braced, we don't want to switch places with it */ 2363 /* If we're braced, we don't want to switch places with it */
2406 if (op->contr->braced) 2364 if (op->contr->braced)
2418 * attack them either. 2376 * attack them either.
2419 */ 2377 */
2420 if ((mon->type == PLAYER || mon->enemy != op) && 2378 if ((mon->type == PLAYER || mon->enemy != op) &&
2421 (mon->type == PLAYER || QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)) && ( 2379 (mon->type == PLAYER || QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)) && (
2422#ifdef PROHIBIT_PLAYERKILL 2380#ifdef PROHIBIT_PLAYERKILL
2423 (op->contr->peaceful 2381 (op->contr->peaceful
2424 || (mon->type == PLAYER 2382 || (mon->type == PLAYER
2425 && mon->contr-> 2383 && mon->contr->
2426 peaceful)) && 2384 peaceful)) &&
2427#else 2385#else
2428 op->contr->peaceful && 2386 op->contr->peaceful &&
2429#endif 2387#endif
2430 !on_battleground)) 2388 !on_battleground))
2431 { 2389 {
2432 if (!op->contr->braced) 2390 if (!op->contr->braced)
2433 { 2391 {
2434 play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER); 2392 play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER);
2435 (void) push_ob (mon, dir, op); 2393 (void) push_ob (mon, dir, op);
2436 } 2394 }
2437 else 2395 else
2438 {
2439 new_draw_info (0, 0, op, "You withhold your attack"); 2396 new_draw_info (0, 0, op, "You withhold your attack");
2440 } 2397
2441 if (op->contr->tmp_invis || op->hide) 2398 if (op->contr->tmp_invis || op->hide)
2442 make_visible (op); 2399 make_visible (op);
2443 } 2400 }
2444 2401
2445 /* If the object is a boulder or other rollable object, then 2402 /* If the object is a boulder or other rollable object, then
2473 op->speed_left += op->speed / op->contr->weapon_sp; 2430 op->speed_left += op->speed / op->contr->weapon_sp;
2474 2431
2475 op->contr->has_hit = 1; /* The last action was to hit, so use weapon_sp */ 2432 op->contr->has_hit = 1; /* The last action was to hit, so use weapon_sp */
2476 } 2433 }
2477 2434
2478 skill_attack (mon, op, 0, NULL, NULL); 2435 skill_attack (mon, op, 0, 0, 0);
2479 2436
2480 /* If attacking another player, that player gets automatic 2437 /* If attacking another player, that player gets automatic
2481 * hitback, and doesn't loose luck either. 2438 * hitback, and doesn't loose luck either.
2482 * Disable hitback on the battleground or if the target is 2439 * Disable hitback on the battleground or if the target is
2483 * the wiz. 2440 * the wiz.
2485 if (mon->type == PLAYER && mon->stats.hp >= 0 && !mon->contr->has_hit && !on_battleground && !QUERY_FLAG (mon, FLAG_WIZ)) 2442 if (mon->type == PLAYER && mon->stats.hp >= 0 && !mon->contr->has_hit && !on_battleground && !QUERY_FLAG (mon, FLAG_WIZ))
2486 { 2443 {
2487 short luck = mon->stats.luck; 2444 short luck = mon->stats.luck;
2488 2445
2489 mon->contr->has_hit = 1; 2446 mon->contr->has_hit = 1;
2490 skill_attack (op, mon, 0, NULL, NULL); 2447 skill_attack (op, mon, 0, 0, 0);
2491 mon->stats.luck = luck; 2448 mon->stats.luck = luck;
2492 } 2449 }
2450
2493 if (action_makes_visible (op)) 2451 if (action_makes_visible (op))
2494 make_visible (op); 2452 make_visible (op);
2495 } 2453 }
2496 } /* if player should attack something */ 2454 } /* if player should attack something */
2497} 2455}
2532 2490
2533 /* Add special check for newcs players and fire on - this way, the 2491 /* Add special check for newcs players and fire on - this way, the
2534 * server can handle repeat firing. 2492 * server can handle repeat firing.
2535 */ 2493 */
2536 if (op->contr->fire_on || (op->contr->run_on && pick != 0)) 2494 if (op->contr->fire_on || (op->contr->run_on && pick != 0))
2537 {
2538 op->direction = dir; 2495 op->direction = dir;
2539 }
2540 else 2496 else
2541 {
2542 op->direction = 0; 2497 op->direction = 0;
2543 } 2498
2544 /* Update how the player looks. Use the facing, so direction may 2499 /* Update how the player looks. Use the facing, so direction may
2545 * get reset to zero. This allows for full animation capabilities 2500 * get reset to zero. This allows for full animation capabilities
2546 * for players. 2501 * for players.
2547 */ 2502 */
2548 animate_object (op, op->facing); 2503 animate_object (op, op->facing);
2593 /* I've been seeing crashes where the golem has been destroyed, but 2548 /* 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 2549 * 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 2550 * 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. 2551 * put this in a a workaround to clean up the golem pointer.
2597 */ 2552 */
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))) 2553 if (op->contr->ranges[range_golem] && QUERY_FLAG (op->contr->ranges[range_golem], FLAG_REMOVED))
2600 {
2601 op->contr->ranges[range_golem] = NULL; 2554 op->contr->ranges[range_golem] = 0;
2602 op->contr->golem_count = 0;
2603 }
2604 2555
2605 /* call this here - we also will call this in do_ericserver, but 2556 /* call this here - we also will call this in do_ericserver, but
2606 * the players time has been increased when doericserver has been 2557 * the players time has been increased when doericserver has been
2607 * called, so we recheck it here. 2558 * called, so we recheck it here.
2608 */ 2559 */
2609 HandleClient (&op->contr->socket, op->contr); 2560 //TODO: better than handling 8 commands, use some more intelligent rate-limiting
2561 for (int rep = 8; --rep && op->contr->ns->handle_command (); )
2562 ;
2563
2610 if (op->speed_left < 0) 2564 if (op->speed_left < 0)
2611 return 0; 2565 return 0;
2612 2566
2613 if (op->direction && (op->contr->run_on || op->contr->fire_on)) 2567 if (op->direction && (op->contr->run_on || op->contr->fire_on))
2614 { 2568 {
2623 if (op->speed_left > 0) 2577 if (op->speed_left > 0)
2624 return 1; 2578 return 1;
2625 else 2579 else
2626 return 0; 2580 return 0;
2627 } 2581 }
2582
2628 return 0; 2583 return 0;
2629} 2584}
2630 2585
2631int 2586int
2632save_life (object *op) 2587save_life (object *op)
2633{ 2588{
2634 object *tmp;
2635
2636 if (!QUERY_FLAG (op, FLAG_LIFESAVE)) 2589 if (!QUERY_FLAG (op, FLAG_LIFESAVE))
2637 return 0; 2590 return 0;
2638 2591
2639 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 2592 for (object *tmp = op->inv; tmp; tmp = tmp->below)
2640 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) 2593 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE))
2641 { 2594 {
2642 play_sound_map (op->map, op->x, op->y, SOUND_OB_EVAPORATE); 2595 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)); 2596 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp));
2597
2644 if (op->contr) 2598 if (op->contr)
2645 esrv_del_item (op->contr, tmp->count); 2599 esrv_del_item (op->contr, tmp->count);
2646 remove_ob (tmp); 2600
2647 free_object (tmp); 2601 tmp->destroy ();
2648 CLEAR_FLAG (op, FLAG_LIFESAVE); 2602 CLEAR_FLAG (op, FLAG_LIFESAVE);
2603
2649 if (op->stats.hp < 0) 2604 if (op->stats.hp < 0)
2650 op->stats.hp = op->stats.maxhp; 2605 op->stats.hp = op->stats.maxhp;
2606
2651 if (op->stats.food < 0) 2607 if (op->stats.food < 0)
2652 op->stats.food = 999; 2608 op->stats.food = 999;
2609
2653 fix_player (op); 2610 fix_player (op);
2654 return 1; 2611 return 1;
2655 } 2612 }
2613
2656 LOG (llevError, "Error: LIFESAVE set without applied object.\n"); 2614 LOG (llevError, "Error: LIFESAVE set without applied object.\n");
2657 CLEAR_FLAG (op, FLAG_LIFESAVE); 2615 CLEAR_FLAG (op, FLAG_LIFESAVE);
2658 enter_player_savebed (op); /* bring him home. */ 2616 enter_player_savebed (op); /* bring him home. */
2659 return 0; 2617 return 0;
2660} 2618}
2674 next = op->below; /* Make sure we have a good value, in case 2632 next = op->below; /* Make sure we have a good value, in case
2675 * we remove object 'op' 2633 * we remove object 'op'
2676 */ 2634 */
2677 if (QUERY_FLAG (op, FLAG_UNPAID)) 2635 if (QUERY_FLAG (op, FLAG_UNPAID))
2678 { 2636 {
2679 remove_ob (op); 2637 op->remove ();
2680 op->x = env->x; 2638 op->x = env->x;
2681 op->y = env->y; 2639 op->y = env->y;
2682 if (env->type == PLAYER) 2640 if (env->type == PLAYER)
2683 esrv_del_item (env->contr, op->count); 2641 esrv_del_item (env->contr, op->count);
2684 insert_ob_in_map (op, env->map, NULL, 0); 2642 insert_ob_in_map (op, env->map, NULL, 0);
2685 } 2643 }
2686 else if (op->inv) 2644 else if (op->inv)
2687 remove_unpaid_objects (op->inv, env); 2645 remove_unpaid_objects (op->inv, env);
2646
2688 op = next; 2647 op = next;
2689 } 2648 }
2690} 2649}
2691 2650
2692 2651
2707 strcpy (buf2, " R.I.P.\n\n"); 2666 strcpy (buf2, " R.I.P.\n\n");
2708 if (op->type == PLAYER) 2667 if (op->type == PLAYER)
2709 sprintf (buf, "%s the %s\n", &op->name, op->contr->title); 2668 sprintf (buf, "%s the %s\n", &op->name, op->contr->title);
2710 else 2669 else
2711 sprintf (buf, "%s\n", &op->name); 2670 sprintf (buf, "%s\n", &op->name);
2671
2712 strncat (buf2, " ", 20 - strlen (buf) / 2); 2672 strncat (buf2, " ", 20 - strlen (buf) / 2);
2713 strcat (buf2, buf); 2673 strcat (buf2, buf);
2714 if (op->type == PLAYER) 2674 if (op->type == PLAYER)
2715 sprintf (buf, "who was in level %d when killed\n", op->level); 2675 sprintf (buf, "who was in level %d when killed\n", op->level);
2716 else 2676 else
2717 sprintf (buf, "who was in level %d when died.\n\n", op->level); 2677 sprintf (buf, "who was in level %d when died.\n\n", op->level);
2678
2718 strncat (buf2, " ", 20 - strlen (buf) / 2); 2679 strncat (buf2, " ", 20 - strlen (buf) / 2);
2719 strcat (buf2, buf); 2680 strcat (buf2, buf);
2720 if (op->type == PLAYER) 2681 if (op->type == PLAYER)
2721 { 2682 {
2722 sprintf (buf, "by %s.\n\n", op->contr->killer); 2683 sprintf (buf, "by %s.\n\n", op->contr->killer);
2723 strncat (buf2, " ", 21 - strlen (buf) / 2); 2684 strncat (buf2, " ", 21 - strlen (buf) / 2);
2724 strcat (buf2, buf); 2685 strcat (buf2, buf);
2725 } 2686 }
2687
2726 strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now)); 2688 strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now));
2727 strncat (buf2, " ", 20 - strlen (buf) / 2); 2689 strncat (buf2, " ", 20 - strlen (buf) / 2);
2728 strcat (buf2, buf); 2690 strcat (buf2, buf);
2691
2729 return buf2; 2692 return buf2;
2730} 2693}
2731 2694
2732 2695
2733 2696
2750 for (i = 0; i < NUM_OUTPUT_BUFS; i++) 2713 for (i = 0; i < NUM_OUTPUT_BUFS; i++)
2751 if (op->contr->outputs[i].buf != NULL && (op->contr->outputs[i].first_update + op->contr->outputs_sync) < (uint16) pticks) 2714 if (op->contr->outputs[i].buf != NULL && (op->contr->outputs[i].first_update + op->contr->outputs_sync) < (uint16) pticks)
2752 flush_output_element (op, &op->contr->outputs[i]); 2715 flush_output_element (op, &op->contr->outputs[i]);
2753 } 2716 }
2754 2717
2755 if (op->contr->state == ST_PLAYING) 2718 if (op->contr->ns->state == ST_PLAYING)
2756 { 2719 {
2757 2720
2758 /* these next three if clauses make it possible to SLOW DOWN 2721 /* these next three if clauses make it possible to SLOW DOWN
2759 hp/grace/spellpoint regeneration. */ 2722 hp/grace/spellpoint regeneration. */
2760 if (op->contr->gen_hp >= 0) 2723 if (op->contr->gen_hp >= 0)
2902 if (!QUERY_FLAG (op, FLAG_WIZ)) 2865 if (!QUERY_FLAG (op, FLAG_WIZ))
2903 op->stats.food--; 2866 op->stats.food--;
2904 } 2867 }
2905 } 2868 }
2906 2869
2907 if (op->contr->state == ST_PLAYING && op->stats.food < 0 && op->stats.hp >= 0) 2870 if (op->contr->ns->state == ST_PLAYING && op->stats.food < 0 && op->stats.hp >= 0)
2908 { 2871 {
2909 object *tmp, *flesh = NULL; 2872 object *tmp, *flesh = NULL;
2910 2873
2911 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 2874 for (tmp = op->inv; tmp != NULL; tmp = tmp->below)
2912 { 2875 {
2934 } /* end if player is starving */ 2897 } /* end if player is starving */
2935 2898
2936 while (op->stats.food < 0 && op->stats.hp > 0) 2899 while (op->stats.food < 0 && op->stats.hp > 0)
2937 op->stats.food++, op->stats.hp--; 2900 op->stats.food++, op->stats.hp--;
2938 2901
2939 if (!op->contr->state && !QUERY_FLAG (op, FLAG_WIZ) && (op->stats.hp < 0 || op->stats.food < 0)) 2902 if (!op->contr->ns->state && !QUERY_FLAG (op, FLAG_WIZ) && (op->stats.hp < 0 || op->stats.food < 0))
2940 kill_player (op); 2903 kill_player (op);
2941} 2904}
2942 2905
2943 2906
2944 2907
2952{ 2915{
2953 char buf[MAX_BUF]; 2916 char buf[MAX_BUF];
2954 int x, y; 2917 int x, y;
2955 2918
2956 //int i; 2919 //int i;
2957 mapstruct *map; /* this is for resurrection */ 2920 maptile *map; /* this is for resurrection */
2958 2921
2959 /* int z; 2922 /* int z;
2960 int num_stats_lose; 2923 int num_stats_lose;
2961 int lost_a_stat; 2924 int lost_a_stat;
2962 int lose_this_stat; 2925 int lose_this_stat;
2981 /* restore player */ 2944 /* restore player */
2982 at = archetype::find ("poisoning"); 2945 at = archetype::find ("poisoning");
2983 tmp = present_arch_in_ob (at, op); 2946 tmp = present_arch_in_ob (at, op);
2984 if (tmp) 2947 if (tmp)
2985 { 2948 {
2986 remove_ob (tmp); 2949 tmp->destroy ();
2987 free_object (tmp);
2988 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); 2950 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed");
2989 } 2951 }
2990 2952
2991 at = archetype::find ("confusion"); 2953 at = archetype::find ("confusion");
2992 tmp = present_arch_in_ob (at, op); 2954 tmp = present_arch_in_ob (at, op);
2993 if (tmp) 2955 if (tmp)
2994 { 2956 {
2995 remove_ob (tmp); 2957 tmp->destroy ();
2996 free_object (tmp);
2997 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); 2958 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer");
2998 } 2959 }
2999 2960
3000 cure_disease (op, 0); /* remove any disease */ 2961 cure_disease (op, 0); /* remove any disease */
3001 op->stats.hp = op->stats.maxhp; 2962 op->stats.hp = op->stats.maxhp;
3178 /* determine_god() seems to not work sometimes... why is this? 3139 /* determine_god() seems to not work sometimes... why is this?
3179 Should I be using something else? GD */ 3140 Should I be using something else? GD */
3180 const char *god = determine_god (op); 3141 const char *god = determine_god (op);
3181 3142
3182 if (god && (strcmp (god, "none"))) 3143 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); 3144 new_draw_info_format (NDI_UNIQUE, 0, op, "For a brief moment you feel the holy presence of %s protecting" " you.", god);
3184 else 3145 else
3185 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you."); 3146 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you feel a holy presence protecting you.");
3186 } 3147 }
3148#else
3149 new_draw_info (NDI_UNIQUE, 0, op, "For a brief moment you" " feel a holy presence protecting you from losing yourself completely.");
3187#endif 3150#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 3151
3190 /* Put a gravestone up where the character 'almost' died. List the 3152 /* Put a gravestone up where the character 'almost' died. List the
3191 * exp loss on the stone. 3153 * exp loss on the stone.
3192 */ 3154 */
3193 tmp = arch_to_object (archetype::find ("gravestone")); 3155 tmp = arch_to_object (archetype::find ("gravestone"));
3198 sprintf (buf, "RIP\nHere rests the hero %s the %s,\n" "who was killed\n" "by %s.\n", &op->name, op->contr->title, op->contr->killer); 3160 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; 3161 tmp->msg = buf;
3200 tmp->x = op->x, tmp->y = op->y; 3162 tmp->x = op->x, tmp->y = op->y;
3201 insert_ob_in_map (tmp, op->map, NULL, 0); 3163 insert_ob_in_map (tmp, op->map, NULL, 0);
3202 3164
3203 /**************************************/ 3165 /**************************************/
3204 /* */ 3166 /* */
3205 /* Subtract the experience points, */ 3167 /* Subtract the experience points, */
3206 /* if we died cause of food, give us */ 3168 /* if we died cause of food, give us */
3207 /* food, and reset HP's... */ 3169 /* food, and reset HP's... */
3208 /* */ 3170 /* */
3209
3210 /**************************************/ 3171 /**************************************/
3211 3172
3212 /* remove any poisoning and confusion the character may be suffering. */ 3173 /* remove any poisoning and confusion the character may be suffering. */
3213 /* restore player */ 3174 /* restore player */
3214 at = archetype::find ("poisoning"); 3175 at = archetype::find ("poisoning");
3215 tmp = present_arch_in_ob (at, op); 3176 tmp = present_arch_in_ob (at, op);
3177
3216 if (tmp) 3178 if (tmp)
3217 { 3179 {
3218 remove_ob (tmp); 3180 tmp->destroy ();
3219 free_object (tmp);
3220 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed"); 3181 new_draw_info (NDI_UNIQUE, 0, op, "Your body feels cleansed");
3221 } 3182 }
3222 3183
3223 at = archetype::find ("confusion"); 3184 at = archetype::find ("confusion");
3224 tmp = present_arch_in_ob (at, op); 3185 tmp = present_arch_in_ob (at, op);
3225 if (tmp) 3186 if (tmp)
3226 { 3187 {
3227 remove_ob (tmp); 3188 tmp->destroy ();
3228 free_object (tmp);
3229 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer"); 3189 new_draw_info (NDI_UNIQUE, 0, tmp, "Your mind feels clearer");
3230 } 3190 }
3191
3231 cure_disease (op, 0); /* remove any disease */ 3192 cure_disease (op, 0); /* remove any disease */
3232 3193
3233 /*add_exp(op, (op->stats.exp * -0.20)); */ 3194 /*add_exp(op, (op->stats.exp * -0.20)); */
3234 apply_death_exp_penalty (op); 3195 apply_death_exp_penalty (op);
3235 if (op->stats.food < 100) 3196 if (op->stats.food < 100)
3245 */ 3206 */
3246 3207
3247 if (is_in_shop (op)) 3208 if (is_in_shop (op))
3248 remove_unpaid_objects (op->inv, op); 3209 remove_unpaid_objects (op->inv, op);
3249 3210
3250 /****************************************/ 3211 /****************************************/
3251 /* */ 3212 /* */
3252 /* Move player to his current respawn- */ 3213 /* Move player to his current respawn- */
3253 /* position (usually last savebed) */ 3214 /* position (usually last savebed) */
3254 /* */ 3215 /* */
3255
3256 /****************************************/ 3216 /****************************************/
3257 3217
3258 enter_player_savebed (op); 3218 enter_player_savebed (op);
3259 3219
3260 /* Save the player before inserting the force to reduce 3220 /* Save the player before inserting the force to reduce
3261 * chance of abuse. 3221 * chance of abuse.
3267 * at his savebed location, and that can have long lasting 3227 * at his savebed location, and that can have long lasting
3268 * spell effects. So first see if there is a spell effect 3228 * spell effects. So first see if there is a spell effect
3269 * on the space that might harm the player. 3229 * on the space that might harm the player.
3270 */ 3230 */
3271 will_kill_again = 0; 3231 will_kill_again = 0;
3272 for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above) 3232 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp; tmp = tmp->above)
3273 {
3274 if (tmp->type == SPELL_EFFECT) 3233 if (tmp->type == SPELL_EFFECT)
3275 will_kill_again |= tmp->attacktype; 3234 will_kill_again |= tmp->attacktype;
3276 } 3235
3277 if (will_kill_again) 3236 if (will_kill_again)
3278 { 3237 {
3279 object *force; 3238 object *force;
3280 int at; 3239 int at;
3281 3240
3283 /* 50 ticks should be enough time for the spell to abate */ 3242 /* 50 ticks should be enough time for the spell to abate */
3284 force->speed = 0.1; 3243 force->speed = 0.1;
3285 force->speed_left = -5.0; 3244 force->speed_left = -5.0;
3286 SET_FLAG (force, FLAG_APPLIED); 3245 SET_FLAG (force, FLAG_APPLIED);
3287 for (at = 0; at < NROFATTACKS; at++) 3246 for (at = 0; at < NROFATTACKS; at++)
3288 {
3289 if (will_kill_again & (1 << at)) 3247 if (will_kill_again & (1 << at))
3290 force->resist[at] = 100; 3248 force->resist[at] = 100;
3291 } 3249
3292 insert_ob_in_ob (force, op); 3250 insert_ob_in_ob (force, op);
3293 fix_player (op); 3251 fix_player (op);
3294 3252
3295 } 3253 }
3296 3254
3306 op->contr->party = NULL; 3264 op->contr->party = NULL;
3307 if (settings.set_title == TRUE) 3265 if (settings.set_title == TRUE)
3308 op->contr->own_title[0] = '\0'; 3266 op->contr->own_title[0] = '\0';
3309 new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf); 3267 new_draw_info (NDI_UNIQUE | NDI_ALL, 0, NULL, buf);
3310 check_score (op); 3268 check_score (op);
3269
3311 if (op->contr->ranges[range_golem] != NULL) 3270 if (op->contr->ranges[range_golem])
3312 { 3271 {
3313 remove_friendly_object (op->contr->ranges[range_golem]); 3272 remove_friendly_object (op->contr->ranges[range_golem]);
3314 remove_ob (op->contr->ranges[range_golem]); 3273 op->contr->ranges[range_golem]->destroy ();
3315 free_object (op->contr->ranges[range_golem]);
3316 op->contr->ranges[range_golem] = NULL; 3274 op->contr->ranges[range_golem] = 0;
3317 op->contr->golem_count = 0;
3318 } 3275 }
3276
3319 loot_object (op); /* Remove some of the items for good */ 3277 loot_object (op); /* Remove some of the items for good */
3320 remove_ob (op); 3278 op->remove ();
3321 op->direction = 0; 3279 op->direction = 0;
3322 3280
3323 if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp) 3281 if (!QUERY_FLAG (op, FLAG_WAS_WIZ) && op->stats.exp)
3324 { 3282 {
3325 delete_character (op->name, 0); 3283 delete_character (op->name, 0);
3376 } 3334 }
3377 3335
3378 for (tmp = op->inv; tmp != NULL; tmp = next) 3336 for (tmp = op->inv; tmp != NULL; tmp = next)
3379 { 3337 {
3380 next = tmp->below; 3338 next = tmp->below;
3381 if (tmp->type == EXPERIENCE || tmp->invisible) 3339 if (tmp->invisible)
3382 continue; 3340 continue;
3383 remove_ob (tmp); 3341 tmp->remove ();
3384 tmp->x = op->x, tmp->y = op->y; 3342 tmp->x = op->x, tmp->y = op->y;
3385 if (tmp->type == CONTAINER) 3343 if (tmp->type == CONTAINER)
3386 { /* empty container to ground */ 3344 { /* empty container to ground */
3387 loot_object (tmp); 3345 loot_object (tmp);
3388 } 3346 }
3389 if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(RANDOM () % 3))) 3347 if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(RANDOM () % 3)))
3390 { 3348 {
3391 if (tmp->nrof > 1) 3349 if (tmp->nrof > 1)
3392 { 3350 {
3393 tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); 3351 tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1));
3394 free_object (tmp2); 3352 tmp2->destroy ();
3395 insert_ob_in_map (tmp, op->map, NULL, 0); 3353 insert_ob_in_map (tmp, op->map, NULL, 0);
3396 } 3354 }
3397 else 3355 else
3398 free_object (tmp); 3356 tmp->destroy ();
3399 } 3357 }
3400 else 3358 else
3401 insert_ob_in_map (tmp, op->map, NULL, 0); 3359 insert_ob_in_map (tmp, op->map, NULL, 0);
3402 } 3360 }
3403} 3361}
3428fix_luck (void) 3386fix_luck (void)
3429{ 3387{
3430 player *pl; 3388 player *pl;
3431 3389
3432 for (pl = first_player; pl != NULL; pl = pl->next) 3390 for (pl = first_player; pl != NULL; pl = pl->next)
3433 if (!pl->ob->contr->state) 3391 if (!pl->ob->contr->ns->state)
3434 change_luck (pl->ob, 0); 3392 change_luck (pl->ob, 0);
3435} 3393}
3436 3394
3437 3395
3438/* cast_dust() - handles op throwing objects of type 'DUST'. 3396/* cast_dust() - handles op throwing objects of type 'DUST'.
3468 if (op->type == PLAYER) 3426 if (op->type == PLAYER)
3469 new_draw_info_format (NDI_UNIQUE, 0, op, "You cast %s.", &spob->name); 3427 new_draw_info_format (NDI_UNIQUE, 0, op, "You cast %s.", &spob->name);
3470 3428
3471 cast_spell (op, throw_ob, dir, spob, NULL); 3429 cast_spell (op, throw_ob, dir, spob, NULL);
3472 3430
3473 if (!QUERY_FLAG (throw_ob, FLAG_REMOVED)) 3431 throw_ob->destroy ();
3474 remove_ob (throw_ob);
3475 free_object (throw_ob);
3476} 3432}
3477 3433
3478void 3434void
3479make_visible (object *op) 3435make_visible (object *op)
3480{ 3436{
3494 object *tmp = NULL; 3450 object *tmp = NULL;
3495 3451
3496 if (QUERY_FLAG (&op->arch->clone, FLAG_UNDEAD)) 3452 if (QUERY_FLAG (&op->arch->clone, FLAG_UNDEAD))
3497 return 1; 3453 return 1;
3498 3454
3499 if (op->type == PLAYER)
3500 for (tmp = op->inv; tmp; tmp = tmp->below)
3501 if (tmp->type == EXPERIENCE && tmp->stats.Wis)
3502 if (QUERY_FLAG (tmp, FLAG_UNDEAD))
3503 return 1;
3504 return 0; 3455 return 0;
3505} 3456}
3506 3457
3507/* look at the surrounding terrain to determine 3458/* look at the surrounding terrain to determine
3508 * the hideability of this object. Positive levels 3459 * the hideability of this object. Positive levels
3596int 3547int
3597stand_near_hostile (object *who) 3548stand_near_hostile (object *who)
3598{ 3549{
3599 object *tmp = NULL; 3550 object *tmp = NULL;
3600 int i, friendly = 0, player = 0, mflags; 3551 int i, friendly = 0, player = 0, mflags;
3601 mapstruct *m; 3552 maptile *m;
3602 sint16 x, y; 3553 sint16 x, y;
3603 3554
3604 if (!who) 3555 if (!who)
3605 return 0; 3556 return 0;
3606 3557
3623 if (mflags & P_OUT_OF_MAP) 3574 if (mflags & P_OUT_OF_MAP)
3624 continue; 3575 continue;
3625 if (OB_TYPE_MOVE_BLOCK (who, GET_MAP_MOVE_BLOCK (m, x, y))) 3576 if (OB_TYPE_MOVE_BLOCK (who, GET_MAP_MOVE_BLOCK (m, x, y)))
3626 continue; 3577 continue;
3627 3578
3628 for (tmp = get_map_ob (m, x, y); tmp; tmp = tmp->above) 3579 for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above)
3629 { 3580 {
3630 if ((player ||friendly) &&QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE)) 3581 if ((player ||friendly) &&QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE))
3631 return 1; 3582 return 1;
3632 else if (tmp->type == PLAYER) 3583 else if (tmp->type == PLAYER)
3633 { 3584 {
3687 3638
3688 /* only the viewable area the player sees is updated by LOS 3639 /* only the viewable area the player sees is updated by LOS
3689 * code, so we need to restrict ourselves to that range of values 3640 * code, so we need to restrict ourselves to that range of values
3690 * for any meaningful values. 3641 * for any meaningful values.
3691 */ 3642 */
3692 if (FABS (dx) <= (pl->contr->socket.mapx / 2) && 3643 if (FABS (dx) <= (pl->contr->ns->mapx / 2) &&
3693 FABS (dy) <= (pl->contr->socket.mapy / 2) && 3644 FABS (dy) <= (pl->contr->ns->mapy / 2) &&
3694 !pl->contr->blocked_los[dx + (pl->contr->socket.mapx / 2)][dy + (pl->contr->socket.mapy / 2)]) 3645 !pl->contr->blocked_los[dx + (pl->contr->ns->mapx / 2)][dy + (pl->contr->ns->mapy / 2)])
3695 return 1; 3646 return 1;
3696 op = op->more; 3647 op = op->more;
3697 } 3648 }
3698 return 0; 3649 return 0;
3699} 3650}
3885 { 3836 {
3886 /* forces in the treasurelist can alter the player's stats */ 3837 /* forces in the treasurelist can alter the player's stats */
3887 object *skin; 3838 object *skin;
3888 3839
3889 /* first get the dragon skin force */ 3840 /* first get the dragon skin force */
3841 shstr_cmp dragon_skin_force ("dragon_skin_force");
3890 for (skin = who->inv; skin != NULL && strcmp (skin->arch->name, "dragon_skin_force") != 0; skin = skin->below); 3842 for (skin = who->inv; skin && !(skin->arch->name == dragon_skin_force); skin = skin->below)
3843 ;
3844
3891 if (skin == NULL) 3845 if (!skin)
3892 return; 3846 return;
3893 3847
3894 /* adding new spellpath attunements */ 3848 /* adding new spellpath attunements */
3895 if (item->path_attuned > 0 && !(skin->path_attuned & item->path_attuned)) 3849 if (item->path_attuned > 0 && !(skin->path_attuned & item->path_attuned))
3896 { 3850 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines