diff options
| author | Alan Edwardes <[email protected]> | 2013-12-03 10:47:30 +0000 |
|---|---|---|
| committer | Alan Edwardes <[email protected]> | 2013-12-03 10:47:30 +0000 |
| commit | 550992aebacbc7586553c15a3c2120f85a879126 (patch) | |
| tree | c814cf654018acd5d69bb6e4be5dc9900391fd37 /mp/src/utils/vrad_launcher | |
| parent | VBSP now checks all search paths for an FGD file. (diff) | |
| parent | Make .xcconfigs text files too. (diff) | |
| download | source-sdk-2013-550992aebacbc7586553c15a3c2120f85a879126.tar.xz source-sdk-2013-550992aebacbc7586553c15a3c2120f85a879126.zip | |
Merge remote-tracking branch 'upstream/master' into vbsp-fixes.
Diffstat (limited to 'mp/src/utils/vrad_launcher')
| -rw-r--r-- | mp/src/utils/vrad_launcher/stdafx.cpp | 30 | ||||
| -rw-r--r-- | mp/src/utils/vrad_launcher/stdafx.h | 64 | ||||
| -rw-r--r-- | mp/src/utils/vrad_launcher/vrad_launcher.cpp | 290 | ||||
| -rw-r--r-- | mp/src/utils/vrad_launcher/vrad_launcher.vpc | 98 |
4 files changed, 241 insertions, 241 deletions
diff --git a/mp/src/utils/vrad_launcher/stdafx.cpp b/mp/src/utils/vrad_launcher/stdafx.cpp index ecf65582..983b8ba5 100644 --- a/mp/src/utils/vrad_launcher/stdafx.cpp +++ b/mp/src/utils/vrad_launcher/stdafx.cpp @@ -1,15 +1,15 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//
-//=============================================================================//
-// stdafx.cpp : source file that includes just the standard includes
-// vrad_launcher.pch will be the pre-compiled header
-// stdafx.obj will contain the pre-compiled type information
-
-#include "stdafx.h"
-
-// TODO: reference any additional headers you need in STDAFX.H
-// and not in this file
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +// +//=============================================================================// +// stdafx.cpp : source file that includes just the standard includes +// vrad_launcher.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/mp/src/utils/vrad_launcher/stdafx.h b/mp/src/utils/vrad_launcher/stdafx.h index 1c89a814..36daff0a 100644 --- a/mp/src/utils/vrad_launcher/stdafx.h +++ b/mp/src/utils/vrad_launcher/stdafx.h @@ -1,32 +1,32 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//
-//=============================================================================//
-// stdafx.h : include file for standard system include files,
-// or project specific include files that are used frequently, but
-// are changed infrequently
-//
-
-#if !defined(AFX_STDAFX_H__4A047C84_94D7_4563_A08C_35E52A52AECC__INCLUDED_)
-#define AFX_STDAFX_H__4A047C84_94D7_4563_A08C_35E52A52AECC__INCLUDED_
-
-#if _MSC_VER > 1000
-#pragma once
-#endif // _MSC_VER > 1000
-
-#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
-
-#include <windows.h>
-#include <stdio.h>
-#include "interface.h"
-#include "ivraddll.h"
-
-// TODO: reference additional headers your program requires here
-
-//{{AFX_INSERT_LOCATION}}
-// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
-
-#endif // !defined(AFX_STDAFX_H__4A047C84_94D7_4563_A08C_35E52A52AECC__INCLUDED_)
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +// +//=============================================================================// +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#if !defined(AFX_STDAFX_H__4A047C84_94D7_4563_A08C_35E52A52AECC__INCLUDED_) +#define AFX_STDAFX_H__4A047C84_94D7_4563_A08C_35E52A52AECC__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + +#include <windows.h> +#include <stdio.h> +#include "interface.h" +#include "ivraddll.h" + +// TODO: reference additional headers your program requires here + +//{{AFX_INSERT_LOCATION}} +// Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#endif // !defined(AFX_STDAFX_H__4A047C84_94D7_4563_A08C_35E52A52AECC__INCLUDED_) diff --git a/mp/src/utils/vrad_launcher/vrad_launcher.cpp b/mp/src/utils/vrad_launcher/vrad_launcher.cpp index fc458172..a4d31834 100644 --- a/mp/src/utils/vrad_launcher/vrad_launcher.cpp +++ b/mp/src/utils/vrad_launcher/vrad_launcher.cpp @@ -1,145 +1,145 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//
-//=============================================================================//
-// vrad_launcher.cpp : Defines the entry point for the console application.
-//
-
-#include "stdafx.h"
-#include <direct.h>
-#include "tier1/strtools.h"
-#include "tier0/icommandline.h"
-
-
-char* GetLastErrorString()
-{
- static char err[2048];
-
- LPVOID lpMsgBuf;
- FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- GetLastError(),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
- (LPTSTR) &lpMsgBuf,
- 0,
- NULL
- );
-
- strncpy( err, (char*)lpMsgBuf, sizeof( err ) );
- LocalFree( lpMsgBuf );
-
- err[ sizeof( err ) - 1 ] = 0;
-
- return err;
-}
-
-
-void MakeFullPath( const char *pIn, char *pOut, int outLen )
-{
- if ( pIn[0] == '/' || pIn[0] == '\\' || pIn[1] == ':' )
- {
- // It's already a full path.
- Q_strncpy( pOut, pIn, outLen );
- }
- else
- {
- _getcwd( pOut, outLen );
- Q_strncat( pOut, "\\", outLen, COPY_ALL_CHARACTERS );
- Q_strncat( pOut, pIn, outLen, COPY_ALL_CHARACTERS );
- }
-}
-
-int main(int argc, char* argv[])
-{
- char dllName[512];
-
- CommandLine()->CreateCmdLine( argc, argv );
-
- // check whether they used the -both switch. If this is specified, vrad will be run
- // twice, once with -hdr and once without
- int both_arg=0;
- for(int arg=1;arg<argc;arg++)
- if (Q_stricmp(argv[arg],"-both")==0)
- {
- both_arg=arg;
- }
-
- char fullPath[512], redirectFilename[512];
- MakeFullPath( argv[0], fullPath, sizeof( fullPath ) );
- Q_StripFilename( fullPath );
- Q_snprintf( redirectFilename, sizeof( redirectFilename ), "%s\\%s", fullPath, "vrad.redirect" );
-
- // First, look for vrad.redirect and load the dll specified in there if possible.
- CSysModule *pModule = NULL;
- FILE *fp = fopen( redirectFilename, "rt" );
- if ( fp )
- {
- if ( fgets( dllName, sizeof( dllName ), fp ) )
- {
- char *pEnd = strstr( dllName, "\n" );
- if ( pEnd )
- *pEnd = 0;
-
- pModule = Sys_LoadModule( dllName );
- if ( pModule )
- printf( "Loaded alternate VRAD DLL (%s) specified in vrad.redirect.\n", dllName );
- else
- printf( "Can't find '%s' specified in vrad.redirect.\n", dllName );
- }
-
- fclose( fp );
- }
-
- int returnValue = 0;
-
- for(int mode=0;mode<2;mode++)
- {
- if (mode && (! both_arg))
- continue;
-
-
- // If it didn't load the module above, then use the
- if ( !pModule )
- {
- strcpy( dllName, "vrad_dll.dll" );
- pModule = Sys_LoadModule( dllName );
- }
-
- if( !pModule )
- {
- printf( "vrad_launcher error: can't load %s\n%s", dllName, GetLastErrorString() );
- return 1;
- }
-
- CreateInterfaceFn fn = Sys_GetFactory( pModule );
- if( !fn )
- {
- printf( "vrad_launcher error: can't get factory from vrad_dll.dll\n" );
- Sys_UnloadModule( pModule );
- return 2;
- }
-
- int retCode = 0;
- IVRadDLL *pDLL = (IVRadDLL*)fn( VRAD_INTERFACE_VERSION, &retCode );
- if( !pDLL )
- {
- printf( "vrad_launcher error: can't get IVRadDLL interface from vrad_dll.dll\n" );
- Sys_UnloadModule( pModule );
- return 3;
- }
-
- if (both_arg)
- strcpy(argv[both_arg],(mode)?"-hdr":"-ldr");
- returnValue = pDLL->main( argc, argv );
- Sys_UnloadModule( pModule );
- pModule=0;
- }
- return returnValue;
-}
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +// +//=============================================================================// +// vrad_launcher.cpp : Defines the entry point for the console application. +// + +#include "stdafx.h" +#include <direct.h> +#include "tier1/strtools.h" +#include "tier0/icommandline.h" + + +char* GetLastErrorString() +{ + static char err[2048]; + + LPVOID lpMsgBuf; + FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM | + FORMAT_MESSAGE_IGNORE_INSERTS, + NULL, + GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language + (LPTSTR) &lpMsgBuf, + 0, + NULL + ); + + strncpy( err, (char*)lpMsgBuf, sizeof( err ) ); + LocalFree( lpMsgBuf ); + + err[ sizeof( err ) - 1 ] = 0; + + return err; +} + + +void MakeFullPath( const char *pIn, char *pOut, int outLen ) +{ + if ( pIn[0] == '/' || pIn[0] == '\\' || pIn[1] == ':' ) + { + // It's already a full path. + Q_strncpy( pOut, pIn, outLen ); + } + else + { + _getcwd( pOut, outLen ); + Q_strncat( pOut, "\\", outLen, COPY_ALL_CHARACTERS ); + Q_strncat( pOut, pIn, outLen, COPY_ALL_CHARACTERS ); + } +} + +int main(int argc, char* argv[]) +{ + char dllName[512]; + + CommandLine()->CreateCmdLine( argc, argv ); + + // check whether they used the -both switch. If this is specified, vrad will be run + // twice, once with -hdr and once without + int both_arg=0; + for(int arg=1;arg<argc;arg++) + if (Q_stricmp(argv[arg],"-both")==0) + { + both_arg=arg; + } + + char fullPath[512], redirectFilename[512]; + MakeFullPath( argv[0], fullPath, sizeof( fullPath ) ); + Q_StripFilename( fullPath ); + Q_snprintf( redirectFilename, sizeof( redirectFilename ), "%s\\%s", fullPath, "vrad.redirect" ); + + // First, look for vrad.redirect and load the dll specified in there if possible. + CSysModule *pModule = NULL; + FILE *fp = fopen( redirectFilename, "rt" ); + if ( fp ) + { + if ( fgets( dllName, sizeof( dllName ), fp ) ) + { + char *pEnd = strstr( dllName, "\n" ); + if ( pEnd ) + *pEnd = 0; + + pModule = Sys_LoadModule( dllName ); + if ( pModule ) + printf( "Loaded alternate VRAD DLL (%s) specified in vrad.redirect.\n", dllName ); + else + printf( "Can't find '%s' specified in vrad.redirect.\n", dllName ); + } + + fclose( fp ); + } + + int returnValue = 0; + + for(int mode=0;mode<2;mode++) + { + if (mode && (! both_arg)) + continue; + + + // If it didn't load the module above, then use the + if ( !pModule ) + { + strcpy( dllName, "vrad_dll.dll" ); + pModule = Sys_LoadModule( dllName ); + } + + if( !pModule ) + { + printf( "vrad_launcher error: can't load %s\n%s", dllName, GetLastErrorString() ); + return 1; + } + + CreateInterfaceFn fn = Sys_GetFactory( pModule ); + if( !fn ) + { + printf( "vrad_launcher error: can't get factory from vrad_dll.dll\n" ); + Sys_UnloadModule( pModule ); + return 2; + } + + int retCode = 0; + IVRadDLL *pDLL = (IVRadDLL*)fn( VRAD_INTERFACE_VERSION, &retCode ); + if( !pDLL ) + { + printf( "vrad_launcher error: can't get IVRadDLL interface from vrad_dll.dll\n" ); + Sys_UnloadModule( pModule ); + return 3; + } + + if (both_arg) + strcpy(argv[both_arg],(mode)?"-hdr":"-ldr"); + returnValue = pDLL->main( argc, argv ); + Sys_UnloadModule( pModule ); + pModule=0; + } + return returnValue; +} + diff --git a/mp/src/utils/vrad_launcher/vrad_launcher.vpc b/mp/src/utils/vrad_launcher/vrad_launcher.vpc index 08914048..293e5514 100644 --- a/mp/src/utils/vrad_launcher/vrad_launcher.vpc +++ b/mp/src/utils/vrad_launcher/vrad_launcher.vpc @@ -1,49 +1,49 @@ -//-----------------------------------------------------------------------------
-// VRAD_LAUNCHER.VPC
-//
-// Project Script
-//-----------------------------------------------------------------------------
-
-$Macro SRCDIR "..\.."
-$Macro OUTBINDIR "$SRCDIR\..\game\bin"
-$Macro OUTBINNAME "vrad"
-
-$Include "$SRCDIR\vpc_scripts\source_exe_con_win32_base.vpc"
-
-$Configuration
-{
- $Compiler
- {
- $Create/UsePrecompiledHeader "Use Precompiled Header (/Yu)"
- $PrecompiledHeaderFile "Debug/vrad_launcher.pch"
- }
-}
-
-$Project "Vrad_launcher"
-{
- $Folder "Source Files"
- {
- -$File "$SRCDIR\public\tier0\memoverride.cpp"
-
- $File "vrad_launcher.cpp"
-
- $File "StdAfx.cpp"
- {
- $Configuration
- {
- $Compiler
- {
- $Create/UsePrecompiledHeader "Create Precompiled Header (/Yc)"
- }
- }
- }
-
- }
-
- $Folder "Header Files"
- {
- $File "$SRCDIR\public\tier1\interface.h"
- $File "$SRCDIR\public\ivraddll.h"
- $File "StdAfx.h"
- }
-}
+//----------------------------------------------------------------------------- +// VRAD_LAUNCHER.VPC +// +// Project Script +//----------------------------------------------------------------------------- + +$Macro SRCDIR "..\.." +$Macro OUTBINDIR "$SRCDIR\..\game\bin" +$Macro OUTBINNAME "vrad" + +$Include "$SRCDIR\vpc_scripts\source_exe_con_base.vpc" + +$Configuration +{ + $Compiler + { + $Create/UsePrecompiledHeader "Use Precompiled Header (/Yu)" + $PrecompiledHeaderFile "Debug/vrad_launcher.pch" + } +} + +$Project "Vrad_launcher" +{ + $Folder "Source Files" + { + -$File "$SRCDIR\public\tier0\memoverride.cpp" + + $File "vrad_launcher.cpp" + + $File "StdAfx.cpp" + { + $Configuration + { + $Compiler + { + $Create/UsePrecompiledHeader "Create Precompiled Header (/Yc)" + } + } + } + + } + + $Folder "Header Files" + { + $File "$SRCDIR\public\tier1\interface.h" + $File "$SRCDIR\public\ivraddll.h" + $File "StdAfx.h" + } +} |