Exemple #1
0
void CG_PrecacheNPCSounds( const char *str ) {
	char sEnd[MAX_QPATH], pEnd[MAX_QPATH];
	int i, j, k;

	k = 2;
	while ( str[k] ) {
		pEnd[k - 2] = str[k];
		k++;
	}
	pEnd[k - 2] = '\0';

	for ( i = 0; i < 4; i++ ) {
		// It would be better if we knew what type this actually was (extra, combat, jedi, etc).
		//	But that would require extra configstring indexing and that is a bad thing.
		for ( j = 0; j < MAX_CUSTOM_SOUNDS; j++ ) {
			const char *s = GetCustomSoundForType( i + 1, j );

			if ( s && s[0] ) {
				// whatever it is, try registering it under this folder.
				k = 1;
				while ( s[k] ) {
					sEnd[k - 1] = s[k];
					k++;
				}
				sEnd[k - 1] = '\0';

				trap->S_Shutup( qtrue );
				trap->S_RegisterSound( va( "sound/chars/%s/misc/%s", pEnd, sEnd ) );
				trap->S_Shutup( qfalse );
			}
			else
				break;
		}
	}
}
void CG_PrecacheNPCSounds(const char *str)
{
	char sEnd[MAX_QPATH];
	char pEnd[MAX_QPATH];
	int i = 0;
	int j = 0;
	int k = 0;

	k = 2;

	while (str[k])
	{
		pEnd[k-2] = str[k];
		k++;
	}
	pEnd[k-2] = 0;

	while (i < 4) //4 types
	{ //It would be better if we knew what type this actually was (extra, combat, jedi, etc).
	  //But that would require extra configstring indexing and that is a bad thing.

		while (j < MAX_CUSTOM_SOUNDS)
		{
			const char *s = GetCustomSoundForType(i+1, j);

			if (s && s[0])
			{ //whatever it is, try registering it under this folder.
				k = 1;
				while (s[k])
				{
					sEnd[k-1] = s[k];
					k++;
				}
				sEnd[k-1] = 0;

				trap_S_ShutUp(qtrue);
				trap_S_RegisterSound( va("sound/chars/%s/misc/%s", pEnd, sEnd) );
				trap_S_ShutUp(qfalse);
			}
			else
			{ //move onto the next set
				break;
			}

			j++;
		}

		j = 0;
		i++;
	}
}
Exemple #3
0
static void CG_RegisterCustomSounds(clientInfo_t *ci, int setType, const char *psDir)
{
	int iTableEntries = 0;
	int i;

	switch (setType)
	{
	case 1:
		iTableEntries = MAX_CUSTOM_SOUNDS;
		break;
	case 2:
		iTableEntries = MAX_CUSTOM_COMBAT_SOUNDS;
		break;
	case 3:
		iTableEntries = MAX_CUSTOM_EXTRA_SOUNDS;
		break;
	case 4:
		iTableEntries = MAX_CUSTOM_JEDI_SOUNDS;
		break;
	case 5:
		iTableEntries = MAX_CUSTOM_SIEGE_SOUNDS;
	default:
		assert(0);
		return;
	}

	for ( i = 0 ; i<iTableEntries; i++ )
	{
		sfxHandle_t hSFX;
		const char *s = GetCustomSoundForType(setType, i);

		if ( !s )
		{
			break;
		}

		s++;
		hSFX = trap->S_RegisterSound( va("sound/chars/%s/misc/%s", psDir, s) );

		if (hSFX == 0)
		{
			char modifiedSound[MAX_QPATH];
			char *p;

			strcpy(modifiedSound, s);
			p = strchr(modifiedSound,'.');

			if (p)
			{
				char testNumber[2];
				p--;

				//before we destroy it.. we want to see if this is actually a number.
				//If it isn't a number then don't try decrementing and registering as
				//it will only cause a disk hit (we don't try precaching such files)
				testNumber[0] = *p;
				testNumber[1] = 0;
				if (atoi(testNumber))
				{
					*p = 0;

					strcat(modifiedSound, "1.wav");

					hSFX = trap->S_RegisterSound( va("sound/chars/%s/misc/%s", psDir, modifiedSound) );
				}
			}
		}

		SetCustomSoundForType(ci, setType, i, hSFX);
	}
}