… | |
… | |
439 | |
439 | |
440 | char * |
440 | char * |
441 | object::as_string () |
441 | object::as_string () |
442 | { |
442 | { |
443 | return dump_object (this); |
443 | return dump_object (this); |
444 | } |
|
|
445 | |
|
|
446 | /* |
|
|
447 | * get_nearest_part(multi-object, object 2) returns the part of the |
|
|
448 | * multi-object 1 which is closest to the second object. |
|
|
449 | * If it's not a multi-object, it is returned. |
|
|
450 | */ |
|
|
451 | static object * |
|
|
452 | get_nearest_part (object *op, const object *pl) |
|
|
453 | { |
|
|
454 | object *tmp, *closest; |
|
|
455 | int last_dist, i; |
|
|
456 | |
|
|
457 | if (!op->more) |
|
|
458 | return op; |
|
|
459 | |
|
|
460 | for (last_dist = distance (op, pl), closest = op, tmp = op->more; |
|
|
461 | tmp; |
|
|
462 | tmp = tmp->more) |
|
|
463 | if ((i = distance (tmp, pl)) < last_dist) |
|
|
464 | closest = tmp, last_dist = i; |
|
|
465 | |
|
|
466 | return closest; |
|
|
467 | } |
444 | } |
468 | |
445 | |
469 | /* |
446 | /* |
470 | * Returns the object which has the count-variable equal to the argument. |
447 | * Returns the object which has the count-variable equal to the argument. |
471 | * VERRRY slow. |
448 | * VERRRY slow. |