📄 bloodclientshell.cpp
字号:
else
{
m_bLookSpring = DFALSE;
}
// Set the player movement variables (runlock)
hVar = pClientDE->GetConsoleVar ("RunLock");
if(hVar && pClientDE->GetVarValueFloat(hVar))
cdata.byFlags |= CDATA_RUNLOCK;
else
cdata.byFlags &= ~CDATA_RUNLOCK;
// Turn on client side prediction
pClientDE->RunConsoleString("Prediction 1");
// Determine if we were lobby launched...
DBOOL bNetworkGameStarted = DFALSE;
DBOOL bLobbyLaunched = DFALSE;
#ifndef _DEMO
DRESULT dr = pClientDE->IsLobbyLaunched("dplay2");
if (dr == LT_OK)
{
DBOOL bRet = NetStart_DoLobbyLaunchWizard(pClientDE);
if (bRet)
{
bLobbyLaunched = DTRUE;
bNetworkGameStarted = DTRUE;
}
else
{
pClientDE->Shutdown();
return LT_ERROR;
}
}
#endif
// Check for console vars that say we should do networking setup stuff...
DBOOL bDoNetStuff = DFALSE;
hVar = pClientDE->GetConsoleVar("Multiplayer");
if (hVar)
{
if ((DBOOL)pClientDE->GetVarValueFloat(hVar)) bDoNetStuff = DTRUE;
}
hVar = pClientDE->GetConsoleVar("ConnectPlr");
if (hVar)
{
char* sVar = pClientDE->GetVarValueString(hVar);
if (sVar && sVar[0] != '\0' && _mbscmp((const unsigned char*)sVar, (const unsigned char*)"0") != 0) bDoNetStuff = DTRUE;
}
hVar = pClientDE->GetConsoleVar("Connect");
if (hVar)
{
char* sVar = pClientDE->GetVarValueString(hVar);
if (sVar && sVar[0] != '\0' && _mbscmp((const unsigned char*)sVar, (const unsigned char*)"0") != 0) bDoNetStuff = DTRUE;
}
if (bLobbyLaunched) bDoNetStuff = DFALSE;
#ifdef _DEMO
bDoNetStuff = DFALSE;
#endif
// Determine if we should display the networking dialogs...
if (bDoNetStuff)
{
bNetworkGameStarted = NetStart_DoWizard (pClientDE);
if (!bNetworkGameStarted)
{
pClientDE->Shutdown();
return LT_ERROR;
}
}
// Pass RMode on to SetRenderMode...
DRESULT hResult = pClientDE->SetRenderMode(pMode);
if (hResult != LT_OK)
{
// If an error occurred, try 640x480x16...
RMode rMode;
rMode.m_Width = 640;
rMode.m_Height = 480;
rMode.m_BitDepth = 16;
rMode.m_bHardware = pMode->m_bHardware;
sprintf(rMode.m_RenderDLL, "%s", pMode->m_RenderDLL);
sprintf(rMode.m_InternalName, "%s", pMode->m_InternalName);
sprintf(rMode.m_Description, "%s", pMode->m_Description);
if (pClientDE->SetRenderMode(&rMode) != LT_OK)
{
// Okay, that didn't work, looks like we're stuck with software...
rMode.m_bHardware = DFALSE;
sprintf(rMode.m_RenderDLL, "soft.ren");
sprintf(rMode.m_InternalName, "");
sprintf(rMode.m_Description, "");
if (pClientDE->SetRenderMode(&rMode) != LT_OK)
{
Abort(IDS_ERR_SETVIDMODE, 6929314);
return LT_ERROR;
}
}
}
// Draw the loading screen if we are hosting a network game already...
if (bNetworkGameStarted && g_bIsHost)
{
DrawLoadingScreen();
pClientDE->FlipScreen(FLIPSCREEN_CANDRAWCONSOLE);
DrawLoadingScreen();
}
// Register console commands
pClientDE->RegisterConsoleProgram("LeakFile", LeakFileFn);
pClientDE->RegisterConsoleProgram("Connect", ConnectFn);
pClientDE->RegisterConsoleProgram("FragSelf", FragSelfFn);
pClientDE->RegisterConsoleProgram("InitSound", InitSoundFn);
pClientDE->RegisterConsoleProgram("NextLevel", NextLevelFn);
pClientDE->RegisterConsoleProgram("Load", LoadLevelFn);
// Try to initialize the level manager (including
// if (!m_LevelMgr.Init(pClientDE))
// {
// PrintError("Could not init LevelMgr");
// return LT_ERROR;
// }
// Setup the music stuff...
if( !m_Music.IsInitialized( ))
{
HCONSOLEVAR hConsoleVar;
hConsoleVar = pClientDE->GetConsoleVar( "musictype" );
// Default to ima if music never set before...
if( !hConsoleVar )
m_Music.Init( pClientDE, DTRUE );
else
{
// See if they want cdaudio or ima...
if(_mbsicmp((const unsigned char*)pClientDE->GetVarValueString( hConsoleVar ), (const unsigned char*)"cdaudio" ) == 0 )
m_Music.Init( pClientDE, DFALSE );
else
m_Music.Init( pClientDE, DTRUE );
}
}
// Set the sound volume
hVar = pClientDE->GetConsoleVar("SoundVolume");
if (hVar)
{
pClientDE->SetSoundVolume((int)pClientDE->GetVarValueFloat(hVar));
}
else
{
pClientDE->SetSoundVolume(35);
}
// Set the music volume
hVar = pClientDE->GetConsoleVar("MusicVolume");
if (hVar)
{
pClientDE->SetMusicVolume((int)pClientDE->GetVarValueFloat(hVar));
}
else
{
pClientDE->SetMusicVolume(35);
}
// Set the mouse sensitivity
m_fOriginalMouseSensitivity = GetMouseSensitivity();
// SetMouseSensitivity(m_fOriginalMouseSensitivity);
m_fOriginalKeyTurnRate = GetKeyboardTurnRate();
// SetKeyboardTurnRate(m_fOriginalKeyTurnRate);
// Set the invert y-axis variable
hVar=pClientDE->GetConsoleVar("MouseInvertYAxis");
if (hVar && (int)pClientDE->GetVarValueFloat(hVar) != 0)
{
m_bMouseInvertYAxis=DTRUE;
}
else
{
m_bMouseInvertYAxis=DFALSE;
}
// Set the use joystick variable
hVar=pClientDE->GetConsoleVar("UseJoystick");
if (hVar && (int)pClientDE->GetVarValueFloat(hVar) != 0)
{
m_bUseJoystick=DTRUE;
}
else
{
m_bUseJoystick=DFALSE;
}
// Set the keyboard turn rate
hVar=pClientDE->GetConsoleVar("KeyboardTurnRate");
if (hVar)
{
m_fKeyboardTurnRate=pClientDE->GetVarValueFloat(hVar);
}
else
{
m_fKeyboardTurnRate=1.0f;
}
/*
if (m_Music.IsInitialized())
{
// Only re-init if not already using ima...
if (!m_Music.UsingIMA())
{
// preserve the music level, just in case we come back to ima...
CMusic::EMusicLevel level;
level = m_Music.GetMusicLevel();
if (m_Music.Init (pClientDE, DTRUE))
{
// Only start the music if we are in a world...
if (IsInWorld() && !pClientShell->IsFirstUpdate())
{
m_Music.InitPlayLists();
m_Music.PlayMusicLevel (level);
}
}
}
}
*/
// Set the model hook function to do special model rendering...
pClientDE->SetModelHook((ModelHookFn)DefaultModelHook, this);
// Initialize the Message Mgr (T option)
m_MessageMgr.Init(pClientDE);
m_MessageMgr.Enable(DTRUE);
// Initialize the Cheat Manager
m_CheatMgr.Init(pClientDE);
#ifndef _DEMO
m_FragInfo.Init(pClientDE, GetTeamMgr());
#endif
HSTRING szErrorStr = 0;
// Initialize the Status bar
if (!m_NewStatusBar.Init(pClientDE))
{
szErrorStr = pClientDE->FormatString(IDS_INITERR_STATUS);
CSPrint(pClientDE->GetStringData(szErrorStr));
pClientDE->FreeString(szErrorStr);
Abort(IDS_ERR_INITSTATUSBAR, 6929318);
return LT_ERROR;
}
// Initialize the Status bar
if (!m_CommLink.Init(pClientDE))
{
szErrorStr = pClientDE->FormatString(IDS_INITERR_COMMLINK);
CSPrint(pClientDE->GetStringData(szErrorStr));
pClientDE->FreeString(szErrorStr);
Abort(IDS_ERR_INITSTATUSBAR, 6929317);
return LT_ERROR;
}
// Initialize the Menu
if (!m_Menu.Init (pClientDE))
{
szErrorStr = pClientDE->FormatString(IDS_INITERR_MENUS);
CSPrint(pClientDE->GetStringData(szErrorStr));
pClientDE->FreeString(szErrorStr);
Abort(IDS_ERR_INITMENU, 6929316);
return LT_ERROR;
}
// Init the special fx mgr...
if (!m_sfxMgr.Init(pClientDE))
{
szErrorStr = pClientDE->FormatString(IDS_INITERR_SFX);
CSPrint(pClientDE->GetStringData(szErrorStr));
pClientDE->FreeString(szErrorStr);
Abort(IDS_ERR_INITSFXMGR, 6929315);
return LT_ERROR;
}
// Init the voice manager...
if (!m_VoiceMgr.Init(pClientDE))
{
szErrorStr = pClientDE->FormatString(IDS_INITERR_VOICE);
CSPrint(pClientDE->GetStringData(szErrorStr));
pClientDE->FreeString(szErrorStr);
Abort(IDS_ERR_INITVOICEMGR, 61011701);
return LT_ERROR;
}
if (!m_playerCamera.Init(pClientDE))
{
szErrorStr = pClientDE->FormatString(IDS_INITERR_CAMERA);
CSPrint(pClientDE->GetStringData(szErrorStr));
pClientDE->FreeString(szErrorStr);
Abort(IDS_ERR_INITPLAYERCAMERA, 6929318);
return LT_ERROR;
}
else
{
DVector vOffset;
VEC_SET(vOffset, 0.0f, 30.0f, 0.0f);
// m_playerCamera.SetDistUp(1000.0f);
// m_playerCamera.SetPointAtOffset(vOffset);
// m_playerCamera.SetChaseOffset(vOffset);
m_playerCamera.SetDeathOffset(vOffset);
m_playerCamera.SetFirstPerson();
m_b3rdPerson = DFALSE;
}
if (!bNetworkGameStarted)
{
StartGameRequest request;
memset( &request, 0, sizeof( StartGameRequest ));
NetStart_ClearGameStruct(); // Start with clean slate
request.m_pGameInfo = NetStart_GetGameStruct();
request.m_GameInfoLen = sizeof(NetGame_t);
HCONSOLEVAR hVar;
// Set the Console lines
if (hVar = pClientDE->GetConsoleVar("NumConsoleLines"))
{
DFLOAT fLines = pClientDE->GetVarValueFloat(hVar);
// m_MessageMgr.SetMaxMessages((int)fLines);
m_MessageMgr.SetMaxMessages((int)6);
pClientDE->RunConsoleString("NumConsoleLines 0");
}
// Get the command line world, if found
if (hVar = pClientDE->GetConsoleVar("runworld"))
{
char *pWorldName = pClientDE->GetVarValueString(hVar);
StartNewGame(pWorldName, STARTGAME_NORMAL, GAMETYPE_CUSTOM, LOADTYPE_NEW_GAME, DIFFICULTY_MEDIUM);
m_bFirstWorld = DTRUE;
}
else
{
if (!StartMovies(pClientDE))
{
bPlayingMovies = DFALSE;
SetGameState(GS_MENU);
m_Menu.SetCurrentMenu(MENU_ID_MAINMENU, MENU_ID_MAINMENU);
}
else
{
bPlayingMovies = DTRUE;
}
}
}
else
{
// Set the game state for a net game that is loading...
SetGameState(GS_MPLOADINGLEVEL);
}
// Display the title screen if we're not playing movies...
HSURFACE hTitleSurface = DNULL;
DFLOAT fTitleTime = CWinUtil::GetTime();
if (!bPlayingMovies && !bNetworkGameStarted)
{
#ifndef _DEBUG
#ifdef _ADDON
hTitleSurface = Splash_Display(pClientDE, "\\screens_ao\\title.pcx", DTRUE);
#else
hTitleSurface = Splash_Display(pClientDE, "\\screens\\title.pcx", DTRUE);
#endif
fTitleTime = CWinUtil::GetTime();
#endif
}
// Read the player.cfg file, or defaultplayer.cfg if you can't find it.
// if (!LoadConfig("player.cfg", &m_Config))
// LoadConfig("defaultplayer.cfg", &m_Config);
#ifdef BRANDED
// Initialize brand stuff
CreateBrandSurface();
#endif
// Seed the random number generator
if ( pClientDE )
{
int nSeed=(int)(CWinUtil::GetTime() * 1000.0f);
srand(nSeed);
}
// Initialize the message box font
m_messageFont.Init(pClientDE, "interface/fonts/MenuFont1.pcx", "interface/fonts/MenuFont1.fnt");
// Initialize the message box
m_messageBox.Create(pClientDE, "interface/mainmenus/dialog.pcx", &m_messageFont, DNULL, DNULL);
m_messageBox.SetTextColor(SETRGB(255, 255, 255));
// Make sure the title screen has been up long enough...
if (hTitleSurface)
{
#ifndef _DEBUG
CWinUtil::TimedKeyWait(VK_ESCAPE, VK_RETURN, VK_SPACE, 6.0f);
#endif
pClientDE->DeleteSurface(hTitleSurface);
hTitleSurface = DNULL;
CWinUtil::Sleep(50);
}
// Remove any stray keypresses...
CWinUtil::RemoveKeyDownMessages();
// Show error if sound didn't initialize properly
if( resInitSound != LT_OK )
{
if( resInitSound == LT_NO3DSOUNDPROVIDER )
{
hstrError = pClientDE->FormatString( IDS_MESSAGE_INVALID3DSOUNDPROVIDER );
}
else
{
hstrError = pClientDE->FormatString( IDS_MESSAGE_SOUNDERROR );
}
pszError = pClientDE->GetStringData( hstrError );
DoMessageBox( pszError );
pClientDE->FreeString( hstrError );
}
// All done...
return LT_OK;
}
// --------------------------------------------------------------------------- //
//
// ROUTINE: CBloodClientShell::OnEngineTerm()
//
// PURPOSE: Called upon engine termination.
//
// --------------------------------------------------------------------------- //
void CBloodClientShell::OnEngineTerm()
{
CClientDE* pClientDE = GetClientDE();
m_Menu.Term();
m_MessageMgr.Term();
m_VoiceMgr.Term();
m_NewStatusBar.Term();
m_CommLink.Term();
m_Music.Term( );
if (m_Credits.IsInited())
m_Credits.Term();
if (m_hCrosshair)
pClientDE->DeleteSurface(m_hCrosshair);
// Terminate the message box and its font
m_messageFont.Term();
m_messageBox.Destroy();
// Deal with some advanced options...
if (m_bSoundOriginallyEnabled && AdvancedDisableSound())
{
pClientDE->RunConsoleString ("SoundEnable 1");
}
if (m_bMusicOriginallyEnabled && AdvancedDisableMusic())
{
pClientDE->RunConsoleString ("MusicEnable 1");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -