Zesstra | 715ec20 | 2025-07-09 22:18:31 +0200 | [diff] [blame^] | 1 | DEPRECATED |
| 2 | SYNOPSIS |
| 3 | int transfer(object item, object dest) |
| 4 | |
| 5 | DESCRIPTION |
| 6 | This efun is for backward compatibility only. It is only |
| 7 | available in compat mode. |
| 8 | |
| 9 | Move the object "item" to the object "dest". All kinds of |
| 10 | tests are done, and a number is returned specifying the |
| 11 | result: |
| 12 | |
| 13 | 0: Success. |
| 14 | 1: To heavy for destination. |
| 15 | 2: Can't be dropped. |
| 16 | 3: Can't take it out of it's container. |
| 17 | 4: The object can't be inserted into bags etc. |
| 18 | 5: The destination doesn't allow insertions of objects. |
| 19 | 6: The object can't be picked up. |
| 20 | |
| 21 | If an object is transfered to a newly created object, make |
| 22 | sure that the new object first is transfered to it's |
| 23 | destination. |
| 24 | |
| 25 | The efun calls add_weight(), drop(), get(), prevent_insert(), |
| 26 | add_weight(), and can_put_and_get() where needed. |
| 27 | |
| 28 | REPLACEMENT |
| 29 | This efun can easily be replaced with a simul_efun: |
| 30 | |
| 31 | /*--------------------------------------------------------*/ |
| 32 | int transfer(object item, object dest) |
| 33 | { |
| 34 | int weight; |
| 35 | object from; |
| 36 | |
| 37 | efun::set_this_object(previous_object()); |
| 38 | |
| 39 | weight = item->query_weight(); |
| 40 | if (!item) |
| 41 | return 3; |
| 42 | |
| 43 | from = environment(item); |
| 44 | if (from) |
| 45 | { |
| 46 | /* |
| 47 | * If the original place of the object is a living object, |
| 48 | * then we must call drop() to check that the object can be |
| 49 | * dropped. |
| 50 | */ |
| 51 | if (living(from)) |
| 52 | { |
| 53 | if (item->drop() || !item) |
| 54 | return 2; |
| 55 | } |
| 56 | /* |
| 57 | * If 'from' is not a room and not a player, check that we may |
| 58 | * remove things out of it. |
| 59 | */ |
| 60 | else if (environment(from)) |
| 61 | { |
| 62 | if (!from->can_put_and_get() || !from) |
| 63 | return 3; |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | /* |
| 68 | * If the destination is not a room, and not a player, |
| 69 | * Then we must test 'prevent_insert', and 'can_put_and_get'. |
| 70 | */ |
| 71 | if (environment(dest) && !living(dest)) |
| 72 | { |
| 73 | if (item->prevent_insert()) |
| 74 | return 4; |
| 75 | if (!dest->can_put_and_get() || !dest) |
| 76 | return 5; |
| 77 | } |
| 78 | |
| 79 | if (living(dest)) |
| 80 | { |
| 81 | if (!item->get() || !item) |
| 82 | return 6; |
| 83 | } |
| 84 | |
| 85 | /* |
| 86 | * If it is not a room, correct the total weight in the |
| 87 | * destination. |
| 88 | */ |
| 89 | if (environment(dest) && weight) |
| 90 | { |
| 91 | if (!dest->add_weight(weight) || !dest) |
| 92 | return 1; |
| 93 | } |
| 94 | |
| 95 | /* |
| 96 | * If it is not a room, correct the weight in the 'from' object. |
| 97 | */ |
| 98 | if (from && environment(from) && weight) |
| 99 | { |
| 100 | from->add_weight(-weight); |
| 101 | } |
| 102 | |
| 103 | move_object(item, dest); |
| 104 | |
| 105 | return 0; |
| 106 | } |
| 107 | /*--------------------------------------------------------*/ |
| 108 | |
| 109 | |
| 110 | HISTORY |
| 111 | Deprecated in LDMud 3.3; available only when compiled with |
| 112 | USE_DEPRECATED. |
| 113 | |
| 114 | SEE ALSO |
| 115 | move_object(E), drop(A), get(A), prevent_insert(A), |
| 116 | can_put_and_get(A), add_weight(A) |