There is a dynamic two-dimensional array. There is a base of items. An item can occupy an arbitrary number of cells in an array.
The item has the [coordinates] parameter, where the coordinates of the cell are shown, where the left-top corner of the item is located and its length and height are additionally indicated. About such a scheme is meant.

In this case: [crossbow: 2-2: 2: 4].
To transfer an item, drag-n-drop is used. BUT, since in the inventory database, in fact, the item is located in the coordinates of one cell, then the items are elementary superimposed on one another.
And if the item comes from the outside, the inventory is not generated at all: the system checks the coordinate entries, makes corrections x + width, y + height and inserts the item into the empty space, if it exists. But such checks are very monstrous and costly, since all corrections should fall into the temporary storage of occupied cells and not be taken into account when checking for their freedom.
You can back up with a crutch on the other hand: with each inventory operation, send a new version of the mask of occupied sectors in the array to the database, but tests have shown that 4 people strenuously rearranging the items in the inventory put the fuckin base on them and eats an unforgivably much memory.
Did someone develop similar systems? Solved similar problems? How can this be optimized? Or maybe I do not notice which thread is a simpler approach to the topic?
текущий_инвентарь_без_предметаmatrix +пустой_инвентарь_с_предметом, i.e. one dimension. In the most banal case, you make a matrix of zeros and ones, and if you add at least one deuce, you forbid it. - Sh4dow