qop
This commit is contained in:
@@ -954,26 +954,16 @@ int main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Search for .cell directory up the tree */
|
||||
char *search_dir = SDL_GetCurrentDirectory();
|
||||
/* Check for .cell directory in the current directory */
|
||||
char *cell_parent_dir = NULL;
|
||||
struct stat st;
|
||||
|
||||
while (search_dir && strlen(search_dir) > 1) {
|
||||
char test_path[PATH_MAX];
|
||||
snprintf(test_path, sizeof(test_path), "%s/.cell", search_dir);
|
||||
if (stat(test_path, &st) == 0 && S_ISDIR(st.st_mode)) {
|
||||
cell_parent_dir = strdup(search_dir);
|
||||
break;
|
||||
}
|
||||
char *last_sep = strrchr(search_dir, '/');
|
||||
if (!last_sep || last_sep == search_dir) {
|
||||
if (stat("/.cell", &st) == 0 && S_ISDIR(st.st_mode))
|
||||
cell_parent_dir = strdup("/");
|
||||
break;
|
||||
}
|
||||
*last_sep = '\0';
|
||||
char *current_dir = SDL_GetCurrentDirectory();
|
||||
char test_path[PATH_MAX];
|
||||
snprintf(test_path, sizeof(test_path), "%s/.cell", current_dir);
|
||||
if (stat(test_path, &st) == 0 && S_ISDIR(st.st_mode)) {
|
||||
cell_parent_dir = strdup(current_dir);
|
||||
}
|
||||
SDL_free(current_dir);
|
||||
|
||||
if (cell_parent_dir) {
|
||||
/* 1) Strip any trailing slash from cell_parent_dir (except if it's just "/") */
|
||||
@@ -981,26 +971,18 @@ int main(int argc, char **argv)
|
||||
if (proj_len > 1 && cell_parent_dir[proj_len - 1] == '/')
|
||||
cell_parent_dir[proj_len - 1] = '\0';
|
||||
|
||||
char scriptpath[PATH_MAX];
|
||||
snprintf(scriptpath, sizeof(scriptpath), "%s/scripts", cell_parent_dir);
|
||||
|
||||
char cellpath[PATH_MAX];
|
||||
snprintf(cellpath, sizeof(cellpath), "%s/.cell/modules", cell_parent_dir);
|
||||
|
||||
PHYSFS_mount(scriptpath, NULL, 1);
|
||||
PHYSFS_mount(cellpath, NULL, 0);
|
||||
PHYSFS_mount(cell_parent_dir, NULL, 0);
|
||||
PHYSFS_setWriteDir(cell_parent_dir);
|
||||
|
||||
free(cell_parent_dir);
|
||||
} else {
|
||||
// Not in a project - use CELLPATH after confirming ..
|
||||
// TODO: implement
|
||||
printf("Could not find project! Exiting!\n");
|
||||
printf("Cell requires a .cell folder to run.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
SDL_free(search_dir);
|
||||
|
||||
/* Create the initial actor from the command line */
|
||||
int actor_argc = argc - script_start;
|
||||
|
||||
Reference in New Issue
Block a user