summaryrefslogtreecommitdiff
path: root/hammer_launcher
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /hammer_launcher
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'hammer_launcher')
-rw-r--r--hammer_launcher/hammer_launcher.icobin0 -> 3310 bytes
-rw-r--r--hammer_launcher/hammer_launcher.rc72
-rw-r--r--hammer_launcher/hammer_launcher.vpc43
-rw-r--r--hammer_launcher/main.cpp198
-rw-r--r--hammer_launcher/resource.h23
5 files changed, 336 insertions, 0 deletions
diff --git a/hammer_launcher/hammer_launcher.ico b/hammer_launcher/hammer_launcher.ico
new file mode 100644
index 0000000..81ff707
--- /dev/null
+++ b/hammer_launcher/hammer_launcher.ico
Binary files differ
diff --git a/hammer_launcher/hammer_launcher.rc b/hammer_launcher/hammer_launcher.rc
new file mode 100644
index 0000000..fb7df31
--- /dev/null
+++ b/hammer_launcher/hammer_launcher.rc
@@ -0,0 +1,72 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Icon
+//
+
+// Icon with lowest ID value placed first to ensure application icon
+// remains consistent on all systems.
+IDI_HAMMER_LAUNCHER ICON DISCARDABLE "hammer_launcher.ico"
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#include ""afxres.h""\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/hammer_launcher/hammer_launcher.vpc b/hammer_launcher/hammer_launcher.vpc
new file mode 100644
index 0000000..b116003
--- /dev/null
+++ b/hammer_launcher/hammer_launcher.vpc
@@ -0,0 +1,43 @@
+//-----------------------------------------------------------------------------
+// HAMMER_LAUNCHER.VPC
+//
+// Project Script
+//-----------------------------------------------------------------------------
+
+$Macro SRCDIR ".."
+$Macro OUTBINDIR "$SRCDIR\..\game\bin"
+$Macro OUTBINNAME "hammer"
+
+$Include "$SRCDIR\vpc_scripts\source_exe_base.vpc"
+
+$Configuration
+{
+ $Compiler
+ {
+ $AdditionalOptions "$BASE /EHa"
+ }
+
+ $Linker [$WIN32]
+ {
+ $EnableLargeAddresses "Support Addresses Larger Than 2 Gigabytes (/LARGEADDRESSAWARE)"
+ }
+}
+
+$Project "Hammer_launcher"
+{
+ $Folder "Source Files"
+ {
+ -$File "$SRCDIR\public\tier0\memoverride.cpp"
+ $File "main.cpp"
+ }
+
+ $Folder "Resources"
+ {
+ $File "hammer_launcher.rc"
+ }
+
+ $Folder "Link Libraries"
+ {
+ $Lib appframework
+ }
+}
diff --git a/hammer_launcher/main.cpp b/hammer_launcher/main.cpp
new file mode 100644
index 0000000..72d3634
--- /dev/null
+++ b/hammer_launcher/main.cpp
@@ -0,0 +1,198 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose: Launcher for hammer, which is sitting in its own DLL
+//
+//===========================================================================//
+
+#include <windows.h>
+#include <eh.h>
+#include "appframework/AppFramework.h"
+#include "ihammer.h"
+#include "tier0/dbg.h"
+#include "vstdlib/cvar.h"
+#include "filesystem.h"
+#include "materialsystem/imaterialsystem.h"
+#include "istudiorender.h"
+#include "filesystem_init.h"
+#include "datacache/idatacache.h"
+#include "datacache/imdlcache.h"
+#include "vphysics_interface.h"
+#include "vgui/ivgui.h"
+#include "vgui/ISurface.h"
+#include "inputsystem/iinputsystem.h"
+#include "tier0/icommandline.h"
+#include "p4lib/ip4.h"
+
+//-----------------------------------------------------------------------------
+// Global systems
+//-----------------------------------------------------------------------------
+IHammer *g_pHammer;
+IMaterialSystem *g_pMaterialSystem;
+IFileSystem *g_pFileSystem;
+IDataCache *g_pDataCache;
+IInputSystem *g_pInputSystem;
+
+//-----------------------------------------------------------------------------
+// The application object
+//-----------------------------------------------------------------------------
+class CHammerApp : public CAppSystemGroup
+{
+public:
+ // Methods of IApplication
+ virtual bool Create( );
+ virtual bool PreInit( );
+ virtual int Main( );
+ virtual void PostShutdown();
+ virtual void Destroy();
+
+private:
+ int MainLoop();
+};
+
+
+//-----------------------------------------------------------------------------
+// Define the application object
+//-----------------------------------------------------------------------------
+CHammerApp g_ApplicationObject;
+DEFINE_WINDOWED_APPLICATION_OBJECT_GLOBALVAR( g_ApplicationObject );
+
+
+//-----------------------------------------------------------------------------
+// Create all singleton systems
+//-----------------------------------------------------------------------------
+bool CHammerApp::Create( )
+{
+ // Save some memory so engine/hammer isn't so painful
+ CommandLine()->AppendParm( "-disallowhwmorph", NULL );
+
+ IAppSystem *pSystem;
+
+ // Add in the cvar factory
+ AppModule_t cvarModule = LoadModule( VStdLib_GetICVarFactory() );
+ pSystem = AddSystem( cvarModule, CVAR_INTERFACE_VERSION );
+ if ( !pSystem )
+ return false;
+
+ bool bSteam;
+ char pFileSystemDLL[MAX_PATH];
+ if ( FileSystem_GetFileSystemDLLName( pFileSystemDLL, MAX_PATH, bSteam ) != FS_OK )
+ return false;
+
+ AppModule_t fileSystemModule = LoadModule( pFileSystemDLL );
+ g_pFileSystem = (IFileSystem*)AddSystem( fileSystemModule, FILESYSTEM_INTERFACE_VERSION );
+
+ FileSystem_SetBasePaths( g_pFileSystem );
+
+ AppSystemInfo_t appSystems[] =
+ {
+ { "materialsystem.dll", MATERIAL_SYSTEM_INTERFACE_VERSION },
+ { "inputsystem.dll", INPUTSYSTEM_INTERFACE_VERSION },
+ { "studiorender.dll", STUDIO_RENDER_INTERFACE_VERSION },
+ { "vphysics.dll", VPHYSICS_INTERFACE_VERSION },
+ { "datacache.dll", DATACACHE_INTERFACE_VERSION },
+ { "datacache.dll", MDLCACHE_INTERFACE_VERSION },
+ { "datacache.dll", STUDIO_DATA_CACHE_INTERFACE_VERSION },
+ { "vguimatsurface.dll", VGUI_SURFACE_INTERFACE_VERSION },
+ { "vgui2.dll", VGUI_IVGUI_INTERFACE_VERSION },
+ { "hammer_dll.dll", INTERFACEVERSION_HAMMER },
+ { "", "" } // Required to terminate the list
+ };
+
+ if ( !AddSystems( appSystems ) )
+ return false;
+
+ // Add Perforce separately since it's possible it isn't there. (SDK)
+ if ( !CommandLine()->CheckParm( "-nop4" ) )
+ {
+ AppModule_t p4Module = LoadModule( "p4lib.dll" );
+ AddSystem( p4Module, P4_INTERFACE_VERSION );
+ }
+ // Connect to interfaces loaded in AddSystems that we need locally
+ g_pMaterialSystem = (IMaterialSystem*)FindSystem( MATERIAL_SYSTEM_INTERFACE_VERSION );
+ g_pHammer = (IHammer*)FindSystem( INTERFACEVERSION_HAMMER );
+ g_pDataCache = (IDataCache*)FindSystem( DATACACHE_INTERFACE_VERSION );
+ g_pInputSystem = (IInputSystem*)FindSystem( INPUTSYSTEM_INTERFACE_VERSION );
+
+ // This has to be done before connection.
+ g_pMaterialSystem->SetShaderAPI( "shaderapidx9.dll" );
+
+ return true;
+}
+
+void CHammerApp::Destroy()
+{
+ g_pFileSystem = NULL;
+ g_pMaterialSystem = NULL;
+ g_pDataCache = NULL;
+ g_pHammer = NULL;
+ g_pInputSystem = NULL;
+}
+
+
+//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+SpewRetval_t HammerSpewFunc( SpewType_t type, tchar const *pMsg )
+{
+ if ( type == SPEW_ASSERT )
+ {
+ return SPEW_DEBUGGER;
+ }
+ else if( type == SPEW_ERROR )
+ {
+ MessageBox( NULL, pMsg, "Hammer Error", MB_OK | MB_ICONSTOP );
+ return SPEW_ABORT;
+ }
+ else
+ {
+ return SPEW_CONTINUE;
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Init, shutdown
+//-----------------------------------------------------------------------------
+bool CHammerApp::PreInit( )
+{
+ SpewOutputFunc( HammerSpewFunc );
+ if ( !g_pHammer->InitSessionGameConfig( GetVProjectCmdLineValue() ) )
+ return false;
+
+ //
+ // Init the game and mod dirs in the file system.
+ // This needs to happen before calling Init on the material system.
+ //
+ CFSSearchPathsInit initInfo;
+ initInfo.m_pFileSystem = g_pFileSystem;
+ initInfo.m_pDirectoryName = g_pHammer->GetDefaultModFullPath();
+
+ if ( FileSystem_LoadSearchPaths( initInfo ) != FS_OK )
+ {
+ Error( "Unable to load search paths!\n" );
+ }
+
+ // Required to run through the editor
+ g_pMaterialSystem->EnableEditorMaterials();
+
+ // needed for VGUI model rendering
+ g_pMaterialSystem->SetAdapter( 0, MATERIAL_INIT_ALLOCATE_FULLSCREEN_TEXTURE );
+
+ return true;
+}
+
+void CHammerApp::PostShutdown()
+{
+}
+
+
+//-----------------------------------------------------------------------------
+// main application
+//-----------------------------------------------------------------------------
+int CHammerApp::Main( )
+{
+ return g_pHammer->MainLoop();
+}
+
+
+
+
+
diff --git a/hammer_launcher/resource.h b/hammer_launcher/resource.h
new file mode 100644
index 0000000..5c2b44c
--- /dev/null
+++ b/hammer_launcher/resource.h
@@ -0,0 +1,23 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//
+//=============================================================================//
+//{{NO_DEPENDENCIES}}
+// Microsoft Developer Studio generated include file.
+// Used by hammer_launcher.rc
+//
+#define IDI_HAMMER_LAUNCHER 101
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 102
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1000
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif