dndplayer / dnd-player

An online virtual DND playground to support online groups.
https://dnd-player.com
Other
1 stars 0 forks source link

Refactor fog polygon storage #61

Closed chrisella closed 5 years ago

chrisella commented 5 years ago

Currently the fog data within a map treats the maskPolygons as an array. Firebase doesn't actually have any concept of arrays in the realtime DB, however it DOES try and detect where people use objects "like" arrays and then convert them in the API responses. The problem with this is that in certain cases it will fail. One of these cases will likely affect the fog, that being that for it to detect an array it must have contiguous numerical keys, the important bit being contiguous. I believe Firebase can handle some gaps, but with the fog as more polys are deleted there will be more gaps until a point where I suspect bits will just break.

To combat this we need to rework the current bits so we store and expect an object back from the DB. We can still use the transform function to convert it into an array locally, but then we shouldn't be caught off guard when we delete too many fog polygons.