diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /devtools/tagbuild | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'devtools/tagbuild')
| -rw-r--r-- | devtools/tagbuild/StdAfx.cpp | 15 | ||||
| -rw-r--r-- | devtools/tagbuild/StdAfx.h | 26 | ||||
| -rw-r--r-- | devtools/tagbuild/tagbuild.cpp | 180 | ||||
| -rw-r--r-- | devtools/tagbuild/tagbuild.vpc | 49 |
4 files changed, 270 insertions, 0 deletions
diff --git a/devtools/tagbuild/StdAfx.cpp b/devtools/tagbuild/StdAfx.cpp new file mode 100644 index 0000000..d9360a8 --- /dev/null +++ b/devtools/tagbuild/StdAfx.cpp @@ -0,0 +1,15 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +// +//=============================================================================// +// stdafx.cpp : source file that includes just the standard includes +// tagbuild.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/devtools/tagbuild/StdAfx.h b/devtools/tagbuild/StdAfx.h new file mode 100644 index 0000000..8b6ae51 --- /dev/null +++ b/devtools/tagbuild/StdAfx.h @@ -0,0 +1,26 @@ +//========= 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__BC019BF6_D3B1_4EA1_AA0E_044EEC919C6D__INCLUDED_) +#define AFX_STDAFX_H__BC019BF6_D3B1_4EA1_AA0E_044EEC919C6D__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + + +// 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__BC019BF6_D3B1_4EA1_AA0E_044EEC919C6D__INCLUDED_) diff --git a/devtools/tagbuild/tagbuild.cpp b/devtools/tagbuild/tagbuild.cpp new file mode 100644 index 0000000..600a6cb --- /dev/null +++ b/devtools/tagbuild/tagbuild.cpp @@ -0,0 +1,180 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +// +//=============================================================================// +// tagbuild.cpp : Defines the entry point for the console application. +// + +#include "stdafx.h" +#include <stdio.h> +#include <process.h> +#include <string.h> +#include "interface.h" +#include "imysqlwrapper.h" + +const char *search = "VLV_INTERNAL "; + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void printusage( void ) +{ + printf( "usage: tagbuild engine.dll buildid <hostname database username password>\n" ); + + // Exit app + exit( 1 ); +} + +int main(int argc, char* argv[]) +{ + if ( argc != 3 && argc != 7 ) + { + printusage(); + } + + int idlen = strlen( argv[ 2 ] ); + + if ( idlen > 32 ) + { + printf( "id string '%s' is %i long, 32 is max\n", argv[ 2 ], idlen ); + printusage(); + } + + // Open for reading and writing + FILE *fp = fopen( argv[ 1 ], "r+" ); + if ( !fp ) + { + printf( "unable to open %s\n", argv[ 1 ] ); + exit( 1 ); + } + + fseek( fp, 0, SEEK_END ); + int size = ftell( fp ); + fseek( fp, 0, SEEK_SET ); + + int searchlen = strlen( search ); + + char alreadytagged[ 32 ]; + Q_memset( alreadytagged, ' ', sizeof( alreadytagged ) ); + alreadytagged[ 31 ] = 0; + // Copies in the id, but doesn't copy the terminating '\0' + Q_memcpy( alreadytagged, argv[ 2 ], Q_strlen( argv[ 2 ] ) ); + + bool found = false; + char *buf = new char[ size ]; + if ( buf ) + { + fread( buf, size, 1, fp ); + + // Now search + char *start = buf; + while ( start - buf < ( size - searchlen ) ) + { + if ( !memcmp( start, search, searchlen - 1 ) ) + { + int pos = start - buf; + + printf( "Found placeholder at %i, writing '%s' into file\n", + pos, argv[ 2 ] ); + + fseek( fp, pos, SEEK_SET ); + fwrite( argv[ 2 ], idlen, 1, fp ); + while ( idlen < searchlen ) + { + fputc( ' ', fp ); + ++idlen; + } + + found = true; + break; + } + else if ( !memcmp( start, alreadytagged, searchlen - 1 ) ) + { + int pos = start - buf; + + printf( "Found tag at %i (%s)\n", pos, argv[ 2 ] ); + found = true; + break; + } + + ++start; + } + + if ( !found ) + { + printf( "Couldn't find search string '%s' in binary data\n", search ); + } + + } + else + { + printf( "unable to allocate %i bytes for %s\n", size, argv[ 1 ] ); + } + + + fclose( fp ); + + if ( argc <= 3 ) + { + printf( "Skipping database insertion\n" ); + } + else + { + // Now connect to steamweb and update the engineaccess table + CSysModule *sql = Sys_LoadModule( "mysql_wrapper" ); + if ( sql ) + { + CreateInterfaceFn factory = Sys_GetFactory( sql ); + if ( factory ) + { + IMySQL *mysql = ( IMySQL * )factory( MYSQL_WRAPPER_VERSION_NAME, NULL ); + if ( mysql ) + { + if ( mysql->InitMySQL( argv[ 4 ], argv[ 3 ], argv[ 5 ], argv[ 6 ] ) ) + { + char q[ 512 ]; + + Q_snprintf( q, sizeof( q ), "insert into engineaccess (BuildIdentifier,AllowAccess) values (\"%s\",1);", + argv[2] ); + + int retcode = mysql->Execute( q ); + if ( retcode != 0 ) + { + printf( "Query %s failed\n", q ); + } + else + { + printf( "Successfully added buildidentifier '%s' to %s:%s\n", + argv[ 2 ], argv[ 3 ], argv[ 4 ] ); + } + } + else + { + printf( "InitMySQL failed\n" ); + } + + mysql->Release(); + } + else + { + printf( "Unable to connect via mysql_wrapper\n"); + } + } + else + { + printf( "Unable to get factory from mysql_wrapper.dll, not updating access mysql table!!!" ); + } + + Sys_UnloadModule( sql ); + } + else + { + printf( "Unable to load mysql_wrapper.dll, not updating access mysql table!!!" ); + } + } + + return 0; +} diff --git a/devtools/tagbuild/tagbuild.vpc b/devtools/tagbuild/tagbuild.vpc new file mode 100644 index 0000000..9d374ca --- /dev/null +++ b/devtools/tagbuild/tagbuild.vpc @@ -0,0 +1,49 @@ +//----------------------------------------------------------------------------- +// TAGBUILD.VPC +// +// Project Script +//----------------------------------------------------------------------------- + +$Macro SRCDIR "..\.." +$Macro OUTBINDIR "$SRCDIR\..\game\bin" + +$Include "$SRCDIR\vpc_scripts\source_exe_con_base.vpc" + +$Configuration +{ + $Compiler + { + $AdditionalIncludeDirectories "$BASE,$SRCDIR\utils\vmpi" + } +} + +$Project "Tagbuild" +{ + $Folder "Source Files" + { + -$File "$SRCDIR\public\tier0\memoverride.cpp" + + $File "StdAfx.cpp" + $File "StdAfx.h" + $File "tagbuild.cpp" + } + + $Folder "Header Files" + { + $File "$SRCDIR\public\tier0\basetypes.h" + $File "$SRCDIR\public\tier0\commonmacros.h" + $File "$SRCDIR\public\tier0\dbg.h" + $File "$SRCDIR\public\tier0\fasttimer.h" + $File "$SRCDIR\public\tier0\icommandline.h" + $File "$SRCDIR\utils\vmpi\imysqlwrapper.h" + $File "$SRCDIR\public\tier0\memdbgoff.h" + $File "$SRCDIR\public\tier0\memdbgon.h" + $File "$SRCDIR\public\tier0\platform.h" + $File "$SRCDIR\public\tier0\protected_things.h" + $File "$SRCDIR\public\string_t.h" + $File "$SRCDIR\public\tier1\strtools.h" + $File "$SRCDIR\public\tier1\utlmemory.h" + $File "$SRCDIR\public\tier1\utlvector.h" + $File "$SRCDIR\public\vstdlib\vstdlib.h" + } +} |