… | |
… | |
284 | } |
284 | } |
285 | |
285 | |
286 | void |
286 | void |
287 | player::disconnect () |
287 | player::disconnect () |
288 | { |
288 | { |
|
|
289 | if (ob) |
|
|
290 | { |
|
|
291 | ob->close_container (); //TODO: client-specific |
|
|
292 | ob->drop_unpaid_items (); |
|
|
293 | } |
|
|
294 | |
289 | if (ns) |
295 | if (ns) |
290 | { |
296 | { |
291 | if (active) |
297 | if (active) |
292 | INVOKE_PLAYER (LOGOUT, this, ARG_INT (0)); |
298 | INVOKE_PLAYER (LOGOUT, this, ARG_INT (0)); |
293 | |
299 | |
294 | INVOKE_PLAYER (DISCONNECT, this); |
300 | INVOKE_PLAYER (DISCONNECT, this); |
295 | |
301 | |
296 | ns->reset_stats (); |
302 | ns->reset_stats (); |
297 | ns->pl = 0; |
303 | ns->pl = 0; |
298 | ns = 0; |
304 | ns = 0; |
299 | } |
|
|
300 | |
|
|
301 | if (ob) |
|
|
302 | { |
|
|
303 | ob->close_container (); //TODO: client-specific |
|
|
304 | ob->drop_unpaid_items (); |
|
|
305 | } |
305 | } |
306 | |
306 | |
307 | observe = ob; |
307 | observe = ob; |
308 | |
308 | |
309 | deactivate (); |
309 | deactivate (); |
… | |
… | |
425 | unsigned lastdist; |
425 | unsigned lastdist; |
426 | rv_vector rv; |
426 | rv_vector rv; |
427 | |
427 | |
428 | for (ol = first_friendly_object, lastdist = 1000; ol; ol = ol->next) |
428 | for (ol = first_friendly_object, lastdist = 1000; ol; ol = ol->next) |
429 | { |
429 | { |
430 | /* We should not find free objects on this friendly list, but it |
|
|
431 | * does periodically happen. Given that, lets deal with it. |
|
|
432 | * While unlikely, it is possible the next object on the friendly |
|
|
433 | * list is also free, so encapsulate this in a while loop. |
|
|
434 | */ |
|
|
435 | while (QUERY_FLAG (ol->ob, FLAG_FREED) || !QUERY_FLAG (ol->ob, FLAG_FRIENDLY)) |
|
|
436 | { |
|
|
437 | object *tmp = ol->ob; |
|
|
438 | |
|
|
439 | /* Can't do much more other than log the fact, because the object |
|
|
440 | * itself will have been cleared. |
|
|
441 | */ |
|
|
442 | LOG (llevDebug, "get_nearest_player: Found free/non friendly object '%s' on friendly list\n", |
|
|
443 | tmp->debug_desc ()); |
|
|
444 | ol = ol->next; |
|
|
445 | remove_friendly_object (tmp); |
|
|
446 | if (!ol) |
|
|
447 | return op; |
|
|
448 | } |
|
|
449 | |
|
|
450 | /* Remove special check for player from this. First, it looks to cause |
|
|
451 | * some crashes (ol->ob->contr not set properly?), but secondly, a more |
|
|
452 | * complicated method of state checking would be needed in any case - |
|
|
453 | * as it was, a clever player could type quit, and the function would |
|
|
454 | * skip them over while waiting for confirmation. Remove |
|
|
455 | * on_same_map check, as can_detect_enemy also does this |
|
|
456 | */ |
|
|
457 | if (!can_detect_enemy (mon, ol->ob, &rv)) |
430 | if (!can_detect_enemy (mon, ol->ob, &rv)) |
458 | continue; |
431 | continue; |
459 | |
432 | |
460 | if (lastdist > rv.distance) |
433 | if (lastdist > rv.distance) |
461 | { |
434 | { |