📄 bloodclientshell.cpp
字号:
//----------------------------------------------------------
//
// MODULE : BloodClientShell.cpp
//
// PURPOSE : Blood 2 Client shell
//
// CREATED : 9/21/97
//
//----------------------------------------------------------
// includes...
#include <stdarg.h>
#include <stdio.h>
#include "BloodClientShell.h"
#include "ViewWeapon.h"
#include "Commands.h"
#include "VKDefs.h"
#include "ClientRes.h"
#include "SfxMsgIds.h"
#include "ClientUtilities.h"
#include "LoadSave.h"
#include "VolumeBrushFX.h"
#include "CameraFX.h"
#include "client_physics.h"
#include "NetStart.h"
#include "TheVoice.h"
#include "WinUtil.h"
#include "ClientRes.h"
#include "LoadScreenData.h"
#include "Splash.h"
#include "MoveMgr.h"
#include "WeaponDefs.h"
#include "GameWeapons.h"
#include "SoundTypes.h"
#include "physics_lt.h"
PhysicsState g_normalPhysicsState;
PhysicsState g_waterPhysicsState;
//#define FLAG_BASECHARACTER 1
// defines...
#define BOBV_WALKING 24.0f
#define BOBH_WALKING 16.0f
#define SWAYV_WALKING 32.0f
#define SWAYH_WALKING 80.0f
#define BOBV_CRAWLING 24.0f
#define BOBH_CRAWLING 16.0f
#define SWAYV_CRAWLING 16.0f
#define SWAYH_CRAWLING 40.0f
#define FOV_NORMAL 90.0f
#define FOV_SEEING_EYE 120.0f
#define FOV_ZOOMED 12.5f
#define MOVIE_STARTLITH 1
#define MOVIE_PLAYINGLITH 2
#define MOVIE_STARTGTI 3
#define MOVIE_PLAYINGGTI 4
#define MOVIE_STARTINTRO 5
#define MOVIE_PLAYINGINTRO 6
#define MOVIE_FINISHED 7
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define SOUND_REVERB_UPDATE_PERIOD 0.33f
#define PLAYER_MULTI_UPDATE_TIMER 0.14f
#define MSG_SOUND_STRING "sounds\\events\\woodclank2a.wav"
// Guids...
#ifdef _ADDON
DGUID BLOOD2GUID = { /* Add-On */
0xc13e628, 0x418c, 0x11d2, 0x86, 0xa, 0x0, 0x60, 0x97, 0x18, 0xa9, 0x42
};
#else
DGUID BLOOD2GUID = { /* 0C13E629-419C-11D2-860A-00609719A842 */
0xc13e629, 0x419c, 0x11d2, 0x86, 0xa, 0x0, 0x60, 0x97, 0x19, 0xa8, 0x42
};
#endif
// Misc...
char msgbuf[513];
DBOOL g_bAborting = DFALSE;
DBOOL g_bIsHost = DFALSE;
DBOOL g_bLevelChange3rdPersonCam = DFALSE;
DBOOL g_bLevelChangeNoUpdate = DFALSE;
DBOOL g_bPlayerInvReset = DFALSE;
DFLOAT g_fPlayerUpdateTimer = 0.0f;
#ifdef _ADDON
static char *s_szCheerSounds[] =
{
"sounds_ao\\events\\cheer1.wav",
"sounds_ao\\events\\cheer2.wav"
};
#define NUMCHEERSOUNDS ( sizeof( s_szCheerSounds ) / sizeof( s_szCheerSounds[0] ))
static char *s_szBooSounds[] =
{
"sounds_ao\\events\\boo1.wav",
"sounds_ao\\events\\boo2.wav",
"sounds_ao\\events\\boo3.wav"
};
#define NUMBOOSOUNDS ( sizeof( s_szBooSounds ) / sizeof( s_szBooSounds[0] ))
#endif // _ADDON
// Global pointer to the client shell..
CBloodClientShell *g_pBloodClientShell = DNULL;
// Prototypes..
DBOOL ConnectToTcpIpAddress(CClientDE* pClientDE, char* sAddress);
// Setup..
SETUP_CLIENTSHELL();
ClientShellDE* CreateClientShell(ClientDE *pClientDE)
{
g_pClientDE = pClientDE;
return (ClientShellDE*)(new CBloodClientShell);
}
void DeleteClientShell(ClientShellDE *pInputShell)
{
if (pInputShell)
{
delete ((CBloodClientShell*)pInputShell);
}
}
void CShell_GetConsoleString(char* sKey, char* sDest, char* sDefault)
{
if (g_pClientDE)
{
HCONSOLEVAR hVar = g_pClientDE->GetConsoleVar(sKey);
if (hVar)
{
char* sValue = g_pClientDE->GetVarValueString(hVar);
if (sValue)
{
strcpy(sDest, sValue);
return;
}
}
}
strcpy(sDest, sDefault);
}
static DBOOL LoadLeakFile(ClientDE *pClientDE, char *pFilename);
void LeakFileFn(int argc, char **argv)
{
if (argc < 0)
{
g_pBloodClientShell->GetClientDE()->CPrint("LeakFile <filename>");
return;
}
if (LoadLeakFile(g_pBloodClientShell->GetClientDE(), argv[0]))
{
g_pBloodClientShell->GetClientDE()->CPrint("Leak file %s loaded successfully!", argv[0]);
}
else
{
g_pBloodClientShell->GetClientDE()->CPrint("Unable to load leak file %s", argv[0]);
}
}
void ConnectFn(int argc, char **argv)
{
if (argc <= 0)
{
g_pBloodClientShell->GetClientDE()->CPrint("Connect <tcpip address> (use '*' for local net)");
return;
}
ConnectToTcpIpAddress(g_pBloodClientShell->GetClientDE(), argv[0]);
}
void NextLevelFn(int argc, char **argv)
{
if (g_bIsHost)
{
ClientDE *pClientDE;
HMESSAGEWRITE hWrite;
pClientDE = g_pBloodClientShell->GetClientDE();
hWrite = pClientDE->StartMessage(CMSG_NEXTLEVEL);
pClientDE->EndMessage(hWrite);
}
else
{
g_pBloodClientShell->GetClientDE()->CPrint("Only the host can change levels");
}
}
void LoadLevelFn(int argc, char **argv)
{
if (argc >= 1 && argv[0])
{
g_pBloodClientShell->StartNewGame(argv[0]);
}
else
{
g_pBloodClientShell->GetClientDE()->CPrint("Usage: load <level-name>");
}
}
void CBloodClientShell::StartNewGame(char *pszWorld)
{
if (!pszWorld) return;
if (m_bInWorld)
{
StartNewWorld(pszWorld, m_nGameType, LOADTYPE_NEW_LEVEL);
}
else
{
StartNewGame(pszWorld, STARTGAME_NORMAL, GAMETYPE_CUSTOM, LOADTYPE_NEW_GAME, DIFFICULTY_MEDIUM);
m_bFirstWorld = DTRUE;
}
}
void FragSelfFn(int argc, char **argv)
{
ClientDE *pClientDE;
HMESSAGEWRITE hWrite;
pClientDE = g_pBloodClientShell->GetClientDE();
hWrite = pClientDE->StartMessage(CMSG_FRAGSELF);
pClientDE->EndMessage(hWrite);
}
void InitSoundFn(int argc, char **argv)
{
if( g_pBloodClientShell )
g_pBloodClientShell->InitSound( );
}
/*
// --------------------------------------------------------------------------- //
//
// ROUTINE: AuraModelHook
//
// PURPOSE: Special Rendering Code for Aura spell
//
// --------------------------------------------------------------------------- //
void AuraModelHook (struct ModelHookData_t *pData, void *pUser)
{
CClientDE* pClientDE = (CClientDE*) pUser;
if (!pClientDE ) return;
DDWORD nUserFlags = 0;
pClientDE->GetObjectUserFlags (pData->m_hObject, &nUserFlags);
if (nUserFlags & FLAG_BASECHARACTER)
{
pData->m_Flags &= ~MHF_USETEXTURE;
if (pData->m_LightAdd)
{
VEC_SET (*pData->m_LightAdd, 255.0f, 255.0f, 255.0f);
}
}
}
*/
// --------------------------------------------------------------------------- //
//
// ROUTINE: DefaultModelHook
//
// PURPOSE: Default model hook function
//
// --------------------------------------------------------------------------- //
void DefaultModelHook (struct ModelHookData_t *pData, void *pUser)
{
DDWORD nUserFlags;
DFLOAT fGlowValue, fGlowFactor;
g_pClientDE->GetObjectUserFlags( pData->m_hObject, &nUserFlags );
if( g_pBloodClientShell->NightGogglesActive( ) && nUserFlags & USERFLG_NIGHTGOGGLESGLOW )
{
pData->m_Flags &= ~MHF_USETEXTURE;
if (pData->m_LightAdd)
{
VEC_SET (*pData->m_LightAdd, 0.0f, 255.0f, 0.0f);
}
}
else if( nUserFlags & USRFLG_GLOW )
{
if( pData->m_LightAdd )
{
// Cycle the glow with a period of 2 seconds...
fGlowFactor = ( DFLOAT )sin( g_pClientDE->GetTime( ) * MATH_CIRCLE / 2.0f );
fGlowValue = 128.0f + 128.0f * fGlowFactor;
fGlowValue = DCLAMP( fGlowValue, 0.0f, 255.0f );
VEC_SET( *pData->m_LightAdd, fGlowValue, fGlowValue, fGlowValue );
}
}
// Glow red for anger
else if (nUserFlags & USRFLG_ANGERGLOW)
{
if( pData->m_LightAdd )
{
// Cycle the glow with a period of 0.5 seconds...
fGlowFactor = ( DFLOAT )sin( g_pClientDE->GetTime( ) * MATH_CIRCLE * 6.0f );
fGlowValue = 192.0f + 64.0f * fGlowFactor;
fGlowValue = DCLAMP( fGlowValue, 0.0f, 255.0f );
VEC_SET( *pData->m_LightAdd, fGlowValue, 255.0 - fGlowValue, 255.0 - fGlowValue );
}
}
// Glow green for willpower
else if (nUserFlags & USRFLG_WILLPOWERGLOW)
{
if( pData->m_LightAdd )
{
// Cycle the glow with a period of 0.5 seconds...
fGlowFactor = ( DFLOAT )sin( g_pClientDE->GetTime( ) * MATH_CIRCLE * 6.0f );
fGlowValue = 192.0f + 64.0f * fGlowFactor;
fGlowValue = DCLAMP( fGlowValue, 0.0f, 255.0f );
VEC_SET( *pData->m_LightAdd, 255.0 - fGlowValue, fGlowValue, 255.0 - fGlowValue );
}
}
}
// ----------------------------------------------------------------------- //
//
// ROUTINE: CBloodClientShell::CBloodClientShell()
//
// PURPOSE: constructor
//
// ----------------------------------------------------------------------- //
CBloodClientShell::CBloodClientShell()
{
m_pMoveMgr = DNULL;
m_hCamera = NULL;
m_fPitch = m_fYaw = cdata.fPitch = cdata.fYaw = 0.0f;
for (int i=0;i<CLIENTWEAPONSLOTS;i++)
{
m_abyWeaponID[i] = WEAP_NONE;
m_abyLWeaponID[i] = WEAP_NONE;
}
m_pWeapon = DNULL;
m_pLWeapon = DNULL;
m_hWeapHandObj = DNULL;
m_hLWeapHandObj = DNULL;
m_nGameState = GS_NONE;
m_bInWorld = DFALSE;
m_hCrosshair = NULL;
m_bShowCrosshair = DFALSE;
m_nCrosshair = 0;
m_nLastCrosshair = 0;
m_nCrosshairOriginalNum = 0;
m_bCrosshairOriginallyOn = 0;
m_cxCrosshair = m_cyCrosshair = 0;
m_DefFovX = FOV_NORMAL;
m_fovYScale = 0.80f;
m_fovX = 0;
m_fovY = 0;
m_fCantIncrement = 0.006f; // in radians (.25 degrees)
m_fCantMaxDist = 0.036f; // in radians (2.0 degrees)
m_fCamCant = 0.0f;
cdata.byFlags = 0;
// Set up default attributes
_mbscpy((unsigned char*)m_Config.szName, (const unsigned char*)"Player");
m_Config.nCharacter = CHARACTER_CALEB;
m_Config.nSkin = MULTIPLAY_SKIN_NORMAL;
m_Config.nStrength = 5;
m_Config.nSpeed = 3;
m_Config.nResistance = 3;
m_Config.nMagic = 1;
m_bDrawStatusBar = DTRUE;
m_bDrawFragBar = DFALSE;
m_bRenderCamera = DFALSE;
m_pExternalCamera = DNULL;
m_hSeeingEyeObj = DNULL;
m_hOrbObj = DNULL;
m_hLastOrbObj = DNULL;
m_bBurn = DFALSE;
m_bBlind = DFALSE;
m_bFadeIn = DFALSE;
m_bFadeOut = DFALSE;
m_fFadeVal = 0.0f;
m_fBurnTime = 0.0f;
m_fBlindTime = 0.0f;
m_hstrTitle = DNULL;
m_hstrLoadScreen = DNULL;
m_nLoadScreenID = 0;
// Advanced options
m_bAdvancedDisableMusic = DFALSE;
m_bAdvancedDisableSound = DFALSE;
m_bAdvancedDisableMovies = DFALSE;
m_bAdvancedDisableJoystick = DFALSE;
m_bAdvancedEnableOptSurf = DFALSE;
m_bAdvancedDisableLightMap = DFALSE;
m_bAdvancedEnableTripBuf = DFALSE;
m_bAdvancedDisableDx6Cmds = DFALSE;
m_bAdvancedEnableTJuncs = DFALSE;
m_bAdvancedDisableFog = DFALSE;
m_bAdvancedDisableLines = DFALSE;
m_bAdvancedDisableModelFB = DFALSE;
m_bAdvancedEnablePixelDoubling = DFALSE;
m_bAdvancedEnableMultiTexturing = DFALSE;
// Container init
m_hContainerSound = DNULL;
m_eCurContainerCode = CC_NOTHING;
m_fContainerStartTime = -1.0f;
m_fFovXFXDir = 1.0f;
m_fLastTime = 0.0f;
m_fRotDir = 1.0f;
m_fMaxRot = 0.55f;
m_bFirstUpdate = DFALSE;
m_hLoadingScreen = DNULL;
m_fLoadingFadeTime = 0.0f;
m_bLoadingFadeUp = DTRUE;
m_bPlayedWaitingSound = DFALSE;
m_bHandledStartup = DFALSE;
m_bFirstWorld = DTRUE;
m_SavedGameInfo.LoadInfo();
g_pBloodClientShell = this;
m_bDemoPlayback = DFALSE;
m_bShiftState = DFALSE;
m_bRollCredits = DFALSE;
_mbscpy((unsigned char*)m_szFilename, (const unsigned char*)"");
m_pCreature = DNULL;
#ifdef BRANDED
m_fBrandCounter = 45.0f;
m_hBrandSurface = DNULL;
#endif
m_bIgnoreKeyboardMessage=DFALSE;
g_bAborting = DFALSE;
m_hCurrentItemName = DNULL;
m_hCurrentItemIcon = DNULL;
m_hCurrentItemIconH = DNULL;
m_nCurrentItemCharge = 0;
m_hPrevItemIcon = DNULL;
m_nPrevItemCharge = 0;
m_hNextItemIcon = DNULL;
m_nNextItemCharge = 0;
m_nGlobalDetail = DETAIL_LOW;
m_bMouseInvertYAxis = DFALSE;
m_bUseJoystick = DFALSE;
m_bMouseLook = DTRUE;
m_bLookSpring = DFALSE;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -