Database

Initially, all maps were stored in XML files. This is nice and open, and makes copying filse around easy, but runs into performance issues with large maps since it is difficult to break the maps up into chunks.

The higher level map functions have already been abstracted so that the storage mechanism used shouldn't make any difference to the front end. All we need to do now is to design and implement a database storage mechanism for tile sets.

Tile Sets

A tile set is represented as an ITileSet, which represents the tiles, rivers, roads, places etc on a map. A single map may consist of multiple tilesets, for example a building complex which has multiple levels, or a village which has an outdoor map plus internal maps for each building.

CREATE TABLE tileset (id int autoindex NOT NULL,
                      name varchar(24) NOT NULL,
                      parent_id int DEFAULT 0,
                      int height NOT NULL,
                      int width NOT NULL);
 
CREATE TABLE terrain (id int autoindex NOT NULL,
                      name varchar(32));
 
CREATE TABLE area (id int autoindex NOT NULL,
                   name varchar(240) NOT NULL);
 
CREATE TABLE tile (id bigint autoindex NOT NULL, 
                   tileset_id int NOT NULL,
                   x int NOT NULL, y int NOT NULL, 
                   altitude int DEFAULT 0,
                   terrain int NOT NULL,
                   area int);
 
mapcraft/database.txt · Last modified: 2007/12/24 11:49 by sam
 
Recent changes RSS feed Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki