mirror of
https://github.com/nzp-team/quakespasm.git
synced 2024-11-10 06:32:03 +00:00
Restored PF_GetSoundLen
This commit is contained in:
parent
2450734297
commit
47d84df458
1 changed files with 45 additions and 1 deletions
|
@ -1728,6 +1728,50 @@ void PF_changeyaw (void)
|
|||
ent->v.angles[1] = anglemod (current + move);
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
PF_GetSoundLen
|
||||
|
||||
Get the lenght of the sound (useful for things like radio)
|
||||
==============
|
||||
*/
|
||||
void PF_GetSoundLen (void)
|
||||
{
|
||||
|
||||
char *name;
|
||||
|
||||
name = G_STRING(OFS_PARM0);
|
||||
|
||||
char namebuffer[256];
|
||||
byte *data;
|
||||
wavinfo_t info;
|
||||
byte stackbuf[1*1024]; // avoid dirtying the cache heap
|
||||
|
||||
//Con_Printf ("S_LoadSound: %x\n", (int)stackbuf);
|
||||
// load it in
|
||||
Q_strcpy(namebuffer, "");
|
||||
Q_strcat(namebuffer, name);
|
||||
|
||||
data = COM_LoadStackFile(namebuffer, stackbuf, sizeof(stackbuf), NULL);
|
||||
|
||||
if (!data)
|
||||
{
|
||||
Con_Printf ("Couldn't load %s\n", namebuffer);
|
||||
G_FLOAT(OFS_RETURN) = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
info = GetWavinfo (name, data, com_filesize);
|
||||
if (info.channels != 1)
|
||||
{
|
||||
Con_Printf ("%s is a stereo sample\n",name);
|
||||
G_FLOAT(OFS_RETURN) = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
G_FLOAT(OFS_RETURN) = (float)info.samples/(float)info.rate;
|
||||
}
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
|
||||
|
@ -3170,7 +3214,7 @@ static builtin_t pr_builtin[] =
|
|||
PF_nextent, // #47
|
||||
PF_particle, // #48
|
||||
PF_changeyaw, // #49
|
||||
PF_Fixme, // #50
|
||||
PF_GetSoundLen, // #50 sB fixed :)
|
||||
PF_vectoangles, // #51
|
||||
PF_WriteByte, // #52
|
||||
PF_WriteChar, // #53
|
||||
|
|
Loading…
Reference in a new issue