char s[128];
char *p1,*p2;
- logo("CFG_load: загрузка конфигурации из %s\n",cfg_file);
- if((h=fopen(cfg_file,"rb"))==NULL) {
+ char pc[50];
+ char *e = getenv("HOME");
+ strncpy(pc, e, 30);
+ strcpy(&pc[strlen(pc)], "/default.cfg");
+ if (!fexists(pc)) {
+ strcpy(pc, "default.cfg");
+ if (!fexists(pc)) {
+ strcpy(pc, "/usr/share/doom2d-rembo/default.cfg");
+ if (!fexists(pc)) {
+ logo("default.cfg not found\n");
+ return;
+ }
+ }
+ }
+
+ logo("CFG_load: загрузка конфигурации из %s\n",pc);
+ if((h=fopen(pc,"rb"))==NULL) {
perror("Cannot open file");return;
}
while(!feof(h)) {
pl2.id=-2;
myrandomize();
F_startup();
- F_addwad("doom2d.wad");
+ char *pw;
+#ifndef WIN32
+ pw = "/usr/share/doom2d-rembo/doom2d.wad";
+#else
+ pw = "doom2d.wad";
+#endif
+ if (fexists(pw))
+ F_addwad(pw);
+ else
+ F_addwad("doom2d.wad");
CFG_args(argc, argv);
CFG_load();
F_initwads();
void F_loadmus(char n[8]) {
if (musdisabled) return;
char f[50];
+ char name[50];
#ifndef WIN32
- strcpy(f,"music/");
+ strcpy(f, "/usr/share/doom2d-rembo/music/");
#else
- strcpy(f,"music\\");
+ strcpy(f, "music\\");
#endif
- strncpy(&f[6], n, 8);
- f[6+8]='\0';
- muslo = Mix_LoadMUS(f);
- if (muslo == NULL) {
- char name[50];
+ int l = strlen(f);
+ strncpy(&f[l], n, 8);
+ f[l+8]='\0';
+ trans_ascii_str(name, f);
+ muslo = Mix_LoadMUS(name);
+ if (muslo == NULL)
+ {
+#ifndef WIN32
+ strcpy(f, "music/");
+ int l = strlen(f);
+ strncpy(&f[l], n, 8);
+ f[l+8]='\0';
trans_ascii_str(name, f);
muslo = Mix_LoadMUS(name);
- if (!muslo) logo("Music not found '%s'\n", name);
+#endif
}
-}
+ if (!muslo) logo("Music not found '%s'\n", name);
+}
void F_freemus(void) {
if (musdisabled) return;
{
srand(SDL_GetTicks());
}
+
+int fexists(char * filename)
+{
+ FILE *f;
+ if (f = fopen(filename, "r"))
+ {
+ fclose(f);
+ return 1;
+ }
+ return 0;
+}
\ No newline at end of file