dungeon_crawler

diff prototype/src/tileset.cc @ 63:7f52d6310317

fixed design issue with datafile_path
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 02 Oct 2012 04:52:59 +0300
parents aa9e28670ae2
children
line diff
     1.1 --- a/prototype/src/tileset.cc	Tue Sep 25 06:59:11 2012 +0300
     1.2 +++ b/prototype/src/tileset.cc	Tue Oct 02 04:52:59 2012 +0300
     1.3 @@ -1,4 +1,9 @@
     1.4  #include <stdio.h>
     1.5 +#ifndef _MSC_VER
     1.6 +#include <alloca.h>
     1.7 +#else
     1.8 +#include <malloc.h>
     1.9 +#endif
    1.10  #include "tileset.h"
    1.11  #include "datapath.h"
    1.12  
    1.13 @@ -26,6 +31,9 @@
    1.14  		fprintf(stderr, "failed to open tileset: %s\n", fname);
    1.15  		return false;
    1.16  	}
    1.17 +	char *tmp = (char*)alloca(strlen(fname) + 1);
    1.18 +	strcpy(tmp, fname);
    1.19 +	fname = tmp;
    1.20  
    1.21  	int linenum = 0;
    1.22  	char buf[512];
    1.23 @@ -48,7 +56,7 @@
    1.24  
    1.25  		printf("Tileset %s, loading tile \"%s\" -> %s\n", fname, line, tilefile);
    1.26  		Tile *tile = new Tile(this);
    1.27 -		if(!tile->load(datafile_path(tilefile))) {
    1.28 +		if(!tile->load(datafile_path(tilefile).c_str())) {
    1.29  			fprintf(stderr, "failed to load tile: %s\n", tilefile);
    1.30  			delete tile;
    1.31  			continue;