project_files/frontlib/model/map.c
changeset 7224 5143861c83bd
parent 7179 f84805e6df03
child 7230 240620f46dd7
equal deleted inserted replaced
7221:8d04e85ca204 7224:5143861c83bd
     9 flib_map *flib_map_create_regular(const char *theme, int templateFilter) {
     9 flib_map *flib_map_create_regular(const char *theme, int templateFilter) {
    10 	flib_map *result = NULL;
    10 	flib_map *result = NULL;
    11 	if(!theme) {
    11 	if(!theme) {
    12 		flib_log_e("null parameter in flib_map_create_regular");
    12 		flib_log_e("null parameter in flib_map_create_regular");
    13 	} else {
    13 	} else {
    14 		flib_map *newmap = calloc(1, sizeof(flib_map));
    14 		flib_map *newmap = flib_calloc(1, sizeof(flib_map));
    15 		if(newmap) {
    15 		if(newmap) {
    16 			newmap->mapgen = MAPGEN_REGULAR;
    16 			newmap->mapgen = MAPGEN_REGULAR;
    17 			newmap->templateFilter = templateFilter;
    17 			newmap->templateFilter = templateFilter;
    18 			newmap->theme = flib_strdupnull(theme);
    18 			newmap->theme = flib_strdupnull(theme);
    19 			if(newmap->theme) {
    19 			if(newmap->theme) {
    29 flib_map *flib_map_create_maze(const char *theme, int mazeSize) {
    29 flib_map *flib_map_create_maze(const char *theme, int mazeSize) {
    30 	flib_map *result = NULL;
    30 	flib_map *result = NULL;
    31 	if(!theme) {
    31 	if(!theme) {
    32 		flib_log_e("null parameter in flib_map_create_maze");
    32 		flib_log_e("null parameter in flib_map_create_maze");
    33 	} else {
    33 	} else {
    34 		flib_map *newmap = calloc(1, sizeof(flib_map));
    34 		flib_map *newmap = flib_calloc(1, sizeof(flib_map));
    35 		if(newmap) {
    35 		if(newmap) {
    36 			newmap->mapgen = MAPGEN_MAZE;
    36 			newmap->mapgen = MAPGEN_MAZE;
    37 			newmap->mazeSize = mazeSize;
    37 			newmap->mazeSize = mazeSize;
    38 			newmap->theme = flib_strdupnull(theme);
    38 			newmap->theme = flib_strdupnull(theme);
    39 			if(newmap->theme) {
    39 			if(newmap->theme) {
    49 flib_map *flib_map_create_named(const char *name) {
    49 flib_map *flib_map_create_named(const char *name) {
    50 	flib_map *result = NULL;
    50 	flib_map *result = NULL;
    51 	if(!name) {
    51 	if(!name) {
    52 		flib_log_e("null parameter in flib_map_create_named");
    52 		flib_log_e("null parameter in flib_map_create_named");
    53 	} else {
    53 	} else {
    54 		flib_map *newmap = calloc(1, sizeof(flib_map));
    54 		flib_map *newmap = flib_calloc(1, sizeof(flib_map));
    55 		if(newmap) {
    55 		if(newmap) {
    56 			newmap->mapgen = MAPGEN_NAMED;
    56 			newmap->mapgen = MAPGEN_NAMED;
    57 			newmap->name = flib_strdupnull(name);
    57 			newmap->name = flib_strdupnull(name);
    58 			if(newmap->name) {
    58 			if(newmap->name) {
    59 				result = newmap;
    59 				result = newmap;
    68 flib_map *flib_map_create_drawn(const char *theme, const uint8_t *drawData, int drawDataSize) {
    68 flib_map *flib_map_create_drawn(const char *theme, const uint8_t *drawData, int drawDataSize) {
    69 	flib_map *result = NULL;
    69 	flib_map *result = NULL;
    70 	if(!theme || !drawData) {
    70 	if(!theme || !drawData) {
    71 		flib_log_e("null parameter in flib_map_create_named");
    71 		flib_log_e("null parameter in flib_map_create_named");
    72 	} else {
    72 	} else {
    73 		flib_map *newmap = calloc(1, sizeof(flib_map));
    73 		flib_map *newmap = flib_calloc(1, sizeof(flib_map));
    74 		if(newmap) {
    74 		if(newmap) {
    75 			newmap->mapgen = MAPGEN_DRAWN;
    75 			newmap->mapgen = MAPGEN_DRAWN;
    76 			newmap->drawData = flib_bufdupnull(drawData, drawDataSize);
    76 			newmap->drawData = flib_bufdupnull(drawData, drawDataSize);
    77 			newmap->drawDataSize = drawDataSize;
    77 			newmap->drawDataSize = drawDataSize;
    78 			if(newmap->drawData) {
    78 			if(newmap->drawData) {