开发者

How to handle dynamic objects and terrain efficiently like Wurm Online

I have been interested in how Wurm Online handles a dynamically changing map and set of objects whilst still being able to run on a normal computer. I would like to know if there is any information available on how to reproduce the sam开发者_如何学JAVAe type of object management style, efficiently, not only in terms of the client, but for a server to be able to manage the data.


See MineCraft. In that case, 'similar features' are handled through something like a dynamic 2D linked list of 3D arrays of "blocks" (that is, integer ids for terrain objects)....or so i would think. I wrote a weak clone of the system once, which went something like this:

struct block_chunk {
    int[16][16][16] blocks;
    block_chunk *above;
    block_chunk *below;
    block_chunk *north;
    block_chunk *south;
    block_chunk *east;
    block_chunk *west;
    entity_list *mobs;
};

//standard Linked List
struct entity_list {
    entity_list *next;
    entity *object;
};

struct entity {
    //blah blah blah
};

That, of course, is not the only method -- I also wrote an implementation using octant-trees, which is startlingly more space-efficient given large contiguous regions of identical matter:

struct block_chunk {
    boolean is_leaf;
    block_chunk *TNE;
    block_chunk *TSE;
    block_chunk *TNW;
    block_chunk *TSW;
    block_chunk *BNE;
    block_chunk *BSE;
    block_chunk *BNW;
    block_chunk *BSW;

    //the node will either fill all contents with one block, or store a 3D array
    int *block_fill;
    int[][][] *blocks;
};

You probably knew all of this, but if you're interested in knowing how Minecraft (which, after all, was developed by Markus Persson, the very same Wurm guy) manages its server maps with that sort of detail, you'd have to get your hands on the source code -- since there is a vibrant modding community, that is not a problem. Of course, there's also community documentation, which is all well and good (except for all of those ten-year-old trolls who inhabit the forums...)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜