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.37 by root, Thu Dec 14 02:37:37 2006 UTC vs.
Revision 1.50 by elmex, Wed Dec 20 10:31:00 2006 UTC

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#include <pwd.h> 25#include <pwd.h>
26#ifndef __CEXTRACT__
27# include <sproto.h> 26#include <sproto.h>
28#endif
29#include <sounds.h> 27#include <sounds.h>
30#include <living.h> 28#include <living.h>
31#include <object.h> 29#include <object.h>
32#include <spells.h> 30#include <spells.h>
33#include <skills.h> 31#include <skills.h>
34#include <newclient.h>
35 32
36#ifdef COZY_SERVER 33#ifdef COZY_SERVER
37extern int same_party (partylist *a, partylist *b); 34extern int same_party (partylist *a, partylist *b);
38#endif 35#endif
39 36
85 int comp; 82 int comp;
86 int size; 83 int size;
87 84
88 sprintf (buf, "%s/%s", settings.confdir, settings.motd); 85 sprintf (buf, "%s/%s", settings.confdir, settings.motd);
89 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) 86 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL)
90 {
91 return; 87 return;
92 } 88
93 motd[0] = '\0'; 89 motd[0] = '\0';
94 size = 0; 90 size = 0;
91
95 while (fgets (buf, MAX_BUF, fp) != NULL) 92 while (fgets (buf, MAX_BUF, fp) != NULL)
96 { 93 {
97 if (*buf == '#') 94 if (*buf == '#')
98 continue; 95 continue;
96
99 strncat (motd + size, buf, HUGE_BUF - size); 97 strncat (motd + size, buf, HUGE_BUF - size);
100 size += strlen (buf); 98 size += strlen (buf);
101 } 99 }
100
102 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);
103 close_and_delete (fp, comp); 102 close_and_delete (fp, comp);
104} 103}
105 104
106void 105void
112 int comp; 111 int comp;
113 int size; 112 int size;
114 113
115 sprintf (buf, "%s/%s", settings.confdir, settings.rules); 114 sprintf (buf, "%s/%s", settings.confdir, settings.rules);
116 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) 115 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL)
117 {
118 return; 116 return;
119 } 117
120 rules[0] = '\0'; 118 rules[0] = '\0';
121 size = 0; 119 size = 0;
120
122 while (fgets (buf, MAX_BUF, fp) != NULL) 121 while (fgets (buf, MAX_BUF, fp) != NULL)
123 { 122 {
124 if (*buf == '#') 123 if (*buf == '#')
125 continue; 124 continue;
125
126 if (size + strlen (buf) >= HUGE_BUF) 126 if (size + strlen (buf) >= HUGE_BUF)
127 { 127 {
128 LOG (llevDebug, "Warning, rules size is > %d bytes.\n", HUGE_BUF); 128 LOG (llevDebug, "Warning, rules size is > %d bytes.\n", HUGE_BUF);
129 break; 129 break;
130 } 130 }
131
131 strncat (rules + size, buf, HUGE_BUF - size); 132 strncat (rules + size, buf, HUGE_BUF - size);
132 size += strlen (buf); 133 size += strlen (buf);
133 } 134 }
135
134 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);
135 close_and_delete (fp, comp); 137 close_and_delete (fp, comp);
136} 138}
137 139
138void 140void
146 int size; 148 int size;
147 149
148 sprintf (buf, "%s/%s", settings.confdir, settings.news); 150 sprintf (buf, "%s/%s", settings.confdir, settings.news);
149 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL) 151 if ((fp = open_and_uncompress (buf, 0, &comp)) == NULL)
150 return; 152 return;
153
151 news[0] = '\0'; 154 news[0] = '\0';
152 subject[0] = '\0'; 155 subject[0] = '\0';
153 size = 0; 156 size = 0;
157
154 while (fgets (buf, MAX_BUF, fp) != NULL) 158 while (fgets (buf, MAX_BUF, fp) != NULL)
155 { 159 {
156 if (*buf == '#') 160 if (*buf == '#')
157 continue; 161 continue;
162
158 if (*buf == '%') 163 if (*buf == '%')
159 { /* send one news */ 164 { /* send one news */
160 if (size > 0) 165 if (size > 0)
161 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 */
162 strcpy (subject, buf + 1); 167 strcpy (subject, buf + 1);
189 return 0; 194 return 0;
190 195
191 for (; *cp != '\0'; cp++) 196 for (; *cp != '\0'; cp++)
192 if (!((*cp >= 'a' && *cp <= 'z') || (*cp >= 'A' && *cp <= 'Z')) && *cp != '-' && *cp != '_') 197 if (!((*cp >= 'a' && *cp <= 'z') || (*cp >= 'A' && *cp <= 'Z')) && *cp != '-' && *cp != '_')
193 return 0; 198 return 0;
199
194 return 1; 200 return 1;
195} 201}
196 202
197/* This no longer sets the player map. Also, it now updates 203/* This no longer sets the player map. Also, it now updates
198 * 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.
206 * the one that is passed. 212 * the one that is passed.
207 */ 213 */
208static player * 214static player *
209get_player (player *p) 215get_player (player *p)
210{ 216{
211 object *op = arch_to_object (get_player_archetype (NULL)); 217 object *op = arch_to_object (get_player_archetype (0));
212 int i; 218 int i;
213
214 if (!p)
215 {
216 p = new player;
217
218 /* This adds the player in the linked list. There is extra
219 * complexity here because we want to add the new player at the
220 * end of the list - there is in fact no compelling reason that
221 * that needs to be done except for things like output of
222 * 'who'.
223 */
224 player *tmp = first_player;
225
226 while (tmp != NULL && tmp->next != NULL)
227 tmp = tmp->next;
228 if (tmp != NULL)
229 tmp->next = p;
230 else
231 first_player = p;
232
233 p->next = NULL;
234 }
235 219
236 /* Clears basically the entire player structure except 220 /* Clears basically the entire player structure except
237 * for next and socket. 221 * for next and socket.
238 */ 222 */
239 p->clear (); 223 p->clear ();
258 op->speed_left = 0.5; 242 op->speed_left = 0.5;
259 op->speed = 1.0; 243 op->speed = 1.0;
260 op->direction = 5; /* So player faces south */ 244 op->direction = 5; /* So player faces south */
261 op->stats.wc = 2; 245 op->stats.wc = 2;
262 op->run_away = 25; /* Then we panick... */ 246 op->run_away = 25; /* Then we panick... */
247
248 {
249 int oldmon = p->socket->monitor_spells; // what a hack
263 p->socket.monitor_spells = 0; /* Needed because esrv_update_spells( ) gets called by roll_stats */ 250 p->socket->monitor_spells = 0; /* Needed because esrv_update_spells( ) gets called by roll_stats */
264
265 roll_stats (op); 251 roll_stats (op);
252 p->socket->monitor_spells = oldmon;
253 }
266 p->state = ST_ROLL_STAT; 254 p->state = ST_ROLL_STAT;
267 clear_los (op); 255 clear_los (op);
268 256
269 p->gen_sp_armour = 10; 257 p->gen_sp_armour = 10;
270 p->last_speed = -1; 258 p->last_speed = -1;
275 p->usekeys = containers; 263 p->usekeys = containers;
276 p->last_weapon_sp = -1; 264 p->last_weapon_sp = -1;
277 p->peaceful = 1; /* default peaceful */ 265 p->peaceful = 1; /* default peaceful */
278 p->do_los = 1; 266 p->do_los = 1;
279 p->explore = 0; 267 p->explore = 0;
280 p->no_shout = 0; /* default can shout */
281 268
282 assign (p->title, op->arch->clone.name); 269 assign (p->title, op->arch->clone.name);
283 op->race = op->arch->clone.race; 270 op->race = op->arch->clone.race;
284 271
285 CLEAR_FLAG (op, FLAG_READY_SKILL); 272 CLEAR_FLAG (op, FLAG_READY_SKILL);
292 for (i = 0; i < NUM_SKILLS; i++) 279 for (i = 0; i < NUM_SKILLS; i++)
293 { 280 {
294 p->last_skill_exp[i] = -1; 281 p->last_skill_exp[i] = -1;
295 p->last_skill_ob[i] = NULL; 282 p->last_skill_ob[i] = NULL;
296 } 283 }
284
297 for (i = 0; i < NROFATTACKS; i++) 285 for (i = 0; i < NROFATTACKS; i++)
298 {
299 p->last_resist[i] = -1; 286 p->last_resist[i] = -1;
300 } 287
301 p->last_stats.exp = -1; 288 p->last_stats.exp = -1;
302 p->last_weight = (uint32) - 1; 289 p->last_weight = (uint32) - 1;
303 290
304 p->socket.update_look = 0; 291 p->socket->update_look = 0;
305 p->socket.look_position = 0; 292 p->socket->look_position = 0;
293
306 return p; 294 return p;
307} 295}
308 296
309/* This loads the first map an puts the player on it. */ 297/* This loads the first map an puts the player on it. */
310static void 298static void
311set_first_map (object *op) 299set_first_map (object *op)
312{ 300{
313 strcpy (op->contr->maplevel, first_map_path); 301 strcpy (op->contr->maplevel, first_map_path);
314 op->x = -1; 302 op->x = -1;
315 op->y = -1; 303 op->y = -1;
316 enter_exit (op, NULL); 304 enter_exit (op, 0);
317} 305}
318 306
319/* Tries to add player on the connection passwd in ns. 307/* Tries to add player on the connection passwd in ns.
320 * 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
321 * mode. 309 * mode.
322 */ 310 */
323 311
324int 312int
325add_player (client_socket * ns) 313add_player (client *ns)
326{ 314{
327 player *p; 315 player *p = new player;
328 316
329 p = get_player (NULL);
330 p->socket = *ns; 317 p->socket = ns;
331 p->socket.faces_sent = (uint8 *) malloc (p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); 318 ns->pl = p;
332 319
333 if (p->socket.faces_sent == NULL) 320 p->next = first_player;
334 fatal (OUT_OF_MEMORY); 321 first_player = p;
335 322
336 memcpy (p->socket.faces_sent, ns->faces_sent, p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); 323 p = get_player (p);
337 /* Needed because the socket we just copied over needs to be cleared. 324
338 * Note that this can result in a client reset if there is partial data
339 * on the uncoming socket.
340 */
341 //TODO socket copying is EVIL, do not do this
342 p->socket.inbuf_len = 0;
343 set_first_map (p->ob); 325 set_first_map (p->ob);
344 326
345 CLEAR_FLAG (p->ob, FLAG_FRIENDLY); 327 CLEAR_FLAG (p->ob, FLAG_FRIENDLY);
346 add_friendly_object (p->ob); 328 add_friendly_object (p->ob);
347 send_rules (p->ob); 329 send_rules (p->ob);
366 { 348 {
367 if (at == NULL || at->next == NULL) 349 if (at == NULL || at->next == NULL)
368 at = first_archetype; 350 at = first_archetype;
369 else 351 else
370 at = at->next; 352 at = at->next;
353
371 if (at->clone.type == PLAYER) 354 if (at->clone.type == PLAYER)
372 return at; 355 return at;
356
373 if (at == start) 357 if (at == start)
374 { 358 {
375 LOG (llevError, "No Player archetypes\n"); 359 LOG (llevError, "No Player archetypes\n");
376 exit (-1); 360 exit (-1);
377 } 361 }
378 } 362 }
379} 363}
380
381 364
382object * 365object *
383get_nearest_player (object *mon) 366get_nearest_player (object *mon)
384{ 367{
385 object *op = NULL; 368 object *op = NULL;
715void 698void
716get_name (object *op) 699get_name (object *op)
717{ 700{
718 op->contr->write_buf[0] = '\0'; 701 op->contr->write_buf[0] = '\0';
719 op->contr->state = ST_GET_NAME; 702 op->contr->state = ST_GET_NAME;
720 send_query (&op->contr->socket, 0, "What is your name?\n:"); 703 send_query (op->contr->socket, 0, "What is your name?\n:");
721} 704}
722 705
723void 706void
724get_password (object *op) 707get_password (object *op)
725{ 708{
726 op->contr->write_buf[0] = '\0'; 709 op->contr->write_buf[0] = '\0';
727 op->contr->state = ST_GET_PASSWORD; 710 op->contr->state = ST_GET_PASSWORD;
728 send_query (&op->contr->socket, CS_QUERY_HIDEINPUT, "What is your password?\n:"); 711 send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "What is your password?\n:");
729} 712}
730 713
731void 714void
732play_again (object *op) 715play_again (object *op)
733{ 716{
734 op->contr->state = ST_PLAY_AGAIN; 717 op->contr->state = ST_PLAY_AGAIN;
735 op->chosen_skill = NULL; 718 op->chosen_skill = NULL;
736 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Do you want to play again (a/q)?"); 719 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Do you want to play again (a/q)?");
737 /* a bit of a hack, but there are various places early in th 720 /* a bit of a hack, but there are various places early in th
738 * player creation process that a user can quit (eg, roll 721 * player creation process that a user can quit (eg, roll
739 * stats) that isn't removing the player. Taking a quick 722 * stats) that isn't removing the player. Taking a quick
740 * look, there are many places that call play_again without 723 * look, there are many places that call play_again without
741 * removing the player - it probably makes more sense 724 * removing the player - it probably makes more sense
790confirm_password (object *op) 773confirm_password (object *op)
791{ 774{
792 775
793 op->contr->write_buf[0] = '\0'; 776 op->contr->write_buf[0] = '\0';
794 op->contr->state = ST_CONFIRM_PASSWORD; 777 op->contr->state = ST_CONFIRM_PASSWORD;
795 send_query (&op->contr->socket, CS_QUERY_HIDEINPUT, "Please type your password again.\n:"); 778 send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "Please type your password again.\n:");
796} 779}
797 780
798void 781void
799get_party_password (object *op, partylist *party) 782get_party_password (object *op, partylist *party)
800{ 783{
804 return; 787 return;
805 } 788 }
806 op->contr->write_buf[0] = '\0'; 789 op->contr->write_buf[0] = '\0';
807 op->contr->state = ST_GET_PARTY_PASSWORD; 790 op->contr->state = ST_GET_PARTY_PASSWORD;
808 op->contr->party_to_join = party; 791 op->contr->party_to_join = party;
809 send_query (&op->contr->socket, CS_QUERY_HIDEINPUT, "What is the password?\n:"); 792 send_query (op->contr->socket, CS_QUERY_HIDEINPUT, "What is the password?\n:");
810} 793}
811 794
812 795
813/* This rolls four 1-6 rolls and sums the best 3 of the 4. */ 796/* This rolls four 1-6 rolls and sums the best 3 of the 4. */
814int 797int
911 894
912void 895void
913Roll_Again (object *op) 896Roll_Again (object *op)
914{ 897{
915 esrv_new_player (op->contr, 0); 898 esrv_new_player (op->contr, 0);
916 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, 899 send_query (op->contr->socket, CS_QUERY_SINGLECHAR,
917 "[y] to roll new stats [n] to use stats\n[1-7] [1-7] to swap stats.\nRoll again (y/n/1-7)? "); 900 "[y] to roll new stats [n] to use stats\n[1-7] [1-7] to swap stats.\nRoll again (y/n/1-7)? ");
918} 901}
919 902
920void 903void
921Swap_Stat (object *op, int Swap_Second) 904Swap_Stat (object *op, int Swap_Second)
988 new_draw_info (NDI_UNIQUE, 0, op, buf); 971 new_draw_info (NDI_UNIQUE, 0, op, buf);
989 } 972 }
990 else 973 else
991 Swap_Stat (op, stat_trans[keynum]); 974 Swap_Stat (op, stat_trans[keynum]);
992 975
993 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, ""); 976 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "");
994 return 1; 977 return 1;
995 } 978 }
996 switch (key) 979 switch (key)
997 { 980 {
998 case 'n': 981 case 'n':
1012 enter_exit (op, NULL); 995 enter_exit (op, NULL);
1013#endif 996#endif
1014 SET_ANIMATION (op, 2); /* So player faces south */ 997 SET_ANIMATION (op, 2); /* So player faces south */
1015 /* Enter exit adds a player otherwise */ 998 /* Enter exit adds a player otherwise */
1016 add_statbonus (op); 999 add_statbonus (op);
1017 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, 1000 send_query (op->contr->socket, CS_QUERY_SINGLECHAR,
1018 "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n"); 1001 "Now choose a character.\nPress any key to change outlook.\nPress `d' when you're pleased.\n");
1019 op->contr->state = ST_CHANGE_CLASS; 1002 op->contr->state = ST_CHANGE_CLASS;
1020 if (op->msg) 1003 if (op->msg)
1021 new_draw_info (NDI_BLUE, 0, op, op->msg); 1004 new_draw_info (NDI_BLUE, 0, op, op->msg);
1022 return 0; 1005 return 0;
1023 } 1006 }
1024 case 'y': 1007 case 'y':
1025 case 'Y': 1008 case 'Y':
1026 roll_stats (op); 1009 roll_stats (op);
1027 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, ""); 1010 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "");
1028 return 1; 1011 return 1;
1029 1012
1030 case 'q': 1013 case 'q':
1031 case 'Q': 1014 case 'Q':
1032 play_again (op); 1015 play_again (op);
1033 return 1; 1016 return 1;
1034 1017
1035 default: 1018 default:
1036 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?"); 1019 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Yes, No, Quit or 1-6. Roll again?");
1037 return 0; 1020 return 0;
1038 } 1021 }
1039 return 0; 1022 return 0;
1040} 1023}
1041 1024
1109 * if the map isn't there, then stay on the 1092 * if the map isn't there, then stay on the
1110 * default initial map */ 1093 * default initial map */
1111 tmp->destroy (); 1094 tmp->destroy ();
1112 } 1095 }
1113 else 1096 else
1114 {
1115 LOG (llevDebug, "first_map_ext_path not set\n"); 1097 LOG (llevDebug, "first_map_ext_path not set\n");
1116 } 1098
1117 return 0; 1099 return 0;
1118 } 1100 }
1119 1101
1120 /* Following actually changes the race - this is the default command 1102 /* Following actually changes the race - this is the default command
1121 * if we don't match with one of the options above. 1103 * if we don't match with one of the options above.
1151 op->stats.grace = 0; 1133 op->stats.grace = 0;
1152 1134
1153 if (op->msg) 1135 if (op->msg)
1154 new_draw_info (NDI_BLUE, 0, op, op->msg); 1136 new_draw_info (NDI_BLUE, 0, op, op->msg);
1155 1137
1156 send_query (&op->contr->socket, CS_QUERY_SINGLECHAR, "Press any key for the next race.\nPress `d' to play this race.\n"); 1138 send_query (op->contr->socket, CS_QUERY_SINGLECHAR, "Press any key for the next race.\nPress `d' to play this race.\n");
1157 return 0; 1139 return 0;
1158} 1140}
1159 1141
1160int 1142int
1161key_confirm_quit (object *op, char key) 1143key_confirm_quit (object *op, char key)
1241 { 1223 {
1242 op->enemy = NULL; 1224 op->enemy = NULL;
1243 CLEAR_FLAG (op, FLAG_SCARED); 1225 CLEAR_FLAG (op, FLAG_SCARED);
1244 return; 1226 return;
1245 } 1227 }
1228
1246 get_rangevector (op, op->enemy, &rv, 0); 1229 get_rangevector (op, op->enemy, &rv, 0);
1247 1230
1248 dir = absdir (4 + rv.direction); 1231 dir = absdir (4 + rv.direction);
1249 for (diff = 0; diff < 3; diff++) 1232 for (diff = 0; diff < 3; diff++)
1250 { 1233 {
1251 int m = 1 - (RANDOM () & 2); 1234 int m = 1 - (RANDOM () & 2);
1252 1235
1253 if (move_ob (op, absdir (dir + diff * m), op) || (diff == 0 && move_ob (op, absdir (dir - diff * m), op))) 1236 if (move_ob (op, absdir (dir + diff * m), op) || (diff == 0 && move_ob (op, absdir (dir - diff * m), op)))
1254 {
1255 return; 1237 return;
1256 }
1257 } 1238 }
1239
1258 /* Cornered, get rid of scared */ 1240 /* Cornered, get rid of scared */
1259 CLEAR_FLAG (op, FLAG_SCARED); 1241 CLEAR_FLAG (op, FLAG_SCARED);
1260 op->enemy = NULL; 1242 op->enemy = NULL;
1261} 1243}
1262 1244
1818 if (!dir) 1800 if (!dir)
1819 { 1801 {
1820 new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); 1802 new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!");
1821 return 0; 1803 return 0;
1822 } 1804 }
1805
1823 if (op->type == PLAYER) 1806 if (op->type == PLAYER)
1824 bow = op->contr->ranges[range_bow]; 1807 bow = op->contr->ranges[range_bow];
1825 else 1808 else
1826 { 1809 {
1827 for (bow = op->inv; bow; bow = bow->below) 1810 for (bow = op->inv; bow; bow = bow->below)
1835 { 1818 {
1836 LOG (llevError, "Range: bow without activated bow (%s).\n", &op->name); 1819 LOG (llevError, "Range: bow without activated bow (%s).\n", &op->name);
1837 return 0; 1820 return 0;
1838 } 1821 }
1839 } 1822 }
1823
1840 if (!bow->race || !bow->skill) 1824 if (!bow->race || !bow->skill)
1841 { 1825 {
1842 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name); 1826 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", &bow->name);
1843 return 0; 1827 return 0;
1844 } 1828 }
1846 bowspeed = bow->stats.sp + dex_bonus[op->stats.Dex]; 1830 bowspeed = bow->stats.sp + dex_bonus[op->stats.Dex];
1847 1831
1848 /* penalize ROF for bestarrow */ 1832 /* penalize ROF for bestarrow */
1849 if (op->type == PLAYER && op->contr->bowtype == bow_bestarrow) 1833 if (op->type == PLAYER && op->contr->bowtype == bow_bestarrow)
1850 bowspeed -= dex_bonus[op->stats.Dex] + 5; 1834 bowspeed -= dex_bonus[op->stats.Dex] + 5;
1835
1851 if (bowspeed < 1) 1836 if (bowspeed < 1)
1852 bowspeed = 1; 1837 bowspeed = 1;
1853 1838
1854 if (arrow == NULL) 1839 if (arrow == NULL)
1855 { 1840 {
1861 else 1846 else
1862 CLEAR_FLAG (op, FLAG_READY_BOW); 1847 CLEAR_FLAG (op, FLAG_READY_BOW);
1863 return 0; 1848 return 0;
1864 } 1849 }
1865 } 1850 }
1851
1866 mflags = get_map_flags (op->map, &m, sx, sy, &sx, &sy); 1852 mflags = get_map_flags (op->map, &m, sx, sy, &sx, &sy);
1867 if (mflags & P_OUT_OF_MAP) 1853 if (mflags & P_OUT_OF_MAP)
1868 {
1869 return 0; 1854 return 0;
1870 } 1855
1871 if (GET_MAP_MOVE_BLOCK (m, sx, sy) == MOVE_FLY_LOW) 1856 if (GET_MAP_MOVE_BLOCK (m, sx, sy) == MOVE_FLY_LOW)
1872 { 1857 {
1873 new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); 1858 new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way.");
1874 return 0; 1859 return 0;
1875 } 1860 }
1881 return 0; 1866 return 0;
1882 } 1867 }
1883 1868
1884 left = arrow; /* these are arrows left to the player */ 1869 left = arrow; /* these are arrows left to the player */
1885 arrow = get_split_ob (arrow, 1); 1870 arrow = get_split_ob (arrow, 1);
1886 if (arrow == NULL) 1871 if (!arrow)
1887 { 1872 {
1888 new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); 1873 new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race);
1889 return 0; 1874 return 0;
1890 } 1875 }
1876
1891 arrow->set_owner (op); 1877 arrow->set_owner (op);
1892 arrow->skill = bow->skill; 1878 arrow->skill = bow->skill;
1893 1879
1894 arrow->direction = dir; 1880 arrow->direction = dir;
1895 arrow->x = sx; 1881 arrow->x = sx;
1904 SET_ANIMATION (arrow, arrow->direction); 1890 SET_ANIMATION (arrow, arrow->direction);
1905 arrow->stats.sp = arrow->stats.wc; /* save original wc and dam */ 1891 arrow->stats.sp = arrow->stats.wc; /* save original wc and dam */
1906 arrow->stats.hp = arrow->stats.dam; 1892 arrow->stats.hp = arrow->stats.dam;
1907 arrow->stats.grace = arrow->attacktype; 1893 arrow->stats.grace = arrow->attacktype;
1908 if (arrow->slaying != NULL) 1894 if (arrow->slaying != NULL)
1909 arrow->spellarg = strdup_local (arrow->slaying); 1895 arrow->spellarg = strdup (arrow->slaying);
1910 1896
1911 /* Note that this was different for monsters - they got their level 1897 /* Note that this was different for monsters - they got their level
1912 * added to the damage. I think the strength bonus is more proper. 1898 * added to the damage. I think the strength bonus is more proper.
1913 */ 1899 */
1914 1900
1938 } 1924 }
1939 1925
1940 if (arrow->attacktype == AT_PHYSICAL) 1926 if (arrow->attacktype == AT_PHYSICAL)
1941 arrow->attacktype |= bow->attacktype; 1927 arrow->attacktype |= bow->attacktype;
1942 1928
1943 if (bow->slaying != NULL) 1929 if (bow->slaying)
1944 arrow->slaying = bow->slaying; 1930 arrow->slaying = bow->slaying;
1945 1931
1946 arrow->map = m; 1932 arrow->map = m;
1947 arrow->move_type = MOVE_FLY_LOW; 1933 arrow->move_type = MOVE_FLY_LOW;
1948 arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; 1934 arrow->move_on = MOVE_FLY_LOW | MOVE_WALK;
2064 CLEAR_FLAG (item, FLAG_ANIMATE); 2050 CLEAR_FLAG (item, FLAG_ANIMATE);
2065 item->face = item->arch->clone.face; 2051 item->face = item->arch->clone.face;
2066 item->speed = 0; 2052 item->speed = 0;
2067 update_ob_speed (item); 2053 update_ob_speed (item);
2068 } 2054 }
2069 if ((tmp = is_player_inv (item))) 2055 if ((tmp = item->in_player ()))
2070 esrv_update_item (UPD_ANIM, tmp, item); 2056 esrv_update_item (UPD_ANIM, tmp, item);
2071 } 2057 }
2072 } 2058 }
2073 else if (item->type == ROD || item->type == HORN) 2059 else if (item->type == ROD || item->type == HORN)
2074 { 2060 {
2224 * 0 otherwise 2210 * 0 otherwise
2225 */ 2211 */
2226static int 2212static int
2227player_attack_door (object *op, object *door) 2213player_attack_door (object *op, object *door)
2228{ 2214{
2229
2230 /* If its a door, try to find a use a key. If we do destroy the door, 2215 /* If its a door, try to find a use a key. If we do destroy the door,
2231 * might as well return immediately as there is nothing more to do - 2216 * might as well return immediately as there is nothing more to do -
2232 * otherwise, we fall through to the rest of the code. 2217 * otherwise, we fall through to the rest of the code.
2233 */ 2218 */
2234 object *key = find_key (op, op, door); 2219 object *key = find_key (op, op, door);
2272 * It should keep the code cleaner. 2257 * It should keep the code cleaner.
2273 * When this is called, the players direction has been updated 2258 * When this is called, the players direction has been updated
2274 * (taking into account confusion.) The player is also actually 2259 * (taking into account confusion.) The player is also actually
2275 * going to try and move (not fire weapons). 2260 * going to try and move (not fire weapons).
2276 */ 2261 */
2277
2278void 2262void
2279move_player_attack (object *op, int dir) 2263move_player_attack (object *op, int dir)
2280{ 2264{
2281 object *tmp, *mon; 2265 object *tmp, *mon;
2282 sint16 nx, ny; 2266 sint16 nx, ny;
2284 maptile *m; 2268 maptile *m;
2285 2269
2286 nx = freearr_x[dir] + op->x; 2270 nx = freearr_x[dir] + op->x;
2287 ny = freearr_y[dir] + op->y; 2271 ny = freearr_y[dir] + op->y;
2288 2272
2289 on_battleground = op_on_battleground (op, NULL, NULL); 2273 on_battleground = op_on_battleground (op, 0, 0);
2290 2274
2291 /* If braced, or can't move to the square, and it is not out of the 2275 /* If braced, or can't move to the square, and it is not out of the
2292 * map, attack it. Note order of if statement is important - don't 2276 * map, attack it. Note order of if statement is important - don't
2293 * want to be calling move_ob if braced, because move_ob will move the 2277 * want to be calling move_ob if braced, because move_ob will move the
2294 * player. This is a pretty nasty hack, because if we could 2278 * player. This is a pretty nasty hack, because if we could
2306 return; /* Don't think this should happen */ 2290 return; /* Don't think this should happen */
2307 } 2291 }
2308 else 2292 else
2309 m = op->map; 2293 m = op->map;
2310 2294
2311 if ((tmp = get_map_ob (m, nx, ny)) == NULL) 2295 if ((tmp = GET_MAP_OB (m, nx, ny)) == NULL)
2312 { 2296 {
2313 /* LOG(llevError,"player_move_attack: get_map_ob returns NULL, but player can not more there.\n"); */ 2297 /* LOG(llevError,"player_move_attack: GET_MAP_OB returns NULL, but player can not move there.\n"); */
2314 return; 2298 return;
2315 } 2299 }
2316 2300
2317 mon = NULL; 2301 mon = 0;
2318 /* Go through all the objects, and find ones of interest. Only stop if 2302 /* Go through all the objects, and find ones of interest. Only stop if
2319 * we find a monster - that is something we know we want to attack. 2303 * we find a monster - that is something we know we want to attack.
2320 * if its a door or barrel (can roll) see if there may be monsters 2304 * if its a door or barrel (can roll) see if there may be monsters
2321 * on the space 2305 * on the space
2322 */ 2306 */
2323 while (tmp != NULL) 2307 while (tmp)
2324 { 2308 {
2325 if (tmp == op) 2309 if (tmp == op)
2326 { 2310 {
2327 tmp = tmp->above; 2311 tmp = tmp->above;
2328 continue; 2312 continue;
2338 mon = tmp; 2322 mon = tmp;
2339 2323
2340 tmp = tmp->above; 2324 tmp = tmp->above;
2341 } 2325 }
2342 2326
2343 if (mon == NULL) /* This happens anytime the player tries to move */ 2327 if (!mon) /* This happens anytime the player tries to move */
2344 return; /* into a wall */ 2328 return; /* into a wall */
2345 2329
2346 if (mon->head != NULL) 2330 if (mon->head)
2347 mon = mon->head; 2331 mon = mon->head;
2348 2332
2349 if ((mon->type == DOOR && mon->stats.hp >= 0) || (mon->type == LOCKED_DOOR)) 2333 if ((mon->type == DOOR && mon->stats.hp >= 0) || (mon->type == LOCKED_DOOR))
2350 if (player_attack_door (op, mon)) 2334 if (player_attack_door (op, mon))
2351 return; 2335 return;
2388 * attack them either. 2372 * attack them either.
2389 */ 2373 */
2390 if ((mon->type == PLAYER || mon->enemy != op) && 2374 if ((mon->type == PLAYER || mon->enemy != op) &&
2391 (mon->type == PLAYER || QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)) && ( 2375 (mon->type == PLAYER || QUERY_FLAG (mon, FLAG_UNAGGRESSIVE) || QUERY_FLAG (mon, FLAG_FRIENDLY)) && (
2392#ifdef PROHIBIT_PLAYERKILL 2376#ifdef PROHIBIT_PLAYERKILL
2393 (op->contr->peaceful 2377 (op->contr->peaceful
2394 || (mon->type == PLAYER 2378 || (mon->type == PLAYER
2395 && mon->contr-> 2379 && mon->contr->
2396 peaceful)) && 2380 peaceful)) &&
2397#else 2381#else
2398 op->contr->peaceful && 2382 op->contr->peaceful &&
2399#endif 2383#endif
2400 !on_battleground)) 2384 !on_battleground))
2401 { 2385 {
2402 if (!op->contr->braced) 2386 if (!op->contr->braced)
2403 { 2387 {
2404 play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER); 2388 play_sound_map (op->map, op->x, op->y, SOUND_PUSH_PLAYER);
2405 (void) push_ob (mon, dir, op); 2389 (void) push_ob (mon, dir, op);
2406 } 2390 }
2407 else 2391 else
2408 {
2409 new_draw_info (0, 0, op, "You withhold your attack"); 2392 new_draw_info (0, 0, op, "You withhold your attack");
2410 } 2393
2411 if (op->contr->tmp_invis || op->hide) 2394 if (op->contr->tmp_invis || op->hide)
2412 make_visible (op); 2395 make_visible (op);
2413 } 2396 }
2414 2397
2415 /* If the object is a boulder or other rollable object, then 2398 /* If the object is a boulder or other rollable object, then
2443 op->speed_left += op->speed / op->contr->weapon_sp; 2426 op->speed_left += op->speed / op->contr->weapon_sp;
2444 2427
2445 op->contr->has_hit = 1; /* The last action was to hit, so use weapon_sp */ 2428 op->contr->has_hit = 1; /* The last action was to hit, so use weapon_sp */
2446 } 2429 }
2447 2430
2448 skill_attack (mon, op, 0, NULL, NULL); 2431 skill_attack (mon, op, 0, 0, 0);
2449 2432
2450 /* If attacking another player, that player gets automatic 2433 /* If attacking another player, that player gets automatic
2451 * hitback, and doesn't loose luck either. 2434 * hitback, and doesn't loose luck either.
2452 * Disable hitback on the battleground or if the target is 2435 * Disable hitback on the battleground or if the target is
2453 * the wiz. 2436 * the wiz.
2455 if (mon->type == PLAYER && mon->stats.hp >= 0 && !mon->contr->has_hit && !on_battleground && !QUERY_FLAG (mon, FLAG_WIZ)) 2438 if (mon->type == PLAYER && mon->stats.hp >= 0 && !mon->contr->has_hit && !on_battleground && !QUERY_FLAG (mon, FLAG_WIZ))
2456 { 2439 {
2457 short luck = mon->stats.luck; 2440 short luck = mon->stats.luck;
2458 2441
2459 mon->contr->has_hit = 1; 2442 mon->contr->has_hit = 1;
2460 skill_attack (op, mon, 0, NULL, NULL); 2443 skill_attack (op, mon, 0, 0, 0);
2461 mon->stats.luck = luck; 2444 mon->stats.luck = luck;
2462 } 2445 }
2446
2463 if (action_makes_visible (op)) 2447 if (action_makes_visible (op))
2464 make_visible (op); 2448 make_visible (op);
2465 } 2449 }
2466 } /* if player should attack something */ 2450 } /* if player should attack something */
2467} 2451}
2502 2486
2503 /* Add special check for newcs players and fire on - this way, the 2487 /* Add special check for newcs players and fire on - this way, the
2504 * server can handle repeat firing. 2488 * server can handle repeat firing.
2505 */ 2489 */
2506 if (op->contr->fire_on || (op->contr->run_on && pick != 0)) 2490 if (op->contr->fire_on || (op->contr->run_on && pick != 0))
2507 {
2508 op->direction = dir; 2491 op->direction = dir;
2509 }
2510 else 2492 else
2511 {
2512 op->direction = 0; 2493 op->direction = 0;
2513 } 2494
2514 /* Update how the player looks. Use the facing, so direction may 2495 /* Update how the player looks. Use the facing, so direction may
2515 * get reset to zero. This allows for full animation capabilities 2496 * get reset to zero. This allows for full animation capabilities
2516 * for players. 2497 * for players.
2517 */ 2498 */
2518 animate_object (op, op->facing); 2499 animate_object (op, op->facing);
2570 2551
2571 /* call this here - we also will call this in do_ericserver, but 2552 /* call this here - we also will call this in do_ericserver, but
2572 * the players time has been increased when doericserver has been 2553 * the players time has been increased when doericserver has been
2573 * called, so we recheck it here. 2554 * called, so we recheck it here.
2574 */ 2555 */
2575 HandleClient (&op->contr->socket, op->contr); 2556 //TODO: better than handling 8 commands, use some more intelligent rate-limiting
2557 for (int rep = 8; --rep && op->contr->socket->handle_command (); )
2558 ;
2559
2576 if (op->speed_left < 0) 2560 if (op->speed_left < 0)
2577 return 0; 2561 return 0;
2578 2562
2579 if (op->direction && (op->contr->run_on || op->contr->fire_on)) 2563 if (op->direction && (op->contr->run_on || op->contr->fire_on))
2580 { 2564 {
2589 if (op->speed_left > 0) 2573 if (op->speed_left > 0)
2590 return 1; 2574 return 1;
2591 else 2575 else
2592 return 0; 2576 return 0;
2593 } 2577 }
2578
2594 return 0; 2579 return 0;
2595} 2580}
2596 2581
2597int 2582int
2598save_life (object *op) 2583save_life (object *op)
2599{ 2584{
2600 object *tmp;
2601
2602 if (!QUERY_FLAG (op, FLAG_LIFESAVE)) 2585 if (!QUERY_FLAG (op, FLAG_LIFESAVE))
2603 return 0; 2586 return 0;
2604 2587
2605 for (tmp = op->inv; tmp != NULL; tmp = tmp->below) 2588 for (object *tmp = op->inv; tmp; tmp = tmp->below)
2606 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE)) 2589 if (QUERY_FLAG (tmp, FLAG_APPLIED) && QUERY_FLAG (tmp, FLAG_LIFESAVE))
2607 { 2590 {
2608 play_sound_map (op->map, op->x, op->y, SOUND_OB_EVAPORATE); 2591 play_sound_map (op->map, op->x, op->y, SOUND_OB_EVAPORATE);
2609 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); 2592 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp));
2610 2593
2621 op->stats.food = 999; 2604 op->stats.food = 999;
2622 2605
2623 fix_player (op); 2606 fix_player (op);
2624 return 1; 2607 return 1;
2625 } 2608 }
2609
2626 LOG (llevError, "Error: LIFESAVE set without applied object.\n"); 2610 LOG (llevError, "Error: LIFESAVE set without applied object.\n");
2627 CLEAR_FLAG (op, FLAG_LIFESAVE); 2611 CLEAR_FLAG (op, FLAG_LIFESAVE);
2628 enter_player_savebed (op); /* bring him home. */ 2612 enter_player_savebed (op); /* bring him home. */
2629 return 0; 2613 return 0;
2630} 2614}
2653 esrv_del_item (env->contr, op->count); 2637 esrv_del_item (env->contr, op->count);
2654 insert_ob_in_map (op, env->map, NULL, 0); 2638 insert_ob_in_map (op, env->map, NULL, 0);
2655 } 2639 }
2656 else if (op->inv) 2640 else if (op->inv)
2657 remove_unpaid_objects (op->inv, env); 2641 remove_unpaid_objects (op->inv, env);
2642
2658 op = next; 2643 op = next;
2659 } 2644 }
2660} 2645}
2661 2646
2662 2647
2677 strcpy (buf2, " R.I.P.\n\n"); 2662 strcpy (buf2, " R.I.P.\n\n");
2678 if (op->type == PLAYER) 2663 if (op->type == PLAYER)
2679 sprintf (buf, "%s the %s\n", &op->name, op->contr->title); 2664 sprintf (buf, "%s the %s\n", &op->name, op->contr->title);
2680 else 2665 else
2681 sprintf (buf, "%s\n", &op->name); 2666 sprintf (buf, "%s\n", &op->name);
2667
2682 strncat (buf2, " ", 20 - strlen (buf) / 2); 2668 strncat (buf2, " ", 20 - strlen (buf) / 2);
2683 strcat (buf2, buf); 2669 strcat (buf2, buf);
2684 if (op->type == PLAYER) 2670 if (op->type == PLAYER)
2685 sprintf (buf, "who was in level %d when killed\n", op->level); 2671 sprintf (buf, "who was in level %d when killed\n", op->level);
2686 else 2672 else
2687 sprintf (buf, "who was in level %d when died.\n\n", op->level); 2673 sprintf (buf, "who was in level %d when died.\n\n", op->level);
2674
2688 strncat (buf2, " ", 20 - strlen (buf) / 2); 2675 strncat (buf2, " ", 20 - strlen (buf) / 2);
2689 strcat (buf2, buf); 2676 strcat (buf2, buf);
2690 if (op->type == PLAYER) 2677 if (op->type == PLAYER)
2691 { 2678 {
2692 sprintf (buf, "by %s.\n\n", op->contr->killer); 2679 sprintf (buf, "by %s.\n\n", op->contr->killer);
2693 strncat (buf2, " ", 21 - strlen (buf) / 2); 2680 strncat (buf2, " ", 21 - strlen (buf) / 2);
2694 strcat (buf2, buf); 2681 strcat (buf2, buf);
2695 } 2682 }
2683
2696 strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now)); 2684 strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now));
2697 strncat (buf2, " ", 20 - strlen (buf) / 2); 2685 strncat (buf2, " ", 20 - strlen (buf) / 2);
2698 strcat (buf2, buf); 2686 strcat (buf2, buf);
2687
2699 return buf2; 2688 return buf2;
2700} 2689}
2701 2690
2702 2691
2703 2692
3234 * at his savebed location, and that can have long lasting 3223 * at his savebed location, and that can have long lasting
3235 * spell effects. So first see if there is a spell effect 3224 * spell effects. So first see if there is a spell effect
3236 * on the space that might harm the player. 3225 * on the space that might harm the player.
3237 */ 3226 */
3238 will_kill_again = 0; 3227 will_kill_again = 0;
3239 for (tmp = get_map_ob (op->map, op->x, op->y); tmp; tmp = tmp->above) 3228 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp; tmp = tmp->above)
3240 if (tmp->type == SPELL_EFFECT) 3229 if (tmp->type == SPELL_EFFECT)
3241 will_kill_again |= tmp->attacktype; 3230 will_kill_again |= tmp->attacktype;
3242 3231
3243 if (will_kill_again) 3232 if (will_kill_again)
3244 { 3233 {
3341 } 3330 }
3342 3331
3343 for (tmp = op->inv; tmp != NULL; tmp = next) 3332 for (tmp = op->inv; tmp != NULL; tmp = next)
3344 { 3333 {
3345 next = tmp->below; 3334 next = tmp->below;
3346 if (tmp->type == EXPERIENCE || tmp->invisible) 3335 if (tmp->invisible)
3347 continue; 3336 continue;
3348 tmp->remove (); 3337 tmp->remove ();
3349 tmp->x = op->x, tmp->y = op->y; 3338 tmp->x = op->x, tmp->y = op->y;
3350 if (tmp->type == CONTAINER) 3339 if (tmp->type == CONTAINER)
3351 { /* empty container to ground */ 3340 { /* empty container to ground */
3457 object *tmp = NULL; 3446 object *tmp = NULL;
3458 3447
3459 if (QUERY_FLAG (&op->arch->clone, FLAG_UNDEAD)) 3448 if (QUERY_FLAG (&op->arch->clone, FLAG_UNDEAD))
3460 return 1; 3449 return 1;
3461 3450
3462 if (op->type == PLAYER)
3463 for (tmp = op->inv; tmp; tmp = tmp->below)
3464 if (tmp->type == EXPERIENCE && tmp->stats.Wis)
3465 if (QUERY_FLAG (tmp, FLAG_UNDEAD))
3466 return 1;
3467 return 0; 3451 return 0;
3468} 3452}
3469 3453
3470/* look at the surrounding terrain to determine 3454/* look at the surrounding terrain to determine
3471 * the hideability of this object. Positive levels 3455 * the hideability of this object. Positive levels
3586 if (mflags & P_OUT_OF_MAP) 3570 if (mflags & P_OUT_OF_MAP)
3587 continue; 3571 continue;
3588 if (OB_TYPE_MOVE_BLOCK (who, GET_MAP_MOVE_BLOCK (m, x, y))) 3572 if (OB_TYPE_MOVE_BLOCK (who, GET_MAP_MOVE_BLOCK (m, x, y)))
3589 continue; 3573 continue;
3590 3574
3591 for (tmp = get_map_ob (m, x, y); tmp; tmp = tmp->above) 3575 for (tmp = GET_MAP_OB (m, x, y); tmp; tmp = tmp->above)
3592 { 3576 {
3593 if ((player ||friendly) &&QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE)) 3577 if ((player ||friendly) &&QUERY_FLAG (tmp, FLAG_MONSTER) && !QUERY_FLAG (tmp, FLAG_UNAGGRESSIVE))
3594 return 1; 3578 return 1;
3595 else if (tmp->type == PLAYER) 3579 else if (tmp->type == PLAYER)
3596 { 3580 {
3650 3634
3651 /* only the viewable area the player sees is updated by LOS 3635 /* only the viewable area the player sees is updated by LOS
3652 * code, so we need to restrict ourselves to that range of values 3636 * code, so we need to restrict ourselves to that range of values
3653 * for any meaningful values. 3637 * for any meaningful values.
3654 */ 3638 */
3655 if (FABS (dx) <= (pl->contr->socket.mapx / 2) && 3639 if (FABS (dx) <= (pl->contr->socket->mapx / 2) &&
3656 FABS (dy) <= (pl->contr->socket.mapy / 2) && 3640 FABS (dy) <= (pl->contr->socket->mapy / 2) &&
3657 !pl->contr->blocked_los[dx + (pl->contr->socket.mapx / 2)][dy + (pl->contr->socket.mapy / 2)]) 3641 !pl->contr->blocked_los[dx + (pl->contr->socket->mapx / 2)][dy + (pl->contr->socket->mapy / 2)])
3658 return 1; 3642 return 1;
3659 op = op->more; 3643 op = op->more;
3660 } 3644 }
3661 return 0; 3645 return 0;
3662} 3646}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines