Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

Well, the gigantic room would be 10,000 x 10,000.  Which means storing just a single byte tile value is 100MB!  And storing a single byte flag value is another 100MB!  To make things more interesting, the UI drawing is decoupled from the actual game engine.  So I have to make a copy of the map every update so the UI drawing thread can read the map without fear of it changing while it is reading.  (The alternative is to lock all reads of the map, which would defeat threading entirely and be atrociously slow)  Copying 100MB is a substantial time.  By breaking into 100x100 rooms, each of a more manageable 10KB size, I can use reference counting to only copy sections that changes.  So stuff like FOV flags are only set on the live rooms - the rest of the rooms just have a flag stating that their FOV flag is constant.  The same is for the smoke simulation - I have to store the amount of smoke per tile, but for the vast majority this is zero, so I can have that allocated only where necessary.

Separate rooms is also a very useful optimization for things like MOB look up. Until 1812 I stored monster and item lists per-room.  Usually rooms were small, so to see if an item was on a square it would be faster to look through all monsters to see if a monster was there than track it per square.  (This particularly relevant for stuff like Everything is Fodder which is technically an infinite map as it generates rooms on demand)  For 1812, I had to build a separate VDB-style (https://github.com/AcademySoftwareFoundation/openvdb) acceleration structure to swiftly locate all creatures globally.  I ended up with separate tables for both teams and for the officers, so I could do efficient searches for all enemy troops, or all friendly officers.

Separate rooms is a very useful roguelike construction technique as you can piece together "levels" that are usually connected by staircases smoothly.  Vicious Orcs is a good example of this.   The original motivation was Jacob's Matrix where it was just to confuse people through non-cartesian coordinates.  And I assure you, it can be very confusing :>