summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bea6473)
raw | patch | inline | side by side (parent: bea6473)
author | ARembo <ARembo@gmail.com> | |
Mon, 25 Jul 2011 01:49:18 +0000 (21:49 -0400) | ||
committer | ARembo <ARembo@gmail.com> | |
Mon, 25 Jul 2011 01:49:18 +0000 (21:49 -0400) |
src/config.c | patch | blob | history | |
src/main.c | patch | blob | history | |
src/music.c | patch | blob | history | |
src/my.c | patch | blob | history |
diff --git a/src/config.c b/src/config.c
index bc498c63b92ba5ea58a93404095ccce80805b520..2985a4f8e6e0e427736db2c2a700a49e873601c4 100644 (file)
--- a/src/config.c
+++ b/src/config.c
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)) {
diff --git a/src/main.c b/src/main.c
index b12d7ecc0ff68e6fcf399c833be8036014d84d52..5f0fe2343b3c2ee257222347a8234115f148d940 100644 (file)
--- a/src/main.c
+++ b/src/main.c
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();
diff --git a/src/music.c b/src/music.c
index 1f0881584ba96fef761bbf69e010e22377002faf..5e7308f67d84ab58035334f0a5c9e307947ab6ea 100644 (file)
--- a/src/music.c
+++ b/src/music.c
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;
diff --git a/src/my.c b/src/my.c
index 72f444d98c7211b83dcdff5f702d8565141e6183..701dd1d8cceca2518d9017ab6490b01f84109dbd 100644 (file)
--- a/src/my.c
+++ b/src/my.c
{
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