git-svn-id: https://svn.eduke32.com/eduke32@638 1a8010ca-5511-0410-912e-c29ae57300e0

This commit is contained in:
terminx 2008-03-08 09:04:01 +00:00
parent 6b956dfe2a
commit 3b395263ce
3 changed files with 87 additions and 35 deletions

View file

@ -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; } 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; int tokn;
char *cmdtokptr; char *cmdtokptr;
@ -8647,7 +8647,7 @@ static int parsegroupfiles(scriptfile *script)
char *fn; char *fn;
pathsearchmode = 1; pathsearchmode = 1;
if (!scriptfile_getstring(script,&fn)) if (!scriptfile_getstring(script,&fn) && preload)
{ {
int j = initgroupfile(fn); int j = initgroupfile(fn);
@ -8667,7 +8667,7 @@ static int parsegroupfiles(scriptfile *script)
case T_CACHESIZE: case T_CACHESIZE:
{ {
int j; int j;
if (scriptfile_getnumber(script,&j)) break; if (scriptfile_getnumber(script,&j) || !preload) break;
if (j > 0) MAXCACHE1DSIZE = j<<10; if (j > 0) MAXCACHE1DSIZE = j<<10;
} }
@ -8687,14 +8687,15 @@ static int parsegroupfiles(scriptfile *script)
} }
else else
{ {
parsegroupfiles(included); parsedefinitions_game(included, preload);
scriptfile_close(included); scriptfile_close(included);
} }
} }
break; break;
} }
case T_NOAUTOLOAD: case T_NOAUTOLOAD:
g_NoAutoLoad = 1; if (preload)
g_NoAutoLoad = 1;
break; break;
case T_MUSIC: case T_MUSIC:
{ {
@ -8715,15 +8716,18 @@ static int parsegroupfiles(scriptfile *script)
break; break;
} }
} }
if(ID==NULL) if (!preload)
{ {
initprintf("Error: missing ID for music definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr)); if(ID==NULL)
break; {
} initprintf("Error: missing ID for music definition near line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr));
#ifdef USE_OPENAL break;
if (AL_DefineMusic(ID,ext)) }
initprintf("Error: invalid music ID on line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr)); #ifdef USE_OPENAL
#endif if (AL_DefineMusic(ID,ext))
initprintf("Error: invalid music ID on line %s:%d\n", script->filename, scriptfile_getlinum(script,tinttokptr));
#endif
}
} }
break; break;
@ -8744,12 +8748,15 @@ static int parsegroupfiles(scriptfile *script)
scriptfile_getstring(script,&name); 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)); if(num==-1)
break; {
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; break;
case T_EOF: case T_EOF:
@ -8761,14 +8768,14 @@ static int parsegroupfiles(scriptfile *script)
return 0; return 0;
} }
static int loadgroupfiles(const char *fn) static int loaddefinitions_game(const char *fn, const int preload)
{ {
scriptfile *script; scriptfile *script;
script = scriptfile_fromfile((char *)fn); script = scriptfile_fromfile((char *)fn);
if (!script) return -1; if (!script) return -1;
parsegroupfiles(script); parsedefinitions_game(script, preload);
scriptfile_close(script); scriptfile_close(script);
scriptfile_clearsymbols(); scriptfile_clearsymbols();
@ -10289,7 +10296,7 @@ void app_main(int argc,const char **argv)
autoloadgrps(duke3dgrp); autoloadgrps(duke3dgrp);
} }
loadgroupfiles(duke3ddef); loaddefinitions_game(duke3ddef, TRUE);
{ {
struct strllist *s; struct strllist *s;
@ -10371,8 +10378,11 @@ void app_main(int argc,const char **argv)
} }
if (quitevent) return; 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); // initprintf("numplayers=%i\n",numplayers);
if (numplayers > 1) if (numplayers > 1)

View file

@ -1162,6 +1162,7 @@ void AudioUpdate(void) { MUSIC_Update(); }
void playmusic(const char *fn); void playmusic(const char *fn);
#if 0
char *makename(char *destname,char *OGGname) char *makename(char *destname,char *OGGname)
{ {
if (!(*OGGname)) if (!(*OGGname))
@ -1212,7 +1213,57 @@ int AL_DefineMusic(char *ID,char *name)
// playmusicMAP(ID,sel); // playmusicMAP(ID,sel);
return 0; 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) void playmusicMAP(const char *fn,const int sel)
{ {
Musicsize=0; Musicsize=0;

View file

@ -374,13 +374,9 @@ void MV_PlayVoice(VoiceNode *voice)
flags = DisableInterrupts(); flags = DisableInterrupts();
LL_SortedInsertion(&VoiceList, voice, prev, next, VoiceNode, priority); 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
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
RestoreInterrupts(flags); RestoreInterrupts(flags);
} }
@ -396,12 +392,7 @@ void MV_StopVoice(VoiceNode *voice)
unsigned int flags; unsigned int flags;
flags = DisableInterrupts(); flags = DisableInterrupts();
#ifdef USE_OPENAL if(!voice->bufsnd)Bfree(voice->bufsnd);
if (!openal_disabled)
{
if(!voice->bufsnd)Bfree(voice->bufsnd);
}
#endif
// move the voice from the play list to the free list // move the voice from the play list to the free list
LL_Remove(voice, next, prev); LL_Remove(voice, next, prev);
LL_Add(&VoicePool, voice, next, prev); LL_Add(&VoicePool, voice, next, prev);