From 3b395263ce12c9af1570f62a3b0a986dacf313d5 Mon Sep 17 00:00:00 2001 From: terminx Date: Sat, 8 Mar 2008 09:04:01 +0000 Subject: [PATCH] git-svn-id: https://svn.eduke32.com/eduke32@638 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/game.c | 54 ++++++++++++--------- polymer/eduke32/source/jaudiolib/fx_man.c | 51 +++++++++++++++++++ polymer/eduke32/source/jaudiolib/multivoc.c | 17 ++----- 3 files changed, 87 insertions(+), 35 deletions(-) diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index af2e8ef0b..1e520b8d3 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -8614,7 +8614,7 @@ static void autoloadgrps(const char *fn) while (findfiles) { Bsprintf(tempbuf,"autoload/%s/%s",fn,findfiles->name); initprintf("Using group file '%s'.\n",tempbuf); initgroupfile(tempbuf); findfiles = findfiles->next; } } -static int parsegroupfiles(scriptfile *script) +static int parsedefinitions_game(scriptfile *script, const int preload) { int tokn; char *cmdtokptr; @@ -8647,7 +8647,7 @@ static int parsegroupfiles(scriptfile *script) char *fn; pathsearchmode = 1; - if (!scriptfile_getstring(script,&fn)) + if (!scriptfile_getstring(script,&fn) && preload) { int j = initgroupfile(fn); @@ -8667,7 +8667,7 @@ static int parsegroupfiles(scriptfile *script) case T_CACHESIZE: { int j; - if (scriptfile_getnumber(script,&j)) break; + if (scriptfile_getnumber(script,&j) || !preload) break; if (j > 0) MAXCACHE1DSIZE = j<<10; } @@ -8687,14 +8687,15 @@ static int parsegroupfiles(scriptfile *script) } else { - parsegroupfiles(included); + parsedefinitions_game(included, preload); scriptfile_close(included); } } break; } case T_NOAUTOLOAD: - g_NoAutoLoad = 1; + if (preload) + g_NoAutoLoad = 1; break; case T_MUSIC: { @@ -8715,15 +8716,18 @@ static int parsegroupfiles(scriptfile *script) break; } } - if(ID==NULL) + if (!preload) { - initprintf("Error: missing ID for music definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr)); - break; - } -#ifdef USE_OPENAL - if (AL_DefineMusic(ID,ext)) - initprintf("Error: invalid music ID on line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr)); -#endif + if(ID==NULL) + { + initprintf("Error: missing ID for music definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr)); + break; + } + #ifdef USE_OPENAL + if (AL_DefineMusic(ID,ext)) + initprintf("Error: invalid music ID on line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr)); + #endif + } } break; @@ -8744,12 +8748,15 @@ static int parsegroupfiles(scriptfile *script) scriptfile_getstring(script,&name); } } - if(num==-1) + if (!preload) { - initprintf("Error: missing ID for sound definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr)); - break; + if(num==-1) + { + initprintf("Error: missing ID for sound definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr)); + break; + } + if(AL_DefineSound(num,name))initprintf("Error: invalid sound ID on line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr)); } - if(AL_DefineSound(num,name))initprintf("Error: invalid sound ID on line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr)); } break; case T_EOF: @@ -8761,14 +8768,14 @@ static int parsegroupfiles(scriptfile *script) return 0; } -static int loadgroupfiles(const char *fn) +static int loaddefinitions_game(const char *fn, const int preload) { scriptfile *script; script = scriptfile_fromfile((char *)fn); if (!script) return -1; - parsegroupfiles(script); + parsedefinitions_game(script, preload); scriptfile_close(script); scriptfile_clearsymbols(); @@ -10289,7 +10296,7 @@ void app_main(int argc,const char **argv) autoloadgrps(duke3dgrp); } - loadgroupfiles(duke3ddef); + loaddefinitions_game(duke3ddef, TRUE); { struct strllist *s; @@ -10371,8 +10378,11 @@ void app_main(int argc,const char **argv) } if (quitevent) return; - if (!loaddefinitionsfile(duke3ddef)) initprintf("Definitions file '%s' loaded.\n",duke3ddef); - + if (!loaddefinitionsfile(duke3ddef)) + { + initprintf("Definitions file '%s' loaded.\n",duke3ddef); + loaddefinitions_game(duke3ddef, FALSE); + } // initprintf("numplayers=%i\n",numplayers); if (numplayers > 1) diff --git a/polymer/eduke32/source/jaudiolib/fx_man.c b/polymer/eduke32/source/jaudiolib/fx_man.c index b1f9abf44..8477cb800 100644 --- a/polymer/eduke32/source/jaudiolib/fx_man.c +++ b/polymer/eduke32/source/jaudiolib/fx_man.c @@ -1162,6 +1162,7 @@ void AudioUpdate(void) { MUSIC_Update(); } void playmusic(const char *fn); +#if 0 char *makename(char *destname,char *OGGname) { if (!(*OGGname)) @@ -1212,7 +1213,57 @@ int AL_DefineMusic(char *ID,char *name) // playmusicMAP(ID,sel); return 0; } +#else +char *makename(char *destname,char *OGGname,char *origname) +{ + if(!origname)return destname; + if(destname)Bfree(destname); + destname=Bcalloc(Bstrlen(OGGname)+Bstrlen(origname)+1,sizeof(char)); + if(!destname)return 0; + Bstrcpy(destname,(*OGGname)?OGGname:origname); + if(*OGGname&&OGGname[Bstrlen(OGGname)-1]=='/') + { + while(*origname=='/')origname++; + Bstrcat(destname,origname); + } + OGGname=Bstrchr(destname,'.'); + if(OGGname)Bstrcpy(OGGname,".ogg");else Bstrcat(destname,".ogg"); + return destname; +} + +int AL_DefineSound(int ID,char *name) +{ + if(ID>=MAXSOUNDS)return 1; + g_sounds[ID].filename1=makename(g_sounds[ID].filename1,name,g_sounds[ID].filename); +// initprintf("(%s)(%s)(%s)\n",g_sounds[ID].filename1,name,g_sounds[ID].filename); +// loadsound(ID); + return 0; +} + +int AL_DefineMusic(char *ID,char *name) +{ + int lev,ep,sel;char b1,b2; + + if(!ID)return 1; + if(!Bstrcmp(ID,"intro")) {sel=MAXVOLUMES*MAXLEVELS; ID=env_music_fn[0];}else + if(!Bstrcmp(ID,"briefing")){sel=MAXVOLUMES*MAXLEVELS+1;ID=env_music_fn[1];}else + if(!Bstrcmp(ID,"loading")) {sel=MAXVOLUMES*MAXLEVELS+2;ID=env_music_fn[2];}else + { + sscanf(ID,"%c%d%c%d",&b1,&ep,&b2,&lev); + lev--;ep--; + if(toupper(b1)!='E'||toupper(b2)!='L'||lev>=MAXLEVELS||ep>=MAXVOLUMES)return 1; + sel=(ep*MAXLEVELS)+lev; + ID=map[sel].musicfn; + } + + map[sel].musicfn1=makename(map[sel].musicfn1,name,ID); + initprintf("%-15s | ",ID); + initprintf("%3d %2d %2d | %s\n",sel,ep,lev,map[sel].musicfn1); +// playmusicMAP(ID,sel); + return 0; +} +#endif void playmusicMAP(const char *fn,const int sel) { Musicsize=0; diff --git a/polymer/eduke32/source/jaudiolib/multivoc.c b/polymer/eduke32/source/jaudiolib/multivoc.c index eaf00d4d9..02af369a3 100644 --- a/polymer/eduke32/source/jaudiolib/multivoc.c +++ b/polymer/eduke32/source/jaudiolib/multivoc.c @@ -374,13 +374,9 @@ void MV_PlayVoice(VoiceNode *voice) flags = DisableInterrupts(); LL_SortedInsertion(&VoiceList, voice, prev, next, VoiceNode, priority); -#ifdef USE_OPENAL - if (!openal_disabled) - { - if(!voice->bufsnd)voice->bufsnd=(char *)Bcalloc(0x8000*4,sizeof(char)); - if(!voice->bufsnd)initprintf("Attention. It gonna crash! Thank you."); // FIXME: change the msg - } -#endif + + if(!voice->bufsnd)voice->bufsnd=(char *)Bcalloc(0x8000*4,sizeof(char)); + if(!voice->bufsnd)initprintf("Attention. It gonna crash! Thank you."); // FIXME: change the msg RestoreInterrupts(flags); } @@ -396,12 +392,7 @@ void MV_StopVoice(VoiceNode *voice) unsigned int flags; flags = DisableInterrupts(); -#ifdef USE_OPENAL - if (!openal_disabled) - { - if(!voice->bufsnd)Bfree(voice->bufsnd); - } -#endif + if(!voice->bufsnd)Bfree(voice->bufsnd); // move the voice from the play list to the free list LL_Remove(voice, next, prev); LL_Add(&VoicePool, voice, next, prev);