Thinking about an item placement rewrite

Currently add_item searches over an area to place an item if it doesn’t fit and it doesn’t take into account weight constraints, but it does take into account max item constraints. The search over the area is done recursivily which is a bit odd and it fails silently, although failure only happens if a 4x4 area around the target has 64 items each.

add_item_or_charges takes weight into constraint and attempts to allow overflow to other squares, but does so in a haphazard way that I am not convienced actually works.

I think that add_item should be simplified and only be used for mapgen (it is currently used through the entire code base) and not even attempt to place an object that overflows. Everywhere else add_item_or_charges should be used and both should be rewritten. Furthermore it would simplify the code base to simply have a can_place(x,y,item) function.

I am down for making these changes, but as a new contributior I wanted to build some concensus.


It sounds alright to me. I’d recommend popping into the IRC and asking kevingranades opinion. He will likely have a very strong opinion but if he thinks it’s worth doing it is pretty much guaranteed to get in.