2008-01-19 10:57:25 +00:00
|
|
|
#include <engine/e_common_interface.h>
|
2008-01-13 11:15:32 +00:00
|
|
|
#include "g_layers.h"
|
|
|
|
|
2008-01-29 21:39:41 +00:00
|
|
|
static MAPITEM_LAYER_TILEMAP *game_layer = 0;
|
|
|
|
static MAPITEM_GROUP *game_group = 0;
|
2008-01-13 11:15:32 +00:00
|
|
|
|
|
|
|
static int groups_start = 0;
|
|
|
|
static int groups_num = 0;
|
|
|
|
static int layers_start = 0;
|
|
|
|
static int layers_num = 0;
|
|
|
|
|
|
|
|
void layers_init()
|
|
|
|
{
|
|
|
|
map_get_type(MAPITEMTYPE_GROUP, &groups_start, &groups_num);
|
|
|
|
|
|
|
|
{
|
2008-01-29 21:39:41 +00:00
|
|
|
int p = 0;
|
2008-01-13 11:15:32 +00:00
|
|
|
map_get_type(MAPITEMTYPE_LAYER, &layers_start, &layers_num);
|
|
|
|
|
|
|
|
for(int i = 0; i < layers_num; i++)
|
|
|
|
{
|
|
|
|
MAPITEM_LAYER *layer = (MAPITEM_LAYER *)map_get_item(layers_start+i, 0, 0);
|
|
|
|
if(layer->type == LAYERTYPE_TILES)
|
|
|
|
{
|
|
|
|
MAPITEM_LAYER_TILEMAP *tilemap = (MAPITEM_LAYER_TILEMAP *)layer;
|
2008-01-29 21:39:41 +00:00
|
|
|
|
|
|
|
if(p)
|
|
|
|
{
|
|
|
|
p--;
|
|
|
|
if(p == 0)
|
|
|
|
tilemap->flags |= 2;
|
|
|
|
}
|
|
|
|
|
2008-01-13 11:15:32 +00:00
|
|
|
if(tilemap->flags&1)
|
2008-01-29 21:39:41 +00:00
|
|
|
{
|
|
|
|
dbg_msg("layers", "game");
|
2008-01-13 11:15:32 +00:00
|
|
|
game_layer = tilemap;
|
2008-01-29 21:39:41 +00:00
|
|
|
p = 2;
|
|
|
|
}
|
2008-01-13 11:15:32 +00:00
|
|
|
}
|
2008-01-29 21:39:41 +00:00
|
|
|
dbg_msg("layers", "%d %d", i, layer->type);
|
2008-01-13 11:15:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int layers_num_groups() { return groups_num; }
|
|
|
|
MAPITEM_GROUP *layers_get_group(int index)
|
|
|
|
{
|
|
|
|
return (MAPITEM_GROUP *)map_get_item(groups_start+index, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
MAPITEM_LAYER *layers_get_layer(int index)
|
|
|
|
{
|
|
|
|
return (MAPITEM_LAYER *)map_get_item(layers_start+index, 0, 0);
|
|
|
|
}
|
|
|
|
|
2008-01-29 21:39:41 +00:00
|
|
|
MAPITEM_LAYER_TILEMAP *layers_game_layer()
|
2008-01-13 11:15:32 +00:00
|
|
|
{
|
|
|
|
return game_layer;
|
|
|
|
}
|
|
|
|
|
2008-01-29 21:39:41 +00:00
|
|
|
MAPITEM_GROUP *layers_game_group()
|
|
|
|
{
|
|
|
|
return game_group;
|
|
|
|
}
|
|
|
|
|