1
0
mirror of https://github.com/alliedmodders/hl2sdk.git synced 2025-09-19 20:16:10 +08:00

Start of Source2 work.

This commit is contained in:
Nicholas Hastings
2015-07-09 13:07:26 -04:00
parent 56e10b870f
commit cd9b331641
30 changed files with 5017 additions and 1111 deletions

View File

@ -13,18 +13,19 @@ ICvar *cvar, *g_pCVar;
IEventSystem *g_pEventSystem;
IProcessUtils *g_pProcessUtils;
IPhysics2 *g_pPhysics2;
IPhysics2ActorManager *g_pPhysics2ActorManager;
IPhysics2ResourceManager *g_pPhysics2ResourceManager;
IBaseFileSystem *g_pBaseFileSystem;
IFileSystem *g_pFullFileSystem;
IAsyncFileSystem *g_pAsyncFileSystem;
IResourceSystem *g_pResourceSystem;
IMaterialSystem *materials, *g_pMaterialSystem;
IMaterialSystem2 *g_pMaterialSystem2;
IResourceSystemTools *g_pResourceSystemTools;
IMaterialSystem *g_pMaterialSystem;
IInputSystem *g_pInputSystem;
IInputStackSystem *g_pInputStackSystem;
INetworkSystem *g_pNetworkSystem;
INetworkSystemUtils *g_pNetworkSystemUtils;
IRenderDeviceMgr *g_pRenderDeviceMgr;
IMaterialSystemHardwareConfig *g_pMaterialSystemHardwareConfig;
IRenderUtils *g_pRenderUtils;
ISoundSystem *g_pSoundSystem;
IDebugTextureInfo *g_pMaterialSystemDebugTextureInfo;
IVBAllocTracker *g_VBAllocTracker;
@ -32,9 +33,6 @@ IColorCorrectionSystem *colorcorrection;
IP4 *p4;
IMdlLib *mdllib;
IQueuedLoader *g_pQueuedLoader;
IResourceAccessControl *g_pResourceAccessControl;
IPrecacheSystem *g_pPrecacheSystem;
IStudioRender *g_pStudioRender, *studiorender;
vgui::IVGui *g_pVGui;
vgui::IInput *g_pVGuiInput;
vgui::IPanel *g_pVGuiPanel;
@ -43,22 +41,101 @@ vgui::ISchemeManager *g_pVGuiSchemeManager;
vgui::ISystem *g_pVGuiSystem;
ILocalize *g_pLocalize;
vgui::ILocalize *g_pVGuiLocalize;
IMatSystemSurface *g_pMatSystemSurface;
IDataCache *g_pDataCache;
IMDLCache *g_pMDLCache, *mdlcache;
IAvi *g_pAVI;
IBik *g_pBIK;
IQuickTime *g_pQuickTime;
IDmeMakefileUtils *g_pDmeMakefileUtils;
IPhysicsCollision *g_pPhysicsCollision;
ISoundEmitterSystemBase *g_pSoundEmitterSystem;
ISoundEmitterSystemBaseS1 *g_pSoundEmitterSystemS1;
IMeshSystem *g_pMeshSystem;
IMeshUtils *g_pMeshUtils;
IRenderDevice *g_pRenderDevice;
IRenderDeviceSetup *g_pRenderDeviceSetup;
IRenderHardwareConfig *g_pRenderHardwareConfig;
ISceneSystem *g_pSceneSystem;
ISceneUtils *g_pSceneUtils;
IWorldRendererMgr *g_pWorldRendererMgr;
IVGuiRenderSurface *g_pVGuiRenderSurface;
IMatchFramework *g_pMatchFramework;
IGameUISystemMgr *g_pGameUISystemMgr;
IResourceManifestRegistry *g_pResourceManifestRegistry;
IResourceHandleUtils *g_pResourceHandleUtils;
ISchemaSystem *g_pSchemaSystem;
IResourceCompilerSystem *g_pResourceCompilerSystem;
IPostProcessingSystem *g_pPostProcessingSystem;
ISoundMixGroupSystem *g_pSoundMixGroupSystem;
ISoundOpSystemEdit *g_pSoundOpSystemEdit;
ISoundOpSystem *g_pSoundOpSystem;
IAssetSystem *g_pAssetSystem;
IAssetSystemTest *g_pAssetSystemTest;
IParticleSystemMgr *g_pParticleSystemMgr;
IVScriptManager *g_pVScriptService;
IToolScriptManager *g_pToolScriptManager;
IPropertyEditorSystem *g_pPropertyEditorSystem;
IModelProcessingSystem *g_pModelProcessingSystem;
IPanoramaUI *g_pPanoramaUI;
IToolFramework2 *g_pToolFramework2;
IMapBuilderMgr *g_pWorldRendererBuilderMgr;
IMapBuilderMgr *g_pLightingBuilderMgr;
IMapBuilderMgr *g_pPhysicsBuilderMgr;
IMapBuilderMgr *g_pVisBuilderMgr;
IMapBuilderMgr *g_pEnvironmentBuilderMgr;
IMapBuilderMgr *g_pBakedLODBuilderMgr;
IHelpSystem *g_pHelpSystem;
IToolSceneNodeFactory *g_pToolSceneNodeFactory;
IToolGameSimulationSystem *g_pToolGameSimulationSystem;
IToolGameSimulationDispatcher *g_pToolGameSimulationDispatcher;
ISchemaTestExternal_Two *g_pSchemaTestExternal_Two;
ISchemaTestExternal_One *g_pSchemaTestExternal_One;
IAnimationSystem *g_pAnimationSystem;
IAnimationSystemUtils *g_pAnimationSystemUtils;
IHammerMapLoader *g_pHammerMapLoader;
IMaterialUtils *g_pMaterialUtils;
IFontManager *g_pFontManager;
ITextLayout *g_pTextLayout;
IAssetPreviewSystem *g_pAssetPreviewSystem;
IAssetBrowserSystem *g_pAssetBrowserSystem;
IVConComm *g_pVConComm;
IConfigurationSystem *g_pConfigurationSystem;
INetworkMessages *g_pNetworkMessages;
IFlattenedSerializers *g_pFlattenedSerializers;
ISource2Client *g_pSource2Client;
ISource2ClientPrediction *g_pSource2ClientPrediction;
ISource2Server *g_pSource2Server;
ISource2ServerSerializers *g_pSource2ServerSerializers;
ISource2Host *g_pSource2Host;
ISource2GameClients *g_pSource2GameClients;
ISource2GameEntities *g_pSource2GameEntities;
IEngineServiceMgr *g_pEngineServiceMgr;
IHostStateMgr *g_pHostStateMgr;
INetworkService *g_pNetworkService;
INetworkClientService *g_pNetworkClientService;
INetworkServerService *g_pNetworkServerService;
ITextMessageMgr *g_pTextMessageMgr;
IToolService *g_pToolService;
IRenderService *g_pRenderService;
IStatsService *g_pStatsService;
IUserInfoChangeService *g_pUserInfoChangeService;
IVProfService *g_pVProfService;
IInputService *g_pInputService;
IMapListService *g_pMapListService;
IGameUIService *g_pGameUIService;
ISoundService *g_pSoundService;
IBenchmarkService *g_pBenchmarkService;
IDebugService *g_pDebugService;
IKeyValueCache *g_pKeyValueCache;
IGameResourceServiceClient *g_pGameResourceServiceClient;
IGameResourceServiceServer *g_pGameResourceServiceServer;
ISource2EngineToClient *g_pSource2EngineToClient;
ISource2EngineToServer *g_pSource2EngineToServer;
ISource2EngineToServerStringTable *g_pSource2EngineToServerStringTable;
ISource2EngineToClientStringTable *g_pSource2EngineToClientStringTable;
ISource2EngineSoundServer *g_pSource2EngineSoundServer;
ISource2EngineSoundClient *g_pSource2EngineSoundClient;
IServerUploadGameStats *g_pServerUploadGameStats;
IScaleformUI *g_pScaleformUI;
IVR *vr;
struct InterfaceGlobals_t
{
@ -79,30 +156,32 @@ static const InterfaceGlobals_t g_pInterfaceGlobals[] =
{ EVENTSYSTEM_INTERFACE_VERSION, &g_pEventSystem },
{ PROCESS_UTILS_INTERFACE_VERSION, &g_pProcessUtils },
{ VPHYSICS2_INTERFACE_VERSION, &g_pPhysics2 },
{ VPHYSICS2_ACTOR_MGR_INTERFACE_VERSION, &g_pPhysics2ActorManager },
{ VPHYSICS2_RESOURCE_MGR_INTERFACE_VERSION, &g_pPhysics2ResourceManager },
{ BASEFILESYSTEM_INTERFACE_VERSION, &g_pBaseFileSystem },
{ FILESYSTEM_INTERFACE_VERSION, &g_pFullFileSystem },
{ ASYNCFILESYSTEM_INTERFACE_VERSION, &g_pAsyncFileSystem },
{ RESOURCESYSTEM_INTERFACE_VERSION, &g_pResourceSystem },
{ MATERIAL_SYSTEM_INTERFACE_VERSION, &materials },
{ MATERIAL_SYSTEM_INTERFACE_VERSION, &g_pMaterialSystem },
{ MATERIAL_SYSTEM2_INTERFACE_VERSION, &g_pMaterialSystem2 },
{ RESOURCESYSTEMTOOLS_INTERFACE_VERSION, &g_pResourceSystemTools },
{ RESOURCEMANIFESTREGISTRY_INTERFACE_VERSION, &g_pResourceManifestRegistry },
{ RESOURCEHANDLEUTILS_INTERFACE_VERSION, &g_pResourceHandleUtils },
{ SCHEMASYSTEM_INTERFACE_VERSION, &g_pSchemaSystem },
{ RESOURCECOMPILERSYSTEM_INTERFACE_VERSION, &g_pResourceCompilerSystem },
{ MATERIAL_SYSTEM2_INTERFACE_VERSION, &g_pMaterialSystem },
{ POSTPROCESSINGSYSTEM_INTERFACE_VERSION, &g_pPostProcessingSystem },
{ INPUTSYSTEM_INTERFACE_VERSION, &g_pInputSystem },
{ INPUTSTACKSYSTEM_INTERFACE_VERSION, &g_pInputStackSystem },
{ NETWORKSYSTEM_INTERFACE_VERSION, &g_pNetworkSystem },
{ RENDER_DEVICE_MGR_INTERFACE_VERSION, &g_pRenderDeviceMgr },
{ MATERIALSYSTEM_HARDWARECONFIG_INTERFACE_VERSION, &g_pMaterialSystemHardwareConfig },
{ RENDER_UTILS_INTERFACE_VERSION, &g_pRenderUtils },
{ SOUNDSYSTEM_INTERFACE_VERSION, &g_pSoundSystem },
{ SOUNDMIXGROUPSYSTEM_INTERFACE_VERSION, &g_pSoundMixGroupSystem },
{ SOUNDOPSYSTEMEDIT_INTERFACE_VERSION, &g_pSoundOpSystemEdit },
{ SOUNDOPSYSTEM_INTERFACE_VERSION, &g_pSoundOpSystem },
{ DEBUG_TEXTURE_INFO_VERSION, &g_pMaterialSystemDebugTextureInfo },
{ VB_ALLOC_TRACKER_INTERFACE_VERSION, &g_VBAllocTracker },
{ COLORCORRECTION_INTERFACE_VERSION, &colorcorrection },
{ P4_INTERFACE_VERSION, &p4 },
{ MDLLIB_INTERFACE_VERSION, &mdllib },
{ QUEUEDLOADER_INTERFACE_VERSION, &g_pQueuedLoader },
{ RESOURCE_ACCESS_CONTROL_INTERFACE_VERSION, &g_pResourceAccessControl },
{ PRECACHE_SYSTEM_INTERFACE_VERSION, &g_pPrecacheSystem },
{ STUDIO_RENDER_INTERFACE_VERSION, &g_pStudioRender },
{ STUDIO_RENDER_INTERFACE_VERSION, &studiorender },
{ VGUI_IVGUI_INTERFACE_VERSION, &g_pVGui },
{ VGUI_INPUT_INTERFACE_VERSION, &g_pVGuiInput },
{ VGUI_PANEL_INTERFACE_VERSION, &g_pVGuiPanel },
@ -111,23 +190,98 @@ static const InterfaceGlobals_t g_pInterfaceGlobals[] =
{ VGUI_SYSTEM_INTERFACE_VERSION, &g_pVGuiSystem },
{ LOCALIZE_INTERFACE_VERSION, &g_pLocalize },
{ LOCALIZE_INTERFACE_VERSION, &g_pVGuiLocalize },
{ MAT_SYSTEM_SURFACE_INTERFACE_VERSION, &g_pMatSystemSurface },
{ DATACACHE_INTERFACE_VERSION, &g_pDataCache },
{ MDLCACHE_INTERFACE_VERSION, &g_pMDLCache },
{ MDLCACHE_INTERFACE_VERSION, &mdlcache },
{ AVI_INTERFACE_VERSION, &g_pAVI },
{ BIK_INTERFACE_VERSION, &g_pBIK },
{ QUICKTIME_INTERFACE_VERSION, &g_pQuickTime },
{ DMEMAKEFILE_UTILS_INTERFACE_VERSION, &g_pDmeMakefileUtils },
{ VPHYSICS_COLLISION_INTERFACE_VERSION, &g_pPhysicsCollision },
{ SOUNDEMITTERSYSTEM_INTERFACE_VERSION, &g_pSoundEmitterSystem },
{ SOUNDEMITTERSYSTEMS1_INTERFACE_VERSION, &g_pSoundEmitterSystemS1 },
{ MESHSYSTEM_INTERFACE_VERSION, &g_pMeshSystem },
{ MESHUTILS_INTERFACE_VERSION, &g_pMeshUtils },
{ RENDER_DEVICE_INTERFACE_VERSION, &g_pRenderDevice },
{ RENDER_DEVICE_SETUP_INTERFACE_VERSION, &g_pRenderDeviceSetup },
{ RENDER_HARDWARECONFIG_INTERFACE_VERSION, &g_pRenderHardwareConfig },
{ SCENESYSTEM_INTERFACE_VERSION, &g_pSceneSystem },
{ SCENEUTILS_INTERFACE_VERSION, &g_pSceneUtils },
{ WORLD_RENDERER_MGR_INTERFACE_VERSION, &g_pWorldRendererMgr },
{ RENDER_SYSTEM_SURFACE_INTERFACE_VERSION, &g_pVGuiRenderSurface },
{ ASSETSYSTEM_INTERFACE_VERSION, &g_pAssetSystem },
{ ASSETSYSTEMTEST_INTERFACE_VERSION, &g_pAssetSystemTest },
{ PARTICLESYSTEMMGR_INTERFACE_VERSION, &g_pParticleSystemMgr },
{ VSCRIPT_INTERFACE_VERSION, &g_pVScriptService },
{ TOOLSCRIPTMANAGER_INTERFACE_VERSION, &g_pToolScriptManager },
{ PROPERTYEDITORSYSTEM_INTERFACE_VERSION, &g_pPropertyEditorSystem },
{ MODELPROCESSINGSYSTEM_INTERFACE_VERSION, &g_pModelProcessingSystem },
{ MATCHFRAMEWORK_INTERFACE_VERSION, &g_pMatchFramework },
{ GAMEUISYSTEMMGR_INTERFACE_VERSION, &g_pGameUISystemMgr }
{ PANORAMAUI_INTERFACE_VERSION, &g_pPanoramaUI },
{ TOOLFRAMEWORK2_INTERFACE_VERSION, &g_pToolFramework2 },
{ WORLDRENDERERBUILDER_INTERFACE_VERSION, &g_pWorldRendererBuilderMgr },
{ LIGHTINGBUILDER_INTERFACE_VERSION, &g_pLightingBuilderMgr },
{ PHYSICSBUILDER_INTERFACE_VERSION, &g_pPhysicsBuilderMgr },
{ VISBUILDER_INTERFACE_VERSION, &g_pVisBuilderMgr },
{ ENVIRONMENTBUILDER_INTERFACE_VERSION, &g_pEnvironmentBuilderMgr },
{ BAKEDLODBUILDER_INTERFACE_VERSION, &g_pBakedLODBuilderMgr },
{ HELPSYSTEM_INTERFACE_VERSION, &g_pHelpSystem },
{ TOOLSCENENODEFACTORY_INTERFACE_VERSION, &g_pToolSceneNodeFactory },
{ TOOLGAMESIMULATIONSYSTEM_INTERFACE_VERSION, &g_pToolGameSimulationSystem },
{ TOOLGAMESIMULATIONDISPATCHER_INTERFACE_VERSION, &g_pToolGameSimulationDispatcher },
{ SCHEMATESTEXTERNALTWO_INTERFACE_VERSION, &g_pSchemaTestExternal_Two },
{ SCHEMATESTEXTERNALONE_INTERFACE_VERSION, &g_pSchemaTestExternal_One },
{ ANIMATIONSYSTEM_INTERFACE_VERSION, &g_pAnimationSystem },
{ ANIMATIONSYSTEMUTILS_INTERFACE_VERSION, &g_pAnimationSystemUtils },
{ HAMMERMAPLOADER_INTERFACE_VERSION, &g_pHammerMapLoader },
{ MATERIALUTILS_INTERFACE_VERSION, &g_pMaterialUtils },
{ FONTMANAGER_INTERFACE_VERSION, &g_pFontManager },
{ TEXTLAYOUT_INTERFACE_VERSION, &g_pTextLayout },
{ ASSETPREVIEWSYSTEM_INTERFACE_VERSION, &g_pAssetPreviewSystem },
{ ASSETBROWSERSYSTEM_INTERFACE_VERSION, &g_pAssetBrowserSystem },
{ VCONCOMM_INTERFACE_VERSION, &g_pVConComm },
{ CONFIGURATIONSYSTEM_INTERFACE_VERSION, &g_pConfigurationSystem },
{ NETWORKSYSTEM_INTERFACE_VERSION, &g_pNetworkSystem },
{ NETWORKSYSTEMUTILS_INTERFACE_VERSION, &g_pNetworkSystemUtils },
{ NETWORKMESSAGES_INTERFACE_VERSION, &g_pNetworkMessages },
{ FLATTENEDSERIALIZERS_INTERFACE_VERSION, &g_pFlattenedSerializers },
{ SOURCE2CLIENT_INTERFACE_VERSION, &g_pSource2Client },
{ SOURCE2CLIENTPREDICTION_INTERFACE_VERSION, &g_pSource2ClientPrediction },
{ SOURCE2SERVER_INTERFACE_VERSION, &g_pSource2Server },
{ SOURCE2SERVERSERIALIZERS_INTERFACE_VERSION, &g_pSource2ServerSerializers },
{ SOURCE2HOST_INTERFACE_VERSION, &g_pSource2Host },
{ SOURCE2GAMECLIENTS_INTERFACE_VERSION, &g_pSource2GameClients },
{ SOURCE2GAMEENTITIES_INTERFACE_VERSION, &g_pSource2GameEntities },
{ ENGINESERVICEMGR_INTERFACE_VERSION, &g_pEngineServiceMgr },
{ HOSTSTATEMGR_INTERFACE_VERSION, &g_pHostStateMgr },
{ NETWORKSERVICE_INTERFACE_VERSION, &g_pNetworkService },
{ NETWORKCLIENTSERVICE_INTERFACE_VERSION, &g_pNetworkClientService },
{ NETWORKSERVERSERVICE_INTERFACE_VERSION, &g_pNetworkServerService },
{ TEXTMESSAGEMGR_INTERFACE_VERSION, &g_pTextMessageMgr },
{ TOOLSERVICE_INTERFACE_VERSION, &g_pToolService },
{ RENDERSERVICE_INTERFACE_VERSION, &g_pRenderService },
{ STATSSERVICE_INTERFACE_VERSION, &g_pStatsService },
{ USERINFOCHANGESERVICE_INTERFACE_VERSION, &g_pUserInfoChangeService },
{ VPROFSERVICE_INTERFACE_VERSION, &g_pVProfService },
{ INPUTSERVICE_INTERFACE_VERSION, &g_pInputService },
{ MAPLISTSERVICE_INTERFACE_VERSION, &g_pMapListService },
{ GAMEUISERVICE_INTERFACE_VERSION, &g_pGameUIService },
{ SOUNDSERVICE_INTERFACE_VERSION, &g_pSoundService },
{ BENCHMARKSERVICE_INTERFACE_VERSION, &g_pBenchmarkService },
{ DEBUGSERVICE_INTERFACE_VERSION, &g_pDebugService },
{ KEYVALUECACHE_INTERFACE_VERSION, &g_pKeyValueCache },
{ GAMERESOURCESERVICECLIENT_INTERFACE_VERSION, &g_pGameResourceServiceClient },
{ GAMERESOURCESERVICESERVER_INTERFACE_VERSION, &g_pGameResourceServiceServer },
{ SOURCE2ENGINETOCLIENT_INTERFACE_VERSION, &g_pSource2EngineToClient },
{ SOURCE2ENGINETOSERVER_INTERFACE_VERSION, &g_pSource2EngineToServer },
{ SOURCE2ENGINETOSERVERSTRINGTABLE_INTERFACE_VERSION, &g_pSource2EngineToServerStringTable },
{ SOURCE2ENGINETOCLIENTSTRINGTABLE_INTERFACE_VERSION, &g_pSource2EngineToClientStringTable },
{ SOURCE2ENGINESOUNDSERVER_INTERFACE_VERSION, &g_pSource2EngineSoundServer },
{ SOURCE2ENGINESOUNDCLIENT_INTERFACE_VERSION, &g_pSource2EngineSoundClient },
/*
.data:4C0E39A8 dd offset aVphysics2_inte ; "VPhysics2_Interface_001"
.data:4C0E39B0 dd offset aVphysics2_hand ; "VPhysics2_Handle_Interface_001"
*/
{ SERVERUPLOADGAMESTATS_INTERFACE_VERSION, &g_pServerUploadGameStats },
{ SCALEFORMUI_INTERFACE_VERSION, &g_pScaleformUI },
{ VR_INTERFACE_VERSION, vr }
};
static const int NUM_INTERFACES = sizeof(g_pInterfaceGlobals) / sizeof(InterfaceGlobals_t);
@ -143,7 +297,8 @@ void ConnectInterfaces(CreateInterfaceFn *pFactoryList, int nFactoryCount)
{
if (s_nRegistrationCount < 0)
{
Error("APPSYSTEM: In ConnectInterfaces(), s_nRegistrationCount is %d!\n", s_nRegistrationCount);
//Error("APPSYSTEM: In ConnectInterfaces(), s_nRegistrationCount is %d!\n", s_nRegistrationCount);
Plat_ExitProcess(1);
s_nConnectionCount++;
return;
}

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
@ -18,9 +18,11 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -52,6 +52,11 @@ enum AppSystemTier_t
APP_SYSTEM_TIER_OTHER,
};
enum BuildType_t
{
kBuildTypeRelease = 2
};
abstract_class IAppSystem
{
@ -67,6 +72,7 @@ public:
// Init, shutdown
virtual InitReturnVal_t Init() = 0;
virtual void Shutdown() = 0;
virtual void PreShutdown() = 0;
// Returns all dependent libraries
virtual const AppSystemInfo_t* GetDependencies() = 0;
@ -79,6 +85,8 @@ public:
// Returns whether or not the app system is a singleton
virtual bool IsSingleton() = 0;
virtual BuildType_t GetBuildType() = 0;
};

File diff suppressed because it is too large Load Diff

View File

@ -22,6 +22,7 @@
#include "tier1/utlstring.h"
//#include "tier1/functors.h"
#include "tier1/checksum_crc.h"
#include "tier1/utldelegate.h"
#include "tier1/utlqueue.h"
#include "appframework/IAppSystem.h"
#include "tier2/tier2.h"
@ -33,6 +34,9 @@
class CUtlBuffer;
class KeyValues;
class IFileList;
struct SearchPathStateHandle_t;
class ILowLevelFileIO;
class CSteamID;
typedef void * FileHandle_t;
typedef int FileFindHandle_t;
@ -229,6 +233,18 @@ enum SearchPathAdd_t
PATH_ADD_TO_TAIL_ATINDEX, // First path searched
};
// ??????
enum SearchPathPriority_t
{
PRIORITY_UNKNOWN,
};
// ??????
enum GetSearchPathTypes_t
{
};
enum FilesystemOpenExFlags_t
{
FSOPEN_UNBUFFERED = (1 << 0),
@ -391,8 +407,6 @@ public:
// This is the minimal interface that can be implemented to provide access to
// a named set of files.
#define BASEFILESYSTEM_INTERFACE_VERSION "VBaseFileSystem011"
abstract_class IBaseFileSystem
{
public:
@ -424,6 +438,7 @@ public:
virtual bool ReadFile( const char *pFileName, const char *pPath, CUtlBuffer &buf, int nMaxBytes = 0, int nStartingByte = 0, FSAllocFunc_t pfnAlloc = NULL ) = 0;
virtual bool WriteFile( const char *pFileName, const char *pPath, CUtlBuffer &buf ) = 0;
virtual bool UnzipFile( const char *pFileName, const char *pPath, const char *pDestination ) = 0;
virtual bool CopyAFile( const char *pFileName, const char *pPath, const char *pDestination, bool bDontOverwrite = false ) = 0;
};
@ -458,9 +473,13 @@ public:
// override is cleared and the current .bsp is searched for an embedded PAK file
// and this file becomes the highest priority search path ( i.e., it's looked at first
// even before the mod's file system path ).
virtual void AddSearchPath( const char *pPath, const char *pathID, SearchPathAdd_t addType = PATH_ADD_TO_TAIL ) = 0;
virtual void AddSearchPath( const char *pPath, const char *pathID, SearchPathAdd_t addType = PATH_ADD_TO_TAIL, SearchPathPriority_t priority = PRIORITY_UNKNOWN ) = 0;
virtual bool RemoveSearchPath( const char *pPath, const char *pathID = 0 ) = 0;
virtual SearchPathStateHandle_t *SaveSearchPathState( const char *pszName ) const = 0;
virtual void RestoreSearchPathState( SearchPathStateHandle_t *pState ) = 0;
virtual void DestroySearchPathState( SearchPathStateHandle_t *pState ) = 0;
// Remove all search paths (including write path?)
virtual void RemoveAllSearchPaths( void ) = 0;
@ -473,11 +492,14 @@ public:
// remember it in case you add search paths with this path ID.
virtual void MarkPathIDByRequestOnly( const char *pPathID, bool bRequestOnly ) = 0;
virtual bool IsFileInReadOnlySearchPath ( const char *pPathID, const char *pFileName ) = 0;
virtual void SetSearchPathReadOnly( const char *pPathID, const char *, bool bReadOnly ) = 0;
// converts a partial path into a full path
virtual const char *RelativePathToFullPath( const char *pFileName, const char *pPathID, char *pLocalPath, int localPathBufferSize, PathTypeFilter_t pathFilter = FILTER_NONE, PathTypeQuery_t *pPathType = NULL ) = 0;
// Returns the search path, each path is separated by ;s. Returns the length of the string returned
virtual int GetSearchPath( const char *pathID, bool bGetPackFiles, char *pPath, int nMaxLen ) = 0;
virtual int GetSearchPath( const char *pathID, GetSearchPathTypes_t pathType, char *pPath, int nMaxLen ) = 0;
//--------------------------------------------------------
// File manipulation operations
@ -551,7 +573,7 @@ public:
// Returns true on success ( based on current list of search paths, otherwise false if
// it can't be resolved )
virtual bool FullPathToRelativePath( const char *pFullpath, char *pRelative, int maxlen ) = 0;
virtual bool FullPathToRelativePath( const char *pFullpath, const char *pPathID, char *pRelative, int maxlen ) = 0;
// Gets the current working directory
virtual bool GetCurrentDirectory( char* pDirectory, int maxlen ) = 0;
@ -643,7 +665,7 @@ public:
// Start of new functions after Lost Coast release (7/05)
//--------------------------------------------------------
virtual FileHandle_t OpenEx( const char *pFileName, const char *pOptions, unsigned flags = 0, const char *pathID = 0, char **ppszResolvedFilename = NULL ) = 0;
virtual FileHandle_t OpenEx( const char *pFileName, const char *pOptions, unsigned flags = 0, const char *pathID = 0 ) = 0;
// Extended version of read provides more context to allow for more optimal reading
virtual int ReadEx( void* pOutput, int sizeDest, int size, FileHandle_t file ) = 0;
@ -658,9 +680,6 @@ public:
virtual IBlockingFileItemList *RetrieveBlockingFileAccessInfo() = 0;
#endif
virtual void SetupPreloadData() = 0;
virtual void DiscardPreloadData() = 0;
// Fixme, we could do these via a string embedded into the compiled data, etc...
enum KeyValuesPreloadType_t
{
@ -679,6 +698,7 @@ public:
virtual FSAsyncStatus_t AsyncWriteFile(const char *pFileName, const CUtlBuffer *pSrc, int nSrcBytes, bool bFreeMemory, bool bAppend = false, FSAsyncControl_t *pControl = NULL ) = 0;
// Async read functions with memory blame
FSAsyncStatus_t AsyncReadCreditAlloc( const FileAsyncRequest_t &request, const char *pszFile, int line, FSAsyncControl_t *phControl = NULL ) { return AsyncReadMultipleCreditAlloc( &request, 1, pszFile, line, phControl ); }
virtual FSAsyncStatus_t AsyncWriteUGCFile( const char *pFileName, const CUtlBuffer *pSrc, int nSrcBytes, bool bFreeMemory, CUtlDelegate<void (bool, const char *)> callback, FSAsyncControl_t *phControl = NULL ) = 0;
virtual FSAsyncStatus_t AsyncReadMultipleCreditAlloc( const FileAsyncRequest_t *pRequests, int nRequests, const char *pszFile, int line, FSAsyncControl_t *phControls = NULL ) = 0;
virtual FSAsyncStatus_t AsyncDirectoryScan( const char* pSearchSpec, bool recurseFolders, void* pContext, FSAsyncScanAddFunc_t pfnAdd, FSAsyncScanCompleteFunc_t pfnDone, FSAsyncControl_t *pControl = NULL ) = 0;
@ -700,12 +720,6 @@ public:
//--------------------------------------------------------
//
//--------------------------------------------------------
virtual void BeginMapAccess() = 0;
virtual void EndMapAccess() = 0;
// Returns true on success, otherwise false if it can't be resolved
virtual bool FullPathToRelativePathEx( const char *pFullpath, const char *pPathId, char *pRelative, int maxlen ) = 0;
virtual int GetPathIndex( const FileNameHandle_t &handle ) = 0;
virtual long GetPathTime( const char *pPath, const char *pPathID ) = 0;
@ -776,13 +790,20 @@ public:
virtual FSDirtyDiskReportFunc_t GetDirtyDiskReportFunc() = 0;
virtual void AddVPKFile( char const *pszName, SearchPathAdd_t addType = PATH_ADD_TO_TAIL ) = 0;
virtual void RemoveVPKFile( char const *pszName ) = 0;
virtual void GetVPKFileNames( CUtlVector<CUtlString> &destVector ) = 0;
virtual void RemoveAllMapSearchPaths() = 0;
virtual void SyncDvdDevCache() = 0;
virtual void AddVPKFile( const char *pszName, const char *, SearchPathAdd_t addType = PATH_ADD_TO_TAIL ) = 0;
virtual void RemoveVPKFile( const char *pszName, const char * ) = 0;
virtual bool IsVPKFileLoaded( const char *pszName ) = 0;
virtual void EnableAutoVPKFileLoading( bool ) = 0;
virtual void GetAutoVPKFileLoading( void ) = 0;
virtual void AddUGCVPKFile( uint64 ugcId, const char *, SearchPathAdd_t ) = 0;
virtual void RemoveUGCVPKFile( uint64 ugcId, const char * ) = 0;
virtual bool IsUGCVPKFileLoaded( uint64 ugcId ) = 0;
virtual void ParseUGCHandleFromFilename( const char *, char ** )const = 0;
virtual void CreateFilenameForUGCFile( char *, int, uint64 ugcId, const char *, char ) const = 0;
virtual void GetUGCInfo( uint64 ugcId, char **, int *, CSteamID * ) = 0;
virtual void OpenUGCFile( uint64 ugcId ) = 0;
virtual bool GetStringFromKVPool( CRC32_t poolKey, unsigned int key, char *pOutBuff, int buflen ) = 0;
virtual void SyncDvdDevCache() = 0;
virtual bool DiscoverDLC( int iController ) = 0;
virtual int IsAnyDLCPresent( bool *pbDLCSearchPathMounted = NULL ) = 0;
@ -797,6 +818,20 @@ public:
// 0.0 will turn off the functionality.
virtual void SetIODelayAlarm( float flThreshhold ) = 0;
virtual ILowLevelFileIO *GetLowLevelFileIO( void ) = 0;
virtual void SetLowLevelFileIO( ILowLevelFileIO * ) = 0;
virtual void AddXLSPUpdateSearchPath( const void *, int ) = 0;
virtual void DumpFileSystemStats( int, const char * ) = 0;
virtual void DeleteDirectory( const char *pFileName, const char *pathID = 0 ) = 0;
virtual bool IsPathInvalidForFilesystem( const char *pFileName ) = 0;
virtual void GetAvailableDrives( CUtlVector<CUtlString> &drives ) = 0;
virtual const char *ReadLine( FileHandle_t file, bool bStripNewline = true ) = 0;
};
//-----------------------------------------------------------------------------

View File

@ -56,6 +56,8 @@ public:
virtual bool ReadFile( const char *pFileName, const char *pPath, CUtlBuffer &buf, int nMaxBytes = 0, int nStartingByte = 0, FSAllocFunc_t pfnAlloc = NULL ) { return m_pBaseFileSystemPassThru->ReadFile( pFileName, pPath, buf, nMaxBytes, nStartingByte, pfnAlloc ); }
virtual bool WriteFile( const char *pFileName, const char *pPath, CUtlBuffer &buf ) { return m_pBaseFileSystemPassThru->WriteFile( pFileName, pPath, buf ); }
virtual bool UnzipFile( const char *pFileName, const char *pPath, const char *pDestination ) { return m_pBaseFileSystemPassThru->UnzipFile( pFileName, pPath, pDestination ); }
virtual bool CopyAFile( const char *pFileName, const char *pPath, const char *pDestination, bool bDontOverwrite )
{ return m_pBaseFileSystemPassThru->CopyAFile( pFileName, pPath, pDestination, bDontOverwrite ); }
protected:
IBaseFileSystem *m_pBaseFileSystemPassThru;
@ -92,14 +94,20 @@ public:
virtual void *QueryInterface( const char *pInterfaceName ) { return m_pFileSystemPassThru->QueryInterface( pInterfaceName ); }
virtual InitReturnVal_t Init() { return m_pFileSystemPassThru->Init(); }
virtual void Shutdown() { m_pFileSystemPassThru->Shutdown(); }
virtual void PreShutdown() { m_pFileSystemPassThru->PreShutdown(); }
virtual const AppSystemInfo_t* GetDependencies() { return m_pFileSystemPassThru->GetDependencies(); }
virtual AppSystemTier_t GetTier() { return m_pFileSystemPassThru->GetTier(); }
virtual void Reconnect( CreateInterfaceFn factory, const char *pInterfaceName ) { m_pFileSystemPassThru->Reconnect( factory, pInterfaceName ); }
virtual bool IsSingleton() { return m_pFileSystemPassThru->IsSingleton(); }
virtual BuildType_t GetBuildType() { return m_pFileSystemPassThru->GetBuildType(); }
virtual void RemoveAllSearchPaths( void ) { m_pFileSystemPassThru->RemoveAllSearchPaths(); }
virtual void AddSearchPath( const char *pPath, const char *pathID, SearchPathAdd_t addType ) { m_pFileSystemPassThru->AddSearchPath( pPath, pathID, addType ); }
virtual void AddSearchPath( const char *pPath, const char *pathID, SearchPathAdd_t addType, SearchPathPriority_t priority )
{ m_pFileSystemPassThru->AddSearchPath( pPath, pathID, addType, priority ); }
virtual bool RemoveSearchPath( const char *pPath, const char *pathID ) { return m_pFileSystemPassThru->RemoveSearchPath( pPath, pathID ); }
virtual SearchPathStateHandle_t *SaveSearchPathState( const char *pszName ) const { return m_pFileSystemPassThru->SaveSearchPathState( pszName ); }
virtual void RestoreSearchPathState( SearchPathStateHandle_t *pState ) { m_pFileSystemPassThru->RestoreSearchPathState( pState ); }
virtual void DestroySearchPathState( SearchPathStateHandle_t *pState ) { m_pFileSystemPassThru->DestroySearchPathState( pState ); }
virtual void RemoveFile( char const* pRelativePath, const char *pathID ) { m_pFileSystemPassThru->RemoveFile( pRelativePath, pathID ); }
virtual bool RenameFile( char const *pOldPath, char const *pNewPath, const char *pathID ) { return m_pFileSystemPassThru->RenameFile( pOldPath, pNewPath, pathID ); }
virtual void CreateDirHierarchy( const char *path, const char *pathID ) { m_pFileSystemPassThru->CreateDirHierarchy( path, pathID ); }
@ -125,7 +133,7 @@ public:
virtual bool FindIsDirectory( FileFindHandle_t handle ) { return m_pFileSystemPassThru->FindIsDirectory( handle ); }
virtual void FindClose( FileFindHandle_t handle ) { m_pFileSystemPassThru->FindClose( handle ); }
virtual const char *GetLocalPath( const char *pFileName, char *pLocalPath, int localPathBufferSize ) { return m_pFileSystemPassThru->GetLocalPath( pFileName, pLocalPath, localPathBufferSize ); }
virtual bool FullPathToRelativePath( const char *pFullpath, char *pRelative, int maxlen ) { return m_pFileSystemPassThru->FullPathToRelativePath( pFullpath, pRelative, maxlen ); }
virtual bool FullPathToRelativePath( const char *pFullPath, const char *pPathId, char *pRelative, int nMaxLen ) { return m_pFileSystemPassThru->FullPathToRelativePath( pFullPath, pPathId, pRelative, nMaxLen ); }
virtual bool GetCurrentDirectory( char* pDirectory, int maxlen ) { return m_pFileSystemPassThru->GetCurrentDirectory( pDirectory, maxlen ); }
virtual void PrintOpenedFiles( void ) { m_pFileSystemPassThru->PrintOpenedFiles(); }
virtual void PrintSearchPaths( void ) { m_pFileSystemPassThru->PrintSearchPaths(); }
@ -134,6 +142,7 @@ public:
virtual void AddLoggingFunc( void (*pfnLogFunc)( const char *fileName, const char *accessType ) ){ m_pFileSystemPassThru->AddLoggingFunc( pfnLogFunc ); }
virtual void RemoveLoggingFunc( FileSystemLoggingFunc_t logFunc ) { m_pFileSystemPassThru->RemoveLoggingFunc( logFunc ); }
virtual FSAsyncStatus_t AsyncReadMultiple( const FileAsyncRequest_t *pRequests, int nRequests, FSAsyncControl_t *pControls ) { return m_pFileSystemPassThru->AsyncReadMultiple( pRequests, nRequests, pControls ); }
virtual FSAsyncStatus_t AsyncWriteUGCFile( const char *pFileName, const CUtlBuffer *pSrc, int nSrcBytes, bool bFreeMemory, CUtlDelegate<void (bool, const char *)> callback, FSAsyncControl_t *phControl = NULL ) { return m_pFileSystemPassThru->AsyncWriteUGCFile( pFileName, pSrc, nSrcBytes, bFreeMemory, callback, phControl ); }
virtual FSAsyncStatus_t AsyncReadMultipleCreditAlloc( const FileAsyncRequest_t *pRequests, int nRequests, const char *pszFile, int line, FSAsyncControl_t *pControls ) { return m_pFileSystemPassThru->AsyncReadMultipleCreditAlloc( pRequests, nRequests, pszFile, line, pControls ); }
virtual FSAsyncStatus_t AsyncDirectoryScan( const char* pSearchSpec, bool recurseFolders, void* pContext, FSAsyncScanAddFunc_t pfnAdd, FSAsyncScanCompleteFunc_t pfnDone, FSAsyncControl_t *pControl = NULL ) { return m_pFileSystemPassThru->AsyncDirectoryScan( pSearchSpec, recurseFolders, pContext, pfnAdd, pfnDone, pControl ); }
virtual FSAsyncStatus_t AsyncFinish(FSAsyncControl_t hControl, bool wait) { return m_pFileSystemPassThru->AsyncFinish( hControl, wait ); }
@ -172,6 +181,8 @@ public:
const char *pPathID
) { m_pFileSystemPassThru->FindFileAbsoluteList( output, pWildCard, pPathID ); }
virtual void MarkPathIDByRequestOnly( const char *pPathID, bool bRequestOnly ) { m_pFileSystemPassThru->MarkPathIDByRequestOnly( pPathID, bRequestOnly ); }
virtual bool IsFileInReadOnlySearchPath ( const char *pPathID, const char *pFileName ) { return m_pFileSystemPassThru->IsFileInReadOnlySearchPath( pPathID, pFileName ); }
virtual void SetSearchPathReadOnly( const char *pPathID, const char *pUnknown, bool bReadOnly ) { m_pFileSystemPassThru->SetSearchPathReadOnly( pPathID, pUnknown, bReadOnly ); }
virtual FSAsyncStatus_t AsyncAppend(const char *pFileName, const void *pSrc, int nSrcBytes, bool bFreeMemory, FSAsyncControl_t *pControl ) { return m_pFileSystemPassThru->AsyncAppend( pFileName, pSrc, nSrcBytes, bFreeMemory, pControl); }
virtual FSAsyncStatus_t AsyncWrite(const char *pFileName, const void *pSrc, int nSrcBytes, bool bFreeMemory, bool bAppend, FSAsyncControl_t *pControl ) { return m_pFileSystemPassThru->AsyncWrite( pFileName, pSrc, nSrcBytes, bFreeMemory, bAppend, pControl); }
virtual FSAsyncStatus_t AsyncWriteFile(const char *pFileName, const CUtlBuffer *pSrc, int nSrcBytes, bool bFreeMemory, bool bAppend, FSAsyncControl_t *pControl ) { return m_pFileSystemPassThru->AsyncWriteFile( pFileName, pSrc, nSrcBytes, bFreeMemory, bAppend, pControl); }
@ -182,9 +193,9 @@ public:
virtual bool AsyncSuspend() { return m_pFileSystemPassThru->AsyncSuspend(); }
virtual bool AsyncResume() { return m_pFileSystemPassThru->AsyncResume(); }
virtual const char *RelativePathToFullPath( const char *pFileName, const char *pPathID, char *pLocalPath, int localPathBufferSize, PathTypeFilter_t pathFilter = FILTER_NONE, PathTypeQuery_t *pPathType = NULL ) { return m_pFileSystemPassThru->RelativePathToFullPath( pFileName, pPathID, pLocalPath, localPathBufferSize, pathFilter, pPathType ); }
virtual int GetSearchPath( const char *pathID, bool bGetPackFiles, char *pPath, int nMaxLen ) { return m_pFileSystemPassThru->GetSearchPath( pathID, bGetPackFiles, pPath, nMaxLen ); }
virtual int GetSearchPath( const char *pathID, GetSearchPathTypes_t type, char *pPath, int nMaxLen ) { return m_pFileSystemPassThru->GetSearchPath( pathID, type, pPath, nMaxLen ); }
virtual FileHandle_t OpenEx( const char *pFileName, const char *pOptions, unsigned flags = 0, const char *pathID = 0, char **ppszResolvedFilename = NULL ) { return m_pFileSystemPassThru->OpenEx( pFileName, pOptions, flags, pathID, ppszResolvedFilename );}
virtual FileHandle_t OpenEx( const char *pFileName, const char *pOptions, unsigned flags = 0, const char *pathID = 0 ) { return m_pFileSystemPassThru->OpenEx( pFileName, pOptions, flags, pathID );}
virtual int ReadEx( void* pOutput, int destSize, int size, FileHandle_t file ) { return m_pFileSystemPassThru->ReadEx( pOutput, destSize, size, file ); }
virtual int ReadFileEx( const char *pFileName, const char *pPath, void **ppBuf, bool bNullTerminate, bool bOptimalAlloc, int nMaxBytes = 0, int nStartingByte = 0, FSAllocFunc_t pfnAlloc = NULL ) { return m_pFileSystemPassThru->ReadFileEx( pFileName, pPath, ppBuf, bNullTerminate, bOptimalAlloc, nMaxBytes, nStartingByte, pfnAlloc ); }
@ -194,8 +205,6 @@ public:
virtual IBlockingFileItemList *RetrieveBlockingFileAccessInfo() { return m_pFileSystemPassThru->RetrieveBlockingFileAccessInfo(); }
#endif
virtual void SetupPreloadData() {}
virtual void DiscardPreloadData() {}
// If the "PreloadedData" hasn't been purged, then this'll try and instance the KeyValues using the fast path of compiled keyvalues loaded during startup.
// Otherwise, it'll just fall through to the regular KeyValues loading routines
@ -208,11 +217,7 @@ public:
virtual void *AllocOptimalReadBuffer( FileHandle_t hFile, unsigned nSize, unsigned nOffset ) { return m_pFileSystemPassThru->AllocOptimalReadBuffer( hFile, nOffset, nSize ); }
virtual void FreeOptimalReadBuffer( void *p ) { m_pFileSystemPassThru->FreeOptimalReadBuffer( p ); }
virtual void BeginMapAccess() { m_pFileSystemPassThru->BeginMapAccess(); }
virtual void EndMapAccess() { m_pFileSystemPassThru->EndMapAccess(); }
virtual bool ReadToBuffer( FileHandle_t hFile, CUtlBuffer &buf, int nMaxBytes = 0, FSAllocFunc_t pfnAlloc = NULL ) { return m_pFileSystemPassThru->ReadToBuffer( hFile, buf, nMaxBytes, pfnAlloc ); }
virtual bool FullPathToRelativePathEx( const char *pFullPath, const char *pPathId, char *pRelative, int nMaxLen ) { return m_pFileSystemPassThru->FullPathToRelativePathEx( pFullPath, pPathId, pRelative, nMaxLen ); }
virtual int GetPathIndex( const FileNameHandle_t &handle ) { return m_pFileSystemPassThru->GetPathIndex( handle ); }
virtual long GetPathTime( const char *pPath, const char *pPathID ) { return m_pFileSystemPassThru->GetPathTime( pPath, pPathID ); }
@ -245,16 +250,21 @@ public:
virtual FSDirtyDiskReportFunc_t GetDirtyDiskReportFunc() { return m_pFileSystemPassThru->GetDirtyDiskReportFunc(); }
virtual void AddVPKFile( char const *pPkName, SearchPathAdd_t addType = PATH_ADD_TO_TAIL ) { m_pFileSystemPassThru->AddVPKFile( pPkName, addType ); }
virtual void RemoveVPKFile( char const *pPkName ) { m_pFileSystemPassThru->RemoveVPKFile( pPkName ); }
virtual void GetVPKFileNames( CUtlVector<CUtlString> &destVector ) { m_pFileSystemPassThru->GetVPKFileNames( destVector ); }
virtual void RemoveAllMapSearchPaths( void ) { m_pFileSystemPassThru->RemoveAllMapSearchPaths(); }
virtual void AddVPKFile( char const *pPkName, const char *pUnknown, SearchPathAdd_t addType = PATH_ADD_TO_TAIL ) { m_pFileSystemPassThru->AddVPKFile( pPkName, pUnknown, addType ); }
virtual void RemoveVPKFile( char const *pPkName, const char *pUnknown ) { m_pFileSystemPassThru->RemoveVPKFile( pPkName, pUnknown ); }
virtual bool IsVPKFileLoaded( const char *pszName ) { return m_pFileSystemPassThru->IsVPKFileLoaded( pszName ); }
virtual void EnableAutoVPKFileLoading( bool unk ) { m_pFileSystemPassThru->EnableAutoVPKFileLoading( unk ); }
virtual void GetAutoVPKFileLoading( void ) { m_pFileSystemPassThru->GetAutoVPKFileLoading(); }
virtual void AddUGCVPKFile( uint64 ugcId, const char *unk1, SearchPathAdd_t unk2 ) { m_pFileSystemPassThru->AddUGCVPKFile( ugcId, unk1, unk2 ); }
virtual void RemoveUGCVPKFile( uint64 ugcId, const char *unk1 ) { m_pFileSystemPassThru->RemoveUGCVPKFile( ugcId, unk1 ); }
virtual bool IsUGCVPKFileLoaded( uint64 ugcId ) { return m_pFileSystemPassThru->IsUGCVPKFileLoaded( ugcId ); }
virtual void ParseUGCHandleFromFilename( const char *unk1, char **unk2 ) const { m_pFileSystemPassThru->ParseUGCHandleFromFilename( unk1, unk2 ); }
virtual void CreateFilenameForUGCFile( char *unk1, int unk2, uint64 ugcId, const char *unk3, char unk4 ) const { m_pFileSystemPassThru->CreateFilenameForUGCFile( unk1, unk2, ugcId, unk3, unk4 ); }
virtual void GetUGCInfo( uint64 ugcId, char **unk1, int *unk2, CSteamID *unk3 ) { m_pFileSystemPassThru->GetUGCInfo( ugcId, unk1, unk2, unk3 ); }
virtual void OpenUGCFile( uint64 ugcId ) { m_pFileSystemPassThru->OpenUGCFile( ugcId ); }
virtual void SyncDvdDevCache( void ) { m_pFileSystemPassThru->SyncDvdDevCache(); }
virtual bool GetStringFromKVPool( CRC32_t poolKey, unsigned int key, char *pOutBuff, int buflen ) { return m_pFileSystemPassThru->GetStringFromKVPool( poolKey, key, pOutBuff, buflen ); }
virtual bool DiscoverDLC( int iController ) { return m_pFileSystemPassThru->DiscoverDLC( iController ); }
virtual int IsAnyDLCPresent( bool *pbDLCSearchPathMounted = NULL ) { return m_pFileSystemPassThru->IsAnyDLCPresent( pbDLCSearchPathMounted ); }
virtual bool GetAnyDLCInfo( int iDLC, unsigned int *pLicenseMask, wchar_t *pTitleBuff, int nOutTitleSize ) { return m_pFileSystemPassThru->GetAnyDLCInfo( iDLC, pLicenseMask, pTitleBuff, nOutTitleSize ); }
@ -264,6 +274,14 @@ public:
virtual bool IsSpecificDLCPresent( unsigned int nDLCPackage ) { return m_pFileSystemPassThru->IsSpecificDLCPresent( nDLCPackage ); }
virtual void SetIODelayAlarm( float flThreshhold ) { m_pFileSystemPassThru->SetIODelayAlarm( flThreshhold ); }
virtual ILowLevelFileIO *GetLowLevelFileIO( void ) { return m_pFileSystemPassThru->GetLowLevelFileIO(); }
virtual void SetLowLevelFileIO( ILowLevelFileIO *pIO ) { m_pFileSystemPassThru->SetLowLevelFileIO( pIO ); }
virtual void AddXLSPUpdateSearchPath( const void *unk1, int unk2 ) { m_pFileSystemPassThru->AddXLSPUpdateSearchPath( unk1, unk2 ); }
virtual void DumpFileSystemStats( int unk1, const char *unk2 ) { m_pFileSystemPassThru->DumpFileSystemStats( unk1, unk2 ); }
virtual void DeleteDirectory( const char *pFileName, const char *pathID = 0 ) { m_pFileSystemPassThru->DeleteDirectory( pFileName, pathID ); }
virtual bool IsPathInvalidForFilesystem( const char *pFileName ) { return m_pFileSystemPassThru->IsPathInvalidForFilesystem( pFileName ); }
virtual void GetAvailableDrives( CUtlVector<CUtlString> &drives ) { m_pFileSystemPassThru->GetAvailableDrives( drives ); }
virtual const char *ReadLine( FileHandle_t file, bool bStripNewline = true ) { return m_pFileSystemPassThru->ReadLine( file, bStripNewline ); }
protected:
IFileSystem *m_pFileSystemPassThru;
};

View File

@ -19,6 +19,9 @@ class ConCommandBase;
class ConCommand;
class ConVar;
class Color;
class IConVarListener;
class CConVarDetail;
struct ConVarSnapshot_t;
//-----------------------------------------------------------------------------
@ -166,6 +169,15 @@ protected:
virtual ICVarIteratorInternal *FactoryInternalIterator( void ) = 0;
friend class Iterator;
virtual void InstallConVarListener( IConVarListener *pListener ) = 0;
virtual void RemoveConVarListener( IConVarListener *pListener ) = 0;
virtual void GetConVarDetails( CUtlVector<CConVarDetail> &out ) = 0;
virtual void ResetConVarsToDefaultValues( const char *pszPrefix ) = 0;
virtual ConVarSnapshot_t *TakeConVarSnapshot( void ) = 0;
virtual void ResetConVarsToSnapshot( ConVarSnapshot_t *pSnapshot ) = 0;
virtual void DestroyConVarSnapshot( ConVarSnapshot_t *pSnaoshot ) = 0;
};
inline ICvar::Iterator::Iterator(ICvar *icvar)

View File

@ -48,47 +48,121 @@ class ICvar;
class IProcessUtils;
class ILocalize;
class IPhysics2;
class IPhysics2ActorManager;
class IPhysics2ResourceManager;
class IEventSystem;
class IAsyncFileSystem;
class IColorCorrectionSystem;
class IDebugTextureInfo;
class IBaseFileSystem;
class IFileSystem;
class IRenderHardwareConfig;
class IInputSystem;
class IInputStackSystem;
class IMaterialSystem;
class IMaterialSystem2;
class IMaterialSystemHardwareConfig;
class IMdlLib;
class INetworkSystem;
class INetworkSystemUtils;
class IP4;
class IQueuedLoader;
class IResourceAccessControl;
class IPrecacheSystem;
class IRenderDevice;
class IRenderDeviceSetup;
class IRenderDeviceMgr;
class IRenderUtils;
class IResourceSystem;
class IResourceSystemTools;
class IVBAllocTracker;
class IXboxInstaller;
class IMatchFramework;
class ISoundSystem;
class IStudioRender;
class IMatSystemSurface;
class IGameUISystemMgr;
class IDataCache;
class IMDLCache;
class IAvi;
class IBik;
class IQuickTime;
class IDmeMakefileUtils;
class IPhysicsCollision;
class ISoundEmitterSystemBase;
class ISoundEmitterSystemBaseS1;
class IMeshSystem;
class IMeshUtils;
class IWorldRendererMgr;
class ISceneSystem;
class ISceneUtils;
class IVGuiRenderSurface;
class IResourceManifestRegistry;
class IResourceHandleUtils;
class ISchemaSystem;
class IResourceCompilerSystem;
class IPostProcessingSystem;
class ISoundMixGroupSystem;
class ISoundOpSystemEdit;
class ISoundOpSystem;
class IAssetSystem;
class IAssetSystemTest;
class IParticleSystemMgr;
class IVScriptManager;
class IToolScriptManager;
class IPropertyEditorSystem;
class IModelProcessingSystem;
class IPanoramaUI;
class IToolFramework2;
class IMapBuilderMgr;
class IHelpSystem;
class IToolSceneNodeFactory;
class IToolGameSimulationSystem;
class IToolGameSimulationDispatcher;
class ISchemaTestExternal_Two;
class ISchemaTestExternal_One;
class IAnimationSystem;
class IAnimationSystemUtils;
class IHammerMapLoader;
class IMaterialUtils;
class IFontManager;
class ITextLayout;
class IAssetPreviewSystem;
class IAssetBrowserSystem;
class IVConComm;
class IConfigurationSystem;
class INetworkMessages;
class IFlattenedSerializers;
class ISource2Client;
class ISource2ClientPrediction;
class ISource2Server;
class ISource2ServerSerializers;
class ISource2Host;
class ISource2GameClients;
class ISource2GameEntities;
class IEngineServiceMgr;
class IHostStateMgr;
class INetworkService;
class INetworkClientService;
class INetworkServerService;
class ITextMessageMgr;
class IToolService;
class IRenderService;
class IStatsService;
class IUserInfoChangeService;
class IVProfService;
class IInputService;
class IMapListService;
class IGameUIService;
class ISoundService;
class IBenchmarkService;
class IDebugService;
class IKeyValueCache;
class IGameResourceServiceClient;
class IGameResourceServiceServer;
class ISource2EngineToClient;
class ISource2EngineToServer;
class ISource2EngineToServerStringTable;
class ISource2EngineToClientStringTable;
class ISource2EngineSoundServer;
class ISource2EngineSoundClient;
class IServerUploadGameStats;
class IScaleformUI;
class IVR;
namespace vgui
{
@ -113,13 +187,10 @@ DECLARE_TIER1_INTERFACE( ICvar, g_pCVar )
#define PROCESS_UTILS_INTERFACE_VERSION "VProcessUtils002"
DECLARE_TIER1_INTERFACE( IProcessUtils, g_pProcessUtils );
#define VPHYSICS2_INTERFACE_VERSION "Physics2 Interface v0.3"
#define VPHYSICS2_INTERFACE_VERSION "Physics2 Interface Old v0.5"
DECLARE_TIER1_INTERFACE( IPhysics2, g_pPhysics2 );
#define VPHYSICS2_ACTOR_MGR_INTERFACE_VERSION "Physics2 Interface ActorMgr v0.1"
DECLARE_TIER1_INTERFACE( IPhysics2ActorManager, g_pPhysics2ActorManager );
#define VPHYSICS2_RESOURCE_MGR_INTERFACE_VERSION "Physics2 Interface ResourceMgr v0.1"
#define VPHYSICS2_RESOURCE_MGR_INTERFACE_VERSION "VPhysX Interface ResourceMgr v0.1"
DECLARE_TIER1_INTERFACE( IPhysics2ResourceManager, g_pPhysics2ResourceManager );
#define EVENTSYSTEM_INTERFACE_VERSION "EventSystem001"
@ -132,21 +203,41 @@ DECLARE_TIER3_INTERFACE( vgui::ILocalize, g_pVGuiLocalize );
#define RENDER_DEVICE_MGR_INTERFACE_VERSION "RenderDeviceMgr001"
DECLARE_TIER2_INTERFACE( IRenderDeviceMgr, g_pRenderDeviceMgr );
#define RENDER_UTILS_INTERFACE_VERSION "RenderUtils_001"
DECLARE_TIER2_INTERFACE( IRenderUtils, g_pRenderUtils );
#define BASEFILESYSTEM_INTERFACE_VERSION "VBaseFileSystem011"
DECLARE_TIER2_INTERFACE( IBaseFileSystem, g_pBaseFileSystem );
#define FILESYSTEM_INTERFACE_VERSION "VFileSystem017"
DECLARE_TIER2_INTERFACE( IFileSystem, g_pFullFileSystem );
#define ASYNCFILESYSTEM_INTERFACE_VERSION "VNewAsyncFileSystem001"
DECLARE_TIER2_INTERFACE( IAsyncFileSystem, g_pAsyncFileSystem );
#define RESOURCESYSTEM_INTERFACE_VERSION "ResourceSystem004"
#define RESOURCESYSTEM_INTERFACE_VERSION "ResourceSystem009"
DECLARE_TIER2_INTERFACE( IResourceSystem, g_pResourceSystem );
#define MATERIAL_SYSTEM_INTERFACE_VERSION "VMaterialSystem080"
DECLARE_TIER2_INTERFACE( IMaterialSystem, materials );
DECLARE_TIER2_INTERFACE( IMaterialSystem, g_pMaterialSystem );
#define RESOURCESYSTEMTOOLS_INTERFACE_VERSION "ResourceSystemTools001"
DECLARE_TIER2_INTERFACE( IResourceSystemTools, g_pResourceSystemTools );
#define RESOURCEMANIFESTREGISTRY_INTERFACE_VERSION "ResourceManifestRegistry001"
DECLARE_TIER2_INTERFACE( IResourceManifestRegistry, g_pResourceManifestRegistry );
#define RESOURCEHANDLEUTILS_INTERFACE_VERSION "ResourceHandleUtils001"
DECLARE_TIER2_INTERFACE( IResourceHandleUtils, g_pResourceHandleUtils );
#define SCHEMASYSTEM_INTERFACE_VERSION "SchemaSystem_001"
DECLARE_TIER2_INTERFACE( ISchemaSystem, g_pSchemaSystem );
#define RESOURCECOMPILERSYSTEM_INTERFACE_VERSION "ResourceCompilerSystem001"
DECLARE_TIER2_INTERFACE( IResourceCompilerSystem, g_pResourceCompilerSystem );
#define POSTPROCESSINGSYSTEM_INTERFACE_VERSION "PostProcessingSystem_001"
DECLARE_TIER2_INTERFACE( IPostProcessingSystem, g_pPostProcessingSystem );
#define MATERIAL_SYSTEM2_INTERFACE_VERSION "VMaterialSystem2_001"
DECLARE_TIER2_INTERFACE( IMaterialSystem2, g_pMaterialSystem2 );
DECLARE_TIER2_INTERFACE( IMaterialSystem, g_pMaterialSystem );
#define INPUTSYSTEM_INTERFACE_VERSION "InputSystemVersion001"
DECLARE_TIER2_INTERFACE( IInputSystem, g_pInputSystem );
@ -154,11 +245,14 @@ DECLARE_TIER2_INTERFACE( IInputSystem, g_pInputSystem );
#define INPUTSTACKSYSTEM_INTERFACE_VERSION "InputStackSystemVersion001"
DECLARE_TIER2_INTERFACE( IInputStackSystem, g_pInputStackSystem );
#define NETWORKSYSTEM_INTERFACE_VERSION "NetworkSystemVersion002"
#define NETWORKSYSTEM_INTERFACE_VERSION "NetworkSystemVersion001"
DECLARE_TIER2_INTERFACE( INetworkSystem, g_pNetworkSystem );
#define MATERIALSYSTEM_HARDWARECONFIG_INTERFACE_VERSION "MaterialSystemHardwareConfig013"
DECLARE_TIER2_INTERFACE( IMaterialSystemHardwareConfig, g_pMaterialSystemHardwareConfig );
#define NETWORKSYSTEMUTILS_INTERFACE_VERSION "NetworkSystemUtilsVersion001"
DECLARE_TIER2_INTERFACE( INetworkSystemUtils, g_pNetworkSystemUtils );
#define NETWORKMESSAGES_INTERFACE_VERSION "NetworkMessagesVersion001"
DECLARE_TIER2_INTERFACE( INetworkMessages, g_pNetworkMessages );
#define DEBUG_TEXTURE_INFO_VERSION "DebugTextureInfo001"
DECLARE_TIER2_INTERFACE( IDebugTextureInfo, g_pMaterialSystemDebugTextureInfo );
@ -169,7 +263,7 @@ DECLARE_TIER2_INTERFACE( IVBAllocTracker, g_VBAllocTracker );
#define COLORCORRECTION_INTERFACE_VERSION "COLORCORRECTION_VERSION_1"
DECLARE_TIER2_INTERFACE( IColorCorrectionSystem, colorcorrection );
#define P4_INTERFACE_VERSION "VP4002"
#define P4_INTERFACE_VERSION "VP4003"
DECLARE_TIER2_INTERFACE( IP4, p4 );
#define MDLLIB_INTERFACE_VERSION "VMDLLIB001"
@ -178,12 +272,6 @@ DECLARE_TIER2_INTERFACE( IMdlLib, mdllib );
#define QUEUEDLOADER_INTERFACE_VERSION "QueuedLoaderVersion001"
DECLARE_TIER2_INTERFACE( IQueuedLoader, g_pQueuedLoader );
#define RESOURCE_ACCESS_CONTROL_INTERFACE_VERSION "VResourceAccessControl001"
DECLARE_TIER2_INTERFACE( IResourceAccessControl, g_pResourceAccessControl );
#define PRECACHE_SYSTEM_INTERFACE_VERSION "VPrecacheSystem001"
DECLARE_TIER2_INTERFACE( IPrecacheSystem, g_pPrecacheSystem );
#if defined( _X360 )
#define XBOXINSTALLER_INTERFACE_VERSION "XboxInstallerVersion001"
DECLARE_TIER2_INTERFACE( IXboxInstaller, g_pXboxInstaller );
@ -192,40 +280,249 @@ DECLARE_TIER2_INTERFACE( IXboxInstaller, g_pXboxInstaller );
#define MATCHFRAMEWORK_INTERFACE_VERSION "MATCHFRAMEWORK_001"
DECLARE_TIER2_INTERFACE( IMatchFramework, g_pMatchFramework );
#define GAMEUISYSTEMMGR_INTERFACE_VERSION "GameUISystemMgr001"
DECLARE_TIER3_INTERFACE( IGameUISystemMgr, g_pGameUISystemMgr );
//-----------------------------------------------------------------------------
// Not exactly a global, but we're going to keep track of these here anyways
// NOTE: Appframework deals with connecting these bad boys. See materialsystem2app.cpp
//-----------------------------------------------------------------------------
#define RENDER_DEVICE_INTERFACE_VERSION "RenderDevice001"
DECLARE_TIER2_INTERFACE( IRenderDevice, g_pRenderDevice );
#define RENDER_DEVICE_INTERFACE_VERSION "RenderDevice002"
DECLARE_TIER2_INTERFACE(IRenderDevice, g_pRenderDevice);
#define RENDER_HARDWARECONFIG_INTERFACE_VERSION "RenderHardwareConfig001"
#define RENDER_DEVICE_SETUP_INTERFACE_VERSION "VRenderDeviceSetupV001"
DECLARE_TIER2_INTERFACE( IRenderDeviceSetup, g_pRenderDeviceSetup );
#define RENDER_HARDWARECONFIG_INTERFACE_VERSION "RenderHardwareConfig002"
DECLARE_TIER2_INTERFACE( IRenderHardwareConfig, g_pRenderHardwareConfig );
#define SOUNDSYSTEM_INTERFACE_VERSION "SoundSystem001"
DECLARE_TIER2_INTERFACE( ISoundSystem, g_pSoundSystem );
#define SOUNDMIXGROUPSYSTEM_INTERFACE_VERSION "SoundMixGroupSystem001"
DECLARE_TIER2_INTERFACE( ISoundMixGroupSystem, g_pSoundMixGroupSystem);
#define SOUNDOPSYSTEMEDIT_INTERFACE_VERSION "SoundOpSystemEdit001"
DECLARE_TIER2_INTERFACE( ISoundOpSystemEdit, g_pSoundOpSystemEdit );
#define SOUNDOPSYSTEM_INTERFACE_VERSION "SoundOpSystem001"
DECLARE_TIER2_INTERFACE( ISoundOpSystem, g_pSoundOpSystem );
#define MESHSYSTEM_INTERFACE_VERSION "MeshSystem001"
DECLARE_TIER3_INTERFACE( IMeshSystem, g_pMeshSystem );
#define STUDIO_RENDER_INTERFACE_VERSION "VStudioRender026"
DECLARE_TIER3_INTERFACE( IStudioRender, g_pStudioRender );
DECLARE_TIER3_INTERFACE( IStudioRender, studiorender );
#define MAT_SYSTEM_SURFACE_INTERFACE_VERSION "MatSystemSurface006"
DECLARE_TIER3_INTERFACE( IMatSystemSurface, g_pMatSystemSurface );
#define MESHUTILS_INTERFACE_VERSION "MeshUtils001"
DECLARE_TIER3_INTERFACE( IMeshUtils, g_pMeshUtils );
#define RENDER_SYSTEM_SURFACE_INTERFACE_VERSION "RenderSystemSurface001"
DECLARE_TIER3_INTERFACE( IVGuiRenderSurface, g_pVGuiRenderSurface );
#define SCENESYSTEM_INTERFACE_VERSION "SceneSystem_001"
#define ASSETSYSTEM_INTERFACE_VERSION "AssetSystem001"
DECLARE_TIER3_INTERFACE( IAssetSystem, g_pAssetSystem );
#define ASSETSYSTEMTEST_INTERFACE_VERSION "AssetSystemTest001"
DECLARE_TIER3_INTERFACE( IAssetSystemTest, g_pAssetSystemTest );
#define PARTICLESYSTEMMGR_INTERFACE_VERSION "ParticleSystemMgr002"
DECLARE_TIER3_INTERFACE( IParticleSystemMgr, g_pParticleSystemMgr );
#define VSCRIPT_INTERFACE_VERSION "VScriptManager010"
DECLARE_TIER3_INTERFACE( IVScriptManager, g_pVScriptService );
#define TOOLSCRIPTMANAGER_INTERFACE_VERSION "ToolScriptManager001"
DECLARE_TIER3_INTERFACE( IToolScriptManager, g_pToolScriptManager );
#define PROPERTYEDITORSYSTEM_INTERFACE_VERSION "PropertyEditorSystem_001"
DECLARE_TIER3_INTERFACE( IPropertyEditorSystem, g_pPropertyEditorSystem );
#define MODELPROCESSINGSYSTEM_INTERFACE_VERSION "ModelProcessingSystem001"
DECLARE_TIER3_INTERFACE( IModelProcessingSystem, g_pModelProcessingSystem );
#define PANORAMAUI_INTERFACE_VERSION "PanoramaUI001"
DECLARE_TIER3_INTERFACE( IPanoramaUI, g_pPanoramaUI );
#define TOOLFRAMEWORK2_INTERFACE_VERSION "ToolFramework2_001"
DECLARE_TIER3_INTERFACE( IToolFramework2, g_pToolFramework2 );
#define WORLDRENDERERBUILDER_INTERFACE_VERSION "WorldRendererBuilderMgr001"
DECLARE_TIER3_INTERFACE( IMapBuilderMgr, g_pWorldRendererBuilderMgr );
#define LIGHTINGBUILDER_INTERFACE_VERSION "LightingBuilderMgr001"
DECLARE_TIER3_INTERFACE( IMapBuilderMgr, g_pLightingBuilderMgr );
#define PHYSICSBUILDER_INTERFACE_VERSION "PhysicsBuilderMgr001"
DECLARE_TIER3_INTERFACE( IMapBuilderMgr, g_pPhysicsBuilderMgr );
#define VISBUILDER_INTERFACE_VERSION "VisBuilder_001"
DECLARE_TIER3_INTERFACE( IMapBuilderMgr, g_pVisBuilderMgr );
#define ENVIRONMENTBUILDER_INTERFACE_VERSION "EnvironmentMapBuilder_001"
DECLARE_TIER3_INTERFACE( IMapBuilderMgr, g_pEnvironmentBuilderMgr );
#define BAKEDLODBUILDER_INTERFACE_VERSION "BakedLODBuilderMgr001"
DECLARE_TIER3_INTERFACE( IMapBuilderMgr, g_pBakedLODBuilderMgr );
#define HELPSYSTEM_INTERFACE_VERSION "HelpSystem_001"
DECLARE_TIER3_INTERFACE( IHelpSystem, g_pHelpSystem );
#define TOOLSCENENODEFACTORY_INTERFACE_VERSION "ToolSceneNodeFactory_001"
DECLARE_TIER3_INTERFACE( IToolSceneNodeFactory, g_pToolSceneNodeFactory );
#define TOOLGAMESIMULATIONSYSTEM_INTERFACE_VERSION "ToolGameSimulationSystem_001"
DECLARE_TIER3_INTERFACE( IToolGameSimulationSystem, g_pToolGameSimulationSystem );
#define TOOLGAMESIMULATIONDISPATCHER_INTERFACE_VERSION "ToolGameSimulationDispatcher_001"
DECLARE_TIER3_INTERFACE( IToolGameSimulationDispatcher, g_pToolGameSimulationDispatcher );
#define SCHEMATESTEXTERNALTWO_INTERFACE_VERSION "SchemaTestExternal_Two_001"
DECLARE_TIER3_INTERFACE( ISchemaTestExternal_Two, g_pSchemaTestExternal_Two );
#define SCHEMATESTEXTERNALONE_INTERFACE_VERSION "SchemaTestExternal_One_001"
DECLARE_TIER3_INTERFACE( ISchemaTestExternal_One, g_pSchemaTestExternal_One );
#define ANIMATIONSYSTEM_INTERFACE_VERSION "AnimationSystem_001"
DECLARE_TIER3_INTERFACE( IAnimationSystem, g_pAnimationSystem );
#define ANIMATIONSYSTEMUTILS_INTERFACE_VERSION "AnimationSystemUtils_001"
DECLARE_TIER3_INTERFACE( IAnimationSystemUtils, g_pAnimationSystemUtils );
#define HAMMERMAPLOADER_INTERFACE_VERSION "HammerMapLoader001"
DECLARE_TIER3_INTERFACE( IHammerMapLoader, g_pHammerMapLoader );
#define MATERIALUTILS_INTERFACE_VERSION "MaterialUtils_001"
DECLARE_TIER3_INTERFACE( IMaterialUtils, g_pMaterialUtils );
#define FONTMANAGER_INTERFACE_VERSION "FontManager_001"
DECLARE_TIER3_INTERFACE( IFontManager, g_pFontManager );
#define TEXTLAYOUT_INTERFACE_VERSION "TextLayout_001"
DECLARE_TIER3_INTERFACE( ITextLayout, g_pTextLayout );
#define ASSETPREVIEWSYSTEM_INTERFACE_VERSION "AssetPreviewSystem_001"
DECLARE_TIER3_INTERFACE( IAssetPreviewSystem, g_pAssetPreviewSystem );
#define ASSETBROWSERSYSTEM_INTERFACE_VERSION "AssetBrowserSystem_001"
DECLARE_TIER3_INTERFACE( IAssetBrowserSystem, g_pAssetBrowserSystem );
#define VCONCOMM_INTERFACE_VERSION "VConComm001"
DECLARE_TIER3_INTERFACE( IVConComm, g_pVConComm );
#define CONFIGURATIONSYSTEM_INTERFACE_VERSION "ConfigurationSystem_001"
DECLARE_TIER3_INTERFACE( IConfigurationSystem, g_pConfigurationSystem );
#define FLATTENEDSERIALIZERS_INTERFACE_VERSION "FlattenedSerializersVersion001"
DECLARE_TIER3_INTERFACE( IFlattenedSerializers, g_pFlattenedSerializers );
#define SOURCE2CLIENT_INTERFACE_VERSION "Source2Client001"
DECLARE_TIER3_INTERFACE( ISource2Client, g_pSource2Client );
#define SOURCE2CLIENTPREDICTION_INTERFACE_VERSION "Source2ClientPrediction001"
DECLARE_TIER3_INTERFACE( ISource2ClientPrediction, g_pSource2ClientPrediction );
#define SOURCE2SERVER_INTERFACE_VERSION "Source2Server001"
DECLARE_TIER3_INTERFACE( ISource2Server, g_pSource2Server );
#define SOURCE2SERVERSERIALIZERS_INTERFACE_VERSION "Source2ServerSerializers001"
DECLARE_TIER3_INTERFACE( ISource2ServerSerializers, g_pSource2ServerSerializers );
#define SOURCE2HOST_INTERFACE_VERSION "Source2Host001"
DECLARE_TIER3_INTERFACE( ISource2Host, g_pSource2Host );
#define SOURCE2GAMECLIENTS_INTERFACE_VERSION "Source2GameClients001"
DECLARE_TIER3_INTERFACE( ISource2GameClients, g_pSource2GameClients );
#define SOURCE2GAMEENTITIES_INTERFACE_VERSION "Source2GameEntities001"
DECLARE_TIER3_INTERFACE( ISource2GameEntities, g_pSource2GameEntities );
#define ENGINESERVICEMGR_INTERFACE_VERSION "EngineServiceMgr001"
DECLARE_TIER3_INTERFACE( IEngineServiceMgr, g_pEngineServiceMgr );
#define HOSTSTATEMGR_INTERFACE_VERSION "HostStateMgr001"
DECLARE_TIER3_INTERFACE( IHostStateMgr, g_pHostStateMgr );
#define NETWORKSERVICE_INTERFACE_VERSION "NetworkService_001"
DECLARE_TIER3_INTERFACE( INetworkService, g_pNetworkService );
#define NETWORKCLIENTSERVICE_INTERFACE_VERSION "NetworkClientService_001"
DECLARE_TIER3_INTERFACE( INetworkClientService, g_pNetworkClientService );
#define NETWORKSERVERSERVICE_INTERFACE_VERSION "NetworkServerService_001"
DECLARE_TIER3_INTERFACE( INetworkServerService, g_pNetworkServerService );
#define TEXTMESSAGEMGR_INTERFACE_VERSION "TextMessageMgr_001"
DECLARE_TIER3_INTERFACE( ITextMessageMgr, g_pTextMessageMgr );
#define TOOLSERVICE_INTERFACE_VERSION "ToolService_001"
DECLARE_TIER3_INTERFACE(IToolService, g_pToolService);
#define RENDERSERVICE_INTERFACE_VERSION "RenderService_001"
DECLARE_TIER3_INTERFACE( IRenderService, g_pRenderService );
#define STATSSERVICE_INTERFACE_VERSION "StatsService_001"
DECLARE_TIER3_INTERFACE( IStatsService, g_pStatsService );
#define USERINFOCHANGESERVICE_INTERFACE_VERSION "UserInfoChangeService_001"
DECLARE_TIER3_INTERFACE( IUserInfoChangeService, g_pUserInfoChangeService );
#define VPROFSERVICE_INTERFACE_VERSION "VProfService_001"
DECLARE_TIER3_INTERFACE( IVProfService, g_pVProfService );
#define INPUTSERVICE_INTERFACE_VERSION "InputService_001"
DECLARE_TIER3_INTERFACE( IInputService, g_pInputService );
#define MAPLISTSERVICE_INTERFACE_VERSION "MapListService_001"
DECLARE_TIER3_INTERFACE( IMapListService, g_pMapListService );
#define GAMEUISERVICE_INTERFACE_VERSION "GameUIService_001"
DECLARE_TIER3_INTERFACE( IGameUIService, g_pGameUIService );
#define SOUNDSERVICE_INTERFACE_VERSION "SoundService_001"
DECLARE_TIER3_INTERFACE( ISoundService, g_pSoundService );
#define BENCHMARKSERVICE_INTERFACE_VERSION "BenchmarkService001"
DECLARE_TIER3_INTERFACE( IBenchmarkService, g_pBenchmarkService );
#define DEBUGSERVICE_INTERFACE_VERSION "VDebugService_001"
DECLARE_TIER3_INTERFACE( IDebugService, g_pDebugService );
#define KEYVALUECACHE_INTERFACE_VERSION "KeyValueCache001"
DECLARE_TIER3_INTERFACE( IKeyValueCache, g_pKeyValueCache );
#define GAMERESOURCESERVICECLIENT_INTERFACE_VERSION "GameResourceServiceClientV001"
DECLARE_TIER3_INTERFACE( IGameResourceServiceClient, g_pGameResourceServiceClient );
#define GAMERESOURCESERVICESERVER_INTERFACE_VERSION "GameResourceServiceServerV001"
DECLARE_TIER3_INTERFACE( IGameResourceServiceServer, g_pGameResourceServiceServer );
#define SOURCE2ENGINETOCLIENT_INTERFACE_VERSION "Source2EngineToClient001"
DECLARE_TIER3_INTERFACE( ISource2EngineToClient, g_pSource2EngineToClient );
#define SOURCE2ENGINETOSERVER_INTERFACE_VERSION "Source2EngineToServer001"
DECLARE_TIER3_INTERFACE( ISource2EngineToServer, g_pSource2EngineToServer );
#define SOURCE2ENGINETOSERVERSTRINGTABLE_INTERFACE_VERSION "Source2EngineToServerStringTable001"
DECLARE_TIER3_INTERFACE( ISource2EngineToServerStringTable, g_pSource2EngineToServerStringTable );
#define SOURCE2ENGINETOCLIENTSTRINGTABLE_INTERFACE_VERSION "Source2EngineToClientStringTable001"
DECLARE_TIER3_INTERFACE( ISource2EngineToClientStringTable, g_pSource2EngineToClientStringTable );
#define SOURCE2ENGINESOUNDSERVER_INTERFACE_VERSION "Source2EngineSoundServer001"
DECLARE_TIER3_INTERFACE( ISource2EngineSoundServer, g_pSource2EngineSoundServer );
#define SOURCE2ENGINESOUNDCLIENT_INTERFACE_VERSION "Source2EngineSoundClient001"
DECLARE_TIER3_INTERFACE( ISource2EngineSoundClient, g_pSource2EngineSoundClient );
#define SCALEFORMUI_INTERFACE_VERSION "ScaleformUI001"
DECLARE_TIER3_INTERFACE( IScaleformUI, g_pScaleformUI );
#define SERVERUPLOADGAMESTATS_INTERFACE_VERSION "ServerUploadGameStats001"
DECLARE_TIER3_INTERFACE( IServerUploadGameStats, g_pServerUploadGameStats );
#define SCENESYSTEM_INTERFACE_VERSION "SceneSystem_002"
DECLARE_TIER3_INTERFACE( ISceneSystem, g_pSceneSystem );
#define VGUI_SURFACE_INTERFACE_VERSION "VGUI_Surface031"
#define SCENEUTILS_INTERFACE_VERSION "SceneUtils_001"
DECLARE_TIER3_INTERFACE( ISceneUtils, g_pSceneUtils );
#define VGUI_SURFACE_INTERFACE_VERSION "VGUI_Surface032"
DECLARE_TIER3_INTERFACE( vgui::ISurface, g_pVGuiSurface );
#define SCHEME_SURFACE_INTERFACE_VERSION "SchemeSurface001"
@ -236,7 +533,7 @@ DECLARE_TIER3_INTERFACE( vgui::IInput, g_pVGuiInput );
#define VGUI_IVGUI_INTERFACE_VERSION "VGUI_ivgui008"
DECLARE_TIER3_INTERFACE( vgui::IVGui, g_pVGui );
#define VGUI_PANEL_INTERFACE_VERSION "VGUI_Panel009"
#define VGUI_PANEL_INTERFACE_VERSION "VGUI_Panel010"
DECLARE_TIER3_INTERFACE( vgui::IPanel, g_pVGuiPanel );
#define VGUI_SCHEME_INTERFACE_VERSION "VGUI_Scheme010"
@ -248,28 +545,30 @@ DECLARE_TIER3_INTERFACE( vgui::ISystem, g_pVGuiSystem );
#define DATACACHE_INTERFACE_VERSION "VDataCache003"
DECLARE_TIER3_INTERFACE( IDataCache, g_pDataCache ); // FIXME: Should IDataCache be in tier2?
#define MDLCACHE_INTERFACE_VERSION "MDLCache004"
DECLARE_TIER3_INTERFACE( IMDLCache, g_pMDLCache );
DECLARE_TIER3_INTERFACE( IMDLCache, mdlcache );
#define AVI_INTERFACE_VERSION "VAvi001"
DECLARE_TIER3_INTERFACE( IAvi, g_pAVI );
#define BIK_INTERFACE_VERSION "VBik001"
DECLARE_TIER3_INTERFACE( IBik, g_pBIK );
#define QUICKTIME_INTERFACE_VERSION "IQuickTime001"
DECLARE_TIER3_INTERFACE( IQuickTime, g_pQuickTime );
#define DMEMAKEFILE_UTILS_INTERFACE_VERSION "VDmeMakeFileUtils001"
DECLARE_TIER3_INTERFACE( IDmeMakefileUtils, g_pDmeMakefileUtils );
#define VPHYSICS_COLLISION_INTERFACE_VERSION "VPhysicsCollision007"
DECLARE_TIER3_INTERFACE( IPhysicsCollision, g_pPhysicsCollision );
#define SOUNDEMITTERSYSTEM_INTERFACE_VERSION "VSoundEmitter003"
DECLARE_TIER3_INTERFACE( ISoundEmitterSystemBase, g_pSoundEmitterSystem );
#define SOUNDEMITTERSYSTEMS1_INTERFACE_VERSION "VSoundEmitterS1_001"
DECLARE_TIER3_INTERFACE( ISoundEmitterSystemBaseS1, g_pSoundEmitterSystemS1 );
#define WORLD_RENDERER_MGR_INTERFACE_VERSION "WorldRendererMgr001"
DECLARE_TIER3_INTERFACE( IWorldRendererMgr, g_pWorldRendererMgr );
#define VR_INTERFACE_VERSION "VR_001"
DECLARE_TIER3_INTERFACE(IVR, vr);
//-----------------------------------------------------------------------------
// Fills out global DLL exported interface pointers
//-----------------------------------------------------------------------------

View File

@ -113,6 +113,37 @@ FORCEINLINE float fpmax( float a, float b )
#ifdef __cplusplus
// This is the preferred clamp operator. Using the clamp macro can lead to
// unexpected side-effects or more expensive code. Even the clamp (all
// lower-case) function can generate more expensive code because of the
// mixed types involved.
template< class T >
T Clamp( T const &val, T const &minVal, T const &maxVal )
{
if( val < minVal )
return minVal;
else if( val > maxVal )
return maxVal;
else
return val;
}
// This is the preferred Min operator. Using the MIN macro can lead to unexpected
// side-effects or more expensive code.
template< class T >
T Min( T const &val1, T const &val2 )
{
return val1 < val2 ? val1 : val2;
}
// This is the preferred Max operator. Using the MAX macro can lead to unexpected
// side-effects or more expensive code.
template< class T >
T Max( T const &val1, T const &val2 )
{
return val1 > val2 ? val1 : val2;
}
template< class T, class Y >
inline T clamp( T const &val, Y const &minVal, Y const &maxVal )
{

View File

@ -82,8 +82,6 @@ class Color;
// DebuggerBreak();
//-----------------------------------------------------------------------------
PLATFORM_INTERFACE void _ExitOnFatalAssert( const tchar* pFile, int line );
PLATFORM_INTERFACE bool SetupWin32ConsoleIO();
// Returns true if they want to break in the debugger.
@ -96,11 +94,6 @@ PLATFORM_INTERFACE bool SetupWin32ConsoleIO();
{ \
LoggingResponse_t ret = Log_Assert( "%s (%d) : %s\n", __TFILE__, __LINE__, _msg ); \
_executeExp; \
if ( ret == LR_DEBUGGER ) \
{ \
if ( _bFatal ) \
_ExitOnFatalAssert( __TFILE__, __LINE__ ); \
} \
} \
} while (0)

View File

@ -91,16 +91,14 @@ void ConVar_PublishToVXConsole();
//-----------------------------------------------------------------------------
// Called when a ConCommand needs to execute
//-----------------------------------------------------------------------------
typedef void ( *FnCommandCallbackV1_t )( void );
typedef void ( *FnCommandCallback_t )( const CCommandContext &context, const CCommand &command );
#define COMMAND_COMPLETION_MAXITEMS 64
#define COMMAND_COMPLETION_ITEM_LENGTH 64
typedef void ( *FnCommandCallbackV1_t )( const CCommandContext &context );
typedef void ( *FnCommandCallbackV2_t )( const CCommandContext &context, const CCommand &command );
typedef void ( *FnCommandCallback_t )( const CCommand &command );
//-----------------------------------------------------------------------------
// Returns 0 to COMMAND_COMPLETION_MAXITEMS worth of completion strings
//-----------------------------------------------------------------------------
typedef int ( *FnCommandCompletionCallback )( const char *partial, char commands[ COMMAND_COMPLETION_MAXITEMS ][ COMMAND_COMPLETION_ITEM_LENGTH ] );
typedef int(*FnCommandCompletionCallback)( const char *partial, CUtlVector< CUtlString > &commands );
//-----------------------------------------------------------------------------
@ -109,13 +107,7 @@ typedef int ( *FnCommandCompletionCallback )( const char *partial, char command
class ICommandCallback
{
public:
virtual void CommandCallback( const CCommand &command ) = 0;
};
class ICommandCallback2
{
public:
virtual void CommandCallback( const CCommandContext &context, const CCommand &command ) = 0;
virtual void CommandCallback(const CCommandContext &context, const CCommand &command) = 0;
};
class ICommandCompletionCallback
@ -183,6 +175,8 @@ protected:
char *CopyString( const char *from );
private:
int m_Unknown;
// Next ConVar in chain
// Prior to register, it points to the next convar in the DLL.
// Once registered, though, m_pNext is reset to point to the next
@ -198,6 +192,7 @@ private:
// ConVar flags
int m_nFlags;
int m_nFlags2;
protected:
// ConVars add themselves to this list for the executable.
@ -300,14 +295,10 @@ friend class CCvar;
public:
typedef ConCommandBase BaseClass;
ConCommand( const char *pName, FnCommandCallbackV1_t callback,
const char *pHelpString = 0, int flags = 0, FnCommandCompletionCallback completionFunc = 0 );
ConCommand( const char *pName, FnCommandCallback_t callback,
const char *pHelpString = 0, int flags = 0, FnCommandCompletionCallback completionFunc = 0 );
ConCommand( const char *pName, ICommandCallback *pCallback,
const char *pHelpString = 0, int flags = 0, ICommandCompletionCallback *pCommandCompletionCallback = 0 );
ConCommand( const char *pName, ICommandCallback2 *pCallback,
const char *pHelpString = 0, int flags = 0, ICommandCompletionCallback *pCommandCompletionCallback = 0 );
virtual ~ConCommand( void );
@ -329,25 +320,34 @@ private:
// Those fields will not exist in the version of this class that is instanced
// in mod code.
// Call this function when executing the command
union
{
FnCommandCallbackV1_t m_fnCommandCallbackV1;
FnCommandCallback_t m_fnCommandCallback;
ICommandCallback *m_pCommandCallback;
ICommandCallback2 *m_pCommandCallback2;
};
union
{
FnCommandCallbackV2_t m_fnCommandCallbackV2;
FnCommandCompletionCallback m_fnCompletionCallback;
ICommandCompletionCallback *m_pCommandCompletionCallback;
};
bool m_bHasCompletionCallback : 1;
bool m_bUsingCommandCompletionInterface : 1;
struct ConCommandCB
{
// Call this function when executing the command
union
{
FnCommandCallback_t m_fnCommandCallback;
FnCommandCallbackV2_t m_fnCommandCallbackV2;
ICommandCallback *m_pCommandCallback;
};
bool m_bUsingCommandCallbackInterface : 1;
bool m_bUsingOldCommandCallback : 1;
bool m_bUsingCommandCallbackInterface2 : 1;
bool m_bUsingV2CommandCallback : 1;
};
CUtlVector<ConCommandCB> m_Callbacks;
ConCommand *m_pParent;
};
@ -957,9 +957,9 @@ private:
// Purpose: Utility macros to quicky generate a simple console command
//-----------------------------------------------------------------------------
#define CON_COMMAND( name, description ) \
static void name( const CCommandContext &context, const CCommand &args ); \
static void name( const CCommand &args ); \
static ConCommand name##_command( #name, name, description ); \
static void name( const CCommandContext &context, const CCommand &args )
static void name( const CCommand &args )
#ifdef CLIENT_DLL
#define CON_COMMAND_SHARED( name, description ) \

View File

@ -80,7 +80,7 @@ class CCommand;
#define FCVAR_ACCESSIBLE_FROM_THREADS (1<<25) // used as a debugging tool necessary to check material system thread convars
#define FCVAR_VCONSOLE_SET_FOCUS (1<<31)
// #define FCVAR_AVAILABLE (1<<26)
#define FCVAR_LINKED_CONCOMMAND (1<<26)
// #define FCVAR_AVAILABLE (1<<27)
#define FCVAR_MATERIAL_THREAD_MASK ( FCVAR_RELOAD_MATERIALS | FCVAR_RELOAD_TEXTURES | FCVAR_MATERIAL_SYSTEM_THREAD )
@ -115,6 +115,8 @@ public:
virtual bool IsFlagSet( int nFlag ) const = 0;
virtual int GetSplitScreenPlayerSlot() const = 0;
virtual void AddFlags( int flags ) = 0;
};

View File

@ -227,6 +227,8 @@ typedef char * va_list;
#define INCORRECT_PATH_SEPARATOR_S "\\"
#endif
int V_vsnprintf( char *pDest, int maxLenInCharacters, const char *pFormat, va_list params );
template <size_t maxLenInCharacters> int V_vsprintf_safe( char (&pDest)[maxLenInCharacters], const char *pFormat, va_list params ) { return V_vsnprintf( pDest, maxLenInCharacters, pFormat, params ); }
int V_vsnprintf( char *pDest, int maxLen, const char *pFormat, va_list params );
// Prints out a pretified memory counter string value ( e.g., 7,233.27 Mb, 1,298.003 Kb, 127 bytes )

View File

@ -0,0 +1,107 @@
//====== Copyright <20> 1996-2004, Valve Corporation, All rights reserved. =======
//
// Purpose:
//
//=============================================================================
#ifndef UTLBINARYBLOCK_H
#define UTLBINARYBLOCK_H
#ifdef _WIN32
#pragma once
#endif
#include "tier1/utlmemory.h"
#include "tier1/strtools.h"
#include "limits.h"
//-----------------------------------------------------------------------------
// Base class, containing simple memory management
//-----------------------------------------------------------------------------
class CUtlBinaryBlock
{
public:
CUtlBinaryBlock( int growSize = 0, int initSize = 0 );
// NOTE: nInitialLength indicates how much of the buffer starts full
CUtlBinaryBlock( void* pMemory, int nSizeInBytes, int nInitialLength );
CUtlBinaryBlock( const void* pMemory, int nSizeInBytes );
CUtlBinaryBlock( const CUtlBinaryBlock& src );
void Get( void *pValue, int nMaxLen ) const;
void Set( const void *pValue, int nLen );
const void *Get( ) const;
void *Get( );
unsigned char& operator[]( int i );
const unsigned char& operator[]( int i ) const;
int Length() const;
void SetLength( int nLength ); // Undefined memory will result
bool IsEmpty() const;
void Clear();
void Purge();
bool IsReadOnly() const;
CUtlBinaryBlock &operator=( const CUtlBinaryBlock &src );
// Test for equality
bool operator==( const CUtlBinaryBlock &src ) const;
private:
CUtlMemory<unsigned char> m_Memory;
int m_nActualLength;
};
//-----------------------------------------------------------------------------
// class inlines
//-----------------------------------------------------------------------------
inline const void *CUtlBinaryBlock::Get( ) const
{
return m_Memory.Base();
}
inline void *CUtlBinaryBlock::Get( )
{
return m_Memory.Base();
}
inline int CUtlBinaryBlock::Length() const
{
return m_nActualLength;
}
inline unsigned char& CUtlBinaryBlock::operator[]( int i )
{
return m_Memory[i];
}
inline const unsigned char& CUtlBinaryBlock::operator[]( int i ) const
{
return m_Memory[i];
}
inline bool CUtlBinaryBlock::IsReadOnly() const
{
return m_Memory.IsReadOnly();
}
inline bool CUtlBinaryBlock::IsEmpty() const
{
return Length() == 0;
}
inline void CUtlBinaryBlock::Clear()
{
SetLength( 0 );
}
inline void CUtlBinaryBlock::Purge()
{
SetLength( 0 );
m_Memory.Purge();
}
#endif // UTLBINARYBLOCK_H

View File

@ -0,0 +1,97 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: A header describing use of the delegate system. It's hiding
// the highly complex implementation details of the delegate system
//
// $NoKeywords: $
//
//===========================================================================//
#ifndef UTLDELEGATE_H
#define UTLDELEGATE_H
#ifdef _WIN32
#pragma once
#endif
//-----------------------------------------------------------------------------
// The delegate system: A method of invoking methods, whether they are
// member methods of classes, static methods of classes, or free functions,
// dealing with all the nastiness in differences between how the calls have
// to happen yet works in a highly optimal fashion. For details, see
//
// http://www.codeproject.com/cpp/FastDelegate.asp
//
// The delegate design pattern is described here
//
// http://en.wikipedia.org/wiki/Delegation_(programming)
//-----------------------------------------------------------------------------
#ifdef UTLDELEGATE_USAGE_DEMONSTRATION
//-----------------------------------------------------------------------------
// Here, we show how to use this system (the ifdef UTLDELEGATE_USAGE_DEMONSTRATION is used to get syntax coloring).
//-----------------------------------------------------------------------------
// First, define the functions you wish to call.
int Test1( char *pString, float x );
class CTestClass
{
public:
void Test2();
static float Test3( int x );
};
void Test()
{
CTestClass testClass;
// CUtlDelegate is a class that can be used to invoke methods of classes
// or static functions in a highly efficient manner.
// There are a couple ways to hook up a delegate. One is in a constructor
// Note that the template parameter of CUtlFastDelegate looks like the
// function type: first, you have the return type, then ( parameter list )
CUtlDelegate< int ( char *, float ) > delegate1( &Test1 );
// Another way is to use the UtlMakeDelegate method, allowing you to
// define the delegate later. Note that UtlMakeDelegate does *not* do a heap allocation
CUtlDelegate< void () > delegate2;
delegate2 = UtlMakeDelegate( &testClass, &CTestClass::Test2 );
// A third method is to use the Bind() method of CUtlFastDelegate
// Note that you do not pass in the class pointer for static functions
CUtlDelegate< float ( int ) > delegate3;
delegate3.Bind( &CTestClass::Test3 );
// Use the () operator to invoke the function calls.
int x = delegate1( "hello", 1.0f );
delegate2();
float y = delegate3( 5 );
// Use the Clear() method to unbind a delegate.
delegate1.Clear();
// You can use operator! or IsEmpty() to see if a delegate is bound
if ( !delegate1.IsEmpty() )
{
delegate1( "hello2" );
}
// Delegates maintain an internal non-templatized representation of the
// functions they are bound to called CUtlAbstractDelegate. These are
// useful when keeping a list of untyped delegates or when passing
// delegates across interface boundaries.
const CUtlAbstractDelegate &abstractDelegate3 = delegate3.GetAbstractDelegate();
CUtlDelegate< float ( int ) > delegate4;
delegate4.SetAbstractDelegate( abstractDelegate3 );
delegate4( 10 );
}
#endif // UTLDELEGATE_USAGE_DEMONSTRATION
// Looking in this file may cause blindness.
#include "tier1/utldelegateimpl.h"
#endif // UTLDELEGATE_H

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
//====== Copyright <20> 1996-2004, Valve Corporation, All rights reserved. =======
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
@ -15,96 +15,30 @@
#include "tier1/strtools.h"
#include "limits.h"
//-----------------------------------------------------------------------------
// Base class, containing simple memory management
//-----------------------------------------------------------------------------
class CUtlBinaryBlock
#if defined( OSX )
inline wchar_t *wcsdup(const wchar_t *pString)
{
public:
CUtlBinaryBlock( int growSize = 0, int initSize = 0 );
wchar_t *pMemory;
// NOTE: nInitialLength indicates how much of the buffer starts full
CUtlBinaryBlock( void* pMemory, int nSizeInBytes, int nInitialLength );
CUtlBinaryBlock( const void* pMemory, int nSizeInBytes );
CUtlBinaryBlock( const CUtlBinaryBlock& src );
if (!pString)
return NULL;
void Get( void *pValue, int nMaxLen ) const;
void Set( const void *pValue, int nLen );
const void *Get( ) const;
void *Get( );
size_t len = (wcslen(pString) + 1);
if ((pMemory = (wchar_t *)malloc(len * sizeof(wchar_t))) != NULL)
{
return wcscpy( pMemory, pString );
}
unsigned char& operator[]( int i );
const unsigned char& operator[]( int i ) const;
int Length() const;
void SetLength( int nLength ); // Undefined memory will result
bool IsEmpty() const;
void Clear();
void Purge();
bool IsReadOnly() const;
CUtlBinaryBlock &operator=( const CUtlBinaryBlock &src );
// Test for equality
bool operator==( const CUtlBinaryBlock &src ) const;
private:
CUtlMemory<unsigned char> m_Memory;
int m_nActualLength;
};
//-----------------------------------------------------------------------------
// class inlines
//-----------------------------------------------------------------------------
inline const void *CUtlBinaryBlock::Get( ) const
{
return m_Memory.Base();
return NULL;
}
inline void *CUtlBinaryBlock::Get( )
inline size_t strnlen(const char *s, size_t n)
{
return m_Memory.Base();
}
inline int CUtlBinaryBlock::Length() const
{
return m_nActualLength;
}
inline unsigned char& CUtlBinaryBlock::operator[]( int i )
{
return m_Memory[i];
}
inline const unsigned char& CUtlBinaryBlock::operator[]( int i ) const
{
return m_Memory[i];
}
inline bool CUtlBinaryBlock::IsReadOnly() const
{
return m_Memory.IsReadOnly();
}
inline bool CUtlBinaryBlock::IsEmpty() const
{
return Length() == 0;
}
inline void CUtlBinaryBlock::Clear()
{
SetLength( 0 );
}
inline void CUtlBinaryBlock::Purge()
{
SetLength( 0 );
m_Memory.Purge();
const char *p = (const char *)memchr(s, 0, n);
return (p ? p - s : n);
}
#endif
//-----------------------------------------------------------------------------
// Simple string class.
@ -112,49 +46,100 @@ inline void CUtlBinaryBlock::Purge()
//-----------------------------------------------------------------------------
class CUtlString
{
public:
typedef enum
{
PATTERN_NONE = 0x00000000,
PATTERN_DIRECTORY = 0x00000001
} TUtlStringPattern;
public:
CUtlString();
CUtlString( const char *pString );
CUtlString( const char *pString, int length );
CUtlString( const CUtlString& string );
// Attaches the string to external memory. Useful for avoiding a copy
CUtlString( void* pMemory, int nSizeInBytes, int nInitialLength );
CUtlString( const void* pMemory, int nSizeInBytes );
#ifdef MOVE_CONSTRUCTOR_SUPPORT
// Support moving of CUtlString objects. Long live C++11
// This move constructor will get called when appropriate, such as when
// returning objects from functions, or otherwise copying from temporaries
// which are about to be destroyed. It can also be explicitly invoked with
// std::move().
// Move constructor:
CUtlString( CUtlString&& rhs )
{
// Move the string pointer from the source to this -- be sure to
// zero out the source to avoid double frees.
m_pString = rhs.m_pString;
rhs.m_pString = 0;
}
// Move assignment operator:
CUtlString& operator=( CUtlString&& rhs )
{
// Move the string pointer from the source to this -- be sure to
// zero out the source to avoid double frees.
m_pString = rhs.m_pString;
rhs.m_pString = 0;
return *this;
}
#endif
~CUtlString();
const char *Get( ) const;
void Set( const char *pValue );
operator const char*() const;
// Set directly and don't look for a null terminator in pValue.
// nChars does not include the nul and this will only copy
// at most nChars (even if pValue is longer). If nChars
// is >strlen(pValue) it will copy past the end, don't do it
// Does nothing if pValue == String()
void SetDirect( const char *pValue, int nChars );
// Converts to c-strings
operator const char*() const;
// for compatibility switching items from UtlSymbol
const char *String() const { return Get(); }
// Returns strlen
int Length() const;
// IsEmpty() is more efficient than Length() == 0
bool IsEmpty() const;
// Sets the length (used to serialize into the buffer )
// Note: If nLen != 0, then this adds an extra byte for a null-terminator.
void SetLength( int nLen );
char *Get();
char *GetForModify();
void Clear();
void Purge();
// Case Change
void ToLower();
void ToUpper();
void Append( const char *pAddition, int nChars );
void Append( const char *pchAddition );
void Append( const char chAddition ) { char temp[2] = { chAddition, 0 }; Append( temp ); }
// Strips the trailing slash
void StripTrailingSlash();
void FixSlashes( char cSeparator = CORRECT_PATH_SEPARATOR );
// Trim whitespace
void TrimLeft( char cTarget );
void TrimLeft( const char *szTargets = "\t\r\n " );
void TrimRight( char cTarget );
void TrimRight( const char *szTargets = "\t\r\n " );
void Trim( char cTarget );
void Trim( const char *szTargets = "\t\r\n " );
bool IsEqual_CaseSensitive( const char *src ) const;
bool IsEqual_CaseInsensitive( const char *src ) const;
CUtlString &operator=( const CUtlString &src );
CUtlString &operator=( const char *src );
// Test for equality
bool operator==( const CUtlString &src ) const;
bool operator==( const char *src ) const;
bool operator!=( const CUtlString &src ) const { return !operator==( src ); }
bool operator!=( const char *src ) const { return !operator==( src ); }
CUtlString &operator+=( const CUtlString &rhs );
CUtlString &operator+=( const char *rhs );
@ -162,31 +147,56 @@ public:
CUtlString &operator+=( int rhs );
CUtlString &operator+=( double rhs );
CUtlString operator+( const char *pOther );
CUtlString operator+( int rhs );
CUtlString operator+( const char *pOther ) const;
CUtlString operator+( const CUtlString &other ) const;
CUtlString operator+( int rhs ) const;
int Format( const char *pFormat, ... );
bool MatchesPattern( const CUtlString &Pattern, int nFlags = 0 ) const; // case SENSITIVE, use * for wildcard in pattern string
// Take a piece out of the string.
char operator[]( int i ) const;
int Format( const char *pFormat, ... ) FMTFUNCTION( 2, 3 );
int FormatV( const char *pFormat, va_list marker );
// Defining AltArgumentType_t hints that associative container classes should
// also implement Find/Insert/Remove functions that take const char* params.
typedef const char *AltArgumentType_t;
// Get a copy of part of the string.
// If you only specify nStart, it'll go from nStart to the end.
// You can use negative numbers and it'll wrap around to the start.
CUtlString Slice( int32 nStart=0, int32 nEnd=INT_MAX );
CUtlString Slice( int32 nStart=0, int32 nEnd=INT_MAX ) const;
// Grab a substring starting from the left or the right side.
CUtlString Left( int32 nChars );
CUtlString Right( int32 nChars );
// Get a substring starting from the left or the right side.
CUtlString Left( int32 nChars ) const;
CUtlString Right( int32 nChars ) const;
// Replace all instances of one character with another.
CUtlString Replace( char cFrom, char cTo );
// Get a string with all instances of one character replaced with another.
CUtlString Replace( char cFrom, char cTo ) const;
// Calls right through to V_MakeAbsolutePath.
CUtlString AbsPath( const char *pStartingDir=NULL );
// Replace all instances of specified string with another.
CUtlString Replace( const char *pszFrom, const char *pszTo ) const;
// Get this string as an absolute path (calls right through to V_MakeAbsolutePath).
CUtlString AbsPath( const char *pStartingDir=NULL ) const;
// Gets the filename (everything except the path.. c:\a\b\c\somefile.txt -> somefile.txt).
CUtlString UnqualifiedFilename();
CUtlString UnqualifiedFilename() const;
// Strips off one directory. Uses V_StripLastDir but strips the last slash also!
CUtlString DirName();
// Gets a string with one directory removed. Uses V_StripLastDir but strips the last slash also!
CUtlString DirName() const;
// Get a string with the extension removed (with V_StripExtension).
CUtlString StripExtension() const;
// Get a string with the filename removed (uses V_UnqualifiedFileName and also strips the last slash)
CUtlString StripFilename() const;
// Get a string with the base filename (with V_FileBase).
CUtlString GetBaseFilename() const;
// Get a string with the file extension (with V_FileBase).
CUtlString GetExtension() const;
// Works like V_ComposeFileName.
static CUtlString PathJoin( const char *pStr1, const char *pStr2 );
@ -195,17 +205,93 @@ public:
static int __cdecl SortCaseInsensitive( const CUtlString *pString1, const CUtlString *pString2 );
static int __cdecl SortCaseSensitive( const CUtlString *pString1, const CUtlString *pString2 );
// Empty string for those times when you need to return an empty string and
// either don't want to pay the construction cost, or are returning a
// const CUtlString& and cannot just return "".
static const CUtlString &GetEmptyString();
private:
CUtlBinaryBlock m_Storage;
// INTERNALS
// AllocMemory allocates enough space for length characters plus a terminating zero.
// Previous characters are preserved, the buffer is null-terminated, but new characters
// are not touched.
void *AllocMemory( uint32 length );
// If m_pString is not NULL, it points to the start of the string, and the memory allocation.
char *m_pString;
};
// // If these are not defined, CUtlConstString as rhs will auto-convert
// // to const char* and do logical operations on the raw pointers. Ugh.
// inline friend bool operator<( const T *lhs, const CUtlConstStringBase &rhs ) { return rhs.Compare( lhs ) > 0; }
// inline friend bool operator==( const T *lhs, const CUtlConstStringBase &rhs ) { return rhs.Compare( lhs ) == 0; }
// inline friend bool operator!=( const T *lhs, const CUtlConstStringBase &rhs ) { return rhs.Compare( lhs ) != 0; }
inline bool operator==( const char *pString, const CUtlString &utlString )
{
return utlString.IsEqual_CaseSensitive( pString );
}
inline bool operator!=( const char *pString, const CUtlString &utlString )
{
return !utlString.IsEqual_CaseSensitive( pString );
}
inline bool operator==( const CUtlString &utlString, const char *pString )
{
return utlString.IsEqual_CaseSensitive( pString );
}
inline bool operator!=( const CUtlString &utlString, const char *pString )
{
return !utlString.IsEqual_CaseSensitive( pString );
}
//-----------------------------------------------------------------------------
// Inline methods
//-----------------------------------------------------------------------------
inline CUtlString::CUtlString()
: m_pString( NULL )
{
}
inline CUtlString::CUtlString( const char *pString )
: m_pString( NULL )
{
Set( pString );
}
inline CUtlString::CUtlString( const char *pString, int length )
: m_pString( NULL )
{
SetDirect( pString, length );
}
inline CUtlString::CUtlString( const CUtlString& string )
: m_pString( NULL )
{
Set( string.Get() );
}
inline CUtlString::~CUtlString()
{
Purge();
}
inline int CUtlString::Length() const
{
if (m_pString)
{
return V_strlen( m_pString );
}
return 0;
}
inline bool CUtlString::IsEmpty() const
{
return Length() == 0;
return !m_pString || m_pString[0] == 0;
}
inline int __cdecl CUtlString::SortCaseInsensitive( const CUtlString *pString1, const CUtlString *pString2 )
@ -218,5 +304,151 @@ inline int __cdecl CUtlString::SortCaseSensitive( const CUtlString *pString1, co
return V_strcmp( pString1->String(), pString2->String() );
}
// Converts to c-strings
inline CUtlString::operator const char*() const
{
return Get();
}
//-----------------------------------------------------------------------------
// Purpose: Implementation of low-level string functionality for character types.
//-----------------------------------------------------------------------------
template < typename T >
class StringFuncs
{
public:
static T *Duplicate( const T *pValue );
// Note that this function takes a character count, and does not guarantee null-termination.
static void Copy( T *out_pOut, const T *pIn, int iLengthInChars );
static int Compare( const T *pLhs, const T *pRhs );
static int CaselessCompare( const T *pLhs, const T *pRhs );
static int Length( const T *pValue );
static const T *FindChar( const T *pStr, const T cSearch );
static const T *EmptyString();
static const T *NullDebugString();
};
template < >
class StringFuncs<char>
{
public:
static char *Duplicate( const char *pValue ) { return strdup( pValue ); }
// Note that this function takes a character count, and does not guarantee null-termination.
static void Copy( char *out_pOut, const char *pIn, int iLengthInChars ) { strncpy( out_pOut, pIn, iLengthInChars ); }
static int Compare( const char *pLhs, const char *pRhs ) { return strcmp( pLhs, pRhs ); }
static int CaselessCompare( const char *pLhs, const char *pRhs ) { return Q_strcasecmp( pLhs, pRhs ); }
static int Length( const char *pValue ) { return (int)strlen( pValue ); }
static const char *FindChar( const char *pStr, const char cSearch ) { return strchr( pStr, cSearch ); }
static const char *EmptyString() { return ""; }
static const char *NullDebugString() { return "(null)"; }
};
template < >
class StringFuncs<wchar_t>
{
public:
static wchar_t *Duplicate( const wchar_t *pValue ) { return wcsdup( pValue ); }
// Note that this function takes a character count, and does not guarantee null-termination.
static void Copy( wchar_t *out_pOut, const wchar_t *pIn, int iLengthInChars ) { wcsncpy( out_pOut, pIn, iLengthInChars ); }
static int Compare( const wchar_t *pLhs, const wchar_t *pRhs ) { return wcscmp( pLhs, pRhs ); }
static int CaselessCompare( const wchar_t *pLhs, const wchar_t *pRhs ); // no implementation?
static int Length( const wchar_t *pValue ) { return (int)wcslen( pValue ); }
static const wchar_t *FindChar( const wchar_t *pStr, const wchar_t cSearch ) { return wcschr( pStr, cSearch ); }
static const wchar_t *EmptyString() { return L""; }
static const wchar_t *NullDebugString() { return L"(null)"; }
};
//-----------------------------------------------------------------------------
// Dirt-basic auto-release string class. Not intended for manipulation,
// can be stored in a container or forwarded as a functor parameter.
// Note the benefit over CUtlString: sizeof(CUtlConstString) == sizeof(char*).
// Also note: null char* pointers are treated identically to empty strings.
//-----------------------------------------------------------------------------
template < typename T = char >
class CUtlConstStringBase
{
public:
CUtlConstStringBase() : m_pString( NULL ) {}
explicit CUtlConstStringBase( const T *pString ) : m_pString( NULL ) { Set( pString ); }
CUtlConstStringBase( const CUtlConstStringBase& src ) : m_pString( NULL ) { Set( src.m_pString ); }
~CUtlConstStringBase() { Set( NULL ); }
void Set( const T *pValue );
void Clear() { Set( NULL ); }
const T *Get() const { return m_pString ? m_pString : StringFuncs<T>::EmptyString(); }
operator const T*() const { return m_pString ? m_pString : StringFuncs<T>::EmptyString(); }
bool IsEmpty() const { return m_pString == NULL; } // Note: empty strings are never stored by Set
int Compare( const T *rhs ) const;
// Logical ops
bool operator<( const T *rhs ) const { return Compare( rhs ) < 0; }
bool operator==( const T *rhs ) const { return Compare( rhs ) == 0; }
bool operator!=( const T *rhs ) const { return Compare( rhs ) != 0; }
bool operator<( const CUtlConstStringBase &rhs ) const { return Compare( rhs.m_pString ) < 0; }
bool operator==( const CUtlConstStringBase &rhs ) const { return Compare( rhs.m_pString ) == 0; }
bool operator!=( const CUtlConstStringBase &rhs ) const { return Compare( rhs.m_pString ) != 0; }
// If these are not defined, CUtlConstString as rhs will auto-convert
// to const char* and do logical operations on the raw pointers. Ugh.
inline friend bool operator<( const T *lhs, const CUtlConstStringBase &rhs ) { return rhs.Compare( lhs ) > 0; }
inline friend bool operator==( const T *lhs, const CUtlConstStringBase &rhs ) { return rhs.Compare( lhs ) == 0; }
inline friend bool operator!=( const T *lhs, const CUtlConstStringBase &rhs ) { return rhs.Compare( lhs ) != 0; }
CUtlConstStringBase &operator=( const T *src ) { Set( src ); return *this; }
CUtlConstStringBase &operator=( const CUtlConstStringBase &src ) { Set( src.m_pString ); return *this; }
// Defining AltArgumentType_t is a hint to containers that they should
// implement Find/Insert/Remove functions that take const char* params.
typedef const T *AltArgumentType_t;
protected:
const T *m_pString;
};
template < typename T >
void CUtlConstStringBase<T>::Set( const T *pValue )
{
if ( pValue != m_pString )
{
free( ( void* ) m_pString );
m_pString = pValue && pValue[0] ? StringFuncs<T>::Duplicate( pValue ) : NULL;
}
}
template < typename T >
int CUtlConstStringBase<T>::Compare( const T *rhs ) const
{
// Empty or null RHS?
if ( !rhs || !rhs[0] )
return m_pString ? 1 : 0;
// Empty *this, non-empty RHS?
if ( !m_pString )
return -1;
// Neither empty
return StringFuncs<T>::Compare( m_pString, rhs );
}
typedef CUtlConstStringBase<char> CUtlConstString;
typedef CUtlConstStringBase<wchar_t> CUtlConstWideString;
//-----------------------------------------------------------------------------
// Helper functor objects.
//-----------------------------------------------------------------------------
template < typename T > struct UTLConstStringCaselessStringLessFunctor { bool operator()( const CUtlConstStringBase<T>& a, const char *b ) const { return StringFuncs<T>::CaselessCompare( a.Get(), b ) < 0; } };
template < typename T > struct UTLConstStringCaselessStringEqualFunctor { bool operator()( const CUtlConstStringBase<T>& a, const char *b ) const { return StringFuncs<T>::CaselessCompare( a.Get(), b ) == 0; } };
// Helper function for CUtlMaps with a CUtlString key
inline bool UtlStringLessFunc( const CUtlString &lhs, const CUtlString &rhs ) { return V_strcmp( lhs.Get(), rhs.Get() ) < 0; }
inline bool UtlStringCaseInsensitiveLessFunc( const CUtlString &lhs, const CUtlString &rhs ) { return V_stricmp( lhs.Get(), rhs.Get() ) < 0; }
#endif // UTLSTRING_H

View File

@ -160,21 +160,9 @@ protected:
void ShiftElementsRight( int elem, int num = 1 );
void ShiftElementsLeft( int elem, int num = 1 );
CAllocator m_Memory;
int m_Size;
CAllocator m_Memory;
#ifndef _X360
// For easier access to the elements through the debugger
// it's in release builds so this can be used in libraries correctly
T *m_pElements;
inline void ResetDbgInfo()
{
m_pElements = Base();
}
#else
inline void ResetDbgInfo() {}
#endif
};
@ -531,14 +519,12 @@ template< typename T, class A >
inline CUtlVector<T, A>::CUtlVector( int growSize, int initSize ) :
m_Memory(growSize, initSize), m_Size(0)
{
ResetDbgInfo();
}
template< typename T, class A >
inline CUtlVector<T, A>::CUtlVector( T* pMemory, int allocationCount, int numElements ) :
m_Memory(pMemory, allocationCount), m_Size(numElements)
{
ResetDbgInfo();
}
template< typename T, class A >
@ -663,7 +649,6 @@ void CUtlVector<T, A>::GrowVector( int num )
}
m_Size += num;
ResetDbgInfo();
}
@ -710,7 +695,6 @@ void CUtlVector<T, A>::EnsureCapacity( int num )
{
MEM_ALLOC_CREDIT_CLASS();
m_Memory.EnsureCapacity(num);
ResetDbgInfo();
}
@ -1116,7 +1100,6 @@ inline void CUtlVector<T, A>::Purge()
{
RemoveAll();
m_Memory.Purge();
ResetDbgInfo();
}

View File

@ -123,12 +123,6 @@ struct CCommandContext;
//
//-----------------------------------------------------------------------------
#define VSCRIPT_INTERFACE_VERSION "VScriptManager010"
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
class IScriptVM;
enum ScriptLanguage_t

View File

@ -0,0 +1,16 @@
#include <appframework/IAppSystem.h>
#include <tier1/functors.h>
class IEventQueue;
abstract_class IEventSystem : public IAppSystem
{
public:
virtual IEventQueue *CreateEventQueue() = 0;
virtual void DestroyEventQueue( IEventQueue *pQueue ) = 0;
virtual void RunEvents( IEventQueue *pQueue ) = 0;
virtual int RegisterEvent( const char *pszName ) = 0;
virtual void FireEvent( int eventId, IEventQueue *pQueue, const void *pListener, CFunctorData *pData ) = 0;
virtual void RegisterListener( int eventId, IEventQueue *pQueue, CFunctorCallback *pCallback ) = 0;
virtual void UnregisterListener( int eventId, IEventQueue *pQueue, CFunctorCallback *pCallback ) = 0;
};

View File

@ -1,3 +1,4 @@
//===== Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ======//
//
// Purpose:
@ -103,7 +104,10 @@ ConCommandBase::ConCommandBase( void )
m_pszHelpString = NULL;
m_nFlags = 0;
m_nFlags2 = 0;
m_pNext = NULL;
m_Unknown = 0;
}
//-----------------------------------------------------------------------------
@ -501,43 +505,26 @@ int CCommand::FindArgInt( const char *pName, int nDefaultVal ) const
//-----------------------------------------------------------------------------
// Default console command autocompletion function
//-----------------------------------------------------------------------------
int DefaultCompletionFunc( const char *partial, char commands[ COMMAND_COMPLETION_MAXITEMS ][ COMMAND_COMPLETION_ITEM_LENGTH ] )
int DefaultCompletionFunc( const char *partial, CUtlVector< CUtlString > &commands )
{
return 0;
}
//-----------------------------------------------------------------------------
// Purpose: Constructs a console command
//-----------------------------------------------------------------------------
//ConCommand::ConCommand()
//{
// m_bIsNewConCommand = true;
//}
ConCommand::ConCommand( const char *pName, FnCommandCallbackV1_t callback, const char *pHelpString /*= 0*/, int flags /*= 0*/, FnCommandCompletionCallback completionFunc /*= 0*/ )
{
// Set the callback
m_fnCommandCallbackV1 = callback;
m_bUsingOldCommandCallback = true;
m_bUsingCommandCallbackInterface = false;
m_bUsingCommandCallbackInterface2 = false;
m_fnCompletionCallback = completionFunc ? completionFunc : DefaultCompletionFunc;
m_bHasCompletionCallback = completionFunc != 0 ? true : false;
// Setup the rest
BaseClass::Create( pName, pHelpString, flags );
}
ConCommand::ConCommand( const char *pName, FnCommandCallback_t callback, const char *pHelpString /*= 0*/, int flags /*= 0*/, FnCommandCompletionCallback completionFunc /*= 0*/ )
{
// Set the callback
m_fnCommandCallback = callback;
m_bUsingOldCommandCallback = false;
ConCommandCB cb;
cb.m_fnCommandCallback = callback;
cb.m_bUsingOldCommandCallback = false;
cb.m_bUsingCommandCallbackInterface = false;
m_Callbacks.AddToTail(cb);
m_fnCompletionCallback = completionFunc ? completionFunc : DefaultCompletionFunc;
m_bHasCompletionCallback = completionFunc != 0 ? true : false;
m_bUsingCommandCallbackInterface = false;
m_bUsingCommandCallbackInterface2 = false;
m_bUsingCommandCompletionInterface = false;
m_pParent = this;
// Setup the rest
BaseClass::Create( pName, pHelpString, flags );
@ -546,26 +533,17 @@ ConCommand::ConCommand( const char *pName, FnCommandCallback_t callback, const c
ConCommand::ConCommand( const char *pName, ICommandCallback *pCallback, const char *pHelpString /*= 0*/, int flags /*= 0*/, ICommandCompletionCallback *pCompletionCallback /*= 0*/ )
{
// Set the callback
m_pCommandCallback = pCallback;
m_bUsingOldCommandCallback = false;
ConCommandCB cb;
cb.m_pCommandCallback = pCallback;
cb.m_bUsingOldCommandCallback = false;
cb.m_bUsingCommandCallbackInterface = true;
m_Callbacks.AddToTail(cb);
m_pCommandCompletionCallback = pCompletionCallback;
m_bHasCompletionCallback = ( pCompletionCallback != 0 );
m_bUsingCommandCallbackInterface = true;
m_bUsingCommandCallbackInterface2 = false;
m_bUsingCommandCompletionInterface = true;
// Setup the rest
BaseClass::Create( pName, pHelpString, flags );
}
ConCommand::ConCommand( const char *pName, ICommandCallback2 *pCallback, const char *pHelpString /*= 0*/, int flags /*= 0*/, ICommandCompletionCallback *pCompletionCallback /*= 0*/ )
{
// Set the callback
m_pCommandCallback2 = pCallback;
m_bUsingOldCommandCallback = false;
m_pCommandCompletionCallback = pCompletionCallback;
m_bHasCompletionCallback = ( pCompletionCallback != 0 );
m_bUsingCommandCallbackInterface = false;
m_bUsingCommandCallbackInterface2 = true;
m_pParent = this;
// Setup the rest
BaseClass::Create( pName, pHelpString, flags );
@ -593,41 +571,44 @@ bool ConCommand::IsCommand( void ) const
//-----------------------------------------------------------------------------
void ConCommand::Dispatch( const CCommandContext &context, const CCommand &command )
{
if ( m_bUsingOldCommandCallback )
FOR_EACH_VEC(m_Callbacks, i)
{
if ( m_fnCommandCallbackV1 )
ConCommandCB cb = m_Callbacks[i];
if (cb.m_bUsingOldCommandCallback)
{
( *m_fnCommandCallbackV1 )();
if (m_fnCommandCallbackV1)
{
(*m_fnCommandCallbackV1)(context);
return;
}
}
else if ( m_bUsingCommandCallbackInterface )
else if (cb.m_bUsingCommandCallbackInterface)
{
if ( m_pCommandCallback )
if (cb.m_pCommandCallback)
{
m_pCommandCallback->CommandCallback( command );
cb.m_pCommandCallback->CommandCallback(context, command);
return;
}
}
else if (m_bUsingCommandCallbackInterface2 )
else if (cb.m_bUsingV2CommandCallback)
{
if ( m_pCommandCallback2 )
if (cb.m_bUsingV2CommandCallback)
{
m_pCommandCallback2->CommandCallback( context, command );
return;
cb.m_fnCommandCallbackV2(context, command);
}
}
else
{
if ( m_fnCommandCallback )
if (cb.m_fnCommandCallback)
{
( *m_fnCommandCallback )( context, command );
(*cb.m_fnCommandCallback)(command);
return;
}
}
// Command without callback!!!
AssertMsg( 0, ( "Encountered ConCommand without a callback!\n" ) );
AssertMsg(0, ("Encountered ConCommand without a callback!\n"));
}
}
@ -636,7 +617,7 @@ void ConCommand::Dispatch( const CCommandContext &context, const CCommand &comma
//-----------------------------------------------------------------------------
int ConCommand::AutoCompleteSuggest( const char *partial, CUtlVector< CUtlString > &commands )
{
if ( m_bUsingCommandCallbackInterface )
if (m_bUsingCommandCompletionInterface)
{
if ( !m_pCommandCompletionCallback )
return 0;
@ -647,14 +628,7 @@ int ConCommand::AutoCompleteSuggest( const char *partial, CUtlVector< CUtlString
if ( !m_fnCompletionCallback )
return 0;
char rgpchCommands[ COMMAND_COMPLETION_MAXITEMS ][ COMMAND_COMPLETION_ITEM_LENGTH ];
int iret = ( m_fnCompletionCallback )( partial, rgpchCommands );
for ( int i = 0 ; i < iret; ++i )
{
CUtlString str = rgpchCommands[ i ];
commands.AddToTail( str );
}
return iret;
return m_fnCompletionCallback( partial, commands );
}

View File

@ -321,7 +321,7 @@ void CCountedStringPool::SpewStrings()
Msg("\n%d total counted strings.", m_Elements.Count());
}
#ifdef _DEBUG
#ifdef _DEBUG1111
CON_COMMAND( test_stringpool, "Tests the class CStringPool" )
{
CStringPool pool;

View File

@ -1541,8 +1541,8 @@ void V_AppendSlash( char *pStr, int strSize )
int len = V_strlen( pStr );
if ( len > 0 && !PATHSEPARATOR(pStr[len-1]) )
{
if ( len+1 >= strSize )
Error( "V_AppendSlash: ran out of space on %s.", pStr );
//if ( len+1 >= strSize )
//Error( "V_AppendSlash: ran out of space on %s.", pStr );
pStr[len] = CORRECT_PATH_SEPARATOR;
pStr[len+1] = 0;
@ -1566,8 +1566,8 @@ void V_MakeAbsolutePath( char *pOut, int outLen, const char *pPath, const char *
}
else
{
if ( !_getcwd( pOut, outLen ) )
Error( "V_MakeAbsolutePath: _getcwd failed." );
//if ( !_getcwd( pOut, outLen ) )
//Error( "V_MakeAbsolutePath: _getcwd failed." );
if ( pStartingDir )
{
@ -1581,8 +1581,8 @@ void V_MakeAbsolutePath( char *pOut, int outLen, const char *pPath, const char *
V_strncat( pOut, pPath, outLen, COPY_ALL_CHARACTERS );
}
if ( !V_RemoveDotSlashes( pOut ) )
Error( "V_MakeAbsolutePath: tried to \"..\" past the root." );
//if ( !V_RemoveDotSlashes( pOut ) )
//Error( "V_MakeAbsolutePath: tried to \"..\" past the root." );
V_FixSlashes( pOut );
}

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
@ -18,9 +18,11 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v120</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
@ -143,6 +145,7 @@
<WarningLevel>Level3</WarningLevel>
<UndefinePreprocessorDefinitions>
</UndefinePreprocessorDefinitions>
<AdditionalOptions>/Zo %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<PreLinkEvent>
<Command>

View File

@ -22,6 +22,7 @@
#include <ctype.h>
#include <stdlib.h>
#include <limits.h>
#include "tier1/utlbinaryblock.h"
#include "tier1/utlstring.h"
#include "tier1/strtools.h"
#include "tier1/characterset.h"
@ -552,7 +553,7 @@ bool Unserialize( CUtlBuffer &buf, CUtlString &dest )
{
int nLen = buf.PeekDelimitedStringLength( s_pConv );
dest.SetLength( nLen - 1 ); // -1 because the length returned includes space for \0
buf.GetDelimitedString( s_pConv, dest.Get(), nLen );
buf.GetDelimitedString( s_pConv, dest.GetForModify(), nLen );
return buf.IsValid();
}

View File

@ -1,274 +1,269 @@
//====== Copyright <20> 1996-2004, Valve Corporation, All rights reserved. =======
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================
#define __STDC_LIMIT_MACROS
#include <stdint.h>
#include "tier1/utlstring.h"
#include "tier1/strtools.h"
#include <ctype.h>
//-----------------------------------------------------------------------------
// Base class, containing simple memory management
//-----------------------------------------------------------------------------
CUtlBinaryBlock::CUtlBinaryBlock( int growSize, int initSize ) : m_Memory( growSize, initSize )
{
m_nActualLength = 0;
}
CUtlBinaryBlock::CUtlBinaryBlock( void* pMemory, int nSizeInBytes, int nInitialLength ) : m_Memory( (unsigned char*)pMemory, nSizeInBytes )
{
m_nActualLength = nInitialLength;
}
CUtlBinaryBlock::CUtlBinaryBlock( const void* pMemory, int nSizeInBytes ) : m_Memory( (const unsigned char*)pMemory, nSizeInBytes )
{
m_nActualLength = nSizeInBytes;
}
CUtlBinaryBlock::CUtlBinaryBlock( const CUtlBinaryBlock& src )
{
Set( src.Get(), src.Length() );
}
void CUtlBinaryBlock::Get( void *pValue, int nLen ) const
{
Assert( nLen > 0 );
if ( m_nActualLength < nLen )
{
nLen = m_nActualLength;
}
if ( nLen > 0 )
{
memcpy( pValue, m_Memory.Base(), nLen );
}
}
void CUtlBinaryBlock::SetLength( int nLength )
{
Assert( !m_Memory.IsReadOnly() );
m_nActualLength = nLength;
if ( nLength > m_Memory.NumAllocated() )
{
int nOverFlow = nLength - m_Memory.NumAllocated();
m_Memory.Grow( nOverFlow );
// If the reallocation failed, clamp length
if ( nLength > m_Memory.NumAllocated() )
{
m_nActualLength = m_Memory.NumAllocated();
}
}
#ifdef _DEBUG
if ( m_Memory.NumAllocated() > m_nActualLength )
{
memset( ( ( char * )m_Memory.Base() ) + m_nActualLength, 0xEB, m_Memory.NumAllocated() - m_nActualLength );
}
#endif
}
void CUtlBinaryBlock::Set( const void *pValue, int nLen )
{
Assert( !m_Memory.IsReadOnly() );
if ( !pValue )
{
nLen = 0;
}
SetLength( nLen );
if ( m_nActualLength )
{
if ( ( ( const char * )m_Memory.Base() ) >= ( ( const char * )pValue ) + nLen ||
( ( const char * )m_Memory.Base() ) + m_nActualLength <= ( ( const char * )pValue ) )
{
memcpy( m_Memory.Base(), pValue, m_nActualLength );
}
else
{
memmove( m_Memory.Base(), pValue, m_nActualLength );
}
}
}
CUtlBinaryBlock &CUtlBinaryBlock::operator=( const CUtlBinaryBlock &src )
{
Assert( !m_Memory.IsReadOnly() );
Set( src.Get(), src.Length() );
return *this;
}
bool CUtlBinaryBlock::operator==( const CUtlBinaryBlock &src ) const
{
if ( src.Length() != Length() )
return false;
return !memcmp( src.Get(), Get(), Length() );
}
// NOTE: This has to be the last file included!
#include "tier0/memdbgon.h"
//-----------------------------------------------------------------------------
// Simple string class.
//-----------------------------------------------------------------------------
CUtlString::CUtlString()
//-----------------------------------------------------------------------------
// Either allocates or reallocates memory to the length
//
// Allocated space for length characters. It automatically adds space for the
// nul and the cached length at the start of the memory block. Will adjust
// m_pString and explicitly set the nul at the end before returning.
void *CUtlString::AllocMemory( uint32 length )
{
void *pMemoryBlock;
if ( m_pString )
{
pMemoryBlock = realloc( m_pString, length + 1 );
}
else
{
pMemoryBlock = malloc( length + 1 );
}
m_pString = (char*)pMemoryBlock;
m_pString[ length ] = 0;
return pMemoryBlock;
}
CUtlString::CUtlString( const char *pString )
//-----------------------------------------------------------------------------
void CUtlString::SetDirect( const char *pValue, int nChars )
{
Set( pString );
if ( pValue && nChars > 0 )
{
if ( pValue == m_pString )
{
AssertMsg( nChars == Q_strlen(m_pString), "CUtlString::SetDirect does not support resizing strings in place." );
return; // Do nothing. Realloc in AllocMemory might move pValue's location resulting in a bad memcpy.
}
Assert( nChars <= Min<int>( strnlen(pValue, nChars) + 1, nChars ) );
AllocMemory( nChars );
Q_memcpy( m_pString, pValue, nChars );
}
else
{
Purge();
}
}
CUtlString::CUtlString( const CUtlString& string )
{
Set( string.Get() );
}
// Attaches the string to external memory. Useful for avoiding a copy
CUtlString::CUtlString( void* pMemory, int nSizeInBytes, int nInitialLength ) : m_Storage( pMemory, nSizeInBytes, nInitialLength )
{
}
CUtlString::CUtlString( const void* pMemory, int nSizeInBytes ) : m_Storage( pMemory, nSizeInBytes )
{
}
void CUtlString::Set( const char *pValue )
{
Assert( !m_Storage.IsReadOnly() );
int nLen = pValue ? Q_strlen(pValue) + 1 : 0;
m_Storage.Set( pValue, nLen );
}
// Returns strlen
int CUtlString::Length() const
{
return m_Storage.Length() ? m_Storage.Length() - 1 : 0;
int length = pValue ? V_strlen( pValue ) : 0;
SetDirect( pValue, length );
}
// Sets the length (used to serialize into the buffer )
void CUtlString::SetLength( int nLen )
{
Assert( !m_Storage.IsReadOnly() );
// Add 1 to account for the NULL
m_Storage.SetLength( nLen > 0 ? nLen + 1 : 0 );
if ( nLen > 0 )
{
#ifdef _DEBUG
int prevLen = m_pString ? Length() : 0;
#endif
AllocMemory( nLen );
#ifdef _DEBUG
if ( nLen > prevLen )
{
V_memset( m_pString + prevLen, 0xEB, nLen - prevLen );
}
#endif
}
else
{
Purge();
}
}
const char *CUtlString::Get( ) const
{
if ( m_Storage.Length() == 0 )
if (!m_pString)
{
return "";
}
return reinterpret_cast< const char* >( m_Storage.Get() );
return m_pString;
}
// Converts to c-strings
CUtlString::operator const char*() const
char *CUtlString::GetForModify()
{
return Get();
}
char *CUtlString::Get()
{
Assert( !m_Storage.IsReadOnly() );
if ( m_Storage.Length() == 0 )
if ( !m_pString )
{
// In general, we optimise away small mallocs for empty strings
// but if you ask for the non-const bytes, they must be writable
// so we can't return "" here, like we do for the const version - jd
m_Storage.SetLength( 1 );
m_Storage[ 0 ] = '\0';
void *pMemoryBlock = malloc( 1 );
m_pString = (char *)pMemoryBlock;
*m_pString = 0;
}
return reinterpret_cast< char* >( m_Storage.Get() );
return m_pString;
}
char CUtlString::operator[]( int i ) const
{
if ( !m_pString )
return '\0';
if ( i >= Length() )
{
return '\0';
}
return m_pString[i];
}
void CUtlString::Clear()
{
Purge();
}
void CUtlString::Purge()
{
free( m_pString );
m_pString = NULL;
}
bool CUtlString::IsEqual_CaseSensitive( const char *src ) const
{
if ( !src )
{
return (Length() == 0);
}
return ( V_strcmp( Get(), src ) == 0 );
}
bool CUtlString::IsEqual_CaseInsensitive( const char *src ) const
{
if ( !src )
{
return (Length() == 0);
}
return ( V_stricmp( Get(), src ) == 0 );
}
void CUtlString::ToLower()
{
if ( !m_pString )
{
return;
}
V_strlower( m_pString );
}
void CUtlString::ToUpper()
{
if ( !m_pString )
{
return;
}
V_strupr( m_pString );
}
CUtlString &CUtlString::operator=( const CUtlString &src )
{
Assert( !m_Storage.IsReadOnly() );
m_Storage = src.m_Storage;
SetDirect( src.Get(), src.Length() );
return *this;
}
CUtlString &CUtlString::operator=( const char *src )
{
Assert( !m_Storage.IsReadOnly() );
Set( src );
return *this;
}
bool CUtlString::operator==( const CUtlString &src ) const
{
return m_Storage == src.m_Storage;
}
if ( IsEmpty() )
{
if ( src.IsEmpty() )
{
return true;
}
bool CUtlString::operator==( const char *src ) const
{
return ( strcmp( Get(), src ) == 0 );
return false;
}
else
{
if ( src.IsEmpty() )
{
return false;
}
return Q_strcmp( m_pString, src.m_pString ) == 0;
}
}
CUtlString &CUtlString::operator+=( const CUtlString &rhs )
{
Assert( !m_Storage.IsReadOnly() );
const int lhsLength( Length() );
const int rhsLength( rhs.Length() );
if (!rhsLength)
{
return *this;
}
const int requestedLength( lhsLength + rhsLength );
SetLength( requestedLength );
const int allocatedLength( Length() );
const int copyLength( allocatedLength - lhsLength < rhsLength ? allocatedLength - lhsLength : rhsLength );
memcpy( Get() + lhsLength, rhs.Get(), copyLength );
m_Storage[ allocatedLength ] = '\0';
AllocMemory( requestedLength );
Q_memcpy( m_pString + lhsLength, rhs.m_pString, rhsLength );
return *this;
}
CUtlString &CUtlString::operator+=( const char *rhs )
{
Assert( !m_Storage.IsReadOnly() );
const int lhsLength( Length() );
const int rhsLength( Q_strlen( rhs ) );
const int rhsLength( V_strlen( rhs ) );
const int requestedLength( lhsLength + rhsLength );
SetLength( requestedLength );
const int allocatedLength( Length() );
const int copyLength( allocatedLength - lhsLength < rhsLength ? allocatedLength - lhsLength : rhsLength );
memcpy( Get() + lhsLength, rhs, copyLength );
m_Storage[ allocatedLength ] = '\0';
if (!requestedLength)
{
return *this;
}
AllocMemory( requestedLength );
Q_memcpy( m_pString + lhsLength, rhs, rhsLength );
return *this;
}
CUtlString &CUtlString::operator+=( char c )
{
Assert( !m_Storage.IsReadOnly() );
const int lhsLength( Length() );
AllocMemory( lhsLength + 1 );
m_pString[ lhsLength ] = c;
int nLength = Length();
SetLength( nLength + 1 );
m_Storage[ nLength ] = c;
m_Storage[ nLength+1 ] = '\0';
return *this;
}
CUtlString &CUtlString::operator+=( int rhs )
{
Assert( !m_Storage.IsReadOnly() );
Assert( sizeof( rhs ) == 4 );
char tmpBuf[ 12 ]; // Sufficient for a signed 32 bit integer [ -2147483648 to +2147483647 ]
Q_snprintf( tmpBuf, sizeof( tmpBuf ), "%d", rhs );
V_snprintf( tmpBuf, sizeof( tmpBuf ), "%d", rhs );
tmpBuf[ sizeof( tmpBuf ) - 1 ] = '\0';
return operator+=( tmpBuf );
@ -276,42 +271,114 @@ CUtlString &CUtlString::operator+=( int rhs )
CUtlString &CUtlString::operator+=( double rhs )
{
Assert( !m_Storage.IsReadOnly() );
char tmpBuf[ 256 ]; // How big can doubles be??? Dunno.
Q_snprintf( tmpBuf, sizeof( tmpBuf ), "%lg", rhs );
V_snprintf( tmpBuf, sizeof( tmpBuf ), "%lg", rhs );
tmpBuf[ sizeof( tmpBuf ) - 1 ] = '\0';
return operator+=( tmpBuf );
}
bool CUtlString::MatchesPattern( const CUtlString &Pattern, int nFlags ) const
{
const char *pszSource = String();
const char *pszPattern = Pattern.String();
bool bExact = true;
while( 1 )
{
if ( ( *pszPattern ) == 0 )
{
return ( (*pszSource ) == 0 );
}
if ( ( *pszPattern ) == '*' )
{
pszPattern++;
if ( ( *pszPattern ) == 0 )
{
return true;
}
bExact = false;
continue;
}
int nLength = 0;
while( ( *pszPattern ) != '*' && ( *pszPattern ) != 0 )
{
nLength++;
pszPattern++;
}
while( 1 )
{
const char *pszStartPattern = pszPattern - nLength;
const char *pszSearch = pszSource;
for( int i = 0; i < nLength; i++, pszSearch++, pszStartPattern++ )
{
if ( ( *pszSearch ) == 0 )
{
return false;
}
if ( ( *pszSearch ) != ( *pszStartPattern ) )
{
break;
}
}
if ( pszSearch - pszSource == nLength )
{
break;
}
if ( bExact == true )
{
return false;
}
if ( ( nFlags & PATTERN_DIRECTORY ) != 0 )
{
if ( ( *pszPattern ) != '/' && ( *pszSource ) == '/' )
{
return false;
}
}
pszSource++;
}
pszSource += nLength;
}
}
int CUtlString::Format( const char *pFormat, ... )
{
Assert( !m_Storage.IsReadOnly() );
char tmpBuf[ 4096 ]; //< Nice big 4k buffer, as much memory as my first computer had, a Radio Shack Color Computer
va_list marker;
va_start( marker, pFormat );
#ifdef _WIN32
int len = _vsnprintf( tmpBuf, sizeof( tmpBuf ) - 1, pFormat, marker );
#elif defined _LINUX || defined __APPLE__
int len = vsnprintf( tmpBuf, sizeof( tmpBuf ) - 1, pFormat, marker );
#else
#error "define vsnprintf type."
#endif
int len = FormatV( pFormat, marker );
va_end( marker );
// Len < 0 represents an overflow
if( len < 0 )
{
len = sizeof( tmpBuf ) - 1;
tmpBuf[sizeof( tmpBuf ) - 1] = 0;
}
return len;
}
//--------------------------------------------------------------------------------------------------
// This can be called from functions that take varargs.
//--------------------------------------------------------------------------------------------------
int CUtlString::FormatV( const char *pFormat, va_list marker )
{
char tmpBuf[ 4096 ]; //< Nice big 4k buffer, as much memory as my first computer had, a Radio Shack Color Computer
//va_start( marker, pFormat );
int len = V_vsprintf_safe( tmpBuf, pFormat, marker );
//va_end( marker );
Set( tmpBuf );
return len;
}
@ -324,11 +391,377 @@ void CUtlString::StripTrailingSlash()
return;
int nLastChar = Length() - 1;
char c = m_Storage[ nLastChar ];
char c = m_pString[ nLastChar ];
if ( c == '\\' || c == '/' )
{
m_Storage[ nLastChar ] = 0;
m_Storage.SetLength( m_Storage.Length() - 1 );
SetLength( nLastChar );
}
}
void CUtlString::FixSlashes( char cSeparator/*=CORRECT_PATH_SEPARATOR*/ )
{
if ( m_pString )
{
V_FixSlashes( m_pString, cSeparator );
}
}
//-----------------------------------------------------------------------------
// Trim functions
//-----------------------------------------------------------------------------
void CUtlString::TrimLeft( char cTarget )
{
int nIndex = 0;
if ( IsEmpty() )
{
return;
}
while( m_pString[nIndex] == cTarget )
{
++nIndex;
}
// We have some whitespace to remove
if ( nIndex > 0 )
{
memcpy( m_pString, &m_pString[nIndex], Length() - nIndex );
SetLength( Length() - nIndex );
}
}
void CUtlString::TrimLeft( const char *szTargets )
{
int i;
if ( IsEmpty() )
{
return;
}
for( i = 0; m_pString[i] != 0; i++ )
{
bool bWhitespace = false;
for( int j = 0; szTargets[j] != 0; j++ )
{
if ( m_pString[i] == szTargets[j] )
{
bWhitespace = true;
break;
}
}
if ( !bWhitespace )
{
break;
}
}
// We have some whitespace to remove
if ( i > 0 )
{
memcpy( m_pString, &m_pString[i], Length() - i );
SetLength( Length() - i );
}
}
void CUtlString::TrimRight( char cTarget )
{
const int nLastCharIndex = Length() - 1;
int nIndex = nLastCharIndex;
while ( nIndex >= 0 && m_pString[nIndex] == cTarget )
{
--nIndex;
}
// We have some whitespace to remove
if ( nIndex < nLastCharIndex )
{
m_pString[nIndex + 1] = 0;
SetLength( nIndex + 2 );
}
}
void CUtlString::TrimRight( const char *szTargets )
{
const int nLastCharIndex = Length() - 1;
int i;
for( i = nLastCharIndex; i > 0; i-- )
{
bool bWhitespace = false;
for( int j = 0; szTargets[j] != 0; j++ )
{
if ( m_pString[i] == szTargets[j] )
{
bWhitespace = true;
break;
}
}
if ( !bWhitespace )
{
break;
}
}
// We have some whitespace to remove
if ( i < nLastCharIndex )
{
m_pString[i + 1] = 0;
SetLength( i + 2 );
}
}
void CUtlString::Trim( char cTarget )
{
TrimLeft( cTarget );
TrimRight( cTarget );
}
void CUtlString::Trim( const char *szTargets )
{
TrimLeft( szTargets );
TrimRight( szTargets );
}
CUtlString CUtlString::Slice( int32 nStart, int32 nEnd ) const
{
int length = Length();
if ( length == 0 )
{
return CUtlString();
}
if ( nStart < 0 )
nStart = length - (-nStart % length);
else if ( nStart >= length )
nStart = length;
if ( nEnd == INT32_MAX )
nEnd = length;
else if ( nEnd < 0 )
nEnd = length - (-nEnd % length);
else if ( nEnd >= length )
nEnd = length;
if ( nStart >= nEnd )
return CUtlString();
const char *pIn = String();
CUtlString ret;
ret.SetDirect( pIn + nStart, nEnd - nStart );
return ret;
}
// Grab a substring starting from the left or the right side.
CUtlString CUtlString::Left( int32 nChars ) const
{
return Slice( 0, nChars );
}
CUtlString CUtlString::Right( int32 nChars ) const
{
return Slice( -nChars );
}
CUtlString CUtlString::Replace( char cFrom, char cTo ) const
{
if (!m_pString)
{
return CUtlString();
}
CUtlString ret = *this;
int len = ret.Length();
for ( int i=0; i < len; i++ )
{
if ( ret.m_pString[i] == cFrom )
ret.m_pString[i] = cTo;
}
return ret;
}
CUtlString CUtlString::Replace( const char *pszFrom, const char *pszTo ) const
{
Assert( pszTo ); // Can be 0 length, but not null
Assert( pszFrom && *pszFrom ); // Must be valid and have one character.
const char *pos = V_strstr( String(), pszFrom );
if ( !pos )
{
return *this;
}
const char *pFirstFound = pos;
// count number of search string
int nSearchCount = 0;
int nSearchLength = V_strlen( pszFrom );
while ( pos )
{
nSearchCount++;
int nSrcOffset = ( pos - String() ) + nSearchLength;
pos = V_strstr( String() + nSrcOffset, pszFrom );
}
// allocate the new string
int nReplaceLength = V_strlen( pszTo );
int nAllocOffset = nSearchCount * ( nReplaceLength - nSearchLength );
size_t srcLength = Length();
CUtlString strDest;
size_t destLength = srcLength + nAllocOffset;
strDest.SetLength( destLength );
// find and replace the search string
pos = pFirstFound;
int nDestOffset = 0;
int nSrcOffset = 0;
while ( pos )
{
// Found an instance
int nCurrentSearchOffset = pos - String();
int nCopyLength = nCurrentSearchOffset - nSrcOffset;
V_strncpy( strDest.GetForModify() + nDestOffset, String() + nSrcOffset, nCopyLength + 1 );
nDestOffset += nCopyLength;
V_strncpy( strDest.GetForModify() + nDestOffset, pszTo, nReplaceLength + 1 );
nDestOffset += nReplaceLength;
nSrcOffset = nCurrentSearchOffset + nSearchLength;
pos = V_strstr( String() + nSrcOffset, pszFrom );
}
// making sure that the left over string from the source is the same size as the left over dest buffer
Assert( destLength - nDestOffset == srcLength - nSrcOffset );
if ( destLength - nDestOffset > 0 )
{
V_strncpy( strDest.GetForModify() + nDestOffset, String() + nSrcOffset, destLength - nDestOffset + 1 );
}
return strDest;
}
CUtlString CUtlString::AbsPath( const char *pStartingDir ) const
{
char szNew[MAX_PATH];
V_MakeAbsolutePath( szNew, sizeof( szNew ), this->String(), pStartingDir );
return CUtlString( szNew );
}
CUtlString CUtlString::UnqualifiedFilename() const
{
const char *pFilename = V_UnqualifiedFileName( this->String() );
return CUtlString( pFilename );
}
CUtlString CUtlString::DirName() const
{
CUtlString ret( this->String() );
V_StripLastDir( (char*)ret.Get(), ret.Length() + 1 );
V_StripTrailingSlash( (char*)ret.Get() );
return ret;
}
CUtlString CUtlString::StripExtension() const
{
char szTemp[MAX_PATH];
V_StripExtension( String(), szTemp, sizeof( szTemp ) );
return CUtlString( szTemp );
}
CUtlString CUtlString::StripFilename() const
{
const char *pFilename = V_UnqualifiedFileName( Get() ); // NOTE: returns 'Get()' on failure, never NULL
int nCharsToCopy = pFilename - Get();
CUtlString result;
result.SetDirect( Get(), nCharsToCopy );
result.StripTrailingSlash();
return result;
}
CUtlString CUtlString::GetBaseFilename() const
{
char szTemp[MAX_PATH];
V_FileBase( String(), szTemp, sizeof( szTemp ) );
return CUtlString( szTemp );
}
CUtlString CUtlString::GetExtension() const
{
char szTemp[MAX_PATH];
V_ExtractFileExtension( String(), szTemp, sizeof( szTemp ) );
return CUtlString( szTemp );
}
CUtlString CUtlString::PathJoin( const char *pStr1, const char *pStr2 )
{
char szPath[MAX_PATH];
V_ComposeFileName( pStr1, pStr2, szPath, sizeof( szPath ) );
return CUtlString( szPath );
}
CUtlString CUtlString::operator+( const char *pOther ) const
{
CUtlString s = *this;
s += pOther;
return s;
}
CUtlString CUtlString::operator+( const CUtlString &other ) const
{
CUtlString s = *this;
s += other;
return s;
}
CUtlString CUtlString::operator+( int rhs ) const
{
CUtlString ret = *this;
ret += rhs;
return ret;
}
//-----------------------------------------------------------------------------
// Purpose: concatenate the provided string to our current content
//-----------------------------------------------------------------------------
void CUtlString::Append( const char *pchAddition )
{
(*this) += pchAddition;
}
void CUtlString::Append( const char *pchAddition, int nChars )
{
nChars = Min<int>( nChars, V_strlen( pchAddition ) );
const int lhsLength( Length() );
const int rhsLength( nChars );
const int requestedLength( lhsLength + rhsLength );
AllocMemory( requestedLength );
const int allocatedLength( requestedLength );
const int copyLength( allocatedLength - lhsLength < rhsLength ? allocatedLength - lhsLength : rhsLength );
memcpy( GetForModify() + lhsLength, pchAddition, copyLength );
m_pString[ allocatedLength ] = '\0';
}
// Shared static empty string.
const CUtlString &CUtlString::GetEmptyString()
{
static const CUtlString s_emptyString;
return s_emptyString;
}