Commit 96b57ccd authored by mercury233's avatar mercury233

fix

parent 06ea1af8
...@@ -782,19 +782,14 @@ void Game::LoadExpansionDB() { ...@@ -782,19 +782,14 @@ void Game::LoadExpansionDB() {
#else #else
DIR * dir; DIR * dir;
struct dirent * dirp; struct dirent * dirp;
const char *foldername = "./expansions/"; if((dir = opendir("./expansions/")) != NULL) {
if((dir = opendir(foldername)) != NULL) {
while((dirp = readdir(dir)) != NULL) { while((dirp = readdir(dir)) != NULL) {
size_t len = strlen(dirp->d_name); size_t len = strlen(dirp->d_name);
if(len < 5 || strcasecmp(dirp->d_name + len - 4, ".cdb") != 0) if(len < 5 || strcasecmp(dirp->d_name + len - 4, ".cdb") != 0)
continue; continue;
char *filepath = (char *)malloc(sizeof(char)*(len + strlen(foldername))); char filepath[1000];
strncpy(filepath, foldername, strlen(foldername) + 1); sprintf(filepath, "./expansions/%s", dirp->d_name);
strncat(filepath, dirp->d_name, len); dataManager.LoadDB(filepath);
std::cout << "Found file " << filepath << std::endl;
if(!dataManager.LoadDB(filepath))
std::cout << "Error loading file" << std::endl;
free(filepath);
} }
closedir(dir); closedir(dir);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment