env_sound: Initial commit.

This commit is contained in:
Marco Cawthorne 2019-03-13 21:56:43 +01:00
parent 2af78be51a
commit 7e74f7adec
13 changed files with 407 additions and 0 deletions

View file

@ -82,6 +82,8 @@ void CSQC_Init(float apilevel, string enginename, float engineversion)
HUD_Init();
Scores_Init();
Client_Init(apilevel, enginename, engineversion);
DSP_Init();
}
void CSQC_UpdateView(float w, float h, float focus)
@ -219,6 +221,7 @@ void CSQC_UpdateView(float w, float h, float focus)
Predict_PostFrame((player)self);
}
DSP_UpdateListener();
pSeat = (void*)0x70000000i;
if (needcursor) {
@ -587,6 +590,66 @@ float CSQC_Parse_CenterPrint(string sMessage)
return TRUE;
}
/*
=================
CSQC_Ent_ParseMapEntity
=================
*/
float CSQC_Ent_ParseMapEntity( void )
{
CBaseEntity eEnt = __NULL__;
string strField, strValue;
__fullspawndata = "";
int iClass = FALSE;
while ( 1 ) {
strField = getentitytoken();
if ( !strField ) {
break;
}
if ( strField == "}" ) {
if ( !eEnt.classname ) {
break;
}
if ( iClass == TRUE ) {
eEnt.Init();
return TRUE;
}
if ( eEnt ) {
remove( eEnt );
}
return TRUE;
}
strValue = getentitytoken();
if ( !strValue ) {
break;
}
switch ( strField ) {
case "classname":
/*if ( strValue == "env_cubemap" ) {
iClass = TRUE;
eEnt = spawn(CEnvCubemap);
} else */if ( strValue == "env_sound" ) {
eEnt = spawn(env_sound);
iClass = TRUE;
} else {
eEnt.classname = strValue;
}
break;
default:
__fullspawndata = sprintf( "%s\"%s\" \"%s\" ", __fullspawndata, strField, strValue );
break;
}
}
return FALSE;
}
/*
=================
CSQC_WorldLoaded
@ -609,6 +672,27 @@ void CSQC_WorldLoaded(void)
precache_pic("{scorch1", TRUE);
precache_pic("{scorch2", TRUE);
precache_pic("{scorch3", TRUE);
string strTokenized;
getentitytoken( 0 );
while ( 1 ) {
strTokenized = getentitytoken();
if ( strTokenized == "" ) {
break;
}
if ( strTokenized != "{" ) {
print("^1[WARNING] ^7Bad entity data\n");
return;
}
if ( !CSQC_Ent_ParseMapEntity() ) {
print("^1[WARNING] ^7Bad entity data\n");
return;
}
}
}
/*

View file

@ -1,5 +1,7 @@
#includelist
../gs-entbase/client/baseentity.cpp
../gs-entbase/client/fade.cpp
../gs-entbase/client/sprite.cpp
../gs-entbase/client/text.cpp
../gs-entbase/client/env_sound.cpp
#endlist

View file

@ -0,0 +1,70 @@
/***
*
* Copyright (c) 2016-2019 Marco 'eukara' Hladik. All rights reserved.
*
* See the file LICENSE attached with the sources for usage details.
*
****/
string __fullspawndata;
class CBaseEntity {
string targetname;
string target;
void() CBaseEntity;
virtual void() Init;
virtual void(string, string) SpawnKey;
};
void CBaseEntity :: SpawnKey (string strField, string strKey) {
switch ( strField ) {
case "targetname":
targetname = strKey;
break;
case "target":
target = strKey;
break;
case "origin":
origin = stov( strKey );
setorigin( this, origin );
break;
case "angles":
angles = stov( strKey );
break;
case "model":
model = strKey;
break;
case "style":
style = stof( strKey );
break;
case "color":
color = stov( strKey );
break;
case "movetype":
movetype = stof( strKey );
break;
case "solid":
solid = stof( strKey );
break;
case "scale":
scale = stof( strKey );
break;
default:
//dprint(sprintf("Unknown field %s, value %s\n", strField, strKey));
}
}
void CBaseEntity::Init(void)
{
for (int i = 0; i < (tokenize(__fullspawndata) - 1); i += 2) {
//dprint(sprintf("SpawnData: %s %s\n", argv(i), argv(i+1)));
SpawnKey(argv(i), argv(i+1));
}
}
void CBaseEntity::CBaseEntity(void)
{
Init();
}

View file

@ -0,0 +1,250 @@
/***
*
* Copyright (c) 2016-2019 Marco 'eukara' Hladik. All rights reserved.
*
* See the file LICENSE attached with the sources for usage details.
*
****/
int g_iDSP;
float g_flDSPCheck;
enum {
DSP_DEFAULT,
DSP_PADDEDCELL,
DSP_ROOM,
DSP_BATHROOM,
DSP_LIVINGROOM,
DSP_STONEROOM,
DSP_AUDITORIUM,
DSP_CONCERTHALL,
DSP_CAVE,
DSP_ARENA,
DSP_HANGAR,
DSP_CARPETEDHALLWAY,
DSP_HALLWAY,
DSP_STONECORRIDOR,
DSP_ALLEY,
DSP_FOREST,
DSP_CITY,
DSP_MOUNTAINS,
DSP_QUARRY,
DSP_PLAIN,
DSP_PARKINGLOT,
DSP_SEWERPIPE,
DSP_UNDERWATER,
DSP_DRUGGED,
DSP_DIZZY,
DSP_PSYCHOTIC,
DSP_CITYSTREETS,
DSP_SUBWAY,
DSP_MUSEUM,
DSP_LIBRARY,
DSP_UNDERPASS,
DSP_ABANDONED,
DSP_DUSTYROOM,
DSP_CHAPEL,
DSP_SMALLWATERROOM
};
reverbinfo_t reverbPresets [35] = {
{ 1.0000f, 1.0000f, 0.3162f, 0.8913f, 1.0000f, 1.4900f, 0.8300f, 1.0000f, 0.0500f, 0.0070f, [0,0,0], 1.2589f, 0.0110f, [0,0,0], 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 },
{ 0.1715f, 1.0000f, 0.3162f, 0.0010f, 1.0000f, 0.1700f, 0.1000f, 1.0000f, 0.2500f, 0.0010f, [0,0,0], 1.2691f, 0.0020f, [0,0,0], 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 },
{ 0.4287f, 1.0000f, 0.3162f, 0.5929f, 1.0000f, 0.4000f, 0.8300f, 1.0000f, 0.1503f, 0.0020f, [0,0,0], 1.0629f, 0.0030f, [0,0,0], 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 },
{ 0.1715f, 1.0000f, 0.3162f, 0.2512f, 1.0000f, 1.4900f, 0.5400f, 1.0000f, 0.6531f, 0.0070f, [0,0,0], 3.2734f, 0.0110f, [0,0,0], 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 },
{ 0.9766f, 1.0000f, 0.3162f, 0.0010f, 1.0000f, 0.5000f, 0.1000f, 1.0000f, 0.2051f, 0.0030f, [0,0,0], 0.2805f, 0.0040f, [0,0,0], 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 },
{ 1.0000f, 1.0000f, 0.3162f, 0.7079f, 1.0000f, 2.3100f, 0.6400f, 1.0000f, 0.4411f, 0.0120f, [0,0,0], 1.1003f, 0.0170f, [0,0,0], 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 },
{ 1.0000f, 1.0000f, 0.3162f, 0.5781f, 1.0000f, 4.3200f, 0.5900f, 1.0000f, 0.4032f, 0.0200f, [0,0,0], 0.7170f, 0.0300f, [0,0,0], 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 },
{ 1.0000f, 1.0000f, 0.3162f, 0.5623f, 1.0000f, 3.9200f, 0.7000f, 1.0000f, 0.2427f, 0.0200f, [0,0,0], 0.9977f, 0.0290f, [0,0,0], 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 },
{ 1.0000f, 1.0000f, 0.3162f, 1.0000f, 1.0000f, 2.9100f, 1.3000f, 1.0000f, 0.5000f, 0.0150f, [0,0,0], 0.7063f, 0.0220f, [0,0,0], 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 },
{ 1.0000f, 1.0000f, 0.3162f, 0.4477f, 1.0000f, 7.2400f, 0.3300f, 1.0000f, 0.2612f, 0.0200f, [0,0,0], 1.0186f, 0.0300f, [0,0,0], 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 },
{ 1.0000f, 1.0000f, 0.3162f, 0.3162f, 1.0000f, 10.0500f, 0.2300f, 1.0000f, 0.5000f, 0.0200f, [0,0,0], 1.2560f, 0.0300f, [0,0,0], 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 },
{ 0.4287f, 1.0000f, 0.3162f, 0.0100f, 1.0000f, 0.3000f, 0.1000f, 1.0000f, 0.1215f, 0.0020f, [0,0,0], 0.1531f, 0.0300f, [0,0,0], 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 },
{ 0.3645f, 1.0000f, 0.3162f, 0.7079f, 1.0000f, 1.4900f, 0.5900f, 1.0000f, 0.2458f, 0.0070f, [0,0,0], 1.6615f, 0.0110f, [0,0,0], 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 },
{ 1.0000f, 1.0000f, 0.3162f, 0.7612f, 1.0000f, 2.7000f, 0.7900f, 1.0000f, 0.2472f, 0.0130f, [0,0,0], 1.5758f, 0.0200f, [0,0,0], 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 },
{ 1.0000f, 0.3000f, 0.3162f, 0.7328f, 1.0000f, 1.4900f, 0.8600f, 1.0000f, 0.2500f, 0.0070f, [0,0,0], 0.9954f, 0.0110f, [0,0,0], 0.1250f, 0.9500f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 },
{ 1.0000f, 0.3000f, 0.3162f, 0.0224f, 1.0000f, 1.4900f, 0.5400f, 1.0000f, 0.0525f, 0.1620f, [0,0,0], 0.7682f, 0.0880f, [0,0,0], 0.1250f, 1.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 },
{ 1.0000f, 0.5000f, 0.3162f, 0.3981f, 1.0000f, 1.4900f, 0.6700f, 1.0000f, 0.0730f, 0.0070f, [0,0,0], 0.1427f, 0.0110f, [0,0,0], 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 },
{ 1.0000f, 0.2700f, 0.3162f, 0.0562f, 1.0000f, 1.4900f, 0.2100f, 1.0000f, 0.0407f, 0.3000f, [0,0,0], 0.1919f, 0.1000f, [0,0,0], 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 },
{ 1.0000f, 1.0000f, 0.3162f, 0.3162f, 1.0000f, 1.4900f, 0.8300f, 1.0000f, 0.0000f, 0.0610f, [0,0,0], 1.7783f, 0.0250f, [0,0,0], 0.1250f, 0.7000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 },
{ 1.0000f, 0.2100f, 0.3162f, 0.1000f, 1.0000f, 1.4900f, 0.5000f, 1.0000f, 0.0585f, 0.1790f, [0,0,0], 0.1089f, 0.1000f, [0,0,0], 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 },
{ 1.0000f, 1.0000f, 0.3162f, 1.0000f, 1.0000f, 1.6500f, 1.5000f, 1.0000f, 0.2082f, 0.0080f, [0,0,0], 0.2652f, 0.0120f, [0,0,0], 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 },
{ 0.3071f, 0.8000f, 0.3162f, 0.3162f, 1.0000f, 2.8100f, 0.1400f, 1.0000f, 1.6387f, 0.0140f, [0,0,0], 3.2471f, 0.0210f, [0,0,0], 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 },
{ 0.3645f, 1.0000f, 0.3162f, 0.0100f, 1.0000f, 1.4900f, 0.1000f, 1.0000f, 0.5963f, 0.0070f, [0,0,0], 7.0795f, 0.0110f, [0,0,0], 0.2500f, 0.0000f, 1.1800f, 0.3480f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 },
{ 0.4287f, 0.5000f, 0.3162f, 1.0000f, 1.0000f, 8.3900f, 1.3900f, 1.0000f, 0.8760f, 0.0020f, [0,0,0], 3.1081f, 0.0300f, [0,0,0], 0.2500f, 0.0000f, 0.2500f, 1.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 },
{ 0.3645f, 0.6000f, 0.3162f, 0.6310f, 1.0000f, 17.2300f, 0.5600f, 1.0000f, 0.1392f, 0.0200f, [0,0,0], 0.4937f, 0.0300f, [0,0,0], 0.2500f, 1.0000f, 0.8100f, 0.3100f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 },
{ 0.0625f, 0.5000f, 0.3162f, 0.8404f, 1.0000f, 7.5600f, 0.9100f, 1.0000f, 0.4864f, 0.0200f, [0,0,0], 2.4378f, 0.0300f, [0,0,0], 0.2500f, 0.0000f, 4.0000f, 1.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 },
{ 1.0000f, 0.7800f, 0.3162f, 0.7079f, 0.8913f, 1.7900f, 1.1200f, 0.9100f, 0.2818f, 0.0460f, [0,0,0], 0.1995f, 0.0280f, [0,0,0], 0.2500f, 0.2000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 },
{ 1.0000f, 0.7400f, 0.3162f, 0.7079f, 0.8913f, 3.0100f, 1.2300f, 0.9100f, 0.7079f, 0.0460f, [0,0,0], 1.2589f, 0.0280f, [0,0,0], 0.1250f, 0.2100f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 },
{ 1.0000f, 0.8200f, 0.3162f, 0.1778f, 0.1778f, 3.2800f, 1.4000f, 0.5700f, 0.2512f, 0.0390f, [0,0,0], 0.8913f, 0.0340f, [0,0,0], 0.1300f, 0.1700f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 107.5000f, 0.0000f, 0x0 },
{ 1.0000f, 0.8200f, 0.3162f, 0.2818f, 0.0891f, 2.7600f, 0.8900f, 0.4100f, 0.3548f, 0.0290f, [0,0,0], 0.8913f, 0.0200f, [0,0,0], 0.1300f, 0.1700f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 107.5000f, 0.0000f, 0x0 },
{ 1.0000f, 0.8200f, 0.3162f, 0.4467f, 0.8913f, 3.5700f, 1.1200f, 0.9100f, 0.3981f, 0.0590f, [0,0,0], 0.8913f, 0.0370f, [0,0,0], 0.2500f, 0.1400f, 0.2500f, 0.0000f, 0.9920f, 5000.0000f, 250.0000f, 0.0000f, 0x1 },
{ 1.0000f, 0.6900f, 0.3162f, 0.7943f, 0.8913f, 3.2800f, 1.1700f, 0.9100f, 0.4467f, 0.0440f, [0,0,0], 0.2818f, 0.0240f, [0,0,0], 0.2500f, 0.2000f, 0.2500f, 0.0000f, 0.9966f, 5000.0000f, 250.0000f, 0.0000f, 0x1 },
{ 0.3645f, 0.5600f, 0.3162f, 0.7943f, 0.7079f, 1.7900f, 0.3800f, 0.2100f, 0.5012f, 0.0020f, [0,0,0], 1.2589f, 0.0060f, [0,0,0], 0.2020f, 0.0500f, 0.2500f, 0.0000f, 0.9886f, 13046.0000f, 163.3000f, 0.0000f, 0x1 },
{ 1.0000f, 0.8400f, 0.3162f, 0.5623f, 1.0000f, 4.6200f, 0.6400f, 1.2300f, 0.4467f, 0.0320f, [0,0,0], 0.7943f, 0.0490f, [0,0,0], 0.2500f, 0.0000f, 0.2500f, 0.1100f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 },
{ 1.0000f, 0.7000f, 0.3162f, 0.4477f, 1.0000f, 1.5100f, 1.2500f, 1.1400f, 0.8913f, 0.0200f, [0,0,0], 1.4125f, 0.0300f, [0,0,0], 0.1790f, 0.1500f, 0.8950f, 0.1900f, 0.9920f, 5000.0000f, 250.0000f, 0.0000f, 0x0 }
};
class env_sound:CBaseEntity {
int m_iRoomType;
int m_iRadius;
void() env_sound;
virtual void() customphysics;
virtual void(string, string) SpawnKey;
};
void env_sound::customphysics(void)
{
int s = (float)getproperty(VF_ACTIVESEAT);
pSeat = &seats[s];
if (checkpvs(pSeat->vPlayerOrigin, this) == FALSE) {
return;
}
float fDist = vlen(pSeat->vPlayerOrigin - this.origin);
if (g_flDSPCheck > time) {
return;
}
other = world;
traceline(this.origin, pSeat->vPlayerOrigin, MOVE_OTHERONLY, this);
if (trace_fraction < 1.0f) {
return;
}
if (fDist <= m_iRadius) {
if (g_iDSP == m_iRoomType) {
return;
}
setup_reverb(12, &reverbPresets[m_iRoomType], sizeof(reverbinfo_t));
g_iDSP = m_iRoomType;
g_flDSPCheck = time + 0.5;
}
}
void env_sound::env_sound(void)
{
Init();
/* Valve BSP, convert their env_sound */
if (serverkeyfloat("*bspversion") == 30) {
switch(m_iRoomType) {
case 0:
case 1:
m_iRoomType = DSP_DEFAULT;
break;
case 2:
m_iRoomType = DSP_SEWERPIPE;
break;
case 3:
m_iRoomType = DSP_SEWERPIPE;
break;
case 4:
m_iRoomType = DSP_SEWERPIPE;
break;
case 5:
m_iRoomType = DSP_HALLWAY;
break;
case 6:
m_iRoomType = DSP_UNDERPASS;
break;
case 7:
m_iRoomType = DSP_SUBWAY;
break;
case 8:
m_iRoomType = DSP_BATHROOM;
break;
case 9:
m_iRoomType = DSP_LIVINGROOM;
break;
case 10:
m_iRoomType = DSP_AUDITORIUM;
break;
case 11:
m_iRoomType = DSP_QUARRY;
break;
case 12:
m_iRoomType = DSP_FOREST;
break;
case 13:
m_iRoomType = DSP_MOUNTAINS;
break;
case 14:
m_iRoomType = DSP_UNDERWATER;
break;
case 15:
m_iRoomType = DSP_UNDERWATER;
break;
case 16:
m_iRoomType = DSP_UNDERWATER;
break;
case 17:
m_iRoomType = DSP_PARKINGLOT;
break;
case 18:
m_iRoomType = DSP_CAVE;
break;
case 19:
m_iRoomType = DSP_ABANDONED;
break;
case 20:
m_iRoomType = DSP_CHAPEL;
break;
case 21:
m_iRoomType = DSP_CONCERTHALL;
break;
case 22:
m_iRoomType = DSP_MUSEUM;
break;
case 23:
m_iRoomType = DSP_CAVE;
break;
case 24:
m_iRoomType = DSP_CAVE;
break;
case 25:
m_iRoomType = DSP_CAVE;
break;
case 26:
m_iRoomType = DSP_DRUGGED;
break;
case 27:
m_iRoomType = DSP_DIZZY;
break;
case 28:
m_iRoomType = DSP_PSYCHOTIC;
break;
}
}
}
void env_sound::SpawnKey (string strField, string strKey)
{
switch (strField) {
case "roomtype":
m_iRoomType = stoi(strKey);
break;
case "radius":
m_iRadius = stoi(strKey);
break;
default:
CBaseEntity::SpawnKey(strField, strKey);
}
}
void DSP_Init(void)
{
g_iDSP = 0;
setup_reverb(12, &reverbPresets[g_iDSP], sizeof(reverbinfo_t));
setup_reverb(10, &reverbPresets[DSP_UNDERWATER], sizeof(reverbinfo_t));
}
void DSP_UpdateListener(void)
{
makevectors(getproperty(VF_CL_VIEWANGLES));
SetListener(getproperty(VF_ORIGIN), v_forward, v_right, v_up, 10);
}

View file

@ -28,6 +28,7 @@ void info_notnull :: info_notnull ( void )
CLASSEXPORT( info_node, info_notnull )
CLASSEXPORT( info_target, info_notnull )
CLASSEXPORT( env_sound, info_null )
/*class CSuit : CBaseTrigger
{

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.