… | |
… | |
161 | set_first_map (object *op) |
161 | set_first_map (object *op) |
162 | { |
162 | { |
163 | strcpy (op->contr->maplevel, first_map_path); |
163 | strcpy (op->contr->maplevel, first_map_path); |
164 | op->x = -1; |
164 | op->x = -1; |
165 | op->y = -1; |
165 | op->y = -1; |
166 | enter_exit (op, 0); |
166 | op->enter_exit (0); |
167 | } |
167 | } |
168 | |
168 | |
169 | // connect the player with a specific client |
169 | // connect the player with a specific client |
170 | // also changed, rationalises, and fixes some incorrect settings |
170 | // also changed, rationalises, and fixes some incorrect settings |
171 | void |
171 | void |
… | |
… | |
191 | |
191 | |
192 | ob->carrying = sum_weight (ob); |
192 | ob->carrying = sum_weight (ob); |
193 | link_player_skills (ob); |
193 | link_player_skills (ob); |
194 | |
194 | |
195 | CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); |
195 | CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); |
196 | ob->set_speed (ob->speed); |
|
|
197 | |
196 | |
198 | assign (title, ob->arch->clone.name); |
197 | assign (title, ob->arch->clone.name); |
199 | |
198 | |
200 | /* can_use_shield is a new flag. However, the can_use.. seems to largely come |
199 | /* can_use_shield is a new flag. However, the can_use.. seems to largely come |
201 | * from the class, and not race. I don't see any way to get the class information |
200 | * from the class, and not race. I don't see any way to get the class information |
… | |
… | |
238 | ns->floorbox_update (); |
237 | ns->floorbox_update (); |
239 | |
238 | |
240 | esrv_send_inventory (ob, ob); |
239 | esrv_send_inventory (ob, ob); |
241 | esrv_add_spells (this, 0); |
240 | esrv_add_spells (this, 0); |
242 | |
241 | |
243 | enter_exit (ob, 0); |
242 | ob->enter_exit (0); |
|
|
243 | ob->activate (1); |
244 | |
244 | |
245 | send_rules (ob); |
245 | send_rules (ob); |
246 | send_news (ob); |
246 | send_news (ob); |
247 | display_motd (ob); |
247 | display_motd (ob); |
248 | INVOKE_PLAYER (LOGIN, this); |
248 | INVOKE_PLAYER (LOGIN, this); |
249 | } |
249 | } |
250 | |
250 | |
251 | void |
251 | void |
252 | player::disconnect () |
252 | player::disconnect () |
253 | { |
253 | { |
|
|
254 | if (ob) |
|
|
255 | ob->deactivate (1); |
|
|
256 | |
254 | //TODO: don't be so harsh and destroy :) |
257 | //TODO: don't be so harsh and destroy :) |
255 | if (ns) |
258 | if (ns) |
256 | { |
259 | { |
257 | if (enable_save) |
260 | if (enable_save) |
258 | INVOKE_PLAYER (LOGOUT, this, ARG_INT (0)); |
261 | INVOKE_PLAYER (LOGOUT, this, ARG_INT (0)); |
… | |
… | |
920 | snprintf (mapname, MAX_BUF - 1, "%s/%s", first_map_ext_path, &op->arch->name); |
923 | snprintf (mapname, MAX_BUF - 1, "%s/%s", first_map_ext_path, &op->arch->name); |
921 | tmp = object::create (); |
924 | tmp = object::create (); |
922 | EXIT_PATH (tmp) = mapname; |
925 | EXIT_PATH (tmp) = mapname; |
923 | EXIT_X (tmp) = op->x; |
926 | EXIT_X (tmp) = op->x; |
924 | EXIT_Y (tmp) = op->y; |
927 | EXIT_Y (tmp) = op->y; |
925 | enter_exit (op, tmp); /* we don't really care if it succeeded; |
928 | op->enter_exit (tmp); /* we don't really care if it succeeded; |
926 | * if the map isn't there, then stay on the |
929 | * if the map isn't there, then stay on the |
927 | * default initial map */ |
930 | * default initial map */ |
928 | tmp->destroy (); |
931 | tmp->destroy (); |
929 | } |
932 | } |
930 | else |
933 | else |
… | |
… | |
987 | INVOKE_PLAYER (QUIT, op->contr); |
990 | INVOKE_PLAYER (QUIT, op->contr); |
988 | |
991 | |
989 | op->contr->enable_save = false; |
992 | op->contr->enable_save = false; |
990 | |
993 | |
991 | terminate_all_pets (op); |
994 | terminate_all_pets (op); |
992 | leave_map (op); |
995 | op->remove (); |
993 | op->direction = 0; |
996 | op->direction = 0; |
994 | new_draw_info_format (NDI_UNIQUE | NDI_ALL, 5, NULL, "%s quits the game.", &op->name); |
997 | new_draw_info_format (NDI_UNIQUE | NDI_ALL, 5, NULL, "%s quits the game.", &op->name); |
995 | |
998 | |
996 | strcpy (op->contr->killer, "quit"); |
999 | strcpy (op->contr->killer, "quit"); |
997 | check_score (op); |
1000 | check_score (op); |
998 | op->contr->party = 0; |
1001 | op->contr->party = 0; |
999 | op->contr->own_title[0] = '\0'; |
1002 | op->contr->own_title[0] = '\0'; |
1000 | |
|
|
1001 | object_ptr ob = op; |
|
|
1002 | |
|
|
1003 | /* We need to hunt for any per player unique maps in memory and |
|
|
1004 | * get rid of them. The trailing slash in the path is intentional, |
|
|
1005 | * so that players named 'Ab' won't match against players 'Abe' pathname |
|
|
1006 | */ |
|
|
1007 | char buf[MAX_BUF]; |
|
|
1008 | sprintf (buf, "%s/%s/%s/", settings.localdir, settings.playerdir, &op->name); |
|
|
1009 | |
|
|
1010 | for_all_maps (mp) |
|
|
1011 | if (!strncmp (mp->path, buf, strlen (buf))) |
|
|
1012 | delete_map (mp); |
|
|
1013 | |
|
|
1014 | delete_character (ob->name, 1); |
|
|
1015 | ob->contr->destroy (); |
1003 | op->contr->destroy (); |
1016 | |
1004 | |
1017 | return 1; |
1005 | return 1; |
1018 | } |
1006 | } |
1019 | |
1007 | |
1020 | void |
1008 | void |
… | |
… | |
1764 | } |
1752 | } |
1765 | else if (op->contr->bowtype >= bow_n && op->contr->bowtype <= bow_nw) |
1753 | else if (op->contr->bowtype >= bow_n && op->contr->bowtype <= bow_nw) |
1766 | { |
1754 | { |
1767 | if (!similar_direction (dir, op->contr->bowtype - bow_n + 1)) |
1755 | if (!similar_direction (dir, op->contr->bowtype - bow_n + 1)) |
1768 | wcmod = -1; |
1756 | wcmod = -1; |
|
|
1757 | |
1769 | ret = fire_bow (op, op, NULL, op->contr->bowtype - bow_n + 1, wcmod, op->x, op->y); |
1758 | ret = fire_bow (op, op, NULL, op->contr->bowtype - bow_n + 1, wcmod, op->x, op->y); |
1770 | } |
1759 | } |
1771 | else if (op->contr->bowtype == bow_threewide) |
1760 | else if (op->contr->bowtype == bow_threewide) |
1772 | { |
1761 | { |
1773 | ret = fire_bow (op, op, NULL, dir, 0, op->x, op->y); |
1762 | ret = fire_bow (op, op, NULL, dir, 0, op->x, op->y); |
… | |
… | |
3319 | if (pl->type != PLAYER) |
3308 | if (pl->type != PLAYER) |
3320 | { |
3309 | { |
3321 | LOG (llevError, "player_can_view() called for non-player object\n"); |
3310 | LOG (llevError, "player_can_view() called for non-player object\n"); |
3322 | return -1; |
3311 | return -1; |
3323 | } |
3312 | } |
|
|
3313 | |
3324 | if (!pl || !op) |
3314 | if (!pl || !op) |
3325 | return 0; |
3315 | return 0; |
3326 | |
3316 | |
3327 | if (op->head) |
|
|
3328 | { |
|
|
3329 | op = op->head; |
3317 | op = op->head_ (); |
3330 | } |
3318 | |
3331 | get_rangevector (pl, op, &rv, 0x1); |
3319 | get_rangevector (pl, op, &rv, 0x1); |
3332 | |
3320 | |
3333 | /* starting with the 'head' part, lets loop |
3321 | /* starting with the 'head' part, lets loop |
3334 | * through the object and find if it has any |
3322 | * through the object and find if it has any |
3335 | * part that is in the los array but isnt on |
3323 | * part that is in the los array but isnt on |