📄 bloodclientshell.cpp
字号:
m_bNightGogglesActive = DFALSE;
m_hNightGogglesSound = DNULL;
m_hTheEyeLoopingSound = DNULL;
m_bBinocularsActive = DFALSE;
m_bPaused = DFALSE;
m_bInMessageBox = DFALSE;
m_eMusicLevel = CMusic::MUSICLEVEL_SILENCE;
// Camera stuff...
m_fOffsetY = 0.0f;
m_fOffsetX = 0.0f;
m_fOffsetRot = 0.0f;
ROT_INIT(m_Rotation);
m_hstrObjectivesText = DNULL;
m_hstrObjectivesTitle = DNULL;
m_dwAmmo = 0;
m_dwAltAmmo = 0;
m_hCtfCapturedString1 = DNULL;
m_hCtfCapturedString2 = DNULL;
#ifdef _ADDON
m_hSoccerGoalString1 = DNULL;
m_hSoccerGoalString2 = DNULL;
#endif // _ADDON
m_nLastLoadType = LOADTYPE_NEW_GAME;
m_bUseReverb = DFALSE;
m_fReverbLevel = 0.0f;
VEC_INIT( m_vLastReverbPos );
m_bNetFriendlyFire = DFALSE;
m_bNetNegTeamFrags = DFALSE;
m_bNetOnlyFlagScores = DFALSE;
m_bNetOnlyGoalScores = DFALSE;
m_nTrapped = 0;
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CBloodClientShell::~CBloodClientShell()
//
// PURPOSE: Destruction
//
// ----------------------------------------------------------------------- //
CBloodClientShell::~CBloodClientShell()
{
CClientDE* pClientDE = GetClientDE();
if (m_pMoveMgr)
{
delete m_pMoveMgr;
m_pMoveMgr = DNULL;
}
if (m_pWeapon) delete m_pWeapon;
if (m_pLWeapon) delete m_pLWeapon;
g_pBloodClientShell = DNULL;
if( m_hCurrentItemName )
pClientDE->FreeString( m_hCurrentItemName );
if( m_hCurrentItemIcon )
pClientDE->FreeString( m_hCurrentItemIcon );
if( m_hCurrentItemIconH )
pClientDE->FreeString( m_hCurrentItemIconH );
if( m_hPrevItemIcon )
pClientDE->FreeString( m_hPrevItemIcon );
if( m_hNextItemIcon )
pClientDE->FreeString( m_hNextItemIcon );
if( m_hNightGogglesSound )
{
g_pClientDE->KillSound( m_hNightGogglesSound );
}
if( m_hTheEyeLoopingSound )
{
g_pClientDE->KillSound( m_hTheEyeLoopingSound );
}
if( m_hContainerSound)
{
g_pClientDE->KillSound( m_hContainerSound );
}
if( m_hstrTitle )
g_pClientDE->FreeString( m_hstrTitle );
if( m_hstrLoadScreen )
g_pClientDE->FreeString( m_hstrLoadScreen );
if( m_hstrObjectivesText )
g_pClientDE->FreeString( m_hstrObjectivesText );
if( m_hstrObjectivesTitle )
g_pClientDE->FreeString( m_hstrObjectivesTitle );
if (m_hCtfCapturedString1)
g_pClientDE->FreeString(m_hCtfCapturedString1);
if (m_hCtfCapturedString2)
g_pClientDE->FreeString(m_hCtfCapturedString2);
#ifdef _ADDON
if (m_hSoccerGoalString1)
g_pClientDE->FreeString(m_hSoccerGoalString1);
if (m_hSoccerGoalString2)
g_pClientDE->FreeString(m_hSoccerGoalString2);
#endif // _ADDON
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CBloodClientShell::InitSound
//
// PURPOSE: Initialize the sounds
//
// ----------------------------------------------------------------------- //
DRESULT CBloodClientShell::InitSound()
{
Sound3DProvider *pSound3DProviderList, *pSound3DProvider;
InitSoundInfo soundInfo;
ReverbProperties reverbProperties;
HCONSOLEVAR hVar;
DDWORD dwProviderID;
char sz3dSoundProviderName[_MAX_PATH + 1];
DRESULT res;
CClientDE* pClientDE = GetClientDE();
if( !pClientDE )
return LT_ERROR;
INITSOUNDINFO_INIT(soundInfo);
// Reload the sounds if there are any
soundInfo.m_dwFlags = INITSOUNDINFOFLAG_RELOADSOUNDS;
// Get the 3d sound provider id.
hVar = pClientDE->GetConsoleVar( "3DSoundProvider" );
if( hVar )
{
dwProviderID = ( DDWORD )pClientDE->GetVarValueFloat( hVar );
}
else
dwProviderID = SOUND3DPROVIDERID_NONE;
// Can also be set by provider name, in which case the id will be set to UNKNOWN.
if( dwProviderID == SOUND3DPROVIDERID_NONE || dwProviderID == SOUND3DPROVIDERID_UNKNOWN )
{
sz3dSoundProviderName[0] = 0;
hVar = pClientDE->GetConsoleVar( "3DSoundProviderName" );
if( hVar )
{
SAFE_STRCPY( sz3dSoundProviderName, pClientDE->GetVarValueString( hVar ));
dwProviderID = SOUND3DPROVIDERID_UNKNOWN;
}
}
// See if the provider exists.
if( dwProviderID != SOUND3DPROVIDERID_NONE )
{
pClientDE->GetSound3DProviderLists( pSound3DProviderList, DFALSE );
if( !pSound3DProviderList )
return LT_NO3DSOUNDPROVIDER;
pSound3DProvider = pSound3DProviderList;
while( pSound3DProvider )
{
// If the provider is selected by name, then compare the names.
if( dwProviderID == SOUND3DPROVIDERID_UNKNOWN )
{
if( _mbscmp(( const unsigned char * )sz3dSoundProviderName, ( const unsigned char * )pSound3DProvider->m_szProvider ) == 0 )
break;
}
// Or compare by the id's.
else if( pSound3DProvider->m_dwProviderID == dwProviderID )
break;
// Not this one, try next one.
pSound3DProvider = pSound3DProvider->m_pNextProvider;
}
// Check if we found one.
if( pSound3DProvider )
{
// Use this provider.
SAFE_STRCPY( soundInfo.m_sz3DProvider, pSound3DProvider->m_szProvider );
// Get the maximum number of 3d voices to use.
hVar = pClientDE->GetConsoleVar( "Max3DVoices" );
if( hVar )
{
soundInfo.m_nNum3DVoices = ( DBYTE )g_pClientDE->GetVarValueFloat( hVar );
}
else
soundInfo.m_nNum3DVoices = 16;
}
pClientDE->ReleaseSound3DProviderList( pSound3DProviderList );
}
// Get the maximum number of sw voices to use.
hVar = pClientDE->GetConsoleVar( "MaxSWVoices" );
if( hVar )
{
soundInfo.m_nNumSWVoices = ( DBYTE )g_pClientDE->GetVarValueFloat( hVar );
}
else
soundInfo.m_nNumSWVoices = 32;
soundInfo.m_nSampleRate = 22050;
soundInfo.m_nBitsPerSample = 16;
if ((hVar = pClientDE->GetConsoleVar("soundvolume")))
{
soundInfo.m_nVolume = (unsigned short)(pClientDE->GetVarValueFloat(hVar));
}
DBOOL b8bitOnly = DFALSE;
hVar = pClientDE->GetConsoleVar("sound16bit");
if (hVar)
{
b8bitOnly = (pClientDE->GetVarValueFloat(hVar) == 0.0f) ? DTRUE : DFALSE;
}
if( b8bitOnly )
soundInfo.m_dwFlags |= INITSOUNDINFOFLAG_CONVERT16TO8;
DFLOAT fMinStreamSoundTime = 0.5f;
hVar = pClientDE->GetConsoleVar ("MinStreamTime");
if (hVar)
{
fMinStreamSoundTime = pClientDE->GetVarValueFloat (hVar);
fMinStreamSoundTime = (fMinStreamSoundTime < 0.2f ? 0.2f :
(fMinStreamSoundTime > 1.5f ? 1.5f : fMinStreamSoundTime));
}
soundInfo.m_fMinStreamTime = fMinStreamSoundTime;
soundInfo.m_fDistanceFactor = 1.0f / 64.0f;
// Go initialize the sounds.
m_bUseReverb = DFALSE;
if(( res = pClientDE->InitSound(&soundInfo)) == LT_OK )
{
if( soundInfo.m_dwResults & INITSOUNDINFORESULTS_REVERB )
{
m_bUseReverb = DTRUE;
}
hVar = pClientDE->GetConsoleVar( "ReverbLevel" );
if( hVar )
{
m_fReverbLevel = g_pClientDE->GetVarValueFloat( hVar );
}
else
m_fReverbLevel = 1.0f;
reverbProperties.m_dwParams = REVERBPARAM_VOLUME;
reverbProperties.m_fVolume = m_fReverbLevel;
pClientDE->SetReverbProperties( &reverbProperties );
}
return res;
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CBloodClientShell::CSPrint
//
// PURPOSE: Displays a line of text on the client
//
// ----------------------------------------------------------------------- //
void CBloodClientShell::CSPrint (char* msg, ...)
{
CClientDE* pClientDE = GetClientDE();
// parse the message
char pMsg[256];
va_list marker;
va_start (marker, msg);
int nSuccess = vsprintf (pMsg, msg, marker);
va_end (marker);
if (nSuccess < 0) return;
// now display the message
m_MessageMgr.AddLine(pMsg);
pClientDE->CPrint(pMsg);
}
void CBloodClientShell::CSPrint(int nStringID)
{
CClientDE* pClientDE = GetClientDE();
if (!pClientDE) return;
HSTRING hString = pClientDE->FormatString(nStringID);
if (!hString) return;
CSPrint(pClientDE->GetStringData(hString));
pClientDE->FreeString(hString);
}
void CBloodClientShell::CSPrint2(char* msg)
{
CClientDE* pClientDE = GetClientDE();
if (!pClientDE) return;
m_MessageMgr.AddLine(msg);
pClientDE->CPrint(msg);
}
// --------------------------------------------------------------------------- //
//
// ROUTINE: CBloodClientShell::OnEvent()
//
// PURPOSE: Engine event handler
//
// --------------------------------------------------------------------------- //
void CBloodClientShell::OnEvent(DDWORD dwEventID, DDWORD dwParam)
{
// Handle any events we want to deal with...
switch (dwEventID)
{
case LTEVENT_DISCONNECT:
{
if (!g_bIsHost)
{
CSPrint(IDS_SERVERDISCONNECT);
PlaySound(MSG_SOUND_STRING);
}
break;
}
}
// Let the base class handle the even too...
CClientShellDE::OnEvent(dwEventID, dwParam);
}
// --------------------------------------------------------------------------- //
//
// ROUTINE: CBloodClientShell::OnEngineInitialized()
//
// PURPOSE: Called upon engine initialization.
//
// --------------------------------------------------------------------------- //
DRESULT CBloodClientShell::OnEngineInitialized(RMode *pMode, DGUID *pAppGuid)
{
// Local variables...
HCONSOLEVAR hVar;
CClientDE* pClientDE = GetClientDE();
DBOOL bPlayingMovies = DFALSE;
DRESULT resInitSound;
HSTRING hstrError;
char *pszError;
// Set the guid...
*pAppGuid = BLOOD2GUID;
// Init Move mgr...
m_pMoveMgr = new CMoveMgr(this);
if(!m_pMoveMgr)
return LT_ERROR;
m_pMoveMgr->Init(pClientDE);
// Initialize The Voice data...
TheVoice_Init(pClientDE);
// Initialize the physics states...
g_normalPhysicsState.m_pClientDE = pClientDE;
VEC_SET(g_normalPhysicsState.m_GravityAccel, 0.0f, -1000.0f, 0.0f);
g_normalPhysicsState.m_VelocityDampen = 0.35f;
g_waterPhysicsState.m_pClientDE = pClientDE;
VEC_SET(g_waterPhysicsState.m_GravityAccel, 0.0f, -500.0f, 0.0f);
g_waterPhysicsState.m_VelocityDampen = 0.20f;
// Initialize sound...
resInitSound = InitSound();
// Add to NumRuns count...
float nNumRuns = 0.0f;
hVar = pClientDE->GetConsoleVar ("NumRuns");
if (hVar)
{
nNumRuns = pClientDE->GetVarValueFloat (hVar);
}
nNumRuns++;
char strConsole[64];
sprintf (strConsole, "+NumRuns %f", nNumRuns);
pClientDE->RunConsoleString (strConsole);
// Format some strings...
m_hCtfCapturedString1 = pClientDE->FormatString(IDS_CTF_CAPTURED_1);
m_hCtfCapturedString2 = pClientDE->FormatString(IDS_CTF_CAPTURED_2);
#ifdef _ADDON
m_hSoccerGoalString1 = pClientDE->FormatString(IDS_SOCCER_GOAL_1);
m_hSoccerGoalString2 = pClientDE->FormatString(IDS_SOCCER_GOAL_2);
#endif // _ADDON
// check advanced options...
hVar = pClientDE->GetConsoleVar ("DisableMusic");
if (hVar && pClientDE->GetVarValueFloat (hVar)) m_bAdvancedDisableMusic = DTRUE;
hVar = pClientDE->GetConsoleVar ("DisableSound");
if (hVar && pClientDE->GetVarValueFloat (hVar)) m_bAdvancedDisableSound = DTRUE;
hVar = pClientDE->GetConsoleVar ("DisableMovies");
if (hVar && pClientDE->GetVarValueFloat (hVar)) m_bAdvancedDisableMovies = DTRUE;
hVar = pClientDE->GetConsoleVar ("DisableJoystick");
if (hVar && pClientDE->GetVarValueFloat (hVar)) m_bAdvancedDisableJoystick = DTRUE;
hVar = pClientDE->GetConsoleVar ("EnableOptSurf");
if (hVar && pClientDE->GetVarValueFloat (hVar)) m_bAdvancedEnableOptSurf = DTRUE;
hVar = pClientDE->GetConsoleVar ("DisableLightMap");
if (hVar && pClientDE->GetVarValueFloat (hVar)) m_bAdvancedDisableLightMap = DTRUE;
hVar = pClientDE->GetConsoleVar ("EnableTripBuf");
if (hVar && pClientDE->GetVarValueFloat (hVar)) m_bAdvancedEnableTripBuf = DTRUE;
hVar = pClientDE->GetConsoleVar ("DisableDx6Cmds");
if (hVar && pClientDE->GetVarValueFloat (hVar)) m_bAdvancedDisableDx6Cmds = DTRUE;
hVar = pClientDE->GetConsoleVar ("EnableTJuncs");
if (hVar && pClientDE->GetVarValueFloat (hVar)) m_bAdvancedEnableTJuncs = DTRUE;
hVar = pClientDE->GetConsoleVar ("DisableFog");
if (hVar && pClientDE->GetVarValueFloat (hVar)) m_bAdvancedDisableFog = DTRUE;
hVar = pClientDE->GetConsoleVar ("DisableLines");
if (hVar && pClientDE->GetVarValueFloat (hVar)) m_bAdvancedDisableLines = DTRUE;
hVar = pClientDE->GetConsoleVar ("DisableModelFB");
if (hVar && pClientDE->GetVarValueFloat (hVar)) m_bAdvancedDisableModelFB = DTRUE;
hVar = pClientDE->GetConsoleVar ("EnablePixDub");
if (hVar && pClientDE->GetVarValueFloat (hVar)) m_bAdvancedEnablePixelDoubling = DTRUE;
hVar = pClientDE->GetConsoleVar ("EnableMultiTex");
if (hVar && pClientDE->GetVarValueFloat (hVar)) m_bAdvancedEnableMultiTexturing = DTRUE;
// Set the detail console variables
MenuSetDetail();
// Set the player cursor display
hVar = pClientDE->GetConsoleVar ("Crosshair");
if(hVar && pClientDE->GetVarValueFloat(hVar))
{
m_bShowCrosshair = DTRUE;
m_bCrosshairOriginallyOn = DTRUE;
}
else
{
m_bShowCrosshair = DFALSE;
m_bCrosshairOriginallyOn = DFALSE;
}
hVar = pClientDE->GetConsoleVar ("CrosshairNum");
m_nCrosshair = (DBYTE)pClientDE->GetVarValueFloat(hVar);
if(m_nCrosshair > 41) m_nCrosshair = 0;
m_nCrosshairOriginalNum = m_nCrosshair;
// Set the player movement variables (mouselook)
hVar = pClientDE->GetConsoleVar ("MouseLook");
if(hVar && pClientDE->GetVarValueFloat(hVar))
{
m_bMouseLook = DTRUE;
// cdata.byFlags |= CDATA_MOUSEAIMING;
}
else
{
m_bMouseLook = DFALSE;
// cdata.byFlags &= ~CDATA_MOUSEAIMING;
}
// Set the player movement variables (lookspring)
hVar = pClientDE->GetConsoleVar ("LookSpring");
if(hVar && pClientDE->GetVarValueFloat(hVar))
{
m_bLookSpring = DTRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -