… | |
… | |
335 | |
335 | |
336 | // the player itself is always on a map, so we will find him here |
336 | // the player itself is always on a map, so we will find him here |
337 | // even if our inv is in a player. |
337 | // even if our inv is in a player. |
338 | if (envest->is_on_map ()) |
338 | if (envest->is_on_map ()) |
339 | if (object *pl = envest->ms ().player ()) |
339 | if (object *pl = envest->ms ().player ()) |
340 | if (pl->container == env) |
340 | if (pl->container_ () == env) |
341 | return pl; |
341 | return pl; |
342 | } |
342 | } |
343 | else |
343 | else |
344 | { |
344 | { |
345 | // maybe there is a player standing on the same mapspace |
345 | // maybe there is a player standing on the same mapspace |
346 | // this will catch the case where "this" is a player |
346 | // this will catch the case where "this" is a player |
347 | if (object *pl = ms ().player ()) |
347 | if (object *pl = ms ().player ()) |
348 | if ((!pl->container && pl->contr->ns && !pl->contr->ns->update_look) |
348 | if ((pl->contr->ns && !pl->container_ () && !pl->contr->ns->update_look) |
349 | || this == pl->container) |
349 | || pl->container_ () == this) |
350 | return pl; |
350 | return pl; |
351 | } |
351 | } |
352 | } |
352 | } |
353 | |
353 | |
354 | return 0; |
354 | return 0; |
… | |
… | |
1041 | * the previous environment. |
1041 | * the previous environment. |
1042 | */ |
1042 | */ |
1043 | void |
1043 | void |
1044 | object::do_remove () |
1044 | object::do_remove () |
1045 | { |
1045 | { |
1046 | object *tmp, *last = 0; |
|
|
1047 | object *otmp; |
|
|
1048 | |
|
|
1049 | if (flag [FLAG_REMOVED]) |
1046 | if (flag [FLAG_REMOVED]) |
1050 | return; |
1047 | return; |
1051 | |
1048 | |
1052 | INVOKE_OBJECT (REMOVE, this); |
1049 | INVOKE_OBJECT (REMOVE, this); |
1053 | |
1050 | |
… | |
… | |
1119 | close_container (); |
1116 | close_container (); |
1120 | |
1117 | |
1121 | --map->players; |
1118 | --map->players; |
1122 | map->touch (); |
1119 | map->touch (); |
1123 | } |
1120 | } |
1124 | else if (pl->container == this) |
1121 | else if (pl->container_ () == this) |
1125 | { |
1122 | { |
1126 | // removing a container should close it |
1123 | // removing a container should close it |
1127 | close_container (); |
1124 | close_container (); |
1128 | } |
1125 | } |
1129 | |
1126 | |
… | |
… | |
1145 | |
1142 | |
1146 | int check_walk_off = !flag [FLAG_NO_APPLY]; |
1143 | int check_walk_off = !flag [FLAG_NO_APPLY]; |
1147 | |
1144 | |
1148 | if (object *pl = ms.player ()) |
1145 | if (object *pl = ms.player ()) |
1149 | { |
1146 | { |
1150 | if (pl->container == this) |
1147 | if (pl->container_ () == this) |
1151 | /* If a container that the player is currently using somehow gets |
1148 | /* If a container that the player is currently using somehow gets |
1152 | * removed (most likely destroyed), update the player view |
1149 | * removed (most likely destroyed), update the player view |
1153 | * appropriately. |
1150 | * appropriately. |
1154 | */ |
1151 | */ |
1155 | pl->close_container (); |
1152 | pl->close_container (); |
… | |
… | |
1159 | //TODO: update floorbox to preserve ordering |
1156 | //TODO: update floorbox to preserve ordering |
1160 | if (pl->contr->ns) |
1157 | if (pl->contr->ns) |
1161 | pl->contr->ns->floorbox_update (); |
1158 | pl->contr->ns->floorbox_update (); |
1162 | } |
1159 | } |
1163 | |
1160 | |
|
|
1161 | if (check_walk_off) |
1164 | for (tmp = ms.bot; tmp; tmp = tmp->above) |
1162 | for (object *above, *tmp = ms.bot; tmp; tmp = above) |
1165 | { |
1163 | { |
|
|
1164 | above = tmp->above; |
|
|
1165 | |
1166 | /* No point updating the players look faces if he is the object |
1166 | /* No point updating the players look faces if he is the object |
1167 | * being removed. |
1167 | * being removed. |
1168 | */ |
1168 | */ |
1169 | |
1169 | |
1170 | /* See if object moving off should effect something */ |
1170 | /* See if object moving off should effect something */ |
1171 | if (check_walk_off |
|
|
1172 | && ((move_type & tmp->move_off) |
1171 | if ((move_type & tmp->move_off) |
1173 | && (move_type & ~tmp->move_off & ~tmp->move_block) == 0)) |
1172 | && (move_type & ~tmp->move_off & ~tmp->move_block) == 0) |
1174 | { |
|
|
1175 | move_apply (tmp, this, 0); |
1173 | move_apply (tmp, this, 0); |
1176 | |
|
|
1177 | if (destroyed ()) |
|
|
1178 | LOG (llevError, "BUG: remove_ob(): name %s, destroyed leaving object\n", tmp->debug_desc ()); |
|
|
1179 | } |
1174 | } |
1180 | |
|
|
1181 | last = tmp; |
|
|
1182 | } |
|
|
1183 | |
1175 | |
1184 | if (affects_los ()) |
1176 | if (affects_los ()) |
1185 | update_all_los (map, x, y); |
1177 | update_all_los (map, x, y); |
1186 | } |
1178 | } |
1187 | } |
1179 | } |