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.38 by root, Thu Dec 14 04:30:32 2006 UTC vs.
Revision 1.52 by root, Thu Dec 21 23:37:06 2006 UTC

27#include <sounds.h> 27#include <sounds.h>
28#include <living.h> 28#include <living.h>
29#include <object.h> 29#include <object.h>
30#include <spells.h> 30#include <spells.h>
31#include <skills.h> 31#include <skills.h>
32#include <newclient.h>
33 32
34#ifdef COZY_SERVER 33#ifdef COZY_SERVER
35extern int same_party (partylist *a, partylist *b); 34extern int same_party (partylist *a, partylist *b);
36#endif 35#endif
37 36
83 int comp; 82 int comp;
84 int size; 83 int size;
85 84
86 sprintf (buf, "%s/%s", settings.confdir, settings.motd); 85 sprintf (buf, "%s/%s", settings.confdir, settings.motd);
87 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) 86 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL)
88 {
89 return; 87 return;
90 } 88
91 motd[0] = '\0'; 89 motd[0] = '\0';
92 size = 0; 90 size = 0;
91
93 while (fgets (buf, MAX_BUF, fp) != NULL) 92 while (fgets (buf, MAX_BUF, fp) != NULL)
94 { 93 {
95 if (*buf == '#') 94 if (*buf == '#')
96 continue; 95 continue;
96
97 strncat (motd + size, buf, HUGE_BUF - size); 97 strncat (motd + size, buf, HUGE_BUF - size);
98 size += strlen (buf); 98 size += strlen (buf);
99 } 99 }
100
100 draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_MOTD, MSG_SUBTYPE_NONE, motd, NULL); 101 draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_MOTD, MSG_SUBTYPE_NONE, motd, NULL);
101 close_and_delete (fp, comp); 102 close_and_delete (fp, comp);
102} 103}
103 104
104void 105void
110 int comp; 111 int comp;
111 int size; 112 int size;
112 113
113 sprintf (buf, "%s/%s", settings.confdir, settings.rules); 114 sprintf (buf, "%s/%s", settings.confdir, settings.rules);
114 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) 115 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL)
115 {
116 return; 116 return;
117 } 117
118 rules[0] = '\0'; 118 rules[0] = '\0';
119 size = 0; 119 size = 0;
120
120 while (fgets (buf, MAX_BUF, fp) != NULL) 121 while (fgets (buf, MAX_BUF, fp) != NULL)
121 { 122 {
122 if (*buf == '#') 123 if (*buf == '#')
123 continue; 124 continue;
125
124 if (size + strlen (buf) >= HUGE_BUF) 126 if (size + strlen (buf) >= HUGE_BUF)
125 { 127 {
126 LOG (llevDebug, "Warning, rules size is > %d bytes.\n", HUGE_BUF); 128 LOG (llevDebug, "Warning, rules size is > %d bytes.\n", HUGE_BUF);
127 break; 129 break;
128 } 130 }
131
129 strncat (rules + size, buf, HUGE_BUF - size); 132 strncat (rules + size, buf, HUGE_BUF - size);
130 size += strlen (buf); 133 size += strlen (buf);
131 } 134 }
135
132 draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_RULES, rules, NULL); 136 draw_ext_info (NDI_UNIQUE | NDI_GREEN, 0, op, MSG_TYPE_ADMIN, MSG_TYPE_ADMIN_RULES, rules, NULL);
133 close_and_delete (fp, comp); 137 close_and_delete (fp, comp);
134} 138}
135 139
136void 140void
144 int size; 148 int size;
145 149
146 sprintf (buf, "%s/%s", settings.confdir, settings.news); 150 sprintf (buf, "%s/%s", settings.confdir, settings.news);
147 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) 151 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL)
148 return; 152 return;
153
149 news[0] = '\0'; 154 news[0] = '\0';
150 subject[0] = '\0'; 155 subject[0] = '\0';
151 size = 0; 156 size = 0;
157
152 while (fgets (buf, MAX_BUF, fp) != NULL) 158 while (fgets (buf, MAX_BUF, fp) != NULL)
153 { 159 {
154 if (*buf == '#') 160 if (*buf == '#')
155 continue; 161 continue;
162
156 if (*buf == '%') 163 if (*buf == '%')
157 { /* send one news */ 164 { /* send one news */
158 if (size > 0) 165 if (size > 0)
159 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 */ 166 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 */
160 strcpy (subject, buf + 1); 167 strcpy (subject, buf + 1);
187 return 0; 194 return 0;
188 195
189 for (; *cp != '\0'; cp++) 196 for (; *cp != '\0'; cp++)
190 if (!((*cp >= 'a' && *cp <= 'z') || (*cp >= 'A' && *cp <= 'Z')) && *cp != '-' && *cp != '_') 197 if (!((*cp >= 'a' && *cp <= 'z') || (*cp >= 'A' && *cp <= 'Z')) && *cp != '-' && *cp != '_')
191 return 0; 198 return 0;
199
192 return 1; 200 return 1;
193} 201}
194 202
195/* This no longer sets the player map. Also, it now updates 203/* This no longer sets the player map. Also, it now updates
196 * all the pointers so the caller doesn't need to do that. 204 * all the pointers so the caller doesn't need to do that.
234 op->speed_left = 0.5; 242 op->speed_left = 0.5;
235 op->speed = 1.0; 243 op->speed = 1.0;
236 op->direction = 5; /* So player faces south */ 244 op->direction = 5; /* So player faces south */
237 op->stats.wc = 2; 245 op->stats.wc = 2;
238 op->run_away = 25; /* Then we panick... */ 246 op->run_away = 25; /* Then we panick... */
247
248 {
249 int oldmon = p->ns->monitor_spells; // what a hack
239 p->socket->monitor_spells = 0; /* Needed because esrv_update_spells( ) gets called by roll_stats */ 250 p->ns->monitor_spells = 0; /* Needed because esrv_update_spells( ) gets called by roll_stats */
240
241 roll_stats (op); 251 roll_stats (op);
252 p->ns->monitor_spells = oldmon;
253 }
242 p->state = ST_ROLL_STAT; 254 p->ns->state = ST_ROLL_STAT;
243 clear_los (op); 255 clear_los (op);
244 256
245 p->gen_sp_armour = 10; 257 p->gen_sp_armour = 10;
246 p->last_speed = -1; 258 p->last_speed = -1;
247 p->shoottype = range_none; 259 p->shoottype = range_none;
251 p->usekeys = containers; 263 p->usekeys = containers;
252 p->last_weapon_sp = -1; 264 p->last_weapon_sp = -1;
253 p->peaceful = 1; /* default peaceful */ 265 p->peaceful = 1; /* default peaceful */
254 p->do_los = 1; 266 p->do_los = 1;
255 p->explore = 0; 267 p->explore = 0;
256 p->no_shout = 0; /* default can shout */
257 268
258 assign (p->title, op->arch->clone.name); 269 assign (p->title, op->arch->clone.name);
259 op->race = op->arch->clone.race; 270 op->race = op->arch->clone.race;
260 271
261 CLEAR_FLAG (op, FLAG_READY_SKILL); 272 CLEAR_FLAG (op, FLAG_READY_SKILL);
275 p->last_resist[i] = -1; 286 p->last_resist[i] = -1;
276 287
277 p->last_stats.exp = -1; 288 p->last_stats.exp = -1;
278 p->last_weight = (uint32) - 1; 289 p->last_weight = (uint32) - 1;
279 290
280 p->socket->update_look = 0; 291 p->ns->update_look = 0;
281 p->socket->look_position = 0; 292 p->ns->look_position = 0;
282 293
283 return p; 294 return p;
284} 295}
285 296
286/* This loads the first map an puts the player on it. */ 297/* This loads the first map an puts the player on it. */
288set_first_map (object *op) 299set_first_map (object *op)
289{ 300{
290 strcpy (op->contr->maplevel, first_map_path); 301 strcpy (op->contr->maplevel, first_map_path);
291 op->x = -1; 302 op->x = -1;
292 op->y = -1; 303 op->y = -1;
293 enter_exit (op, NULL); 304 enter_exit (op, 0);
294} 305}
295 306
296/* Tries to add player on the connection passwd in ns. 307/* Tries to add player on the connection passwd in ns.
297 * All we can really get in this is some settings like host and display 308 * All we can really get in this is some settings like host and display
298 * mode. 309 * mode.
299 */ 310 */
300 311
301int 312int
302add_player (client_socket *ns) 313add_player (client *ns)
303{ 314{
304 player *p = new player; 315 player *p = new player;
305 316
306 p->socket = ns; 317 p->ns = ns;
307 ns->pl = p; 318 ns->pl = p;
308 319
309 p->next = first_player; 320 p->next = first_player;
310 first_player = p; 321 first_player = p;
311 322
316 CLEAR_FLAG (p->ob, FLAG_FRIENDLY); 327 CLEAR_FLAG (p->ob, FLAG_FRIENDLY);
317 add_friendly_object (p->ob); 328 add_friendly_object (p->ob);
318 send_rules (p->ob); 329 send_rules (p->ob);
319 send_news (p->ob); 330 send_news (p->ob);
320 display_motd (p->ob); 331 display_motd (p->ob);
332
321 get_name (p->ob); 333 get_name (p->ob);
322 334
323 return 0; 335 return 0;
324} 336}
325 337
337 { 349 {
338 if (at == NULL || at->next == NULL) 350 if (at == NULL || at->next == NULL)
339 at = first_archetype; 351 at = first_archetype;
340 else 352 else
341 at = at->next; 353 at = at->next;
354
342 if (at->clone.type == PLAYER) 355 if (at->clone.type == PLAYER)
343 return at; 356 return at;
357
344 if (at == start) 358 if (at == start)
345 { 359 {
346 LOG (llevError, "No Player archetypes\n"); 360 LOG (llevError, "No Player archetypes\n");
347 exit (-1); 361 exit (-1);
348 } 362 }
349 } 363 }
350} 364}
351
352 365
353object * 366object *
354get_nearest_player (object *mon) 367get_nearest_player (object *mon)
355{ 368{
356 object *op = NULL; 369 object *op = NULL;
685 698
686void 699void
687get_name (object *op) 700get_name (object *op)
688{ 701{
689 op->contr->write_buf[0] = '\0'; 702 op->contr->write_buf[0] = '\0';
690 op->contr->state = ST_GET_NAME; 703 op->contr->ns->state = ST_GET_NAME;
691 send_query (op->contr->socket, 0, "What is your name?\n:"); 704 send_query (op->contr->ns, 0, "What is your name?\n:");
692} 705}
693 706
694void 707void
695get_password (object *op) 708get_password (object *op)
696{ 709{
697 op->contr->write_buf[0] = '\0'; 710 op->contr->write_buf[0] = '\0';
698 op->contr->state = ST_GET_PASSWORD; 711 op->contr->ns->state = ST_GET_PASSWORD;
699 send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "What is your password?\n:"); 712 send_query (op->contr->ns, CS_QUERY_HIDEINPUT, "What is your password?\n:");
700} 713}
701 714
702void 715void
703play_again (object *op) 716play_again (object *op)
704{ 717{
705 op->contr->state = ST_PLAY_AGAIN; 718 op->contr->ns->state = ST_PLAY_AGAIN;
706 op->chosen_skill = NULL; 719 op->chosen_skill = NULL;
707 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Do you want to play again (a/q)?"); 720 send_query (op->contr->ns, CS_QUERY_SINGLECHAR, "Do you want to play again (a/q)?");
708 /* a bit of a hack, but there are various places early in th 721 /* a bit of a hack, but there are various places early in th
709 * player creation process that a user can quit (eg, roll 722 * player creation process that a user can quit (eg, roll
710 * stats) that isn't removing the player. Taking a quick 723 * stats) that isn't removing the player. Taking a quick
711 * look, there are many places that call play_again without 724 * look, there are many places that call play_again without
712 * removing the player - it probably makes more sense 725 * removing the player - it probably makes more sense
713 * to leave it to play_again to remove the object in all 726 * to leave it to play_again to remove the object in all
714 * cases. 727 * cases.
715 */ 728 */
716 if (!QUERY_FLAG (op, FLAG_REMOVED)) 729 if (!QUERY_FLAG (op, FLAG_REMOVED))
717 op->remove (); 730 op->remove ();
731
718 /* Need to set this to null - otherwise, it could point to garbage, 732 /* Need to set this to null - otherwise, it could point to garbage,
719 * and draw() doesn't check to see if the player is removed, only if 733 * and draw() doesn't check to see if the player is removed, only if
720 * the map is null or not swapped out. 734 * the map is null or not swapped out.
721 */ 735 */
722 op->map = NULL; 736 op->map = NULL;
760void 774void
761confirm_password (object *op) 775confirm_password (object *op)
762{ 776{
763 777
764 op->contr->write_buf[0] = '\0'; 778 op->contr->write_buf[0] = '\0';
765 op->contr->state = ST_CONFIRM_PASSWORD; 779 op->contr->ns->state = ST_CONFIRM_PASSWORD;
766 send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "Please type your password again.\n:"); 780 send_query (op->contr->ns, CS_QUERY_HIDEINPUT, "Please type your password again.\n:");
767} 781}
768 782
769void 783void
770get_party_password (object *op, partylist *party) 784get_party_password (object *op, partylist *party)
771{ 785{
773 { 787 {
774 LOG (llevError, "get_party_password(): tried to make player %s join a NULL party", &op->name); 788 LOG (llevError, "get_party_password(): tried to make player %s join a NULL party", &op->name);
775 return; 789 return;
776 } 790 }
777 op->contr->write_buf[0] = '\0'; 791 op->contr->write_buf[0] = '\0';
778 op->contr->state = ST_GET_PARTY_PASSWORD; 792 op->contr->ns->state = ST_GET_PARTY_PASSWORD;
779 op->contr->party_to_join = party; 793 op->contr->party_to_join = party;
780 send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "What is the password?\n:"); 794 send_query (op->contr->ns, CS_QUERY_HIDEINPUT, "What is the password?\n:");
781} 795}
782 796
783 797
784/* This rolls four 1-6 rolls and sums the best 3 of the 4. */ 798/* This rolls four 1-6 rolls and sums the best 3 of the 4. */
785int 799int
882 896
883void 897void
884Roll_Again (object *op) 898Roll_Again (object *op)
885{ 899{
886 esrv_new_player (op->contr, 0); 900 esrv_new_player (op->contr, 0);
887 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, 901 send_query (op->contr->ns, CS_QUERY_SINGLECHAR,
888 "[y] to roll new stats [n] to use stats\n[1-7] [1-7] to swap stats.\nRoll again (y/n/1-7)? "); 902 "[y] to roll new stats [n] to use stats\n[1-7] [1-7] to swap stats.\nRoll again (y/n/1-7)? ");
889} 903}
890 904
891void 905void
892Swap_Stat (object *op, int Swap_Second) 906Swap_Stat (object *op, int Swap_Second)
959 new_draw_info (NDI_UNIQUE, 0, op, buf); 973 new_draw_info (NDI_UNIQUE, 0, op, buf);
960 } 974 }
961 else 975 else
962 Swap_Stat (op, stat_trans[keynum]); 976 Swap_Stat (op, stat_trans[keynum]);
963 977
964 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, ""); 978 send_query (op->contr->ns, CS_QUERY_SINGLECHAR, "");
965 return 1; 979 return 1;
966 } 980 }
967 switch (key) 981 switch (key)
968 { 982 {
969 case 'n': 983 case 'n':
983 enter_exit (op, NULL); 997 enter_exit (op, NULL);
984#endif 998#endif
985 SET_ANIMATION (op, 2); /* So player faces south */ 999 SET_ANIMATION (op, 2); /* So player faces south */
986 /* Enter exit adds a player otherwise */ 1000 /* Enter exit adds a player otherwise */
987 add_statbonus (op); 1001 add_statbonus (op);
988 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, 1002 send_query (op->contr->ns, CS_QUERY_SINGLECHAR,
989 "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n"); 1003 "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n");
990 op->contr->state = ST_CHANGE_CLASS; 1004 op->contr->ns->state = ST_CHANGE_CLASS;
991 if (op->msg) 1005 if (op->msg)
992 new_draw_info (NDI_BLUE, 0, op, op->msg); 1006 new_draw_info (NDI_BLUE, 0, op, op->msg);
993 return 0; 1007 return 0;
994 } 1008 }
995 case 'y': 1009 case 'y':
996 case 'Y': 1010 case 'Y':
997 roll_stats (op); 1011 roll_stats (op);
998 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, ""); 1012 send_query (op->contr->ns, CS_QUERY_SINGLECHAR, "");
999 return 1; 1013 return 1;
1000 1014
1001 case 'q': 1015 case 'q':
1002 case 'Q': 1016 case 'Q':
1003 play_again (op); 1017 play_again (op);
1004 return 1; 1018 return 1;
1005 1019
1006 default: 1020 default:
1007 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?"); 1021 send_query (op->contr->ns, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?");
1008 return 0; 1022 return 0;
1009 } 1023 }
1010 return 0; 1024 return 0;
1011} 1025}
1012 1026
1040 create_treasure (tl, op, 0, 0, 0); 1054 create_treasure (tl, op, 0, 0, 0);
1041 1055
1042 INVOKE_PLAYER (BIRTH, op->contr); 1056 INVOKE_PLAYER (BIRTH, op->contr);
1043 INVOKE_PLAYER (LOGIN, op->contr); 1057 INVOKE_PLAYER (LOGIN, op->contr);
1044 1058
1045 op->contr->state = ST_PLAYING; 1059 op->contr->ns->state = ST_PLAYING;
1046 1060
1047 if (op->msg) 1061 if (op->msg)
1048 op->msg = NULL; 1062 op->msg = NULL;
1049 1063
1050 /* We create this now because some of the unique maps will need it 1064 /* We create this now because some of the unique maps will need it
1080 * if the map isn't there, then stay on the 1094 * if the map isn't there, then stay on the
1081 * default initial map */ 1095 * default initial map */
1082 tmp->destroy (); 1096 tmp->destroy ();
1083 } 1097 }
1084 else 1098 else
1085 {
1086 LOG (llevDebug, "first_map_ext_path not set\n"); 1099 LOG (llevDebug, "first_map_ext_path not set\n");
1087 } 1100
1088 return 0; 1101 return 0;
1089 } 1102 }
1090 1103
1091 /* Following actually changes the race - this is the default command 1104 /* Following actually changes the race - this is the default command
1092 * if we don't match with one of the options above. 1105 * if we don't match with one of the options above.
1122 op->stats.grace = 0; 1135 op->stats.grace = 0;
1123 1136
1124 if (op->msg) 1137 if (op->msg)
1125 new_draw_info (NDI_BLUE, 0, op, op->msg); 1138 new_draw_info (NDI_BLUE, 0, op, op->msg);
1126 1139
1127 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Press any key for the next race.\nPress `d' to play this race.\n"); 1140 send_query (op->contr->ns, CS_QUERY_SINGLECHAR, "Press any key for the next race.\nPress `d' to play this race.\n");
1128 return 0; 1141 return 0;
1129} 1142}
1130 1143
1131int 1144int
1132key_confirm_quit (object *op, char key) 1145key_confirm_quit (object *op, char key)
1133{ 1146{
1134 char buf[MAX_BUF]; 1147 char buf[MAX_BUF];
1135 1148
1136 if (key != 'y' && key != 'Y' && key != 'q' && key != 'Q') 1149 if (key != 'y' && key != 'Y' && key != 'q' && key != 'Q')
1137 { 1150 {
1138 op->contr->state = ST_PLAYING; 1151 op->contr->ns->state = ST_PLAYING;
1139 new_draw_info (NDI_UNIQUE, 0, op, "OK, continuing to play."); 1152 new_draw_info (NDI_UNIQUE, 0, op, "OK, continuing to play.");
1140 return 1; 1153 return 1;
1141 } 1154 }
1142 1155
1143 INVOKE_PLAYER (LOGOUT, op->contr); 1156 INVOKE_PLAYER (LOGOUT, op->contr);
1212 { 1225 {
1213 op->enemy = NULL; 1226 op->enemy = NULL;
1214 CLEAR_FLAG (op, FLAG_SCARED); 1227 CLEAR_FLAG (op, FLAG_SCARED);
1215 return; 1228 return;
1216 } 1229 }
1230
1217 get_rangevector (op, op->enemy, &rv, 0); 1231 get_rangevector (op, op->enemy, &rv, 0);
1218 1232
1219 dir = absdir (4 + rv.direction); 1233 dir = absdir (4 + rv.direction);
1220 for (diff = 0; diff < 3; diff++) 1234 for (diff = 0; diff < 3; diff++)
1221 { 1235 {
1222 int m = 1 - (RANDOM () & 2); 1236 int m = 1 - (RANDOM () & 2);
1223 1237
1224 if (move_ob (op, absdir (dir + diff * m), op) || (diff == 0 && move_ob (op, absdir (dir - diff * m), op))) 1238 if (move_ob (op, absdir (dir + diff * m), op) || (diff == 0 && move_ob (op, absdir (dir - diff * m), op)))
1225 {
1226 return; 1239 return;
1227 }
1228 } 1240 }
1241
1229 /* Cornered, get rid of scared */ 1242 /* Cornered, get rid of scared */
1230 CLEAR_FLAG (op, FLAG_SCARED); 1243 CLEAR_FLAG (op, FLAG_SCARED);
1231 op->enemy = NULL; 1244 op->enemy = NULL;
1232} 1245}
1233 1246
1789 if (!dir) 1802 if (!dir)
1790 { 1803 {
1791 new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); 1804 new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!");
1792 return 0; 1805 return 0;
1793 } 1806 }
1807
1794 if (op->type == PLAYER) 1808 if (op->type == PLAYER)
1795 bow = op->contr->ranges[range_bow]; 1809 bow = op->contr->ranges[range_bow];
1796 else 1810 else
1797 { 1811 {
1798 for (bow = op->inv; bow; bow = bow->below) 1812 for (bow = op->inv; bow; bow = bow->below)
1806 { 1820 {
1807 LOG (llevError, "Range: bow without activated bow (%s).\n", &op->name); 1821 LOG (llevError, "Range: bow without activated bow (%s).\n", &op->name);
1808 return 0; 1822 return 0;
1809 } 1823 }
1810 } 1824 }
1825
1811 if (!bow->race || !bow->skill) 1826 if (!bow->race || !bow->skill)
1812 { 1827 {
1813 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name); 1828 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name);
1814 return 0; 1829 return 0;
1815 } 1830 }
1817 bowspeed = bow->stats.sp + dex_bonus[op->stats.Dex]; 1832 bowspeed = bow->stats.sp + dex_bonus[op->stats.Dex];
1818 1833
1819 /* penalize ROF for bestarrow */ 1834 /* penalize ROF for bestarrow */
1820 if (op->type == PLAYER && op->contr->bowtype == bow_bestarrow) 1835 if (op->type == PLAYER && op->contr->bowtype == bow_bestarrow)
1821 bowspeed -= dex_bonus[op->stats.Dex] + 5; 1836 bowspeed -= dex_bonus[op->stats.Dex] + 5;
1837
1822 if (bowspeed < 1) 1838 if (bowspeed < 1)
1823 bowspeed = 1; 1839 bowspeed = 1;
1824 1840
1825 if (arrow == NULL) 1841 if (arrow == NULL)
1826 { 1842 {
1832 else 1848 else
1833 CLEAR_FLAG (op, FLAG_READY_BOW); 1849 CLEAR_FLAG (op, FLAG_READY_BOW);
1834 return 0; 1850 return 0;
1835 } 1851 }
1836 } 1852 }
1853
1837 mflags = get_map_flags (op->map, &m, sx, sy, &sx, &sy); 1854 mflags = get_map_flags (op->map, &m, sx, sy, &sx, &sy);
1838 if (mflags & P_OUT_OF_MAP) 1855 if (mflags & P_OUT_OF_MAP)
1839 {
1840 return 0; 1856 return 0;
1841 } 1857
1842 if (GET_MAP_MOVE_BLOCK (m, sx, sy) == MOVE_FLY_LOW) 1858 if (GET_MAP_MOVE_BLOCK (m, sx, sy) == MOVE_FLY_LOW)
1843 { 1859 {
1844 new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); 1860 new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way.");
1845 return 0; 1861 return 0;
1846 } 1862 }
1852 return 0; 1868 return 0;
1853 } 1869 }
1854 1870
1855 left = arrow; /* these are arrows left to the player */ 1871 left = arrow; /* these are arrows left to the player */
1856 arrow = get_split_ob (arrow, 1); 1872 arrow = get_split_ob (arrow, 1);
1857 if (arrow == NULL) 1873 if (!arrow)
1858 { 1874 {
1859 new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); 1875 new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race);
1860 return 0; 1876 return 0;
1861 } 1877 }
1878
1862 arrow->set_owner (op); 1879 arrow->set_owner (op);
1863 arrow->skill = bow->skill; 1880 arrow->skill = bow->skill;
1864 1881
1865 arrow->direction = dir; 1882 arrow->direction = dir;
1866 arrow->x = sx; 1883 arrow->x = sx;
1875 SET_ANIMATION (arrow, arrow->direction); 1892 SET_ANIMATION (arrow, arrow->direction);
1876 arrow->stats.sp = arrow->stats.wc; /* save original wc and dam */ 1893 arrow->stats.sp = arrow->stats.wc; /* save original wc and dam */
1877 arrow->stats.hp = arrow->stats.dam; 1894 arrow->stats.hp = arrow->stats.dam;
1878 arrow->stats.grace = arrow->attacktype; 1895 arrow->stats.grace = arrow->attacktype;
1879 if (arrow->slaying != NULL) 1896 if (arrow->slaying != NULL)
1880 arrow->spellarg = strdup_local (arrow->slaying); 1897 arrow->spellarg = strdup (arrow->slaying);
1881 1898
1882 /* Note that this was different for monsters - they got their level 1899 /* Note that this was different for monsters - they got their level
1883 * added to the damage. I think the strength bonus is more proper. 1900 * added to the damage. I think the strength bonus is more proper.
1884 */ 1901 */
1885 1902
1909 } 1926 }
1910 1927
1911 if (arrow->attacktype == AT_PHYSICAL) 1928 if (arrow->attacktype == AT_PHYSICAL)
1912 arrow->attacktype |= bow->attacktype; 1929 arrow->attacktype |= bow->attacktype;
1913 1930
1914 if (bow->slaying != NULL) 1931 if (bow->slaying)
1915 arrow->slaying = bow->slaying; 1932 arrow->slaying = bow->slaying;
1916 1933
1917 arrow->map = m; 1934 arrow->map = m;
1918 arrow->move_type = MOVE_FLY_LOW; 1935 arrow->move_type = MOVE_FLY_LOW;
1919 arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; 1936 arrow->move_on = MOVE_FLY_LOW | MOVE_WALK;
2035 CLEAR_FLAG (item, FLAG_ANIMATE); 2052 CLEAR_FLAG (item, FLAG_ANIMATE);
2036 item->face = item->arch->clone.face; 2053 item->face = item->arch->clone.face;
2037 item->speed = 0; 2054 item->speed = 0;
2038 update_ob_speed (item); 2055 update_ob_speed (item);
2039 } 2056 }
2040 if ((tmp = is_player_inv (item))) 2057 if ((tmp = item->in_player ()))
2041 esrv_update_item (UPD_ANIM, tmp, item); 2058 esrv_update_item (UPD_ANIM, tmp, item);
2042 } 2059 }
2043 } 2060 }
2044 else if (item->type == ROD || item->type == HORN) 2061 else if (item->type == ROD || item->type == HORN)
2045 { 2062 {
2195 * 0 otherwise 2212 * 0 otherwise
2196 */ 2213 */
2197static int 2214static int
2198player_attack_door (object *op, object *door) 2215player_attack_door (object *op, object *door)
2199{ 2216{
2200
2201 /* If its a door, try to find a use a key. If we do destroy the door, 2217 /* If its a door, try to find a use a key. If we do destroy the door,
2202 * might as well return immediately as there is nothing more to do - 2218 * might as well return immediately as there is nothing more to do -
2203 * otherwise, we fall through to the rest of the code. 2219 * otherwise, we fall through to the rest of the code.
2204 */ 2220 */
2205 object *key = find_key (op, op, door); 2221 object *key = find_key (op, op, door);
2243 * It should keep the code cleaner. 2259 * It should keep the code cleaner.
2244 * When this is called, the players direction has been updated 2260 * When this is called, the players direction has been updated
2245 * (taking into account confusion.) The player is also actually 2261 * (taking into account confusion.) The player is also actually
2246 * going to try and move (not fire weapons). 2262 * going to try and move (not fire weapons).
2247 */ 2263 */
2248
2249void 2264void
2250move_player_attack (object *op, int dir) 2265move_player_attack (object *op, int dir)
2251{ 2266{
2252 object *tmp, *mon; 2267 object *tmp, *mon;
2253 sint16 nx, ny; 2268 sint16 nx, ny;
2255 maptile *m; 2270 maptile *m;
2256 2271
2257 nx = freearr_x[dir] + op->x; 2272 nx = freearr_x[dir] + op->x;
2258 ny = freearr_y[dir] + op->y; 2273 ny = freearr_y[dir] + op->y;
2259 2274
2260 on_battleground = op_on_battleground (op, NULL, NULL); 2275 on_battleground = op_on_battleground (op, 0, 0);
2261 2276
2262 /* If braced, or can't move to the square, and it is not out of the 2277 /* If braced, or can't move to the square, and it is not out of the
2263 * map, attack it. Note order of if statement is important - don't 2278 * map, attack it. Note order of if statement is important - don't
2264 * want to be calling move_ob if braced, because move_ob will move the 2279 * want to be calling move_ob if braced, because move_ob will move the
2265 * player. This is a pretty nasty hack, because if we could 2280 * player. This is a pretty nasty hack, because if we could
2277 return; /* Don't think this should happen */ 2292 return; /* Don't think this should happen */
2278 } 2293 }
2279 else 2294 else
2280 m = op->map; 2295 m = op->map;
2281 2296
2282 if ((tmp = get_map_ob (m, nx, ny)) == NULL) 2297 if ((tmp = GET_MAP_OB (m, nx, ny)) == NULL)
2283 { 2298 {
2284 /* LOG(llevError,"player_move_attack: get_map_ob returns NULL, but player can not more there.\n"); */ 2299 /* LOG(llevError,"player_move_attack: GET_MAP_OB returns NULL, but player can not move there.\n"); */
2285 return; 2300 return;
2286 } 2301 }
2287 2302
2288 mon = NULL; 2303 mon = 0;
2289 /* Go through all the objects, and find ones of interest. Only stop if 2304 /* Go through all the objects, and find ones of interest. Only stop if
2290 * we find a monster - that is something we know we want to attack. 2305 * we find a monster - that is something we know we want to attack.
2291 * if its a door or barrel (can roll) see if there may be monsters 2306 * if its a door or barrel (can roll) see if there may be monsters
2292 * on the space 2307 * on the space
2293 */ 2308 */
2294 while (tmp != NULL) 2309 while (tmp)
2295 { 2310 {
2296 if (tmp == op) 2311 if (tmp == op)
2297 { 2312 {
2298 tmp = tmp->above; 2313 tmp = tmp->above;
2299 continue; 2314 continue;
2309 mon = tmp; 2324 mon = tmp;
2310 2325
2311 tmp = tmp->above; 2326 tmp = tmp->above;
2312 } 2327 }
2313 2328
2314 if (mon == NULL) /* This happens anytime the player tries to move */ 2329 if (!mon) /* This happens anytime the player tries to move */
2315 return; /* into a wall */ 2330 return; /* into a wall */
2316 2331
2317 if (mon->head != NULL) 2332 if (mon->head)
2318 mon = mon->head; 2333 mon = mon->head;
2319 2334
2320 if ((mon->type == DOOR && mon->stats.hp >= 0) || (mon->type == LOCKED_DOOR)) 2335 if ((mon->type == DOOR && mon->stats.hp >= 0) || (mon->type == LOCKED_DOOR))
2321 if (player_attack_door (op, mon)) 2336 if (player_attack_door (op, mon))
2322 return; 2337 return;
2359 * attack them either. 2374 * attack them either.
2360 */ 2375 */
2361 if ((mon->type == PLAYER || mon->enemy != op) && 2376 if ((mon->type == PLAYER || mon->enemy != op) &&
2362 (mon->type == PLAYER || QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)) && ( 2377 (mon->type == PLAYER || QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)) && (
2363#ifdef PROHIBIT_PLAYERKILL 2378#ifdef PROHIBIT_PLAYERKILL
2364 (op->contr->peaceful 2379 (op->contr->peaceful
2365 || (mon->type == PLAYER 2380 || (mon->type == PLAYER
2366 && mon->contr-> 2381 && mon->contr->
2367 peaceful)) && 2382 peaceful)) &&
2368#else 2383#else
2369 op->contr->peaceful && 2384 op->contr->peaceful &&
2370#endif 2385#endif
2371 !on_battleground)) 2386 !on_battleground))
2372 { 2387 {
2373 if (!op->contr->braced) 2388 if (!op->contr->braced)
2374 { 2389 {
2375 play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER); 2390 play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER);
2376 (void) push_ob (mon, dir, op); 2391 (void) push_ob (mon, dir, op);
2377 } 2392 }
2378 else 2393 else
2379 {
2380 new_draw_info (0, 0, op, "You withhold your attack"); 2394 new_draw_info (0, 0, op, "You withhold your attack");
2381 } 2395
2382 if (op->contr->tmp_invis || op->hide) 2396 if (op->contr->tmp_invis || op->hide)
2383 make_visible (op); 2397 make_visible (op);
2384 } 2398 }
2385 2399
2386 /* If the object is a boulder or other rollable object, then 2400 /* If the object is a boulder or other rollable object, then
2414 op->speed_left += op->speed / op->contr->weapon_sp; 2428 op->speed_left += op->speed / op->contr->weapon_sp;
2415 2429
2416 op->contr->has_hit = 1; /* The last action was to hit, so use weapon_sp */ 2430 op->contr->has_hit = 1; /* The last action was to hit, so use weapon_sp */
2417 } 2431 }
2418 2432
2419 skill_attack (mon, op, 0, NULL, NULL); 2433 skill_attack (mon, op, 0, 0, 0);
2420 2434
2421 /* If attacking another player, that player gets automatic 2435 /* If attacking another player, that player gets automatic
2422 * hitback, and doesn't loose luck either. 2436 * hitback, and doesn't loose luck either.
2423 * Disable hitback on the battleground or if the target is 2437 * Disable hitback on the battleground or if the target is
2424 * the wiz. 2438 * the wiz.
2426 if (mon->type == PLAYER && mon->stats.hp >= 0 && !mon->contr->has_hit && !on_battleground && !QUERY_FLAG (mon, FLAG_WIZ)) 2440 if (mon->type == PLAYER && mon->stats.hp >= 0 && !mon->contr->has_hit && !on_battleground && !QUERY_FLAG (mon, FLAG_WIZ))
2427 { 2441 {
2428 short luck = mon->stats.luck; 2442 short luck = mon->stats.luck;
2429 2443
2430 mon->contr->has_hit = 1; 2444 mon->contr->has_hit = 1;
2431 skill_attack (op, mon, 0, NULL, NULL); 2445 skill_attack (op, mon, 0, 0, 0);
2432 mon->stats.luck = luck; 2446 mon->stats.luck = luck;
2433 } 2447 }
2448
2434 if (action_makes_visible (op)) 2449 if (action_makes_visible (op))
2435 make_visible (op); 2450 make_visible (op);
2436 } 2451 }
2437 } /* if player should attack something */ 2452 } /* if player should attack something */
2438} 2453}
2473 2488
2474 /* Add special check for newcs players and fire on - this way, the 2489 /* Add special check for newcs players and fire on - this way, the
2475 * server can handle repeat firing. 2490 * server can handle repeat firing.
2476 */ 2491 */
2477 if (op->contr->fire_on || (op->contr->run_on && pick != 0)) 2492 if (op->contr->fire_on || (op->contr->run_on && pick != 0))
2478 {
2479 op->direction = dir; 2493 op->direction = dir;
2480 }
2481 else 2494 else
2482 {
2483 op->direction = 0; 2495 op->direction = 0;
2484 } 2496
2485 /* Update how the player looks. Use the facing, so direction may 2497 /* Update how the player looks. Use the facing, so direction may
2486 * get reset to zero. This allows for full animation capabilities 2498 * get reset to zero. This allows for full animation capabilities
2487 * for players. 2499 * for players.
2488 */ 2500 */
2489 animate_object (op, op->facing); 2501 animate_object (op, op->facing);
2541 2553
2542 /* call this here - we also will call this in do_ericserver, but 2554 /* call this here - we also will call this in do_ericserver, but
2543 * the players time has been increased when doericserver has been 2555 * the players time has been increased when doericserver has been
2544 * called, so we recheck it here. 2556 * called, so we recheck it here.
2545 */ 2557 */
2546 HandleClient (op->contr->socket, op->contr); 2558 //TODO: better than handling 8 commands, use some more intelligent rate-limiting
2559 for (int rep = 8; --rep && op->contr->ns->handle_command (); )
2560 ;
2561
2547 if (op->speed_left < 0) 2562 if (op->speed_left < 0)
2548 return 0; 2563 return 0;
2549 2564
2550 if (op->direction && (op->contr->run_on || op->contr->fire_on)) 2565 if (op->direction && (op->contr->run_on || op->contr->fire_on))
2551 { 2566 {
2560 if (op->speed_left > 0) 2575 if (op->speed_left > 0)
2561 return 1; 2576 return 1;
2562 else 2577 else
2563 return 0; 2578 return 0;
2564 } 2579 }
2580
2565 return 0; 2581 return 0;
2566} 2582}
2567 2583
2568int 2584int
2569save_life (object *op) 2585save_life (object *op)
2570{ 2586{
2571 object *tmp;
2572
2573 if (!QUERY_FLAG (op, FLAG_LIFESAVE)) 2587 if (!QUERY_FLAG (op, FLAG_LIFESAVE))
2574 return 0; 2588 return 0;
2575 2589
2576 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 2590 for (object *tmp = op->inv; tmp; tmp = tmp->below)
2577 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) 2591 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE))
2578 { 2592 {
2579 play_sound_map (op->map, op->x, op->y, SOUND_OB_EVAPORATE); 2593 play_sound_map (op->map, op->x, op->y, SOUND_OB_EVAPORATE);
2580 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); 2594 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp));
2581 2595
2592 op->stats.food = 999; 2606 op->stats.food = 999;
2593 2607
2594 fix_player (op); 2608 fix_player (op);
2595 return 1; 2609 return 1;
2596 } 2610 }
2611
2597 LOG (llevError, "Error: LIFESAVE set without applied object.\n"); 2612 LOG (llevError, "Error: LIFESAVE set without applied object.\n");
2598 CLEAR_FLAG (op, FLAG_LIFESAVE); 2613 CLEAR_FLAG (op, FLAG_LIFESAVE);
2599 enter_player_savebed (op); /* bring him home. */ 2614 enter_player_savebed (op); /* bring him home. */
2600 return 0; 2615 return 0;
2601} 2616}
2624 esrv_del_item (env->contr, op->count); 2639 esrv_del_item (env->contr, op->count);
2625 insert_ob_in_map (op, env->map, NULL, 0); 2640 insert_ob_in_map (op, env->map, NULL, 0);
2626 } 2641 }
2627 else if (op->inv) 2642 else if (op->inv)
2628 remove_unpaid_objects (op->inv, env); 2643 remove_unpaid_objects (op->inv, env);
2644
2629 op = next; 2645 op = next;
2630 } 2646 }
2631} 2647}
2632 2648
2633 2649
2648 strcpy (buf2, " R.I.P.\n\n"); 2664 strcpy (buf2, " R.I.P.\n\n");
2649 if (op->type == PLAYER) 2665 if (op->type == PLAYER)
2650 sprintf (buf, "%s the %s\n", &op->name, op->contr->title); 2666 sprintf (buf, "%s the %s\n", &op->name, op->contr->title);
2651 else 2667 else
2652 sprintf (buf, "%s\n", &op->name); 2668 sprintf (buf, "%s\n", &op->name);
2669
2653 strncat (buf2, " ", 20 - strlen (buf) / 2); 2670 strncat (buf2, " ", 20 - strlen (buf) / 2);
2654 strcat (buf2, buf); 2671 strcat (buf2, buf);
2655 if (op->type == PLAYER) 2672 if (op->type == PLAYER)
2656 sprintf (buf, "who was in level %d when killed\n", op->level); 2673 sprintf (buf, "who was in level %d when killed\n", op->level);
2657 else 2674 else
2658 sprintf (buf, "who was in level %d when died.\n\n", op->level); 2675 sprintf (buf, "who was in level %d when died.\n\n", op->level);
2676
2659 strncat (buf2, " ", 20 - strlen (buf) / 2); 2677 strncat (buf2, " ", 20 - strlen (buf) / 2);
2660 strcat (buf2, buf); 2678 strcat (buf2, buf);
2661 if (op->type == PLAYER) 2679 if (op->type == PLAYER)
2662 { 2680 {
2663 sprintf (buf, "by %s.\n\n", op->contr->killer); 2681 sprintf (buf, "by %s.\n\n", op->contr->killer);
2664 strncat (buf2, " ", 21 - strlen (buf) / 2); 2682 strncat (buf2, " ", 21 - strlen (buf) / 2);
2665 strcat (buf2, buf); 2683 strcat (buf2, buf);
2666 } 2684 }
2685
2667 strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now)); 2686 strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now));
2668 strncat (buf2, " ", 20 - strlen (buf) / 2); 2687 strncat (buf2, " ", 20 - strlen (buf) / 2);
2669 strcat (buf2, buf); 2688 strcat (buf2, buf);
2689
2670 return buf2; 2690 return buf2;
2671} 2691}
2672 2692
2673 2693
2674 2694
2691 for (i = 0; i < NUM_OUTPUT_BUFS; i++) 2711 for (i = 0; i < NUM_OUTPUT_BUFS; i++)
2692 if (op->contr->outputs[i].buf != NULL && (op->contr->outputs[i].first_update + op->contr->outputs_sync) < (uint16) pticks) 2712 if (op->contr->outputs[i].buf != NULL && (op->contr->outputs[i].first_update + op->contr->outputs_sync) < (uint16) pticks)
2693 flush_output_element (op, &op->contr->outputs[i]); 2713 flush_output_element (op, &op->contr->outputs[i]);
2694 } 2714 }
2695 2715
2696 if (op->contr->state == ST_PLAYING) 2716 if (op->contr->ns->state == ST_PLAYING)
2697 { 2717 {
2698 2718
2699 /* these next three if clauses make it possible to SLOW DOWN 2719 /* these next three if clauses make it possible to SLOW DOWN
2700 hp/grace/spellpoint regeneration. */ 2720 hp/grace/spellpoint regeneration. */
2701 if (op->contr->gen_hp >= 0) 2721 if (op->contr->gen_hp >= 0)
2843 if (!QUERY_FLAG (op, FLAG_WIZ)) 2863 if (!QUERY_FLAG (op, FLAG_WIZ))
2844 op->stats.food--; 2864 op->stats.food--;
2845 } 2865 }
2846 } 2866 }
2847 2867
2848 if (op->contr->state == ST_PLAYING && op->stats.food < 0 && op->stats.hp >= 0) 2868 if (op->contr->ns->state == ST_PLAYING && op->stats.food < 0 && op->stats.hp >= 0)
2849 { 2869 {
2850 object *tmp, *flesh = NULL; 2870 object *tmp, *flesh = NULL;
2851 2871
2852 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 2872 for (tmp = op->inv; tmp != NULL; tmp = tmp->below)
2853 { 2873 {
2875 } /* end if player is starving */ 2895 } /* end if player is starving */
2876 2896
2877 while (op->stats.food < 0 && op->stats.hp > 0) 2897 while (op->stats.food < 0 && op->stats.hp > 0)
2878 op->stats.food++, op->stats.hp--; 2898 op->stats.food++, op->stats.hp--;
2879 2899
2880 if (!op->contr->state && !QUERY_FLAG (op, FLAG_WIZ) && (op->stats.hp < 0 || op->stats.food < 0)) 2900 if (!op->contr->ns->state && !QUERY_FLAG (op, FLAG_WIZ) && (op->stats.hp < 0 || op->stats.food < 0))
2881 kill_player (op); 2901 kill_player (op);
2882} 2902}
2883 2903
2884 2904
2885 2905
3205 * at his savebed location, and that can have long lasting 3225 * at his savebed location, and that can have long lasting
3206 * spell effects. So first see if there is a spell effect 3226 * spell effects. So first see if there is a spell effect
3207 * on the space that might harm the player. 3227 * on the space that might harm the player.
3208 */ 3228 */
3209 will_kill_again = 0; 3229 will_kill_again = 0;
3210 for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above) 3230 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp; tmp = tmp->above)
3211 if (tmp->type == SPELL_EFFECT) 3231 if (tmp->type == SPELL_EFFECT)
3212 will_kill_again |= tmp->attacktype; 3232 will_kill_again |= tmp->attacktype;
3213 3233
3214 if (will_kill_again) 3234 if (will_kill_again)
3215 { 3235 {
3312 } 3332 }
3313 3333
3314 for (tmp = op->inv; tmp != NULL; tmp = next) 3334 for (tmp = op->inv; tmp != NULL; tmp = next)
3315 { 3335 {
3316 next = tmp->below; 3336 next = tmp->below;
3317 if (tmp->type == EXPERIENCE || tmp->invisible) 3337 if (tmp->invisible)
3318 continue; 3338 continue;
3319 tmp->remove (); 3339 tmp->remove ();
3320 tmp->x = op->x, tmp->y = op->y; 3340 tmp->x = op->x, tmp->y = op->y;
3321 if (tmp->type == CONTAINER) 3341 if (tmp->type == CONTAINER)
3322 { /* empty container to ground */ 3342 { /* empty container to ground */
3364fix_luck (void) 3384fix_luck (void)
3365{ 3385{
3366 player *pl; 3386 player *pl;
3367 3387
3368 for (pl = first_player; pl != NULL; pl = pl->next) 3388 for (pl = first_player; pl != NULL; pl = pl->next)
3369 if (!pl->ob->contr->state) 3389 if (!pl->ob->contr->ns->state)
3370 change_luck (pl->ob, 0); 3390 change_luck (pl->ob, 0);
3371} 3391}
3372 3392
3373 3393
3374/* cast_dust() - handles op throwing objects of type 'DUST'. 3394/* cast_dust() - handles op throwing objects of type 'DUST'.
3428 object *tmp = NULL; 3448 object *tmp = NULL;
3429 3449
3430 if (QUERY_FLAG (&op->arch->clone, FLAG_UNDEAD)) 3450 if (QUERY_FLAG (&op->arch->clone, FLAG_UNDEAD))
3431 return 1; 3451 return 1;
3432 3452
3433 if (op->type == PLAYER)
3434 for (tmp = op->inv; tmp; tmp = tmp->below)
3435 if (tmp->type == EXPERIENCE && tmp->stats.Wis)
3436 if (QUERY_FLAG (tmp, FLAG_UNDEAD))
3437 return 1;
3438 return 0; 3453 return 0;
3439} 3454}
3440 3455
3441/* look at the surrounding terrain to determine 3456/* look at the surrounding terrain to determine
3442 * the hideability of this object. Positive levels 3457 * the hideability of this object. Positive levels
3557 if (mflags & P_OUT_OF_MAP) 3572 if (mflags & P_OUT_OF_MAP)
3558 continue; 3573 continue;
3559 if (OB_TYPE_MOVE_BLOCK (who, GET_MAP_MOVE_BLOCK (m, x, y))) 3574 if (OB_TYPE_MOVE_BLOCK (who, GET_MAP_MOVE_BLOCK (m, x, y)))
3560 continue; 3575 continue;
3561 3576
3562 for (tmp = get_map_ob (m, x, y); tmp; tmp = tmp->above) 3577 for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above)
3563 { 3578 {
3564 if ((player ||friendly) &&QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE)) 3579 if ((player ||friendly) &&QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE))
3565 return 1; 3580 return 1;
3566 else if (tmp->type == PLAYER) 3581 else if (tmp->type == PLAYER)
3567 { 3582 {
3621 3636
3622 /* only the viewable area the player sees is updated by LOS 3637 /* only the viewable area the player sees is updated by LOS
3623 * code, so we need to restrict ourselves to that range of values 3638 * code, so we need to restrict ourselves to that range of values
3624 * for any meaningful values. 3639 * for any meaningful values.
3625 */ 3640 */
3626 if (FABS (dx) <= (pl->contr->socket->mapx / 2) && 3641 if (FABS (dx) <= (pl->contr->ns->mapx / 2) &&
3627 FABS (dy) <= (pl->contr->socket->mapy / 2) && 3642 FABS (dy) <= (pl->contr->ns->mapy / 2) &&
3628 !pl->contr->blocked_los[dx + (pl->contr->socket->mapx / 2)][dy + (pl->contr->socket->mapy / 2)]) 3643 !pl->contr->blocked_los[dx + (pl->contr->ns->mapx / 2)][dy + (pl->contr->ns->mapy / 2)])
3629 return 1; 3644 return 1;
3630 op = op->more; 3645 op = op->more;
3631 } 3646 }
3632 return 0; 3647 return 0;
3633} 3648}
3819 { 3834 {
3820 /* forces in the treasurelist can alter the player's stats */ 3835 /* forces in the treasurelist can alter the player's stats */
3821 object *skin; 3836 object *skin;
3822 3837
3823 /* first get the dragon skin force */ 3838 /* first get the dragon skin force */
3839 shstr_cmp dragon_skin_force ("dragon_skin_force");
3824 for (skin = who->inv; skin != NULL && strcmp (skin->arch->name, "dragon_skin_force") != 0; skin = skin->below); 3840 for (skin = who->inv; skin && !(skin->arch->name == dragon_skin_force); skin = skin->below)
3841 ;
3842
3825 if (skin == NULL) 3843 if (!skin)
3826 return; 3844 return;
3827 3845
3828 /* adding new spellpath attunements */ 3846 /* adding new spellpath attunements */
3829 if (item->path_attuned > 0 && !(skin->path_attuned & item->path_attuned)) 3847 if (item->path_attuned > 0 && !(skin->path_attuned & item->path_attuned))
3830 { 3848 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines