about summary refs log tree commit diff
path: root/src/engine/map.c
blob: dfb8b69155f16f20ebdf2812615311b1f3d761af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <stdio.h>
#include "datafile.h"

static DATAFILE *map = 0;

void *map_get_data(int index)
{
	return datafile_get_data(map, index);
}

void map_unload_data(int index)
{
	datafile_unload_data(map, index);
}

void *map_get_item(int index, int *type, int *id)
{
	return datafile_get_item(map, index, type, id);
}

void map_get_type(int type, int *start, int *num)
{
	datafile_get_type(map, type, start, num);
}

void *map_find_item(int type, int id)
{
	return datafile_find_item(map, type, id);
}

int map_num_items()
{
	return datafile_num_items(map);
}

void map_unload()
{
	datafile_unload(map);
	map = 0x0;
}

int map_is_loaded()
{
	return map != 0;
}

int map_load(const char *mapname)
{
	char buf[512];
	sprintf(buf, "data/maps/%s.map", mapname);
	map = datafile_load(buf);
	return map != 0;
}

void map_set(void *m)
{
	if(map)
		map_unload();
	map = (DATAFILE*)m;
}