17 Sep 2010

This commit is contained in:
g-cont 2010-09-17 00:00:00 +04:00 committed by Alibek Omarov
parent c44aba6a7d
commit ed98f35b45
30 changed files with 8487 additions and 1697 deletions

View File

@ -1,8 +1,13 @@
build ????
build 1313
Launch: code revision, remove dead code, implement some missed functions
Sound: fix some errors and crash
Sound: implement music volume
Sound: reworking sound mixer
Sound: implement DSP
Engine: add support for five mouse extra-buttons
Engine: fix some physics bugs
SDK: add blue-shift game source to SDK (combined with main game source)
build 1305

705
dlls/bshift.dsp Normal file
View File

@ -0,0 +1,705 @@
# Microsoft Developer Studio Project File - Name="bshift" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
CFG=bshift - Win32 Release
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "bshift.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "bshift.mak" CFG="bshift - Win32 Release"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "bshift - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE "bshift - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "bshift - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir ".\Release"
# PROP BASE Intermediate_Dir ".\Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "..\temp\bshift\!release"
# PROP Intermediate_Dir "..\temp\bshift\!release"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\dlls" /I "..\common" /I "..\game_shared" /I "..\\" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "BSHIFT_DLL" /FD /c
# SUBTRACT CPP /Fr /YX
# ADD BASE MTL /nologo /D "NDEBUG" /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386
# ADD LINK32 msvcrt.lib /nologo /subsystem:windows /dll /pdb:none /machine:I386 /nodefaultlib:"libc.lib" /def:".\hl.def" /out:"..\temp\bshift\!release/hl.dll"
# SUBTRACT LINK32 /profile /map /debug
# Begin Custom Build
TargetDir=\Xash3D\src_main\temp\bshift\!release
InputPath=\Xash3D\src_main\temp\bshift\!release\hl.dll
SOURCE="$(InputPath)"
"D:\Xash3D\bshift\bin\server.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy $(TargetDir)\hl.dll "D:\Xash3D\bshift\bin\server.dll"
# End Custom Build
!ELSEIF "$(CFG)" == "bshift - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir ".\hl___Win"
# PROP BASE Intermediate_Dir ".\hl___Win"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "..\temp\bshift\!debug"
# PROP Intermediate_Dir "..\temp\bshift\!debug"
# PROP Ignore_Export_Lib 1
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\dlls" /I "..\common" /I "..\game_shared" /I "..\\" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "BSHIFT_DLL" /FR /FD /c
# SUBTRACT CPP /YX
# ADD BASE MTL /nologo /D "_DEBUG" /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386
# ADD LINK32 msvcrtd.lib /nologo /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc.lib" /def:".\hl.def" /out:"..\temp\bshift\!debug/hl.dll" /pdbtype:sept
# SUBTRACT LINK32 /profile
# Begin Custom Build
TargetDir=\Xash3D\src_main\temp\bshift\!debug
InputPath=\Xash3D\src_main\temp\bshift\!debug\hl.dll
SOURCE="$(InputPath)"
"D:\Xash3D\bshift\bin\server.dll" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
copy $(TargetDir)\hl.dll "D:\Xash3D\bshift\bin\server.dll"
# End Custom Build
!ENDIF
# Begin Target
# Name "bshift - Win32 Release"
# Name "bshift - Win32 Debug"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90"
# Begin Source File
SOURCE=.\aflock.cpp
# End Source File
# Begin Source File
SOURCE=.\agrunt.cpp
# End Source File
# Begin Source File
SOURCE=.\airtank.cpp
# End Source File
# Begin Source File
SOURCE=.\animating.cpp
# End Source File
# Begin Source File
SOURCE=.\animation.cpp
# End Source File
# Begin Source File
SOURCE=.\apache.cpp
# End Source File
# Begin Source File
SOURCE=.\barnacle.cpp
# End Source File
# Begin Source File
SOURCE=.\barney.cpp
# End Source File
# Begin Source File
SOURCE=.\bigmomma.cpp
# End Source File
# Begin Source File
SOURCE=.\bloater.cpp
# End Source File
# Begin Source File
SOURCE=.\bmodels.cpp
# End Source File
# Begin Source File
SOURCE=.\bullsquid.cpp
# End Source File
# Begin Source File
SOURCE=.\buttons.cpp
# End Source File
# Begin Source File
SOURCE=.\cbase.cpp
# End Source File
# Begin Source File
SOURCE=.\client.cpp
# End Source File
# Begin Source File
SOURCE=.\combat.cpp
# End Source File
# Begin Source File
SOURCE=.\controller.cpp
# End Source File
# Begin Source File
SOURCE=.\crossbow.cpp
# End Source File
# Begin Source File
SOURCE=.\crowbar.cpp
# End Source File
# Begin Source File
SOURCE=.\defaultai.cpp
# End Source File
# Begin Source File
SOURCE=.\doors.cpp
# End Source File
# Begin Source File
SOURCE=.\effects.cpp
# End Source File
# Begin Source File
SOURCE=.\egon.cpp
# End Source File
# Begin Source File
SOURCE=.\explode.cpp
# End Source File
# Begin Source File
SOURCE=.\flyingmonster.cpp
# End Source File
# Begin Source File
SOURCE=.\func_break.cpp
# End Source File
# Begin Source File
SOURCE=.\func_tank.cpp
# End Source File
# Begin Source File
SOURCE=.\game.cpp
# End Source File
# Begin Source File
SOURCE=.\gamerules.cpp
# End Source File
# Begin Source File
SOURCE=.\gargantua.cpp
# End Source File
# Begin Source File
SOURCE=.\gauss.cpp
# End Source File
# Begin Source File
SOURCE=.\genericmonster.cpp
# End Source File
# Begin Source File
SOURCE=.\ggrenade.cpp
# End Source File
# Begin Source File
SOURCE=.\globals.cpp
# End Source File
# Begin Source File
SOURCE=.\glock.cpp
# End Source File
# Begin Source File
SOURCE=.\gman.cpp
# End Source File
# Begin Source File
SOURCE=.\h_ai.cpp
# End Source File
# Begin Source File
SOURCE=.\h_battery.cpp
# End Source File
# Begin Source File
SOURCE=.\h_cine.cpp
# End Source File
# Begin Source File
SOURCE=.\h_cycler.cpp
# End Source File
# Begin Source File
SOURCE=.\h_export.cpp
# End Source File
# Begin Source File
SOURCE=.\handgrenade.cpp
# End Source File
# Begin Source File
SOURCE=.\hassassin.cpp
# End Source File
# Begin Source File
SOURCE=.\headcrab.cpp
# End Source File
# Begin Source File
SOURCE=.\healthkit.cpp
# End Source File
# Begin Source File
SOURCE=.\hgrunt.cpp
# End Source File
# Begin Source File
SOURCE=.\hornet.cpp
# End Source File
# Begin Source File
SOURCE=.\hornetgun.cpp
# End Source File
# Begin Source File
SOURCE=.\houndeye.cpp
# End Source File
# Begin Source File
SOURCE=.\ichthyosaur.cpp
# End Source File
# Begin Source File
SOURCE=.\islave.cpp
# End Source File
# Begin Source File
SOURCE=.\items.cpp
# End Source File
# Begin Source File
SOURCE=.\leech.cpp
# End Source File
# Begin Source File
SOURCE=.\lights.cpp
# End Source File
# Begin Source File
SOURCE=.\maprules.cpp
# End Source File
# Begin Source File
SOURCE=.\monstermaker.cpp
# End Source File
# Begin Source File
SOURCE=.\monsters.cpp
# End Source File
# Begin Source File
SOURCE=.\monsterstate.cpp
# End Source File
# Begin Source File
SOURCE=.\mortar.cpp
# End Source File
# Begin Source File
SOURCE=.\mp5.cpp
# End Source File
# Begin Source File
SOURCE=.\multiplay_gamerules.cpp
# End Source File
# Begin Source File
SOURCE=.\nihilanth.cpp
# End Source File
# Begin Source File
SOURCE=.\nodes.cpp
# End Source File
# Begin Source File
SOURCE=.\osprey.cpp
# End Source File
# Begin Source File
SOURCE=.\pathcorner.cpp
# End Source File
# Begin Source File
SOURCE=.\plane.cpp
# End Source File
# Begin Source File
SOURCE=.\plats.cpp
# End Source File
# Begin Source File
SOURCE=.\player.cpp
# End Source File
# Begin Source File
SOURCE=..\game_shared\pm_debug.cpp
# End Source File
# Begin Source File
SOURCE=..\game_shared\pm_math.cpp
# End Source File
# Begin Source File
SOURCE=..\game_shared\pm_shared.cpp
# End Source File
# Begin Source File
SOURCE=.\python.cpp
# End Source File
# Begin Source File
SOURCE=.\rat.cpp
# End Source File
# Begin Source File
SOURCE=.\roach.cpp
# End Source File
# Begin Source File
SOURCE=.\rpg.cpp
# End Source File
# Begin Source File
SOURCE=.\satchel.cpp
# End Source File
# Begin Source File
SOURCE=.\schedule.cpp
# End Source File
# Begin Source File
SOURCE=.\scientist.cpp
# End Source File
# Begin Source File
SOURCE=.\scripted.cpp
# End Source File
# Begin Source File
SOURCE=.\shotgun.cpp
# End Source File
# Begin Source File
SOURCE=.\singleplay_gamerules.cpp
# End Source File
# Begin Source File
SOURCE=.\skill.cpp
# End Source File
# Begin Source File
SOURCE=.\sound.cpp
# End Source File
# Begin Source File
SOURCE=.\soundent.cpp
# End Source File
# Begin Source File
SOURCE=.\spectator.cpp
# End Source File
# Begin Source File
SOURCE=.\squadmonster.cpp
# End Source File
# Begin Source File
SOURCE=.\squeakgrenade.cpp
# End Source File
# Begin Source File
SOURCE=.\subs.cpp
# End Source File
# Begin Source File
SOURCE=.\talkmonster.cpp
# End Source File
# Begin Source File
SOURCE=.\teamplay_gamerules.cpp
# End Source File
# Begin Source File
SOURCE=.\tempmonster.cpp
# End Source File
# Begin Source File
SOURCE=.\tentacle.cpp
# End Source File
# Begin Source File
SOURCE=.\triggers.cpp
# End Source File
# Begin Source File
SOURCE=.\tripmine.cpp
# End Source File
# Begin Source File
SOURCE=.\turret.cpp
# End Source File
# Begin Source File
SOURCE=.\util.cpp
# End Source File
# Begin Source File
SOURCE=.\weapons.cpp
# End Source File
# Begin Source File
SOURCE=.\world.cpp
# End Source File
# Begin Source File
SOURCE=.\xen.cpp
# End Source File
# Begin Source File
SOURCE=.\zombie.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
# Begin Source File
SOURCE=.\activity.h
# End Source File
# Begin Source File
SOURCE=.\activitymap.h
# End Source File
# Begin Source File
SOURCE=.\animation.h
# End Source File
# Begin Source File
SOURCE=.\basemonster.h
# End Source File
# Begin Source File
SOURCE=.\cbase.h
# End Source File
# Begin Source File
SOURCE=.\cdll_dll.h
# End Source File
# Begin Source File
SOURCE=.\client.h
# End Source File
# Begin Source File
SOURCE=.\decals.h
# End Source File
# Begin Source File
SOURCE=.\defaultai.h
# End Source File
# Begin Source File
SOURCE=.\doors.h
# End Source File
# Begin Source File
SOURCE=.\effects.h
# End Source File
# Begin Source File
SOURCE=..\engine\eiface.h
# End Source File
# Begin Source File
SOURCE=.\enginecallback.h
# End Source File
# Begin Source File
SOURCE=.\explode.h
# End Source File
# Begin Source File
SOURCE=.\extdll.h
# End Source File
# Begin Source File
SOURCE=.\flyingmonster.h
# End Source File
# Begin Source File
SOURCE=.\func_break.h
# End Source File
# Begin Source File
SOURCE=.\gamerules.h
# End Source File
# Begin Source File
SOURCE=.\hornet.h
# End Source File
# Begin Source File
SOURCE=.\items.h
# End Source File
# Begin Source File
SOURCE=.\monsterevent.h
# End Source File
# Begin Source File
SOURCE=.\monsters.h
# End Source File
# Begin Source File
SOURCE=.\nodes.h
# End Source File
# Begin Source File
SOURCE=.\plane.h
# End Source File
# Begin Source File
SOURCE=.\player.h
# End Source File
# Begin Source File
SOURCE=..\game_shared\pm_debug.h
# End Source File
# Begin Source File
SOURCE=..\game_shared\pm_defs.h
# End Source File
# Begin Source File
SOURCE=..\game_shared\pm_info.h
# End Source File
# Begin Source File
SOURCE=..\game_shared\pm_materials.h
# End Source File
# Begin Source File
SOURCE=..\game_shared\pm_movevars.h
# End Source File
# Begin Source File
SOURCE=..\game_shared\pm_shared.h
# End Source File
# Begin Source File
SOURCE=.\saverestore.h
# End Source File
# Begin Source File
SOURCE=.\schedule.h
# End Source File
# Begin Source File
SOURCE=.\scripted.h
# End Source File
# Begin Source File
SOURCE=.\scriptevent.h
# End Source File
# Begin Source File
SOURCE=.\skill.h
# End Source File
# Begin Source File
SOURCE=.\soundent.h
# End Source File
# Begin Source File
SOURCE=.\spectator.h
# End Source File
# Begin Source File
SOURCE=.\squadmonster.h
# End Source File
# Begin Source File
SOURCE=.\talkmonster.h
# End Source File
# Begin Source File
SOURCE=.\teamplay_gamerules.h
# End Source File
# Begin Source File
SOURCE=.\trains.h
# End Source File
# Begin Source File
SOURCE=.\util.h
# End Source File
# Begin Source File
SOURCE=.\vector.h
# End Source File
# Begin Source File
SOURCE=.\weapons.h
# End Source File
# End Group
# Begin Group "Resource Files"
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
# End Group
# End Target
# End Project

View File

@ -2265,4 +2265,122 @@ void CItemSoda::CanTouch ( CBaseEntity *pOther )
SetTouch ( NULL );
SetThink ( SUB_Remove );
pev->nextthink = gpGlobals->time;
}
}
#ifdef BSHIFT_DLL
//=========================================================
// env_warpball
//=========================================================
#define SF_REMOVE_ON_FIRE 0x0001
#define SF_KILL_CENTER 0x0002
class CEnvWarpBall : public CBaseEntity
{
public:
void Precache( void );
void Spawn( void ) { Precache(); }
void Think( void );
void KeyValue( KeyValueData *pkvd );
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
virtual int ObjectCaps( void ) { return CBaseEntity :: ObjectCaps() & ~FCAP_ACROSS_TRANSITION; }
Vector vecOrigin;
};
LINK_ENTITY_TO_CLASS( env_warpball, CEnvWarpBall );
void CEnvWarpBall :: KeyValue( KeyValueData *pkvd )
{
if (FStrEq(pkvd->szKeyName, "radius"))
{
pev->button = atoi(pkvd->szValue);
pkvd->fHandled = TRUE;
}
if (FStrEq(pkvd->szKeyName, "warp_target"))
{
pev->message = ALLOC_STRING(pkvd->szValue);
pkvd->fHandled = TRUE;
}
if (FStrEq(pkvd->szKeyName, "damage_delay"))
{
pev->frags = atof(pkvd->szValue);
pkvd->fHandled = TRUE;
}
else
CBaseEntity::KeyValue( pkvd );
}
void CEnvWarpBall::Precache( void )
{
PRECACHE_MODEL( "sprites/lgtning.spr" );
PRECACHE_MODEL( "sprites/Fexplo1.spr" );
PRECACHE_SOUND( "debris/beamstart2.wav" );
PRECACHE_SOUND( "debris/beamstart7.wav" );
}
void CEnvWarpBall::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
int iTimes = 0;
int iDrawn = 0;
TraceResult tr;
Vector vecDest;
CBeam *pBeam;
CBaseEntity *pEntity = UTIL_FindEntityByTargetname ( NULL, STRING(pev->message));
edict_t *pos;
if(pEntity)//target found ?
{
vecOrigin = pEntity->pev->origin;
pos = pEntity->edict();
}
else
{ //use as center
vecOrigin = pev->origin;
pos = edict();
}
EMIT_SOUND( pos, CHAN_BODY, "debris/beamstart2.wav", 1, ATTN_NORM );
UTIL_ScreenShake( vecOrigin, 6, 160, 1.0, pev->button );
CSprite *pSpr = CSprite::SpriteCreate( "sprites/Fexplo1.spr", vecOrigin, TRUE );
pSpr->AnimateAndDie( 18 );
pSpr->SetTransparency(kRenderGlow, 77, 210, 130, 255, kRenderFxNoDissipation);
EMIT_SOUND( pos, CHAN_ITEM, "debris/beamstart7.wav", 1, ATTN_NORM );
int iBeams = RANDOM_LONG(20, 40);
while (iDrawn < iBeams && iTimes < (iBeams * 3))
{
vecDest = pev->button * (Vector(RANDOM_FLOAT(-1,1), RANDOM_FLOAT(-1,1), RANDOM_FLOAT(-1,1)).Normalize());
UTIL_TraceLine( vecOrigin, vecOrigin + vecDest, ignore_monsters, NULL, &tr);
if (tr.flFraction != 1.0)
{
// we hit something.
iDrawn++;
pBeam = CBeam::BeamCreate("sprites/lgtning.spr", 200);
pBeam->PointsInit( vecOrigin, tr.vecEndPos );
pBeam->SetColor( 20, 243, 20 );
pBeam->SetNoise( 65 );
pBeam->SetBrightness( 220 );
pBeam->SetWidth( 30 );
pBeam->SetScrollRate( 35 );
pBeam->SetThink(&CBeam:: SUB_Remove );
pBeam->pev->nextthink = gpGlobals->time + RANDOM_FLOAT(0.5, 1.6);
}
iTimes++;
}
pev->nextthink = gpGlobals->time + pev->frags;
}
void CEnvWarpBall::Think( void )
{
SUB_UseTargets( this, USE_TOGGLE, 0);
if ( pev->spawnflags & SF_KILL_CENTER )
{
CBaseEntity *pMonster = NULL;
while ((pMonster = UTIL_FindEntityInSphere( pMonster, vecOrigin, 72 )) != NULL)
{
if ( FBitSet( pMonster->pev->flags, FL_MONSTER ) || FClassnameIs( pMonster->pev, "player"))
pMonster->TakeDamage ( pev, pev, 100, DMG_GENERIC );
}
}
if ( pev->spawnflags & SF_REMOVE_ON_FIRE ) UTIL_Remove( this );
}
#endif

View File

@ -20,15 +20,17 @@
#include "cbase.h"
#include "monsters.h"
#include "schedule.h"
#include "talkmonster.h"
// For holograms, make them not solid so the player can walk through them
#define SF_GENERICMONSTER_NOTSOLID 4
#define SF_GENERICMONSTER_NOTSOLID 4
#define SF_HEAD_CONTROLLER 8
//=========================================================
// Monster's Anim Events Go Here
//=========================================================
class CGenericMonster : public CBaseMonster
class CGenericMonster : public CTalkMonster
{
public:
void Spawn( void );
@ -120,6 +122,11 @@ void CGenericMonster :: Spawn()
MonsterInit();
if ( pev->spawnflags & SF_HEAD_CONTROLLER )
{
m_afCapability = bits_CAP_TURN_HEAD;
}
if ( pev->spawnflags & SF_GENERICMONSTER_NOTSOLID )
{
pev->solid = SOLID_NOT;
@ -132,6 +139,8 @@ void CGenericMonster :: Spawn()
//=========================================================
void CGenericMonster :: Precache()
{
CTalkMonster::Precache();
TalkInit();
PRECACHE_MODEL( (char *)STRING(pev->model) );
}

View File

@ -340,3 +340,72 @@ class CItemLongJump : public CItem
};
LINK_ENTITY_TO_CLASS( item_longjump, CItemLongJump );
#ifdef BSHIFT_DLL
class CItemArmorVest : public CItem
{
void Spawn( void )
{
Precache( );
SET_MODEL(ENT(pev), "models/barney_vest.mdl");
CItem::Spawn( );
}
void Precache( void )
{
PRECACHE_MODEL ("models/barney_vest.mdl");
PRECACHE_SOUND( "items/gunpickup2.wav" );
}
BOOL MyTouch( CBasePlayer *pPlayer )
{
if ((pPlayer->pev->armorvalue < MAX_NORMAL_BATTERY) &&
(pPlayer->pev->weapons & (1<<WEAPON_SUIT)))
{
pPlayer->pev->armorvalue += 60;
pPlayer->pev->armorvalue = min(pPlayer->pev->armorvalue, MAX_NORMAL_BATTERY);
EMIT_SOUND( pPlayer->edict(), CHAN_ITEM, "items/gunpickup2.wav", 1, ATTN_NORM );
MESSAGE_BEGIN( MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev );
WRITE_STRING( STRING(pev->classname) );
MESSAGE_END();
return TRUE;
}
return FALSE;
}
};
LINK_ENTITY_TO_CLASS(item_armorvest, CItemArmorVest);
class CItemHelmet : public CItem
{
void Spawn( void )
{
Precache( );
SET_MODEL(ENT(pev), "models/barney_helmet.mdl");
CItem::Spawn( );
}
void Precache( void )
{
PRECACHE_MODEL ("models/barney_helmet.mdl");
PRECACHE_SOUND( "items/gunpickup2.wav" );
}
BOOL MyTouch( CBasePlayer *pPlayer )
{
if ((pPlayer->pev->armorvalue < MAX_NORMAL_BATTERY) &&
(pPlayer->pev->weapons & (1<<WEAPON_SUIT)))
{
pPlayer->pev->armorvalue += 40;
pPlayer->pev->armorvalue = min(pPlayer->pev->armorvalue, MAX_NORMAL_BATTERY);
EMIT_SOUND( pPlayer->edict(), CHAN_ITEM, "items/gunpickup2.wav", 1, ATTN_NORM );
MESSAGE_BEGIN( MSG_ONE, gmsgItemPickup, NULL, pPlayer->pev );
WRITE_STRING( STRING(pev->classname) );
MESSAGE_END();
return TRUE;
}
return FALSE;
}
};
LINK_ENTITY_TO_CLASS(item_helmet, CItemHelmet);
#endif

View File

@ -115,6 +115,10 @@ private:
LINK_ENTITY_TO_CLASS( monster_scientist, CScientist );
#ifdef BSHIFT_DLL
LINK_ENTITY_TO_CLASS( monster_rosenberg, CScientist );
#endif
TYPEDESCRIPTION CScientist::m_SaveData[] =
{
DEFINE_FIELD( CScientist, m_painTime, FIELD_TIME ),
@ -428,7 +432,9 @@ void CScientist::DeclineFollowing( void )
{
Talk( 10 );
m_hTalkTarget = m_hEnemy;
PlaySentence( "SC_POK", 2, VOL_NORM, ATTN_NORM );
if ( FClassnameIs(pev, "monster_rosenberg"))
PlaySentence( "RO_POK", 2, VOL_NORM, ATTN_NORM );
else PlaySentence( "SC_POK", 2, VOL_NORM, ATTN_NORM );
}
@ -438,7 +444,9 @@ void CScientist :: Scream( void )
{
Talk( 10 );
m_hTalkTarget = m_hEnemy;
PlaySentence( "SC_SCREAM", RANDOM_FLOAT(3, 6), VOL_NORM, ATTN_NORM );
if ( FClassnameIs(pev, "monster_rosenberg"))
PlaySentence( "RO_SCREAM", RANDOM_FLOAT(3, 6), VOL_NORM, ATTN_NORM );
else PlaySentence( "SC_SCREAM", RANDOM_FLOAT(3, 6), VOL_NORM, ATTN_NORM );
}
}
@ -459,7 +467,9 @@ void CScientist :: StartTask( Task_t *pTask )
// if ( FOkToSpeak() )
Talk( 2 );
m_hTalkTarget = m_hTargetEnt;
PlaySentence( "SC_HEAL", 2, VOL_NORM, ATTN_IDLE );
if ( FClassnameIs(pev, "monster_rosenberg"))
PlaySentence( "RO_HEAL", 2, VOL_NORM, ATTN_IDLE );
else PlaySentence( "SC_HEAL", 2, VOL_NORM, ATTN_IDLE );
TaskComplete();
break;
@ -480,10 +490,16 @@ void CScientist :: StartTask( Task_t *pTask )
{
Talk( 2 );
m_hTalkTarget = m_hEnemy;
if ( m_hEnemy->IsPlayer() )
PlaySentence( "SC_PLFEAR", 5, VOL_NORM, ATTN_NORM );
if ( FClassnameIs(pev, "monster_rosenberg"))
{
PlaySentence( "RO_FEAR", 5, VOL_NORM, ATTN_NORM );
}
else
PlaySentence( "SC_FEAR", 5, VOL_NORM, ATTN_NORM );
{
if ( m_hEnemy->IsPlayer() )
PlaySentence( "SC_PLFEAR", 5, VOL_NORM, ATTN_NORM );
else PlaySentence( "SC_FEAR", 5, VOL_NORM, ATTN_NORM );
}
}
TaskComplete();
break;
@ -664,7 +680,11 @@ void CScientist :: Spawn( void )
pev->solid = SOLID_SLIDEBOX;
pev->movetype = MOVETYPE_STEP;
m_bloodColor = BLOOD_COLOR_RED;
pev->health = gSkillData.scientistHealth;
if ( FClassnameIs(pev, "monster_rosenberg"))
pev->health = gSkillData.scientistHealth * 2;
else pev->health = gSkillData.scientistHealth;
pev->view_ofs = Vector ( 0, 0, 50 );// position of the eyes relative to monster's origin.
m_flFieldOfView = VIEW_FIELD_WIDE; // NOTE: we need a wide field of view so scientists will notice player and say hello
m_MonsterState = MONSTERSTATE_NONE;
@ -700,7 +720,9 @@ void CScientist :: Precache( void )
PRECACHE_SOUND("scientist/sci_pain3.wav");
PRECACHE_SOUND("scientist/sci_pain4.wav");
PRECACHE_SOUND("scientist/sci_pain5.wav");
#ifdef BSHIFT_DLL
PRECACHE_SOUND("rosenberg/ro_pain1.wav");
#endif
// every new scientist must call this, otherwise
// when a level is loaded, nobody will talk (time is reset to 0)
TalkInit();
@ -722,27 +744,55 @@ void CScientist :: TalkInit()
// scientists speach group names (group names are in sentences.txt)
m_szGrp[TLK_ANSWER] = "SC_ANSWER";
m_szGrp[TLK_QUESTION] = "SC_QUESTION";
m_szGrp[TLK_IDLE] = "SC_IDLE";
m_szGrp[TLK_STARE] = "SC_STARE";
m_szGrp[TLK_USE] = "SC_OK";
m_szGrp[TLK_UNUSE] = "SC_WAIT";
m_szGrp[TLK_STOP] = "SC_STOP";
m_szGrp[TLK_NOSHOOT] = "SC_SCARED";
m_szGrp[TLK_HELLO] = "SC_HELLO";
// scientists speach group names (group names are in sentences.txt)
if ( FClassnameIs(pev, "monster_rosenberg"))
{
m_szGrp[TLK_ANSWER] = "RO_ANSWER";
m_szGrp[TLK_QUESTION] = "RO_QUESTION";
m_szGrp[TLK_IDLE] = "RO_IDLE";
m_szGrp[TLK_STARE] = "RO_STARE";
m_szGrp[TLK_USE] = "RO_OK";
m_szGrp[TLK_UNUSE] = "RO_WAIT";
m_szGrp[TLK_STOP] = "RO_STOP";
m_szGrp[TLK_NOSHOOT] = "RO_SCARED";
m_szGrp[TLK_HELLO] = "RO_HELLO";
m_szGrp[TLK_PLHURT1] = "!SC_CUREA";
m_szGrp[TLK_PLHURT2] = "!SC_CUREB";
m_szGrp[TLK_PLHURT3] = "!SC_CUREC";
m_szGrp[TLK_PLHURT1] = "!RO_CUREA";
m_szGrp[TLK_PLHURT2] = "!RO_CUREB";
m_szGrp[TLK_PLHURT3] = "!RO_CUREC";
m_szGrp[TLK_PHELLO] = "SC_PHELLO";
m_szGrp[TLK_PIDLE] = "SC_PIDLE";
m_szGrp[TLK_PQUESTION] = "SC_PQUEST";
m_szGrp[TLK_SMELL] = "SC_SMELL";
m_szGrp[TLK_PHELLO] = "RO_PHELLO";
m_szGrp[TLK_PIDLE] = "RO_PIDLE";
m_szGrp[TLK_PQUESTION] = "RO_PQUEST";
m_szGrp[TLK_SMELL] = "RO_SMELL";
m_szGrp[TLK_WOUND] = "SC_WOUND";
m_szGrp[TLK_MORTAL] = "SC_MORTAL";
m_szGrp[TLK_WOUND] = "RO_WOUND";
m_szGrp[TLK_MORTAL] = "RO_MORTAL";
}
else
{
m_szGrp[TLK_ANSWER] = "SC_ANSWER";
m_szGrp[TLK_QUESTION] = "SC_QUESTION";
m_szGrp[TLK_IDLE] = "SC_IDLE";
m_szGrp[TLK_STARE] = "SC_STARE";
m_szGrp[TLK_USE] = "SC_OK";
m_szGrp[TLK_UNUSE] = "SC_WAIT";
m_szGrp[TLK_STOP] = "SC_STOP";
m_szGrp[TLK_NOSHOOT] = "SC_SCARED";
m_szGrp[TLK_HELLO] = "SC_HELLO";
m_szGrp[TLK_PLHURT1] = "!SC_CUREA";
m_szGrp[TLK_PLHURT2] = "!SC_CUREB";
m_szGrp[TLK_PLHURT3] = "!SC_CUREC";
m_szGrp[TLK_PHELLO] = "SC_PHELLO";
m_szGrp[TLK_PIDLE] = "SC_PIDLE";
m_szGrp[TLK_PQUESTION] = "SC_PQUEST";
m_szGrp[TLK_SMELL] = "SC_SMELL";
m_szGrp[TLK_WOUND] = "SC_WOUND";
m_szGrp[TLK_MORTAL] = "SC_MORTAL";
}
// get voice for head
switch (pev->body % 3)
@ -753,6 +803,9 @@ void CScientist :: TalkInit()
case HEAD_LUTHER: m_voicePitch = 95; break; //luther
case HEAD_SLICK: m_voicePitch = 100; break;//slick
}
if ( FClassnameIs(pev, "monster_rosenberg"))
m_voicePitch = 95; // rosenberg has too low voice
}
int CScientist :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType)
@ -760,8 +813,11 @@ int CScientist :: TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, f
if ( pevInflictor && pevInflictor->flags & FL_CLIENT )
{
Remember( bits_MEMORY_PROVOKED );
StopFollowing( TRUE );
if ( !FClassnameIs(pev, "monster_rosenberg"))
{
Remember( bits_MEMORY_PROVOKED );
StopFollowing( TRUE );
}
}
// make sure friends talk about it if player hurts scientist...
@ -792,6 +848,12 @@ void CScientist :: PainSound ( void )
m_painTime = gpGlobals->time + RANDOM_FLOAT(0.5, 0.75);
if ( FClassnameIs(pev, "monster_rosenberg"))
{
EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "rosenberg/ro_pain1.wav", 1, ATTN_NORM, 0, GetVoicePitch());
return;
}
switch (RANDOM_LONG(0,4))
{
case 0: EMIT_SOUND_DYN( ENT(pev), CHAN_VOICE, "scientist/sci_pain1.wav", 1, ATTN_NORM, 0, GetVoicePitch()); break;
@ -971,7 +1033,7 @@ Schedule_t *CScientist :: GetSchedule ( void )
}
return GetScheduleOfType( SCHED_TARGET_FACE ); // Just face and follow.
}
else // UNDONE: When afraid, scientist won't move out of your way. Keep This? If not, write move away scared
else if ( !FClassnameIs(pev, "monster_rosenberg")) // UNDONE: When afraid, scientist won't move out of your way. Keep This? If not, write move away scared
{
if ( HasConditions( bits_COND_NEW_ENEMY ) ) // I just saw something new and scary, react
return GetScheduleOfType( SCHED_FEAR ); // React to something scary

View File

@ -928,7 +928,7 @@ int CTalkMonster :: FOkToSpeak( void )
if (gpGlobals->time <= CTalkMonster::g_talkWaitTime)
return FALSE;
if ( pev->spawnflags & SF_MONSTER_GAG )
if ( pev->spawnflags & SF_MONSTER_GAG && !FClassnameIs(pev, "monster_generic") )
return FALSE;
if ( m_MonsterState == MONSTERSTATE_PRONE )

View File

@ -2072,11 +2072,25 @@ void CTriggerGravity::GravityTouch( CBaseEntity *pOther )
pOther->pev->gravity = pev->gravity;
}
#ifdef BSHIFT_DLL
class CTriggerPlayerFreeze : public CBaseDelay
{
public:
void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value );
int ObjectCaps( void ) { return CBaseDelay::ObjectCaps() & ~FCAP_ACROSS_TRANSITION; }
};
LINK_ENTITY_TO_CLASS( trigger_playerfreeze, CTriggerPlayerFreeze );
void CTriggerPlayerFreeze::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
if ( !pActivator || !pActivator->IsPlayer() )
pActivator = CBaseEntity::Instance(g_engfuncs.pfnPEntityOfEntIndex( 1 ));
if (pActivator->pev->flags & FL_FROZEN)
((CBasePlayer *)((CBaseEntity *)pActivator))->EnableControl(TRUE);
else ((CBasePlayer *)((CBaseEntity *)pActivator))->EnableControl(FALSE);
}
#endif
// this is a really bad idea.
class CTriggerChangeTarget : public CBaseDelay

View File

@ -21,8 +21,8 @@ bool CL_CopyEntityToPhysEnt( physent_t *pe, cl_entity_t *ent )
{
model_t *mod = CM_ClipHandleToModel( ent->curstate.modelindex );
// bad model ?
if( !mod || mod->type == mod_bad )
// NOTE: player never collide with sprites (even with solid sprites)
if( !mod || mod->type == mod_bad || mod->type == mod_sprite )
return false;
pe->player = ent->player;
@ -435,8 +435,8 @@ void CL_SetSolidEntities( void )
for( i = 0; i < 3; i++ )
{
absmin[i] = cl.frame.cd.origin[i] - 256;
absmax[i] = cl.frame.cd.origin[i] + 256;
absmin[i] = cl.frame.cd.origin[i] - 1024;
absmax[i] = cl.frame.cd.origin[i] + 1024;
}
CL_CopyEntityToPhysEnt( &clgame.pmove->physents[0], &clgame.entities[0] );

View File

@ -303,35 +303,36 @@ bool Cmd_GetMusicList( const char *s, char *completedname, int length )
string matchbuf;
int i, numtracks;
t = FS_Search( va( "media/%s*.ogg", s ), true );
t = FS_Search( va( "media/%s*.*", s ), true );
if( !t ) return false;
FS_FileBase(t->filenames[0], matchbuf );
if(completedname && length) com.strncpy( completedname, matchbuf, length );
if(t->numfilenames == 1) return true;
FS_FileBase( t->filenames[0], matchbuf );
if( completedname && length ) com.strncpy( completedname, matchbuf, length );
if( t->numfilenames == 1 ) return true;
for(i = 0, numtracks = 0; i < t->numfilenames; i++)
{
const char *ext = FS_FileExtension( t->filenames[i] );
if( com.stricmp(ext, "ogg" )) continue;
FS_FileBase(t->filenames[i], matchbuf );
Msg("%16s\n", matchbuf );
if( !com.stricmp( ext, "wav" ) || !com.stricmp( ext, "ogg" ));
else continue;
FS_FileBase( t->filenames[i], matchbuf );
Msg( "%16s\n", matchbuf );
numtracks++;
}
Msg("\n^3 %i soundtracks found.\n", numtracks );
Msg( "\n^3 %i soundtracks found.\n", numtracks );
Mem_Free(t);
// cut shortestMatch to the amount common with s
if(completedname && length)
if( completedname && length )
{
for( i = 0; matchbuf[i]; i++ )
{
if(com.tolower(completedname[i]) != com.tolower(matchbuf[i]))
if( com.tolower( completedname[i]) != com.tolower( matchbuf[i] ))
completedname[i] = 0;
}
}
return true;
}
@ -451,7 +452,9 @@ bool Cmd_GetSoundList( const char *s, char *completedname, int length )
{
const char *ext = FS_FileExtension( t->filenames[i] );
if( com.stricmp( ext, "wav" ) && com.stricmp( ext, "ogg" )) continue;
if( !com.stricmp( ext, "wav" ) || !com.stricmp( ext, "ogg" ));
else continue;
com.strncpy( matchbuf, t->filenames[i] + com.strlen(snddir), MAX_STRING );
FS_StripExtension( matchbuf );
Msg( "%16s\n", matchbuf );
@ -783,7 +786,7 @@ autocomplete_list_t cmd_list[] =
{ "playdemo", Cmd_GetDemoList, },
{ "menufont", Cmd_GetFontList, },
{ "setfont", Cmd_GetFontList, },
{ "music", Cmd_GetSoundList, },
{ "music", Cmd_GetMusicList, },
{ "movie", Cmd_GetMovieList },
{ "exec", Cmd_GetConfigList },
{ "give", Cmd_GetItemsList },

View File

@ -8,6 +8,14 @@
#include "client.h"
#define WM_MOUSEWHEEL ( WM_MOUSELAST + 1 ) // message that will be supported by the OS
#define MK_XBUTTON1 0x0020
#define MK_XBUTTON2 0x0040
#define MK_XBUTTON3 0x0080
#define MK_XBUTTON4 0x0100
#define MK_XBUTTON5 0x0200
#define WM_XBUTTONUP 0x020C
#define WM_XBUTTONDOWN 0x020B
#define WND_HEADSIZE wnd_caption // some offset
#define WND_BORDER 3 // sentinel border in pixels
@ -42,6 +50,19 @@ static byte scan_to_key[128] =
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
};
// extra mouse buttons
static int mouse_buttons[] =
{
MK_LBUTTON,
MK_RBUTTON,
MK_MBUTTON,
MK_XBUTTON1,
MK_XBUTTON2,
MK_XBUTTON3,
MK_XBUTTON4,
MK_XBUTTON5
};
/*
=======
Host_MapKey
@ -102,7 +123,7 @@ void IN_StartupMouse( void )
if( host.type == HOST_DEDICATED ) return;
if( FS_CheckParm( "-nomouse" )) return;
in_mouse_buttons = 3;
in_mouse_buttons = 8;
in_mouseparmsvalid = SystemParametersInfo( SPI_GETMOUSE, 0, in_originalmouseparms, 0 );
in_mouseinitialized = true;
in_mouse_wheel = RegisterWindowMessage( "MSWHEEL_ROLLMSG" );
@ -372,7 +393,7 @@ main window procedure
*/
long IN_WndProc( void *hWnd, uint uMsg, uint wParam, long lParam )
{
int temp = 0;
int i, temp = 0;
if( uMsg == in_mouse_wheel )
uMsg = WM_MOUSEWHEEL;
@ -454,10 +475,14 @@ long IN_WndProc( void *hWnd, uint uMsg, uint wParam, long lParam )
case WM_RBUTTONUP:
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
case WM_XBUTTONDOWN:
case WM_XBUTTONUP:
case WM_MOUSEMOVE:
if( wParam & MK_LBUTTON ) temp |= 1;
if( wParam & MK_RBUTTON ) temp |= 2;
if( wParam & MK_MBUTTON ) temp |= 4;
for( i = 0; i < in_mouse_buttons; i++ )
{
if( wParam & mouse_buttons[i] )
temp |= (1<<i);
}
IN_MouseEvent( temp );
break;
case WM_SYSCOMMAND:

View File

@ -117,12 +117,15 @@ hull_t *PM_HullForEntity( physent_t *pe, vec3_t mins, vec3_t maxs, vec3_t offset
vec3_t hullmins, hullmaxs;
// decide which clipping hull to use, based on the size
if( pe->movetype == MOVETYPE_PUSH )
if( pe->solid == SOLID_BSP )
{
vec3_t size;
if( pe->movetype != MOVETYPE_PUSH )
Host_Error( "SOLID_BSP without MOVETYPE_PUSH\n" );
if( !pe->model || pe->model->type != mod_brush && pe->model->type != mod_world )
Host_Error( "Entity %i has MOVETYPE_PUSH with a non bsp model\n", pe->info );
Host_Error( "Entity %s has MOVETYPE_PUSH with a non bsp model\n", pe->name );
VectorSubtract( maxs, mins, size );

View File

@ -600,6 +600,7 @@ void SV_Init( void )
Cvar_Get ("lservercfgfile","listenserver.cfg", 0, "name of listen server configuration file" );
Cvar_Get ("motdfile", "motd.txt", 0, "name of 'message of the day' file" );
Cvar_Get ("sv_language", "0", 0, "game language (currently unused)" );
Cvar_Get ("suitvolume", "0.25", CVAR_ARCHIVE, "HEV suit volume" );
// half-life shared variables
sv_zmax = Cvar_Get ("sv_zmax", "0", CVAR_PHYSICINFO, "zfar server value" );

View File

@ -700,7 +700,7 @@ SAVERESTOREDATA *SV_LoadSaveData( const char *level )
int i, id, size, version;
com.snprintf( name, sizeof( name ), "save/%s.HL1", level );
MsgDev( D_INFO, "Loading game from %s...\n", name + 1 );
MsgDev( D_INFO, "Loading game from %s...\n", name );
pFile = FS_OpenEx( name, "rb", true );
if( !pFile )
@ -1646,7 +1646,7 @@ bool SV_LoadGame( const char *pName )
com.snprintf( name, sizeof( name ), "save/%s.sav", pName );
MsgDev( D_INFO, "Loading game from %s...\n", name + 1 );
MsgDev( D_INFO, "Loading game from %s...\n", name );
SV_ClearSaveDir();
if( !svs.initialized ) SV_InitGame ();

View File

@ -2800,13 +2800,15 @@ void PM_CheckParamters( void )
pmove->cmd.upmove *= fRatio;
}
if ( pmove->flags & FL_FROZEN ||
pmove->flags & FL_ONTRAIN ||
pmove->dead )
if ( pmove->flags & FL_FROZEN || pmove->flags & FL_ONTRAIN || pmove->dead )
{
pmove->cmd.forwardmove = 0;
pmove->cmd.sidemove = 0;
pmove->cmd.upmove = 0;
// clearing IN_JUMP flag when frozen
if( pmove->flags & FL_FROZEN )
pmove->cmd.buttons = 0;
}

View File

@ -32,8 +32,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define ID_SOUNDLIBRARY 4
#define ID_SOUNDVOLUME 5
#define ID_MUSICVOLUME 6
#define ID_EAX 7
#define ID_A3D 8
#define ID_INTERP 7
#define ID_NODSP 8
#define ID_MSGHINT 9
typedef struct
@ -41,8 +41,6 @@ typedef struct
int soundLibrary;
float soundVolume;
float musicVolume;
int enableEAX;
int enableA3D;
} uiAudioValues_t;
static uiAudioValues_t uiAudioInitial;
@ -63,8 +61,8 @@ typedef struct
menuSpinControl_s soundLibrary;
menuSlider_s soundVolume;
menuSlider_s musicVolume;
menuCheckBox_s EAX;
menuCheckBox_s A3D;
menuCheckBox_s lerping;
menuCheckBox_s noDSP;
menuAction_s hintMessage;
char hintText[MAX_HINT_TEXT];
@ -103,18 +101,16 @@ static void UI_Audio_GetConfig( void )
uiAudio.soundVolume.curValue = CVAR_GET_FLOAT( "volume" );
uiAudio.musicVolume.curValue = CVAR_GET_FLOAT( "musicvolume" );
if( CVAR_GET_FLOAT( "s_allowEAX" ))
uiAudio.EAX.enabled = 1;
if( CVAR_GET_FLOAT( "s_lerping" ))
uiAudio.lerping.enabled = 1;
if( CVAR_GET_FLOAT( "s_allowA3D" ))
uiAudio.A3D.enabled = 1;
if( CVAR_GET_FLOAT( "dsp_off" ))
uiAudio.noDSP.enabled = 1;
// save initial values
uiAudioInitial.soundLibrary = uiAudio.soundLibrary.curValue;
uiAudioInitial.soundVolume = uiAudio.soundVolume.curValue;
uiAudioInitial.musicVolume = uiAudio.musicVolume.curValue;
uiAudioInitial.enableEAX = uiAudio.EAX.enabled;
uiAudioInitial.enableA3D = uiAudio.A3D.enabled;
}
/*
@ -126,8 +122,8 @@ static void UI_Audio_SetConfig( void )
{
CVAR_SET_FLOAT( "volume", uiAudio.soundVolume.curValue );
CVAR_SET_FLOAT( "musicvolume", uiAudio.musicVolume.curValue );
CVAR_SET_FLOAT( "s_allowEAX", uiAudio.EAX.enabled );
CVAR_SET_FLOAT( "s_allowA3D", uiAudio.A3D.enabled );
CVAR_SET_FLOAT( "s_lerping", uiAudio.lerping.enabled );
CVAR_SET_FLOAT( "dsp_off", uiAudio.noDSP.enabled );
CHANGE_AUDIO( uiAudio.audioList[(int)uiAudio.soundLibrary.curValue] );
}
@ -143,6 +139,8 @@ static void UI_Audio_UpdateConfig( void )
CVAR_SET_FLOAT( "volume", uiAudio.soundVolume.curValue );
CVAR_SET_FLOAT( "musicvolume", uiAudio.musicVolume.curValue );
CVAR_SET_FLOAT( "s_lerping", uiAudio.lerping.enabled );
CVAR_SET_FLOAT( "dsp_off", uiAudio.noDSP.enabled );
// See if the apply button should be enabled or disabled
uiAudio.apply.generic.flags |= QMF_GRAYED;
@ -152,18 +150,6 @@ static void UI_Audio_UpdateConfig( void )
uiAudio.apply.generic.flags &= ~QMF_GRAYED;
return;
}
if( uiAudioInitial.enableEAX != uiAudio.EAX.enabled )
{
uiAudio.apply.generic.flags &= ~QMF_GRAYED;
return;
}
if( uiAudioInitial.enableA3D != uiAudio.A3D.enabled )
{
uiAudio.apply.generic.flags &= ~QMF_GRAYED;
return;
}
}
/*
@ -177,8 +163,8 @@ static void UI_Audio_Callback( void *self, int event )
switch( item->id )
{
case ID_EAX:
case ID_A3D:
case ID_INTERP:
case ID_NODSP:
if( event == QM_PRESSED )
((menuCheckBox_s *)self)->focusPic = UI_CHECKBOX_PRESSED;
else ((menuCheckBox_s *)self)->focusPic = UI_CHECKBOX_FOCUS;
@ -300,23 +286,23 @@ static void UI_Audio_Init( void )
uiAudio.musicVolume.maxValue = 1.0;
uiAudio.musicVolume.range = 0.05f;
uiAudio.EAX.generic.id = ID_EAX;
uiAudio.EAX.generic.type = QMTYPE_CHECKBOX;
uiAudio.EAX.generic.flags = QMF_HIGHLIGHTIFFOCUS|QMF_ACT_ONRELEASE|QMF_MOUSEONLY|QMF_DROPSHADOW;
uiAudio.EAX.generic.name = "Enable EAX 2.0 support";
uiAudio.EAX.generic.x = 320;
uiAudio.EAX.generic.y = 370;
uiAudio.EAX.generic.callback = UI_Audio_Callback;
uiAudio.EAX.generic.statusText = "enable/disable Environmental Audio eXtensions";
uiAudio.lerping.generic.id = ID_INTERP;
uiAudio.lerping.generic.type = QMTYPE_CHECKBOX;
uiAudio.lerping.generic.flags = QMF_HIGHLIGHTIFFOCUS|QMF_ACT_ONRELEASE|QMF_MOUSEONLY|QMF_DROPSHADOW;
uiAudio.lerping.generic.name = "Enable sound interpolation";
uiAudio.lerping.generic.x = 320;
uiAudio.lerping.generic.y = 370;
uiAudio.lerping.generic.callback = UI_Audio_Callback;
uiAudio.lerping.generic.statusText = "enable/disable interpolation on sound output";
uiAudio.A3D.generic.id = ID_A3D;
uiAudio.A3D.generic.type = QMTYPE_CHECKBOX;
uiAudio.A3D.generic.flags = QMF_HIGHLIGHTIFFOCUS|QMF_GRAYED|QMF_ACT_ONRELEASE|QMF_MOUSEONLY|QMF_DROPSHADOW;
uiAudio.A3D.generic.name = "Enable A3D 2.0 support";
uiAudio.A3D.generic.x = 320;
uiAudio.A3D.generic.y = 420;
uiAudio.A3D.generic.callback = UI_Audio_Callback;
uiAudio.A3D.generic.statusText = "enable/disable Aureal Audio 3D environment sound";
uiAudio.noDSP.generic.id = ID_NODSP;
uiAudio.noDSP.generic.type = QMTYPE_CHECKBOX;
uiAudio.noDSP.generic.flags = QMF_HIGHLIGHTIFFOCUS|QMF_ACT_ONRELEASE|QMF_MOUSEONLY|QMF_DROPSHADOW;
uiAudio.noDSP.generic.name = "Disable DSP effects";
uiAudio.noDSP.generic.x = 320;
uiAudio.noDSP.generic.y = 420;
uiAudio.noDSP.generic.callback = UI_Audio_Callback;
uiAudio.noDSP.generic.statusText = "this disables sound processing (like echo, flanger etc)";
UI_Audio_GetConfig();
@ -328,8 +314,8 @@ static void UI_Audio_Init( void )
UI_AddItem( &uiAudio.menu, (void *)&uiAudio.soundLibrary );
UI_AddItem( &uiAudio.menu, (void *)&uiAudio.soundVolume );
UI_AddItem( &uiAudio.menu, (void *)&uiAudio.musicVolume );
UI_AddItem( &uiAudio.menu, (void *)&uiAudio.EAX );
UI_AddItem( &uiAudio.menu, (void *)&uiAudio.A3D );
UI_AddItem( &uiAudio.menu, (void *)&uiAudio.lerping );
UI_AddItem( &uiAudio.menu, (void *)&uiAudio.noDSP );
}
/*

View File

@ -303,8 +303,8 @@ bool Sound_ResampleInternal( wavdata_t *sc, int inrate, int inwidth, int outrate
}
else
{
sample = (int)( (unsigned char)(data[srcsample*2+0]) - 128) << 8;
sample2 = (int)( (unsigned char)(data[srcsample*2+1]) - 128) << 8;
sample = (int)((char)(data[srcsample*2+0])) << 8;
sample2 = (int)((char)(data[srcsample*2+1])) << 8;
}
if( outwidth == 2 )
@ -327,7 +327,7 @@ bool Sound_ResampleInternal( wavdata_t *sc, int inrate, int inwidth, int outrate
samplefrac += fracstep;
if( inwidth == 2 ) sample = LittleShort(((short *)data)[srcsample] );
else sample = (int)( (unsigned char)(data[srcsample]) - 128) << 8;
else sample = (int)( (char)(data[srcsample])) << 8;
if( outwidth == 2 ) ((short *)sound.tempbuffer)[i] = sample;
else ((signed char *)sound.tempbuffer)[i] = sample >> 8;

View File

@ -239,6 +239,21 @@ bool Sound_LoadWAV( const char *name, const byte *buffer, size_t filesize )
Mem_Copy( sound.wav, buffer + (iff_dataPtr - buffer), sound.size );
// now convert 8-bit sounds to signed
if( sound.width == 1 )
{
int i, j;
char *pData = sound.wav;
for( i = 0; i < sound.samples; i++ )
{
for( j = 0; j < sound.channels; j++ )
{
*pData = (byte)((int)((byte)*pData) - 128 );
pData++;
}
}
}
return true;
}

View File

@ -20,6 +20,9 @@
#define M_PI2 (float)6.28318530717958647692
#endif
#define M_PI_F ((float)(M_PI))
#define M_PI2_F ((float)(M_PI2))
#define RAD2DEG( x ) ((float)(x) * (float)(180.f / M_PI))
#define DEG2RAD( x ) ((float)(x) * (float)(M_PI / 180.f))

View File

@ -18,6 +18,8 @@ static dllfunc_t dsound_funcs[] =
dll_info_t dsound_dll = { "dsound.dll", dsound_funcs, NULL, NULL, NULL, false, 0, 0 };
#define SAMPLE_16BIT_SHIFT 1
// 64K is > 1 second at 16-bit, 22050 Hz
#define WAV_BUFFERS 64
#define WAV_MASK 0x3F
@ -41,7 +43,6 @@ static bool snd_isdirect, snd_iswave;
static bool primary_format_set;
static int snd_buffer_count = 0;
static int snd_sent, snd_completed;
static int sample16;
/*
=======================================================================
@ -95,9 +96,9 @@ static bool DS_CreateBuffers( void *hInst )
Mem_Set( &format, 0, sizeof( format ));
format.wFormatTag = WAVE_FORMAT_PCM;
format.nChannels = dma.channels;
format.wBitsPerSample = dma.samplebits;
format.nSamplesPerSec = dma.speed;
format.nChannels = 2;
format.wBitsPerSample = 16;
format.nSamplesPerSec = SOUND_DMA_SPEED;
format.nBlockAlign = format.nChannels * format.wBitsPerSample / 8;
format.nAvgBytesPerSec = format.nSamplesPerSec * format.nBlockAlign;
format.cbSize = 0;
@ -177,10 +178,6 @@ static bool DS_CreateBuffers( void *hInst )
MsgDev( D_INFO, "- failed. forced to software\n" );
}
dma.channels = format.nChannels;
dma.samplebits = format.wBitsPerSample;
dma.speed = format.nSamplesPerSec;
if( pDSBuf->lpVtbl->GetCaps( pDSBuf, &dsbcaps ) != DS_OK )
{
MsgDev( D_ERROR, "DS_CreateBuffers: GetCaps failed\n");
@ -223,13 +220,11 @@ static bool DS_CreateBuffers( void *hInst )
dma.samplepos = 0;
snd_hwnd = (HWND)hInst;
gSndBufSize = dsbcaps.dwBufferBytes;
dma.samples = gSndBufSize / (dma.samplebits / 8 );
dma.submission_chunk = 1;
dma.samples = gSndBufSize / 2;
dma.buffer = (byte *)lpData;
sample16 = (dma.samplebits / 8) - 1;
SNDDMA_BeginPainting();
if( dma.buffer ) Mem_Set( dma.buffer, 0, dma.samples * dma.samplebits / 8 );
if( dma.buffer ) Mem_Set( dma.buffer, 0, dma.samples * 2 );
SNDDMA_Submit();
return true;
@ -335,16 +330,6 @@ si_state_t SNDDMA_InitDirect( void *hInst )
DSCAPS dscaps;
HRESULT hresult;
dma.channels = 2;
dma.samplebits = 16;
switch( s_khz->integer )
{
case 44: dma.speed = 44100; break;
case 22: dma.speed = 22050; break;
default: dma.speed = 11025; break;
}
if( !dsound_dll.link )
{
if( !Sys_LoadLibrary( NULL, &dsound_dll ))
@ -402,21 +387,11 @@ si_state_t SNDDMA_InitWav( void )
snd_sent = 0;
snd_completed = 0;
dma.channels = 2;
dma.samplebits = 16;
switch( s_khz->integer )
{
case 44: dma.speed = 44100; break;
case 22: dma.speed = 22050; break;
default: dma.speed = 11025; break;
}
Mem_Set( &format, 0, sizeof( format ));
format.wFormatTag = WAVE_FORMAT_PCM;
format.nChannels = dma.channels;
format.wBitsPerSample = dma.samplebits;
format.nSamplesPerSec = dma.speed;
format.nChannels = 2;
format.wBitsPerSample = 16;
format.nSamplesPerSec = SOUND_DMA_SPEED;
format.nBlockAlign = format.nChannels * format.wBitsPerSample / 8;
format.nAvgBytesPerSec = format.nSamplesPerSec * format.nBlockAlign;
format.cbSize = 0;
@ -493,10 +468,8 @@ si_state_t SNDDMA_InitWav( void )
}
dma.samplepos = 0;
dma.samples = gSndBufSize / ( dma.samplebits / 8 );
dma.submission_chunk = 512;
dma.samples = gSndBufSize / 2;
dma.buffer = (byte *)lpData;
sample16 = (dma.samplebits / 8) - 1;
wav_init = true;
return SIS_SUCCESS;
@ -598,7 +571,7 @@ int SNDDMA_GetDMAPos( void )
}
s >>= sample16;
s >>= SAMPLE_16BIT_SHIFT;
s &= (dma.samples - 1);
return s;
@ -616,7 +589,7 @@ int SNDDMA_GetSoundtime( void )
static int buffers, oldsamplepos;
int samplepos, fullsamples;
fullsamples = dma.samples / dma.channels;
fullsamples = dma.samples / 2;
// it is possible to miscount buffers
// if it has wrapped twice between
@ -637,7 +610,7 @@ int SNDDMA_GetSoundtime( void )
}
oldsamplepos = samplepos;
return (buffers * fullsamples + samplepos / dma.channels);
return (buffers * fullsamples + samplepos / 2);
}
/*
@ -719,7 +692,7 @@ void SNDDMA_Submit( void )
}
// submit a few new sound blocks
while((( snd_sent - snd_completed ) >> sample16 ) < 8 )
while((( snd_sent - snd_completed ) >> SAMPLE_16BIT_SHIFT ) < 8 )
{
h = lpWaveHdr + ( snd_sent & WAV_MASK );

File diff suppressed because it is too large Load Diff

1060
snd_dx/s_dsp.old Normal file

File diff suppressed because it is too large Load Diff

View File

@ -127,10 +127,6 @@ wavdata_t *S_LoadSound( sfx_t *sfx )
else sc = FS_LoadSound( sfx->name, NULL, 0 );
if( !sc ) sc = S_CreateDefaultSound();
// upload and resample
Sound_Process( &sc, dma.speed, sc->width, SOUND_RESAMPLE );
sfx->cache = sc;
return sfx->cache;

View File

@ -20,14 +20,12 @@ int paintedtime; // sample PAIRS
cvar_t *s_check_errors;
cvar_t *s_volume;
cvar_t *s_suitvolume; // game.dll requires this
cvar_t *s_musicvolume;
cvar_t *s_khz;
cvar_t *s_show;
cvar_t *s_mixahead;
cvar_t *s_primary;
cvar_t *s_allowEAX;
cvar_t *s_allowA3D;
cvar_t *s_lerping;
cvar_t *dsp_off; // set to 1 to disable all dsp processing
/*
=============================================================================
@ -93,6 +91,7 @@ void S_FreeChannel( channel_t *ch )
ch->use_loop = false;
ch->isSentence = false;
// clear mixer
Mem_Set( &ch->pMixer, 0, sizeof( ch->pMixer ));
SND_CloseMouth( ch );
@ -366,16 +365,8 @@ void SND_Spatialize( channel_t *ch )
dist = VectorNormalizeLength( source_vec ) * ch->dist_mult;
dot = DotProduct( s_listener.right, source_vec );
if( dma.channels == 1 )
{
rscale = 1.0f;
lscale = 1.0f;
}
else
{
rscale = 1.0f + dot;
lscale = 1.0f - dot;
}
rscale = 1.0f + dot;
lscale = 1.0f - dot;
// add in distance effect
scale = ( 1.0f - dist ) * rscale;
@ -634,17 +625,13 @@ S_ClearBuffer
*/
void S_ClearBuffer( void )
{
int clear;
s_rawend = 0;
if( dma.samplebits == 8 )
clear = 0x80;
else clear = 0;
SNDDMA_BeginPainting ();
if( dma.buffer ) Mem_Set( dma.buffer, clear, dma.samples * dma.samplebits / 8 );
if( dma.buffer ) Mem_Set( dma.buffer, 0, dma.samples * 2 );
SNDDMA_Submit ();
MIX_ClearAllPaintBuffers( PAINTBUFFER_SIZE, true );
}
/*
@ -679,13 +666,13 @@ void S_StopAllSounds( void )
S_FreeChannel( &channels[i] );
}
// clear any remaining soundfade
Mem_Set( &soundfade, 0, sizeof( soundfade ));
s_volume->modified = true; // rebuild scaletable
// clear all the channels
Mem_Set( channels, 0, sizeof( channels ));
S_ClearBuffer ();
// clear any remaining soundfade
Mem_Set( &soundfade, 0, sizeof( soundfade ));
}
//=============================================================================
@ -700,19 +687,37 @@ void S_UpdateChannels( void )
// updates DMA time
soundtime = SNDDMA_GetSoundtime();
#if 0
// check to make sure that we haven't overshot
if( paintedtime < soundtime ) paintedtime = soundtime;
// mix ahead of current position
endtime = soundtime + s_mixahead->value * dma.speed;
endtime = soundtime + s_mixahead->value * SOUND_DMA_SPEED;
// mix to an even submission block size
endtime = (endtime + dma.submission_chunk - 1) & ~(dma.submission_chunk - 1);
samps = dma.samples >> (dma.channels - 1);
samps = dma.samples >> 1;
if( endtime - soundtime > samps ) endtime = soundtime + samps;
#else
// soundtime - total samples that have been played out to hardware at dmaspeed
// paintedtime - total samples that have been mixed at speed
// endtime - target for samples in mixahead buffer at speed
endtime = soundtime + s_mixahead->value * SOUND_DMA_SPEED;
samps = dma.samples >> 1;
if((int)( endtime - soundtime ) > samps )
endtime = soundtime + samps;
if(( endtime - paintedtime ) & 0x3 )
{
// The difference between endtime and painted time should align on
// boundaries of 4 samples. This is important when upsampling from 11khz -> 44khz.
endtime -= ( endtime - paintedtime ) & 0x3;
}
#endif
MIX_PaintChannels( endtime );
S_PaintChannels( endtime );
SNDDMA_Submit();
}
@ -761,10 +766,6 @@ void S_RenderFrame( ref_params_t *fd )
VectorCopy( fd->right, s_listener.right );
VectorCopy( fd->up, s_listener.up );
// rebuild scale tables if volume is modified
if( s_volume->modified || soundfade.percent != 0 )
S_InitScaletable();
// update spatialization for static and dynamic sounds
for( i = 0, ch = channels; i < total_channels; i++, ch++ )
{
@ -818,8 +819,44 @@ void S_Music_f( void )
{
int c = Cmd_Argc();
if( c == 2 ) S_StartBackgroundTrack( Cmd_Argv(1), Cmd_Argv(1) );
else if( c == 3 ) S_StartBackgroundTrack( Cmd_Argv(1), Cmd_Argv(2) );
// run background track
if( c == 1 )
{
// blank name stopped last track
S_StopBackgroundTrack();
}
else if( c == 2 )
{
string intro, main, track;
char *ext[] = { "wav", "ogg" };
int i;
com.strncpy( track, Cmd_Argv( 1 ), sizeof( track ));
com.snprintf( intro, sizeof( intro ), "%s_intro", Cmd_Argv( 1 ));
com.snprintf( main, sizeof( main ), "%s_main", Cmd_Argv( 1 ));
for( i = 0; i < 2; i++ )
{
if( FS_FileExists( va( "media/%s.%s", intro, ext[i] ))
&& FS_FileExists( va( "media/%s.%s", main, ext[i] )))
{
// combined track with introduction and main loop theme
S_StartBackgroundTrack( intro, main );
break;
}
else if( FS_FileExists( va( "media/%s.%s", track, ext[i] )))
{
// single looped theme
S_StartBackgroundTrack( track, track );
break;
}
}
}
else if( c == 3 )
{
S_StartBackgroundTrack( Cmd_Argv( 1 ), Cmd_Argv( 2 ));
}
else Msg( "Usage: music <musicfile> [loopfile]\n" );
}
@ -841,15 +878,12 @@ S_SoundInfo_f
void S_SoundInfo_f( void )
{
S_PrintDeviceName();
Msg( "%5d channel(s)\n", dma.channels );
Msg( "%5d channel(s)\n", 2 );
Msg( "%5d samples\n", dma.samples );
Msg( "%5d bits/sample\n", dma.samplebits );
Msg( "%5d bytes/sec\n", dma.speed );
Msg( "%5d bits/sample\n", 16 );
Msg( "%5d bytes/sec\n", SOUND_DMA_SPEED );
Msg( "%5d total_channels\n", total_channels );
MsgDev( D_NOTE, "%5d samplepos\n", dma.samplepos );
MsgDev( D_NOTE, "%5d submission_chunk\n", dma.submission_chunk );
MsgDev( D_NOTE, "0x%x dma buffer\n", dma.buffer );
}
/*
@ -862,15 +896,13 @@ bool S_Init( void *hInst )
Cmd_ExecuteString( "sndlatch\n" );
s_volume = Cvar_Get( "volume", "0.7", CVAR_ARCHIVE, "sound volume" );
s_suitvolume = Cvar_Get( "suitvolume", "0.5", CVAR_ARCHIVE, "HEV suit volume" );
s_musicvolume = Cvar_Get( "musicvolume", "1.0", CVAR_ARCHIVE, "background music volume" );
s_khz = Cvar_Get( "s_khz", "22", CVAR_LATCH_AUDIO|CVAR_ARCHIVE, "output sound frequency" );
s_mixahead = Cvar_Get( "s_mixahead", "0.1", 0, "how much sound to mix ahead of time" );
s_show = Cvar_Get( "s_show", "0", 0, "show playing sounds" );
s_primary = Cvar_Get( "s_primary", "0", CVAR_LATCH_AUDIO|CVAR_ARCHIVE, "use direct primary buffer" );
s_check_errors = Cvar_Get( "s_check_errors", "1", CVAR_ARCHIVE, "ignore audio engine errors" );
s_allowEAX = Cvar_Get("s_allowEAX", "1", CVAR_LATCH_AUDIO|CVAR_ARCHIVE, "allow EAX 2.0 extension" );
s_allowA3D = Cvar_Get("s_allowA3D", "1", CVAR_LATCH_AUDIO|CVAR_ARCHIVE, "allow A3D 2.0 extension" );
s_lerping = Cvar_Get( "s_lerping", "0", CVAR_ARCHIVE, "apply interpolation to sound output" );
dsp_off = Cvar_Get( "dsp_off", "0", CVAR_ARCHIVE, "set to 1 to disable all dsp processing" );
Cmd_AddCommand( "play", S_Play_f, "playing a specified sound file" );
Cmd_AddCommand( "stopsound", S_StopSound_f, "stop all sounds" );
@ -888,10 +920,12 @@ bool S_Init( void *hInst )
soundtime = 0;
paintedtime = 0;
MIX_InitAllPaintbuffers ();
S_InitScaletable ();
S_StopAllSounds ();
VOX_Init ();
SX_Init ();
AllocDsps ();
return true;
}
@ -910,8 +944,9 @@ void S_Shutdown( void )
S_StopAllSounds ();
S_FreeSounds ();
VOX_Shutdown ();
SX_Free ();
FreeDsps ();
SNDDMA_Shutdown ();
MIX_FreeAllPaintbuffers ();
Mem_FreePool( &sndpool );
}

File diff suppressed because it is too large Load Diff

View File

@ -26,10 +26,12 @@ void S_StartBackgroundTrack( const char *introTrack, const char *mainTrack )
{
introTrack = "";
}
if( !mainTrack || !*mainTrack )
{
mainTrack = introTrack;
}
if( !*introTrack ) return;
if( mainTrack )
@ -78,7 +80,7 @@ void S_StreamBackgroundTrack( void )
if( !s_bgTrack.stream ) return;
// don't bother playing anything if musicvolume is 0
if( !s_musicvolume->value ) return;
if( !s_musicvolume->value || s_listener.paused ) return;
// see how many samples should be copied into the raw buffer
if( s_rawend < soundtime )
@ -91,7 +93,7 @@ void S_StreamBackgroundTrack( void )
bufferSamples = MAX_RAW_SAMPLES - (s_rawend - soundtime);
// decide how much data needs to be read from the file
fileSamples = bufferSamples * info->rate / dma.speed;
fileSamples = bufferSamples * info->rate / SOUND_DMA_SPEED;
// our max buffer size
fileBytes = fileSamples * ( info->width * info->channels );
@ -164,18 +166,14 @@ Cinematic streaming and voice over network
*/
void S_StreamRawSamples( int samples, int rate, int width, int channels, const byte *data )
{
int i, snd_vol;
int a, b, src, dst;
int i, a, b, src, dst;
int fracstep, samplefrac;
int incount, outcount;
snd_vol = (int)(s_musicvolume->value * 256);
if( snd_vol < 0 ) snd_vol = 0;
src = 0;
samplefrac = 0;
fracstep = (((double)rate) / (double)dma.speed) * 256.0;
outcount = (double)samples * (double) dma.speed / (double)rate;
fracstep = (((double)rate) / (double)SOUND_DMA_SPEED) * 256.0;
outcount = (double)samples * (double)SOUND_DMA_SPEED / (double)rate;
incount = samples * channels;
#define TAKE_SAMPLE( s ) (sizeof(*in) == 1 ? (a = (in[src+(s)]-128)<<8,\
@ -183,7 +181,7 @@ void S_StreamRawSamples( int samples, int rate, int width, int channels, const b
(a = in[src+(s)],\
b = (src < incount - channels) ? (in[src+channels+(s)]) : 0))
#define LERP_SAMPLE ((((((b - a) * (samplefrac & 255)) >> 8) + a) * snd_vol))
#define LERP_SAMPLE (((((b - a) * (samplefrac & 255)) >> 8) + a))
#define RESAMPLE_RAW \
if( channels == 2 ) { \

View File

@ -6,8 +6,8 @@
#include "sound.h"
// hardcoded macros to test for zero crossing
#define ZERO_X_8( b ) (( b )< 2 && ( b ) > -2 )
#define ZERO_X_16( b ) (( b )< 512 && ( b ) > -512 )
#define ZERO_X_8( b ) (( b ) < 2 && ( b ) > -2 )
#define ZERO_X_16( b ) (( b ) < 512 && ( b ) > -512 )
//-----------------------------------------------------------------------------
// Purpose: Search backward for a zero crossing starting at sample

View File

@ -368,6 +368,8 @@ void VOX_FreeWord( channel_t *pchan )
pchan->currentWord = NULL; // sentence is finished
Mem_Set( &pchan->pMixer, 0, sizeof( pchan->pMixer ));
// UNDONE: add references to sources
return;
if( pchan->words[pchan->wordIndex].sfx )
{
// If this wave wasn't precached by the game code

View File

@ -22,6 +22,12 @@ extern byte *sndpool;
#define SND_LOCALSOUND (1<<9) // not paused, not looped, for internal use
#define SND_STOP_LOOPING (1<<10) // stop all looping sounds on the entity.
// sound engine rate defines
#define SOUND_DMA_SPEED 44100 // hardware playback rate
#define SOUND_11k 11025 // 11khz sample rate
#define SOUND_22k 22050 // 22khz sample rate
#define SOUND_44k 44100 // 44khz sample rate
// fixed point stuff for real-time resampling
#define FIX_BITS 28
#define FIX_SCALE (1 << FIX_BITS)
@ -32,12 +38,34 @@ extern byte *sndpool;
#define FIX_FRACTION(a,b) (FIX(a)/(b))
#define FIX_FRACPART(a) ((a) & FIX_MASK)
#define CLIP( x ) (( x ) > 32767 ? 32767 : (( x ) < -32767 ? -32767 : ( x )))
#define SWAP( a, b, t ) {(t) = (a); (a) = (b); (b) = (t);}
#define AVG( a, b ) (((a) + (b)) >> 1 )
#define AVG4( a, b, c, d ) (((a) + (b) + (c) + (d)) >> 2 )
#define PAINTBUFFER_SIZE 1024 // 44k: was 512
#define PAINTBUFFER (g_curpaintbuffer)
#define CPAINTBUFFERS 3
typedef struct
{
int left;
int right;
} portable_samplepair_t;
// sound mixing buffer
#define CPAINTFILTERMEM 3
#define CPAINTFILTERS 4 // maximum number of consecutive upsample passes per paintbuffer
typedef struct
{
bool factive; // if true, mix to this paintbuffer using flags
portable_samplepair_t *pbuf; // front stereo mix buffer, for 2 or 4 channel mixing
int ifilter; // current filter memory buffer to use for upsampling pass
portable_samplepair_t fltmem[CPAINTFILTERS][CPAINTFILTERMEM];
} paintbuffer_t;
typedef struct sfx_s
{
string name;
@ -48,6 +76,13 @@ typedef struct sfx_s
struct sfx_s *hashNext;
} sfx_t;
extern portable_samplepair_t drybuffer[];
extern portable_samplepair_t paintbuffer[];
extern portable_samplepair_t roombuffer[];
extern portable_samplepair_t temppaintbuffer[];
extern portable_samplepair_t *g_curpaintbuffer;
extern paintbuffer_t paintbuffers[];
// structure used for fading in and out client sound volume.
typedef struct
{
@ -61,12 +96,8 @@ typedef struct
typedef struct
{
int channels;
int samples; // mono samples in buffer
int submission_chunk; // don't mix less than this #
int samplepos; // in mono samples
int samplebits;
int speed;
byte *buffer;
} dma_t;
@ -99,6 +130,7 @@ typedef struct
bool use_loop; // don't loop default and local sounds
bool staticsound; // use origin instead of fetching entnum's origin
bool localsound; // it's a local menu sound (not looped, not paused)
bool bdry; // if true, bypass all dsp processing for this sound (ie: music)
mixer_t pMixer;
// sentence mixer
@ -152,7 +184,6 @@ void SNDDMA_Submit( void );
#define MAX_CHANNELS 128
#define MAX_RAW_SAMPLES 8192
extern portable_samplepair_t paintbuffer[];
extern channel_t channels[MAX_CHANNELS];
extern int total_channels;
extern int paintedtime;
@ -160,20 +191,21 @@ extern int s_rawend;
extern int soundtime;
extern dma_t dma;
extern listener_t s_listener;
extern int idsp_room;
extern cvar_t *s_check_errors;
extern cvar_t *s_volume;
extern cvar_t *s_musicvolume;
extern cvar_t *s_khz;
extern cvar_t *s_show;
extern cvar_t *s_mixahead;
extern cvar_t *s_primary;
extern cvar_t *s_lerping;
extern cvar_t *dsp_off;
extern portable_samplepair_t s_rawsamples[MAX_RAW_SAMPLES];
void S_InitScaletable( void );
wavdata_t *S_LoadSound( sfx_t *sfx );
void S_PaintChannels( int endtime );
float S_GetMasterVolume( void );
void S_PrintDeviceName( void );
@ -187,6 +219,10 @@ void S_BeginFrame( void );
// s_mix.c
//
int S_MixDataToDevice( channel_t *pChannel, int sampleCount, int outputRate, int outputOffset );
void MIX_ClearAllPaintBuffers( int SampleCount, bool clearFilters );
void MIX_InitAllPaintbuffers( void );
void MIX_FreeAllPaintbuffers( void );
void MIX_PaintChannels( int endtime );
// s_load.c
bool S_TestSoundChar( const char *pch, char c );
@ -195,9 +231,16 @@ sfx_t *S_FindName( const char *name, int *pfInCache );
void S_FreeSound( sfx_t *sfx );
// s_dsp.c
bool AllocDsps( void );
void FreeDsps( void );
void CheckNewDspPresets( void );
void DSP_Process( int idsp, portable_samplepair_t *pbfront, int sampleCount );
float DSP_GetGain( int idsp );
void DSP_ClearState( void );
void SX_Init( void );
void SX_Free( void );
void SX_RoomFX( int endtime, int fFilter, int fTimefx );
void SX_RoomFX( portable_samplepair_t *pbuf, int sampleCount );
bool S_Init( void *hInst );
void S_Shutdown( void );

View File

@ -3,7 +3,19 @@ Microsoft Developer Studio Workspace File, Format Version 6.00
###############################################################################
Project: "bshift"=".\dlls\hl.dsp" - Package Owner=<4>
Project: "hl"=".\dlls\hl.dsp" - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Project: "bshift"=".\dlls\bshift.dsp" - Package Owner=<4>
Package=<5>
{{{