… | |
… | |
1568 | return where->env->insert (this); |
1568 | return where->env->insert (this); |
1569 | else |
1569 | else |
1570 | return where->map->insert (this, where->x, where->y, originator, flags); |
1570 | return where->map->insert (this, where->x, where->y, originator, flags); |
1571 | } |
1571 | } |
1572 | |
1572 | |
1573 | // check whether we can put this into the map, respect max_nrof, max_volume, max_items |
1573 | // check whether we can put this into the map, respect max_volume, max_items |
1574 | bool |
1574 | bool |
1575 | object::can_drop_at (maptile *m, int x, int y, object *originator) |
1575 | object::can_drop_at (maptile *m, int x, int y, object *originator) |
1576 | { |
1576 | { |
1577 | mapspace &ms = m->at (x, y); |
1577 | mapspace &ms = m->at (x, y); |
1578 | |
1578 | |
1579 | int items = ms.items (); |
1579 | int items = ms.items (); |
1580 | |
1580 | |
1581 | if (!items // testing !items ensures we can drop at least one item |
1581 | if (!items // testing !items ensures we can drop at least one item |
1582 | || (items < m->max_items |
1582 | || (items < m->max_items |
1583 | && ms.volume () < m->max_volume |
1583 | && ms.volume () < m->max_volume)) |
1584 | && nrof <= m->max_nrof)) |
|
|
1585 | return true; |
1584 | return true; |
1586 | |
1585 | |
1587 | if (originator && originator->is_player ()) |
1586 | if (originator && originator->is_player ()) |
1588 | originator->contr->failmsg (format ( |
1587 | originator->contr->failmsg (format ( |
1589 | "No matter how hard you try, you just cannot put the %s here H<Try to remove some items from the floor first.>", |
1588 | "No matter how hard you try, you just cannot put the %s here H<Try to remove some items from the floor first.>", |
… | |
… | |
2518 | { |
2517 | { |
2519 | return map ? map->region (x, y) |
2518 | return map ? map->region (x, y) |
2520 | : region::default_region (); |
2519 | : region::default_region (); |
2521 | } |
2520 | } |
2522 | |
2521 | |
2523 | const materialtype_t * |
|
|
2524 | object::dominant_material () const |
|
|
2525 | { |
|
|
2526 | if (materialtype_t *mt = name_to_material (materialname)) |
|
|
2527 | return mt; |
|
|
2528 | |
|
|
2529 | return name_to_material (shstr_unknown); |
|
|
2530 | } |
|
|
2531 | |
|
|
2532 | void |
2522 | void |
2533 | object::open_container (object *new_container) |
2523 | object::open_container (object *new_container) |
2534 | { |
2524 | { |
2535 | if (container == new_container) |
2525 | if (container == new_container) |
2536 | return; |
2526 | return; |