Merged New Inventory Project into main branch

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1871 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
lalien
2008-03-08 15:15:25 +00:00
parent e16d166277
commit 43ca24dda8
649 changed files with 93359 additions and 82507 deletions
+104 -103
View File
@@ -20,24 +20,24 @@ static void AILCALLBACK timer_func( UINT32 user )
pGapList = (AudioGapList*)user;
pGapList->gap_monitor_timer += GAP_TIMER_INTERVAL;
pGapList->gap_monitor_timer += GAP_TIMER_INTERVAL;
if ( pGapList->audio_gap_active )
{
if ( (pGapList->gap_monitor_timer / 1000) > pGapList->end[ pGapList->gap_monitor_current] )
{
pGapList->audio_gap_active = 0;
pGapList->gap_monitor_current++;
}
}
else
if ( pGapList->audio_gap_active )
{
if ( pGapList->gap_monitor_current < pGapList->count )
if ( (pGapList->gap_monitor_timer / 1000) > pGapList->end[ pGapList->gap_monitor_current] )
{
pGapList->audio_gap_active = 0;
pGapList->gap_monitor_current++;
}
}
else
{
if ( pGapList->gap_monitor_current < pGapList->count )
{
if ( ( pGapList->gap_monitor_timer / 1000) >= pGapList->start[ pGapList->gap_monitor_current ])
{
if ( ( pGapList->gap_monitor_timer / 1000) >= pGapList->start[ pGapList->gap_monitor_current ])
{
pGapList->audio_gap_active = 1;
}
}
}
}
}
@@ -49,7 +49,7 @@ void AudioGapListInit( CHAR8 *zSoundFile, AudioGapList *pGapList )
// This procedure will load in the appropriate .gap file, corresponding
// to the .wav file in szSoundEffects indexed by uiSampleNum
// The procedure will then allocate and load in the AUDIO_GAP information,
// while counting the number of elements loaded
// while counting the number of elements loaded
// FILE *pFile;
HWFILE pFile;
@@ -80,7 +80,7 @@ void AudioGapListInit( CHAR8 *zSoundFile, AudioGapList *pGapList )
while(pDestFileName[counter] !='.')
{
counter++;
counter++;
}
pDestFileName[counter+1]='g';
@@ -92,85 +92,85 @@ void AudioGapListInit( CHAR8 *zSoundFile, AudioGapList *pGapList )
if( pFile )
{
counter=0;
// gap file exists
// now read in the AUDIO_GAPs
//fread(&Start,sizeof(UINT32), 1, pFile);
FileRead( pFile, &Start,sizeof(UINT32), &uiNumBytesRead );
// gap file exists
// now read in the AUDIO_GAPs
//fread(&Start,sizeof(UINT32), 1, pFile);
FileRead( pFile, &Start,sizeof(UINT32), &uiNumBytesRead );
// while ( !feof(pFile) )
while ( !FileCheckEndOfFile( pFile ) )
{
// can read the first element, there exists a second
// can read the first element, there exists a second
//fread(&End, sizeof(UINT32),1,pFile);
FileRead( pFile, &End, sizeof(UINT32), &uiNumBytesRead );
// allocate space for AUDIO_GAP
pCurrentGap = (AUDIO_GAP *)MemAlloc( sizeof(AUDIO_GAP) );
if (pPreviousGap !=0)
pPreviousGap->pNext=pCurrentGap;
else
FileRead( pFile, &End, sizeof(UINT32), &uiNumBytesRead );
// allocate space for AUDIO_GAP
pCurrentGap = (AUDIO_GAP *)MemAlloc( sizeof(AUDIO_GAP) );
if (pPreviousGap !=0)
pPreviousGap->pNext=pCurrentGap;
else
{
// Start of list
pGapList->pCurrent=pCurrentGap;
pGapList->pHead=pCurrentGap;
// Start of list
pGapList->pCurrent=pCurrentGap;
pGapList->pHead=pCurrentGap;
}
pGapList->size++;
pCurrentGap->pNext=0;
pCurrentGap->uiStart=Start;
pCurrentGap->uiEnd=End;
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Gap Start %d and Ends %d", Start, End) );
pGapList->size++;
pCurrentGap->pNext=0;
pCurrentGap->uiStart=Start;
pCurrentGap->uiEnd=End;
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Gap Start %d and Ends %d", Start, End) );
// Increment pointer
pPreviousGap=pCurrentGap;
// Increment pointer
pPreviousGap=pCurrentGap;
// fread(&Start,sizeof(UINT32), 1, pFile);
FileRead( pFile, &Start, sizeof(UINT32), &uiNumBytesRead );
FileRead( pFile, &Start, sizeof(UINT32), &uiNumBytesRead );
}
pGapList->audio_gap_active=FALSE;
pGapList->current_time=0;
//fclose(pFile);
FileClose( pFile );
}
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Gap List Started From File %s and has %d gaps", pDestFileName, pGapList->size) );
FileClose( pFile );
}
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Gap List Started From File %s and has %d gaps", pDestFileName, pGapList->size) );
}
void AudioGapListDone( AudioGapList *pGapList )
{
// This procedure will go through the AudioGapList and free space/nullify pointers
// This procedure will go through the AudioGapList and free space/nullify pointers
// for any allocated elements
AUDIO_GAP *pCurrent, *pNext;
if (pGapList->pHead !=0)
if (pGapList->pHead !=0)
{
pCurrent=pGapList->pHead;
pNext=pCurrent->pNext;
// There are elements in the list
while(pNext !=0)
pCurrent=pGapList->pHead;
pNext=pCurrent->pNext;
// There are elements in the list
while(pNext !=0)
{
// kill pCurrent
MemFree(pCurrent);
pCurrent=pNext;
pNext=pNext->pNext;
// kill pCurrent
MemFree(pCurrent);
pCurrent=pNext;
pNext=pNext->pNext;
}
// now kill the last element
MemFree(pCurrent);
pCurrent=0;
pCurrent=0;
}
pGapList->pHead=0;
pGapList->pCurrent=0;
pGapList->size = 0;
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Audio Gap List Deleted") );
}
void PollAudioGap( UINT32 uiSampleNum, AudioGapList *pGapList )
@@ -182,70 +182,70 @@ void PollAudioGap( UINT32 uiSampleNum, AudioGapList *pGapList )
// the uiStart of the next element is not greater than current time, set current to next and repeat
// ...if next elements uiStart is larger than current_time, or no more elements..
// set flag FALSE
UINT32 time;
AUDIO_GAP *pCurrent;
if(!pGapList)
{
// no gap list, return
return;
// no gap list, return
return;
}
if (pGapList->size > 0)
{
time=SoundGetPosition(uiSampleNum);
// DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Sound Sample Time is %d", time) );
time=SoundGetPosition(uiSampleNum);
// DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Sound Sample Time is %d", time) );
}
else
{
pGapList->audio_gap_active=(FALSE);
pGapList->audio_gap_active=(FALSE);
return;
}
// set current ot head of gap list for this sound
pCurrent = pGapList -> pHead;
pCurrent = pGapList->pHead;
// check to see if we have fallen behind
if( ( time > pCurrent-> uiEnd ) )
if( ( time > pCurrent->uiEnd ) )
{
// fallen behind
// catchup
while( time > pCurrent -> uiEnd )
{
pCurrent = pCurrent -> pNext;
if( ! pCurrent )
{
pGapList->audio_gap_active=(FALSE);
return;
}
}
// fallen behind
// catchup
while( time > pCurrent->uiEnd )
{
pCurrent = pCurrent->pNext;
if( ! pCurrent )
{
pGapList->audio_gap_active=(FALSE);
return;
}
}
}
// check to see if time is within the next AUDIO_GAPs start time
if ( ( time > pCurrent ->uiStart ) && ( time < pCurrent->uiEnd ) )
if ( ( time > pCurrent->uiStart ) && ( time < pCurrent->uiEnd ) )
{
if ((time >pCurrent->uiStart)&&(time < pCurrent->uiEnd))
{
// we are within the time frame
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Gap Started at %d", time) );
pGapList->audio_gap_active=(TRUE);
}
else if ( (time > pCurrent->uiEnd)&&(pGapList->audio_gap_active == TRUE) )
{
// reset if already set
pGapList->audio_gap_active=(FALSE);
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Gap Ended at %d", time) );
}
if ((time >pCurrent->uiStart)&&(time < pCurrent->uiEnd))
{
// we are within the time frame
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Gap Started at %d", time) );
pGapList->audio_gap_active=(TRUE);
}
else
else if ( (time > pCurrent->uiEnd)&&(pGapList->audio_gap_active == TRUE) )
{
// reset if already set
pGapList->audio_gap_active=(FALSE);
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Gap Ended at %d", time) );
}
}
else
{
pGapList->audio_gap_active=(FALSE);
pGapList->audio_gap_active=(FALSE);
}
}
@@ -258,7 +258,7 @@ UINT32 PlayJA2GapSample( CHAR8 *zSoundFile, UINT32 usRate, UINT32 ubVolume, UINT
memset(&spParms, 0xff, sizeof(SOUNDPARMS));
spParms.uiSpeed = usRate;
spParms.uiVolume = (UINT32) ( ( ubVolume / (FLOAT) HIGHVOLUME ) * GetSpeechVolume( ) );
spParms.uiVolume = (UINT32) ( ( ubVolume / (FLOAT) HIGHVOLUME ) * GetSpeechVolume( ) );
spParms.uiLoop = ubLoops;
spParms.uiPan = uiPan;
spParms.uiPriority=GROUP_PLAYER;
@@ -266,9 +266,10 @@ UINT32 PlayJA2GapSample( CHAR8 *zSoundFile, UINT32 usRate, UINT32 ubVolume, UINT
// Setup Gap Detection, if it is not null
if( pData != NULL )
AudioGapListInit( zSoundFile, pData );
return(SoundPlayStreamedFile( zSoundFile, &spParms));
}