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

This commit is contained in:
terminx 2008-01-26 03:59:34 +00:00
parent 26dc1358ac
commit 1c9d7c28bb
3 changed files with 47 additions and 20 deletions

View file

@ -3736,6 +3736,19 @@ static int parsecommand(void)
casecount=0;
if (tempscrptr)
{
int t,n;
for (i=3;i<3+tempscrptr[1]*2-2;i+=2) // sort them
{
t=tempscrptr[i];n=i;
for (j=i+2;j<3+tempscrptr[1]*2;j+=2)
if (tempscrptr[j]<t){t=tempscrptr[j];n=j;}
if (n!=i)
{
t=tempscrptr[i ];tempscrptr[i ]=tempscrptr[n ];tempscrptr[n ]=t;
t=tempscrptr[i+1];tempscrptr[i+1]=tempscrptr[n+1];tempscrptr[n+1]=t;
}
}
// for (j=3;j<3+tempscrptr[1]*2;j+=2)initprintf("%5d %8x\n",tempscrptr[j],tempscrptr[j+1]);
tempscrptr[0]= (int)scriptptr - (int)&script[0]; // save 'end' location
}
else

View file

@ -4481,6 +4481,7 @@ static int parse(void)
//AddLog("Processing Switch...");
int lValue=GetGameVarID(*insptr++, g_i, g_p), lEnd=*insptr++, lCases=*insptr++;
int *lpDefault=insptr++, *lpCases=insptr, bMatched=0, *lTempInsPtr, lCheckCase;
int left,right;
insptr+=lCases*2;
lTempInsPtr=insptr;
//Bsprintf(g_szBuf,"lEnd= %d *lpDefault=%d",lEnd,*lpDefault);
@ -4488,29 +4489,34 @@ static int parse(void)
//Bsprintf(g_szBuf,"Checking %d cases for %d",lCases, lValue);
//AddLog(g_szBuf);
for (lCheckCase=0; lCheckCase<lCases && !bMatched; lCheckCase++)
left=0;right=lCases-1;
while (!bMatched)
{
//Bsprintf(g_szBuf,"Checking #%d Value= %d",lCheckCase, lpCases[lCheckCase*2]);
//AddLog(g_szBuf);
if (lpCases[lCheckCase*2] == lValue)
{
//AddLog("Found Case Match");
//Bsprintf(g_szBuf,"insptr=%d. lCheckCase=%d, offset=%d, &script[0]=%d",
// (int)insptr,(int)lCheckCase,lpCases[lCheckCase*2+1],(int)&script[0]);
//AddLog(g_szBuf);
// fake a 2-d Array
insptr=(int*)(lpCases[lCheckCase*2+1] + &script[0]);
//Bsprintf(g_szBuf,"insptr=%d. ", (int)insptr);
//AddLog(g_szBuf);
while (1)
{
if (parse())
break;
}
//AddLog("Done Executing Case");
bMatched=1;
}
lCheckCase=(left+right)/2;
// initprintf("(%2d..%2d..%2d) [%2d..%2d..%2d]==%2d\n",left,lCheckCase,right,lpCases[left*2],lpCases[lCheckCase*2],lpCases[right*2],lValue);
if (lpCases[lCheckCase*2] > lValue) right=lCheckCase-1; else
if (lpCases[lCheckCase*2] < lValue) left =lCheckCase+1; else
if (lpCases[lCheckCase*2] == lValue)
{
//AddLog("Found Case Match");
//Bsprintf(g_szBuf,"insptr=%d. lCheckCase=%d, offset=%d, &script[0]=%d",
// (int)insptr,(int)lCheckCase,lpCases[lCheckCase*2+1],(int)&script[0]);
//AddLog(g_szBuf);
// fake a 2-d Array
insptr=(int*)(lpCases[lCheckCase*2+1] + &script[0]);
//Bsprintf(g_szBuf,"insptr=%d. ", (int)insptr);
//AddLog(g_szBuf);
while (1)
{
if (parse())
break;
}
//AddLog("Done Executing Case");
bMatched=1;
}
if (right-left<0)break;
}
if (!bMatched)
{

View file

@ -233,6 +233,14 @@ int loadsound(unsigned int num)
if (num >= MAXSOUNDS || ud.config.SoundToggle == 0) return 0;
if (ud.config.FXDevice < 0) return 0;
if (g_sounds[num].filename == NULL)
{
// Bsprintf(fta_quotes[113],"g_sounds %s(#%d) not found.",sounds[num],num);
// FTA(113,g_player[myconnectindex].ps);
OSD_Printf("Sound (#%d) not defined!\n",num);
return 0;
}
fp = kopen4load(g_sounds[num].filename,loadfromgrouponly);
if (fp == -1)
{