June 20 - Omni Update

Discussion in 'Dev Blog' started by OmnipotentEntity, Jun 20, 2014.

  1. Abion47

    Abion47 Void-Bound Voyager

    The way I see it, there are three different ways the wiring data could be stored.
    1. Within the block data inside chunks;
    2. Adjacent to the block data, but bound to chunks;
    3. Independent of the chunks, in a separate database/manager object.
    The first way would make querying whether a wire with endpoints in unloaded chunks crosses through loaded chunks impossible to determine without loading those chunks. If this is how wire data is stored, it is the opinion of this guy that it needs to not be stored like that ASAP.

    If the wiring data is stored the second way, the unloaded chunks would still need to be loaded, but only partly, as only the wiring data part of the chunks needs to be accessed.

    If the wiring data is stored the third way, that manager/database would be loaded in its entirety, making all data available all the time and this problem relatively trivial.

    Given that all data is not available all the time, I'm guessing it is not stored the third way. I'm hoping that it isn't stored the first way, because if it was the only way to load node information from unloaded chunks would be to generate a whole swath of dummy nodes to exist in every chunk the wire crosses through, which would be a huge hassle to keep straight and would be a nightmare to get to work properly. Something along the lines of the second storage option is how I'm guessing Starbound does it, if only because it strikes me as having the most efficient method of solving this issue.

    The most likely way to solve this issue I can see is to keep all known nodes in memory for as long as one of the two conditions are met:
    1. One of the nodes is within a loaded chunk.
    2. The a chunk is loaded that is in between the nodes' respective chunks.
    Once neither of these conditions are met, the nodes can be safely removed from memory. The wiring between the nodes won't need to be drawn again until one of the nodes is once again loaded as part of its chunk. As a player walks along, he would happen across a wiring node in a loaded chunk, which would then add the node into the node bank for as long as one of the conditions is true.

    The only time a player could end up between two nodes that rest in separate unloaded chunks is when he teleports (down from a ship, from an admin command, etc.). In which case, the world chunks would have to be queried for a quarter of the world's size in each direction, covering exactly half of the world centered on the player. These chunks would have any wiring nodes checked to see if they meet one of the above conditions and, if so, load them into memory. (The reason only half the world needs to be queried is because any nodes that are connected to the unqueried half of the world would not have their wiring cross over chunks the player rests in.)

    This solution assumes that chunks are aligned horizontally as one chunk per column of world data, which I fully realize is an entirely erroneous assumption. There is probably a way to expand this solution to work in the 2D space, though.

    This has been my brainstorming session of the current moment that is probably full of logic jumps and faulty assumptions. Tune in next time where I continue to probably make more wild assumptions and possibly thoroughly embarrass myself.
     

Share This Page