… | |
… | |
329 | player *p; |
329 | player *p; |
330 | |
330 | |
331 | p = get_player (NULL); |
331 | p = get_player (NULL); |
332 | p->socket = *ns; |
332 | p->socket = *ns; |
333 | p->socket.faces_sent = (uint8 *) malloc (p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); |
333 | p->socket.faces_sent = (uint8 *) malloc (p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); |
|
|
334 | |
334 | if (p->socket.faces_sent == NULL) |
335 | if (p->socket.faces_sent == NULL) |
335 | fatal (OUT_OF_MEMORY); |
336 | fatal (OUT_OF_MEMORY); |
|
|
337 | |
336 | memcpy (p->socket.faces_sent, ns->faces_sent, p->socket.faces_sent_len * sizeof (*p->socket.faces_sent)); |
338 | 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. |
339 | /* 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 |
340 | * Note that this can result in a client reset if there is partial data |
339 | * on the uncoming socket. |
341 | * on the uncoming socket. |
340 | */ |
342 | */ |
… | |
… | |
345 | add_friendly_object (p->ob); |
347 | add_friendly_object (p->ob); |
346 | send_rules (p->ob); |
348 | send_rules (p->ob); |
347 | send_news (p->ob); |
349 | send_news (p->ob); |
348 | display_motd (p->ob); |
350 | display_motd (p->ob); |
349 | get_name (p->ob); |
351 | get_name (p->ob); |
|
|
352 | |
350 | return 0; |
353 | return 0; |
351 | } |
354 | } |
352 | |
355 | |
353 | /* |
356 | /* |
354 | * get_player_archetype() return next player archetype from archetype |
357 | * get_player_archetype() return next player archetype from archetype |
… | |
… | |
489 | path_to_player (object *mon, object *pl, unsigned mindiff) |
492 | path_to_player (object *mon, object *pl, unsigned mindiff) |
490 | { |
493 | { |
491 | rv_vector rv; |
494 | rv_vector rv; |
492 | sint16 x, y; |
495 | sint16 x, y; |
493 | int lastx, lasty, dir, i, diff, firstdir = 0, lastdir, max = MAX_SPACES, mflags, blocked; |
496 | int lastx, lasty, dir, i, diff, firstdir = 0, lastdir, max = MAX_SPACES, mflags, blocked; |
494 | mapstruct *m, *lastmap; |
497 | maptile *m, *lastmap; |
495 | |
498 | |
496 | get_rangevector (mon, pl, &rv, 0); |
499 | get_rangevector (mon, pl, &rv, 0); |
497 | |
500 | |
498 | if (rv.distance < mindiff) |
501 | if (rv.distance < mindiff) |
499 | return 0; |
502 | return 0; |
… | |
… | |
1180 | if (settings.set_title == TRUE) |
1183 | if (settings.set_title == TRUE) |
1181 | op->contr->own_title[0] = '\0'; |
1184 | op->contr->own_title[0] = '\0'; |
1182 | |
1185 | |
1183 | if (!QUERY_FLAG (op, FLAG_WAS_WIZ)) |
1186 | if (!QUERY_FLAG (op, FLAG_WAS_WIZ)) |
1184 | { |
1187 | { |
1185 | mapstruct *mp, *next; |
1188 | maptile *mp, *next; |
1186 | |
1189 | |
1187 | /* We need to hunt for any per player unique maps in memory and |
1190 | /* 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, |
1191 | * 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 |
1192 | * so that players named 'Ab' won't match against players 'Abe' pathname |
1190 | */ |
1193 | */ |
… | |
… | |
1264 | */ |
1267 | */ |
1265 | int |
1268 | int |
1266 | check_pick (object *op) |
1269 | check_pick (object *op) |
1267 | { |
1270 | { |
1268 | object *tmp, *next; |
1271 | object *tmp, *next; |
1269 | tag_t next_tag = 0, op_tag; |
|
|
1270 | int stop = 0; |
1272 | int stop = 0; |
1271 | int j, k, wvratio; |
1273 | int j, k, wvratio; |
1272 | char putstring[128], tmpstr[16]; |
1274 | char putstring[128], tmpstr[16]; |
1273 | |
1275 | |
1274 | |
|
|
1275 | /* if you're flying, you cna't pick up anything */ |
1276 | /* if you're flying, you cna't pick up anything */ |
1276 | if (op->move_type & MOVE_FLYING) |
1277 | if (op->move_type & MOVE_FLYING) |
1277 | return 1; |
1278 | return 1; |
1278 | |
1279 | |
1279 | op_tag = op->count; |
|
|
1280 | |
|
|
1281 | next = op->below; |
1280 | next = op->below; |
1282 | if (next) |
|
|
1283 | next_tag = next->count; |
|
|
1284 | |
1281 | |
1285 | /* loop while there are items on the floor that are not marked as |
1282 | /* loop while there are items on the floor that are not marked as |
1286 | * destroyed */ |
1283 | * destroyed */ |
1287 | while (next && !was_destroyed (next, next_tag)) |
1284 | while (next && !next->destroyed ()) |
1288 | { |
1285 | { |
1289 | tmp = next; |
1286 | tmp = next; |
1290 | next = tmp->below; |
1287 | next = tmp->below; |
1291 | if (next) |
|
|
1292 | next_tag = next->count; |
|
|
1293 | |
1288 | |
1294 | if (was_destroyed (op, op_tag)) |
1289 | if (op->destroyed ()) |
1295 | return 0; |
1290 | return 0; |
1296 | |
1291 | |
1297 | if (!can_pick (op, tmp)) |
1292 | if (!can_pick (op, tmp)) |
1298 | continue; |
1293 | continue; |
1299 | |
1294 | |
… | |
… | |
1770 | |
1765 | |
1771 | object * |
1766 | object * |
1772 | pick_arrow_target (object *op, const char *type, int dir) |
1767 | pick_arrow_target (object *op, const char *type, int dir) |
1773 | { |
1768 | { |
1774 | object *tmp = NULL; |
1769 | object *tmp = NULL; |
1775 | mapstruct *m; |
1770 | maptile *m; |
1776 | int i, mflags, found, number; |
1771 | int i, mflags, found, number; |
1777 | sint16 x, y; |
1772 | sint16 x, y; |
1778 | |
1773 | |
1779 | if (op->map == NULL) |
1774 | if (op->map == NULL) |
1780 | return find_arrow (op, type); |
1775 | return find_arrow (op, type); |
… | |
… | |
1840 | */ |
1835 | */ |
1841 | int |
1836 | int |
1842 | fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy) |
1837 | fire_bow (object *op, object *part, object *arrow, int dir, int wc_mod, sint16 sx, sint16 sy) |
1843 | { |
1838 | { |
1844 | object *left, *bow; |
1839 | object *left, *bow; |
1845 | tag_t left_tag, tag; |
|
|
1846 | int bowspeed, mflags; |
1840 | int bowspeed, mflags; |
1847 | mapstruct *m; |
1841 | maptile *m; |
1848 | |
1842 | |
1849 | if (!dir) |
1843 | if (!dir) |
1850 | { |
1844 | { |
1851 | new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); |
1845 | new_draw_info (NDI_UNIQUE, 0, op, "You can't shoot yourself!"); |
1852 | return 0; |
1846 | return 0; |
… | |
… | |
1912 | free_object (arrow); |
1906 | free_object (arrow); |
1913 | return 0; |
1907 | return 0; |
1914 | } |
1908 | } |
1915 | |
1909 | |
1916 | left = arrow; /* these are arrows left to the player */ |
1910 | left = arrow; /* these are arrows left to the player */ |
1917 | left_tag = left->count; |
|
|
1918 | arrow = get_split_ob (arrow, 1); |
1911 | arrow = get_split_ob (arrow, 1); |
1919 | if (arrow == NULL) |
1912 | if (arrow == NULL) |
1920 | { |
1913 | { |
1921 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1914 | new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); |
1922 | return 0; |
1915 | return 0; |
… | |
… | |
1965 | arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level; |
1958 | arrow->level = op->chosen_skill ? op->chosen_skill->level : op->level; |
1966 | } |
1959 | } |
1967 | else |
1960 | else |
1968 | { |
1961 | { |
1969 | arrow->stats.wc = op->stats.wc - bow->magic - arrow->magic - arrow->stats.wc + wc_mod; |
1962 | arrow->stats.wc = op->stats.wc - bow->magic - arrow->magic - arrow->stats.wc + wc_mod; |
1970 | |
|
|
1971 | arrow->level = op->level; |
1963 | arrow->level = op->level; |
1972 | } |
1964 | } |
|
|
1965 | |
1973 | if (arrow->attacktype == AT_PHYSICAL) |
1966 | if (arrow->attacktype == AT_PHYSICAL) |
1974 | arrow->attacktype |= bow->attacktype; |
1967 | arrow->attacktype |= bow->attacktype; |
|
|
1968 | |
1975 | if (bow->slaying != NULL) |
1969 | if (bow->slaying != NULL) |
1976 | arrow->slaying = bow->slaying; |
1970 | arrow->slaying = bow->slaying; |
1977 | |
1971 | |
1978 | arrow->map = m; |
1972 | arrow->map = m; |
1979 | arrow->move_type = MOVE_FLY_LOW; |
1973 | arrow->move_type = MOVE_FLY_LOW; |
1980 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
1974 | arrow->move_on = MOVE_FLY_LOW | MOVE_WALK; |
1981 | |
1975 | |
1982 | play_sound_map (op->map, op->x, op->y, SOUND_FIRE_ARROW); |
1976 | 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); |
1977 | insert_ob_in_map (arrow, m, op, 0); |
1985 | |
1978 | |
1986 | if (!was_destroyed (arrow, tag)) |
1979 | if (!arrow->destroyed ()) |
1987 | move_arrow (arrow); |
1980 | move_arrow (arrow); |
1988 | |
1981 | |
1989 | if (op->type == PLAYER) |
1982 | if (op->type == PLAYER) |
1990 | { |
1983 | { |
1991 | if (was_destroyed (left, left_tag)) |
1984 | if (left->destroyed ()) |
1992 | esrv_del_item (op->contr, left_tag); |
1985 | esrv_del_item (op->contr, left->count); |
1993 | else |
1986 | else |
1994 | esrv_send_item (op, left); |
1987 | esrv_send_item (op, left); |
1995 | } |
1988 | } |
|
|
1989 | |
1996 | return 1; |
1990 | return 1; |
1997 | } |
1991 | } |
1998 | |
1992 | |
1999 | /* Special fire code for players - this takes into |
1993 | /* Special fire code for players - this takes into |
2000 | * account the special fire modes players can have |
1994 | * account the special fire modes players can have |
… | |
… | |
2312 | move_player_attack (object *op, int dir) |
2306 | move_player_attack (object *op, int dir) |
2313 | { |
2307 | { |
2314 | object *tmp, *mon; |
2308 | object *tmp, *mon; |
2315 | sint16 nx, ny; |
2309 | sint16 nx, ny; |
2316 | int on_battleground; |
2310 | int on_battleground; |
2317 | mapstruct *m; |
2311 | maptile *m; |
2318 | |
2312 | |
2319 | nx = freearr_x[dir] + op->x; |
2313 | nx = freearr_x[dir] + op->x; |
2320 | ny = freearr_y[dir] + op->y; |
2314 | ny = freearr_y[dir] + op->y; |
2321 | |
2315 | |
2322 | on_battleground = op_on_battleground (op, NULL, NULL); |
2316 | on_battleground = op_on_battleground (op, NULL, NULL); |
… | |
… | |
2952 | { |
2946 | { |
2953 | char buf[MAX_BUF]; |
2947 | char buf[MAX_BUF]; |
2954 | int x, y; |
2948 | int x, y; |
2955 | |
2949 | |
2956 | //int i; |
2950 | //int i; |
2957 | mapstruct *map; /* this is for resurrection */ |
2951 | maptile *map; /* this is for resurrection */ |
2958 | |
2952 | |
2959 | /* int z; |
2953 | /* int z; |
2960 | int num_stats_lose; |
2954 | int num_stats_lose; |
2961 | int lost_a_stat; |
2955 | int lost_a_stat; |
2962 | int lose_this_stat; |
2956 | int lose_this_stat; |
… | |
… | |
3596 | int |
3590 | int |
3597 | stand_near_hostile (object *who) |
3591 | stand_near_hostile (object *who) |
3598 | { |
3592 | { |
3599 | object *tmp = NULL; |
3593 | object *tmp = NULL; |
3600 | int i, friendly = 0, player = 0, mflags; |
3594 | int i, friendly = 0, player = 0, mflags; |
3601 | mapstruct *m; |
3595 | maptile *m; |
3602 | sint16 x, y; |
3596 | sint16 x, y; |
3603 | |
3597 | |
3604 | if (!who) |
3598 | if (!who) |
3605 | return 0; |
3599 | return 0; |
3606 | |
3600 | |