diff options
| author | Narendra Umate <[email protected]> | 2013-12-02 23:36:05 -0800 |
|---|---|---|
| committer | Narendra Umate <[email protected]> | 2013-12-02 23:36:05 -0800 |
| commit | 8737f191f3b59f001a77bf6c08091109211c1c9f (patch) | |
| tree | dbbf05c004d9b026f2c1f23f06600fe0add82c36 /mp/src/common | |
| parent | Update .gitignore. (diff) | |
| parent | Make .xcconfigs text files too. (diff) | |
| download | source-sdk-2013-8737f191f3b59f001a77bf6c08091109211c1c9f.tar.xz source-sdk-2013-8737f191f3b59f001a77bf6c08091109211c1c9f.zip | |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'mp/src/common')
57 files changed, 7253 insertions, 7253 deletions
diff --git a/mp/src/common/GameUI/IGameUI.h b/mp/src/common/GameUI/IGameUI.h index 8c7d314b..99967f49 100644 --- a/mp/src/common/GameUI/IGameUI.h +++ b/mp/src/common/GameUI/IGameUI.h @@ -1,121 +1,121 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef IGAMEUI_H
-#define IGAMEUI_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include "interface.h"
-#include "vgui/IPanel.h"
-
-#if !defined( _X360 )
-#include "xbox/xboxstubs.h"
-#endif
-
-// reasons why the user can't connect to a game server
-enum ESteamLoginFailure
-{
- STEAMLOGINFAILURE_NONE,
- STEAMLOGINFAILURE_BADTICKET,
- STEAMLOGINFAILURE_NOSTEAMLOGIN,
- STEAMLOGINFAILURE_VACBANNED,
- STEAMLOGINFAILURE_LOGGED_IN_ELSEWHERE
-};
-
-enum ESystemNotify
-{
- SYSTEMNOTIFY_STORAGEDEVICES_CHANGED,
- SYSTEMNOTIFY_USER_SIGNEDIN,
- SYSTEMNOTIFY_USER_SIGNEDOUT,
- SYSTEMNOTIFY_XUIOPENING,
- SYSTEMNOTIFY_XUICLOSED,
- SYSTEMNOTIFY_INVITE_SHUTDOWN, // Cross-game invite is causing us to shutdown
-};
-
-//-----------------------------------------------------------------------------
-// Purpose: contains all the functions that the GameUI dll exports
-//-----------------------------------------------------------------------------
-abstract_class IGameUI
-{
-public:
- // initialization/shutdown
- virtual void Initialize( CreateInterfaceFn appFactory ) = 0;
- virtual void PostInit() = 0;
-
- // connect to other interfaces at the same level (gameui.dll/server.dll/client.dll)
- virtual void Connect( CreateInterfaceFn gameFactory ) = 0;
-
- virtual void Start() = 0;
- virtual void Shutdown() = 0;
- virtual void RunFrame() = 0;
-
- // notifications
- virtual void OnGameUIActivated() = 0;
- virtual void OnGameUIHidden() = 0;
-
- // OLD: Use OnConnectToServer2
- virtual void OLD_OnConnectToServer(const char *game, int IP, int port) = 0;
-
- virtual void OnDisconnectFromServer_OLD( uint8 eSteamLoginFailure, const char *username ) = 0;
- virtual void OnLevelLoadingStarted(bool bShowProgressDialog) = 0;
- virtual void OnLevelLoadingFinished(bool bError, const char *failureReason, const char *extendedReason) = 0;
-
- // level loading progress, returns true if the screen needs updating
- virtual bool UpdateProgressBar(float progress, const char *statusText) = 0;
- // Shows progress desc, returns previous setting... (used with custom progress bars )
- virtual bool SetShowProgressText( bool show ) = 0;
-
- // !!!!!!!!!members added after "GameUI011" initial release!!!!!!!!!!!!!!!!!!!
- virtual void ShowNewGameDialog( int chapter ) = 0;
-
- // Xbox 360
- virtual void SessionNotification( const int notification, const int param = 0 ) = 0;
- virtual void SystemNotification( const int notification ) = 0;
- virtual void ShowMessageDialog( const uint nType, vgui::Panel *pOwner ) = 0;
- virtual void UpdatePlayerInfo( uint64 nPlayerId, const char *pName, int nTeam, byte cVoiceState, int nPlayersNeeded, bool bHost ) = 0;
- virtual void SessionSearchResult( int searchIdx, void *pHostData, XSESSION_SEARCHRESULT *pResult, int ping ) = 0;
- virtual void OnCreditsFinished( void ) = 0;
-
- // inserts specified panel as background for level load dialog
- virtual void SetLoadingBackgroundDialog( vgui::VPANEL panel ) = 0;
-
- // Bonus maps interfaces
- virtual void BonusMapUnlock( const char *pchFileName = NULL, const char *pchMapName = NULL ) = 0;
- virtual void BonusMapComplete( const char *pchFileName = NULL, const char *pchMapName = NULL ) = 0;
- virtual void BonusMapChallengeUpdate( const char *pchFileName, const char *pchMapName, const char *pchChallengeName, int iBest ) = 0;
- virtual void BonusMapChallengeNames( char *pchFileName, char *pchMapName, char *pchChallengeName ) = 0;
- virtual void BonusMapChallengeObjectives( int &iBronze, int &iSilver, int &iGold ) = 0;
- virtual void BonusMapDatabaseSave( void ) = 0;
- virtual int BonusMapNumAdvancedCompleted( void ) = 0;
- virtual void BonusMapNumMedals( int piNumMedals[ 3 ] ) = 0;
-
- virtual void OnConnectToServer2(const char *game, int IP, int connectionPort, int queryPort) = 0;
-
- // X360 Storage device validation:
- // returns true right away if storage device has been previously selected.
- // otherwise returns false and will set the variable pointed by pStorageDeviceValidated to 1
- // once the storage device is selected by user.
- virtual bool ValidateStorageDevice( int *pStorageDeviceValidated ) = 0;
-
- virtual void SetProgressOnStart() = 0;
- virtual void OnDisconnectFromServer( uint8 eSteamLoginFailure ) = 0;
-
- virtual void OnConfirmQuit( void ) = 0;
-
- virtual bool IsMainMenuVisible( void ) = 0;
-
- // Client DLL is providing us with a panel that it wants to replace the main menu with
- virtual void SetMainMenuOverride( vgui::VPANEL panel ) = 0;
- // Client DLL is telling us that a main menu command was issued, probably from its custom main menu panel
- virtual void SendMainMenuCommand( const char *pszCommand ) = 0;
-};
-
-#define GAMEUI_INTERFACE_VERSION "GameUI011"
-
-#endif // IGAMEUI_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef IGAMEUI_H +#define IGAMEUI_H +#ifdef _WIN32 +#pragma once +#endif + +#include "interface.h" +#include "vgui/IPanel.h" + +#if !defined( _X360 ) +#include "xbox/xboxstubs.h" +#endif + +// reasons why the user can't connect to a game server +enum ESteamLoginFailure +{ + STEAMLOGINFAILURE_NONE, + STEAMLOGINFAILURE_BADTICKET, + STEAMLOGINFAILURE_NOSTEAMLOGIN, + STEAMLOGINFAILURE_VACBANNED, + STEAMLOGINFAILURE_LOGGED_IN_ELSEWHERE +}; + +enum ESystemNotify +{ + SYSTEMNOTIFY_STORAGEDEVICES_CHANGED, + SYSTEMNOTIFY_USER_SIGNEDIN, + SYSTEMNOTIFY_USER_SIGNEDOUT, + SYSTEMNOTIFY_XUIOPENING, + SYSTEMNOTIFY_XUICLOSED, + SYSTEMNOTIFY_INVITE_SHUTDOWN, // Cross-game invite is causing us to shutdown +}; + +//----------------------------------------------------------------------------- +// Purpose: contains all the functions that the GameUI dll exports +//----------------------------------------------------------------------------- +abstract_class IGameUI +{ +public: + // initialization/shutdown + virtual void Initialize( CreateInterfaceFn appFactory ) = 0; + virtual void PostInit() = 0; + + // connect to other interfaces at the same level (gameui.dll/server.dll/client.dll) + virtual void Connect( CreateInterfaceFn gameFactory ) = 0; + + virtual void Start() = 0; + virtual void Shutdown() = 0; + virtual void RunFrame() = 0; + + // notifications + virtual void OnGameUIActivated() = 0; + virtual void OnGameUIHidden() = 0; + + // OLD: Use OnConnectToServer2 + virtual void OLD_OnConnectToServer(const char *game, int IP, int port) = 0; + + virtual void OnDisconnectFromServer_OLD( uint8 eSteamLoginFailure, const char *username ) = 0; + virtual void OnLevelLoadingStarted(bool bShowProgressDialog) = 0; + virtual void OnLevelLoadingFinished(bool bError, const char *failureReason, const char *extendedReason) = 0; + + // level loading progress, returns true if the screen needs updating + virtual bool UpdateProgressBar(float progress, const char *statusText) = 0; + // Shows progress desc, returns previous setting... (used with custom progress bars ) + virtual bool SetShowProgressText( bool show ) = 0; + + // !!!!!!!!!members added after "GameUI011" initial release!!!!!!!!!!!!!!!!!!! + virtual void ShowNewGameDialog( int chapter ) = 0; + + // Xbox 360 + virtual void SessionNotification( const int notification, const int param = 0 ) = 0; + virtual void SystemNotification( const int notification ) = 0; + virtual void ShowMessageDialog( const uint nType, vgui::Panel *pOwner ) = 0; + virtual void UpdatePlayerInfo( uint64 nPlayerId, const char *pName, int nTeam, byte cVoiceState, int nPlayersNeeded, bool bHost ) = 0; + virtual void SessionSearchResult( int searchIdx, void *pHostData, XSESSION_SEARCHRESULT *pResult, int ping ) = 0; + virtual void OnCreditsFinished( void ) = 0; + + // inserts specified panel as background for level load dialog + virtual void SetLoadingBackgroundDialog( vgui::VPANEL panel ) = 0; + + // Bonus maps interfaces + virtual void BonusMapUnlock( const char *pchFileName = NULL, const char *pchMapName = NULL ) = 0; + virtual void BonusMapComplete( const char *pchFileName = NULL, const char *pchMapName = NULL ) = 0; + virtual void BonusMapChallengeUpdate( const char *pchFileName, const char *pchMapName, const char *pchChallengeName, int iBest ) = 0; + virtual void BonusMapChallengeNames( char *pchFileName, char *pchMapName, char *pchChallengeName ) = 0; + virtual void BonusMapChallengeObjectives( int &iBronze, int &iSilver, int &iGold ) = 0; + virtual void BonusMapDatabaseSave( void ) = 0; + virtual int BonusMapNumAdvancedCompleted( void ) = 0; + virtual void BonusMapNumMedals( int piNumMedals[ 3 ] ) = 0; + + virtual void OnConnectToServer2(const char *game, int IP, int connectionPort, int queryPort) = 0; + + // X360 Storage device validation: + // returns true right away if storage device has been previously selected. + // otherwise returns false and will set the variable pointed by pStorageDeviceValidated to 1 + // once the storage device is selected by user. + virtual bool ValidateStorageDevice( int *pStorageDeviceValidated ) = 0; + + virtual void SetProgressOnStart() = 0; + virtual void OnDisconnectFromServer( uint8 eSteamLoginFailure ) = 0; + + virtual void OnConfirmQuit( void ) = 0; + + virtual bool IsMainMenuVisible( void ) = 0; + + // Client DLL is providing us with a panel that it wants to replace the main menu with + virtual void SetMainMenuOverride( vgui::VPANEL panel ) = 0; + // Client DLL is telling us that a main menu command was issued, probably from its custom main menu panel + virtual void SendMainMenuCommand( const char *pszCommand ) = 0; +}; + +#define GAMEUI_INTERFACE_VERSION "GameUI011" + +#endif // IGAMEUI_H diff --git a/mp/src/common/SteamCommon.h b/mp/src/common/SteamCommon.h index ac008ff1..fee28878 100644 --- a/mp/src/common/SteamCommon.h +++ b/mp/src/common/SteamCommon.h @@ -1,703 +1,703 @@ -
-//========= Copyright Valve Corporation, All rights reserved. ============//
-/*
-** The copyright to the contents herein is the property of Valve Corporation.
-** The contents may be used and/or copied only with the written permission of
-** Valve, or in accordance with the terms and conditions stipulated in
-** the agreement/contract under which the contents have been supplied.
-**
-*******************************************************************************
-**
-** Contents:
-**
-** Common types used in the Steam DLL interface.
-**
-** This file is distributed to Steam application developers.
-**
-**
-**
-*******************************************************************************/
-
-#ifndef INCLUDED_STEAM_COMMON_STEAMCOMMON_H
-#define INCLUDED_STEAM_COMMON_STEAMCOMMON_H
-
-#if defined(_MSC_VER) && (_MSC_VER > 1000)
-#pragma once
-#endif
-
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-/* Applications should not define STEAM_EXPORTS. */
-
-#if defined ( _WIN32 )
-
-#ifdef STEAM_EXPORTS
-#define STEAM_API __declspec(dllexport)
-#else
-#define STEAM_API __declspec(dllimport)
-#endif
-
-#define STEAM_CALL __cdecl
-
-#else
-
-#define STEAM_API /* */
-#define STEAM_CALL /* */
-
-#endif
-
-typedef void (STEAM_CALL *KeyValueIteratorCallback_t )(const char *Key, const char *Val, void *pvParam);
-
-
-/******************************************************************************
-**
-** Exported macros and constants
-**
-******************************************************************************/
-
-/* DEPRECATED -- these are ignored now, all API access is granted on SteamStartup */
-#define STEAM_USING_FILESYSTEM (0x00000001)
-#define STEAM_USING_LOGGING (0x00000002)
-#define STEAM_USING_USERID (0x00000004)
-#define STEAM_USING_ACCOUNT (0x00000008)
-#define STEAM_USING_ALL (0x0000000f)
-/* END DEPRECATED */
-
-#define STEAM_MAX_PATH (255)
-#define STEAM_QUESTION_MAXLEN (255)
-#define STEAM_SALT_SIZE (8)
-#define STEAM_PROGRESS_PERCENT_SCALE (0x00001000)
-
-/* These are maximum significant string lengths, excluding nul-terminator. */
-#define STEAM_CARD_NUMBER_SIZE (17)
-#define STEAM_CARD_HOLDERNAME_SIZE (100)
-#define STEAM_CARD_EXPYEAR_SIZE (4)
-#define STEAM_CARD_EXPMONTH_SIZE (2)
-#define STEAM_CARD_CVV2_SIZE (5)
-#define STEAM_BILLING_ADDRESS1_SIZE (128)
-#define STEAM_BILLING_ADDRESS2_SIZE (128)
-#define STEAM_BILLING_CITY_SIZE (50)
-#define STEAM_BILLING_ZIP_SIZE (16)
-#define STEAM_BILLING_STATE_SIZE (32)
-#define STEAM_BILLING_COUNTRY_SIZE (32)
-#define STEAM_BILLING_PHONE_SIZE (20)
-#define STEAM_BILLING_EMAIL_ADDRESS_SIZE (100)
-#define STEAM_TYPE_OF_PROOF_OF_PURCHASE_SIZE (20)
-#define STEAM_PROOF_OF_PURCHASE_TOKEN_SIZE (200)
-#define STEAM_EXTERNAL_ACCOUNTNAME_SIZE (100)
-#define STEAM_EXTERNAL_ACCOUNTPASSWORD_SIZE (80)
-#define STEAM_BILLING_CONFIRMATION_CODE_SIZE (22)
-#define STEAM_BILLING_CARD_APPROVAL_CODE_SIZE (100)
-#define STEAM_BILLING_TRANS_DATE_SIZE (9) // mm/dd/yy
-#define STEAM_BILLING_TRANS_TIME_SIZE (9) // hh:mm:ss
-
-/******************************************************************************
-**
-** Scalar type and enumerated type definitions.
-**
-******************************************************************************/
-
-
-typedef unsigned int SteamHandle_t;
-
-typedef void * SteamUserIDTicketValidationHandle_t;
-
-typedef unsigned int SteamCallHandle_t;
-
-#if defined(_MSC_VER)
-typedef unsigned __int64 SteamUnsigned64_t;
-#else
-typedef unsigned long long SteamUnsigned64_t;
-#endif
-
-typedef enum
-{
- eSteamSeekMethodSet = 0,
- eSteamSeekMethodCur = 1,
- eSteamSeekMethodEnd = 2
-} ESteamSeekMethod;
-
-typedef enum
-{
- eSteamBufferMethodFBF = 0,
- eSteamBufferMethodNBF = 1
-} ESteamBufferMethod;
-
-typedef enum
-{
- eSteamErrorNone = 0,
- eSteamErrorUnknown = 1,
- eSteamErrorLibraryNotInitialized = 2,
- eSteamErrorLibraryAlreadyInitialized = 3,
- eSteamErrorConfig = 4,
- eSteamErrorContentServerConnect = 5,
- eSteamErrorBadHandle = 6,
- eSteamErrorHandlesExhausted = 7,
- eSteamErrorBadArg = 8,
- eSteamErrorNotFound = 9,
- eSteamErrorRead = 10,
- eSteamErrorEOF = 11,
- eSteamErrorSeek = 12,
- eSteamErrorCannotWriteNonUserConfigFile = 13,
- eSteamErrorCacheOpen = 14,
- eSteamErrorCacheRead = 15,
- eSteamErrorCacheCorrupted = 16,
- eSteamErrorCacheWrite = 17,
- eSteamErrorCacheSession = 18,
- eSteamErrorCacheInternal = 19,
- eSteamErrorCacheBadApp = 20,
- eSteamErrorCacheVersion = 21,
- eSteamErrorCacheBadFingerPrint = 22,
-
- eSteamErrorNotFinishedProcessing = 23,
- eSteamErrorNothingToDo = 24,
- eSteamErrorCorruptEncryptedUserIDTicket = 25,
- eSteamErrorSocketLibraryNotInitialized = 26,
- eSteamErrorFailedToConnectToUserIDTicketValidationServer = 27,
- eSteamErrorBadProtocolVersion = 28,
- eSteamErrorReplayedUserIDTicketFromClient = 29,
- eSteamErrorReceiveResultBufferTooSmall = 30,
- eSteamErrorSendFailed = 31,
- eSteamErrorReceiveFailed = 32,
- eSteamErrorReplayedReplyFromUserIDTicketValidationServer = 33,
- eSteamErrorBadSignatureFromUserIDTicketValidationServer = 34,
- eSteamErrorValidationStalledSoAborted = 35,
- eSteamErrorInvalidUserIDTicket = 36,
- eSteamErrorClientLoginRateTooHigh = 37,
- eSteamErrorClientWasNeverValidated = 38,
- eSteamErrorInternalSendBufferTooSmall = 39,
- eSteamErrorInternalReceiveBufferTooSmall = 40,
- eSteamErrorUserTicketExpired = 41,
- eSteamErrorCDKeyAlreadyInUseOnAnotherClient = 42,
-
- eSteamErrorNotLoggedIn = 101,
- eSteamErrorAlreadyExists = 102,
- eSteamErrorAlreadySubscribed = 103,
- eSteamErrorNotSubscribed = 104,
- eSteamErrorAccessDenied = 105,
- eSteamErrorFailedToCreateCacheFile = 106,
- eSteamErrorCallStalledSoAborted = 107,
- eSteamErrorEngineNotRunning = 108,
- eSteamErrorEngineConnectionLost = 109,
- eSteamErrorLoginFailed = 110,
- eSteamErrorAccountPending = 111,
- eSteamErrorCacheWasMissingRetry = 112,
- eSteamErrorLocalTimeIncorrect = 113,
- eSteamErrorCacheNeedsDecryption = 114,
- eSteamErrorAccountDisabled = 115,
- eSteamErrorCacheNeedsRepair = 116,
- eSteamErrorRebootRequired = 117,
-
- eSteamErrorNetwork = 200,
- eSteamErrorOffline = 201
-
-
-} ESteamError;
-
-
-typedef enum
-{
- eNoDetailedErrorAvailable,
- eStandardCerrno,
- eWin32LastError,
- eWinSockLastError,
- eDetailedPlatformErrorCount
-} EDetailedPlatformErrorType;
-
-typedef enum /* Filter elements returned by SteamFind{First,Next} */
-{
- eSteamFindLocalOnly, /* limit search to local filesystem */
- eSteamFindRemoteOnly, /* limit search to remote repository */
- eSteamFindAll /* do not limit search (duplicates allowed) */
-} ESteamFindFilter;
-
-
-/******************************************************************************
-**
-** Exported structure and complex type definitions.
-**
-******************************************************************************/
-
-
-typedef struct
-{
- ESteamError eSteamError;
- EDetailedPlatformErrorType eDetailedErrorType;
- int nDetailedErrorCode;
- char szDesc[STEAM_MAX_PATH];
-} TSteamError;
-
-
-
-typedef struct
-{
- int bIsDir; /* If non-zero, element is a directory; if zero, element is a file */
- unsigned int uSizeOrCount; /* If element is a file, this contains size of file in bytes */
- int bIsLocal; /* If non-zero, reported item is a standalone element on local filesystem */
- char cszName[STEAM_MAX_PATH]; /* Base element name (no path) */
- long lLastAccessTime; /* Seconds since 1/1/1970 (like time_t) when element was last accessed */
- long lLastModificationTime; /* Seconds since 1/1/1970 (like time_t) when element was last modified */
- long lCreationTime; /* Seconds since 1/1/1970 (like time_t) when element was created */
-} TSteamElemInfo;
-
-
-typedef struct
-{
- unsigned int uNumSubscriptions;
- unsigned int uMaxNameChars;
- unsigned int uMaxApps;
-
-} TSteamSubscriptionStats;
-
-
-typedef struct
-{
- unsigned int uNumApps;
- unsigned int uMaxNameChars;
- unsigned int uMaxInstallDirNameChars;
- unsigned int uMaxVersionLabelChars;
- unsigned int uMaxLaunchOptions;
- unsigned int uMaxLaunchOptionDescChars;
- unsigned int uMaxLaunchOptionCmdLineChars;
- unsigned int uMaxNumIcons;
- unsigned int uMaxIconSize;
- unsigned int uMaxDependencies;
-
-} TSteamAppStats;
-
-typedef struct
-{
- char *szLabel;
- unsigned int uMaxLabelChars;
- unsigned int uVersionId;
- int bIsNotAvailable;
-} TSteamAppVersion;
-
-typedef struct
-{
- char *szDesc;
- unsigned int uMaxDescChars;
- char *szCmdLine;
- unsigned int uMaxCmdLineChars;
- unsigned int uIndex;
- unsigned int uIconIndex;
- int bNoDesktopShortcut;
- int bNoStartMenuShortcut;
- int bIsLongRunningUnattended;
-
-} TSteamAppLaunchOption;
-
-
-typedef struct
-{
- char *szName;
- unsigned int uMaxNameChars;
- char *szLatestVersionLabel;
- unsigned int uMaxLatestVersionLabelChars;
- char *szCurrentVersionLabel;
- unsigned int uMaxCurrentVersionLabelChars;
- char *szInstallDirName;
- unsigned int uMaxInstallDirNameChars;
- unsigned int uId;
- unsigned int uLatestVersionId;
- unsigned int uCurrentVersionId;
- unsigned int uMinCacheFileSizeMB;
- unsigned int uMaxCacheFileSizeMB;
- unsigned int uNumLaunchOptions;
- unsigned int uNumIcons;
- unsigned int uNumVersions;
- unsigned int uNumDependencies;
-
-} TSteamApp;
-
-typedef enum
-{
- eNoCost = 0,
- eBillOnceOnly = 1,
- eBillMonthly = 2,
- eProofOfPrepurchaseOnly = 3,
- eGuestPass = 4,
- eHardwarePromo = 5,
- eNumBillingTypes,
-} EBillingType;
-
-typedef struct
-{
- char *szName;
- unsigned int uMaxNameChars;
- unsigned int *puAppIds;
- unsigned int uMaxAppIds;
- unsigned int uId;
- unsigned int uNumApps;
- EBillingType eBillingType;
- unsigned int uCostInCents;
- unsigned int uNumDiscounts;
- int bIsPreorder;
- int bRequiresShippingAddress;
- unsigned int uDomesticShippingCostInCents;
- unsigned int uInternationalShippingCostInCents;
- bool bIsCyberCafeSubscription;
- unsigned int uGameCode;
- char szGameCodeDesc[STEAM_MAX_PATH];
- bool bIsDisabled;
- bool bRequiresCD;
- unsigned int uTerritoryCode;
- bool bIsSteam3Subscription;
-
-} TSteamSubscription;
-
-typedef struct
-{
- char szName[STEAM_MAX_PATH];
- unsigned int uDiscountInCents;
- unsigned int uNumQualifiers;
-
-} TSteamSubscriptionDiscount;
-
-typedef struct
-{
- char szName[STEAM_MAX_PATH];
- unsigned int uRequiredSubscription;
- int bIsDisqualifier;
-
-} TSteamDiscountQualifier;
-
-typedef struct TSteamProgress
-{
- int bValid; /* non-zero if call provides progress info */
- unsigned int uPercentDone; /* 0 to 100 * STEAM_PROGRESS_PERCENT_SCALE if bValid */
- char szProgress[STEAM_MAX_PATH]; /* additional progress info */
-} TSteamProgress;
-
-typedef enum
-{
- eSteamNotifyTicketsWillExpire,
- eSteamNotifyAccountInfoChanged,
- eSteamNotifyContentDescriptionChanged,
- eSteamNotifyPleaseShutdown,
- eSteamNotifyNewContentServer,
- eSteamNotifySubscriptionStatusChanged,
- eSteamNotifyContentServerConnectionLost,
- eSteamNotifyCacheLoadingCompleted,
- eSteamNotifyCacheNeedsDecryption,
- eSteamNotifyCacheNeedsRepair
-} ESteamNotificationCallbackEvent;
-
-
-typedef void(*SteamNotificationCallback_t)(ESteamNotificationCallbackEvent eEvent, unsigned int nData);
-
-
-typedef char SteamPersonalQuestion_t[ STEAM_QUESTION_MAXLEN + 1 ];
-
-typedef struct
-{
- unsigned char uchSalt[STEAM_SALT_SIZE];
-} SteamSalt_t;
-
-typedef enum
-{
- eVisa = 1,
- eMaster = 2,
- eAmericanExpress = 3,
- eDiscover = 4,
- eDinnersClub = 5,
- eJCB = 6
-} ESteamPaymentCardType;
-
-typedef struct
-{
- ESteamPaymentCardType eCardType;
- char szCardNumber[ STEAM_CARD_NUMBER_SIZE +1 ];
- char szCardHolderName[ STEAM_CARD_HOLDERNAME_SIZE + 1];
- char szCardExpYear[ STEAM_CARD_EXPYEAR_SIZE + 1 ];
- char szCardExpMonth[ STEAM_CARD_EXPMONTH_SIZE+ 1 ];
- char szCardCVV2[ STEAM_CARD_CVV2_SIZE + 1 ];
- char szBillingAddress1[ STEAM_BILLING_ADDRESS1_SIZE + 1 ];
- char szBillingAddress2[ STEAM_BILLING_ADDRESS2_SIZE + 1 ];
- char szBillingCity[ STEAM_BILLING_CITY_SIZE + 1 ];
- char szBillingZip[ STEAM_BILLING_ZIP_SIZE + 1 ];
- char szBillingState[ STEAM_BILLING_STATE_SIZE + 1 ];
- char szBillingCountry[ STEAM_BILLING_COUNTRY_SIZE + 1 ];
- char szBillingPhone[ STEAM_BILLING_PHONE_SIZE + 1 ];
- char szBillingEmailAddress[ STEAM_BILLING_EMAIL_ADDRESS_SIZE + 1 ];
- unsigned int uExpectedCostInCents;
- unsigned int uExpectedTaxInCents;
- /* If the TSteamSubscription says that shipping info is required, */
- /* then the following fields must be filled out. */
- /* If szShippingName is empty, then assumes so are the rest. */
- char szShippingName[ STEAM_CARD_HOLDERNAME_SIZE + 1];
- char szShippingAddress1[ STEAM_BILLING_ADDRESS1_SIZE + 1 ];
- char szShippingAddress2[ STEAM_BILLING_ADDRESS2_SIZE + 1 ];
- char szShippingCity[ STEAM_BILLING_CITY_SIZE + 1 ];
- char szShippingZip[ STEAM_BILLING_ZIP_SIZE + 1 ];
- char szShippingState[ STEAM_BILLING_STATE_SIZE + 1 ];
- char szShippingCountry[ STEAM_BILLING_COUNTRY_SIZE + 1 ];
- char szShippingPhone[ STEAM_BILLING_PHONE_SIZE + 1 ];
- unsigned int uExpectedShippingCostInCents;
-
-} TSteamPaymentCardInfo;
-
-typedef struct
-{
- char szTypeOfProofOfPurchase[ STEAM_TYPE_OF_PROOF_OF_PURCHASE_SIZE + 1 ];
-
- /* A ProofOfPurchase token is not necessarily a nul-terminated string; it may be binary data
- (perhaps encrypted). Hence we need a length and an array of bytes. */
- unsigned int uLengthOfBinaryProofOfPurchaseToken;
- char cBinaryProofOfPurchaseToken[ STEAM_PROOF_OF_PURCHASE_TOKEN_SIZE + 1 ];
-} TSteamPrepurchaseInfo;
-
-typedef struct
-{
- char szAccountName[ STEAM_EXTERNAL_ACCOUNTNAME_SIZE + 1 ];
- char szPassword[ STEAM_EXTERNAL_ACCOUNTPASSWORD_SIZE + 1 ];
-} TSteamExternalBillingInfo;
-
-typedef enum
-{
- ePaymentCardInfo = 1,
- ePrepurchasedInfo = 2,
- eAccountBillingInfo = 3,
- eExternalBillingInfo = 4, /* indirect billing via ISP etc (not supported yet) */
- ePaymentCardReceipt = 5,
- ePrepurchaseReceipt = 6,
- eEmptyReceipt = 7
-} ESteamSubscriptionBillingInfoType;
-
-typedef struct
-{
- ESteamSubscriptionBillingInfoType eBillingInfoType;
- union {
- TSteamPaymentCardInfo PaymentCardInfo;
- TSteamPrepurchaseInfo PrepurchaseInfo;
- TSteamExternalBillingInfo ExternalBillingInfo;
- char bUseAccountBillingInfo;
- };
-
-} TSteamSubscriptionBillingInfo;
-
-typedef enum
-{
- /* Subscribed */
- eSteamSubscriptionOK = 0, /* Subscribed */
- eSteamSubscriptionPending = 1, /* Awaiting transaction completion */
- eSteamSubscriptionPreorder = 2, /* Is currently a pre-order */
- eSteamSubscriptionPrepurchaseTransferred = 3, /* hop to this account */
- /* Unusbscribed */
- eSteamSubscriptionPrepurchaseInvalid = 4, /* Invalid cd-key */
- eSteamSubscriptionPrepurchaseRejected = 5, /* hopped out / banned / etc */
- eSteamSubscriptionPrepurchaseRevoked = 6, /* hop away from this account */
- eSteamSubscriptionPaymentCardDeclined = 7, /* CC txn declined */
- eSteamSubscriptionCancelledByUser = 8, /* Cancelled by client */
- eSteamSubscriptionCancelledByVendor = 9, /* Cancelled by us */
- eSteamSubscriptionPaymentCardUseLimit = 10, /* Card used too many times, potential fraud */
- eSteamSubscriptionPaymentCardAlert = 11, /* Got a "pick up card" or the like from bank */
- eSteamSubscriptionFailed = 12, /* Other Error in subscription data or transaction failed/lost */
- eSteamSubscriptionPaymentCardAVSFailure = 13, /* Card failed Address Verification check */
- eSteamSubscriptionPaymentCardInsufficientFunds = 14, /* Card failed due to insufficient funds */
- eSteamSubscriptionRestrictedCountry = 15 /* The subscription is not available in the user's country */
-
-} ESteamSubscriptionStatus;
-
-typedef struct
-{
- ESteamPaymentCardType eCardType;
- char szCardLastFourDigits[ 4 + 1 ];
- char szCardHolderName[ STEAM_CARD_HOLDERNAME_SIZE + 1];
- char szBillingAddress1[ STEAM_BILLING_ADDRESS1_SIZE + 1 ];
- char szBillingAddress2[ STEAM_BILLING_ADDRESS2_SIZE + 1 ];
- char szBillingCity[ STEAM_BILLING_CITY_SIZE + 1 ];
- char szBillingZip[ STEAM_BILLING_ZIP_SIZE + 1 ];
- char szBillingState[ STEAM_BILLING_STATE_SIZE + 1 ];
- char szBillingCountry[ STEAM_BILLING_COUNTRY_SIZE + 1 ];
-
- // The following are only available after the subscription leaves "pending" status
- char szCardApprovalCode[ STEAM_BILLING_CARD_APPROVAL_CODE_SIZE + 1];
- char szTransDate[ STEAM_BILLING_TRANS_DATE_SIZE + 1]; /* mm/dd/yy */
- char szTransTime[ STEAM_BILLING_TRANS_TIME_SIZE + 1]; /* hh:mm:ss */
- unsigned int uPriceWithoutTax;
- unsigned int uTaxAmount;
- unsigned int uShippingCost;
-
-} TSteamPaymentCardReceiptInfo;
-
-typedef struct
-{
- char szTypeOfProofOfPurchase[ STEAM_TYPE_OF_PROOF_OF_PURCHASE_SIZE + 1 ];
-} TSteamPrepurchaseReceiptInfo;
-
-typedef struct
-{
- ESteamSubscriptionStatus eStatus;
- ESteamSubscriptionStatus ePreviousStatus;
- ESteamSubscriptionBillingInfoType eReceiptInfoType;
- char szConfirmationCode[ STEAM_BILLING_CONFIRMATION_CODE_SIZE + 1];
- union {
- TSteamPaymentCardReceiptInfo PaymentCardReceiptInfo;
- TSteamPrepurchaseReceiptInfo PrepurchaseReceiptInfo;
- };
-
-} TSteamSubscriptionReceipt;
-
-typedef enum
-{
- ePhysicalBytesReceivedThisSession = 1,
- eAppReadyToLaunchStatus = 2,
- eAppPreloadStatus = 3,
- eAppEntireDepot = 4,
- eCacheBytesPresent = 5
-} ESteamAppUpdateStatsQueryType;
-
-typedef struct
-{
- SteamUnsigned64_t uBytesTotal;
- SteamUnsigned64_t uBytesPresent;
-} TSteamUpdateStats;
-
-typedef enum
-{
- eSteamUserAdministrator = 0x00000001, /* May subscribe, unsubscribe, etc */
- eSteamUserDeveloper = 0x00000002, /* Steam or App developer */
- eSteamUserCyberCafe = 0x00000004 /* CyberCafe, school, etc -- UI should ask for password */
- /* before allowing logout, unsubscribe, etc */
-} ESteamUserTypeFlags;
-
-typedef enum
-{
- eSteamAccountStatusDefault = 0x00000000,
- eSteamAccountStatusEmailVerified = 0x00000001,
- /* Note: Mask value 0x2 is reserved for future use. (Some, but not all, public accounts already have this set.) */
- eSteamAccountDisabled = 0x00000004
-} ESteamAccountStatusBitFields ;
-
-
-typedef enum
-{
- eSteamBootstrapperError = -1,
- eSteamBootstrapperDontCheckForUpdate = 0,
- eSteamBootstrapperCheckForUpdateAndRerun = 7
-
-} ESteamBootStrapperClientAppResult;
-
-typedef enum
-{
- eSteamOnline = 0,
- eSteamOffline = 1,
- eSteamNoAuthMode = 2,
- eSteamBillingOffline = 3
-} eSteamOfflineStatus;
-
-typedef struct
-{
- int eOfflineNow;
- int eOfflineNextSession;
-} TSteamOfflineStatus;
-
-typedef struct
-{
- unsigned int uAppId;
- int bIsSystemDefined;
- char szMountPath[STEAM_MAX_PATH];
-} TSteamAppDependencyInfo;
-
-typedef enum
-{
- eSteamOpenFileRegular = 0x0,
- eSteamOpenFileIgnoreLocal = 0x1,
- eSteamOpenFileChecksumReads = 0x2
-} ESteamOpenFileFlags;
-
-typedef enum
-{
- eSteamValveCDKeyValidationServer = 0,
- eSteamHalfLifeMasterServer = 1,
- eSteamFriendsServer = 2,
- eSteamCSERServer = 3,
- eSteamHalfLife2MasterServer = 4,
- eSteamRDKFMasterServer = 5,
- eMaxServerTypes = 6
-} ESteamServerType;
-
-/******************************************************************************
-**
-** More exported constants
-**
-******************************************************************************/
-
-
-#ifdef __cplusplus
-
-const SteamHandle_t STEAM_INVALID_HANDLE = 0;
-const SteamCallHandle_t STEAM_INVALID_CALL_HANDLE = 0;
-const SteamUserIDTicketValidationHandle_t STEAM_INACTIVE_USERIDTICKET_VALIDATION_HANDLE = 0;
-const unsigned int STEAM_USE_LATEST_VERSION = 0xFFFFFFFF;
-
-#else
-
-#define STEAM_INVALID_HANDLE ((SteamHandle_t)(0))
-#define STEAM_INVALID_CALL_HANDLE ((SteamCallHandle_t)(0))
-#define STEAM_INACTIVE_USERIDTICKET_VALIDATION_HANDLE ((SteamUserIDTicketValidationHandle_t)(0))
-#define STEAM_USE_LATEST_VERSION (0xFFFFFFFFu);
-
-#endif
-
-
-/******************************************************************************
-** Each Steam instance (licensed Steam Service Provider) has a unique SteamInstanceID_t.
-**
-** Each Steam instance as its own DB of users.
-** Each user in the DB has a unique SteamLocalUserID_t (a serial number, with possible
-** rare gaps in the sequence).
-**
-******************************************************************************/
-
-typedef unsigned short SteamInstanceID_t; // MUST be 16 bits
-
-
-#if defined ( _WIN32 )
-typedef unsigned __int64 SteamLocalUserID_t; // MUST be 64 bits
-#else
-typedef unsigned long long SteamLocalUserID_t; // MUST be 64 bits
-#endif
-
-/******************************************************************************
-**
-** Applications need to be able to authenticate Steam users from ANY instance.
-** So a SteamIDTicket contains SteamGlobalUserID, which is a unique combination of
-** instance and user id.
-**
-** SteamLocalUserID is an unsigned 64-bit integer.
-** For platforms without 64-bit int support, we provide access via a union that splits it into
-** high and low unsigned 32-bit ints. Such platforms will only need to compare LocalUserIDs
-** for equivalence anyway - not perform arithmetic with them.
-**
-********************************************************************************/
-typedef struct
-{
- unsigned int Low32bits;
- unsigned int High32bits;
-} TSteamSplitLocalUserID;
-
-typedef struct
-{
- SteamInstanceID_t m_SteamInstanceID;
-
- union
- {
- SteamLocalUserID_t As64bits;
- TSteamSplitLocalUserID Split;
- } m_SteamLocalUserID;
-
-} TSteamGlobalUserID;
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif
+ +//========= Copyright Valve Corporation, All rights reserved. ============// +/* +** The copyright to the contents herein is the property of Valve Corporation. +** The contents may be used and/or copied only with the written permission of +** Valve, or in accordance with the terms and conditions stipulated in +** the agreement/contract under which the contents have been supplied. +** +******************************************************************************* +** +** Contents: +** +** Common types used in the Steam DLL interface. +** +** This file is distributed to Steam application developers. +** +** +** +*******************************************************************************/ + +#ifndef INCLUDED_STEAM_COMMON_STEAMCOMMON_H +#define INCLUDED_STEAM_COMMON_STEAMCOMMON_H + +#if defined(_MSC_VER) && (_MSC_VER > 1000) +#pragma once +#endif + + +#ifdef __cplusplus +extern "C" +{ +#endif + +/* Applications should not define STEAM_EXPORTS. */ + +#if defined ( _WIN32 ) + +#ifdef STEAM_EXPORTS +#define STEAM_API __declspec(dllexport) +#else +#define STEAM_API __declspec(dllimport) +#endif + +#define STEAM_CALL __cdecl + +#else + +#define STEAM_API /* */ +#define STEAM_CALL /* */ + +#endif + +typedef void (STEAM_CALL *KeyValueIteratorCallback_t )(const char *Key, const char *Val, void *pvParam); + + +/****************************************************************************** +** +** Exported macros and constants +** +******************************************************************************/ + +/* DEPRECATED -- these are ignored now, all API access is granted on SteamStartup */ +#define STEAM_USING_FILESYSTEM (0x00000001) +#define STEAM_USING_LOGGING (0x00000002) +#define STEAM_USING_USERID (0x00000004) +#define STEAM_USING_ACCOUNT (0x00000008) +#define STEAM_USING_ALL (0x0000000f) +/* END DEPRECATED */ + +#define STEAM_MAX_PATH (255) +#define STEAM_QUESTION_MAXLEN (255) +#define STEAM_SALT_SIZE (8) +#define STEAM_PROGRESS_PERCENT_SCALE (0x00001000) + +/* These are maximum significant string lengths, excluding nul-terminator. */ +#define STEAM_CARD_NUMBER_SIZE (17) +#define STEAM_CARD_HOLDERNAME_SIZE (100) +#define STEAM_CARD_EXPYEAR_SIZE (4) +#define STEAM_CARD_EXPMONTH_SIZE (2) +#define STEAM_CARD_CVV2_SIZE (5) +#define STEAM_BILLING_ADDRESS1_SIZE (128) +#define STEAM_BILLING_ADDRESS2_SIZE (128) +#define STEAM_BILLING_CITY_SIZE (50) +#define STEAM_BILLING_ZIP_SIZE (16) +#define STEAM_BILLING_STATE_SIZE (32) +#define STEAM_BILLING_COUNTRY_SIZE (32) +#define STEAM_BILLING_PHONE_SIZE (20) +#define STEAM_BILLING_EMAIL_ADDRESS_SIZE (100) +#define STEAM_TYPE_OF_PROOF_OF_PURCHASE_SIZE (20) +#define STEAM_PROOF_OF_PURCHASE_TOKEN_SIZE (200) +#define STEAM_EXTERNAL_ACCOUNTNAME_SIZE (100) +#define STEAM_EXTERNAL_ACCOUNTPASSWORD_SIZE (80) +#define STEAM_BILLING_CONFIRMATION_CODE_SIZE (22) +#define STEAM_BILLING_CARD_APPROVAL_CODE_SIZE (100) +#define STEAM_BILLING_TRANS_DATE_SIZE (9) // mm/dd/yy +#define STEAM_BILLING_TRANS_TIME_SIZE (9) // hh:mm:ss + +/****************************************************************************** +** +** Scalar type and enumerated type definitions. +** +******************************************************************************/ + + +typedef unsigned int SteamHandle_t; + +typedef void * SteamUserIDTicketValidationHandle_t; + +typedef unsigned int SteamCallHandle_t; + +#if defined(_MSC_VER) +typedef unsigned __int64 SteamUnsigned64_t; +#else +typedef unsigned long long SteamUnsigned64_t; +#endif + +typedef enum +{ + eSteamSeekMethodSet = 0, + eSteamSeekMethodCur = 1, + eSteamSeekMethodEnd = 2 +} ESteamSeekMethod; + +typedef enum +{ + eSteamBufferMethodFBF = 0, + eSteamBufferMethodNBF = 1 +} ESteamBufferMethod; + +typedef enum +{ + eSteamErrorNone = 0, + eSteamErrorUnknown = 1, + eSteamErrorLibraryNotInitialized = 2, + eSteamErrorLibraryAlreadyInitialized = 3, + eSteamErrorConfig = 4, + eSteamErrorContentServerConnect = 5, + eSteamErrorBadHandle = 6, + eSteamErrorHandlesExhausted = 7, + eSteamErrorBadArg = 8, + eSteamErrorNotFound = 9, + eSteamErrorRead = 10, + eSteamErrorEOF = 11, + eSteamErrorSeek = 12, + eSteamErrorCannotWriteNonUserConfigFile = 13, + eSteamErrorCacheOpen = 14, + eSteamErrorCacheRead = 15, + eSteamErrorCacheCorrupted = 16, + eSteamErrorCacheWrite = 17, + eSteamErrorCacheSession = 18, + eSteamErrorCacheInternal = 19, + eSteamErrorCacheBadApp = 20, + eSteamErrorCacheVersion = 21, + eSteamErrorCacheBadFingerPrint = 22, + + eSteamErrorNotFinishedProcessing = 23, + eSteamErrorNothingToDo = 24, + eSteamErrorCorruptEncryptedUserIDTicket = 25, + eSteamErrorSocketLibraryNotInitialized = 26, + eSteamErrorFailedToConnectToUserIDTicketValidationServer = 27, + eSteamErrorBadProtocolVersion = 28, + eSteamErrorReplayedUserIDTicketFromClient = 29, + eSteamErrorReceiveResultBufferTooSmall = 30, + eSteamErrorSendFailed = 31, + eSteamErrorReceiveFailed = 32, + eSteamErrorReplayedReplyFromUserIDTicketValidationServer = 33, + eSteamErrorBadSignatureFromUserIDTicketValidationServer = 34, + eSteamErrorValidationStalledSoAborted = 35, + eSteamErrorInvalidUserIDTicket = 36, + eSteamErrorClientLoginRateTooHigh = 37, + eSteamErrorClientWasNeverValidated = 38, + eSteamErrorInternalSendBufferTooSmall = 39, + eSteamErrorInternalReceiveBufferTooSmall = 40, + eSteamErrorUserTicketExpired = 41, + eSteamErrorCDKeyAlreadyInUseOnAnotherClient = 42, + + eSteamErrorNotLoggedIn = 101, + eSteamErrorAlreadyExists = 102, + eSteamErrorAlreadySubscribed = 103, + eSteamErrorNotSubscribed = 104, + eSteamErrorAccessDenied = 105, + eSteamErrorFailedToCreateCacheFile = 106, + eSteamErrorCallStalledSoAborted = 107, + eSteamErrorEngineNotRunning = 108, + eSteamErrorEngineConnectionLost = 109, + eSteamErrorLoginFailed = 110, + eSteamErrorAccountPending = 111, + eSteamErrorCacheWasMissingRetry = 112, + eSteamErrorLocalTimeIncorrect = 113, + eSteamErrorCacheNeedsDecryption = 114, + eSteamErrorAccountDisabled = 115, + eSteamErrorCacheNeedsRepair = 116, + eSteamErrorRebootRequired = 117, + + eSteamErrorNetwork = 200, + eSteamErrorOffline = 201 + + +} ESteamError; + + +typedef enum +{ + eNoDetailedErrorAvailable, + eStandardCerrno, + eWin32LastError, + eWinSockLastError, + eDetailedPlatformErrorCount +} EDetailedPlatformErrorType; + +typedef enum /* Filter elements returned by SteamFind{First,Next} */ +{ + eSteamFindLocalOnly, /* limit search to local filesystem */ + eSteamFindRemoteOnly, /* limit search to remote repository */ + eSteamFindAll /* do not limit search (duplicates allowed) */ +} ESteamFindFilter; + + +/****************************************************************************** +** +** Exported structure and complex type definitions. +** +******************************************************************************/ + + +typedef struct +{ + ESteamError eSteamError; + EDetailedPlatformErrorType eDetailedErrorType; + int nDetailedErrorCode; + char szDesc[STEAM_MAX_PATH]; +} TSteamError; + + + +typedef struct +{ + int bIsDir; /* If non-zero, element is a directory; if zero, element is a file */ + unsigned int uSizeOrCount; /* If element is a file, this contains size of file in bytes */ + int bIsLocal; /* If non-zero, reported item is a standalone element on local filesystem */ + char cszName[STEAM_MAX_PATH]; /* Base element name (no path) */ + long lLastAccessTime; /* Seconds since 1/1/1970 (like time_t) when element was last accessed */ + long lLastModificationTime; /* Seconds since 1/1/1970 (like time_t) when element was last modified */ + long lCreationTime; /* Seconds since 1/1/1970 (like time_t) when element was created */ +} TSteamElemInfo; + + +typedef struct +{ + unsigned int uNumSubscriptions; + unsigned int uMaxNameChars; + unsigned int uMaxApps; + +} TSteamSubscriptionStats; + + +typedef struct +{ + unsigned int uNumApps; + unsigned int uMaxNameChars; + unsigned int uMaxInstallDirNameChars; + unsigned int uMaxVersionLabelChars; + unsigned int uMaxLaunchOptions; + unsigned int uMaxLaunchOptionDescChars; + unsigned int uMaxLaunchOptionCmdLineChars; + unsigned int uMaxNumIcons; + unsigned int uMaxIconSize; + unsigned int uMaxDependencies; + +} TSteamAppStats; + +typedef struct +{ + char *szLabel; + unsigned int uMaxLabelChars; + unsigned int uVersionId; + int bIsNotAvailable; +} TSteamAppVersion; + +typedef struct +{ + char *szDesc; + unsigned int uMaxDescChars; + char *szCmdLine; + unsigned int uMaxCmdLineChars; + unsigned int uIndex; + unsigned int uIconIndex; + int bNoDesktopShortcut; + int bNoStartMenuShortcut; + int bIsLongRunningUnattended; + +} TSteamAppLaunchOption; + + +typedef struct +{ + char *szName; + unsigned int uMaxNameChars; + char *szLatestVersionLabel; + unsigned int uMaxLatestVersionLabelChars; + char *szCurrentVersionLabel; + unsigned int uMaxCurrentVersionLabelChars; + char *szInstallDirName; + unsigned int uMaxInstallDirNameChars; + unsigned int uId; + unsigned int uLatestVersionId; + unsigned int uCurrentVersionId; + unsigned int uMinCacheFileSizeMB; + unsigned int uMaxCacheFileSizeMB; + unsigned int uNumLaunchOptions; + unsigned int uNumIcons; + unsigned int uNumVersions; + unsigned int uNumDependencies; + +} TSteamApp; + +typedef enum +{ + eNoCost = 0, + eBillOnceOnly = 1, + eBillMonthly = 2, + eProofOfPrepurchaseOnly = 3, + eGuestPass = 4, + eHardwarePromo = 5, + eNumBillingTypes, +} EBillingType; + +typedef struct +{ + char *szName; + unsigned int uMaxNameChars; + unsigned int *puAppIds; + unsigned int uMaxAppIds; + unsigned int uId; + unsigned int uNumApps; + EBillingType eBillingType; + unsigned int uCostInCents; + unsigned int uNumDiscounts; + int bIsPreorder; + int bRequiresShippingAddress; + unsigned int uDomesticShippingCostInCents; + unsigned int uInternationalShippingCostInCents; + bool bIsCyberCafeSubscription; + unsigned int uGameCode; + char szGameCodeDesc[STEAM_MAX_PATH]; + bool bIsDisabled; + bool bRequiresCD; + unsigned int uTerritoryCode; + bool bIsSteam3Subscription; + +} TSteamSubscription; + +typedef struct +{ + char szName[STEAM_MAX_PATH]; + unsigned int uDiscountInCents; + unsigned int uNumQualifiers; + +} TSteamSubscriptionDiscount; + +typedef struct +{ + char szName[STEAM_MAX_PATH]; + unsigned int uRequiredSubscription; + int bIsDisqualifier; + +} TSteamDiscountQualifier; + +typedef struct TSteamProgress +{ + int bValid; /* non-zero if call provides progress info */ + unsigned int uPercentDone; /* 0 to 100 * STEAM_PROGRESS_PERCENT_SCALE if bValid */ + char szProgress[STEAM_MAX_PATH]; /* additional progress info */ +} TSteamProgress; + +typedef enum +{ + eSteamNotifyTicketsWillExpire, + eSteamNotifyAccountInfoChanged, + eSteamNotifyContentDescriptionChanged, + eSteamNotifyPleaseShutdown, + eSteamNotifyNewContentServer, + eSteamNotifySubscriptionStatusChanged, + eSteamNotifyContentServerConnectionLost, + eSteamNotifyCacheLoadingCompleted, + eSteamNotifyCacheNeedsDecryption, + eSteamNotifyCacheNeedsRepair +} ESteamNotificationCallbackEvent; + + +typedef void(*SteamNotificationCallback_t)(ESteamNotificationCallbackEvent eEvent, unsigned int nData); + + +typedef char SteamPersonalQuestion_t[ STEAM_QUESTION_MAXLEN + 1 ]; + +typedef struct +{ + unsigned char uchSalt[STEAM_SALT_SIZE]; +} SteamSalt_t; + +typedef enum +{ + eVisa = 1, + eMaster = 2, + eAmericanExpress = 3, + eDiscover = 4, + eDinnersClub = 5, + eJCB = 6 +} ESteamPaymentCardType; + +typedef struct +{ + ESteamPaymentCardType eCardType; + char szCardNumber[ STEAM_CARD_NUMBER_SIZE +1 ]; + char szCardHolderName[ STEAM_CARD_HOLDERNAME_SIZE + 1]; + char szCardExpYear[ STEAM_CARD_EXPYEAR_SIZE + 1 ]; + char szCardExpMonth[ STEAM_CARD_EXPMONTH_SIZE+ 1 ]; + char szCardCVV2[ STEAM_CARD_CVV2_SIZE + 1 ]; + char szBillingAddress1[ STEAM_BILLING_ADDRESS1_SIZE + 1 ]; + char szBillingAddress2[ STEAM_BILLING_ADDRESS2_SIZE + 1 ]; + char szBillingCity[ STEAM_BILLING_CITY_SIZE + 1 ]; + char szBillingZip[ STEAM_BILLING_ZIP_SIZE + 1 ]; + char szBillingState[ STEAM_BILLING_STATE_SIZE + 1 ]; + char szBillingCountry[ STEAM_BILLING_COUNTRY_SIZE + 1 ]; + char szBillingPhone[ STEAM_BILLING_PHONE_SIZE + 1 ]; + char szBillingEmailAddress[ STEAM_BILLING_EMAIL_ADDRESS_SIZE + 1 ]; + unsigned int uExpectedCostInCents; + unsigned int uExpectedTaxInCents; + /* If the TSteamSubscription says that shipping info is required, */ + /* then the following fields must be filled out. */ + /* If szShippingName is empty, then assumes so are the rest. */ + char szShippingName[ STEAM_CARD_HOLDERNAME_SIZE + 1]; + char szShippingAddress1[ STEAM_BILLING_ADDRESS1_SIZE + 1 ]; + char szShippingAddress2[ STEAM_BILLING_ADDRESS2_SIZE + 1 ]; + char szShippingCity[ STEAM_BILLING_CITY_SIZE + 1 ]; + char szShippingZip[ STEAM_BILLING_ZIP_SIZE + 1 ]; + char szShippingState[ STEAM_BILLING_STATE_SIZE + 1 ]; + char szShippingCountry[ STEAM_BILLING_COUNTRY_SIZE + 1 ]; + char szShippingPhone[ STEAM_BILLING_PHONE_SIZE + 1 ]; + unsigned int uExpectedShippingCostInCents; + +} TSteamPaymentCardInfo; + +typedef struct +{ + char szTypeOfProofOfPurchase[ STEAM_TYPE_OF_PROOF_OF_PURCHASE_SIZE + 1 ]; + + /* A ProofOfPurchase token is not necessarily a nul-terminated string; it may be binary data + (perhaps encrypted). Hence we need a length and an array of bytes. */ + unsigned int uLengthOfBinaryProofOfPurchaseToken; + char cBinaryProofOfPurchaseToken[ STEAM_PROOF_OF_PURCHASE_TOKEN_SIZE + 1 ]; +} TSteamPrepurchaseInfo; + +typedef struct +{ + char szAccountName[ STEAM_EXTERNAL_ACCOUNTNAME_SIZE + 1 ]; + char szPassword[ STEAM_EXTERNAL_ACCOUNTPASSWORD_SIZE + 1 ]; +} TSteamExternalBillingInfo; + +typedef enum +{ + ePaymentCardInfo = 1, + ePrepurchasedInfo = 2, + eAccountBillingInfo = 3, + eExternalBillingInfo = 4, /* indirect billing via ISP etc (not supported yet) */ + ePaymentCardReceipt = 5, + ePrepurchaseReceipt = 6, + eEmptyReceipt = 7 +} ESteamSubscriptionBillingInfoType; + +typedef struct +{ + ESteamSubscriptionBillingInfoType eBillingInfoType; + union { + TSteamPaymentCardInfo PaymentCardInfo; + TSteamPrepurchaseInfo PrepurchaseInfo; + TSteamExternalBillingInfo ExternalBillingInfo; + char bUseAccountBillingInfo; + }; + +} TSteamSubscriptionBillingInfo; + +typedef enum +{ + /* Subscribed */ + eSteamSubscriptionOK = 0, /* Subscribed */ + eSteamSubscriptionPending = 1, /* Awaiting transaction completion */ + eSteamSubscriptionPreorder = 2, /* Is currently a pre-order */ + eSteamSubscriptionPrepurchaseTransferred = 3, /* hop to this account */ + /* Unusbscribed */ + eSteamSubscriptionPrepurchaseInvalid = 4, /* Invalid cd-key */ + eSteamSubscriptionPrepurchaseRejected = 5, /* hopped out / banned / etc */ + eSteamSubscriptionPrepurchaseRevoked = 6, /* hop away from this account */ + eSteamSubscriptionPaymentCardDeclined = 7, /* CC txn declined */ + eSteamSubscriptionCancelledByUser = 8, /* Cancelled by client */ + eSteamSubscriptionCancelledByVendor = 9, /* Cancelled by us */ + eSteamSubscriptionPaymentCardUseLimit = 10, /* Card used too many times, potential fraud */ + eSteamSubscriptionPaymentCardAlert = 11, /* Got a "pick up card" or the like from bank */ + eSteamSubscriptionFailed = 12, /* Other Error in subscription data or transaction failed/lost */ + eSteamSubscriptionPaymentCardAVSFailure = 13, /* Card failed Address Verification check */ + eSteamSubscriptionPaymentCardInsufficientFunds = 14, /* Card failed due to insufficient funds */ + eSteamSubscriptionRestrictedCountry = 15 /* The subscription is not available in the user's country */ + +} ESteamSubscriptionStatus; + +typedef struct +{ + ESteamPaymentCardType eCardType; + char szCardLastFourDigits[ 4 + 1 ]; + char szCardHolderName[ STEAM_CARD_HOLDERNAME_SIZE + 1]; + char szBillingAddress1[ STEAM_BILLING_ADDRESS1_SIZE + 1 ]; + char szBillingAddress2[ STEAM_BILLING_ADDRESS2_SIZE + 1 ]; + char szBillingCity[ STEAM_BILLING_CITY_SIZE + 1 ]; + char szBillingZip[ STEAM_BILLING_ZIP_SIZE + 1 ]; + char szBillingState[ STEAM_BILLING_STATE_SIZE + 1 ]; + char szBillingCountry[ STEAM_BILLING_COUNTRY_SIZE + 1 ]; + + // The following are only available after the subscription leaves "pending" status + char szCardApprovalCode[ STEAM_BILLING_CARD_APPROVAL_CODE_SIZE + 1]; + char szTransDate[ STEAM_BILLING_TRANS_DATE_SIZE + 1]; /* mm/dd/yy */ + char szTransTime[ STEAM_BILLING_TRANS_TIME_SIZE + 1]; /* hh:mm:ss */ + unsigned int uPriceWithoutTax; + unsigned int uTaxAmount; + unsigned int uShippingCost; + +} TSteamPaymentCardReceiptInfo; + +typedef struct +{ + char szTypeOfProofOfPurchase[ STEAM_TYPE_OF_PROOF_OF_PURCHASE_SIZE + 1 ]; +} TSteamPrepurchaseReceiptInfo; + +typedef struct +{ + ESteamSubscriptionStatus eStatus; + ESteamSubscriptionStatus ePreviousStatus; + ESteamSubscriptionBillingInfoType eReceiptInfoType; + char szConfirmationCode[ STEAM_BILLING_CONFIRMATION_CODE_SIZE + 1]; + union { + TSteamPaymentCardReceiptInfo PaymentCardReceiptInfo; + TSteamPrepurchaseReceiptInfo PrepurchaseReceiptInfo; + }; + +} TSteamSubscriptionReceipt; + +typedef enum +{ + ePhysicalBytesReceivedThisSession = 1, + eAppReadyToLaunchStatus = 2, + eAppPreloadStatus = 3, + eAppEntireDepot = 4, + eCacheBytesPresent = 5 +} ESteamAppUpdateStatsQueryType; + +typedef struct +{ + SteamUnsigned64_t uBytesTotal; + SteamUnsigned64_t uBytesPresent; +} TSteamUpdateStats; + +typedef enum +{ + eSteamUserAdministrator = 0x00000001, /* May subscribe, unsubscribe, etc */ + eSteamUserDeveloper = 0x00000002, /* Steam or App developer */ + eSteamUserCyberCafe = 0x00000004 /* CyberCafe, school, etc -- UI should ask for password */ + /* before allowing logout, unsubscribe, etc */ +} ESteamUserTypeFlags; + +typedef enum +{ + eSteamAccountStatusDefault = 0x00000000, + eSteamAccountStatusEmailVerified = 0x00000001, + /* Note: Mask value 0x2 is reserved for future use. (Some, but not all, public accounts already have this set.) */ + eSteamAccountDisabled = 0x00000004 +} ESteamAccountStatusBitFields ; + + +typedef enum +{ + eSteamBootstrapperError = -1, + eSteamBootstrapperDontCheckForUpdate = 0, + eSteamBootstrapperCheckForUpdateAndRerun = 7 + +} ESteamBootStrapperClientAppResult; + +typedef enum +{ + eSteamOnline = 0, + eSteamOffline = 1, + eSteamNoAuthMode = 2, + eSteamBillingOffline = 3 +} eSteamOfflineStatus; + +typedef struct +{ + int eOfflineNow; + int eOfflineNextSession; +} TSteamOfflineStatus; + +typedef struct +{ + unsigned int uAppId; + int bIsSystemDefined; + char szMountPath[STEAM_MAX_PATH]; +} TSteamAppDependencyInfo; + +typedef enum +{ + eSteamOpenFileRegular = 0x0, + eSteamOpenFileIgnoreLocal = 0x1, + eSteamOpenFileChecksumReads = 0x2 +} ESteamOpenFileFlags; + +typedef enum +{ + eSteamValveCDKeyValidationServer = 0, + eSteamHalfLifeMasterServer = 1, + eSteamFriendsServer = 2, + eSteamCSERServer = 3, + eSteamHalfLife2MasterServer = 4, + eSteamRDKFMasterServer = 5, + eMaxServerTypes = 6 +} ESteamServerType; + +/****************************************************************************** +** +** More exported constants +** +******************************************************************************/ + + +#ifdef __cplusplus + +const SteamHandle_t STEAM_INVALID_HANDLE = 0; +const SteamCallHandle_t STEAM_INVALID_CALL_HANDLE = 0; +const SteamUserIDTicketValidationHandle_t STEAM_INACTIVE_USERIDTICKET_VALIDATION_HANDLE = 0; +const unsigned int STEAM_USE_LATEST_VERSION = 0xFFFFFFFF; + +#else + +#define STEAM_INVALID_HANDLE ((SteamHandle_t)(0)) +#define STEAM_INVALID_CALL_HANDLE ((SteamCallHandle_t)(0)) +#define STEAM_INACTIVE_USERIDTICKET_VALIDATION_HANDLE ((SteamUserIDTicketValidationHandle_t)(0)) +#define STEAM_USE_LATEST_VERSION (0xFFFFFFFFu); + +#endif + + +/****************************************************************************** +** Each Steam instance (licensed Steam Service Provider) has a unique SteamInstanceID_t. +** +** Each Steam instance as its own DB of users. +** Each user in the DB has a unique SteamLocalUserID_t (a serial number, with possible +** rare gaps in the sequence). +** +******************************************************************************/ + +typedef unsigned short SteamInstanceID_t; // MUST be 16 bits + + +#if defined ( _WIN32 ) +typedef unsigned __int64 SteamLocalUserID_t; // MUST be 64 bits +#else +typedef unsigned long long SteamLocalUserID_t; // MUST be 64 bits +#endif + +/****************************************************************************** +** +** Applications need to be able to authenticate Steam users from ANY instance. +** So a SteamIDTicket contains SteamGlobalUserID, which is a unique combination of +** instance and user id. +** +** SteamLocalUserID is an unsigned 64-bit integer. +** For platforms without 64-bit int support, we provide access via a union that splits it into +** high and low unsigned 32-bit ints. Such platforms will only need to compare LocalUserIDs +** for equivalence anyway - not perform arithmetic with them. +** +********************************************************************************/ +typedef struct +{ + unsigned int Low32bits; + unsigned int High32bits; +} TSteamSplitLocalUserID; + +typedef struct +{ + SteamInstanceID_t m_SteamInstanceID; + + union + { + SteamLocalUserID_t As64bits; + TSteamSplitLocalUserID Split; + } m_SteamLocalUserID; + +} TSteamGlobalUserID; + + +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/mp/src/common/compiledcaptionswap.cpp b/mp/src/common/compiledcaptionswap.cpp index c6c2d09a..494cd698 100644 --- a/mp/src/common/compiledcaptionswap.cpp +++ b/mp/src/common/compiledcaptionswap.cpp @@ -1,103 +1,103 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose: Swap a compiled caption file.
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#include "utlbuffer.h"
-#include "byteswap.h"
-#include "filesystem.h"
-#include "tier2/fileutils.h"
-#include "captioncompiler.h"
-
-// memdbgon must be the last include file in a .cpp file!!!
-#include "tier0/memdbgon.h"
-
-BEGIN_BYTESWAP_DATADESC( CompiledCaptionHeader_t )
- DEFINE_FIELD( magic, FIELD_INTEGER ),
- DEFINE_FIELD( version, FIELD_INTEGER ),
- DEFINE_FIELD( numblocks, FIELD_INTEGER ),
- DEFINE_FIELD( blocksize, FIELD_INTEGER ),
- DEFINE_FIELD( directorysize, FIELD_INTEGER ),
- DEFINE_FIELD( dataoffset, FIELD_INTEGER ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( CaptionLookup_t )
- DEFINE_FIELD( hash, FIELD_INTEGER ),
- DEFINE_FIELD( blockNum, FIELD_INTEGER ),
- DEFINE_FIELD( offset, FIELD_SHORT ),
- DEFINE_FIELD( length, FIELD_SHORT ),
-END_BYTESWAP_DATADESC()
-
-//-----------------------------------------------------------------------------
-// Swap a compiled closecaption file
-//-----------------------------------------------------------------------------
-bool SwapClosecaptionFile( void *pData )
-{
- CByteswap swap;
- swap.ActivateByteSwapping( true );
-
- CompiledCaptionHeader_t *pHdr = (CompiledCaptionHeader_t*)pData;
-
- if ( IsX360() )
- {
- // pre-swap file header
- swap.SwapFieldsToTargetEndian( pHdr );
- }
-
- if ( pHdr->magic != COMPILED_CAPTION_FILEID || pHdr->version != COMPILED_CAPTION_VERSION )
- {
- // bad data
- return false;
- }
-
- // lookup headers
- pData = (byte*)pData + sizeof(CompiledCaptionHeader_t);
- swap.SwapFieldsToTargetEndian( (CaptionLookup_t*)pData, pHdr->directorysize );
-
- // unicode data
- pData = (byte*)pHdr + pHdr->dataoffset;
- swap.SwapBufferToTargetEndian( (wchar_t*)pData, (wchar_t*)pData, pHdr->numblocks * pHdr->blocksize / sizeof(wchar_t) );
-
- if ( IsPC() )
- {
- // post-swap file header
- swap.SwapFieldsToTargetEndian( pHdr );
- }
-
- return true;
-}
-
-#if defined( CLIENT_DLL )
-//-----------------------------------------------------------------------------
-// Callback for UpdateOrCreate - generates .360 file
-//-----------------------------------------------------------------------------
-static bool CaptionCreateCallback( const char *pSourceName, const char *pTargetName, const char *pPathID, void *pExtraData )
-{
- // Generate the file
- CUtlBuffer buf;
- bool bOk = g_pFullFileSystem->ReadFile( pSourceName, pPathID, buf );
- if ( bOk )
- {
- bOk = SwapClosecaptionFile( buf.Base() );
- if ( bOk )
- {
- bOk = g_pFullFileSystem->WriteFile( pTargetName, pPathID, buf );
- }
- else
- {
- Warning( "Failed to create %s\n", pTargetName );
- }
- }
- return bOk;
-}
-
-//-----------------------------------------------------------------------------
-// Calls utility function UpdateOrCreate
-//-----------------------------------------------------------------------------
-int UpdateOrCreateCaptionFile( const char *pSourceName, char *pTargetName, int maxLen, bool bForce )
-{
- return ::UpdateOrCreate( pSourceName, pTargetName, maxLen, "GAME", CaptionCreateCallback, bForce );
-}
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Swap a compiled caption file. +// +// $NoKeywords: $ +//=============================================================================// + +#include "utlbuffer.h" +#include "byteswap.h" +#include "filesystem.h" +#include "tier2/fileutils.h" +#include "captioncompiler.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +BEGIN_BYTESWAP_DATADESC( CompiledCaptionHeader_t ) + DEFINE_FIELD( magic, FIELD_INTEGER ), + DEFINE_FIELD( version, FIELD_INTEGER ), + DEFINE_FIELD( numblocks, FIELD_INTEGER ), + DEFINE_FIELD( blocksize, FIELD_INTEGER ), + DEFINE_FIELD( directorysize, FIELD_INTEGER ), + DEFINE_FIELD( dataoffset, FIELD_INTEGER ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( CaptionLookup_t ) + DEFINE_FIELD( hash, FIELD_INTEGER ), + DEFINE_FIELD( blockNum, FIELD_INTEGER ), + DEFINE_FIELD( offset, FIELD_SHORT ), + DEFINE_FIELD( length, FIELD_SHORT ), +END_BYTESWAP_DATADESC() + +//----------------------------------------------------------------------------- +// Swap a compiled closecaption file +//----------------------------------------------------------------------------- +bool SwapClosecaptionFile( void *pData ) +{ + CByteswap swap; + swap.ActivateByteSwapping( true ); + + CompiledCaptionHeader_t *pHdr = (CompiledCaptionHeader_t*)pData; + + if ( IsX360() ) + { + // pre-swap file header + swap.SwapFieldsToTargetEndian( pHdr ); + } + + if ( pHdr->magic != COMPILED_CAPTION_FILEID || pHdr->version != COMPILED_CAPTION_VERSION ) + { + // bad data + return false; + } + + // lookup headers + pData = (byte*)pData + sizeof(CompiledCaptionHeader_t); + swap.SwapFieldsToTargetEndian( (CaptionLookup_t*)pData, pHdr->directorysize ); + + // unicode data + pData = (byte*)pHdr + pHdr->dataoffset; + swap.SwapBufferToTargetEndian( (wchar_t*)pData, (wchar_t*)pData, pHdr->numblocks * pHdr->blocksize / sizeof(wchar_t) ); + + if ( IsPC() ) + { + // post-swap file header + swap.SwapFieldsToTargetEndian( pHdr ); + } + + return true; +} + +#if defined( CLIENT_DLL ) +//----------------------------------------------------------------------------- +// Callback for UpdateOrCreate - generates .360 file +//----------------------------------------------------------------------------- +static bool CaptionCreateCallback( const char *pSourceName, const char *pTargetName, const char *pPathID, void *pExtraData ) +{ + // Generate the file + CUtlBuffer buf; + bool bOk = g_pFullFileSystem->ReadFile( pSourceName, pPathID, buf ); + if ( bOk ) + { + bOk = SwapClosecaptionFile( buf.Base() ); + if ( bOk ) + { + bOk = g_pFullFileSystem->WriteFile( pTargetName, pPathID, buf ); + } + else + { + Warning( "Failed to create %s\n", pTargetName ); + } + } + return bOk; +} + +//----------------------------------------------------------------------------- +// Calls utility function UpdateOrCreate +//----------------------------------------------------------------------------- +int UpdateOrCreateCaptionFile( const char *pSourceName, char *pTargetName, int maxLen, bool bForce ) +{ + return ::UpdateOrCreate( pSourceName, pTargetName, maxLen, "GAME", CaptionCreateCallback, bForce ); +} #endif
\ No newline at end of file diff --git a/mp/src/common/hl2orange.spa.h b/mp/src/common/hl2orange.spa.h index f8feeee6..ad84b655 100644 --- a/mp/src/common/hl2orange.spa.h +++ b/mp/src/common/hl2orange.spa.h @@ -1,370 +1,370 @@ -////////////////////////////////////////////////////////////////////
-//
-// hl2orange.spa.h
-//
-// Auto-generated on Thursday, 13 September 2007 at 16:59:17
-// XLAST project version 1.0.402.0
-// SPA Compiler version 2.0.6274.0
-//
-////////////////////////////////////////////////////////////////////
-
-#ifndef __THE_ORANGE_BOX_SPA_H__
-#define __THE_ORANGE_BOX_SPA_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-//
-// Title info
-//
-
-#define TITLEID_THE_ORANGE_BOX 0x4541080F
-
-//
-// Context ids
-//
-// These values are passed as the dwContextId to XUserSetContext.
-//
-
-#define CONTEXT_CHAPTER_HL2 0
-#define CONTEXT_SCENARIO 1
-#define CONTEXT_GAME 2
-#define CONTEXT_CHAPTER_EP1 3
-#define CONTEXT_CHAPTER_EP2 4
-#define CONTEXT_CHAPTER_PORTAL 5
-
-//
-// Context values
-//
-// These values are passed as the dwContextValue to XUserSetContext.
-//
-
-// Values for CONTEXT_CHAPTER_HL2
-
-#define CONTEXT_CHAPTER_HL2_POINT_INSERTION 0
-#define CONTEXT_CHAPTER_HL2_A_RED_LETTER_DAY 1
-#define CONTEXT_CHAPTER_HL2_ROUTE_KANAL 2
-#define CONTEXT_CHAPTER_HL2_WATER_HAZARD 3
-#define CONTEXT_CHAPTER_HL2_BLACK_MESA_EAST 4
-#define CONTEXT_CHAPTER_HL2_RAVENHOLM 5
-#define CONTEXT_CHAPTER_HL2_HIGHWAY_17 6
-#define CONTEXT_CHAPTER_HL2_SANDTRAPS 7
-#define CONTEXT_CHAPTER_HL2_NOVA_PROSPEKT 8
-#define CONTEXT_CHAPTER_HL2_ENTANGLEMENT 9
-#define CONTEXT_CHAPTER_HL2_ANTICITIZEN_ONE 10
-#define CONTEXT_CHAPTER_HL2_FOLLOW_FREEMAN 11
-#define CONTEXT_CHAPTER_HL2_OUR_BENEFACTORS 12
-#define CONTEXT_CHAPTER_HL2_DARK_ENERGY 13
-
-// Values for CONTEXT_SCENARIO
-
-#define CONTEXT_SCENARIO_CTF_2FORT 0
-#define CONTEXT_SCENARIO_CP_DUSTBOWL 1
-#define CONTEXT_SCENARIO_CP_GRANARY 2
-#define CONTEXT_SCENARIO_CP_WELL 3
-#define CONTEXT_SCENARIO_CP_GRAVELPIT 4
-#define CONTEXT_SCENARIO_TC_HYDRO 5
-#define CONTEXT_SCENARIO_CTF_CLOAK 6
-#define CONTEXT_SCENARIO_CP_CLOAK 7
-
-// Values for CONTEXT_GAME
-
-#define CONTEXT_GAME_GAME_HALF_LIFE_2 0
-#define CONTEXT_GAME_GAME_EPISODE_ONE 1
-#define CONTEXT_GAME_GAME_EPISODE_TWO 2
-#define CONTEXT_GAME_GAME_PORTAL 3
-#define CONTEXT_GAME_GAME_TEAM_FORTRESS 4
-
-// Values for CONTEXT_CHAPTER_EP1
-
-#define CONTEXT_CHAPTER_EP1_UNDUE_ALARM 0
-#define CONTEXT_CHAPTER_EP1_DIRECT_INTERVENTION 1
-#define CONTEXT_CHAPTER_EP1_LOWLIFE 2
-#define CONTEXT_CHAPTER_EP1_URBAN_FLIGHT 3
-#define CONTEXT_CHAPTER_EP1_EXIT_17 4
-
-// Values for CONTEXT_CHAPTER_EP2
-
-#define CONTEXT_CHAPTER_EP2_TO_THE_WHITE_FOREST 0
-#define CONTEXT_CHAPTER_EP2_THIS_VORTAL_COIL 1
-#define CONTEXT_CHAPTER_EP2_FREEMAN_PONTIFEX 2
-#define CONTEXT_CHAPTER_EP2_RIDING_SHOTGUN 3
-#define CONTEXT_CHAPTER_EP2_UNDER_THE_RADAR 4
-#define CONTEXT_CHAPTER_EP2_OUR_MUTUAL_FIEND 5
-#define CONTEXT_CHAPTER_EP2_T_MINUS_ONE 6
-
-// Values for CONTEXT_CHAPTER_PORTAL
-
-#define CONTEXT_CHAPTER_PORTAL_TESTCHAMBER_00 0
-#define CONTEXT_CHAPTER_PORTAL_TESTCHAMBER_04 1
-#define CONTEXT_CHAPTER_PORTAL_TESTCHAMBER_08 2
-#define CONTEXT_CHAPTER_PORTAL_TESTCHAMBER_10 3
-#define CONTEXT_CHAPTER_PORTAL_TESTCHAMBER_13 4
-#define CONTEXT_CHAPTER_PORTAL_TESTCHAMBER_14 5
-#define CONTEXT_CHAPTER_PORTAL_TESTCHAMBER_15 6
-#define CONTEXT_CHAPTER_PORTAL_TESTCHAMBER_16 7
-#define CONTEXT_CHAPTER_PORTAL_TESTCHAMBER_17 8
-#define CONTEXT_CHAPTER_PORTAL_TESTCHAMBER_18 9
-#define CONTEXT_CHAPTER_PORTAL_TESTCHAMBER_19 10
-
-// Values for X_CONTEXT_PRESENCE
-
-#define CONTEXT_PRESENCE_TF_CP 0
-#define CONTEXT_PRESENCE_TF_CTF_LOSING 1
-#define CONTEXT_PRESENCE_TF_CTF_TIED 2
-#define CONTEXT_PRESENCE_TF_CTF_WINNING 3
-#define CONTEXT_PRESENCE_APPCHOOSER 4
-#define CONTEXT_PRESENCE_MENU 5
-#define CONTEXT_PRESENCE_EP1_INGAME 6
-#define CONTEXT_PRESENCE_HL2_INGAME 7
-#define CONTEXT_PRESENCE_EP2_INGAME 8
-#define CONTEXT_PRESENCE_PORTAL_INGAME 9
-#define CONTEXT_PRESENCE_COMMENTARY 10
-#define CONTEXT_PRESENCE_IDLE 11
-
-// Values for X_CONTEXT_GAME_MODE
-
-#define CONTEXT_GAME_MODE_MULTIPLAYER 0
-#define CONTEXT_GAME_MODE_SINGLEPLAYER 1
-
-//
-// Property ids
-//
-// These values are passed as the dwPropertyId value to XUserSetProperty
-// and as the dwPropertyId value in the XUSER_PROPERTY structure.
-//
-
-#define PROPERTY_CAPS_OWNED 0x10000000
-#define PROPERTY_CAPS_TOTAL 0x10000001
-#define PROPERTY_PLAYER_TEAM_SCORE 0x10000002
-#define PROPERTY_OPPONENT_TEAM_SCORE 0x10000003
-#define PROPERTY_FLAG_CAPTURE_LIMIT 0x1000000B
-#define PROPERTY_NUMBER_OF_ROUNDS 0x1000000C
-#define PROPERTY_GAME_SIZE 0x1000000D
-#define PROPERTY_AUTOBALANCE 0x1000000E
-#define PROPERTY_PRIVATE_SLOTS 0x1000000F
-#define PROPERTY_MAX_GAME_TIME 0x10000010
-#define PROPERTY_NUMBER_OF_KILLS 0x10000011
-#define PROPERTY_DAMAGE_DEALT 0x10000012
-#define PROPERTY_PLAY_TIME 0x10000013
-#define PROPERTY_POINT_CAPTURES 0x10000014
-#define PROPERTY_POINT_DEFENSES 0x10000015
-#define PROPERTY_DOMINATIONS 0x10000016
-#define PROPERTY_REVENGE 0x10000017
-#define PROPERTY_BUILDINGS_DESTROYED 0x10000019
-#define PROPERTY_HEADSHOTS 0x1000001A
-#define PROPERTY_HEALTH_POINTS_HEALED 0x1000001B
-#define PROPERTY_INVULNS 0x1000001C
-#define PROPERTY_KILL_ASSISTS 0x1000001D
-#define PROPERTY_BACKSTABS 0x1000001E
-#define PROPERTY_HEALTH_POINTS_LEACHED 0x1000001F
-#define PROPERTY_BUILDINGS_BUILT 0x10000020
-#define PROPERTY_SENTRY_KILLS 0x10000021
-#define PROPERTY_TELEPORTS 0x10000022
-#define PROPERTY_KILLS 0x10000023
-#define PROPERTY_NUMBER_OF_TEAMS 0x10000025
-#define PROPERTY_TEAM_RED 0x10000026
-#define PROPERTY_TEAM_BLUE 0x10000027
-#define PROPERTY_TEAM_SPECTATOR 0x10000028
-#define PROPERTY_TEAM 0x10000029
-#define PROPERTY_WIN_LIMIT 0x1000002A
-#define PROPERTY_RANKING_TEST 0x2000000A
-#define PROPERTY_POINTS_SCORED 0x20000018
-
-//
-// Achievement ids
-//
-// These values are used in the dwAchievementId member of the
-// XUSER_ACHIEVEMENT structure that is used with
-// XUserWriteAchievements and XUserCreateAchievementEnumerator.
-//
-
-#define ACHIEVEMENT_HLX_KILL_ENEMIES_WITHPHYSICS 43
-#define ACHIEVEMENT_HLX_KILL_ENEMY_WITHHOPPERMINE 44
-#define ACHIEVEMENT_HLX_KILL_ENEMIES_WITHMANHACK 45
-#define ACHIEVEMENT_HLX_KILL_SOLDIER_WITHHISGRENADE 46
-#define ACHIEVEMENT_HLX_KILL_ENEMIES_WITHONEENERGYBALL 47
-#define ACHIEVEMENT_HLX_KILL_ELITESOLDIER_WITHHISENERGYBALL 48
-#define ACHIEVEMENT_EPX_GET_ZOMBINEGRENADE 50
-#define ACHIEVEMENT_EPX_KILL_ZOMBIES_WITHFLARES 51
-#define ACHIEVEMENT_HL2_HIT_CANCOP_WITHCAN 52
-#define ACHIEVEMENT_HL2_PUT_CANINTRASH 53
-#define ACHIEVEMENT_HL2_ESCAPE_APARTMENTRAID 54
-#define ACHIEVEMENT_HL2_BREAK_MINITELEPORTER 55
-#define ACHIEVEMENT_HL2_GET_CROWBAR 56
-#define ACHIEVEMENT_HL2_KILL_BARNACLESWITHBARREL 57
-#define ACHIEVEMENT_HL2_GET_AIRBOAT 58
-#define ACHIEVEMENT_HL2_GET_AIRBOATGUN 60
-#define ACHIEVEMENT_HL2_FIND_VORTIGAUNTCAVE 61
-#define ACHIEVEMENT_HL2_KILL_CHOPPER 62
-#define ACHIEVEMENT_HL2_FIND_HEVFACEPLATE 63
-#define ACHIEVEMENT_HL2_GET_GRAVITYGUN 64
-#define ACHIEVEMENT_HL2_MAKEABASKET 65
-#define ACHIEVEMENT_HL2_BEAT_RAVENHOLM_NOWEAPONS 66
-#define ACHIEVEMENT_HL2_BEAT_CEMETERY 67
-#define ACHIEVEMENT_HL2_KILL_ENEMIES_WITHCRANE 68
-#define ACHIEVEMENT_HL2_PIN_SOLDIER_TOBILLBOARD 69
-#define ACHIEVEMENT_HL2_KILL_ODESSAGUNSHIP 70
-#define ACHIEVEMENT_HL2_KILL_THREEGUNSHIPS 71
-#define ACHIEVEMENT_HL2_BEAT_DONTTOUCHSAND 72
-#define ACHIEVEMENT_HL2_KILL_ENEMIES_WITHANTLIONS 74
-#define ACHIEVEMENT_HL2_KILL_ENEMY_WITHTOILET 75
-#define ACHIEVEMENT_HL2_BEAT_TURRETSTANDOFF2 76
-#define ACHIEVEMENT_HL2_BEAT_TOXICTUNNEL 78
-#define ACHIEVEMENT_HL2_BEAT_PLAZASTANDOFF 79
-#define ACHIEVEMENT_HL2_KILL_ALLC1709SNIPERS 80
-#define ACHIEVEMENT_HL2_BEAT_SUPRESSIONDEVICE 81
-#define ACHIEVEMENT_HL2_BEAT_C1713STRIDERSTANDOFF 82
-#define ACHIEVEMENT_HL2_BEAT_GAME 84
-#define ACHIEVEMENT_HL2_FIND_ALLLAMBDAS 86
-#define ACHIEVEMENT_EP1_BEAT_MAINELEVATOR 87
-#define ACHIEVEMENT_EP1_BEAT_CITADELCORE 88
-#define ACHIEVEMENT_EP1_BEAT_CITADELCORE_NOSTALKERKILLS 89
-#define ACHIEVEMENT_EP1_KILL_ANTLIONS_WITHCARS 90
-#define ACHIEVEMENT_EP1_BEAT_GARAGEELEVATORSTANDOFF 91
-#define ACHIEVEMENT_EP1_KILL_ENEMIES_WITHSNIPERALYX 92
-#define ACHIEVEMENT_EP1_BEAT_HOSPITALATTICGUNSHIP 93
-#define ACHIEVEMENT_EP1_BEAT_CITIZENESCORT_NOCITIZENDEATHS 94
-#define ACHIEVEMENT_EP1_BEAT_GAME 95
-#define ACHIEVEMENT_EP1_BEAT_GAME_ONEBULLET 96
-#define ACHIEVEMENT_EP2_KILL_POISONANTLION 97
-#define ACHIEVEMENT_EP2_KILL_ALLGRUBS 98
-#define ACHIEVEMENT_EP2_BREAK_ALLWEBS 99
-#define ACHIEVEMENT_EP2_BEAT_ANTLIONINVASION 100
-#define ACHIEVEMENT_EP2_BEAT_ANTLIONGUARDS 101
-#define ACHIEVEMENT_EP2_KILL_ENEMIES_WITHCAR 102
-#define ACHIEVEMENT_EP2_BEAT_HUNTERAMBUSH 103
-#define ACHIEVEMENT_EP2_KILL_CHOPPER_NOMISSES 104
-#define ACHIEVEMENT_EP2_KILL_COMBINECANNON 105
-#define ACHIEVEMENT_EP2_FIND_ALLRADARCACHES 106
-#define ACHIEVEMENT_EP2_BEAT_ROCKETCACHEPUZZLE 107
-#define ACHIEVEMENT_EP2_BEAT_RACEWITHDOG 108
-#define ACHIEVEMENT_EP2_BEAT_WHITEFORESTINN 109
-#define ACHIEVEMENT_EP2_PUT_ITEMINROCKET 110
-#define ACHIEVEMENT_EP2_BEAT_MISSILESILO2 111
-#define ACHIEVEMENT_EP2_BEAT_OUTLAND12_NOBUILDINGSDESTROYED 112
-#define ACHIEVEMENT_EP2_BEAT_GAME 113
-#define ACHIEVEMENT_EP2_KILL_HUNTER_WITHFLECHETTES 114
-#define ACHIEVEMENT_PORTAL_GET_PORTALGUNS 115
-#define ACHIEVEMENT_PORTAL_KILL_COMPANIONCUBE 116
-#define ACHIEVEMENT_PORTAL_ESCAPE_TESTCHAMBERS 117
-#define ACHIEVEMENT_PORTAL_BEAT_GAME 118
-#define ACHIEVEMENT_PORTAL_INFINITEFALL 119
-#define ACHIEVEMENT_PORTAL_LONGJUMP 120
-#define ACHIEVEMENT_PORTAL_BEAT_2ADVANCEDMAPS 121
-#define ACHIEVEMENT_PORTAL_BEAT_4ADVANCEDMAPS 122
-#define ACHIEVEMENT_PORTAL_BEAT_6ADVANCEDMAPS 123
-#define ACHIEVEMENT_PORTAL_GET_ALLBRONZE 124
-#define ACHIEVEMENT_PORTAL_GET_ALLSILVER 125
-#define ACHIEVEMENT_PORTAL_GET_ALLGOLD 126
-#define ACHIEVEMENT_TF_GET_TURRETKILLS 127
-#define ACHIEVEMENT_TF_KILL_NEMESIS 128
-#define ACHIEVEMENT_TF_GET_CONSECUTIVEKILLS_NODEATHS 129
-#define ACHIEVEMENT_TF_GET_HEALED_BYENEMY 130
-#define ACHIEVEMENT_TF_PLAY_GAME_FRIENDSONLY 131
-#define ACHIEVEMENT_TF_WIN_MULTIPLEGAMES 132
-#define ACHIEVEMENT_TF_GET_MULTIPLEKILLS 133
-#define ACHIEVEMENT_TF_WIN_2FORT_NOENEMYCAPS 134
-#define ACHIEVEMENT_TF_WIN_WELL_MINIMUMTIME 135
-#define ACHIEVEMENT_TF_WIN_HYDRO_NOENEMYCAPS 136
-#define ACHIEVEMENT_TF_WIN_DUSTBOWL_NOENEMYCAPS 137
-#define ACHIEVEMENT_TF_WIN_GRAVELPIT_NOENEMYCAPS 138
-#define ACHIEVEMENT_TF_PLAY_GAME_EVERYCLASS 139
-#define ACHIEVEMENT_TF_PLAY_GAME_EVERYMAP 140
-#define ACHIEVEMENT_TF_GET_HEALPOINTS 141
-#define ACHIEVEMENT_TF_BURN_PLAYERSINMINIMIMTIME 142
-#define ACHIEVEMENT_HL2_DISINTEGRATE_SOLDIERSINFIELD 143
-#define ACHIEVEMENT_HL2_FOLLOW_FREEMAN 144
-#define ACHIEVEMENT_TF_GET_HEADSHOTS 145
-#define ACHIEVEMENT_PORTAL_DETACH_ALL_CAMERAS 146
-#define ACHIEVEMENT_PORTAL_HIT_TURRET_WITH_TURRET 148
-
-#ifndef _XBOX
-#define ACHIEVEMENT_PORTAL_TRANSMISSION_RECEIVED 149
-#define ACHIEVEMENT_TF_GENERAL_KILL_ENEMIES_AFTER_TELEPORTING 150
-#endif // _XBOX
-
-#define ACHIEVEMENT_TF_LAST_ORANGEBOX 150
-
-//
-// Stats view ids
-//
-// These are used in the dwViewId member of the XUSER_STATS_SPEC structure
-// passed to the XUserReadStats* and XUserCreateStatsEnumerator* functions.
-//
-
-// Skill leaderboards for ranked game modes
-
-#define STATS_VIEW_SKILL_RANKED_MULTIPLAYER 0xFFFF0000
-#define STATS_VIEW_SKILL_RANKED_SINGLEPLAYER 0xFFFF0001
-
-// Skill leaderboards for unranked (standard) game modes
-
-#define STATS_VIEW_SKILL_STANDARD_MULTIPLAYER 0xFFFE0000
-#define STATS_VIEW_SKILL_STANDARD_SINGLEPLAYER 0xFFFE0001
-
-// Title defined leaderboards
-
-#define STATS_VIEW_PLAYER_MAX_UNRANKED 1
-#define STATS_VIEW_PLAYER_MAX_RANKED 2
-
-//
-// Stats view column ids
-//
-// These ids are used to read columns of stats views. They are specified in
-// the rgwColumnIds array of the XUSER_STATS_SPEC structure. Rank, rating
-// and gamertag are not retrieved as custom columns and so are not included
-// in the following definitions. They can be retrieved from each row's
-// header (e.g., pStatsResults->pViews[x].pRows[y].dwRank, etc.).
-//
-
-// Column ids for PLAYER_MAX_UNRANKED
-
-#define STATS_COLUMN_PLAYER_MAX_UNRANKED_POINTS_SCORED 2
-#define STATS_COLUMN_PLAYER_MAX_UNRANKED_KILLS 3
-#define STATS_COLUMN_PLAYER_MAX_UNRANKED_POINTS_CAPPED 1
-#define STATS_COLUMN_PLAYER_MAX_UNRANKED_DAMAGE_DEALT 4
-#define STATS_COLUMN_PLAYER_MAX_UNRANKED_PLAY_TIME 5
-#define STATS_COLUMN_PLAYER_MAX_UNRANKED_POINT_DEFENSES 6
-#define STATS_COLUMN_PLAYER_MAX_UNRANKED_DOMINATIONS 7
-#define STATS_COLUMN_PLAYER_MAX_UNRANKED_REVENGE 8
-#define STATS_COLUMN_PLAYER_MAX_UNRANKED_BUILDINGS_DESTROYED 9
-#define STATS_COLUMN_PLAYER_MAX_UNRANKED_HEADSHOTS 10
-#define STATS_COLUMN_PLAYER_MAX_UNRANKED_HEALTH_POINTS_HEALED 11
-#define STATS_COLUMN_PLAYER_MAX_UNRANKED_INVULNS 12
-#define STATS_COLUMN_PLAYER_MAX_UNRANKED_KILL_ASSISTS 13
-#define STATS_COLUMN_PLAYER_MAX_UNRANKED_BACKSTABS 14
-#define STATS_COLUMN_PLAYER_MAX_UNRANKED_HEALTH_POINTS_LEACHED 15
-#define STATS_COLUMN_PLAYER_MAX_UNRANKED_BUILDINGS_BUILT 16
-#define STATS_COLUMN_PLAYER_MAX_UNRANKED_SENTRY_KILLS 17
-#define STATS_COLUMN_PLAYER_MAX_UNRANKED_TELEPORTS 18
-
-// Column ids for PLAYER_MAX_RANKED
-
-#define STATS_COLUMN_PLAYER_MAX_RANKED_POINTS_SCORED 2
-
-//
-// Matchmaking queries
-//
-// These values are passed as the dwProcedureIndex parameter to
-// XSessionSearch to indicate which matchmaking query to run.
-//
-
-#define SESSION_MATCH_QUERY_PLAYER_MATCH 0
-
-//
-// Gamer pictures
-//
-// These ids are passed as the dwPictureId parameter to XUserAwardGamerTile.
-//
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // __THE_ORANGE_BOX_SPA_H__
-
-
+//////////////////////////////////////////////////////////////////// +// +// hl2orange.spa.h +// +// Auto-generated on Thursday, 13 September 2007 at 16:59:17 +// XLAST project version 1.0.402.0 +// SPA Compiler version 2.0.6274.0 +// +//////////////////////////////////////////////////////////////////// + +#ifndef __THE_ORANGE_BOX_SPA_H__ +#define __THE_ORANGE_BOX_SPA_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +// +// Title info +// + +#define TITLEID_THE_ORANGE_BOX 0x4541080F + +// +// Context ids +// +// These values are passed as the dwContextId to XUserSetContext. +// + +#define CONTEXT_CHAPTER_HL2 0 +#define CONTEXT_SCENARIO 1 +#define CONTEXT_GAME 2 +#define CONTEXT_CHAPTER_EP1 3 +#define CONTEXT_CHAPTER_EP2 4 +#define CONTEXT_CHAPTER_PORTAL 5 + +// +// Context values +// +// These values are passed as the dwContextValue to XUserSetContext. +// + +// Values for CONTEXT_CHAPTER_HL2 + +#define CONTEXT_CHAPTER_HL2_POINT_INSERTION 0 +#define CONTEXT_CHAPTER_HL2_A_RED_LETTER_DAY 1 +#define CONTEXT_CHAPTER_HL2_ROUTE_KANAL 2 +#define CONTEXT_CHAPTER_HL2_WATER_HAZARD 3 +#define CONTEXT_CHAPTER_HL2_BLACK_MESA_EAST 4 +#define CONTEXT_CHAPTER_HL2_RAVENHOLM 5 +#define CONTEXT_CHAPTER_HL2_HIGHWAY_17 6 +#define CONTEXT_CHAPTER_HL2_SANDTRAPS 7 +#define CONTEXT_CHAPTER_HL2_NOVA_PROSPEKT 8 +#define CONTEXT_CHAPTER_HL2_ENTANGLEMENT 9 +#define CONTEXT_CHAPTER_HL2_ANTICITIZEN_ONE 10 +#define CONTEXT_CHAPTER_HL2_FOLLOW_FREEMAN 11 +#define CONTEXT_CHAPTER_HL2_OUR_BENEFACTORS 12 +#define CONTEXT_CHAPTER_HL2_DARK_ENERGY 13 + +// Values for CONTEXT_SCENARIO + +#define CONTEXT_SCENARIO_CTF_2FORT 0 +#define CONTEXT_SCENARIO_CP_DUSTBOWL 1 +#define CONTEXT_SCENARIO_CP_GRANARY 2 +#define CONTEXT_SCENARIO_CP_WELL 3 +#define CONTEXT_SCENARIO_CP_GRAVELPIT 4 +#define CONTEXT_SCENARIO_TC_HYDRO 5 +#define CONTEXT_SCENARIO_CTF_CLOAK 6 +#define CONTEXT_SCENARIO_CP_CLOAK 7 + +// Values for CONTEXT_GAME + +#define CONTEXT_GAME_GAME_HALF_LIFE_2 0 +#define CONTEXT_GAME_GAME_EPISODE_ONE 1 +#define CONTEXT_GAME_GAME_EPISODE_TWO 2 +#define CONTEXT_GAME_GAME_PORTAL 3 +#define CONTEXT_GAME_GAME_TEAM_FORTRESS 4 + +// Values for CONTEXT_CHAPTER_EP1 + +#define CONTEXT_CHAPTER_EP1_UNDUE_ALARM 0 +#define CONTEXT_CHAPTER_EP1_DIRECT_INTERVENTION 1 +#define CONTEXT_CHAPTER_EP1_LOWLIFE 2 +#define CONTEXT_CHAPTER_EP1_URBAN_FLIGHT 3 +#define CONTEXT_CHAPTER_EP1_EXIT_17 4 + +// Values for CONTEXT_CHAPTER_EP2 + +#define CONTEXT_CHAPTER_EP2_TO_THE_WHITE_FOREST 0 +#define CONTEXT_CHAPTER_EP2_THIS_VORTAL_COIL 1 +#define CONTEXT_CHAPTER_EP2_FREEMAN_PONTIFEX 2 +#define CONTEXT_CHAPTER_EP2_RIDING_SHOTGUN 3 +#define CONTEXT_CHAPTER_EP2_UNDER_THE_RADAR 4 +#define CONTEXT_CHAPTER_EP2_OUR_MUTUAL_FIEND 5 +#define CONTEXT_CHAPTER_EP2_T_MINUS_ONE 6 + +// Values for CONTEXT_CHAPTER_PORTAL + +#define CONTEXT_CHAPTER_PORTAL_TESTCHAMBER_00 0 +#define CONTEXT_CHAPTER_PORTAL_TESTCHAMBER_04 1 +#define CONTEXT_CHAPTER_PORTAL_TESTCHAMBER_08 2 +#define CONTEXT_CHAPTER_PORTAL_TESTCHAMBER_10 3 +#define CONTEXT_CHAPTER_PORTAL_TESTCHAMBER_13 4 +#define CONTEXT_CHAPTER_PORTAL_TESTCHAMBER_14 5 +#define CONTEXT_CHAPTER_PORTAL_TESTCHAMBER_15 6 +#define CONTEXT_CHAPTER_PORTAL_TESTCHAMBER_16 7 +#define CONTEXT_CHAPTER_PORTAL_TESTCHAMBER_17 8 +#define CONTEXT_CHAPTER_PORTAL_TESTCHAMBER_18 9 +#define CONTEXT_CHAPTER_PORTAL_TESTCHAMBER_19 10 + +// Values for X_CONTEXT_PRESENCE + +#define CONTEXT_PRESENCE_TF_CP 0 +#define CONTEXT_PRESENCE_TF_CTF_LOSING 1 +#define CONTEXT_PRESENCE_TF_CTF_TIED 2 +#define CONTEXT_PRESENCE_TF_CTF_WINNING 3 +#define CONTEXT_PRESENCE_APPCHOOSER 4 +#define CONTEXT_PRESENCE_MENU 5 +#define CONTEXT_PRESENCE_EP1_INGAME 6 +#define CONTEXT_PRESENCE_HL2_INGAME 7 +#define CONTEXT_PRESENCE_EP2_INGAME 8 +#define CONTEXT_PRESENCE_PORTAL_INGAME 9 +#define CONTEXT_PRESENCE_COMMENTARY 10 +#define CONTEXT_PRESENCE_IDLE 11 + +// Values for X_CONTEXT_GAME_MODE + +#define CONTEXT_GAME_MODE_MULTIPLAYER 0 +#define CONTEXT_GAME_MODE_SINGLEPLAYER 1 + +// +// Property ids +// +// These values are passed as the dwPropertyId value to XUserSetProperty +// and as the dwPropertyId value in the XUSER_PROPERTY structure. +// + +#define PROPERTY_CAPS_OWNED 0x10000000 +#define PROPERTY_CAPS_TOTAL 0x10000001 +#define PROPERTY_PLAYER_TEAM_SCORE 0x10000002 +#define PROPERTY_OPPONENT_TEAM_SCORE 0x10000003 +#define PROPERTY_FLAG_CAPTURE_LIMIT 0x1000000B +#define PROPERTY_NUMBER_OF_ROUNDS 0x1000000C +#define PROPERTY_GAME_SIZE 0x1000000D +#define PROPERTY_AUTOBALANCE 0x1000000E +#define PROPERTY_PRIVATE_SLOTS 0x1000000F +#define PROPERTY_MAX_GAME_TIME 0x10000010 +#define PROPERTY_NUMBER_OF_KILLS 0x10000011 +#define PROPERTY_DAMAGE_DEALT 0x10000012 +#define PROPERTY_PLAY_TIME 0x10000013 +#define PROPERTY_POINT_CAPTURES 0x10000014 +#define PROPERTY_POINT_DEFENSES 0x10000015 +#define PROPERTY_DOMINATIONS 0x10000016 +#define PROPERTY_REVENGE 0x10000017 +#define PROPERTY_BUILDINGS_DESTROYED 0x10000019 +#define PROPERTY_HEADSHOTS 0x1000001A +#define PROPERTY_HEALTH_POINTS_HEALED 0x1000001B +#define PROPERTY_INVULNS 0x1000001C +#define PROPERTY_KILL_ASSISTS 0x1000001D +#define PROPERTY_BACKSTABS 0x1000001E +#define PROPERTY_HEALTH_POINTS_LEACHED 0x1000001F +#define PROPERTY_BUILDINGS_BUILT 0x10000020 +#define PROPERTY_SENTRY_KILLS 0x10000021 +#define PROPERTY_TELEPORTS 0x10000022 +#define PROPERTY_KILLS 0x10000023 +#define PROPERTY_NUMBER_OF_TEAMS 0x10000025 +#define PROPERTY_TEAM_RED 0x10000026 +#define PROPERTY_TEAM_BLUE 0x10000027 +#define PROPERTY_TEAM_SPECTATOR 0x10000028 +#define PROPERTY_TEAM 0x10000029 +#define PROPERTY_WIN_LIMIT 0x1000002A +#define PROPERTY_RANKING_TEST 0x2000000A +#define PROPERTY_POINTS_SCORED 0x20000018 + +// +// Achievement ids +// +// These values are used in the dwAchievementId member of the +// XUSER_ACHIEVEMENT structure that is used with +// XUserWriteAchievements and XUserCreateAchievementEnumerator. +// + +#define ACHIEVEMENT_HLX_KILL_ENEMIES_WITHPHYSICS 43 +#define ACHIEVEMENT_HLX_KILL_ENEMY_WITHHOPPERMINE 44 +#define ACHIEVEMENT_HLX_KILL_ENEMIES_WITHMANHACK 45 +#define ACHIEVEMENT_HLX_KILL_SOLDIER_WITHHISGRENADE 46 +#define ACHIEVEMENT_HLX_KILL_ENEMIES_WITHONEENERGYBALL 47 +#define ACHIEVEMENT_HLX_KILL_ELITESOLDIER_WITHHISENERGYBALL 48 +#define ACHIEVEMENT_EPX_GET_ZOMBINEGRENADE 50 +#define ACHIEVEMENT_EPX_KILL_ZOMBIES_WITHFLARES 51 +#define ACHIEVEMENT_HL2_HIT_CANCOP_WITHCAN 52 +#define ACHIEVEMENT_HL2_PUT_CANINTRASH 53 +#define ACHIEVEMENT_HL2_ESCAPE_APARTMENTRAID 54 +#define ACHIEVEMENT_HL2_BREAK_MINITELEPORTER 55 +#define ACHIEVEMENT_HL2_GET_CROWBAR 56 +#define ACHIEVEMENT_HL2_KILL_BARNACLESWITHBARREL 57 +#define ACHIEVEMENT_HL2_GET_AIRBOAT 58 +#define ACHIEVEMENT_HL2_GET_AIRBOATGUN 60 +#define ACHIEVEMENT_HL2_FIND_VORTIGAUNTCAVE 61 +#define ACHIEVEMENT_HL2_KILL_CHOPPER 62 +#define ACHIEVEMENT_HL2_FIND_HEVFACEPLATE 63 +#define ACHIEVEMENT_HL2_GET_GRAVITYGUN 64 +#define ACHIEVEMENT_HL2_MAKEABASKET 65 +#define ACHIEVEMENT_HL2_BEAT_RAVENHOLM_NOWEAPONS 66 +#define ACHIEVEMENT_HL2_BEAT_CEMETERY 67 +#define ACHIEVEMENT_HL2_KILL_ENEMIES_WITHCRANE 68 +#define ACHIEVEMENT_HL2_PIN_SOLDIER_TOBILLBOARD 69 +#define ACHIEVEMENT_HL2_KILL_ODESSAGUNSHIP 70 +#define ACHIEVEMENT_HL2_KILL_THREEGUNSHIPS 71 +#define ACHIEVEMENT_HL2_BEAT_DONTTOUCHSAND 72 +#define ACHIEVEMENT_HL2_KILL_ENEMIES_WITHANTLIONS 74 +#define ACHIEVEMENT_HL2_KILL_ENEMY_WITHTOILET 75 +#define ACHIEVEMENT_HL2_BEAT_TURRETSTANDOFF2 76 +#define ACHIEVEMENT_HL2_BEAT_TOXICTUNNEL 78 +#define ACHIEVEMENT_HL2_BEAT_PLAZASTANDOFF 79 +#define ACHIEVEMENT_HL2_KILL_ALLC1709SNIPERS 80 +#define ACHIEVEMENT_HL2_BEAT_SUPRESSIONDEVICE 81 +#define ACHIEVEMENT_HL2_BEAT_C1713STRIDERSTANDOFF 82 +#define ACHIEVEMENT_HL2_BEAT_GAME 84 +#define ACHIEVEMENT_HL2_FIND_ALLLAMBDAS 86 +#define ACHIEVEMENT_EP1_BEAT_MAINELEVATOR 87 +#define ACHIEVEMENT_EP1_BEAT_CITADELCORE 88 +#define ACHIEVEMENT_EP1_BEAT_CITADELCORE_NOSTALKERKILLS 89 +#define ACHIEVEMENT_EP1_KILL_ANTLIONS_WITHCARS 90 +#define ACHIEVEMENT_EP1_BEAT_GARAGEELEVATORSTANDOFF 91 +#define ACHIEVEMENT_EP1_KILL_ENEMIES_WITHSNIPERALYX 92 +#define ACHIEVEMENT_EP1_BEAT_HOSPITALATTICGUNSHIP 93 +#define ACHIEVEMENT_EP1_BEAT_CITIZENESCORT_NOCITIZENDEATHS 94 +#define ACHIEVEMENT_EP1_BEAT_GAME 95 +#define ACHIEVEMENT_EP1_BEAT_GAME_ONEBULLET 96 +#define ACHIEVEMENT_EP2_KILL_POISONANTLION 97 +#define ACHIEVEMENT_EP2_KILL_ALLGRUBS 98 +#define ACHIEVEMENT_EP2_BREAK_ALLWEBS 99 +#define ACHIEVEMENT_EP2_BEAT_ANTLIONINVASION 100 +#define ACHIEVEMENT_EP2_BEAT_ANTLIONGUARDS 101 +#define ACHIEVEMENT_EP2_KILL_ENEMIES_WITHCAR 102 +#define ACHIEVEMENT_EP2_BEAT_HUNTERAMBUSH 103 +#define ACHIEVEMENT_EP2_KILL_CHOPPER_NOMISSES 104 +#define ACHIEVEMENT_EP2_KILL_COMBINECANNON 105 +#define ACHIEVEMENT_EP2_FIND_ALLRADARCACHES 106 +#define ACHIEVEMENT_EP2_BEAT_ROCKETCACHEPUZZLE 107 +#define ACHIEVEMENT_EP2_BEAT_RACEWITHDOG 108 +#define ACHIEVEMENT_EP2_BEAT_WHITEFORESTINN 109 +#define ACHIEVEMENT_EP2_PUT_ITEMINROCKET 110 +#define ACHIEVEMENT_EP2_BEAT_MISSILESILO2 111 +#define ACHIEVEMENT_EP2_BEAT_OUTLAND12_NOBUILDINGSDESTROYED 112 +#define ACHIEVEMENT_EP2_BEAT_GAME 113 +#define ACHIEVEMENT_EP2_KILL_HUNTER_WITHFLECHETTES 114 +#define ACHIEVEMENT_PORTAL_GET_PORTALGUNS 115 +#define ACHIEVEMENT_PORTAL_KILL_COMPANIONCUBE 116 +#define ACHIEVEMENT_PORTAL_ESCAPE_TESTCHAMBERS 117 +#define ACHIEVEMENT_PORTAL_BEAT_GAME 118 +#define ACHIEVEMENT_PORTAL_INFINITEFALL 119 +#define ACHIEVEMENT_PORTAL_LONGJUMP 120 +#define ACHIEVEMENT_PORTAL_BEAT_2ADVANCEDMAPS 121 +#define ACHIEVEMENT_PORTAL_BEAT_4ADVANCEDMAPS 122 +#define ACHIEVEMENT_PORTAL_BEAT_6ADVANCEDMAPS 123 +#define ACHIEVEMENT_PORTAL_GET_ALLBRONZE 124 +#define ACHIEVEMENT_PORTAL_GET_ALLSILVER 125 +#define ACHIEVEMENT_PORTAL_GET_ALLGOLD 126 +#define ACHIEVEMENT_TF_GET_TURRETKILLS 127 +#define ACHIEVEMENT_TF_KILL_NEMESIS 128 +#define ACHIEVEMENT_TF_GET_CONSECUTIVEKILLS_NODEATHS 129 +#define ACHIEVEMENT_TF_GET_HEALED_BYENEMY 130 +#define ACHIEVEMENT_TF_PLAY_GAME_FRIENDSONLY 131 +#define ACHIEVEMENT_TF_WIN_MULTIPLEGAMES 132 +#define ACHIEVEMENT_TF_GET_MULTIPLEKILLS 133 +#define ACHIEVEMENT_TF_WIN_2FORT_NOENEMYCAPS 134 +#define ACHIEVEMENT_TF_WIN_WELL_MINIMUMTIME 135 +#define ACHIEVEMENT_TF_WIN_HYDRO_NOENEMYCAPS 136 +#define ACHIEVEMENT_TF_WIN_DUSTBOWL_NOENEMYCAPS 137 +#define ACHIEVEMENT_TF_WIN_GRAVELPIT_NOENEMYCAPS 138 +#define ACHIEVEMENT_TF_PLAY_GAME_EVERYCLASS 139 +#define ACHIEVEMENT_TF_PLAY_GAME_EVERYMAP 140 +#define ACHIEVEMENT_TF_GET_HEALPOINTS 141 +#define ACHIEVEMENT_TF_BURN_PLAYERSINMINIMIMTIME 142 +#define ACHIEVEMENT_HL2_DISINTEGRATE_SOLDIERSINFIELD 143 +#define ACHIEVEMENT_HL2_FOLLOW_FREEMAN 144 +#define ACHIEVEMENT_TF_GET_HEADSHOTS 145 +#define ACHIEVEMENT_PORTAL_DETACH_ALL_CAMERAS 146 +#define ACHIEVEMENT_PORTAL_HIT_TURRET_WITH_TURRET 148 + +#ifndef _XBOX +#define ACHIEVEMENT_PORTAL_TRANSMISSION_RECEIVED 149 +#define ACHIEVEMENT_TF_GENERAL_KILL_ENEMIES_AFTER_TELEPORTING 150 +#endif // _XBOX + +#define ACHIEVEMENT_TF_LAST_ORANGEBOX 150 + +// +// Stats view ids +// +// These are used in the dwViewId member of the XUSER_STATS_SPEC structure +// passed to the XUserReadStats* and XUserCreateStatsEnumerator* functions. +// + +// Skill leaderboards for ranked game modes + +#define STATS_VIEW_SKILL_RANKED_MULTIPLAYER 0xFFFF0000 +#define STATS_VIEW_SKILL_RANKED_SINGLEPLAYER 0xFFFF0001 + +// Skill leaderboards for unranked (standard) game modes + +#define STATS_VIEW_SKILL_STANDARD_MULTIPLAYER 0xFFFE0000 +#define STATS_VIEW_SKILL_STANDARD_SINGLEPLAYER 0xFFFE0001 + +// Title defined leaderboards + +#define STATS_VIEW_PLAYER_MAX_UNRANKED 1 +#define STATS_VIEW_PLAYER_MAX_RANKED 2 + +// +// Stats view column ids +// +// These ids are used to read columns of stats views. They are specified in +// the rgwColumnIds array of the XUSER_STATS_SPEC structure. Rank, rating +// and gamertag are not retrieved as custom columns and so are not included +// in the following definitions. They can be retrieved from each row's +// header (e.g., pStatsResults->pViews[x].pRows[y].dwRank, etc.). +// + +// Column ids for PLAYER_MAX_UNRANKED + +#define STATS_COLUMN_PLAYER_MAX_UNRANKED_POINTS_SCORED 2 +#define STATS_COLUMN_PLAYER_MAX_UNRANKED_KILLS 3 +#define STATS_COLUMN_PLAYER_MAX_UNRANKED_POINTS_CAPPED 1 +#define STATS_COLUMN_PLAYER_MAX_UNRANKED_DAMAGE_DEALT 4 +#define STATS_COLUMN_PLAYER_MAX_UNRANKED_PLAY_TIME 5 +#define STATS_COLUMN_PLAYER_MAX_UNRANKED_POINT_DEFENSES 6 +#define STATS_COLUMN_PLAYER_MAX_UNRANKED_DOMINATIONS 7 +#define STATS_COLUMN_PLAYER_MAX_UNRANKED_REVENGE 8 +#define STATS_COLUMN_PLAYER_MAX_UNRANKED_BUILDINGS_DESTROYED 9 +#define STATS_COLUMN_PLAYER_MAX_UNRANKED_HEADSHOTS 10 +#define STATS_COLUMN_PLAYER_MAX_UNRANKED_HEALTH_POINTS_HEALED 11 +#define STATS_COLUMN_PLAYER_MAX_UNRANKED_INVULNS 12 +#define STATS_COLUMN_PLAYER_MAX_UNRANKED_KILL_ASSISTS 13 +#define STATS_COLUMN_PLAYER_MAX_UNRANKED_BACKSTABS 14 +#define STATS_COLUMN_PLAYER_MAX_UNRANKED_HEALTH_POINTS_LEACHED 15 +#define STATS_COLUMN_PLAYER_MAX_UNRANKED_BUILDINGS_BUILT 16 +#define STATS_COLUMN_PLAYER_MAX_UNRANKED_SENTRY_KILLS 17 +#define STATS_COLUMN_PLAYER_MAX_UNRANKED_TELEPORTS 18 + +// Column ids for PLAYER_MAX_RANKED + +#define STATS_COLUMN_PLAYER_MAX_RANKED_POINTS_SCORED 2 + +// +// Matchmaking queries +// +// These values are passed as the dwProcedureIndex parameter to +// XSessionSearch to indicate which matchmaking query to run. +// + +#define SESSION_MATCH_QUERY_PLAYER_MATCH 0 + +// +// Gamer pictures +// +// These ids are passed as the dwPictureId parameter to XUserAwardGamerTile. +// + + + +#ifdef __cplusplus +} +#endif + +#endif // __THE_ORANGE_BOX_SPA_H__ + + diff --git a/mp/src/common/language.cpp b/mp/src/common/language.cpp index 7053601b..16aeda32 100644 --- a/mp/src/common/language.cpp +++ b/mp/src/common/language.cpp @@ -1,217 +1,217 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose: languages definition
-//
-//=============================================================================
-
-#include "language.h"
-#include "tier0/dbg.h"
-#include "tier1/strtools.h"
-
-// NOTE: This has to be the last file included!
-#include "tier0/memdbgon.h"
-
-
-struct Language_t
-{
- const char *m_pchName;
- const char *m_pchShortName;
- const char *m_pchVGUILocalizationName;
- const char *m_pchICUName; // used by osx; ISO-639-1 + ISO-3166-1 alpha-2. http://userguide.icu-project.org/locale/examples
- ELanguage m_ELanguage;
- int m_LanguageCodeID;
-};
-
-
-// REVIEW
-// es_ES - use new world spanish country code instead?
-// zh_CN - validate that SC date formats come through
-// bt_BR - assume we should use Brazilian rather than Iberian portguese
-
-static const Language_t s_LanguageNames[] =
-{
- { "None", "none", "None", "none", k_Lang_None, 0 },
- { "English", "english", "#GameUI_Language_English", "en_US", k_Lang_English, 1033 },
- { "German", "german", "#GameUI_Language_German", "de_DE", k_Lang_German, 1031 } ,
- { "French", "french", "#GameUI_Language_French", "fr_FR", k_Lang_French, 1036 } ,
- { "Italian", "italian", "#GameUI_Language_Italian", "it_IT", k_Lang_Italian, 1040 } ,
- { "Korean", "koreana", "#GameUI_Language_Korean", "ko_KR", k_Lang_Korean, 1042 } ,
- { "Spanish", "spanish", "#GameUI_Language_Spanish", "es_ES", k_Lang_Spanish, 1034 },
- { "Simplified_Chinese", "schinese", "#GameUI_Language_Simplified_Chinese", "zh_CN", k_Lang_Simplified_Chinese, 2052 },
- { "Traditional_Chinese", "tchinese", "#GameUI_Language_Traditional_Chinese", "zh_TW", k_Lang_Traditional_Chinese, 1028 },
- { "Russian", "russian", "#GameUI_Language_Russian", "ru_RU", k_Lang_Russian, 1049 } ,
- { "Thai", "thai", "#GameUI_Language_Thai", "th_TH", k_Lang_Thai, 1054 } ,
- { "Japanese", "japanese", "#GameUI_Language_Japanese", "ja_JP", k_Lang_Japanese, 1041 } ,
- { "Portuguese", "portuguese", "#GameUI_Language_Portuguese", "pt_PT", k_Lang_Portuguese, 2070 } ,
- { "Polish", "polish", "#GameUI_Language_Polish", "pl_PL", k_Lang_Polish, 1045 } ,
- { "Danish", "danish", "#GameUI_Language_Danish", "da_DK", k_Lang_Danish, 1030 } ,
- { "Dutch", "dutch", "#GameUI_Language_Dutch", "nl_NL", k_Lang_Dutch, 1043 } ,
- { "Finnish", "finnish", "#GameUI_Language_Finnish", "fi_FI", k_Lang_Finnish, 1035 } ,
- { "Norwegian", "norwegian", "#GameUI_Language_Norwegian", "no_NO", k_Lang_Norwegian, 1044 } ,
- { "Swedish", "swedish", "#GameUI_Language_Swedish", "sv_SE", k_Lang_Swedish, 1053 } ,
- { "Romanian", "romanian", "#GameUI_Language_Romanian", "ro_RO", k_Lang_Romanian, 1048 } ,
- { "Turkish", "turkish", "#GameUI_Language_Turkish", "tr_TR", k_Lang_Turkish, 1055 } ,
- { "Hungarian", "hungarian", "#GameUI_Language_Hungarian", "hu_HU", k_Lang_Hungarian, 1038 } ,
- { "Czech", "czech", "#GameUI_Language_Czech", "cs_CZ", k_Lang_Czech, 1029 } ,
- { "Brazilian", "brazilian", "#GameUI_Language_Brazilian", "pt_BR", k_Lang_Brazilian, 1046 } ,
- { "Bulgarian", "bulgarian", "#GameUI_Language_Bulgarian", "bg_BG", k_Lang_Bulgarian, 1026 } ,
- { "Greek", "greek", "#GameUI_Language_Greek", "el_GR", k_Lang_Greek, 1032 },
-};
-
-//-----------------------------------------------------------------------------
-// Purpose: translate language enum into closests windows language code ID
-//-----------------------------------------------------------------------------
-int GetLanguageCodeID(ELanguage eLang)
-{
- for ( uint iLang = 0; iLang < Q_ARRAYSIZE(s_LanguageNames); ++iLang )
- {
- if ( s_LanguageNames[iLang].m_ELanguage == eLang )
- return s_LanguageNames[iLang].m_LanguageCodeID;
- }
-
- // default to English
- return 1033;
-}
-
-//-----------------------------------------------------------------------------
-// Purpose: find the language by name
-//-----------------------------------------------------------------------------
-ELanguage PchLanguageToELanguage( const char *pchShortName, ELanguage eDefault )
-{
- Assert( Q_ARRAYSIZE(s_LanguageNames) == k_Lang_MAX + 1 );
- if ( !pchShortName )
- return eDefault;
-
- for ( uint iLang = 0; iLang < Q_ARRAYSIZE(s_LanguageNames); ++iLang )
- {
- if ( !Q_stricmp( pchShortName, s_LanguageNames[iLang].m_pchShortName ) )
- {
- return s_LanguageNames[iLang].m_ELanguage;
- }
- }
-
- // return default
- return eDefault;
-}
-
-//-----------------------------------------------------------------------------
-// Purpose: find the language by ICU short code
-//-----------------------------------------------------------------------------
-ELanguage PchLanguageICUCodeToELanguage( const char *pchICUCode, ELanguage eDefault )
-{
- Assert( Q_ARRAYSIZE(s_LanguageNames) == k_Lang_MAX + 1 );
- if ( !pchICUCode )
- return eDefault;
-
- // Match to no more than the param length so either a short 'en' or
- // full 'zh-Hant' can match
- int nLen = Q_strlen( pchICUCode );
-
- // we only have 5 character ICU codes so this should be enough room
- char rchCleanedCode[ 6 ];
- Q_strncpy( rchCleanedCode, pchICUCode, Q_ARRAYSIZE( rchCleanedCode ) );
- if( nLen >= 3 && rchCleanedCode[ 2 ] == '-' )
- {
- rchCleanedCode[ 2 ] = '_';
- }
-
- for ( uint iLang = 0; iLang < Q_ARRAYSIZE(s_LanguageNames); ++iLang )
- {
- if ( !Q_strnicmp( rchCleanedCode, s_LanguageNames[iLang].m_pchICUName, nLen ) )
- {
- return s_LanguageNames[iLang].m_ELanguage;
- }
- }
-
- // return default
- return eDefault;
-}
-
-
-//-----------------------------------------------------------------------------
-// Purpose: return the short string name used for this language by SteamUI
-//-----------------------------------------------------------------------------
-const char *GetLanguageShortName( ELanguage eLang )
-{
- COMPILE_TIME_ASSERT( Q_ARRAYSIZE(s_LanguageNames) == k_Lang_MAX + 1 );
- if ( s_LanguageNames[ eLang + 1 ].m_ELanguage == eLang )
- {
- Assert( eLang + 1 < ARRAYSIZE(s_LanguageNames) );
- return s_LanguageNames[ eLang + 1 ].m_pchShortName;
- }
-
- Assert( !"enum ELanguage order mismatched from Language_t s_LanguageNames, fix it!" );
- return s_LanguageNames[0].m_pchShortName;
-}
-
-//-----------------------------------------------------------------------------
-// Purpose: return the ICU code used for this language by SteamUI
-//-----------------------------------------------------------------------------
-const char *GetLanguageICUName( ELanguage eLang )
-{
- COMPILE_TIME_ASSERT( Q_ARRAYSIZE(s_LanguageNames) == k_Lang_MAX + 1 );
- if ( s_LanguageNames[ eLang + 1 ].m_ELanguage == eLang )
- {
- Assert( eLang + 1 < ARRAYSIZE(s_LanguageNames) );
- return s_LanguageNames[ eLang + 1 ].m_pchICUName;
- }
-
- Assert( !"enum ELanguage order mismatched from Language_t s_LanguageNames, fix it!" );
- return s_LanguageNames[0].m_pchICUName;
-}
-
-//-----------------------------------------------------------------------------
-// Purpose: return the CLocale name that works with setlocale()
-//-----------------------------------------------------------------------------
-const char *GetLangugeCLocaleName( ELanguage eLang )
-{
- if ( eLang == k_Lang_None )
- return "";
-
-#ifdef _WIN32
- // table for Win32 is here: http://msdn.microsoft.com/en-us/library/hzz3tw78(v=VS.80).aspx
- // shortname works except for chinese
-
- switch ( eLang )
- {
- case k_Lang_Simplified_Chinese:
- return "chs"; // or "chinese-simplified"
- case k_Lang_Traditional_Chinese:
- return "cht"; // or "chinese-traditional"
- case k_Lang_Korean:
- return "korean"; // steam likes "koreana" for the name for some reason.
- default:
- return GetLanguageShortName( eLang );
- }
-
-#else
- switch ( eLang )
- {
- case k_Lang_Simplified_Chinese:
- case k_Lang_Traditional_Chinese:
- return "zh_CN";
- default:
- ;
- }
-
- // ICU codes work on linux/osx
- return GetLanguageICUName( eLang );
-#endif
-}
-
-//-----------------------------------------------------------------------------
-// Purpose: return the short string name used for this language by SteamUI
-//-----------------------------------------------------------------------------
-const char *GetLanguageVGUILocalization( ELanguage eLang )
-{
- COMPILE_TIME_ASSERT( Q_ARRAYSIZE(s_LanguageNames) == k_Lang_MAX + 1 );
- if ( s_LanguageNames[ eLang + 1 ].m_ELanguage == eLang )
- {
- Assert( eLang + 1 < ARRAYSIZE(s_LanguageNames) );
- return s_LanguageNames[ eLang + 1 ].m_pchVGUILocalizationName;
- }
-
- Assert( !"enum ELanguage order mismatched from Language_t s_LanguageNames, fix it!" );
- return s_LanguageNames[0].m_pchVGUILocalizationName;
-}
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: languages definition +// +//============================================================================= + +#include "language.h" +#include "tier0/dbg.h" +#include "tier1/strtools.h" + +// NOTE: This has to be the last file included! +#include "tier0/memdbgon.h" + + +struct Language_t +{ + const char *m_pchName; + const char *m_pchShortName; + const char *m_pchVGUILocalizationName; + const char *m_pchICUName; // used by osx; ISO-639-1 + ISO-3166-1 alpha-2. http://userguide.icu-project.org/locale/examples + ELanguage m_ELanguage; + int m_LanguageCodeID; +}; + + +// REVIEW +// es_ES - use new world spanish country code instead? +// zh_CN - validate that SC date formats come through +// bt_BR - assume we should use Brazilian rather than Iberian portguese + +static const Language_t s_LanguageNames[] = +{ + { "None", "none", "None", "none", k_Lang_None, 0 }, + { "English", "english", "#GameUI_Language_English", "en_US", k_Lang_English, 1033 }, + { "German", "german", "#GameUI_Language_German", "de_DE", k_Lang_German, 1031 } , + { "French", "french", "#GameUI_Language_French", "fr_FR", k_Lang_French, 1036 } , + { "Italian", "italian", "#GameUI_Language_Italian", "it_IT", k_Lang_Italian, 1040 } , + { "Korean", "koreana", "#GameUI_Language_Korean", "ko_KR", k_Lang_Korean, 1042 } , + { "Spanish", "spanish", "#GameUI_Language_Spanish", "es_ES", k_Lang_Spanish, 1034 }, + { "Simplified_Chinese", "schinese", "#GameUI_Language_Simplified_Chinese", "zh_CN", k_Lang_Simplified_Chinese, 2052 }, + { "Traditional_Chinese", "tchinese", "#GameUI_Language_Traditional_Chinese", "zh_TW", k_Lang_Traditional_Chinese, 1028 }, + { "Russian", "russian", "#GameUI_Language_Russian", "ru_RU", k_Lang_Russian, 1049 } , + { "Thai", "thai", "#GameUI_Language_Thai", "th_TH", k_Lang_Thai, 1054 } , + { "Japanese", "japanese", "#GameUI_Language_Japanese", "ja_JP", k_Lang_Japanese, 1041 } , + { "Portuguese", "portuguese", "#GameUI_Language_Portuguese", "pt_PT", k_Lang_Portuguese, 2070 } , + { "Polish", "polish", "#GameUI_Language_Polish", "pl_PL", k_Lang_Polish, 1045 } , + { "Danish", "danish", "#GameUI_Language_Danish", "da_DK", k_Lang_Danish, 1030 } , + { "Dutch", "dutch", "#GameUI_Language_Dutch", "nl_NL", k_Lang_Dutch, 1043 } , + { "Finnish", "finnish", "#GameUI_Language_Finnish", "fi_FI", k_Lang_Finnish, 1035 } , + { "Norwegian", "norwegian", "#GameUI_Language_Norwegian", "no_NO", k_Lang_Norwegian, 1044 } , + { "Swedish", "swedish", "#GameUI_Language_Swedish", "sv_SE", k_Lang_Swedish, 1053 } , + { "Romanian", "romanian", "#GameUI_Language_Romanian", "ro_RO", k_Lang_Romanian, 1048 } , + { "Turkish", "turkish", "#GameUI_Language_Turkish", "tr_TR", k_Lang_Turkish, 1055 } , + { "Hungarian", "hungarian", "#GameUI_Language_Hungarian", "hu_HU", k_Lang_Hungarian, 1038 } , + { "Czech", "czech", "#GameUI_Language_Czech", "cs_CZ", k_Lang_Czech, 1029 } , + { "Brazilian", "brazilian", "#GameUI_Language_Brazilian", "pt_BR", k_Lang_Brazilian, 1046 } , + { "Bulgarian", "bulgarian", "#GameUI_Language_Bulgarian", "bg_BG", k_Lang_Bulgarian, 1026 } , + { "Greek", "greek", "#GameUI_Language_Greek", "el_GR", k_Lang_Greek, 1032 }, +}; + +//----------------------------------------------------------------------------- +// Purpose: translate language enum into closests windows language code ID +//----------------------------------------------------------------------------- +int GetLanguageCodeID(ELanguage eLang) +{ + for ( uint iLang = 0; iLang < Q_ARRAYSIZE(s_LanguageNames); ++iLang ) + { + if ( s_LanguageNames[iLang].m_ELanguage == eLang ) + return s_LanguageNames[iLang].m_LanguageCodeID; + } + + // default to English + return 1033; +} + +//----------------------------------------------------------------------------- +// Purpose: find the language by name +//----------------------------------------------------------------------------- +ELanguage PchLanguageToELanguage( const char *pchShortName, ELanguage eDefault ) +{ + Assert( Q_ARRAYSIZE(s_LanguageNames) == k_Lang_MAX + 1 ); + if ( !pchShortName ) + return eDefault; + + for ( uint iLang = 0; iLang < Q_ARRAYSIZE(s_LanguageNames); ++iLang ) + { + if ( !Q_stricmp( pchShortName, s_LanguageNames[iLang].m_pchShortName ) ) + { + return s_LanguageNames[iLang].m_ELanguage; + } + } + + // return default + return eDefault; +} + +//----------------------------------------------------------------------------- +// Purpose: find the language by ICU short code +//----------------------------------------------------------------------------- +ELanguage PchLanguageICUCodeToELanguage( const char *pchICUCode, ELanguage eDefault ) +{ + Assert( Q_ARRAYSIZE(s_LanguageNames) == k_Lang_MAX + 1 ); + if ( !pchICUCode ) + return eDefault; + + // Match to no more than the param length so either a short 'en' or + // full 'zh-Hant' can match + int nLen = Q_strlen( pchICUCode ); + + // we only have 5 character ICU codes so this should be enough room + char rchCleanedCode[ 6 ]; + Q_strncpy( rchCleanedCode, pchICUCode, Q_ARRAYSIZE( rchCleanedCode ) ); + if( nLen >= 3 && rchCleanedCode[ 2 ] == '-' ) + { + rchCleanedCode[ 2 ] = '_'; + } + + for ( uint iLang = 0; iLang < Q_ARRAYSIZE(s_LanguageNames); ++iLang ) + { + if ( !Q_strnicmp( rchCleanedCode, s_LanguageNames[iLang].m_pchICUName, nLen ) ) + { + return s_LanguageNames[iLang].m_ELanguage; + } + } + + // return default + return eDefault; +} + + +//----------------------------------------------------------------------------- +// Purpose: return the short string name used for this language by SteamUI +//----------------------------------------------------------------------------- +const char *GetLanguageShortName( ELanguage eLang ) +{ + COMPILE_TIME_ASSERT( Q_ARRAYSIZE(s_LanguageNames) == k_Lang_MAX + 1 ); + if ( s_LanguageNames[ eLang + 1 ].m_ELanguage == eLang ) + { + Assert( eLang + 1 < ARRAYSIZE(s_LanguageNames) ); + return s_LanguageNames[ eLang + 1 ].m_pchShortName; + } + + Assert( !"enum ELanguage order mismatched from Language_t s_LanguageNames, fix it!" ); + return s_LanguageNames[0].m_pchShortName; +} + +//----------------------------------------------------------------------------- +// Purpose: return the ICU code used for this language by SteamUI +//----------------------------------------------------------------------------- +const char *GetLanguageICUName( ELanguage eLang ) +{ + COMPILE_TIME_ASSERT( Q_ARRAYSIZE(s_LanguageNames) == k_Lang_MAX + 1 ); + if ( s_LanguageNames[ eLang + 1 ].m_ELanguage == eLang ) + { + Assert( eLang + 1 < ARRAYSIZE(s_LanguageNames) ); + return s_LanguageNames[ eLang + 1 ].m_pchICUName; + } + + Assert( !"enum ELanguage order mismatched from Language_t s_LanguageNames, fix it!" ); + return s_LanguageNames[0].m_pchICUName; +} + +//----------------------------------------------------------------------------- +// Purpose: return the CLocale name that works with setlocale() +//----------------------------------------------------------------------------- +const char *GetLangugeCLocaleName( ELanguage eLang ) +{ + if ( eLang == k_Lang_None ) + return ""; + +#ifdef _WIN32 + // table for Win32 is here: http://msdn.microsoft.com/en-us/library/hzz3tw78(v=VS.80).aspx + // shortname works except for chinese + + switch ( eLang ) + { + case k_Lang_Simplified_Chinese: + return "chs"; // or "chinese-simplified" + case k_Lang_Traditional_Chinese: + return "cht"; // or "chinese-traditional" + case k_Lang_Korean: + return "korean"; // steam likes "koreana" for the name for some reason. + default: + return GetLanguageShortName( eLang ); + } + +#else + switch ( eLang ) + { + case k_Lang_Simplified_Chinese: + case k_Lang_Traditional_Chinese: + return "zh_CN"; + default: + ; + } + + // ICU codes work on linux/osx + return GetLanguageICUName( eLang ); +#endif +} + +//----------------------------------------------------------------------------- +// Purpose: return the short string name used for this language by SteamUI +//----------------------------------------------------------------------------- +const char *GetLanguageVGUILocalization( ELanguage eLang ) +{ + COMPILE_TIME_ASSERT( Q_ARRAYSIZE(s_LanguageNames) == k_Lang_MAX + 1 ); + if ( s_LanguageNames[ eLang + 1 ].m_ELanguage == eLang ) + { + Assert( eLang + 1 < ARRAYSIZE(s_LanguageNames) ); + return s_LanguageNames[ eLang + 1 ].m_pchVGUILocalizationName; + } + + Assert( !"enum ELanguage order mismatched from Language_t s_LanguageNames, fix it!" ); + return s_LanguageNames[0].m_pchVGUILocalizationName; +} + diff --git a/mp/src/common/language.h b/mp/src/common/language.h index 7ccc4562..2337c236 100644 --- a/mp/src/common/language.h +++ b/mp/src/common/language.h @@ -1,55 +1,55 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose: represent a canonical list of the languages we support,
-//
-//=============================================================================
-
-#ifndef LANG_H
-#define LANG_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-// if you change this enum also change language.cpp:s_LanguageNames
-enum ELanguage
-{
- k_Lang_None = -1,
- k_Lang_First = 0,
- k_Lang_English = 0,
- k_Lang_German,
- k_Lang_French,
- k_Lang_Italian,
- k_Lang_Korean,
- k_Lang_Spanish,
- k_Lang_Simplified_Chinese,
- k_Lang_Traditional_Chinese,
- k_Lang_Russian,
- k_Lang_Thai,
- k_Lang_Japanese,
- k_Lang_Portuguese,
- k_Lang_Polish,
- k_Lang_Danish,
- k_Lang_Dutch,
- k_Lang_Finnish,
- k_Lang_Norwegian,
- k_Lang_Swedish,
- k_Lang_Romanian,
- k_Lang_Turkish,
- k_Lang_Hungarian,
- k_Lang_Czech,
- k_Lang_Brazilian,
- k_Lang_Bulgarian,
- k_Lang_Greek,
- k_Lang_MAX
-};
-
-#define FOR_EACH_LANGUAGE( eLang ) for ( int eLang = (int)k_Lang_First; eLang < k_Lang_MAX; ++eLang )
-
-ELanguage PchLanguageToELanguage(const char *pchShortName, ELanguage eDefault = k_Lang_English);
-ELanguage PchLanguageICUCodeToELanguage( const char *pchICUCode, ELanguage eDefault = k_Lang_English );
-const char *GetLanguageShortName( ELanguage eLang );
-const char *GetLanguageICUName( ELanguage eLang );
-const char *GetLanguageVGUILocalization( ELanguage eLang );
-const char *GetLanguageName( ELanguage eLang );
-
-#endif /* LANG_H */
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: represent a canonical list of the languages we support, +// +//============================================================================= + +#ifndef LANG_H +#define LANG_H +#ifdef _WIN32 +#pragma once +#endif + +// if you change this enum also change language.cpp:s_LanguageNames +enum ELanguage +{ + k_Lang_None = -1, + k_Lang_First = 0, + k_Lang_English = 0, + k_Lang_German, + k_Lang_French, + k_Lang_Italian, + k_Lang_Korean, + k_Lang_Spanish, + k_Lang_Simplified_Chinese, + k_Lang_Traditional_Chinese, + k_Lang_Russian, + k_Lang_Thai, + k_Lang_Japanese, + k_Lang_Portuguese, + k_Lang_Polish, + k_Lang_Danish, + k_Lang_Dutch, + k_Lang_Finnish, + k_Lang_Norwegian, + k_Lang_Swedish, + k_Lang_Romanian, + k_Lang_Turkish, + k_Lang_Hungarian, + k_Lang_Czech, + k_Lang_Brazilian, + k_Lang_Bulgarian, + k_Lang_Greek, + k_Lang_MAX +}; + +#define FOR_EACH_LANGUAGE( eLang ) for ( int eLang = (int)k_Lang_First; eLang < k_Lang_MAX; ++eLang ) + +ELanguage PchLanguageToELanguage(const char *pchShortName, ELanguage eDefault = k_Lang_English); +ELanguage PchLanguageICUCodeToELanguage( const char *pchICUCode, ELanguage eDefault = k_Lang_English ); +const char *GetLanguageShortName( ELanguage eLang ); +const char *GetLanguageICUName( ELanguage eLang ); +const char *GetLanguageVGUILocalization( ELanguage eLang ); +const char *GetLanguageName( ELanguage eLang ); + +#endif /* LANG_H */ diff --git a/mp/src/common/proto_version.h b/mp/src/common/proto_version.h index e9ccfe1d..c4e7ca04 100644 --- a/mp/src/common/proto_version.h +++ b/mp/src/common/proto_version.h @@ -1,49 +1,49 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//
-//=============================================================================//
-#if !defined( PROTO_VERSION_H )
-#define PROTO_VERSION_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-// The current network protocol version. Changing this makes clients and servers incompatible
-#define PROTOCOL_VERSION 24
-
-#define DEMO_BACKWARDCOMPATABILITY
-
-// For backward compatibility of demo files (NET_MAX_PAYLOAD_BITS went away)
-#define PROTOCOL_VERSION_23 23
-
-// For backward compatibility of demo files (sound index bits used to = 13 )
-#define PROTOCOL_VERSION_22 22
-
-// For backward compatibility of demo files (before the special DSP was shipped to public)
-#define PROTOCOL_VERSION_21 21
-
-// For backward compatibility of demo files (old-style dynamic model loading)
-#define PROTOCOL_VERSION_20 20
-
-// For backward compatibility of demo files (post Halloween sound flag extra bit)
-#define PROTOCOL_VERSION_19 19
-
-// For backward compatibility of demo files (pre Halloween sound flag extra bit)
-#define PROTOCOL_VERSION_18 18
-
-// For backward compatibility of demo files (MD5 in map version)
-#define PROTOCOL_VERSION_17 17
-
-// For backward compatibility of demo files (create string tables compression flag)
-#define PROTOCOL_VERSION_14 14
-
-// For backward compatibility of demo files
-#define PROTOCOL_VERSION_12 12
-
-// The PROTOCOL_VERSION when replay shipped to public
-#define PROTOCOL_VERSION_REPLAY 16
-
-#endif
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +// +//=============================================================================// +#if !defined( PROTO_VERSION_H ) +#define PROTO_VERSION_H +#ifdef _WIN32 +#pragma once +#endif + +// The current network protocol version. Changing this makes clients and servers incompatible +#define PROTOCOL_VERSION 24 + +#define DEMO_BACKWARDCOMPATABILITY + +// For backward compatibility of demo files (NET_MAX_PAYLOAD_BITS went away) +#define PROTOCOL_VERSION_23 23 + +// For backward compatibility of demo files (sound index bits used to = 13 ) +#define PROTOCOL_VERSION_22 22 + +// For backward compatibility of demo files (before the special DSP was shipped to public) +#define PROTOCOL_VERSION_21 21 + +// For backward compatibility of demo files (old-style dynamic model loading) +#define PROTOCOL_VERSION_20 20 + +// For backward compatibility of demo files (post Halloween sound flag extra bit) +#define PROTOCOL_VERSION_19 19 + +// For backward compatibility of demo files (pre Halloween sound flag extra bit) +#define PROTOCOL_VERSION_18 18 + +// For backward compatibility of demo files (MD5 in map version) +#define PROTOCOL_VERSION_17 17 + +// For backward compatibility of demo files (create string tables compression flag) +#define PROTOCOL_VERSION_14 14 + +// For backward compatibility of demo files +#define PROTOCOL_VERSION_12 12 + +// The PROTOCOL_VERSION when replay shipped to public +#define PROTOCOL_VERSION_REPLAY 16 + +#endif diff --git a/mp/src/common/qlimits.h b/mp/src/common/qlimits.h index 839cd75b..59bdde2f 100644 --- a/mp/src/common/qlimits.h +++ b/mp/src/common/qlimits.h @@ -1,35 +1,35 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef QLIMITS_H
-#define QLIMITS_H
-
-#if defined( _WIN32 )
-#pragma once
-#endif
-
-// DATA STRUCTURE INFO
-
-#define MAX_NUM_ARGVS 50
-
-// SYSTEM INFO
-#define MAX_QPATH 96 // max length of a game pathname
-#define MAX_OSPATH 260 // max length of a filesystem pathname
-
-#define ON_EPSILON 0.1 // point on plane side epsilon
-
-
-// Resource counts;
-#define MAX_MODEL_INDEX_BITS 11 // sent as a short
-#define MAX_MODELS (1<<MAX_MODEL_INDEX_BITS)
-
-#define MAX_GENERIC_INDEX_BITS 9
-#define MAX_GENERIC (1<<MAX_GENERIC_INDEX_BITS)
-#define MAX_DECAL_INDEX_BITS 9
-#define MAX_BASE_DECALS (1<<MAX_DECAL_INDEX_BITS)
-
-#endif // QLIMITS_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef QLIMITS_H +#define QLIMITS_H + +#if defined( _WIN32 ) +#pragma once +#endif + +// DATA STRUCTURE INFO + +#define MAX_NUM_ARGVS 50 + +// SYSTEM INFO +#define MAX_QPATH 96 // max length of a game pathname +#define MAX_OSPATH 260 // max length of a filesystem pathname + +#define ON_EPSILON 0.1 // point on plane side epsilon + + +// Resource counts; +#define MAX_MODEL_INDEX_BITS 11 // sent as a short +#define MAX_MODELS (1<<MAX_MODEL_INDEX_BITS) + +#define MAX_GENERIC_INDEX_BITS 9 +#define MAX_GENERIC (1<<MAX_GENERIC_INDEX_BITS) +#define MAX_DECAL_INDEX_BITS 9 +#define MAX_BASE_DECALS (1<<MAX_DECAL_INDEX_BITS) + +#endif // QLIMITS_H diff --git a/mp/src/common/randoverride.cpp b/mp/src/common/randoverride.cpp index 1c3fb350..b3e5bd51 100644 --- a/mp/src/common/randoverride.cpp +++ b/mp/src/common/randoverride.cpp @@ -1,27 +1,27 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-//=============================================================================//
-#if !defined(_STATIC_LINKED) || defined(_SHARED_LIB)
-
-#include "stdlib.h"
-#include "vstdlib/random.h"
-
-// memdbgon must be the last include file in a .cpp file!!!
-#include "tier0/memdbgon.h"
-
-#ifdef GNUC
-#define __cdecl
-#endif
-
-void __cdecl srand(unsigned int)
-{
-}
-
-int __cdecl rand()
-{
- return RandomInt( 0, VALVE_RAND_MAX );
-}
-
-#endif // !_STATIC_LINKED || _SHARED_LIB
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +//=============================================================================// +#if !defined(_STATIC_LINKED) || defined(_SHARED_LIB) + +#include "stdlib.h" +#include "vstdlib/random.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +#ifdef GNUC +#define __cdecl +#endif + +void __cdecl srand(unsigned int) +{ +} + +int __cdecl rand() +{ + return RandomInt( 0, VALVE_RAND_MAX ); +} + +#endif // !_STATIC_LINKED || _SHARED_LIB diff --git a/mp/src/common/replay/basereplayserializeable.h b/mp/src/common/replay/basereplayserializeable.h index d30da7e2..7414ab5e 100644 --- a/mp/src/common/replay/basereplayserializeable.h +++ b/mp/src/common/replay/basereplayserializeable.h @@ -1,43 +1,43 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef REPLAYSERIALIIZEABLE_H
-#define REPLAYSERIALIIZEABLE_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "replay/ireplayserializeable.h"
-#include "replay/replayhandle.h"
-
-//----------------------------------------------------------------------------------------
-
-class CBaseReplaySerializeable : public IReplaySerializeable
-{
-public:
- CBaseReplaySerializeable();
-
- virtual void SetHandle( ReplayHandle_t h );
- virtual ReplayHandle_t GetHandle() const;
- virtual bool Read( KeyValues *pIn );
- virtual void Write( KeyValues *pOut );
- virtual const char *GetFilename() const;
- virtual const char *GetFullFilename() const;
- virtual const char *GetDebugName() const;
- virtual void SetLocked( bool bLocked );
- virtual bool IsLocked() const;
- virtual void OnDelete();
- virtual void OnUnload();
- virtual void OnAddedToDirtyList();
-
-private:
- ReplayHandle_t m_hThis;
- bool m_bLocked;
-};
-
-//----------------------------------------------------------------------------------------
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef REPLAYSERIALIIZEABLE_H +#define REPLAYSERIALIIZEABLE_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "replay/ireplayserializeable.h" +#include "replay/replayhandle.h" + +//---------------------------------------------------------------------------------------- + +class CBaseReplaySerializeable : public IReplaySerializeable +{ +public: + CBaseReplaySerializeable(); + + virtual void SetHandle( ReplayHandle_t h ); + virtual ReplayHandle_t GetHandle() const; + virtual bool Read( KeyValues *pIn ); + virtual void Write( KeyValues *pOut ); + virtual const char *GetFilename() const; + virtual const char *GetFullFilename() const; + virtual const char *GetDebugName() const; + virtual void SetLocked( bool bLocked ); + virtual bool IsLocked() const; + virtual void OnDelete(); + virtual void OnUnload(); + virtual void OnAddedToDirtyList(); + +private: + ReplayHandle_t m_hThis; + bool m_bLocked; +}; + +//---------------------------------------------------------------------------------------- + #endif // REPLAYSERIALIIZEABLE_H
\ No newline at end of file diff --git a/mp/src/common/replay/iclientreplay.h b/mp/src/common/replay/iclientreplay.h index 31362f4e..1d4b53d8 100644 --- a/mp/src/common/replay/iclientreplay.h +++ b/mp/src/common/replay/iclientreplay.h @@ -1,64 +1,64 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef ICLIENTREPLAY_H
-#define ICLIENTREPLAY_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "interface.h"
-#include "replay/replayhandle.h"
-
-//----------------------------------------------------------------------------------------
-
-#define CLIENT_REPLAY_INTERFACE_VERSION "ClientReplay001"
-
-//----------------------------------------------------------------------------------------
-
-class IReplayFactory;
-class IReplayScreenshotSystem;
-class IReplayPerformancePlaybackHandler;
-class KeyValues;
-class IReplayCamera;
-class CReplayPerformance;
-struct RenderMovieParams_t;
-class IGameEvent;
-
-//----------------------------------------------------------------------------------------
-
-//
-// Allows the replay and engine DLL's to talk to the client.
-//
-class IClientReplay : public IBaseInterface
-{
-public:
- virtual uint64 GetServerSessionId() = 0;
- virtual bool CacheReplayRagdolls( const char* pFilename, int nStartTick ) = 0; // Cache replay ragdolls
- virtual IReplayScreenshotSystem *GetReplayScreenshotSystem() = 0; // Get the client's replay screenshot system
- virtual IReplayPerformancePlaybackHandler *GetPerformancePlaybackHandler() = 0;
- virtual IReplayCamera *GetReplayCamera() = 0;
- virtual void DisplayReplayMessage( const char *pLocalizeStr, bool bUrgent, bool bDlg, const char *pSound ) = 0;
- virtual void DisplayReplayMessage( const wchar_t *pText, bool bUrgent, bool bDlg, const char *pSound ) = 0;
- virtual void InitPerformanceEditor( ReplayHandle_t hReplay ) = 0;
- virtual void HidePerformanceEditor() = 0;
- virtual bool ShouldRender() = 0;
- virtual void PlaySound( const char *pSound ) = 0;
- virtual void UploadOgsData( KeyValues *pData, bool bIncludeTimeField ) = 0;
- virtual bool ShouldCompletePendingReplay( IGameEvent *pEvent ) = 0;
-
- virtual void OnSaveReplay( ReplayHandle_t hNewReplay, bool bShowInputDlg ) = 0;
- virtual void OnDeleteReplay( ReplayHandle_t hReplay ) = 0; // Called before replay is actually removed from the replay manager
- virtual void OnPlaybackComplete( ReplayHandle_t hReplay, int iPerformance ) = 0;
- virtual void OnRenderStart() = 0;
- virtual void OnRenderComplete( const RenderMovieParams_t &RenderParams, bool bCancelled, bool bSuccess, bool bShowBrowser ) = 0;
- virtual bool OnConfirmQuit() = 0;
- virtual bool OnEndOfReplayReached() = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef ICLIENTREPLAY_H +#define ICLIENTREPLAY_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "interface.h" +#include "replay/replayhandle.h" + +//---------------------------------------------------------------------------------------- + +#define CLIENT_REPLAY_INTERFACE_VERSION "ClientReplay001" + +//---------------------------------------------------------------------------------------- + +class IReplayFactory; +class IReplayScreenshotSystem; +class IReplayPerformancePlaybackHandler; +class KeyValues; +class IReplayCamera; +class CReplayPerformance; +struct RenderMovieParams_t; +class IGameEvent; + +//---------------------------------------------------------------------------------------- + +// +// Allows the replay and engine DLL's to talk to the client. +// +class IClientReplay : public IBaseInterface +{ +public: + virtual uint64 GetServerSessionId() = 0; + virtual bool CacheReplayRagdolls( const char* pFilename, int nStartTick ) = 0; // Cache replay ragdolls + virtual IReplayScreenshotSystem *GetReplayScreenshotSystem() = 0; // Get the client's replay screenshot system + virtual IReplayPerformancePlaybackHandler *GetPerformancePlaybackHandler() = 0; + virtual IReplayCamera *GetReplayCamera() = 0; + virtual void DisplayReplayMessage( const char *pLocalizeStr, bool bUrgent, bool bDlg, const char *pSound ) = 0; + virtual void DisplayReplayMessage( const wchar_t *pText, bool bUrgent, bool bDlg, const char *pSound ) = 0; + virtual void InitPerformanceEditor( ReplayHandle_t hReplay ) = 0; + virtual void HidePerformanceEditor() = 0; + virtual bool ShouldRender() = 0; + virtual void PlaySound( const char *pSound ) = 0; + virtual void UploadOgsData( KeyValues *pData, bool bIncludeTimeField ) = 0; + virtual bool ShouldCompletePendingReplay( IGameEvent *pEvent ) = 0; + + virtual void OnSaveReplay( ReplayHandle_t hNewReplay, bool bShowInputDlg ) = 0; + virtual void OnDeleteReplay( ReplayHandle_t hReplay ) = 0; // Called before replay is actually removed from the replay manager + virtual void OnPlaybackComplete( ReplayHandle_t hReplay, int iPerformance ) = 0; + virtual void OnRenderStart() = 0; + virtual void OnRenderComplete( const RenderMovieParams_t &RenderParams, bool bCancelled, bool bSuccess, bool bShowBrowser ) = 0; + virtual bool OnConfirmQuit() = 0; + virtual bool OnEndOfReplayReached() = 0; +}; + +//---------------------------------------------------------------------------------------- + #endif // ICLIENTREPLAY_H
\ No newline at end of file diff --git a/mp/src/common/replay/iclientreplaycontext.h b/mp/src/common/replay/iclientreplaycontext.h index bdafa15e..7f0b22c2 100644 --- a/mp/src/common/replay/iclientreplaycontext.h +++ b/mp/src/common/replay/iclientreplaycontext.h @@ -1,58 +1,58 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef ICLIENTREPLAYCONTEXT_H
-#define ICLIENTREPLAYCONTEXT_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "replay/ireplaycontext.h"
-#include "replay/replayhandle.h"
-
-//----------------------------------------------------------------------------------------
-
-#define REPLAYHISTORYMANAGER_INTERFACE_VERSION_CLIENT "VENGINE_CLIENT_REPLAY_HISTORY_MANAGER_001"
-
-//----------------------------------------------------------------------------------------
-
-class CReplay;
-class CReplayPerformance;
-class IReplayManager;
-class IReplayMovieManager;
-class IReplayMovieRenderer;
-class IReplayScreenshotManager;
-class IReplayPerformanceManager;
-class IReplayPerformanceController;
-class IReplayRenderQueue;
-
-//----------------------------------------------------------------------------------------
-
-class IClientReplayContext : public IReplayContext
-{
-public:
- virtual CReplay *GetReplay( ReplayHandle_t hReplay ) = 0; // Shorthand to GetReplayManager()->GetReplay()
- virtual IReplayManager *GetReplayManager() = 0;
- virtual IReplayMovieRenderer *GetMovieRenderer() = 0;
- virtual IReplayMovieManager *GetMovieManager() = 0;
- virtual IReplayScreenshotManager *GetScreenshotManager() = 0;
- virtual IReplayPerformanceManager *GetPerformanceManager() = 0;
- virtual IReplayPerformanceController *GetPerformanceController() = 0;
- virtual IReplayRenderQueue *GetRenderQueue() = 0;
- virtual void SetMovieRenderer( IReplayMovieRenderer *pRenderer ) = 0; // Set to be the panel that renders replay movies, or NULL when nothing is rendering
- virtual void OnSignonStateFull() = 0;
- virtual void OnClientSideDisconnect() = 0; // Called when client disconnects
- virtual void PlayReplay( ReplayHandle_t hReplay, int iPerformance, bool bPlaySound ) = 0; // Play the given replay, from spawn tick to death tick
- virtual bool ReconstructReplayIfNecessary( CReplay *pReplay ) = 0;
- virtual void OnPlayerSpawn() = 0; // Called on the client when player is spawned
- virtual void OnPlayerClassChanged() = 0; // Called when the player's class changes - we use this instead of an event for immediacy
- virtual void GetPlaybackTimes( float &flOutTime, float &flOutLength, const CReplay *pReplay, const CReplayPerformance *pPerformance ) = 0; // Calculate the current time and length of a replay or performance - takes in tick and out tick into account for performances - flCurTime should be gpGlobals->curtime. pPerformance can be NULL.
- virtual uint64 GetServerSessionId( ReplayHandle_t hReplay ) = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
-#endif // ICLIENTREPLAYCONTEXT_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef ICLIENTREPLAYCONTEXT_H +#define ICLIENTREPLAYCONTEXT_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "replay/ireplaycontext.h" +#include "replay/replayhandle.h" + +//---------------------------------------------------------------------------------------- + +#define REPLAYHISTORYMANAGER_INTERFACE_VERSION_CLIENT "VENGINE_CLIENT_REPLAY_HISTORY_MANAGER_001" + +//---------------------------------------------------------------------------------------- + +class CReplay; +class CReplayPerformance; +class IReplayManager; +class IReplayMovieManager; +class IReplayMovieRenderer; +class IReplayScreenshotManager; +class IReplayPerformanceManager; +class IReplayPerformanceController; +class IReplayRenderQueue; + +//---------------------------------------------------------------------------------------- + +class IClientReplayContext : public IReplayContext +{ +public: + virtual CReplay *GetReplay( ReplayHandle_t hReplay ) = 0; // Shorthand to GetReplayManager()->GetReplay() + virtual IReplayManager *GetReplayManager() = 0; + virtual IReplayMovieRenderer *GetMovieRenderer() = 0; + virtual IReplayMovieManager *GetMovieManager() = 0; + virtual IReplayScreenshotManager *GetScreenshotManager() = 0; + virtual IReplayPerformanceManager *GetPerformanceManager() = 0; + virtual IReplayPerformanceController *GetPerformanceController() = 0; + virtual IReplayRenderQueue *GetRenderQueue() = 0; + virtual void SetMovieRenderer( IReplayMovieRenderer *pRenderer ) = 0; // Set to be the panel that renders replay movies, or NULL when nothing is rendering + virtual void OnSignonStateFull() = 0; + virtual void OnClientSideDisconnect() = 0; // Called when client disconnects + virtual void PlayReplay( ReplayHandle_t hReplay, int iPerformance, bool bPlaySound ) = 0; // Play the given replay, from spawn tick to death tick + virtual bool ReconstructReplayIfNecessary( CReplay *pReplay ) = 0; + virtual void OnPlayerSpawn() = 0; // Called on the client when player is spawned + virtual void OnPlayerClassChanged() = 0; // Called when the player's class changes - we use this instead of an event for immediacy + virtual void GetPlaybackTimes( float &flOutTime, float &flOutLength, const CReplay *pReplay, const CReplayPerformance *pPerformance ) = 0; // Calculate the current time and length of a replay or performance - takes in tick and out tick into account for performances - flCurTime should be gpGlobals->curtime. pPerformance can be NULL. + virtual uint64 GetServerSessionId( ReplayHandle_t hReplay ) = 0; +}; + +//---------------------------------------------------------------------------------------- + +#endif // ICLIENTREPLAYCONTEXT_H diff --git a/mp/src/common/replay/iclientreplayhistorymanager.h b/mp/src/common/replay/iclientreplayhistorymanager.h index 6eb3f9eb..8013ca04 100644 --- a/mp/src/common/replay/iclientreplayhistorymanager.h +++ b/mp/src/common/replay/iclientreplayhistorymanager.h @@ -1,104 +1,104 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef ICLIENTREPLAYHISTORYMANAGER_H
-#define ICLIENTREPLAYHISTORYMANAGER_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "replay/replayhandle.h"
-#include "replay/screenshot.h"
-#include "interface.h"
-#include "qlimits.h"
-#include "convar.h"
-#include "engine/http.h"
-#include "tier1/utllinkedlist.h"
-#include "tier1/checksum_crc.h"
-#include <time.h>
-
-//----------------------------------------------------------------------------------------
-
-class IReplayDownloadGroup;
-class IReplayDownloadGroupHelper;
-class CDmxElement;
-class KeyValues;
-struct CaptureScreenshotParams_t;
-struct RenderMovieParams_t;
-class CBaseReplay;
-class CReplay;
-class IReplayMovieRenderer;
-class IReplayMovieManager;
-class IReplayMovie;
-class IReplayPerformanceManager;
-class IGameEvent;
-
-//----------------------------------------------------------------------------------------
-
-class IClientReplayHistoryManager : public IBaseInterface
-{
-public:
- virtual bool Init( CreateInterfaceFn fnCreateFactory ) = 0;
- virtual void Shutdown() = 0;
- virtual void Think() = 0;
-
- virtual bool IsInitialized() const = 0;
- virtual bool Commit( CBaseReplay *pNewReplay ) = 0;
-
- virtual void Save() = 0; // Write the entire index and any replays/groups/movies that are marked as dirty
- virtual void FlagReplayForFlush( CBaseReplay *pReplay, bool bForceImmediateWrite ) = 0; // Mark the given replay as dirty - flush to disk at the next opportunity (see CBaseReplayHistoryManager::FlushThink())
-
- virtual void Nuke() = 0;
-
- virtual void DeleteReplay( ReplayHandle_t hReplay, bool bNotifyUI ) = 0;
- virtual CBaseReplay *GetReplay( ReplayHandle_t hReplay ) = 0;
-
- virtual const char *GetBaseDirectory() = 0; // Returns full directory to wherever replays.dmx lives, e.g. c:\program files (x86)\steam\steamapps\someuser\team fortress 2\game\tf\replays\client\ (or server\) - NOTE: includes trailing slash
- virtual const char *GetReplaysSubDir() = 0; // Returns "client" or "server"
-
- // For loop through all replays - indices should not be cached
- virtual int GetReplayCount() const = 0;
-// virtual CBaseReplay *GetReplayAtIndex( int nIndex ) = 0;
-
- virtual const char *GetFullReplayPath() = 0; // Get c:\...\game\tf\replays\<client or server>\
-
- // Client-specific
- virtual int GetAdjustedDeathTick( CReplay *pReplay ) = 0;
- virtual void FlagDownloadGroupForFlush( IReplayDownloadGroup *pGroup, bool bForceImmediate ) = 0;
- virtual void FlagMovieForFlush( IReplayMovie *pMovie, bool bForceImmediate ) = 0; // Flag the movie for flush - if pMovie is NULL, mark the index for flush
- virtual void SetMovieRenderer( IReplayMovieRenderer *pRenderer ) = 0; // Set to be the panel that renders replay movies, or NULL when nothing is rendering
- virtual bool ShouldGameRenderView() = 0; // Called from V_RenderView() to determine whether the game should render - used during movie rendering
- virtual int GetUnrenderedReplayCount() = 0; // Get the number of unrendered replays
- virtual void UpdateCurrentReplayDataFromServer() = 0; // Updates start tick, current file url, demo filename
- virtual void LinkReplayToDownloadGroup() = 0;
- virtual void CaptureScreenshot( CaptureScreenshotParams_t ¶ms ) = 0; // Schedules a screenshot capture at flDelay seconds in the future
- virtual void DoCaptureScreenshot() = 0; // Takes the screenshot right now
- virtual bool ShouldCaptureScreenshot() = 0; // Is screenshot scheduled to be taken right now?
- virtual void GetUnpaddedScreenshotSize( int &nWidth, int &nHeight ) = 0; // Get the dimensions for a screenshot if we take one right now, based on replay_screenshotresolution and the current aspect ratio
- virtual void DeleteScreenshotsForReplay( CReplay *pReplay ) = 0; // Deletes all screenshots associated with the given replay
- virtual void PlayReplay( ReplayHandle_t hReplay ) = 0; // Play the given replay, from spawn tick to death tick
- virtual void RenderMovie( RenderMovieParams_t const& params ) = 0; // Renders the given replay - or if params.hReplay is -1, render all unrendered replays
- virtual void CompleteRender( bool bSuccess ) = 0;
- virtual void OnClientSideDisconnect() = 0; // Called when client disconnects
- virtual void OnSignonStateFull() = 0;
- virtual void OnPlayerSpawn() = 0; // Called on the client when player is spawned
- virtual void OnPlayerClassChanged() = 0; // Called when the player's class changes - we use this instead of an event for immediacy
- virtual void OnReplayRecordingCvarChanged() = 0; // Called (on client only) when replay_recording is set to 1
- virtual void OnGroupDeleted() = 0;
- virtual CReplay *GetPlayingReplay() = 0; // Get the currently playing replay, otherwise NULL if one isn't playing
- virtual CReplay *GetReplayForCurrentLife() = 0; // Gets the current replay (constant from local player spawn until next spawn/disconnect/exit)
- virtual bool IsRendering() = 0; // Are we currently rendering a movie?
- virtual void CancelRender() = 0; // If we're currently rendering, cancel
- virtual IReplayMovieManager *GetMovieManager() = 0;
- virtual IReplayMovieRenderer *GetMovieRenderer() = 0;
- virtual const RenderMovieParams_t *GetRenderSettings() = 0;
- virtual IReplayDownloadGroupHelper *GetDownloadGroupHelper() = 0;
- virtual IReplayPerformanceManager *GetPerformanceManager() = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
-#endif // ICLIENTREPLAYHISTORYMANAGER_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef ICLIENTREPLAYHISTORYMANAGER_H +#define ICLIENTREPLAYHISTORYMANAGER_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "replay/replayhandle.h" +#include "replay/screenshot.h" +#include "interface.h" +#include "qlimits.h" +#include "convar.h" +#include "engine/http.h" +#include "tier1/utllinkedlist.h" +#include "tier1/checksum_crc.h" +#include <time.h> + +//---------------------------------------------------------------------------------------- + +class IReplayDownloadGroup; +class IReplayDownloadGroupHelper; +class CDmxElement; +class KeyValues; +struct CaptureScreenshotParams_t; +struct RenderMovieParams_t; +class CBaseReplay; +class CReplay; +class IReplayMovieRenderer; +class IReplayMovieManager; +class IReplayMovie; +class IReplayPerformanceManager; +class IGameEvent; + +//---------------------------------------------------------------------------------------- + +class IClientReplayHistoryManager : public IBaseInterface +{ +public: + virtual bool Init( CreateInterfaceFn fnCreateFactory ) = 0; + virtual void Shutdown() = 0; + virtual void Think() = 0; + + virtual bool IsInitialized() const = 0; + virtual bool Commit( CBaseReplay *pNewReplay ) = 0; + + virtual void Save() = 0; // Write the entire index and any replays/groups/movies that are marked as dirty + virtual void FlagReplayForFlush( CBaseReplay *pReplay, bool bForceImmediateWrite ) = 0; // Mark the given replay as dirty - flush to disk at the next opportunity (see CBaseReplayHistoryManager::FlushThink()) + + virtual void Nuke() = 0; + + virtual void DeleteReplay( ReplayHandle_t hReplay, bool bNotifyUI ) = 0; + virtual CBaseReplay *GetReplay( ReplayHandle_t hReplay ) = 0; + + virtual const char *GetBaseDirectory() = 0; // Returns full directory to wherever replays.dmx lives, e.g. c:\program files (x86)\steam\steamapps\someuser\team fortress 2\game\tf\replays\client\ (or server\) - NOTE: includes trailing slash + virtual const char *GetReplaysSubDir() = 0; // Returns "client" or "server" + + // For loop through all replays - indices should not be cached + virtual int GetReplayCount() const = 0; +// virtual CBaseReplay *GetReplayAtIndex( int nIndex ) = 0; + + virtual const char *GetFullReplayPath() = 0; // Get c:\...\game\tf\replays\<client or server>\ + + // Client-specific + virtual int GetAdjustedDeathTick( CReplay *pReplay ) = 0; + virtual void FlagDownloadGroupForFlush( IReplayDownloadGroup *pGroup, bool bForceImmediate ) = 0; + virtual void FlagMovieForFlush( IReplayMovie *pMovie, bool bForceImmediate ) = 0; // Flag the movie for flush - if pMovie is NULL, mark the index for flush + virtual void SetMovieRenderer( IReplayMovieRenderer *pRenderer ) = 0; // Set to be the panel that renders replay movies, or NULL when nothing is rendering + virtual bool ShouldGameRenderView() = 0; // Called from V_RenderView() to determine whether the game should render - used during movie rendering + virtual int GetUnrenderedReplayCount() = 0; // Get the number of unrendered replays + virtual void UpdateCurrentReplayDataFromServer() = 0; // Updates start tick, current file url, demo filename + virtual void LinkReplayToDownloadGroup() = 0; + virtual void CaptureScreenshot( CaptureScreenshotParams_t ¶ms ) = 0; // Schedules a screenshot capture at flDelay seconds in the future + virtual void DoCaptureScreenshot() = 0; // Takes the screenshot right now + virtual bool ShouldCaptureScreenshot() = 0; // Is screenshot scheduled to be taken right now? + virtual void GetUnpaddedScreenshotSize( int &nWidth, int &nHeight ) = 0; // Get the dimensions for a screenshot if we take one right now, based on replay_screenshotresolution and the current aspect ratio + virtual void DeleteScreenshotsForReplay( CReplay *pReplay ) = 0; // Deletes all screenshots associated with the given replay + virtual void PlayReplay( ReplayHandle_t hReplay ) = 0; // Play the given replay, from spawn tick to death tick + virtual void RenderMovie( RenderMovieParams_t const& params ) = 0; // Renders the given replay - or if params.hReplay is -1, render all unrendered replays + virtual void CompleteRender( bool bSuccess ) = 0; + virtual void OnClientSideDisconnect() = 0; // Called when client disconnects + virtual void OnSignonStateFull() = 0; + virtual void OnPlayerSpawn() = 0; // Called on the client when player is spawned + virtual void OnPlayerClassChanged() = 0; // Called when the player's class changes - we use this instead of an event for immediacy + virtual void OnReplayRecordingCvarChanged() = 0; // Called (on client only) when replay_recording is set to 1 + virtual void OnGroupDeleted() = 0; + virtual CReplay *GetPlayingReplay() = 0; // Get the currently playing replay, otherwise NULL if one isn't playing + virtual CReplay *GetReplayForCurrentLife() = 0; // Gets the current replay (constant from local player spawn until next spawn/disconnect/exit) + virtual bool IsRendering() = 0; // Are we currently rendering a movie? + virtual void CancelRender() = 0; // If we're currently rendering, cancel + virtual IReplayMovieManager *GetMovieManager() = 0; + virtual IReplayMovieRenderer *GetMovieRenderer() = 0; + virtual const RenderMovieParams_t *GetRenderSettings() = 0; + virtual IReplayDownloadGroupHelper *GetDownloadGroupHelper() = 0; + virtual IReplayPerformanceManager *GetPerformanceManager() = 0; +}; + +//---------------------------------------------------------------------------------------- + +#endif // ICLIENTREPLAYHISTORYMANAGER_H diff --git a/mp/src/common/replay/ienginereplay.h b/mp/src/common/replay/ienginereplay.h index 90de4d3b..98de9495 100644 --- a/mp/src/common/replay/ienginereplay.h +++ b/mp/src/common/replay/ienginereplay.h @@ -1,116 +1,116 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef IENGINEREPLAY_H
-#define IENGINEREPLAY_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "interface.h"
-
-//----------------------------------------------------------------------------------------
-
-#define ENGINE_REPLAY_INTERFACE_VERSION "EngineReplay001"
-
-#if !defined( DEDICATED )
-# define ENGINE_REPLAY_CLIENT_INTERFACE_VERSION "EngineClientReplay001"
-#endif
-
-//----------------------------------------------------------------------------------------
-
-class IServer;
-class INetChannel;
-class IReplayServer;
-class IClientEntityList;
-class IClientReplay;
-struct demoheader_t;
-class CGlobalVarsBase;
-class IDemoBuffer;
-class CBaseRecordingSessionBlock;
-
-//----------------------------------------------------------------------------------------
-
-//
-// Allows the replay, client & server DLL's to talk to the engine
-//
-class IEngineReplay : public IBaseInterface
-{
-public:
- virtual bool IsSupportedModAndPlatform() = 0;
-
- virtual float GetHostTime() = 0;
- virtual int GetHostTickCount() = 0;
- virtual int TimeToTicks( float flTime ) = 0;
- virtual float TicksToTime( int nTick ) = 0;
-
- virtual bool ReadDemoHeader( const char *pFilename, demoheader_t &header ) = 0;
- virtual const char *GetGameDir() = 0;
- virtual void Cbuf_AddText( const char *pCmd ) = 0;
- virtual void Cbuf_Execute() = 0;
- virtual void Host_Disconnect( bool bShowMainMenu ) = 0;
- virtual void HostState_Shutdown() = 0;
- virtual const char *GetModDir() = 0;
-
- virtual bool CopyFile( const char *pSource, const char *pDest ) = 0;
-
- virtual bool LZSS_Compress( char *pDest, unsigned int *pDestLen, const char *pSource, unsigned int nSourceLen ) = 0;
- virtual bool LZSS_Decompress( char *pDest, unsigned int *pDestLen, const char *pSource, unsigned int nSourceLen ) = 0;
-
- virtual bool MD5_HashBuffer( unsigned char pDigest[16], const unsigned char *pBuffer, int nSize, unsigned int pSeed[4] ) = 0;
-
- // Server-specific
- virtual IReplayServer *GetReplayServer() = 0;
- virtual IServer *GetReplayServerAsIServer() = 0;
- virtual IServer *GetGameServer() = 0;
- virtual bool GetSessionRecordBuffer( uint8 **ppSessionBuffer, int *pSize ) = 0;
- virtual bool IsDedicated() = 0;
- virtual void ResetReplayRecordBuffer() = 0;
- virtual demoheader_t *GetReplayDemoHeader() = 0;
- virtual void RecalculateTags() = 0;
- virtual bool NET_GetHostnameAsIP( const char *pHostname, char *pOut, int nOutSize ) = 0;
-};
-
-//
-// Allows the replay and client DLL's to talk to the engine
-//
-#if !defined( DEDICATED )
-class IEngineClientReplay : public IBaseInterface
-{
-public:
- virtual INetChannel *GetNetChannel() = 0;
- virtual bool IsConnected() = 0;
- virtual bool IsListenServer() = 0;
- virtual float GetLastServerTickTime() = 0;
- virtual const char *GetLevelName() = 0;
- virtual const char *GetLevelNameShort() = 0;
- virtual int GetPlayerSlot() = 0;
- virtual bool IsPlayingReplayDemo() = 0;
- virtual IClientEntityList *GetClientEntityList() = 0;
- virtual IClientReplay *GetClientReplayInt() = 0;
- virtual uint32 GetClientSteamID() = 0;
- virtual void Con_NPrintf( int nPos, PRINTF_FORMAT_STRING const char *pFormat, ... ) = 0;
- virtual CGlobalVarsBase *GetClientGlobalVars() = 0;
- virtual void VGui_PlaySound( const char *pSound ) = 0;
- virtual void EngineVGui_ConfirmQuit() = 0;
- virtual int GetScreenWidth() = 0;
- virtual int GetScreenHeight() = 0;
- virtual bool IsDemoPlayingBack() = 0;
- virtual bool IsGamePathValidAndSafeForDownload( const char *pGamePath ) = 0;
- virtual bool IsInGame() = 0;
-
- virtual void InitSoundRecord() = 0;
-
- virtual void Wave_CreateTmpFile( const char *pFilename ) = 0;
- virtual void Wave_AppendTmpFile( const char *pFilename, void *pBuffer, int nNumSamples ) = 0;
- virtual void Wave_FixupTmpFile( const char *pFilename ) = 0;
-
-};
-#endif // !defined( DEDICATED )
-
-//----------------------------------------------------------------------------------------
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef IENGINEREPLAY_H +#define IENGINEREPLAY_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "interface.h" + +//---------------------------------------------------------------------------------------- + +#define ENGINE_REPLAY_INTERFACE_VERSION "EngineReplay001" + +#if !defined( DEDICATED ) +# define ENGINE_REPLAY_CLIENT_INTERFACE_VERSION "EngineClientReplay001" +#endif + +//---------------------------------------------------------------------------------------- + +class IServer; +class INetChannel; +class IReplayServer; +class IClientEntityList; +class IClientReplay; +struct demoheader_t; +class CGlobalVarsBase; +class IDemoBuffer; +class CBaseRecordingSessionBlock; + +//---------------------------------------------------------------------------------------- + +// +// Allows the replay, client & server DLL's to talk to the engine +// +class IEngineReplay : public IBaseInterface +{ +public: + virtual bool IsSupportedModAndPlatform() = 0; + + virtual float GetHostTime() = 0; + virtual int GetHostTickCount() = 0; + virtual int TimeToTicks( float flTime ) = 0; + virtual float TicksToTime( int nTick ) = 0; + + virtual bool ReadDemoHeader( const char *pFilename, demoheader_t &header ) = 0; + virtual const char *GetGameDir() = 0; + virtual void Cbuf_AddText( const char *pCmd ) = 0; + virtual void Cbuf_Execute() = 0; + virtual void Host_Disconnect( bool bShowMainMenu ) = 0; + virtual void HostState_Shutdown() = 0; + virtual const char *GetModDir() = 0; + + virtual bool CopyFile( const char *pSource, const char *pDest ) = 0; + + virtual bool LZSS_Compress( char *pDest, unsigned int *pDestLen, const char *pSource, unsigned int nSourceLen ) = 0; + virtual bool LZSS_Decompress( char *pDest, unsigned int *pDestLen, const char *pSource, unsigned int nSourceLen ) = 0; + + virtual bool MD5_HashBuffer( unsigned char pDigest[16], const unsigned char *pBuffer, int nSize, unsigned int pSeed[4] ) = 0; + + // Server-specific + virtual IReplayServer *GetReplayServer() = 0; + virtual IServer *GetReplayServerAsIServer() = 0; + virtual IServer *GetGameServer() = 0; + virtual bool GetSessionRecordBuffer( uint8 **ppSessionBuffer, int *pSize ) = 0; + virtual bool IsDedicated() = 0; + virtual void ResetReplayRecordBuffer() = 0; + virtual demoheader_t *GetReplayDemoHeader() = 0; + virtual void RecalculateTags() = 0; + virtual bool NET_GetHostnameAsIP( const char *pHostname, char *pOut, int nOutSize ) = 0; +}; + +// +// Allows the replay and client DLL's to talk to the engine +// +#if !defined( DEDICATED ) +class IEngineClientReplay : public IBaseInterface +{ +public: + virtual INetChannel *GetNetChannel() = 0; + virtual bool IsConnected() = 0; + virtual bool IsListenServer() = 0; + virtual float GetLastServerTickTime() = 0; + virtual const char *GetLevelName() = 0; + virtual const char *GetLevelNameShort() = 0; + virtual int GetPlayerSlot() = 0; + virtual bool IsPlayingReplayDemo() = 0; + virtual IClientEntityList *GetClientEntityList() = 0; + virtual IClientReplay *GetClientReplayInt() = 0; + virtual uint32 GetClientSteamID() = 0; + virtual void Con_NPrintf( int nPos, PRINTF_FORMAT_STRING const char *pFormat, ... ) = 0; + virtual CGlobalVarsBase *GetClientGlobalVars() = 0; + virtual void VGui_PlaySound( const char *pSound ) = 0; + virtual void EngineVGui_ConfirmQuit() = 0; + virtual int GetScreenWidth() = 0; + virtual int GetScreenHeight() = 0; + virtual bool IsDemoPlayingBack() = 0; + virtual bool IsGamePathValidAndSafeForDownload( const char *pGamePath ) = 0; + virtual bool IsInGame() = 0; + + virtual void InitSoundRecord() = 0; + + virtual void Wave_CreateTmpFile( const char *pFilename ) = 0; + virtual void Wave_AppendTmpFile( const char *pFilename, void *pBuffer, int nNumSamples ) = 0; + virtual void Wave_FixupTmpFile( const char *pFilename ) = 0; + +}; +#endif // !defined( DEDICATED ) + +//---------------------------------------------------------------------------------------- + #endif // IENGINEREPLAY_H
\ No newline at end of file diff --git a/mp/src/common/replay/iqueryablereplayitem.h b/mp/src/common/replay/iqueryablereplayitem.h index dbf05c13..6e3d3f3e 100644 --- a/mp/src/common/replay/iqueryablereplayitem.h +++ b/mp/src/common/replay/iqueryablereplayitem.h @@ -1,46 +1,46 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef IQUERYABLEREPLAYITEM_H
-#define IQUERYABLEREPLAYITEM_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "interface.h"
-#include "iqueryablereplayitem.h"
-#include "replay/replayhandle.h"
-#include "replay/replaytime.h"
-
-//----------------------------------------------------------------------------------------
-
-class CReplay;
-
-//----------------------------------------------------------------------------------------
-
-typedef int QueryableReplayItemHandle_t;
-
-//----------------------------------------------------------------------------------------
-
-abstract_class IQueryableReplayItem : public IBaseInterface
-{
-public:
- virtual const CReplayTime &GetItemDate() const = 0;
- virtual bool IsItemRendered() const = 0;
- virtual CReplay *GetItemReplay() = 0;
- virtual ReplayHandle_t GetItemReplayHandle() const = 0;
- virtual QueryableReplayItemHandle_t GetItemHandle() const = 0; // Get the handle of this item
- virtual const wchar_t *GetItemTitle() const = 0;
- virtual void SetItemTitle( const wchar_t *pTitle ) = 0;
- virtual float GetItemLength() const = 0;
- virtual void *GetUserData() = 0;
- virtual void SetUserData( void *pUserData ) = 0;
- virtual bool IsItemAMovie() const = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef IQUERYABLEREPLAYITEM_H +#define IQUERYABLEREPLAYITEM_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "interface.h" +#include "iqueryablereplayitem.h" +#include "replay/replayhandle.h" +#include "replay/replaytime.h" + +//---------------------------------------------------------------------------------------- + +class CReplay; + +//---------------------------------------------------------------------------------------- + +typedef int QueryableReplayItemHandle_t; + +//---------------------------------------------------------------------------------------- + +abstract_class IQueryableReplayItem : public IBaseInterface +{ +public: + virtual const CReplayTime &GetItemDate() const = 0; + virtual bool IsItemRendered() const = 0; + virtual CReplay *GetItemReplay() = 0; + virtual ReplayHandle_t GetItemReplayHandle() const = 0; + virtual QueryableReplayItemHandle_t GetItemHandle() const = 0; // Get the handle of this item + virtual const wchar_t *GetItemTitle() const = 0; + virtual void SetItemTitle( const wchar_t *pTitle ) = 0; + virtual float GetItemLength() const = 0; + virtual void *GetUserData() = 0; + virtual void SetUserData( void *pUserData ) = 0; + virtual bool IsItemAMovie() const = 0; +}; + +//---------------------------------------------------------------------------------------- + #endif // IQUERYABLEREPLAYITEM_H
\ No newline at end of file diff --git a/mp/src/common/replay/irecordingsession.h b/mp/src/common/replay/irecordingsession.h index a8c739ef..4b0046d0 100644 --- a/mp/src/common/replay/irecordingsession.h +++ b/mp/src/common/replay/irecordingsession.h @@ -1,27 +1,27 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef IRECORDINGSESSION_H
-#define IRECORDINGSESSION_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "interface.h"
-
-//----------------------------------------------------------------------------------------
-
-class CBaseRecordingSessionBlock;
-
-class IRecordingSession : public IBaseInterface
-{
-public:
- virtual void AddBlock( CBaseRecordingSessionBlock *pBlock ) = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
-#endif // IRECORDINGSESSION_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef IRECORDINGSESSION_H +#define IRECORDINGSESSION_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "interface.h" + +//---------------------------------------------------------------------------------------- + +class CBaseRecordingSessionBlock; + +class IRecordingSession : public IBaseInterface +{ +public: + virtual void AddBlock( CBaseRecordingSessionBlock *pBlock ) = 0; +}; + +//---------------------------------------------------------------------------------------- + +#endif // IRECORDINGSESSION_H diff --git a/mp/src/common/replay/irecordingsessionblockmanager.h b/mp/src/common/replay/irecordingsessionblockmanager.h index 6b2262fb..e2a6a825 100644 --- a/mp/src/common/replay/irecordingsessionblockmanager.h +++ b/mp/src/common/replay/irecordingsessionblockmanager.h @@ -1,30 +1,30 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef IRECORDINGSESSIONBLOCKMANAGER_H
-#define IRECORDINGSESSIONBLOCKMANAGER_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "interface.h"
-#include "replay/replayhandle.h"
-
-//----------------------------------------------------------------------------------------
-
-class IRecordingSessionBlockManager : public IBaseInterface
-{
-public:
- virtual CBaseRecordingSessionBlock *GetBlock( ReplayHandle_t hBlock ) = 0;
- virtual void DeleteBlock( CBaseRecordingSessionBlock *pBlock ) = 0;
- virtual void UnloadBlock( CBaseRecordingSessionBlock *pBlock ) = 0;
- virtual const char *GetBlockPath() const = 0;
- virtual void LoadBlockFromFileName( const char *pFilename, IRecordingSession *pSession ) = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
-#endif // IRECORDINGSESSIONBLOCKMANAGER_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef IRECORDINGSESSIONBLOCKMANAGER_H +#define IRECORDINGSESSIONBLOCKMANAGER_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "interface.h" +#include "replay/replayhandle.h" + +//---------------------------------------------------------------------------------------- + +class IRecordingSessionBlockManager : public IBaseInterface +{ +public: + virtual CBaseRecordingSessionBlock *GetBlock( ReplayHandle_t hBlock ) = 0; + virtual void DeleteBlock( CBaseRecordingSessionBlock *pBlock ) = 0; + virtual void UnloadBlock( CBaseRecordingSessionBlock *pBlock ) = 0; + virtual const char *GetBlockPath() const = 0; + virtual void LoadBlockFromFileName( const char *pFilename, IRecordingSession *pSession ) = 0; +}; + +//---------------------------------------------------------------------------------------- + +#endif // IRECORDINGSESSIONBLOCKMANAGER_H diff --git a/mp/src/common/replay/irecordingsessionmanager.h b/mp/src/common/replay/irecordingsessionmanager.h index 998f1956..23cdf650 100644 --- a/mp/src/common/replay/irecordingsessionmanager.h +++ b/mp/src/common/replay/irecordingsessionmanager.h @@ -1,33 +1,33 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef IRECORDINGSESSIONMANAGER_H
-#define IRECORDINGSESSIONMANAGER_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "interface.h"
-#include "replay/replayhandle.h"
-
-//----------------------------------------------------------------------------------------
-
-class CBaseRecordingSession;
-
-//----------------------------------------------------------------------------------------
-
-class IRecordingSessionManager : public IBaseInterface
-{
-public:
- virtual CBaseRecordingSession *FindSession( ReplayHandle_t hSession ) = 0;
- virtual const CBaseRecordingSession *FindSession( ReplayHandle_t hSession ) const = 0;
- virtual void FlagSessionForFlush( CBaseRecordingSession *pSession, bool bForceImmediate ) = 0;
- virtual int GetServerStartTickForSession( ReplayHandle_t hSession ) = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef IRECORDINGSESSIONMANAGER_H +#define IRECORDINGSESSIONMANAGER_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "interface.h" +#include "replay/replayhandle.h" + +//---------------------------------------------------------------------------------------- + +class CBaseRecordingSession; + +//---------------------------------------------------------------------------------------- + +class IRecordingSessionManager : public IBaseInterface +{ +public: + virtual CBaseRecordingSession *FindSession( ReplayHandle_t hSession ) = 0; + virtual const CBaseRecordingSession *FindSession( ReplayHandle_t hSession ) const = 0; + virtual void FlagSessionForFlush( CBaseRecordingSession *pSession, bool bForceImmediate ) = 0; + virtual int GetServerStartTickForSession( ReplayHandle_t hSession ) = 0; +}; + +//---------------------------------------------------------------------------------------- + #endif // IRECORDINGSESSIONMANAGER_H
\ No newline at end of file diff --git a/mp/src/common/replay/ireplaycamera.h b/mp/src/common/replay/ireplaycamera.h index 0e07be15..24ccb917 100644 --- a/mp/src/common/replay/ireplaycamera.h +++ b/mp/src/common/replay/ireplaycamera.h @@ -1,25 +1,25 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//----------------------------------------------------------------------------------------
-
-#ifndef IREPLAYCAMERA_H
-#define IREPLAYCAMERA_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "interface.h"
-
-//----------------------------------------------------------------------------------------
-
-abstract_class IReplayCamera : public IBaseInterface
-{
-public:
- virtual void ClearOverrideView() = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
-#endif // IREPLAYCAMERA_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//---------------------------------------------------------------------------------------- + +#ifndef IREPLAYCAMERA_H +#define IREPLAYCAMERA_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "interface.h" + +//---------------------------------------------------------------------------------------- + +abstract_class IReplayCamera : public IBaseInterface +{ +public: + virtual void ClearOverrideView() = 0; +}; + +//---------------------------------------------------------------------------------------- + +#endif // IREPLAYCAMERA_H diff --git a/mp/src/common/replay/ireplaycontext.h b/mp/src/common/replay/ireplaycontext.h index 34430ab9..f4fda370 100644 --- a/mp/src/common/replay/ireplaycontext.h +++ b/mp/src/common/replay/ireplaycontext.h @@ -1,47 +1,47 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef IREPLAYCONTEXT_H
-#define IREPLAYCONTEXT_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "interface.h"
-#include "replay/replayhandle.h"
-
-//----------------------------------------------------------------------------------------
-
-class IRecordingSessionManager;
-class IRecordingSessionBlockManager;
-class IRecordingSession;
-class IReplayErrorSystem;
-
-//----------------------------------------------------------------------------------------
-
-class IReplayContext : public IBaseInterface
-{
-public:
- virtual bool Init( CreateInterfaceFn fnCreateFactory ) = 0;
- virtual void Shutdown() = 0;
-
- virtual void Think() = 0;
-
- virtual bool IsInitialized() const = 0;
-
- virtual const char *GetRelativeBaseDir() const = 0; // Returns path to wherever the index .dmx lives relative to the game path, e.g. "replay\client\"
- virtual const char *GetBaseDir() const = 0; // Returns full directory to wherever the index .dmx lives, e.g. c:\program files (x86)\steam\steamapps\<username>\team fortress 2\tf\replays\<client|server>\ -- NOTE: includes trailing slash
- virtual const char *GetReplaySubDir() const = 0; // Returns "client" or "server"
-
- virtual IReplayErrorSystem *GetErrorSystem() = 0;
- virtual IRecordingSessionManager *GetRecordingSessionManager() = 0;
- virtual IRecordingSessionBlockManager *GetRecordingSessionBlockManager() = 0;
- virtual IRecordingSession *GetRecordingSession( ReplayHandle_t hSession ) = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
-#endif // IREPLAYCONTEXT_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef IREPLAYCONTEXT_H +#define IREPLAYCONTEXT_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "interface.h" +#include "replay/replayhandle.h" + +//---------------------------------------------------------------------------------------- + +class IRecordingSessionManager; +class IRecordingSessionBlockManager; +class IRecordingSession; +class IReplayErrorSystem; + +//---------------------------------------------------------------------------------------- + +class IReplayContext : public IBaseInterface +{ +public: + virtual bool Init( CreateInterfaceFn fnCreateFactory ) = 0; + virtual void Shutdown() = 0; + + virtual void Think() = 0; + + virtual bool IsInitialized() const = 0; + + virtual const char *GetRelativeBaseDir() const = 0; // Returns path to wherever the index .dmx lives relative to the game path, e.g. "replay\client\" + virtual const char *GetBaseDir() const = 0; // Returns full directory to wherever the index .dmx lives, e.g. c:\program files (x86)\steam\steamapps\<username>\team fortress 2\tf\replays\<client|server>\ -- NOTE: includes trailing slash + virtual const char *GetReplaySubDir() const = 0; // Returns "client" or "server" + + virtual IReplayErrorSystem *GetErrorSystem() = 0; + virtual IRecordingSessionManager *GetRecordingSessionManager() = 0; + virtual IRecordingSessionBlockManager *GetRecordingSessionBlockManager() = 0; + virtual IRecordingSession *GetRecordingSession( ReplayHandle_t hSession ) = 0; +}; + +//---------------------------------------------------------------------------------------- + +#endif // IREPLAYCONTEXT_H diff --git a/mp/src/common/replay/ireplaydemoplayer.h b/mp/src/common/replay/ireplaydemoplayer.h index ddd7b6de..1a8a1d5a 100644 --- a/mp/src/common/replay/ireplaydemoplayer.h +++ b/mp/src/common/replay/ireplaydemoplayer.h @@ -1,42 +1,42 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef IREPLAYDEMOPLAYER_H
-#define IREPLAYDEMOPLAYER_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "interface.h"
-#include "replay/replay.h"
-
-//----------------------------------------------------------------------------------------
-
-#define INTERFACEVERSION_REPLAYDEMOPLAYER "ReplayDemoPlayer001"
-
-//----------------------------------------------------------------------------------------
-
-//
-// Interface for replay demo player
-//
-class IReplayDemoPlayer : public IBaseInterface
-{
-public:
- virtual void PlayReplay( ReplayHandle_t hReplay, int iPerformance ) = 0;
- virtual void PlayNextReplay() = 0;
- virtual void ClearReplayList() = 0;
- virtual void AddReplayToList( ReplayHandle_t hReplay, int iPerformance ) = 0;
- virtual CReplay *GetCurrentReplay() = 0;
- virtual CReplayPerformance *GetCurrentPerformance() = 0; // The playing replay, or NULL if playing the original replay
- virtual void PauseReplay() = 0;
- virtual bool IsReplayPaused() = 0;
- virtual void ResumeReplay() = 0;
- virtual void OnSignonStateFull() = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef IREPLAYDEMOPLAYER_H +#define IREPLAYDEMOPLAYER_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "interface.h" +#include "replay/replay.h" + +//---------------------------------------------------------------------------------------- + +#define INTERFACEVERSION_REPLAYDEMOPLAYER "ReplayDemoPlayer001" + +//---------------------------------------------------------------------------------------- + +// +// Interface for replay demo player +// +class IReplayDemoPlayer : public IBaseInterface +{ +public: + virtual void PlayReplay( ReplayHandle_t hReplay, int iPerformance ) = 0; + virtual void PlayNextReplay() = 0; + virtual void ClearReplayList() = 0; + virtual void AddReplayToList( ReplayHandle_t hReplay, int iPerformance ) = 0; + virtual CReplay *GetCurrentReplay() = 0; + virtual CReplayPerformance *GetCurrentPerformance() = 0; // The playing replay, or NULL if playing the original replay + virtual void PauseReplay() = 0; + virtual bool IsReplayPaused() = 0; + virtual void ResumeReplay() = 0; + virtual void OnSignonStateFull() = 0; +}; + +//---------------------------------------------------------------------------------------- + #endif // IREPLAYDEMOPLAYER_H
\ No newline at end of file diff --git a/mp/src/common/replay/ireplayerrorsystem.h b/mp/src/common/replay/ireplayerrorsystem.h index 4f0c5d02..cc39b7e1 100644 --- a/mp/src/common/replay/ireplayerrorsystem.h +++ b/mp/src/common/replay/ireplayerrorsystem.h @@ -1,33 +1,33 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef IREPLAYERRORSYSYTEM_H
-#define IREPLAYERRORSYSYTEM_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "interface.h"
-
-//----------------------------------------------------------------------------------------
-
-class KeyValues;
-
-//----------------------------------------------------------------------------------------
-
-//
-// Replay error system
-//
-class IReplayErrorSystem : public IBaseInterface
-{
-public:
- virtual void AddErrorFromTokenName( const char *pToken ) = 0;
- virtual void AddFormattedErrorFromTokenName( const char *pFormatToken, KeyValues *pFormatArgs ) = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef IREPLAYERRORSYSYTEM_H +#define IREPLAYERRORSYSYTEM_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "interface.h" + +//---------------------------------------------------------------------------------------- + +class KeyValues; + +//---------------------------------------------------------------------------------------- + +// +// Replay error system +// +class IReplayErrorSystem : public IBaseInterface +{ +public: + virtual void AddErrorFromTokenName( const char *pToken ) = 0; + virtual void AddFormattedErrorFromTokenName( const char *pFormatToken, KeyValues *pFormatArgs ) = 0; +}; + +//---------------------------------------------------------------------------------------- + #endif // IREPLAYERRORSYSYTEM_H
\ No newline at end of file diff --git a/mp/src/common/replay/ireplayfactory.h b/mp/src/common/replay/ireplayfactory.h index 09f0a16d..0aad205a 100644 --- a/mp/src/common/replay/ireplayfactory.h +++ b/mp/src/common/replay/ireplayfactory.h @@ -1,31 +1,31 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef IREPLAYFACTORY_H
-#define IREPLAYFACTORY_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "interface.h"
-
-//----------------------------------------------------------------------------------------
-
-class CReplay;
-
-//----------------------------------------------------------------------------------------
-
-abstract_class IReplayFactory : public IBaseInterface
-{
-public:
- virtual CReplay *Create() = 0;
-};
-
-#define INTERFACE_VERSION_REPLAY_FACTORY "IReplayFactory001"
-
-//----------------------------------------------------------------------------------------
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef IREPLAYFACTORY_H +#define IREPLAYFACTORY_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "interface.h" + +//---------------------------------------------------------------------------------------- + +class CReplay; + +//---------------------------------------------------------------------------------------- + +abstract_class IReplayFactory : public IBaseInterface +{ +public: + virtual CReplay *Create() = 0; +}; + +#define INTERFACE_VERSION_REPLAY_FACTORY "IReplayFactory001" + +//---------------------------------------------------------------------------------------- + #endif // IREPLAYFACTORY_H
\ No newline at end of file diff --git a/mp/src/common/replay/ireplaymanager.h b/mp/src/common/replay/ireplaymanager.h index 4f11dfdf..bf6ffd76 100644 --- a/mp/src/common/replay/ireplaymanager.h +++ b/mp/src/common/replay/ireplaymanager.h @@ -1,42 +1,42 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef IREPLAYMANAGER_H
-#define IREPLAYMANAGER_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "interface.h"
-#include "replay/replayhandle.h"
-#include "utllinkedlist.h"
-
-//----------------------------------------------------------------------------------------
-
-class CReplay;
-class IQueryableReplayItem;
-
-//----------------------------------------------------------------------------------------
-
-class IReplayManager : public IBaseInterface
-{
-public:
- virtual CReplay *GetReplay( ReplayHandle_t hReplay ) = 0;
- virtual CReplay *GetPlayingReplay() = 0;
- virtual CReplay *GetReplayForCurrentLife() = 0;
- virtual void FlagReplayForFlush( CReplay *pReplay, bool bForceImmediate ) = 0;
- virtual void DeleteReplay( ReplayHandle_t hReplay, bool bNotifyUI ) = 0;
- virtual int GetReplayCount() const = 0;
- virtual int GetUnrenderedReplayCount() = 0; // Get the number of unrendered replays
- virtual void GetReplays( CUtlLinkedList< CReplay *, int > &lstReplays ) = 0;
- virtual void GetReplaysAsQueryableItems( CUtlLinkedList< IQueryableReplayItem *, int > &lstReplays ) = 0;
- virtual float GetDownloadProgress( const CReplay *pReplay ) = 0;
- virtual const char *GetReplaysDir() const = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
-#endif // IREPLAYMANAGER_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef IREPLAYMANAGER_H +#define IREPLAYMANAGER_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "interface.h" +#include "replay/replayhandle.h" +#include "utllinkedlist.h" + +//---------------------------------------------------------------------------------------- + +class CReplay; +class IQueryableReplayItem; + +//---------------------------------------------------------------------------------------- + +class IReplayManager : public IBaseInterface +{ +public: + virtual CReplay *GetReplay( ReplayHandle_t hReplay ) = 0; + virtual CReplay *GetPlayingReplay() = 0; + virtual CReplay *GetReplayForCurrentLife() = 0; + virtual void FlagReplayForFlush( CReplay *pReplay, bool bForceImmediate ) = 0; + virtual void DeleteReplay( ReplayHandle_t hReplay, bool bNotifyUI ) = 0; + virtual int GetReplayCount() const = 0; + virtual int GetUnrenderedReplayCount() = 0; // Get the number of unrendered replays + virtual void GetReplays( CUtlLinkedList< CReplay *, int > &lstReplays ) = 0; + virtual void GetReplaysAsQueryableItems( CUtlLinkedList< IQueryableReplayItem *, int > &lstReplays ) = 0; + virtual float GetDownloadProgress( const CReplay *pReplay ) = 0; + virtual const char *GetReplaysDir() const = 0; +}; + +//---------------------------------------------------------------------------------------- + +#endif // IREPLAYMANAGER_H diff --git a/mp/src/common/replay/ireplaymovie.h b/mp/src/common/replay/ireplaymovie.h index 6b271111..2a2caee3 100644 --- a/mp/src/common/replay/ireplaymovie.h +++ b/mp/src/common/replay/ireplaymovie.h @@ -1,42 +1,42 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef IREPLAYMOVIE_H
-#define IREPLAYMOVIE_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "iqueryablereplayitem.h"
-#include "replay/rendermovieparams.h"
-
-//----------------------------------------------------------------------------------------
-
-abstract_class IReplayMovie : public IQueryableReplayItem
-{
-public:
- virtual ReplayHandle_t GetMovieHandle() const = 0;
- virtual ReplayHandle_t GetReplayHandle() const = 0;
- virtual const ReplayRenderSettings_t &GetRenderSettings() = 0;
- virtual void GetFrameDimensions( int &nWidth, int &nHeight ) = 0;
- virtual void SetIsRendered( bool bIsRendered ) = 0;
- virtual void SetMovieFilename( const char *pFilename ) = 0;
- virtual const char *GetMovieFilename() const = 0;
- virtual void SetMovieTitle( const wchar_t *pTitle ) = 0;
- virtual void SetRenderTime( float flRenderTime ) = 0;
- virtual float GetRenderTime() const = 0;
- virtual void CaptureRecordTime() = 0;
- virtual void SetLength( float flLength ) = 0;
-
- virtual bool IsUploaded() const = 0;
- virtual void SetUploaded( bool bUploaded ) = 0;
- virtual void SetUploadURL( const char *pURL ) = 0;
- virtual const char *GetUploadURL() const = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef IREPLAYMOVIE_H +#define IREPLAYMOVIE_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "iqueryablereplayitem.h" +#include "replay/rendermovieparams.h" + +//---------------------------------------------------------------------------------------- + +abstract_class IReplayMovie : public IQueryableReplayItem +{ +public: + virtual ReplayHandle_t GetMovieHandle() const = 0; + virtual ReplayHandle_t GetReplayHandle() const = 0; + virtual const ReplayRenderSettings_t &GetRenderSettings() = 0; + virtual void GetFrameDimensions( int &nWidth, int &nHeight ) = 0; + virtual void SetIsRendered( bool bIsRendered ) = 0; + virtual void SetMovieFilename( const char *pFilename ) = 0; + virtual const char *GetMovieFilename() const = 0; + virtual void SetMovieTitle( const wchar_t *pTitle ) = 0; + virtual void SetRenderTime( float flRenderTime ) = 0; + virtual float GetRenderTime() const = 0; + virtual void CaptureRecordTime() = 0; + virtual void SetLength( float flLength ) = 0; + + virtual bool IsUploaded() const = 0; + virtual void SetUploaded( bool bUploaded ) = 0; + virtual void SetUploadURL( const char *pURL ) = 0; + virtual const char *GetUploadURL() const = 0; +}; + +//---------------------------------------------------------------------------------------- + #endif // IREPLAYMOVIE_H
\ No newline at end of file diff --git a/mp/src/common/replay/ireplaymoviemanager.h b/mp/src/common/replay/ireplaymoviemanager.h index b7fe0f23..40f605f0 100644 --- a/mp/src/common/replay/ireplaymoviemanager.h +++ b/mp/src/common/replay/ireplaymoviemanager.h @@ -1,56 +1,56 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef IREPLAYMOVIEMANAGER_H
-#define IREPLAYMOVIEMANAGER_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "interface.h"
-#include "utlstring.h"
-#include "utllinkedlist.h"
-#include "replay/replayhandle.h"
-
-//----------------------------------------------------------------------------------------
-
-class IReplayMovie;
-class CReplay;
-struct RenderMovieParams_t;
-class IQueryableReplayItem;
-
-//----------------------------------------------------------------------------------------
-
-abstract_class IReplayMovieManager : public IBaseInterface
-{
-public:
- virtual int GetMovieCount() = 0;
- virtual void GetMovieList( CUtlLinkedList< IReplayMovie * > &list ) = 0; // Fills the list with all movies
- virtual IReplayMovie *GetMovie( ReplayHandle_t hMovie ) = 0;
- virtual IReplayMovie *CreateAndAddMovie( ReplayHandle_t hReplay ) = 0; // Creates and adds a movie based on the given replay
- virtual void DeleteMovie( ReplayHandle_t hMovie ) = 0; // Delete a movie
- virtual int GetNumMoviesDependentOnReplay( const CReplay *pReplay ) = 0; // Get the number of movies that depend on the given replay
- virtual void GetCachedMovieTitleAndClear( wchar_t *pOut, int nOutBufLength ) = 0; // TODO: This is a hack - fix this
- virtual void SetPendingMovie( IReplayMovie *pMovie ) = 0;
- virtual IReplayMovie *GetPendingMovie() = 0;
- virtual void FlagMovieForFlush( IReplayMovie *pMovie, bool bImmediate ) = 0;
- virtual void GetMoviesAsQueryableItems( CUtlLinkedList< IQueryableReplayItem *, int > &lstMovies ) = 0;
- virtual const char *GetRenderDir() const = 0;
- virtual const char *GetRawExportDir() const = 0;
-
- // TODO: Is this the best place for code that actually manages rendering?
- virtual bool IsRendering() const = 0;
- virtual bool RenderingCancelled() const = 0;
- virtual void RenderMovie( RenderMovieParams_t const& params ) = 0; // Renders the given replay - or if params.hReplay is -1, render all unrendered replays
- virtual void RenderNextMovie() = 0;
- virtual void CompleteRender( bool bSuccess, bool bShowBrowser ) = 0;
- virtual void CancelRender() = 0;
- virtual void ClearRenderCancelledFlag() = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef IREPLAYMOVIEMANAGER_H +#define IREPLAYMOVIEMANAGER_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "interface.h" +#include "utlstring.h" +#include "utllinkedlist.h" +#include "replay/replayhandle.h" + +//---------------------------------------------------------------------------------------- + +class IReplayMovie; +class CReplay; +struct RenderMovieParams_t; +class IQueryableReplayItem; + +//---------------------------------------------------------------------------------------- + +abstract_class IReplayMovieManager : public IBaseInterface +{ +public: + virtual int GetMovieCount() = 0; + virtual void GetMovieList( CUtlLinkedList< IReplayMovie * > &list ) = 0; // Fills the list with all movies + virtual IReplayMovie *GetMovie( ReplayHandle_t hMovie ) = 0; + virtual IReplayMovie *CreateAndAddMovie( ReplayHandle_t hReplay ) = 0; // Creates and adds a movie based on the given replay + virtual void DeleteMovie( ReplayHandle_t hMovie ) = 0; // Delete a movie + virtual int GetNumMoviesDependentOnReplay( const CReplay *pReplay ) = 0; // Get the number of movies that depend on the given replay + virtual void GetCachedMovieTitleAndClear( wchar_t *pOut, int nOutBufLength ) = 0; // TODO: This is a hack - fix this + virtual void SetPendingMovie( IReplayMovie *pMovie ) = 0; + virtual IReplayMovie *GetPendingMovie() = 0; + virtual void FlagMovieForFlush( IReplayMovie *pMovie, bool bImmediate ) = 0; + virtual void GetMoviesAsQueryableItems( CUtlLinkedList< IQueryableReplayItem *, int > &lstMovies ) = 0; + virtual const char *GetRenderDir() const = 0; + virtual const char *GetRawExportDir() const = 0; + + // TODO: Is this the best place for code that actually manages rendering? + virtual bool IsRendering() const = 0; + virtual bool RenderingCancelled() const = 0; + virtual void RenderMovie( RenderMovieParams_t const& params ) = 0; // Renders the given replay - or if params.hReplay is -1, render all unrendered replays + virtual void RenderNextMovie() = 0; + virtual void CompleteRender( bool bSuccess, bool bShowBrowser ) = 0; + virtual void CancelRender() = 0; + virtual void ClearRenderCancelledFlag() = 0; +}; + +//---------------------------------------------------------------------------------------- + #endif // IREPLAYMOVIEMANAGER_H
\ No newline at end of file diff --git a/mp/src/common/replay/ireplaymovierenderer.h b/mp/src/common/replay/ireplaymovierenderer.h index 94d5117f..e70835ac 100644 --- a/mp/src/common/replay/ireplaymovierenderer.h +++ b/mp/src/common/replay/ireplaymovierenderer.h @@ -1,33 +1,33 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef IREPLAYMOVIERENDERER_H
-#define IREPLAYMOVIERENDERER_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-class IReplayMovie;
-struct RenderMovieParams_t;
-
-//----------------------------------------------------------------------------------------
-
-abstract_class IReplayMovieRenderer : public IBaseInterface
-{
-public:
- virtual bool SetupRenderer( RenderMovieParams_t ¶ms, IReplayMovie *pMovie ) = 0;
- virtual void ShutdownRenderer() = 0;
- virtual void RenderVideo() = 0;
- virtual void RenderAudio( unsigned char *pBuffer, int nSize, int nNumSamples ) = 0;
-
- virtual void SetAudioSyncFrame( bool isSync = false ) = 0;
- virtual bool IsAudioSyncFrame() = 0;
- virtual float GetRecordingFrameDuration() = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
-#endif // IREPLAYMOVIERENDERER_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef IREPLAYMOVIERENDERER_H +#define IREPLAYMOVIERENDERER_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +class IReplayMovie; +struct RenderMovieParams_t; + +//---------------------------------------------------------------------------------------- + +abstract_class IReplayMovieRenderer : public IBaseInterface +{ +public: + virtual bool SetupRenderer( RenderMovieParams_t ¶ms, IReplayMovie *pMovie ) = 0; + virtual void ShutdownRenderer() = 0; + virtual void RenderVideo() = 0; + virtual void RenderAudio( unsigned char *pBuffer, int nSize, int nNumSamples ) = 0; + + virtual void SetAudioSyncFrame( bool isSync = false ) = 0; + virtual bool IsAudioSyncFrame() = 0; + virtual float GetRecordingFrameDuration() = 0; +}; + +//---------------------------------------------------------------------------------------- + +#endif // IREPLAYMOVIERENDERER_H diff --git a/mp/src/common/replay/ireplayperformancecontroller.h b/mp/src/common/replay/ireplayperformancecontroller.h index 2479fac5..70a119e9 100644 --- a/mp/src/common/replay/ireplayperformancecontroller.h +++ b/mp/src/common/replay/ireplayperformancecontroller.h @@ -1,107 +1,107 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef IREPLAYPERFORMANCECONTROLLER_H
-#define IREPLAYPERFORMANCECONTROLLER_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "interface.h"
-#include "tier1/strtools.h"
-
-//----------------------------------------------------------------------------------------
-
-class IReplayPerformanceEditor;
-class CReplay;
-class Vector;
-class QAngle;
-class CReplayPerformance;
-
-//----------------------------------------------------------------------------------------
-
-// These values are what we use to represent
-
-struct SetViewParams_t
-{
- SetViewParams_t() { V_memset( this, 0, sizeof( SetViewParams_t ) ); }
- SetViewParams_t( float flTime, Vector *pOrigin, QAngle *pAngles, float flFov, float flAccel,
- float flSpeed, float flRotFilter )
- : m_flTime( flTime ),
- m_pOrigin( pOrigin ),
- m_pAngles( pAngles ),
- m_flFov( flFov ),
- m_flAccel( flAccel ),
- m_flSpeed( flSpeed ),
- m_flRotationFilter( flRotFilter )
- {
- }
-
- float m_flTime;
- Vector *m_pOrigin;
- QAngle *m_pAngles;
- float m_flFov;
-
- // Right now only used for updating UI during playback:
- float m_flAccel;
- float m_flSpeed;
- float m_flRotationFilter;
-};
-
-//----------------------------------------------------------------------------------------
-
-class IReplayPerformanceController : public IBaseInterface
-{
-public:
- virtual void SetEditor( IReplayPerformanceEditor *pEditor ) = 0;
-
- virtual bool IsPlaybackDataLeft() = 0;
-
- virtual void StartRecording( CReplay *pReplay, bool bSnip ) = 0;
- virtual void NotifyRewinding() = 0;
-
- virtual void Stop() = 0;
- virtual bool SaveAsync() = 0;
- virtual bool SaveAsAsync( const wchar *pTitle ) = 0;
-
- virtual bool IsSaving() const = 0;
-
- virtual void SaveThink() = 0;
-
- virtual bool GetLastSaveStatus() const = 0;
-
- virtual bool IsRecording() const = 0;
- virtual bool IsPlaying() const = 0;
-
- virtual bool IsDirty() const = 0;
- virtual void NotifyDirty() = 0;
-
- virtual CReplayPerformance *GetPerformance() = 0;
- virtual CReplayPerformance *GetSavedPerformance() = 0;
- virtual bool HasSavedPerformance() = 0;
-
- virtual void NotifyPauseState( bool bPaused ) = 0;
-
- virtual void ClearRewinding() = 0;
-
- virtual void OnSignonStateFull() = 0;
-
- virtual float GetPlaybackTimeScale() const = 0;
-
- //
- // Recorder-specific:
- //
- virtual void AddEvent_Camera_Change_FirstPerson( float flTime, int nEntityIndex ) = 0;
- virtual void AddEvent_Camera_Change_ThirdPerson( float flTime, int nEntityIndex ) = 0;
- virtual void AddEvent_Camera_Change_Free( float flTime ) = 0;
- virtual void AddEvent_Camera_ChangePlayer( float flTime, int nEntIndex ) = 0;
- virtual void AddEvent_Camera_SetView( const SetViewParams_t ¶ms ) = 0;
- virtual void AddEvent_TimeScale( float flTime, float flScale ) = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
-#endif // IREPLAYPERFORMANCECONTROLLER_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef IREPLAYPERFORMANCECONTROLLER_H +#define IREPLAYPERFORMANCECONTROLLER_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "interface.h" +#include "tier1/strtools.h" + +//---------------------------------------------------------------------------------------- + +class IReplayPerformanceEditor; +class CReplay; +class Vector; +class QAngle; +class CReplayPerformance; + +//---------------------------------------------------------------------------------------- + +// These values are what we use to represent + +struct SetViewParams_t +{ + SetViewParams_t() { V_memset( this, 0, sizeof( SetViewParams_t ) ); } + SetViewParams_t( float flTime, Vector *pOrigin, QAngle *pAngles, float flFov, float flAccel, + float flSpeed, float flRotFilter ) + : m_flTime( flTime ), + m_pOrigin( pOrigin ), + m_pAngles( pAngles ), + m_flFov( flFov ), + m_flAccel( flAccel ), + m_flSpeed( flSpeed ), + m_flRotationFilter( flRotFilter ) + { + } + + float m_flTime; + Vector *m_pOrigin; + QAngle *m_pAngles; + float m_flFov; + + // Right now only used for updating UI during playback: + float m_flAccel; + float m_flSpeed; + float m_flRotationFilter; +}; + +//---------------------------------------------------------------------------------------- + +class IReplayPerformanceController : public IBaseInterface +{ +public: + virtual void SetEditor( IReplayPerformanceEditor *pEditor ) = 0; + + virtual bool IsPlaybackDataLeft() = 0; + + virtual void StartRecording( CReplay *pReplay, bool bSnip ) = 0; + virtual void NotifyRewinding() = 0; + + virtual void Stop() = 0; + virtual bool SaveAsync() = 0; + virtual bool SaveAsAsync( const wchar *pTitle ) = 0; + + virtual bool IsSaving() const = 0; + + virtual void SaveThink() = 0; + + virtual bool GetLastSaveStatus() const = 0; + + virtual bool IsRecording() const = 0; + virtual bool IsPlaying() const = 0; + + virtual bool IsDirty() const = 0; + virtual void NotifyDirty() = 0; + + virtual CReplayPerformance *GetPerformance() = 0; + virtual CReplayPerformance *GetSavedPerformance() = 0; + virtual bool HasSavedPerformance() = 0; + + virtual void NotifyPauseState( bool bPaused ) = 0; + + virtual void ClearRewinding() = 0; + + virtual void OnSignonStateFull() = 0; + + virtual float GetPlaybackTimeScale() const = 0; + + // + // Recorder-specific: + // + virtual void AddEvent_Camera_Change_FirstPerson( float flTime, int nEntityIndex ) = 0; + virtual void AddEvent_Camera_Change_ThirdPerson( float flTime, int nEntityIndex ) = 0; + virtual void AddEvent_Camera_Change_Free( float flTime ) = 0; + virtual void AddEvent_Camera_ChangePlayer( float flTime, int nEntIndex ) = 0; + virtual void AddEvent_Camera_SetView( const SetViewParams_t ¶ms ) = 0; + virtual void AddEvent_TimeScale( float flTime, float flScale ) = 0; +}; + +//---------------------------------------------------------------------------------------- + +#endif // IREPLAYPERFORMANCECONTROLLER_H diff --git a/mp/src/common/replay/ireplayperformanceeditor.h b/mp/src/common/replay/ireplayperformanceeditor.h index f5a09d8c..d1eff854 100644 --- a/mp/src/common/replay/ireplayperformanceeditor.h +++ b/mp/src/common/replay/ireplayperformanceeditor.h @@ -1,33 +1,33 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef IREPLAYPERFORMANCEEDITOR_H
-#define IREPLAYPERFORMANCEEDITOR_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "interface.h"
-
-//----------------------------------------------------------------------------------------
-
-class CReplay;
-
-//----------------------------------------------------------------------------------------
-
-//
-// Interface to allow the replay DLL to talk to the actual UI.
-//
-class IReplayPerformanceEditor : public IBaseInterface
-{
-public:
- virtual CReplay *GetReplay() = 0;
- virtual void OnRewindComplete() = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
-#endif // IREPLAYPERFORMANCEEDITOR_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef IREPLAYPERFORMANCEEDITOR_H +#define IREPLAYPERFORMANCEEDITOR_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "interface.h" + +//---------------------------------------------------------------------------------------- + +class CReplay; + +//---------------------------------------------------------------------------------------- + +// +// Interface to allow the replay DLL to talk to the actual UI. +// +class IReplayPerformanceEditor : public IBaseInterface +{ +public: + virtual CReplay *GetReplay() = 0; + virtual void OnRewindComplete() = 0; +}; + +//---------------------------------------------------------------------------------------- + +#endif // IREPLAYPERFORMANCEEDITOR_H diff --git a/mp/src/common/replay/ireplayperformancemanager.h b/mp/src/common/replay/ireplayperformancemanager.h index 728624fd..67852dd3 100644 --- a/mp/src/common/replay/ireplayperformancemanager.h +++ b/mp/src/common/replay/ireplayperformancemanager.h @@ -1,36 +1,36 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef IREPLAYPERFORMANCEMANAGER_H
-#define IREPLAYPERFORMANCEMANAGER_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "interface.h"
-
-//----------------------------------------------------------------------------------------
-
-class CReplayPerformance;
-class CReplay;
-
-//----------------------------------------------------------------------------------------
-
-class IReplayPerformanceManager : public IBaseInterface
-{
-public:
- virtual CReplayPerformance *CreatePerformance( CReplay *pReplay ) = 0;
- virtual void DeletePerformance( CReplayPerformance *pPerformance ) = 0;
-
- virtual const char *GetRelativePath() const = 0;
- virtual const char *GetFullPath() const = 0;
-
- virtual const char *GeneratePerformanceFilename( CReplay *pReplay ) = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
-#endif // IREPLAYPERFORMANCEMANAGER_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef IREPLAYPERFORMANCEMANAGER_H +#define IREPLAYPERFORMANCEMANAGER_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "interface.h" + +//---------------------------------------------------------------------------------------- + +class CReplayPerformance; +class CReplay; + +//---------------------------------------------------------------------------------------- + +class IReplayPerformanceManager : public IBaseInterface +{ +public: + virtual CReplayPerformance *CreatePerformance( CReplay *pReplay ) = 0; + virtual void DeletePerformance( CReplayPerformance *pPerformance ) = 0; + + virtual const char *GetRelativePath() const = 0; + virtual const char *GetFullPath() const = 0; + + virtual const char *GeneratePerformanceFilename( CReplay *pReplay ) = 0; +}; + +//---------------------------------------------------------------------------------------- + +#endif // IREPLAYPERFORMANCEMANAGER_H diff --git a/mp/src/common/replay/ireplayperformanceplaybackhandler.h b/mp/src/common/replay/ireplayperformanceplaybackhandler.h index bb3ad111..2d3146f0 100644 --- a/mp/src/common/replay/ireplayperformanceplaybackhandler.h +++ b/mp/src/common/replay/ireplayperformanceplaybackhandler.h @@ -1,36 +1,36 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef IREPLAYPERFORMANCEPLAYBACKHANDLER_H
-#define IREPLAYPERFORMANCEPLAYBACKHANDLER_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "interface.h"
-#include "replay/ireplayperformancecontroller.h"
-
-//----------------------------------------------------------------------------------------
-
-class Vector;
-class QAngle;
-
-//----------------------------------------------------------------------------------------
-
-class IReplayPerformancePlaybackHandler : public IBaseInterface
-{
-public:
- virtual void OnEvent_Camera_Change_FirstPerson( float flTime, int nEntityIndex ) = 0;
- virtual void OnEvent_Camera_Change_ThirdPerson( float flTime, int nEntityIndex ) = 0;
- virtual void OnEvent_Camera_Change_Free( float flTime ) = 0;
- virtual void OnEvent_Camera_ChangePlayer( float flTime, int nEntIndex ) = 0;
- virtual void OnEvent_Camera_SetView( const SetViewParams_t ¶ms ) = 0;
- virtual void OnEvent_TimeScale( float flTime, float flScale ) = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
-#endif // IREPLAYPERFORMANCEPLAYBACKHANDLER_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef IREPLAYPERFORMANCEPLAYBACKHANDLER_H +#define IREPLAYPERFORMANCEPLAYBACKHANDLER_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "interface.h" +#include "replay/ireplayperformancecontroller.h" + +//---------------------------------------------------------------------------------------- + +class Vector; +class QAngle; + +//---------------------------------------------------------------------------------------- + +class IReplayPerformancePlaybackHandler : public IBaseInterface +{ +public: + virtual void OnEvent_Camera_Change_FirstPerson( float flTime, int nEntityIndex ) = 0; + virtual void OnEvent_Camera_Change_ThirdPerson( float flTime, int nEntityIndex ) = 0; + virtual void OnEvent_Camera_Change_Free( float flTime ) = 0; + virtual void OnEvent_Camera_ChangePlayer( float flTime, int nEntIndex ) = 0; + virtual void OnEvent_Camera_SetView( const SetViewParams_t ¶ms ) = 0; + virtual void OnEvent_TimeScale( float flTime, float flScale ) = 0; +}; + +//---------------------------------------------------------------------------------------- + +#endif // IREPLAYPERFORMANCEPLAYBACKHANDLER_H diff --git a/mp/src/common/replay/ireplayperformanceplayer.h b/mp/src/common/replay/ireplayperformanceplayer.h index cd7e7628..5739b189 100644 --- a/mp/src/common/replay/ireplayperformanceplayer.h +++ b/mp/src/common/replay/ireplayperformanceplayer.h @@ -1,33 +1,33 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef IREPLAYPERFORMANCEPLAYER_H
-#define IREPLAYPERFORMANCEPLAYER_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "interface.h"
-
-//----------------------------------------------------------------------------------------
-
-class CReplay;
-class CReplayPerformance;
-
-//----------------------------------------------------------------------------------------
-
-class IReplayPerformancePlayer : public IBaseInterface
-{
-public:
- virtual void BeginPerformancePlay( CReplayPerformance *pPerformance ) = 0;
- virtual void EndPerformancePlay() = 0;
-
- virtual bool IsPlaying() const = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
-#endif // IREPLAYPERFORMANCEPLAYER_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef IREPLAYPERFORMANCEPLAYER_H +#define IREPLAYPERFORMANCEPLAYER_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "interface.h" + +//---------------------------------------------------------------------------------------- + +class CReplay; +class CReplayPerformance; + +//---------------------------------------------------------------------------------------- + +class IReplayPerformancePlayer : public IBaseInterface +{ +public: + virtual void BeginPerformancePlay( CReplayPerformance *pPerformance ) = 0; + virtual void EndPerformancePlay() = 0; + + virtual bool IsPlaying() const = 0; +}; + +//---------------------------------------------------------------------------------------- + +#endif // IREPLAYPERFORMANCEPLAYER_H diff --git a/mp/src/common/replay/ireplayperformancerecorder.h b/mp/src/common/replay/ireplayperformancerecorder.h index 83997eb7..1274ab0e 100644 --- a/mp/src/common/replay/ireplayperformancerecorder.h +++ b/mp/src/common/replay/ireplayperformancerecorder.h @@ -1,49 +1,49 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef IREPLAYPERFORMANCERECORDER_H
-#define IREPLAYPERFORMANCERECORDER_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "interface.h"
-
-//----------------------------------------------------------------------------------------
-
-class CReplay;
-class Vector;
-class QAngle;
-class CReplayPerformance;
-
-//----------------------------------------------------------------------------------------
-
-class IReplayPerformanceRecorder : public IBaseInterface
-{
-public:
- virtual void BeginPerformanceRecord( CReplay *pReplay ) = 0;
- virtual void EndPerformanceRecord() = 0;
-
- virtual void NotifyPauseState( bool bPaused ) = 0;
-
- virtual CReplayPerformance *GetPerformance() = 0;
- virtual bool IsRecording() const = 0;
-
- virtual void SnipAtTime( float flTime ) = 0;
- virtual void NotifySkipping() = 0;
- virtual void ClearSkipping() = 0;
-
- virtual void AddEvent_Camera_Change_FirstPerson( float flTime, int nEntityIndex ) = 0;
- virtual void AddEvent_Camera_Change_ThirdPerson( float flTime, int nEntityIndex ) = 0;
- virtual void AddEvent_Camera_Change_Free( float flTime ) = 0;
- virtual void AddEvent_Camera_ChangePlayer( float flTime, int nEntIndex ) = 0;
- virtual void AddEvent_Camera_SetView( float flTime, const Vector& origin, const QAngle &angles, float fov ) = 0;
- virtual void AddEvent_Slowmo( float flTime, float flScale ) = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
-#endif // IREPLAYPERFORMANCERECORDER_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef IREPLAYPERFORMANCERECORDER_H +#define IREPLAYPERFORMANCERECORDER_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "interface.h" + +//---------------------------------------------------------------------------------------- + +class CReplay; +class Vector; +class QAngle; +class CReplayPerformance; + +//---------------------------------------------------------------------------------------- + +class IReplayPerformanceRecorder : public IBaseInterface +{ +public: + virtual void BeginPerformanceRecord( CReplay *pReplay ) = 0; + virtual void EndPerformanceRecord() = 0; + + virtual void NotifyPauseState( bool bPaused ) = 0; + + virtual CReplayPerformance *GetPerformance() = 0; + virtual bool IsRecording() const = 0; + + virtual void SnipAtTime( float flTime ) = 0; + virtual void NotifySkipping() = 0; + virtual void ClearSkipping() = 0; + + virtual void AddEvent_Camera_Change_FirstPerson( float flTime, int nEntityIndex ) = 0; + virtual void AddEvent_Camera_Change_ThirdPerson( float flTime, int nEntityIndex ) = 0; + virtual void AddEvent_Camera_Change_Free( float flTime ) = 0; + virtual void AddEvent_Camera_ChangePlayer( float flTime, int nEntIndex ) = 0; + virtual void AddEvent_Camera_SetView( float flTime, const Vector& origin, const QAngle &angles, float fov ) = 0; + virtual void AddEvent_Slowmo( float flTime, float flScale ) = 0; +}; + +//---------------------------------------------------------------------------------------- + +#endif // IREPLAYPERFORMANCERECORDER_H diff --git a/mp/src/common/replay/ireplayplayercache.h b/mp/src/common/replay/ireplayplayercache.h index e27ad2e7..c1a816f3 100644 --- a/mp/src/common/replay/ireplayplayercache.h +++ b/mp/src/common/replay/ireplayplayercache.h @@ -1,41 +1,41 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//----------------------------------------------------------------------------------------
-
-#ifndef IREPLAYPLAYERCACHE_H
-#define IREPLAYPLAYERCACHE_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include "interface.h"
-
-//----------------------------------------------------------------------------------------
-
-#define REPLAYPLAYERCACHE_INTERFACE_VERSION "VENGINE_REPLAY_PLAYER_CACHE_001"
-
-//----------------------------------------------------------------------------------------
-
-abstract_class IReplayPlayerCache : public IBaseInterface
-{
-public:
- virtual bool Init() = 0;
- virtual void Shutdown() = 0;
-
- virtual void SetupPlayer( int nEntIndex ) = 0;
- virtual void DeletePlayerEntry( int nEntIndex ) = 0;
-
- virtual bool PlayerHasCacheEntry( int nEntIndex ) = 0;
-
- virtual void SetPlayerClass( int nEntIndex, const char *pPlayerClass ) = 0;
- virtual void SetPlayerSpawnTick( int nEntIndex, int nTick ) = 0;
- virtual void SetPlayerDeathTick( int nEntIndex, int nTick ) = 0;
-
- virtual const char *GetPlayerClass( int nEntIndex ) = 0;
- virtual int GetPlayerSpawnTick( int nEntIndex ) = 0;
- virtual int GetPlayerDeathTick( int nEntIndex ) = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
-#endif // IREPLAYPLAYERCACHE_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//---------------------------------------------------------------------------------------- + +#ifndef IREPLAYPLAYERCACHE_H +#define IREPLAYPLAYERCACHE_H +#ifdef _WIN32 +#pragma once +#endif + +#include "interface.h" + +//---------------------------------------------------------------------------------------- + +#define REPLAYPLAYERCACHE_INTERFACE_VERSION "VENGINE_REPLAY_PLAYER_CACHE_001" + +//---------------------------------------------------------------------------------------- + +abstract_class IReplayPlayerCache : public IBaseInterface +{ +public: + virtual bool Init() = 0; + virtual void Shutdown() = 0; + + virtual void SetupPlayer( int nEntIndex ) = 0; + virtual void DeletePlayerEntry( int nEntIndex ) = 0; + + virtual bool PlayerHasCacheEntry( int nEntIndex ) = 0; + + virtual void SetPlayerClass( int nEntIndex, const char *pPlayerClass ) = 0; + virtual void SetPlayerSpawnTick( int nEntIndex, int nTick ) = 0; + virtual void SetPlayerDeathTick( int nEntIndex, int nTick ) = 0; + + virtual const char *GetPlayerClass( int nEntIndex ) = 0; + virtual int GetPlayerSpawnTick( int nEntIndex ) = 0; + virtual int GetPlayerDeathTick( int nEntIndex ) = 0; +}; + +//---------------------------------------------------------------------------------------- + +#endif // IREPLAYPLAYERCACHE_H diff --git a/mp/src/common/replay/ireplayrenderqueue.h b/mp/src/common/replay/ireplayrenderqueue.h index e92b33e4..320d90e4 100644 --- a/mp/src/common/replay/ireplayrenderqueue.h +++ b/mp/src/common/replay/ireplayrenderqueue.h @@ -1,32 +1,32 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef IREPLAYRENDERQUEUE_H
-#define IREPLAYRENDERQUEUE_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "interface.h"
-#include "replay/replayhandle.h"
-
-//----------------------------------------------------------------------------------------
-
-abstract_class IReplayRenderQueue : IBaseInterface
-{
-public:
- virtual void Add( ReplayHandle_t hReplay, int iPerformance ) = 0;
- virtual void Remove( ReplayHandle_t hReplay, int iPerformance ) = 0;
- virtual void Clear() = 0;
-
- virtual int GetCount() const = 0;
- virtual bool GetEntryData( int iIndex, ReplayHandle_t *pHandleOut, int *pPerformanceOut ) const = 0;
- virtual bool IsInQueue( ReplayHandle_t hReplay, int iPerformance ) const = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef IREPLAYRENDERQUEUE_H +#define IREPLAYRENDERQUEUE_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "interface.h" +#include "replay/replayhandle.h" + +//---------------------------------------------------------------------------------------- + +abstract_class IReplayRenderQueue : IBaseInterface +{ +public: + virtual void Add( ReplayHandle_t hReplay, int iPerformance ) = 0; + virtual void Remove( ReplayHandle_t hReplay, int iPerformance ) = 0; + virtual void Clear() = 0; + + virtual int GetCount() const = 0; + virtual bool GetEntryData( int iIndex, ReplayHandle_t *pHandleOut, int *pPerformanceOut ) const = 0; + virtual bool IsInQueue( ReplayHandle_t hReplay, int iPerformance ) const = 0; +}; + +//---------------------------------------------------------------------------------------- + #endif // IREPLAYRENDERQUEUE_H
\ No newline at end of file diff --git a/mp/src/common/replay/ireplayscreenshotmanager.h b/mp/src/common/replay/ireplayscreenshotmanager.h index c23d8028..8d73ac40 100644 --- a/mp/src/common/replay/ireplayscreenshotmanager.h +++ b/mp/src/common/replay/ireplayscreenshotmanager.h @@ -1,32 +1,32 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef IREPLAYSCREENSHOTMANAGER_H
-#define IREPLAYSCREENSHOTMANAGER_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "interface.h"
-
-//----------------------------------------------------------------------------------------
-
-class CReplay;
-struct CaptureScreenshotParams_t;
-
-//----------------------------------------------------------------------------------------
-
-class IReplayScreenshotManager : public IBaseInterface
-{
-public:
- virtual void CaptureScreenshot( CaptureScreenshotParams_t& params ) = 0;
- virtual void GetUnpaddedScreenshotSize( int &nOutWidth, int &nOutHeight ) = 0;
- virtual void DeleteScreenshotsForReplay( CReplay *pReplay ) = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
-#endif // IREPLAYSCREENSHOTMANAGER_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef IREPLAYSCREENSHOTMANAGER_H +#define IREPLAYSCREENSHOTMANAGER_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "interface.h" + +//---------------------------------------------------------------------------------------- + +class CReplay; +struct CaptureScreenshotParams_t; + +//---------------------------------------------------------------------------------------- + +class IReplayScreenshotManager : public IBaseInterface +{ +public: + virtual void CaptureScreenshot( CaptureScreenshotParams_t& params ) = 0; + virtual void GetUnpaddedScreenshotSize( int &nOutWidth, int &nOutHeight ) = 0; + virtual void DeleteScreenshotsForReplay( CReplay *pReplay ) = 0; +}; + +//---------------------------------------------------------------------------------------- + +#endif // IREPLAYSCREENSHOTMANAGER_H diff --git a/mp/src/common/replay/ireplayscreenshotsystem.h b/mp/src/common/replay/ireplayscreenshotsystem.h index 00e6e334..82166a45 100644 --- a/mp/src/common/replay/ireplayscreenshotsystem.h +++ b/mp/src/common/replay/ireplayscreenshotsystem.h @@ -1,34 +1,34 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef IREPLAYSCREENSHOTSYSTEM_H
-#define IREPLAYSCREENSHOTSYSTEM_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "interface.h"
-
-//----------------------------------------------------------------------------------------
-
-struct WriteReplayScreenshotParams_t;
-
-//----------------------------------------------------------------------------------------
-
-//
-// Implementation lives in the client - allows replay to tell the client to grab a
-// screenshot or update the cache.
-//
-class IReplayScreenshotSystem : public IBaseInterface
-{
-public:
- virtual void WriteReplayScreenshot( WriteReplayScreenshotParams_t ¶ms ) = 0;
- virtual void UpdateReplayScreenshotCache() = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef IREPLAYSCREENSHOTSYSTEM_H +#define IREPLAYSCREENSHOTSYSTEM_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "interface.h" + +//---------------------------------------------------------------------------------------- + +struct WriteReplayScreenshotParams_t; + +//---------------------------------------------------------------------------------------- + +// +// Implementation lives in the client - allows replay to tell the client to grab a +// screenshot or update the cache. +// +class IReplayScreenshotSystem : public IBaseInterface +{ +public: + virtual void WriteReplayScreenshot( WriteReplayScreenshotParams_t ¶ms ) = 0; + virtual void UpdateReplayScreenshotCache() = 0; +}; + +//---------------------------------------------------------------------------------------- + #endif // IREPLAYSCREENSHOTSYSTEM_H
\ No newline at end of file diff --git a/mp/src/common/replay/ireplayserializeable.h b/mp/src/common/replay/ireplayserializeable.h index a2ba5cd9..cc94628d 100644 --- a/mp/src/common/replay/ireplayserializeable.h +++ b/mp/src/common/replay/ireplayserializeable.h @@ -1,48 +1,48 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef IREPLAYSERIALIIZEABLE_H
-#define IREPLAYSERIALIIZEABLE_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "interface.h"
-#include "replay/replayhandle.h"
-
-//----------------------------------------------------------------------------------------
-
-class KeyValues;
-
-//----------------------------------------------------------------------------------------
-
-class IReplaySerializeable : public IBaseInterface
-{
-public:
- virtual void SetHandle( ReplayHandle_t h ) = 0;
- virtual ReplayHandle_t GetHandle() const = 0;
-
- virtual bool Read( KeyValues *pIn ) = 0;
- virtual void Write( KeyValues *pOut ) = 0;
-
- virtual const char *GetSubKeyTitle() const = 0;
- virtual const char *GetFilename() const = 0;
- virtual const char *GetPath() const = 0;
-
- virtual const char *GetFullFilename() const = 0;
-
- virtual void SetLocked( bool bLocked ) = 0;
- virtual bool IsLocked() const = 0;
-
- virtual void OnDelete() = 0;
- virtual void OnUnload() = 0;
-
- virtual const char *GetDebugName() const = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef IREPLAYSERIALIIZEABLE_H +#define IREPLAYSERIALIIZEABLE_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "interface.h" +#include "replay/replayhandle.h" + +//---------------------------------------------------------------------------------------- + +class KeyValues; + +//---------------------------------------------------------------------------------------- + +class IReplaySerializeable : public IBaseInterface +{ +public: + virtual void SetHandle( ReplayHandle_t h ) = 0; + virtual ReplayHandle_t GetHandle() const = 0; + + virtual bool Read( KeyValues *pIn ) = 0; + virtual void Write( KeyValues *pOut ) = 0; + + virtual const char *GetSubKeyTitle() const = 0; + virtual const char *GetFilename() const = 0; + virtual const char *GetPath() const = 0; + + virtual const char *GetFullFilename() const = 0; + + virtual void SetLocked( bool bLocked ) = 0; + virtual bool IsLocked() const = 0; + + virtual void OnDelete() = 0; + virtual void OnUnload() = 0; + + virtual const char *GetDebugName() const = 0; +}; + +//---------------------------------------------------------------------------------------- + #endif // IREPLAYSERIALIIZEABLE_H
\ No newline at end of file diff --git a/mp/src/common/replay/ireplayserver.h b/mp/src/common/replay/ireplayserver.h index f6de4e56..f2f4bf22 100644 --- a/mp/src/common/replay/ireplayserver.h +++ b/mp/src/common/replay/ireplayserver.h @@ -1,48 +1,48 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//
-//=============================================================================//
-
-#ifndef IREPLAYSERVER_H
-#define IREPLAYSERVER_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-//-----------------------------------------------------------------------------
-
-#include "interface.h"
-
-//-----------------------------------------------------------------------------
-
-class IServer;
-class IReplayDirector;
-class IGameEvent;
-struct netadr_s;
-class CServerReplay;
-
-//-----------------------------------------------------------------------------
-// Interface the Replay module exposes to the engine
-//-----------------------------------------------------------------------------
-#define INTERFACEVERSION_REPLAYSERVER "ReplayServer001"
-
-class IReplayServer : public IBaseInterface
-{
-public:
- virtual ~IReplayServer() {}
-
- virtual IServer *GetBaseServer() = 0; // get Replay base server interface
- virtual IReplayDirector *GetDirector() = 0; // get director interface
- virtual int GetReplaySlot() = 0; // return entity index-1 of Replay in game
- virtual float GetOnlineTime() = 0; // seconds since broadcast started
- virtual void BroadcastEvent(IGameEvent *event) = 0; // send a director command to all specs
- virtual bool IsRecording() = 0;
- virtual void StartRecording() = 0;
- virtual void StopRecording() = 0;
-};
-
-#endif
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +// +//=============================================================================// + +#ifndef IREPLAYSERVER_H +#define IREPLAYSERVER_H + +#ifdef _WIN32 +#pragma once +#endif + +//----------------------------------------------------------------------------- + +#include "interface.h" + +//----------------------------------------------------------------------------- + +class IServer; +class IReplayDirector; +class IGameEvent; +struct netadr_s; +class CServerReplay; + +//----------------------------------------------------------------------------- +// Interface the Replay module exposes to the engine +//----------------------------------------------------------------------------- +#define INTERFACEVERSION_REPLAYSERVER "ReplayServer001" + +class IReplayServer : public IBaseInterface +{ +public: + virtual ~IReplayServer() {} + + virtual IServer *GetBaseServer() = 0; // get Replay base server interface + virtual IReplayDirector *GetDirector() = 0; // get director interface + virtual int GetReplaySlot() = 0; // return entity index-1 of Replay in game + virtual float GetOnlineTime() = 0; // seconds since broadcast started + virtual void BroadcastEvent(IGameEvent *event) = 0; // send a director command to all specs + virtual bool IsRecording() = 0; + virtual void StartRecording() = 0; + virtual void StopRecording() = 0; +}; + +#endif diff --git a/mp/src/common/replay/ireplaysessionrecorder.h b/mp/src/common/replay/ireplaysessionrecorder.h index 846a6831..6c5f905d 100644 --- a/mp/src/common/replay/ireplaysessionrecorder.h +++ b/mp/src/common/replay/ireplaysessionrecorder.h @@ -1,27 +1,27 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef IREPLAYSESSIONRECORDER_H
-#define IREPLAYSESSIONRECORDER_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "interface.h"
-
-//----------------------------------------------------------------------------------------
-
-class IReplaySessionRecorder : public IBaseInterface
-{
-public:
- virtual void StartRecording() = 0;
- virtual void StopRecording( bool bAborting ) = 0;
- virtual void SetCurrentRecordingStartTick( int nStartTick ) = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef IREPLAYSESSIONRECORDER_H +#define IREPLAYSESSIONRECORDER_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "interface.h" + +//---------------------------------------------------------------------------------------- + +class IReplaySessionRecorder : public IBaseInterface +{ +public: + virtual void StartRecording() = 0; + virtual void StopRecording( bool bAborting ) = 0; + virtual void SetCurrentRecordingStartTick( int nStartTick ) = 0; +}; + +//---------------------------------------------------------------------------------------- + #endif // IREPLAYSESSIONRECORDER_H
\ No newline at end of file diff --git a/mp/src/common/replay/ireplaysystem.h b/mp/src/common/replay/ireplaysystem.h index 19c9c24b..0f468839 100644 --- a/mp/src/common/replay/ireplaysystem.h +++ b/mp/src/common/replay/ireplaysystem.h @@ -1,60 +1,60 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef IREPLAYSYSTEM_H
-#define IREPLAYSYSTEM_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "appframework/IAppSystem.h"
-
-//----------------------------------------------------------------------------------------
-
-class IClientReplayContext;
-class IServerReplayContext;
-class IGameEvent;
-
-//----------------------------------------------------------------------------------------
-
-abstract_class IReplaySystem : public IAppSystem
-{
-public:
- // IAppSystem:
- virtual bool Connect( CreateInterfaceFn fnFactory ) = 0;
- virtual void Disconnect() = 0;
- virtual InitReturnVal_t Init() = 0;
- virtual void Shutdown() = 0;
-
- // To be called client- & server-side
- virtual void Think() = 0;
- virtual bool IsReplayEnabled() = 0;
- virtual bool IsRecording() = 0;
-
- // To be called client-side only - on dedicated servers, only subs defined
- virtual bool CL_Init( CreateInterfaceFn fnClientFactory ) = 0;
- virtual void CL_Shutdown() = 0;
- virtual void CL_Render() = 0;
- virtual IClientReplayContext *CL_GetContext() = 0;
-
- // To be called server-side only
- virtual bool SV_Init( CreateInterfaceFn fnFactory ) = 0;
- virtual void SV_Shutdown() = 0;
- virtual void SV_EndRecordingSession( bool bForceSynchronousPublish = false ) = 0;
- virtual void SV_SendReplayEvent( const char *pEventName, int nClientSlot ) = 0;
- virtual void SV_SendReplayEvent( IGameEvent *pEvent, int nClientSlot ) = 0;
- virtual bool SV_ShouldBeginRecording( bool bIsInWaitingForPlayers ) = 0;
- virtual void SV_NotifyReplayRequested() = 0;
- virtual IServerReplayContext *SV_GetContext() = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
-#define REPLAY_INTERFACE_VERSION "ReplaySystem001"
-
-//----------------------------------------------------------------------------------------
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef IREPLAYSYSTEM_H +#define IREPLAYSYSTEM_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "appframework/IAppSystem.h" + +//---------------------------------------------------------------------------------------- + +class IClientReplayContext; +class IServerReplayContext; +class IGameEvent; + +//---------------------------------------------------------------------------------------- + +abstract_class IReplaySystem : public IAppSystem +{ +public: + // IAppSystem: + virtual bool Connect( CreateInterfaceFn fnFactory ) = 0; + virtual void Disconnect() = 0; + virtual InitReturnVal_t Init() = 0; + virtual void Shutdown() = 0; + + // To be called client- & server-side + virtual void Think() = 0; + virtual bool IsReplayEnabled() = 0; + virtual bool IsRecording() = 0; + + // To be called client-side only - on dedicated servers, only subs defined + virtual bool CL_Init( CreateInterfaceFn fnClientFactory ) = 0; + virtual void CL_Shutdown() = 0; + virtual void CL_Render() = 0; + virtual IClientReplayContext *CL_GetContext() = 0; + + // To be called server-side only + virtual bool SV_Init( CreateInterfaceFn fnFactory ) = 0; + virtual void SV_Shutdown() = 0; + virtual void SV_EndRecordingSession( bool bForceSynchronousPublish = false ) = 0; + virtual void SV_SendReplayEvent( const char *pEventName, int nClientSlot ) = 0; + virtual void SV_SendReplayEvent( IGameEvent *pEvent, int nClientSlot ) = 0; + virtual bool SV_ShouldBeginRecording( bool bIsInWaitingForPlayers ) = 0; + virtual void SV_NotifyReplayRequested() = 0; + virtual IServerReplayContext *SV_GetContext() = 0; +}; + +//---------------------------------------------------------------------------------------- + +#define REPLAY_INTERFACE_VERSION "ReplaySystem001" + +//---------------------------------------------------------------------------------------- + #endif // IREPLAYSYSTEM_H
\ No newline at end of file diff --git a/mp/src/common/replay/iserverengine.h b/mp/src/common/replay/iserverengine.h index 0581a7f0..f4cd3299 100644 --- a/mp/src/common/replay/iserverengine.h +++ b/mp/src/common/replay/iserverengine.h @@ -1,27 +1,27 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef ISERVERENGINE_H
-#define ISERVERENGINE_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "interface.h"
-
-//----------------------------------------------------------------------------------------
-
-class IReplayServerEngine : public IBaseInterface
-{
-public:
- virtual void EndReplayRecordingSession() = 0;
- virtual bool IsReplayRecording() = 0;
- virtual bool IsReplay() = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef ISERVERENGINE_H +#define ISERVERENGINE_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "interface.h" + +//---------------------------------------------------------------------------------------- + +class IReplayServerEngine : public IBaseInterface +{ +public: + virtual void EndReplayRecordingSession() = 0; + virtual bool IsReplayRecording() = 0; + virtual bool IsReplay() = 0; +}; + +//---------------------------------------------------------------------------------------- + #endif // ISERVERENGINE_H
\ No newline at end of file diff --git a/mp/src/common/replay/iserverreplay.h b/mp/src/common/replay/iserverreplay.h index 666220a6..3ab5c7f0 100644 --- a/mp/src/common/replay/iserverreplay.h +++ b/mp/src/common/replay/iserverreplay.h @@ -1,37 +1,37 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef ISERVERREPLAY_H
-#define ISERVERREPLAY_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "interface.h"
-
-//----------------------------------------------------------------------------------------
-
-#define SERVER_REPLAY_INTERFACE_VERSION "ServerReplay001"
-
-//----------------------------------------------------------------------------------------
-
-class IReplayFactory;
-class KeyValues;
-
-//----------------------------------------------------------------------------------------
-
-//
-// Allows the replay DLL to talk to the server
-//
-class IServerReplay : public IBaseInterface
-{
-public:
- virtual void UploadOgsData( KeyValues *pData, bool bIncludeTimeField ) = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef ISERVERREPLAY_H +#define ISERVERREPLAY_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "interface.h" + +//---------------------------------------------------------------------------------------- + +#define SERVER_REPLAY_INTERFACE_VERSION "ServerReplay001" + +//---------------------------------------------------------------------------------------- + +class IReplayFactory; +class KeyValues; + +//---------------------------------------------------------------------------------------- + +// +// Allows the replay DLL to talk to the server +// +class IServerReplay : public IBaseInterface +{ +public: + virtual void UploadOgsData( KeyValues *pData, bool bIncludeTimeField ) = 0; +}; + +//---------------------------------------------------------------------------------------- + #endif // ISERVERREPLAY_H
\ No newline at end of file diff --git a/mp/src/common/replay/iserverreplaycontext.h b/mp/src/common/replay/iserverreplaycontext.h index a8e07d15..2437c765 100644 --- a/mp/src/common/replay/iserverreplaycontext.h +++ b/mp/src/common/replay/iserverreplaycontext.h @@ -1,38 +1,38 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef ISERVERREPLAYCONTEXT_H
-#define ISERVERREPLAYCONTEXT_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "replay/ireplaycontext.h"
-
-//----------------------------------------------------------------------------------------
-
-class IGameEvent;
-class IReplaySessionRecorder;
-
-//----------------------------------------------------------------------------------------
-
-#define REPLAYHISTORYMANAGER_INTERFACE_VERSION_SERVER "VENGINE_SERVER_REPLAY_HISTORY_MANAGER_001"
-
-//----------------------------------------------------------------------------------------
-
-class IServerReplayContext : public IReplayContext
-{
-public:
- virtual void FlagForConVarSanityCheck() = 0; // Checks replay_enable / replay_local_fileserver_path / replay_downloadurlport / replay_downloadurlpath
- virtual IGameEvent *CreateReplaySessionInfoEvent() = 0; // Create "replay_sessioninfo" event w/ appropriate fields filled in
- virtual IReplaySessionRecorder *GetSessionRecorder() = 0;
- virtual const char *GetLocalFileServerPath() const = 0; // Returns the local path where session blocks and such should be published for download
- virtual void CreateSessionOnClient( int nClientSlot ) = 0;
-};
-
-//----------------------------------------------------------------------------------------
-
-#endif // ISERVERREPLAYCONTEXT_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef ISERVERREPLAYCONTEXT_H +#define ISERVERREPLAYCONTEXT_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "replay/ireplaycontext.h" + +//---------------------------------------------------------------------------------------- + +class IGameEvent; +class IReplaySessionRecorder; + +//---------------------------------------------------------------------------------------- + +#define REPLAYHISTORYMANAGER_INTERFACE_VERSION_SERVER "VENGINE_SERVER_REPLAY_HISTORY_MANAGER_001" + +//---------------------------------------------------------------------------------------- + +class IServerReplayContext : public IReplayContext +{ +public: + virtual void FlagForConVarSanityCheck() = 0; // Checks replay_enable / replay_local_fileserver_path / replay_downloadurlport / replay_downloadurlpath + virtual IGameEvent *CreateReplaySessionInfoEvent() = 0; // Create "replay_sessioninfo" event w/ appropriate fields filled in + virtual IReplaySessionRecorder *GetSessionRecorder() = 0; + virtual const char *GetLocalFileServerPath() const = 0; // Returns the local path where session blocks and such should be published for download + virtual void CreateSessionOnClient( int nClientSlot ) = 0; +}; + +//---------------------------------------------------------------------------------------- + +#endif // ISERVERREPLAYCONTEXT_H diff --git a/mp/src/common/replay/performance.h b/mp/src/common/replay/performance.h index e6541cd3..a38e1163 100644 --- a/mp/src/common/replay/performance.h +++ b/mp/src/common/replay/performance.h @@ -1,63 +1,63 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef REPLAYPERFORMANCE_H
-#define REPLAYPERFORMANCE_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "shared_defs.h"
-#include "qlimits.h"
-
-//----------------------------------------------------------------------------------------
-
-class CReplay;
-class KeyValues;
-
-//----------------------------------------------------------------------------------------
-
-class CReplayPerformance
-{
-public:
- CReplayPerformance( CReplay *pReplay );
-
- inline bool HasInTick() const { return m_nTickIn >= 0; }
- inline bool HasOutTick() const { return m_nTickOut >= 0; }
-
- inline int GetTickIn() const { return m_nTickIn; }
- inline int GetTickOut() const { return m_nTickOut; }
-
- void Copy( const CReplayPerformance *pSrc );
- void CopyTicks( const CReplayPerformance *pSrc );
-
- void SetFilename( const char *pFilename );
- const char *GetFullPerformanceFilename();
-
- void AutoNameIfHasNoTitle( const char *pMapName );
- void SetTitle( const wchar_t *pTitle );
-
- // NOTE: Doesn't copy exactly - gets a valid filename for the returned performance.
- CReplayPerformance *MakeCopy() const;
-
- void Read( KeyValues *pIn );
- void Write( KeyValues *pOut );
-
- // NOTE: Any changes made here should be reflected in the copy constructor
- // (which is called from MakeCopy()).
- wchar_t m_wszTitle[MAX_TAKE_TITLE_LENGTH];
- char m_szBaseFilename[ MAX_OSPATH ];
- CReplay *m_pReplay;
- int m_nTickIn;
- int m_nTickOut;
-
-private:
- CReplayPerformance( const CReplayPerformance *pPerformance );
-};
-
-//----------------------------------------------------------------------------------------
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef REPLAYPERFORMANCE_H +#define REPLAYPERFORMANCE_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "shared_defs.h" +#include "qlimits.h" + +//---------------------------------------------------------------------------------------- + +class CReplay; +class KeyValues; + +//---------------------------------------------------------------------------------------- + +class CReplayPerformance +{ +public: + CReplayPerformance( CReplay *pReplay ); + + inline bool HasInTick() const { return m_nTickIn >= 0; } + inline bool HasOutTick() const { return m_nTickOut >= 0; } + + inline int GetTickIn() const { return m_nTickIn; } + inline int GetTickOut() const { return m_nTickOut; } + + void Copy( const CReplayPerformance *pSrc ); + void CopyTicks( const CReplayPerformance *pSrc ); + + void SetFilename( const char *pFilename ); + const char *GetFullPerformanceFilename(); + + void AutoNameIfHasNoTitle( const char *pMapName ); + void SetTitle( const wchar_t *pTitle ); + + // NOTE: Doesn't copy exactly - gets a valid filename for the returned performance. + CReplayPerformance *MakeCopy() const; + + void Read( KeyValues *pIn ); + void Write( KeyValues *pOut ); + + // NOTE: Any changes made here should be reflected in the copy constructor + // (which is called from MakeCopy()). + wchar_t m_wszTitle[MAX_TAKE_TITLE_LENGTH]; + char m_szBaseFilename[ MAX_OSPATH ]; + CReplay *m_pReplay; + int m_nTickIn; + int m_nTickOut; + +private: + CReplayPerformance( const CReplayPerformance *pPerformance ); +}; + +//---------------------------------------------------------------------------------------- + #endif // REPLAYPERFORMANCE_H
\ No newline at end of file diff --git a/mp/src/common/replay/rendermovieparams.h b/mp/src/common/replay/rendermovieparams.h index 8076d8e6..2a344d5d 100644 --- a/mp/src/common/replay/rendermovieparams.h +++ b/mp/src/common/replay/rendermovieparams.h @@ -1,62 +1,62 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef RENDERMOVIEPARAMS_H
-#define RENDERMOVIEPARAMS_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "tier1/utlstring.h"
-#include "tier1/strtools.h"
-#include "replay/replayhandle.h"
-#include "replay/shared_defs.h"
-#include "video/ivideoservices.h"
-
-//----------------------------------------------------------------------------------------
-
-typedef unsigned int MovieHandle_t;
-
-struct RenderMovieParams_t
-{
- inline RenderMovieParams_t() : m_iPerformance( -1 ) { V_memset( this, 0, sizeof( RenderMovieParams_t ) ); m_Settings.m_FPS.SetFPS( 0, false ); }
-
- ReplayHandle_t m_hReplay;
- int m_iPerformance; // -1 for default view, otherwise this is an index into the replay's m_vecPerformances vector.
- wchar_t m_wszTitle[MAX_REPLAY_TITLE_LENGTH];
- char m_szVideoPreset[64];
- char m_szExtension[16]; // File extension
- bool m_bQuitWhenFinished;
- bool m_bExportRaw; // Export movie as raw TGA frames and a .WAV
- float m_flEngineFps;
-
- struct ReplayRenderSettings_t
- {
- uint16 m_nWidth;
- uint16 m_nHeight;
- int8 m_nMotionBlurQuality; // [0,MAX_MOTION_BLUR_QUALITY]
- VideoFrameRate_t m_FPS; // Actual framerate can be calculated with m_FPS.GetFps()
- VideoEncodeCodec_t m_Codec;
- bool m_bMotionBlurEnabled; // Motion blur enabled?
- bool m_bAAEnabled; // Antialiasing enabled?
- int8 m_nEncodingQuality; // [0,100]
- bool m_bRaw; // This movie was exported as raw TGA frames and a .WAV file?
- }
- m_Settings;
-};
-
-typedef RenderMovieParams_t::ReplayRenderSettings_t ReplayRenderSettings_t;
-
-//----------------------------------------------------------------------------------------
-
-#define MAX_DOF_QUALITY 2
-#define MAX_MOTION_BLUR_QUALITY 3
-#define SUBPIXEL_JITTER_SAMPLES 16
-#define CHEAP_DOF_SAMPLES 4
-
-//----------------------------------------------------------------------------------------
-
-#endif // RENDERMOVIEPARAMS_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef RENDERMOVIEPARAMS_H +#define RENDERMOVIEPARAMS_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "tier1/utlstring.h" +#include "tier1/strtools.h" +#include "replay/replayhandle.h" +#include "replay/shared_defs.h" +#include "video/ivideoservices.h" + +//---------------------------------------------------------------------------------------- + +typedef unsigned int MovieHandle_t; + +struct RenderMovieParams_t +{ + inline RenderMovieParams_t() : m_iPerformance( -1 ) { V_memset( this, 0, sizeof( RenderMovieParams_t ) ); m_Settings.m_FPS.SetFPS( 0, false ); } + + ReplayHandle_t m_hReplay; + int m_iPerformance; // -1 for default view, otherwise this is an index into the replay's m_vecPerformances vector. + wchar_t m_wszTitle[MAX_REPLAY_TITLE_LENGTH]; + char m_szVideoPreset[64]; + char m_szExtension[16]; // File extension + bool m_bQuitWhenFinished; + bool m_bExportRaw; // Export movie as raw TGA frames and a .WAV + float m_flEngineFps; + + struct ReplayRenderSettings_t + { + uint16 m_nWidth; + uint16 m_nHeight; + int8 m_nMotionBlurQuality; // [0,MAX_MOTION_BLUR_QUALITY] + VideoFrameRate_t m_FPS; // Actual framerate can be calculated with m_FPS.GetFps() + VideoEncodeCodec_t m_Codec; + bool m_bMotionBlurEnabled; // Motion blur enabled? + bool m_bAAEnabled; // Antialiasing enabled? + int8 m_nEncodingQuality; // [0,100] + bool m_bRaw; // This movie was exported as raw TGA frames and a .WAV file? + } + m_Settings; +}; + +typedef RenderMovieParams_t::ReplayRenderSettings_t ReplayRenderSettings_t; + +//---------------------------------------------------------------------------------------- + +#define MAX_DOF_QUALITY 2 +#define MAX_MOTION_BLUR_QUALITY 3 +#define SUBPIXEL_JITTER_SAMPLES 16 +#define CHEAP_DOF_SAMPLES 4 + +//---------------------------------------------------------------------------------------- + +#endif // RENDERMOVIEPARAMS_H diff --git a/mp/src/common/replay/replay.h b/mp/src/common/replay/replay.h index 32f245ce..a0d1cb33 100644 --- a/mp/src/common/replay/replay.h +++ b/mp/src/common/replay/replay.h @@ -1,146 +1,146 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef REPLAY_H
-#define REPLAY_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "replay/iqueryablereplayitem.h"
-#include "replay/replaytime.h"
-#include "replay/basereplayserializeable.h"
-#include "qlimits.h"
-#include "utlstring.h"
-#include "utlvector.h"
-#include "replay/shared_defs.h"
-
-//----------------------------------------------------------------------------------------
-
-class IReplayDownloadEventHandler;
-class CReplayScreenshot;
-class CReplayPerformance;
-
-//----------------------------------------------------------------------------------------
-
-class CReplay : public CBaseReplaySerializeable,
- public IQueryableReplayItem
-{
- typedef CBaseReplaySerializeable BaseClass;
-
-public:
- enum ReplayStatus_t
- {
- REPLAYSTATUS_INVALID,
- REPLAYSTATUS_ERROR,
- REPLAYSTATUS_DOWNLOADPHASE, // Multiple sub-states during download state
- REPLAYSTATUS_READYTOCONVERT, // Download is complete, ready to convert
- REPLAYSTATUS_RENDERING, // Currently rendering the file
- REPLAYSTATUS_RENDERED,
- REPLAYSTATUS_MAX
- };
-
- CReplay();
- virtual ~CReplay() {}
-
- //
- // IReplaySerializeable
- //
- virtual const char *GetSubKeyTitle() const;
- virtual const char *GetPath() const;
- virtual void OnDelete();
- virtual bool Read( KeyValues *pIn );
- virtual void Write( KeyValues *pOut );
-
- virtual void DumpGameSpecificData() const {}
-
- virtual void Update() {}
-
- // Hooks to allow replays to setup event listeners, etc.
- virtual void OnBeginRecording() {}
- virtual void OnEndRecording() {}
-
- // Called when a replay is "completed"
- virtual void OnComplete();
-
- // Should we allow this replay to be deleted?
- virtual bool ShouldAllowDelete() const { return true; }
-
- void AutoNameTitleIfEmpty();
-
- void AddScreenshot( int nWidth, int nHeight, const char *pBaseFilename );
-
- bool HasReconstructedReplay() const;
- bool IsSignificantBlock( int iBlockReconstruction ) const; // Does this replay care about the given block?
-
- CReplayPerformance *AddNewPerformance( bool bGenTitle = true, bool bGenFilename = true );
- void AddPerformance( KeyValues *pIn );
- void AddPerformance( CReplayPerformance *pPerformance );
-
- // Accessors:
- inline int GetScreenshotCount() const { return m_vecScreenshots.Count(); }
- inline const CReplayScreenshot *GetScreenshot( int i ) const { return m_vecScreenshots[ i ]; }
- bool IsDownloaded() const;
- inline int GetPerformanceCount() const { return m_vecPerformances.Count(); }
- CReplayPerformance *GetPerformance( int i );
- const CReplayPerformance *GetPerformance( int i ) const;
- inline bool HasPerformance( CReplayPerformance *pPerformance ) { return m_vecPerformances.Find( pPerformance ) != m_vecPerformances.InvalidIndex(); }
- bool FindPerformance( CReplayPerformance *pPerformance, int &iResult );
- CReplayPerformance *GetPerformanceWithTitle( const wchar_t *pTitle );
- inline const char *GetMapName() const { return m_szMapName; }
- inline int GetSpawnTick() const { return m_nSpawnTick; }
- inline int GetDeathTick() const { return m_nDeathTick; }
-
- // IQueryableReplayItem implementation:
- virtual const CReplayTime &GetItemDate() const;
- virtual bool IsItemRendered() const;
- virtual CReplay *GetItemReplay();
- virtual ReplayHandle_t GetItemReplayHandle() const;
- virtual QueryableReplayItemHandle_t GetItemHandle() const;
- virtual const wchar_t *GetItemTitle() const;
- virtual void SetItemTitle( const wchar_t *pTitle );
- virtual float GetItemLength() const;
- virtual void *GetUserData();
- virtual void SetUserData( void* pUserData );
- virtual bool IsItemAMovie() const;
-
- // Non-persistent data
- mutable IReplayDownloadEventHandler *m_pDownloadEventHandler; // Implemented by replay browser - the reason we've got one per replay rather than
- // one per download group is because the browser needs to receive events per-thumbnail
- bool m_bSaved; // True as soon as the replay is saved to disk for the first time
- bool m_bRequestedByUser; // Did the user request to save this replay?
- bool m_bComplete; // Indicates whether the replay is done recording - this should be false
- // until the player dies, the round ends, or the level changes
- void *m_pUserData;
- float m_flNextUpdateTime;
- bool m_bDirty;
-
- // Persistent data
- ReplayHandle_t m_hSession; // The recording session in which this replay was recorded
- char m_szMapName[MAX_OSPATH];
- ReplayStatus_t m_nStatus;
- const char* m_pFileURL; // In the form <protocol>://<server address>:<port number>/path/file - points to the string in the download group
- wchar_t m_wszTitle[MAX_REPLAY_TITLE_LENGTH];
- CUtlString m_strKilledBy; // Name of player who killed, if any
- int m_nDeathTime;
- int m_nSpawnTick;
- int m_nDeathTick;
- float m_flLength; // The length of the entire replay, including the post-death time, in seconds
- bool m_bRendered; // Has the replay been rendered yet?
- int m_nPlayerSlot; // Player slot (+1), used to determine which player recorded the demo during playback
- int m_nPostDeathRecordTime; // replay_postdeathrecordtime at the time of record
- CUtlVector< CReplayScreenshot * > m_vecScreenshots;
- CUtlVector< CReplayPerformance * > m_vecPerformances;
- int m_iMaxSessionBlockRequired; // The maximum session block required to reconstruct a viewable .dem file from spawn tick until length
- CReplayTime m_RecordTime; // Contains time/date when spawn tick was recorded
- float m_flStartTime; // Start time (uses engine's host_time)
- CUtlString m_strReconstructedFilename;
- bool m_bSavedDuringThisSession;
-};
-
-//----------------------------------------------------------------------------------------
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef REPLAY_H +#define REPLAY_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "replay/iqueryablereplayitem.h" +#include "replay/replaytime.h" +#include "replay/basereplayserializeable.h" +#include "qlimits.h" +#include "utlstring.h" +#include "utlvector.h" +#include "replay/shared_defs.h" + +//---------------------------------------------------------------------------------------- + +class IReplayDownloadEventHandler; +class CReplayScreenshot; +class CReplayPerformance; + +//---------------------------------------------------------------------------------------- + +class CReplay : public CBaseReplaySerializeable, + public IQueryableReplayItem +{ + typedef CBaseReplaySerializeable BaseClass; + +public: + enum ReplayStatus_t + { + REPLAYSTATUS_INVALID, + REPLAYSTATUS_ERROR, + REPLAYSTATUS_DOWNLOADPHASE, // Multiple sub-states during download state + REPLAYSTATUS_READYTOCONVERT, // Download is complete, ready to convert + REPLAYSTATUS_RENDERING, // Currently rendering the file + REPLAYSTATUS_RENDERED, + REPLAYSTATUS_MAX + }; + + CReplay(); + virtual ~CReplay() {} + + // + // IReplaySerializeable + // + virtual const char *GetSubKeyTitle() const; + virtual const char *GetPath() const; + virtual void OnDelete(); + virtual bool Read( KeyValues *pIn ); + virtual void Write( KeyValues *pOut ); + + virtual void DumpGameSpecificData() const {} + + virtual void Update() {} + + // Hooks to allow replays to setup event listeners, etc. + virtual void OnBeginRecording() {} + virtual void OnEndRecording() {} + + // Called when a replay is "completed" + virtual void OnComplete(); + + // Should we allow this replay to be deleted? + virtual bool ShouldAllowDelete() const { return true; } + + void AutoNameTitleIfEmpty(); + + void AddScreenshot( int nWidth, int nHeight, const char *pBaseFilename ); + + bool HasReconstructedReplay() const; + bool IsSignificantBlock( int iBlockReconstruction ) const; // Does this replay care about the given block? + + CReplayPerformance *AddNewPerformance( bool bGenTitle = true, bool bGenFilename = true ); + void AddPerformance( KeyValues *pIn ); + void AddPerformance( CReplayPerformance *pPerformance ); + + // Accessors: + inline int GetScreenshotCount() const { return m_vecScreenshots.Count(); } + inline const CReplayScreenshot *GetScreenshot( int i ) const { return m_vecScreenshots[ i ]; } + bool IsDownloaded() const; + inline int GetPerformanceCount() const { return m_vecPerformances.Count(); } + CReplayPerformance *GetPerformance( int i ); + const CReplayPerformance *GetPerformance( int i ) const; + inline bool HasPerformance( CReplayPerformance *pPerformance ) { return m_vecPerformances.Find( pPerformance ) != m_vecPerformances.InvalidIndex(); } + bool FindPerformance( CReplayPerformance *pPerformance, int &iResult ); + CReplayPerformance *GetPerformanceWithTitle( const wchar_t *pTitle ); + inline const char *GetMapName() const { return m_szMapName; } + inline int GetSpawnTick() const { return m_nSpawnTick; } + inline int GetDeathTick() const { return m_nDeathTick; } + + // IQueryableReplayItem implementation: + virtual const CReplayTime &GetItemDate() const; + virtual bool IsItemRendered() const; + virtual CReplay *GetItemReplay(); + virtual ReplayHandle_t GetItemReplayHandle() const; + virtual QueryableReplayItemHandle_t GetItemHandle() const; + virtual const wchar_t *GetItemTitle() const; + virtual void SetItemTitle( const wchar_t *pTitle ); + virtual float GetItemLength() const; + virtual void *GetUserData(); + virtual void SetUserData( void* pUserData ); + virtual bool IsItemAMovie() const; + + // Non-persistent data + mutable IReplayDownloadEventHandler *m_pDownloadEventHandler; // Implemented by replay browser - the reason we've got one per replay rather than + // one per download group is because the browser needs to receive events per-thumbnail + bool m_bSaved; // True as soon as the replay is saved to disk for the first time + bool m_bRequestedByUser; // Did the user request to save this replay? + bool m_bComplete; // Indicates whether the replay is done recording - this should be false + // until the player dies, the round ends, or the level changes + void *m_pUserData; + float m_flNextUpdateTime; + bool m_bDirty; + + // Persistent data + ReplayHandle_t m_hSession; // The recording session in which this replay was recorded + char m_szMapName[MAX_OSPATH]; + ReplayStatus_t m_nStatus; + const char* m_pFileURL; // In the form <protocol>://<server address>:<port number>/path/file - points to the string in the download group + wchar_t m_wszTitle[MAX_REPLAY_TITLE_LENGTH]; + CUtlString m_strKilledBy; // Name of player who killed, if any + int m_nDeathTime; + int m_nSpawnTick; + int m_nDeathTick; + float m_flLength; // The length of the entire replay, including the post-death time, in seconds + bool m_bRendered; // Has the replay been rendered yet? + int m_nPlayerSlot; // Player slot (+1), used to determine which player recorded the demo during playback + int m_nPostDeathRecordTime; // replay_postdeathrecordtime at the time of record + CUtlVector< CReplayScreenshot * > m_vecScreenshots; + CUtlVector< CReplayPerformance * > m_vecPerformances; + int m_iMaxSessionBlockRequired; // The maximum session block required to reconstruct a viewable .dem file from spawn tick until length + CReplayTime m_RecordTime; // Contains time/date when spawn tick was recorded + float m_flStartTime; // Start time (uses engine's host_time) + CUtlString m_strReconstructedFilename; + bool m_bSavedDuringThisSession; +}; + +//---------------------------------------------------------------------------------------- + #endif // REPLAY_H
\ No newline at end of file diff --git a/mp/src/common/replay/replayhandle.h b/mp/src/common/replay/replayhandle.h index 1c920a55..2dd84148 100644 --- a/mp/src/common/replay/replayhandle.h +++ b/mp/src/common/replay/replayhandle.h @@ -1,25 +1,25 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef REPLAYHANDLE_H
-#define REPLAYHANDLE_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "platform.h"
-
-//----------------------------------------------------------------------------------------
-
-typedef uint32 ReplayHandle_t;
-
-//----------------------------------------------------------------------------------------
-
-#define REPLAY_HANDLE_INVALID ( (ReplayHandle_t)-1 )
-
-//----------------------------------------------------------------------------------------
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef REPLAYHANDLE_H +#define REPLAYHANDLE_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "platform.h" + +//---------------------------------------------------------------------------------------- + +typedef uint32 ReplayHandle_t; + +//---------------------------------------------------------------------------------------- + +#define REPLAY_HANDLE_INVALID ( (ReplayHandle_t)-1 ) + +//---------------------------------------------------------------------------------------- + #endif // REPLAYHANDLE_H
\ No newline at end of file diff --git a/mp/src/common/replay/replaylib.h b/mp/src/common/replay/replaylib.h index 34cb1a9d..9f309807 100644 --- a/mp/src/common/replay/replaylib.h +++ b/mp/src/common/replay/replaylib.h @@ -1,21 +1,21 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef REPLAYLIB_H
-#define REPLAYLIB_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-class IClientReplayContext;
-
-//----------------------------------------------------------------------------------------
-
-bool ReplayLib_Init( const char *pGameDir, IClientReplayContext *pClientReplayContext );
-
-//----------------------------------------------------------------------------------------
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef REPLAYLIB_H +#define REPLAYLIB_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +class IClientReplayContext; + +//---------------------------------------------------------------------------------------- + +bool ReplayLib_Init( const char *pGameDir, IClientReplayContext *pClientReplayContext ); + +//---------------------------------------------------------------------------------------- + #endif // REPLAYLIB_H
\ No newline at end of file diff --git a/mp/src/common/replay/replaytime.h b/mp/src/common/replay/replaytime.h index 02359db7..eb1c3295 100644 --- a/mp/src/common/replay/replaytime.h +++ b/mp/src/common/replay/replaytime.h @@ -1,57 +1,57 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef REPLAYTIME_H
-#define REPLAYTIME_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-class KeyValues;
-
-//----------------------------------------------------------------------------------------
-
-#include "vgui/ILocalize.h"
-
-//----------------------------------------------------------------------------------------
-
-class CReplayTime
-{
-public:
- CReplayTime();
-
- void InitDateAndTimeToNow();
-
- void Read( KeyValues *pIn );
- void Write( KeyValues *pOut );
-
- // Modifiers:
- void SetDate( int nDay, int nMonth, int nYear );
- void SetTime( int nHour, int nMin, int nSec );
- inline void SetRawDate( int nRawDate ) { m_fDate = nRawDate; }
- inline void SetRawTime( int nRawTime ) { m_fTime = nRawTime; }
-
- // Accessors:
- void GetTime( int &nHour, int &nMin, int &nSec ) const;
- void GetDate( int &nDay, int &nMonth, int &nYear ) const;
-
- static const char *FormatTimeString( int nSecs );
- static const char *FormatPreciseTimeString( float flSecs );
- static const wchar_t *GetLocalizedMonth( vgui::ILocalize *pLocalize, int nMonth );
- static const wchar_t *GetLocalizedDay( vgui::ILocalize *pLocalize, int nDay );
- static const wchar_t *GetLocalizedYear( vgui::ILocalize *pLocalize, int nYear );
- static const wchar_t *GetLocalizedTime( vgui::ILocalize *pLocalize, int nHour, int nMin, int nSec );
- static const wchar_t *GetLocalizedDate( vgui::ILocalize *pLocalize, int nDay, int nMonth, int nYear,
- int *pHour = NULL, int *pMin = NULL, int *pSec = NULL, bool bForceFullFormat = false ); // bForceFullFormat true will keep from returning "today" or "yesterday"
- static const wchar_t *GetLocalizedDate( vgui::ILocalize *pLocalize, const CReplayTime &t, bool bForceFullFormat = false );
-
- int m_fDate; // Representation of a date (bitfield)
- int m_fTime; // Representation of time (bitfield)
-};
-
-//----------------------------------------------------------------------------------------
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef REPLAYTIME_H +#define REPLAYTIME_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +class KeyValues; + +//---------------------------------------------------------------------------------------- + +#include "vgui/ILocalize.h" + +//---------------------------------------------------------------------------------------- + +class CReplayTime +{ +public: + CReplayTime(); + + void InitDateAndTimeToNow(); + + void Read( KeyValues *pIn ); + void Write( KeyValues *pOut ); + + // Modifiers: + void SetDate( int nDay, int nMonth, int nYear ); + void SetTime( int nHour, int nMin, int nSec ); + inline void SetRawDate( int nRawDate ) { m_fDate = nRawDate; } + inline void SetRawTime( int nRawTime ) { m_fTime = nRawTime; } + + // Accessors: + void GetTime( int &nHour, int &nMin, int &nSec ) const; + void GetDate( int &nDay, int &nMonth, int &nYear ) const; + + static const char *FormatTimeString( int nSecs ); + static const char *FormatPreciseTimeString( float flSecs ); + static const wchar_t *GetLocalizedMonth( vgui::ILocalize *pLocalize, int nMonth ); + static const wchar_t *GetLocalizedDay( vgui::ILocalize *pLocalize, int nDay ); + static const wchar_t *GetLocalizedYear( vgui::ILocalize *pLocalize, int nYear ); + static const wchar_t *GetLocalizedTime( vgui::ILocalize *pLocalize, int nHour, int nMin, int nSec ); + static const wchar_t *GetLocalizedDate( vgui::ILocalize *pLocalize, int nDay, int nMonth, int nYear, + int *pHour = NULL, int *pMin = NULL, int *pSec = NULL, bool bForceFullFormat = false ); // bForceFullFormat true will keep from returning "today" or "yesterday" + static const wchar_t *GetLocalizedDate( vgui::ILocalize *pLocalize, const CReplayTime &t, bool bForceFullFormat = false ); + + int m_fDate; // Representation of a date (bitfield) + int m_fTime; // Representation of time (bitfield) +}; + +//---------------------------------------------------------------------------------------- + #endif // REPLAYTIME_H
\ No newline at end of file diff --git a/mp/src/common/replay/replayutils.h b/mp/src/common/replay/replayutils.h index 97e011c2..0add85ad 100644 --- a/mp/src/common/replay/replayutils.h +++ b/mp/src/common/replay/replayutils.h @@ -1,43 +1,43 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//----------------------------------------------------------------------------------------
-
-#ifndef REPLAYUTILS_H
-#define REPLAYUTILS_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include "utlstring.h"
-
-void Replay_GetFirstAvailableFilename( char *pDst, int nDstLen, const char *pIdealFilename, const char *pExt,
- const char *pFilePath, int nStartIndex );
-
-void Replay_ConstructReplayFilenameString( CUtlString &strOut, const char *pReplaySubDir, const char *pFilename, const char *pGameDir );
-
-//----------------------------------------------------------------------------------------
-// Util function, copied from src/engine/common.cpp
-//----------------------------------------------------------------------------------------
-char *Replay_va( PRINTF_FORMAT_STRING const char *format, ... );
-
-//----------------------------------------------------------------------------------------
-// Return the base dir, e.g. "c:\...\game\tf\replays\"
-//----------------------------------------------------------------------------------------
-const char *Replay_GetBaseDir();
-
-//----------------------------------------------------------------------------------------
-// Set the game directory (only to be called from ReplayLib_Init())
-//----------------------------------------------------------------------------------------
-void Replay_SetGameDir( const char *pGameDir );
-
-//----------------------------------------------------------------------------------------
-// Return the base dir, e.g. "c:\...\game\tf\replays\"
-//----------------------------------------------------------------------------------------
-const char *Replay_GetGameDir();
-
-//----------------------------------------------------------------------------------------
-// Get a name of the format "<map>: <current date & time>" - used for replays and takes.
-//----------------------------------------------------------------------------------------
-void Replay_GetAutoName( OUT_Z_BYTECAP(nDestSizeInBytes) wchar_t *pDest, int nDestSizeInBytes, const char *pMapName );
-
-#endif // REPLAY_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//---------------------------------------------------------------------------------------- + +#ifndef REPLAYUTILS_H +#define REPLAYUTILS_H +#ifdef _WIN32 +#pragma once +#endif + +#include "utlstring.h" + +void Replay_GetFirstAvailableFilename( char *pDst, int nDstLen, const char *pIdealFilename, const char *pExt, + const char *pFilePath, int nStartIndex ); + +void Replay_ConstructReplayFilenameString( CUtlString &strOut, const char *pReplaySubDir, const char *pFilename, const char *pGameDir ); + +//---------------------------------------------------------------------------------------- +// Util function, copied from src/engine/common.cpp +//---------------------------------------------------------------------------------------- +char *Replay_va( PRINTF_FORMAT_STRING const char *format, ... ); + +//---------------------------------------------------------------------------------------- +// Return the base dir, e.g. "c:\...\game\tf\replays\" +//---------------------------------------------------------------------------------------- +const char *Replay_GetBaseDir(); + +//---------------------------------------------------------------------------------------- +// Set the game directory (only to be called from ReplayLib_Init()) +//---------------------------------------------------------------------------------------- +void Replay_SetGameDir( const char *pGameDir ); + +//---------------------------------------------------------------------------------------- +// Return the base dir, e.g. "c:\...\game\tf\replays\" +//---------------------------------------------------------------------------------------- +const char *Replay_GetGameDir(); + +//---------------------------------------------------------------------------------------- +// Get a name of the format "<map>: <current date & time>" - used for replays and takes. +//---------------------------------------------------------------------------------------- +void Replay_GetAutoName( OUT_Z_BYTECAP(nDestSizeInBytes) wchar_t *pDest, int nDestSizeInBytes, const char *pMapName ); + +#endif // REPLAY_H diff --git a/mp/src/common/replay/screenshot.h b/mp/src/common/replay/screenshot.h index b6126e95..c71bbe13 100644 --- a/mp/src/common/replay/screenshot.h +++ b/mp/src/common/replay/screenshot.h @@ -1,72 +1,72 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef SCREENSHOT_H
-#define SCREENSHOT_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "replay/basereplayserializeable.h"
-#include "mathlib/vector.h"
-#include "qlimits.h"
-#include "strtools.h"
-
-//----------------------------------------------------------------------------------------
-
-#define SUBDIR_SCREENSHOTS "screenshots"
-
-//----------------------------------------------------------------------------------------
-
-class CReplayScreenshot : public CBaseReplaySerializeable
-{
-public:
- inline CReplayScreenshot( int nWidth = 0, int nHeight = 0, const char *pBaseFilename = NULL )
- : m_nWidth( nWidth ), m_nHeight( nHeight )
- {
- if ( pBaseFilename )
- {
- V_strncpy( m_szBaseFilename, pBaseFilename, sizeof( m_szBaseFilename ) );
- }
- }
-
- virtual bool Read( KeyValues *pIn );
- virtual void Write( KeyValues *pOut );
- virtual const char *GetSubKeyTitle() const;
- virtual const char *GetPath() const;
-
- int m_nWidth; // Screenshot width (does not include power-of-2 padding)
- int m_nHeight; // Screenshot height (does not include power-of-2 padding)
- char m_szBaseFilename[ MAX_OSPATH ];
-};
-
-//----------------------------------------------------------------------------------------
-
-struct CaptureScreenshotParams_t // To be passed from the client into IReplayHistoryManager::CaptureScreenshot()
-{
- float m_flDelay; // Delay from now (in seconds) when we will take the screenshot
- int m_nEntity; // Should be 0 if no camera adjustment is needed, otherwise should be the index of the entity index from which m_posCamera will be based
- Vector m_posCamera; // Local position, relative to entity's index (if m_nEntity > 0) for camera position
- QAngle m_angCamera; // World angles of camera - used if m_bUseCameraAngles is true
- bool m_bUseCameraAngles; // Should we use m_angCamera - m_nEntity can't be 0
- bool m_bIgnoreMinTimeBetweenScreenshots; // Force screenshot, regardless of replay_mintimebetweenscreenshots?
- bool m_bPrimary; // Only set to true for the primary screenshot, which is taken when the user saves their replay
-};
-
-//----------------------------------------------------------------------------------------
-
-struct WriteReplayScreenshotParams_t // Passed from the engine into the client to take a screenshot
-{
- const char *m_pFilename;
- int m_nWidth;
- int m_nHeight;
- Vector *m_pOrigin; // Perspective origin from which to render. Can be NULL
- QAngle *m_pAngles; // Perspective angles from which to render. Can be NULL
-};
-
-//----------------------------------------------------------------------------------------
-
-#endif // SCREENSHOT_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef SCREENSHOT_H +#define SCREENSHOT_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "replay/basereplayserializeable.h" +#include "mathlib/vector.h" +#include "qlimits.h" +#include "strtools.h" + +//---------------------------------------------------------------------------------------- + +#define SUBDIR_SCREENSHOTS "screenshots" + +//---------------------------------------------------------------------------------------- + +class CReplayScreenshot : public CBaseReplaySerializeable +{ +public: + inline CReplayScreenshot( int nWidth = 0, int nHeight = 0, const char *pBaseFilename = NULL ) + : m_nWidth( nWidth ), m_nHeight( nHeight ) + { + if ( pBaseFilename ) + { + V_strncpy( m_szBaseFilename, pBaseFilename, sizeof( m_szBaseFilename ) ); + } + } + + virtual bool Read( KeyValues *pIn ); + virtual void Write( KeyValues *pOut ); + virtual const char *GetSubKeyTitle() const; + virtual const char *GetPath() const; + + int m_nWidth; // Screenshot width (does not include power-of-2 padding) + int m_nHeight; // Screenshot height (does not include power-of-2 padding) + char m_szBaseFilename[ MAX_OSPATH ]; +}; + +//---------------------------------------------------------------------------------------- + +struct CaptureScreenshotParams_t // To be passed from the client into IReplayHistoryManager::CaptureScreenshot() +{ + float m_flDelay; // Delay from now (in seconds) when we will take the screenshot + int m_nEntity; // Should be 0 if no camera adjustment is needed, otherwise should be the index of the entity index from which m_posCamera will be based + Vector m_posCamera; // Local position, relative to entity's index (if m_nEntity > 0) for camera position + QAngle m_angCamera; // World angles of camera - used if m_bUseCameraAngles is true + bool m_bUseCameraAngles; // Should we use m_angCamera - m_nEntity can't be 0 + bool m_bIgnoreMinTimeBetweenScreenshots; // Force screenshot, regardless of replay_mintimebetweenscreenshots? + bool m_bPrimary; // Only set to true for the primary screenshot, which is taken when the user saves their replay +}; + +//---------------------------------------------------------------------------------------- + +struct WriteReplayScreenshotParams_t // Passed from the engine into the client to take a screenshot +{ + const char *m_pFilename; + int m_nWidth; + int m_nHeight; + Vector *m_pOrigin; // Perspective origin from which to render. Can be NULL + QAngle *m_pAngles; // Perspective angles from which to render. Can be NULL +}; + +//---------------------------------------------------------------------------------------- + +#endif // SCREENSHOT_H diff --git a/mp/src/common/replay/shared_defs.h b/mp/src/common/replay/shared_defs.h index 550e8678..fa4b0b78 100644 --- a/mp/src/common/replay/shared_defs.h +++ b/mp/src/common/replay/shared_defs.h @@ -1,73 +1,73 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-//=======================================================================================//
-
-#ifndef SHARED_DEFS_H
-#define SHARED_DEFS_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-//----------------------------------------------------------------------------------------
-
-#include "platform.h"
-
-//----------------------------------------------------------------------------------------
-
-#define SUBDIR_REPLAY "replay"
-#define SUBDIR_REPLAYS "replays"
-#define SUBDIR_SESSIONS "sessions"
-#define SUBDIR_BLOCKS "blocks"
-#define SUBDIR_CLIENT "client"
-#define SUBDIR_MOVIES "movies"
-#define SUBDIR_PERFORMANCES "edits"
-#define SUBDIR_SERVER "server"
-#define SUBDIR_RENDERED "rendered"
-#define SUBDIR_TMP "tmp"
-
-//----------------------------------------------------------------------------------------
-
-#define BLOCK_FILE_EXTENSION "block"
-#define GENERIC_FILE_EXTENSION "dmx"
-#define DEMO_FILE_EXTENSION "dem"
-
-//----------------------------------------------------------------------------------------
-
-#define MOVIE_HANDLE_BASE 10000 // 10,000
-
-//----------------------------------------------------------------------------------------
-
-#define BUILD_CURL ( defined( WIN32 ) && !defined( _X360 ) ) || defined( POSIX )
-
-//----------------------------------------------------------------------------------------
-
-#define MIN_SERVER_DUMP_INTERVAL 10
-#define MAX_SERVER_DUMP_INTERVAL 30
-
-#define DOWNLOAD_TIMEOUT_THRESHOLD 90 // Timeout for a replay download - if no blocks
- // are added or updated after this many seconds,
- // the replay will be put in the error state.
-
-//----------------------------------------------------------------------------------------
-
-#define MAX_TIMES_TO_SHOW_REPLAY_WELCOME_DLG 1
-
-//----------------------------------------------------------------------------------------
-
-#define MAX_SESSIONNAME_LENGTH 260
-#define MAX_REPLAY_TITLE_LENGTH 256
-#define MAX_TAKE_TITLE_LENGTH 256
-
-//----------------------------------------------------------------------------------------
-
-#define DEFAULT_COMPRESSOR_TYPE COMPRESSORTYPE_BZ2
-
-//----------------------------------------------------------------------------------------
-
-#define JOB_FAILED ( (JobStatus_t) -1 )
-
-#define DOWNLOAD_MAX_SIZE ( 8 * 1024 * 1024 ) // 8 MB
-
-//----------------------------------------------------------------------------------------
-
-#endif // SHARED_DEFS_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +//=======================================================================================// + +#ifndef SHARED_DEFS_H +#define SHARED_DEFS_H +#ifdef _WIN32 +#pragma once +#endif + +//---------------------------------------------------------------------------------------- + +#include "platform.h" + +//---------------------------------------------------------------------------------------- + +#define SUBDIR_REPLAY "replay" +#define SUBDIR_REPLAYS "replays" +#define SUBDIR_SESSIONS "sessions" +#define SUBDIR_BLOCKS "blocks" +#define SUBDIR_CLIENT "client" +#define SUBDIR_MOVIES "movies" +#define SUBDIR_PERFORMANCES "edits" +#define SUBDIR_SERVER "server" +#define SUBDIR_RENDERED "rendered" +#define SUBDIR_TMP "tmp" + +//---------------------------------------------------------------------------------------- + +#define BLOCK_FILE_EXTENSION "block" +#define GENERIC_FILE_EXTENSION "dmx" +#define DEMO_FILE_EXTENSION "dem" + +//---------------------------------------------------------------------------------------- + +#define MOVIE_HANDLE_BASE 10000 // 10,000 + +//---------------------------------------------------------------------------------------- + +#define BUILD_CURL ( defined( WIN32 ) && !defined( _X360 ) ) || defined( POSIX ) + +//---------------------------------------------------------------------------------------- + +#define MIN_SERVER_DUMP_INTERVAL 10 +#define MAX_SERVER_DUMP_INTERVAL 30 + +#define DOWNLOAD_TIMEOUT_THRESHOLD 90 // Timeout for a replay download - if no blocks + // are added or updated after this many seconds, + // the replay will be put in the error state. + +//---------------------------------------------------------------------------------------- + +#define MAX_TIMES_TO_SHOW_REPLAY_WELCOME_DLG 1 + +//---------------------------------------------------------------------------------------- + +#define MAX_SESSIONNAME_LENGTH 260 +#define MAX_REPLAY_TITLE_LENGTH 256 +#define MAX_TAKE_TITLE_LENGTH 256 + +//---------------------------------------------------------------------------------------- + +#define DEFAULT_COMPRESSOR_TYPE COMPRESSORTYPE_BZ2 + +//---------------------------------------------------------------------------------------- + +#define JOB_FAILED ( (JobStatus_t) -1 ) + +#define DOWNLOAD_MAX_SIZE ( 8 * 1024 * 1024 ) // 8 MB + +//---------------------------------------------------------------------------------------- + +#endif // SHARED_DEFS_H diff --git a/mp/src/common/studiobyteswap.cpp b/mp/src/common/studiobyteswap.cpp index e8d39427..d7723d48 100644 --- a/mp/src/common/studiobyteswap.cpp +++ b/mp/src/common/studiobyteswap.cpp @@ -1,3135 +1,3135 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose: Swaps the bytes in all file types generated by studiomdl
-// (.vvd, .vtx, .mdl, .phy, .ani) so the files can be loaded
-// on a big-endian machine, specifically the Xbox360. A new file is generated
-// with an extra extension in the form of <filename>.360.<ext>
-//
-//=============================================================================//
-
-#include "studio.h"
-#include "optimize.h"
-#include "phyfile.h"
-#include "studiobyteswap.h"
-#include "vphysics_interface.h"
-
-#undef ALIGN4
-#undef ALIGN16
-#undef ALIGN32
-#define ALIGN4( a ) a = (byte *)((int)((byte *)a + 3) & ~ 3)
-#define ALIGN16( a ) a = (byte *)((int)((byte *)a + 15) & ~ 15)
-#define ALIGN32( a ) a = (byte *)((int)((byte *)a + 31) & ~ 31)
-#define ALIGN64( a ) a = (byte *)((int)((byte *)a + 63) & ~ 63)
-
-// Fixup macros create variables that may not be referenced
-#pragma warning( push )
-#pragma warning( disable:4189 ) // local variable is initialized but not referenced
-#pragma warning( disable:4366 ) // The result of the unary '&' operator may be unaligned
-
-namespace StudioByteSwap
-{
-
-static bool g_bVerbose = true;
-static bool g_bNativeSrc;
-static CByteswap g_Swap;
-static IPhysicsCollision *pCollision;
-static CompressFunc_t g_pCompressFunc;
-
-void ActivateByteSwapping( bool activate )
-{
- g_Swap.ActivateByteSwapping( activate );
- SourceIsNative( IsPC() );
-}
-
-void SourceIsNative( bool bNative )
-{
- g_bNativeSrc = bNative;
-}
-
-void SetCollisionInterface( IPhysicsCollision *pPhysicsCollision )
-{
- pCollision = pPhysicsCollision;
-}
-
-void SetVerbose( bool bVerbose )
-{
- g_bVerbose = bVerbose;
-}
-
-//----------------------------------------------------------------------
-// Helper to write a chunk of objects of the same type, and increment the buffer pointers.
-//----------------------------------------------------------------------
-template<class T> inline void WriteObjects( byte **pOutputBuffer, byte **pBaseData, int objectCount = 1 )
-{
- T tempObject;
- for ( int i = 0; i < objectCount; ++i )
- {
- Q_memcpy( &tempObject, *pBaseData, sizeof(T) );
- g_Swap.SwapFieldsToTargetEndian( &tempObject, &tempObject );
- Q_memcpy( *pOutputBuffer, &tempObject, sizeof(T) );
- *pOutputBuffer += sizeof(T);
- *pBaseData += sizeof(T);
- }
-}
-
-//----------------------------------------------------------------------
-// Helper to write a chunk of objects of the same type, and increment the buffer pointers.
-//----------------------------------------------------------------------
-template<class T> inline void WriteObjects( T **pOutputBuffer, T **pBaseData, int objectCount = 1 )
-{
- T tempObject;
- for ( int i = 0; i < objectCount; ++i )
- {
- Q_memcpy( &tempObject, *pBaseData, sizeof(T) );
- g_Swap.SwapFieldsToTargetEndian( &tempObject, &tempObject );
- Q_memcpy( *pOutputBuffer, &tempObject, sizeof(T) );
- ++*pOutputBuffer;
- ++*pBaseData;
- }
-}
-
-//----------------------------------------------------------------------
-// Helper to write a chunk of objects of the same type.
-//----------------------------------------------------------------------
-template<class T> inline void WriteObjects( byte *pOutputBuffer, byte *pBaseData, int objectCount = 1 )
-{
- T tempObject;
- for ( int i = 0; i < objectCount; ++i )
- {
- Q_memcpy( &tempObject, pBaseData, sizeof(T) );
- g_Swap.SwapFieldsToTargetEndian( &tempObject, &tempObject );
- Q_memcpy( pOutputBuffer, &tempObject, sizeof(T) );
- pOutputBuffer += sizeof(T);
- pBaseData += sizeof(T);
- }
-}
-
-//----------------------------------------------------------------------
-// Helper to write a chunk of objects of the same type.
-//----------------------------------------------------------------------
-template<class T> inline void WriteObjects( T *pOutputBuffer, T *pBaseData, int objectCount = 1 )
-{
- T tempObject;
- for ( int i = 0; i < objectCount; ++i )
- {
- Q_memcpy( &tempObject, pBaseData, sizeof(T) );
- g_Swap.SwapFieldsToTargetEndian( &tempObject, &tempObject );
- Q_memcpy( pOutputBuffer, &tempObject, sizeof(T) );
- ++pOutputBuffer;
- ++pBaseData;
- }
-}
-
-//----------------------------------------------------------------------
-// Helper to write a buffer of some integral type, and increment the buffer pointers.
-//----------------------------------------------------------------------
-template<class T> inline void WriteBuffer( byte **pOutputBuffer, byte **pBaseData, int objectCount = 1 )
-{
- T tempObject;
- for ( int i = 0; i < objectCount; ++i )
- {
- Q_memcpy( &tempObject, *pBaseData, sizeof(T) );
- g_Swap.SwapBufferToTargetEndian( &tempObject, &tempObject );
- Q_memcpy( *pOutputBuffer, &tempObject, sizeof(T) );
- *pOutputBuffer += sizeof(T);
- *pBaseData += sizeof(T);
- }
-}
-
-//----------------------------------------------------------------------
-// Helper to write a buffer of some integral type
-//----------------------------------------------------------------------
-template<class T> inline void WriteBuffer( byte *pOutputBuffer, byte *pBaseData, int objectCount = 1 )
-{
- T tempObject;
- for ( int i = 0; i < objectCount; ++i )
- {
- Q_memcpy( &tempObject, pBaseData, sizeof(T) );
- g_Swap.SwapBufferToTargetEndian( &tempObject, &tempObject );
- Q_memcpy( pOutputBuffer, &tempObject, sizeof(T) );
- pOutputBuffer += sizeof(T);
- pBaseData += sizeof(T);
- }
-}
-
-//----------------------------------------------------------------------
-// For getting values in the correct source/dest endian format
-//----------------------------------------------------------------------
-template< class T >
-T SrcNative( T *idx )
-{
- T ret = *idx;
- if ( !g_bNativeSrc )
- {
- g_Swap.SwapBuffer( &ret, idx );
- }
- return ret;
-}
-
-template< class T >
-T DestNative( T *idx )
-{
- T ret = *idx;
- if ( g_bNativeSrc )
- {
- g_Swap.SwapBuffer( &ret, idx );
- }
- return ret;
-}
-
-//----------------------------------------------------------------------
-// Declares objects pointers for src/dest buffer
-//----------------------------------------------------------------------
-#define DECLARE_OBJECT_POINTERS( objPtr, base, type ) \
- type* objPtr##Src = (type*)base##Src; \
- type* objPtr##Dest = (type*)base##Dest; \
- type* objPtr = objPtr##Src;
-
-//----------------------------------------------------------------------
-// Declares src/dest byte pointers and sets them to some index offset in the buffers.
-//----------------------------------------------------------------------
-#define DECLARE_INDEX_POINTERS( ptr, base, index ) \
- byte *ptr##Src = (byte*)base##Src + SrcNative( &base##Src->index ); \
- byte *ptr##Dest = (byte*)base##Dest + SrcNative( &base##Src->index );
-
-//----------------------------------------------------------------------
-// Declares src/dest byte pointers and sets them to some index offset in the buffers.
-// If src pointer is misaligned, the fixup method is called.
-//----------------------------------------------------------------------
-#define DECLARE_INDEX_POINTERS_FIXUP( ptr, base, index ) \
- byte *ptr##Src = (byte*)base##Src + SrcNative( &base##Src->index ); \
- byte *ptr##Dest = (byte*)base##Dest + SrcNative( &base##Src->index ); \
- FIXUP_OFFSETS( ptr, base, index )
-
-//----------------------------------------------------------------------
-// Same as DECLARE_OBJECT_POINTERS, but reuses existing type pointers.
-//----------------------------------------------------------------------
-#define SET_OBJECT_POINTERS( objPtr, base, type ) \
- objPtr##Src = (type*)base##Src; \
- objPtr##Dest = (type*)base##Dest; \
- objPtr = objPtr##Src;
-
-//----------------------------------------------------------------------
-// Same as DECLARE_INDEX_POINTERS, but reuses existing byte pointers.
-//----------------------------------------------------------------------
-#define SET_INDEX_POINTERS( ptr, base, index ) \
- ptr##Src = (byte*)base##Src + SrcNative( &base##Src->index ); \
- ptr##Dest = (byte*)base##Dest + SrcNative( &base##Src->index );
-
-//----------------------------------------------------------------------
-// Same as DECLARE_INDEX_POINTERS, but reuses existing byte pointers.
-// If src pointer is misaligned, the fixup method is called.
-//----------------------------------------------------------------------
-#define SET_INDEX_POINTERS_FIXUP( ptr, base, index ) \
- ptr##Src = (byte*)base##Src + SrcNative( &base##Src->index ); \
- ptr##Dest = (byte*)base##Dest + SrcNative( &base##Src->index ); \
- FIXUP_OFFSETS( ptr, base, index )
-
-//----------------------------------------------------------------------
-// for() loop header, updates all three object pointers (src,dest,native)
-//----------------------------------------------------------------------
-#define ITERATE_BLOCK( objPtr, count ) \
- for ( int objPtr##_idx = 0; objPtr##_idx < SrcNative( &count ); ++objPtr##_idx, ++objPtr, ++objPtr##Src, ++objPtr##Dest )
-
-//----------------------------------------------------------------------
-// Checks for misaligned source pointer, then calculates the necessary fixup,
-// calls the fixup function, and sets the src pointer to the new position.
-//----------------------------------------------------------------------
-#define FIXUP_OFFSETS( ptr, base, index ) \
- { \
- byte *ptr##Fixup = ptr##Src; \
- ALIGN4( ptr##Fixup ); \
- if ( ptr##Fixup != ptr##Src ) \
- { \
- int nShiftBytes = ptr##Fixup - ptr##Src; \
- if ( g_bVerbose ) \
- Warning( "Shifting misaligned data block by %d bytes at " #base "->" #index "\n", nShiftBytes ); \
- int prevBytes = (byte*)ptr##Src - (byte*)g_pDataSrcBase; \
- Q_memmove( (byte*)ptr##Src + nShiftBytes, ptr##Src, fixedFileSize - prevBytes ); \
- g_pFixPoint = ptr##Src; \
- g_nFixupBytes = nShiftBytes; \
- fixedFileSize += nShiftBytes; \
- if ( fixedFileSize > fileSize + BYTESWAP_ALIGNMENT_PADDING ) \
- { \
- Error( "Byteswap buffer overrun - increase BYTESWAP_ALIGNMENT_PADDING!\n" ); \
- return 0; \
- } \
- g_pfnFileProcessFunc( pHdrSrc, UpdateSrcIndexFields ); \
- g_pFixPoint = NULL; \
- g_nFixupBytes = 0; \
- ptr##Src = ptr##Fixup; \
- } \
- }
-
-
-typedef void ( *datadescProcessFunc_t)( void *pBase, void *pData, typedescription_t *pFields );
-typedef void ( *pfnFixupFunc_t )( void *pDestBase, datadescProcessFunc_t );
-
-static pfnFixupFunc_t g_pfnFileProcessFunc;
-static studiohdr_t *g_pHdr;
-static const void *g_pDataSrcBase;
-static void *g_pFixPoint;
-static int g_nFixupBytes;
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-bool UpdateIndex( void *pBase, int *indexMember )
-{
- bool bUpdateIndex = false;
- int idx = *indexMember;
-
- // Update the index fields
- if ( pBase < g_pFixPoint )
- {
- if ( (byte*)pBase + idx >= g_pFixPoint )
- {
- bUpdateIndex = true;
- }
- }
- else
- {
- if ( (byte*)pBase + idx < g_pFixPoint )
- {
- bUpdateIndex = true;
- }
- }
-
- // Update the member offset by the global fixup
- if ( bUpdateIndex && *indexMember )
- {
- *indexMember = idx + g_nFixupBytes * Sign(idx);
- return true;
- }
- return false;
-}
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-int GetIntegerFromField( void *pData, int fieldType )
-{
- if ( fieldType == FIELD_INTEGER )
- {
- return SrcNative( (int*)pData );
- }
- else if ( fieldType == FIELD_SHORT )
- {
- return SrcNative( (short*)pData );
- }
- Error( "Byteswap macro DEFINE_INDEX using unsupported fieldType %d\n", fieldType );
- return 0;
-}
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-void PutIntegerInField( void *pData, int index, int fieldType )
-{
- if ( fieldType == FIELD_INTEGER )
- {
- *(int*)pData = SrcNative( &index );
- }
- else if ( fieldType == FIELD_SHORT )
- {
- *(short*)pData = SrcNative( &index );
- }
- else
- {
- Error( "Byteswap macro DEFINE_INDEX using unsupported fieldType %d\n", fieldType );
- }
-}
-
-//-----------------------------------------------------------------------------
-//
-//-----------------------------------------------------------------------------
-void UpdateSrcIndexFields( void *pBase, void *pData, typedescription_t *pField )
-{
- if ( pField->flags & FTYPEDESC_INDEX )
- {
- int index = GetIntegerFromField( pData, pField->fieldType );
- if ( UpdateIndex( pBase, &index ) )
- {
- PutIntegerInField( pData, index, pField->fieldType );
- }
- }
-}
-
-//-----------------------------------------------------------------------------
-// Pass a datadesc field to a processing function
-//-----------------------------------------------------------------------------
-void ProcessField( void *pBase, void *pData, typedescription_t *pField, datadescProcessFunc_t pfn )
-{
- if ( pfn )
- {
- pfn( pBase, pData, pField );
- }
-}
-
-//-----------------------------------------------------------------------------
-// Process the fields of a datadesc.
-//-----------------------------------------------------------------------------
-void ProcessFields( void *pBaseAddress, void *pData, datamap_t *pDataMap, datadescProcessFunc_t pfnProcessFunc )
-{
- // deal with base class first
- if ( pDataMap->baseMap )
- {
- ProcessFields( pBaseAddress, pData, pDataMap->baseMap, pfnProcessFunc );
- }
-
- typedescription_t *pFields = pDataMap->dataDesc;
- int fieldCount = pDataMap->dataNumFields;
- for ( int i = 0; i < fieldCount; ++i )
- {
- typedescription_t *pField = &pFields[i];
- ProcessField( pBaseAddress, (BYTE*)pData + pField->fieldOffset[ TD_OFFSET_NORMAL ], pField, pfnProcessFunc );
- }
-}
-
-//-----------------------------------------------------------------------------
-// Process the fields of a datadesc.
-//-----------------------------------------------------------------------------
-void ProcessFields( void *pData, datamap_t *pDataMap, datadescProcessFunc_t pfnProcessFunc )
-{
- ProcessFields( pData, pData, pDataMap, pfnProcessFunc );
-}
-
-//-----------------------------------------------------------------------------
-// Process a datadesc field by name
-//-----------------------------------------------------------------------------
-void ProcessFieldByName( void *pBaseAddress, void *pData, datamap_t *pDataMap, const char *pName, datadescProcessFunc_t pfnProcessFunc )
-{
- // deal with base class first
- if ( pDataMap->baseMap )
- {
- ProcessFieldByName( pBaseAddress, pData, pDataMap->baseMap, pName, pfnProcessFunc );
- }
-
- typedescription_t *pFields = pDataMap->dataDesc;
- int fieldCount = pDataMap->dataNumFields;
- for ( int i = 0; i < fieldCount; ++i )
- {
- typedescription_t *pField = &pFields[i];
- if ( !Q_stricmp( pField->fieldName, pName ) )
- {
- ProcessField( pBaseAddress, (BYTE*)pData + pField->fieldOffset[ TD_OFFSET_NORMAL ], pField, pfnProcessFunc );
- break;
- }
- }
-}
-
-//-----------------------------------------------------------------------------
-// Process a datadesc field by name.
-//-----------------------------------------------------------------------------
-void ProcessFieldByName( void *pData, datamap_t *pDataMap, const char *pName, datadescProcessFunc_t pfnProcessFunc )
-{
- ProcessFieldByName( pData, pData, pDataMap, pName, pfnProcessFunc );
-}
-
-void ProcessANIFields( void *pDataBase, datadescProcessFunc_t pfnProcessFunc );
-void ProcessMDLFields( void *pDataBase, datadescProcessFunc_t pfnProcessFunc );
-
-// Fake header declaration for easier phy swapping
-struct swapcompactsurfaceheader_t
-{
- DECLARE_BYTESWAP_DATADESC();
- int size;
- int vphysicsID;
- short version;
- short modelType;
- int surfaceSize;
- Vector dragAxisAreas;
- int axisMapSize;
-};
-
-BEGIN_BYTESWAP_DATADESC( swapcompactsurfaceheader_t )
- DEFINE_FIELD( size, FIELD_INTEGER ),
- DEFINE_FIELD( vphysicsID, FIELD_INTEGER ),
- DEFINE_FIELD( version, FIELD_SHORT ),
- DEFINE_FIELD( modelType, FIELD_SHORT ),
- DEFINE_FIELD( surfaceSize, FIELD_INTEGER ),
- DEFINE_FIELD( dragAxisAreas, FIELD_VECTOR ),
- DEFINE_FIELD( axisMapSize, FIELD_INTEGER ),
-END_BYTESWAP_DATADESC()
-
-// Fake header declaration for old style phy format
-#if defined( _X360 )
-#pragma bitfield_order( push, lsb_to_msb )
-#endif
-struct legacysurfaceheader_t
-{
- DECLARE_BYTESWAP_DATADESC();
- int size;
- float mass_center[3];
- float rotation_inertia[3];
- float upper_limit_radius;
- BEGIN_BITFIELD( bf )
- int max_deviation : 8;
- int byte_size : 24;
- END_BITFIELD()
- int offset_ledgetree_root;
- int dummy[3];
-};
-#if defined( _X360 )
-#pragma bitfield_order( pop )
-#endif
-
-BEGIN_BYTESWAP_DATADESC( legacysurfaceheader_t )
- DEFINE_FIELD( size, FIELD_INTEGER ),
- DEFINE_ARRAY( mass_center, FIELD_FLOAT, 3 ),
- DEFINE_ARRAY( rotation_inertia, FIELD_FLOAT, 3 ),
- DEFINE_FIELD( upper_limit_radius, FIELD_FLOAT ),
- DEFINE_BITFIELD( bf, FIELD_INTEGER, 32 ),
- DEFINE_FIELD( offset_ledgetree_root, FIELD_INTEGER ),
- DEFINE_ARRAY( dummy, FIELD_INTEGER, 3 ),
-END_BYTESWAP_DATADESC()
-
-//----------------------------------------------------------------------
-// Swap a .phy file
-// Fixes alignment errors
-//----------------------------------------------------------------------
-int ByteswapPHY( void *pDestBase, const void *pSrcBase, const int fileSize )
-{
- Assert( pCollision );
- if ( !pCollision )
- return 0;
-
- Q_memset( pDestBase, 0, fileSize );
-
- byte *pSrc = (byte*)pSrcBase;
- byte *pDest = (byte*)pDestBase;
- vcollide_t collide = {0};
-
- // file header
- phyheader_t *pHdr = (phyheader_t*)( g_bNativeSrc ? pSrc : pDest );
- WriteObjects<phyheader_t>( &pDest, &pSrc );
-
- if ( g_bNativeSrc )
- {
- // Reset the pointers and let ivp swap the binary physics data
- pSrc = (byte*)pSrcBase + pHdr->size;
- pDest = (byte*)pDestBase + pHdr->size;
-
- int bufSize = fileSize - pHdr->size;
- pCollision->VCollideLoad( &collide, pHdr->solidCount, (const char *)pSrc, bufSize, false );
- }
-
- // Swap the collision data headers
- for ( int i = 0; i < pHdr->solidCount; ++i )
- {
- swapcompactsurfaceheader_t *baseHdr = (swapcompactsurfaceheader_t*)( g_bNativeSrc ? pSrc : pDest );
- WriteObjects<swapcompactsurfaceheader_t>( pDest, pSrc );
-
- int srcIncrement = baseHdr->surfaceSize + sizeof(swapcompactsurfaceheader_t);
- int destIncrement = srcIncrement;
- bool bCopyToSrc = !g_bNativeSrc;
-
- if ( baseHdr->vphysicsID != MAKEID('V','P','H','Y') )
- {
- // May be old phy format
- legacysurfaceheader_t *legacyHdr = (legacysurfaceheader_t*)( g_bNativeSrc ? pSrc : pDest );
- WriteObjects<legacysurfaceheader_t>( pDest, pSrc );
- if ( legacyHdr->dummy[2] == MAKEID('I','V','P','S') || legacyHdr->dummy[2] == 0 )
- {
- srcIncrement = legacyHdr->byte_size + sizeof(int);
- destIncrement = legacyHdr->byte_size + sizeof(swapcompactsurfaceheader_t);
- bCopyToSrc = false;
-
- if ( !g_bNativeSrc )
- {
- // src needs the size member to be native to load vcollides
- Q_memcpy( pSrc, pDest, sizeof(int) );
- }
- }
- else
- {
- // Not recognized
- Assert(0);
- return 0;
- }
- }
-
- if ( bCopyToSrc )
- {
- // src needs the native header data to load the vcollides
- Q_memcpy( pSrc, pDest, sizeof(swapcompactsurfaceheader_t) );
- }
-
- pSrc += srcIncrement;
- pDest += destIncrement;
- }
-
- // the rest of the file is text
- int currPos = pSrc - (byte*)pSrcBase;
- int remainingBytes = fileSize - currPos;
- WriteBuffer<char>( &pDest, &pSrc, remainingBytes );
-
- if ( !g_bNativeSrc )
- {
- // let ivp swap the ledge tree
- pSrc = (byte*)pSrcBase + pHdr->size;
- int bufSize = fileSize - pHdr->size;
- pCollision->VCollideLoad( &collide, pHdr->solidCount, (const char *)pSrc, bufSize, true );
- }
-
- // Write out the ledge tree data
- pDest = (byte*)pDestBase + pHdr->size;
- for ( int i = 0; i < collide.solidCount; ++i )
- {
- // skip over the size
- pDest += sizeof(int);
- int offset = pCollision->CollideWrite( (char*)pDest, collide.solids[i], g_bNativeSrc );
- int destSize = g_bNativeSrc ? SwapLong( offset ) : offset;
- Q_memcpy( pDest - sizeof(int), &destSize, sizeof(int) );
- pDest += offset;
- }
-
- // Free the memory
- pCollision->VCollideUnload( &collide );
-
- int newFileSize = pDest - (byte*)pDestBase + remainingBytes;
-
- if ( g_pCompressFunc )
- {
- // compress entire swapped PHY
- void *pInput = pDestBase;
- int inputSize = newFileSize;
- void *pOutput;
- int outputSize;
- if ( g_pCompressFunc( pInput, inputSize, &pOutput, &outputSize ) )
- {
- // put the compressed version in its place
- V_memcpy( pDestBase, pOutput, outputSize );
- free( pOutput );
- newFileSize = outputSize;
- }
- }
-
- return newFileSize;
-}
-
-//----------------------------------------------------------------------
-// Swap a .vvd file
-// Doesn't do any alignment fixups
-//----------------------------------------------------------------------
-int ByteswapVVD( void *pDestBase, const void *pSrcBase, const int fileSize )
-{
- Q_memset( pDestBase, 0, fileSize );
-
- byte *pDataSrc = (byte*)pSrcBase;
- byte *pDataDest = (byte*)pDestBase;
-
- /** FILE HEADER **/
-
- DECLARE_OBJECT_POINTERS( pHdr, pData, vertexFileHeader_t )
- WriteObjects<vertexFileHeader_t>( &pDataDest, &pDataSrc );
-
- /** FIXUP TABLE **/
-
- SET_INDEX_POINTERS( pData, pHdr, fixupTableStart )
- WriteObjects<vertexFileFixup_t>( &pDataDest, &pDataSrc, SrcNative( &pHdr->numFixups ) );
-
- /** VERTEX DATA **/
-
- SET_INDEX_POINTERS( pData, pHdr, vertexDataStart )
- WriteObjects<mstudiovertex_t>( &pDataDest, &pDataSrc, SrcNative( &pHdr->numLODVertexes[0] ) );
-
- /** TANGENT DATA **/
-
- if ( pHdr->tangentDataStart != 0 )
- {
- SET_INDEX_POINTERS( pData, pHdr, tangentDataStart )
- WriteBuffer<float>( &pDataDest, &pDataSrc, 4 * SrcNative( &pHdr->numLODVertexes[0] ) );
- }
-
- int newFileSize = pDataDest - (byte*)pDestBase;
-
- if ( g_pCompressFunc )
- {
- void *pInput = (byte*)pDestBase + sizeof( vertexFileHeader_t );
- int inputSize = newFileSize - sizeof( vertexFileHeader_t );
- void *pOutput;
- int outputSize;
- if ( g_pCompressFunc( pInput, inputSize, &pOutput, &outputSize ) )
- {
- // place the compressed data after the header
- V_memcpy( pInput, pOutput, outputSize );
- free( pOutput );
- newFileSize = sizeof( vertexFileHeader_t ) + outputSize;
- }
- }
-
- return newFileSize;
-}
-
-
-//----------------------------------------------------------------------
-// Swap a .vtx file
-// Doesn't do any alignment fixups
-//----------------------------------------------------------------------
-int ByteswapVTX( void *pDestBase, const void *pSrcBase, const int fileSize )
-{
- Q_memset( pDestBase, 0, fileSize );
-
- // Do a straight copy first so the string table is transferred
- memcpy( pDestBase, pSrcBase, fileSize );
-
- // Start writing the file
- byte *pDataSrc = (byte*)pSrcBase;
- byte *pDataDest = (byte*)pDestBase;
-
- DECLARE_OBJECT_POINTERS( pVtxHeader, pData, OptimizedModel::FileHeader_t )
- WriteObjects( pVtxHeaderDest, pVtxHeaderSrc );
-
- /** BODY PARTS **/
-
- SET_INDEX_POINTERS( pData, pVtxHeader, bodyPartOffset )
- DECLARE_OBJECT_POINTERS( pBodyPartHeader, pData, OptimizedModel::BodyPartHeader_t )
- ITERATE_BLOCK( pBodyPartHeader, pVtxHeader->numBodyParts )
- {
- WriteObjects( pBodyPartHeaderDest, pBodyPartHeaderSrc );
-
- /** MODELS **/
-
- SET_INDEX_POINTERS( pData, pBodyPartHeader, modelOffset )
- DECLARE_OBJECT_POINTERS( pModelHeader, pData, OptimizedModel::ModelHeader_t )
- ITERATE_BLOCK( pModelHeader, pBodyPartHeader->numModels )
- {
- WriteObjects( pModelHeaderDest, pModelHeaderSrc );
-
- /** MODEL LODS **/
-
- unsigned int meshOffset = 0;
- SET_INDEX_POINTERS( pData, pModelHeader, lodOffset )
- DECLARE_OBJECT_POINTERS( pModelLODHeader, pData, OptimizedModel::ModelLODHeader_t )
- ITERATE_BLOCK( pModelLODHeader, pModelHeader->numLODs )
- {
- WriteObjects( pModelLODHeaderDest, pModelLODHeaderSrc );
-
- /** MESHES **/
-
- unsigned int prevOffset = meshOffset;
- meshOffset = SrcNative( &pModelLODHeader->meshOffset );
- if ( prevOffset - sizeof(OptimizedModel::ModelLODHeader_t) == meshOffset )
- {
- // This LOD shares data with the previous LOD - don't reswap.
- continue;
- }
-
- SET_INDEX_POINTERS( pData, pModelLODHeader, meshOffset )
- DECLARE_OBJECT_POINTERS( pMeshHeader, pData, OptimizedModel::MeshHeader_t )
- ITERATE_BLOCK( pMeshHeader, pModelLODHeader->numMeshes )
- {
- WriteObjects( pMeshHeaderDest, pMeshHeaderSrc );
-
- /** STRIP GROUPS **/
-
- SET_INDEX_POINTERS( pData, pMeshHeader, stripGroupHeaderOffset )
- DECLARE_OBJECT_POINTERS( pStripGroupHeader, pData, OptimizedModel::StripGroupHeader_t )
- ITERATE_BLOCK( pStripGroupHeader, pMeshHeader->numStripGroups )
- {
- WriteObjects( pStripGroupHeaderDest, pStripGroupHeaderSrc );
-
- /** STRIP VERTS **/
-
- SET_INDEX_POINTERS( pData, pStripGroupHeader, vertOffset )
- WriteObjects<OptimizedModel::Vertex_t>( pDataDest, pDataSrc, SrcNative( &pStripGroupHeader->numVerts ) );
-
- /** VERT INDICES **/
-
- SET_INDEX_POINTERS( pData, pStripGroupHeader, indexOffset )
- WriteBuffer<short>( pDataDest, pDataSrc, SrcNative( &pStripGroupHeader->numIndices ) );
-
- /** STRIPS **/
-
- SET_INDEX_POINTERS( pData, pStripGroupHeader, stripOffset )
- DECLARE_OBJECT_POINTERS( pStripHeader, pData, OptimizedModel::StripHeader_t )
- ITERATE_BLOCK( pStripHeader, pStripGroupHeader->numStrips )
- {
- WriteObjects( pStripHeaderDest, pStripHeaderSrc );
-
- /** BONE STATE CHANGES **/
-
- SET_INDEX_POINTERS( pData, pStripHeader, boneStateChangeOffset )
- WriteObjects<OptimizedModel::BoneStateChangeHeader_t>( pDataDest, pDataSrc, SrcNative( &pStripHeader->numBoneStateChanges ) );
- }
- }
- }
- }
- }
- }
-
- /** MATERIAL REPLACEMENT HEADERS **/
-
- SET_INDEX_POINTERS( pData, pVtxHeader, materialReplacementListOffset )
- DECLARE_OBJECT_POINTERS( pMatRepListHeader, pData, OptimizedModel::MaterialReplacementListHeader_t )
- ITERATE_BLOCK( pMatRepListHeader, pVtxHeader->numLODs )
- {
- WriteObjects( pMatRepListHeaderDest, pMatRepListHeaderSrc );
-
- /** MATERIAL REPLACEMENTS **/
-
- SET_INDEX_POINTERS( pData, pMatRepListHeader, replacementOffset )
- WriteObjects<OptimizedModel::MaterialReplacementHeader_t>( &pDataDest, &pDataSrc, SrcNative( &pMatRepListHeader->numReplacements ) );
- }
-
- int newFileSize = fileSize;
-
- if ( g_pCompressFunc )
- {
- void *pInput = (byte*)pDestBase + sizeof( OptimizedModel::FileHeader_t );
- int inputSize = fileSize - sizeof( OptimizedModel::FileHeader_t );
- void *pOutput;
- int outputSize;
- if ( g_pCompressFunc( pInput, inputSize, &pOutput, &outputSize ) )
- {
- // place the compressed data after the header
- V_memcpy( pInput, pOutput, outputSize );
- free( pOutput );
- newFileSize = sizeof( OptimizedModel::FileHeader_t ) + outputSize;
- }
- }
-
- return newFileSize;
-}
-
-//----------------------------------------------------------------------
-// Swap animation data
-// Fixes alignment errors
-//----------------------------------------------------------------------
-
-void ByteswapAnimData( mstudioanimdesc_t *pAnimDesc, int section, byte *&pDataSrc, byte *&pDataDest )
-{
- /** ANIMATIONS **/
- DECLARE_OBJECT_POINTERS( pAnimation, pData, mstudioanim_t )
- WriteObjects( pAnimationDest, pAnimationSrc );
- if ( pAnimation->bone == 255 )
- {
- // No animation data
- pAnimation = 0;
- }
-
- while( pAnimation )
- {
- if ( pAnimation->flags & ( STUDIO_ANIM_RAWROT | STUDIO_ANIM_RAWPOS | STUDIO_ANIM_RAWROT2 ) )
- {
- if ( pAnimation->flags & STUDIO_ANIM_RAWROT )
- {
- int offset = (byte*)pAnimation->pQuat48() - (byte*)pAnimation;
- pDataSrc = (byte*)pAnimationSrc + offset;
- pDataDest = (byte*)pAnimationDest + offset;
-
- // Write the quaternion (bit fields contained in 3 unsigned shorts)
- WriteBuffer<short>( &pDataDest, &pDataSrc, 3 );
- }
-
- if ( pAnimation->flags & STUDIO_ANIM_RAWROT2 )
- {
- int offset = (byte*)pAnimation->pQuat64() - (byte*)pAnimation;
- pDataSrc = (byte*)pAnimationSrc + offset;
- pDataDest = (byte*)pAnimationDest + offset;
-
- // Write the quaternion (bit fields contained in 1 64 bit int
- WriteBuffer<int64>( &pDataDest, &pDataSrc, 1 );
- }
-
- if ( pAnimation->flags & STUDIO_ANIM_RAWPOS )
- {
- int offset = (byte*)pAnimation->pPos() - (byte*)pAnimation;
- pDataSrc = (byte*)pAnimationSrc + offset;
- pDataDest = (byte*)pAnimationDest + offset;
-
- // Write the vector (3 float16)
- WriteBuffer<short>( &pDataDest, &pDataSrc, 3 );
- }
- }
- else
- {
- int offset = (byte*)pAnimation->pRotV() - (byte*)pAnimation;
- pDataSrc = (byte*)pAnimationSrc + offset;
- pDataDest = (byte*)pAnimationDest + offset;
-
- mstudioanim_valueptr_t *rotvptr = (mstudioanim_valueptr_t*)pDataSrc;
- WriteObjects<mstudioanim_valueptr_t>( &pDataDest, &pDataSrc );
-
- int animValueCt = 0;
- for ( int idx = 0; idx < 3; ++idx )
- {
- animValueCt += rotvptr->offset[idx] ? 1 : 0;
- }
-
- if ( pAnimation->flags & STUDIO_ANIM_ANIMPOS )
- {
- int offset = (byte*)pAnimation->pPosV() - (byte*)pAnimation;
- pDataSrc = (byte*)pAnimationSrc + offset;
- pDataDest = (byte*)pAnimationDest + offset;
-
- mstudioanim_valueptr_t *posvptr = (mstudioanim_valueptr_t*)pDataSrc;
- WriteObjects<mstudioanim_valueptr_t>( &pDataDest, &pDataSrc );
-
- for ( int idx = 0; idx < 3; ++idx )
- {
- animValueCt += posvptr->offset[idx] ? 1 : 0;
- }
- }
-
- // Write position and rotation animations
-
- // Note: destanimvalue_t is a union that can be either two bytes or a short.
- // This structure is used to compress animation data using RLE.
- // The first object of a chunk acts as the header, and uses the two bytes to
- // store how many objects follow, and how many frames are encoded by them.
- // The objects that follow use the short to store a value.
- // The total number of chunks has been determined by counting the number of valid (non-zero) offsets.
- for ( int animValue = 0; animValue < animValueCt; ++animValue )
- {
- int encodedFrames = 0;
- int totalFrames = SrcNative( &pAnimDesc->numframes );
- int sectionFrames = SrcNative( &pAnimDesc->sectionframes );
- if ( sectionFrames )
- {
- int iStartFrame = section * sectionFrames;
- int iEndFrame = (section + 1) * sectionFrames;
-
- iStartFrame = min( iStartFrame, totalFrames - 1 );
- iEndFrame = min( iEndFrame, totalFrames - 1 );
-
- totalFrames = iEndFrame - iStartFrame + 1;
- }
-
- while ( encodedFrames < totalFrames )
- {
- // Write the first animation value (struct of 2 bytes)
- mstudioanimvalue_t *pDestAnimvalue = (mstudioanimvalue_t*)( g_bNativeSrc ? pDataSrc : pDataDest );
- WriteBuffer<char>( &pDataDest, &pDataSrc, 2 );
-
- // Write the remaining animation values from this group (shorts)
- WriteBuffer<short>( &pDataDest, &pDataSrc, pDestAnimvalue->num.valid );
-
- encodedFrames += pDestAnimvalue->num.total;
- }
- }
- }
-
- // TODOKD: Could add a fixup here with some more work, hasn't been necessary yet
- if ( pAnimation->nextoffset )
- {
- // Set pointers to the next animation
- pAnimationSrc = (mstudioanim_t*)( (byte*)pAnimationSrc + SrcNative( &pAnimation->nextoffset ) );
- pAnimationDest = (mstudioanim_t*)( (byte*)pAnimationDest + SrcNative( &pAnimation->nextoffset ) );
- pAnimation = pAnimationSrc;
-
- // Swap the next animation
- WriteObjects( pAnimationDest, pAnimationSrc );
- }
- else
- {
- pAnimation = 0;
- pDataSrc += sizeof( mstudioanim_t );
- pDataDest += sizeof( mstudioanim_t );
- }
- }
-
- ALIGN4( pDataSrc );
- ALIGN4( pDataDest );
-}
-
-
-int ByteswapIKRules( studiohdr_t *&pHdrSrc, int numikrules, int numFrames, byte *&pDataSrc, byte *&pDataDest, int &fixedFileSize, const int fileSize )
-{
- DECLARE_OBJECT_POINTERS( pIKRule, pData, mstudioikrule_t )
-
- ITERATE_BLOCK( pIKRule, numikrules )
- {
- WriteObjects<mstudioikrule_t>( pIKRuleDest, pIKRuleSrc );
-
- /** IK ERROR KEYS **/
-
- // Calculate the number of ikerrors by converting the ikerror start and end float values to
- // frame numbers. (See the generation of these values in simplify.cpp: ProcessIKRules()).
- float start = floorf( SrcNative( &pIKRule->start ) * (numFrames - 1) + 0.5f );
- float end = floorf( SrcNative( &pIKRule->end ) * (numFrames - 1) + 0.5f );
- int totalerror = (int)( end - start + 1 );
- if ( end >= numFrames )
- totalerror += 2;
-
- // Uncompressed - only found in some older models (shipped hl2)
- if ( pIKRule->ikerrorindex )
- {
- SET_INDEX_POINTERS_FIXUP( pData, pIKRule, ikerrorindex )
- WriteObjects<mstudioikerror_t>( pDataDest, pDataSrc, totalerror );
- }
-
- // Compressed - all models since hl2
- if ( pIKRule->compressedikerrorindex )
- {
- SET_INDEX_POINTERS_FIXUP( pData, pIKRule, compressedikerrorindex )
- WriteObjects<mstudiocompressedikerror_t>( pDataDest, pDataSrc );
-
- mstudiocompressedikerror_t *pCompressed = (mstudiocompressedikerror_t *)pDataSrc;
-
- // Write the animvalues.
- for ( int idx = 0; idx < 6; ++idx )
- {
- if ( pCompressed->offset[idx] )
- {
- byte *pAnimvalueSrc = pDataSrc + SrcNative( &pCompressed->offset[idx] );
- byte *pAnimvalueDest = pDataDest + SrcNative( &pCompressed->offset[idx] );
-
- int numerror = 0;
- while ( numerror < totalerror )
- {
- // Write the first animation value (struct of 2 bytes)
- mstudioanimvalue_t *pDestAnimvalue = (mstudioanimvalue_t*)( g_bNativeSrc ? pAnimvalueSrc : pAnimvalueDest );
- WriteBuffer<char>( &pAnimvalueDest, &pAnimvalueSrc, 2 );
-
- // Write the remaining animation values from this group (shorts)
- WriteBuffer<short>( &pAnimvalueDest, &pAnimvalueSrc, pDestAnimvalue->num.valid );
-
- numerror += pDestAnimvalue->num.total;
- }
- }
- }
-
- if ( pIKRule->szattachmentindex )
- {
- SET_INDEX_POINTERS( pData, pIKRule, szattachmentindex )
- int size = strlen( (char*)pDataSrc ) + 1;
- WriteBuffer<char>( pDataDest, pDataSrc, size );
- }
- }
- }
- return fixedFileSize;
-}
-
-
-
-//----------------------------------------------------------------------
-// Swap an .ani file
-// Fixes alignment errors
-//----------------------------------------------------------------------
-int ByteswapANIFile( studiohdr_t* pHdr, void *pDestBase, const void *pSrcBase, const int fileSize )
-{
- // Note, pHdr came from a native .mdl -
- // so the header, animdescs and animblocks are already in native format.
- Assert( pHdr );
- if ( !pHdr )
- return false;
-
- Q_memset( pDestBase, 0, fileSize );
-
- // swap file header
- {
- byte *pHeaderSrc = (byte *)pSrcBase;
- byte *pHeaderDest = (byte *)pDestBase;
- DECLARE_OBJECT_POINTERS( pAniHeader, pHeader, studiohdr_t )
- WriteObjects( pAniHeaderDest, pAniHeaderSrc );
- }
-
- // for fixup functions
- int fixedFileSize = fileSize;
- g_pfnFileProcessFunc = ProcessANIFields;
- g_pDataSrcBase = pSrcBase;
- g_pHdr = pHdr;
- studiohdr_t *pHdrSrc = pHdr;
-
- // The animdesc_t header is always contained in the mdl file, but its data may be in
- // the mdl or the ani. When the data is contained in the mdl, the animdesc index fields
- // represent offsets from the location of the animdesc header. When the data is in the ani,
- // the index fields contain offsets from the start of the animblock in which the animdesc data is contained.
-
- mstudioanimdesc_t *pAnimDesc = pHdr->pLocalAnimdesc( 0 );
- for ( int i = 0; i < pHdr->numlocalanim; ++i, ++pAnimDesc )
- {
- // printf("anim %d : %d : %d\n", i, pAnimDesc->animblock, pAnimDesc->sectionframes );
- if ( pAnimDesc->animblock == -1)
- {
- // out of date model format
- continue;
- }
-
- if ( pAnimDesc->animblock == 0 && pAnimDesc->sectionframes == 0)
- {
- // already saved out
- continue;
- }
-
- if ( pAnimDesc->sectionframes == 0 )
- {
- mstudioanimblock_t *pAnimBlock = pHdr->pAnimBlock( pAnimDesc->animblock );
-
- // printf("block %d : start %d + %d\n", pAnimDesc->animblock, pAnimBlock->datastart, pAnimDesc->animindex );
- // Base address of the animblock
- byte *pBlockBaseSrc = (byte*)pSrcBase + pAnimBlock->datastart;
- byte *pBlockBaseDest = (byte*)pDestBase + pAnimBlock->datastart;
-
- // Base address of the animation in the animblock
- byte *pDataSrc = pBlockBaseSrc + pAnimDesc->animindex;
- byte *pDataDest = pBlockBaseDest + pAnimDesc->animindex;
-
- ByteswapAnimData( pAnimDesc, 0, pDataSrc, pDataDest );
- }
- else
- {
- int numsections = pAnimDesc->numframes / pAnimDesc->sectionframes + 2;
-
- for ( int i = 0; i < numsections; ++i )
- {
- int block = pAnimDesc->pSection( i )->animblock;
- int index = pAnimDesc->pSection( i )->animindex;
-
- if ( block != 0 )
- {
- // printf("%s %d %d\n", pAnimDesc->pszName(), block, index );
-
- mstudioanimblock_t *pAnimBlock = pHdr->pAnimBlock( block );
-
- // Base address of the animblock
- byte *pBlockBaseSrc = (byte*)pSrcBase + pAnimBlock->datastart;
- byte *pBlockBaseDest = (byte*)pDestBase + pAnimBlock->datastart;
- FIXUP_OFFSETS( pBlockBase, pAnimBlock, datastart )
-
- // Base address of the animation in the animblock
- byte *pDataSrc = pBlockBaseSrc + index;
- byte *pDataDest = pBlockBaseDest + index;
-
- ByteswapAnimData( pAnimDesc, i, pDataSrc, pDataDest );
- }
- }
- }
-
- if ( pAnimDesc->animblock == 0)
- {
- // already saved out
- continue;
- }
-
- mstudioanimblock_t *pAnimBlock = pHdr->pAnimBlock( pAnimDesc->animblock );
- // Base address of the animblock
- byte *pBlockBaseSrc = (byte*)pSrcBase + pAnimBlock->datastart;
- byte *pBlockBaseDest = (byte*)pDestBase + pAnimBlock->datastart;
- FIXUP_OFFSETS( pBlockBase, pAnimBlock, datastart )
-
- // Base address of the animation in the animblock
- byte *pDataSrc = pBlockBaseSrc + pAnimDesc->animindex;
- byte *pDataDest = pBlockBaseDest + pAnimDesc->animindex;
- FIXUP_OFFSETS( pData, pAnimDesc, animindex )
-
- /** IK RULES **/
-
- if ( pAnimDesc->animblockikruleindex )
- {
- pDataSrc = (byte*)pBlockBaseSrc + pAnimDesc->animblockikruleindex;
- pDataDest = (byte*)pBlockBaseDest + pAnimDesc->animblockikruleindex;
- FIXUP_OFFSETS( pData, pAnimDesc, animblockikruleindex )
-
- int numikrules = SrcNative( &pAnimDesc->numikrules );
- ByteswapIKRules( pHdrSrc, pAnimDesc->numikrules, pAnimDesc->numframes, pDataSrc, pDataDest, fixedFileSize, fileSize );
- }
-
- /** LOCAL HIERARCHY **/
-
- if ( pAnimDesc->localhierarchyindex )
- {
- pDataSrc = (byte*)pBlockBaseSrc + pAnimDesc->localhierarchyindex;
- pDataDest = (byte*)pBlockBaseDest + pAnimDesc->localhierarchyindex;
- DECLARE_OBJECT_POINTERS( pLocalHierarchy, pData, mstudiolocalhierarchy_t )
-
- // HACK: Since animdescs are already native, pre-swap pAnimDesc->numlocalhierarchy
- // here so the automatic swap inside ITERATE_BLOCK will restore it
- int numlocalhierarchy = SrcNative( &pAnimDesc->numlocalhierarchy );
- ITERATE_BLOCK( pLocalHierarchy, numlocalhierarchy )
- {
- WriteObjects<mstudiolocalhierarchy_t>( pLocalHierarchyDest, pLocalHierarchySrc, pAnimDesc->numlocalhierarchy );
-
- /** COMPRESSED IK ERRORS **/
-
- if ( pLocalHierarchy->localanimindex != 0 )
- {
- // Calculate the number of ikerrors by converting the ikerror start and end float values to
- // frame numbers. (See the generation of these values in simplify.cpp: ProcessIKRules()).
- int numFrames = pAnimDesc->numframes;
- float start = floorf( SrcNative( &pLocalHierarchy->start ) * (numFrames - 1) + 0.5f );
- float end = floorf( SrcNative( &pLocalHierarchy->end ) * (numFrames - 1) + 0.5f );
- int totalerror = (int)( end - start + 1 );
- if ( end >= numFrames )
- totalerror += 2;
-
- SET_INDEX_POINTERS( pData, pLocalHierarchy, localanimindex )
- WriteObjects<mstudiocompressedikerror_t>( pDataDest, pDataSrc );
-
- mstudiocompressedikerror_t *pCompressed = (mstudiocompressedikerror_t *)pDataSrc;
-
- // Write the animvalues.
- for ( int idx = 0; idx < 6; ++idx )
- {
- if ( pCompressed->offset[idx] )
- {
- byte *pAnimvalueSrc = pDataSrc + SrcNative( &pCompressed->offset[idx] );
- byte *pAnimvalueDest = pDataDest + SrcNative( &pCompressed->offset[idx] );
-
- int numerror = 0;
- while ( numerror < totalerror )
- {
- // Write the first animation value (struct of 2 bytes)
- mstudioanimvalue_t *pDestAnimvalue = (mstudioanimvalue_t*)( g_bNativeSrc ? pAnimvalueSrc : pAnimvalueDest );
- WriteBuffer<char>( &pAnimvalueDest, &pAnimvalueSrc, 2 );
-
- // Write the remaining animation values from this group (shorts)
- WriteBuffer<short>( &pAnimvalueDest, &pAnimvalueSrc, pDestAnimvalue->num.valid );
-
- numerror += pDestAnimvalue->num.total;
- }
- }
- }
- }
- } // Local Hierarchy block
- }
- }
-
- // printf("returning %d\n", fixedFileSize );
-
- return fixedFileSize;
-}
-
-int ByteswapANI( studiohdr_t* pHdr, void *pDestBase, const void *pSrcBase, const int fileSize )
-{
- // Make a working copy of the source to allow for alignment fixups
- void *pNewSrcBase = malloc( fileSize + BYTESWAP_ALIGNMENT_PADDING );
- Q_memcpy( pNewSrcBase, pSrcBase, fileSize );
-
- int fixedFileSize = ByteswapANIFile( pHdr, pDestBase, pNewSrcBase, fileSize );
- if ( fixedFileSize != fileSize )
- {
- int finalSize = ByteswapANIFile( pHdr, pDestBase, pNewSrcBase, fixedFileSize );
- if ( finalSize != fixedFileSize )
- {
- if ( g_bVerbose )
- Warning( "Alignment fixups failed on ANI swap!\n" );
- fixedFileSize = 0;
- }
- }
-
- free( pNewSrcBase );
-
- // the compression needs to happen on the final or "fixed" pass
- if ( g_pCompressFunc && pHdr->numanimblocks >= 2 && fixedFileSize )
- {
- // assemble a new anim of compressed anim blocks
- // start with original size, with room for alignment padding
- fixedFileSize += (pHdr->numanimblocks + 1) * 2048;
- byte *pNewDestBase = (byte *)malloc( fixedFileSize );
- Q_memset( pNewDestBase, 0, fixedFileSize );
- byte *pNewDest = pNewDestBase;
-
- // get the header payload as is
- // assuming the header is up to the first anim block
- mstudioanimblock_t *pAnimBlock = pHdr->pAnimBlock( 1 );
- V_memcpy( pNewDest, pDestBase, pAnimBlock->datastart );
- pNewDest += pAnimBlock->datastart;
-
- int padding = AlignValue( (unsigned int)pNewDest - (unsigned int)pNewDestBase, 2048 );
- padding -= (unsigned int)pNewDest - (unsigned int)pNewDestBase;
- pNewDest += padding;
-
- // iterate and compress anim blocks
- for ( int i = 1; i < pHdr->numanimblocks; ++i )
- {
- pAnimBlock = pHdr->pAnimBlock( i );
-
- void *pInput = (byte *)pDestBase + pAnimBlock->datastart;
- int inputSize = pAnimBlock->dataend - pAnimBlock->datastart;
-
- pAnimBlock->datastart = (unsigned int)pNewDest - (unsigned int)pNewDestBase;
-
- void *pOutput;
- int outputSize;
- if ( g_pCompressFunc( pInput, inputSize, &pOutput, &outputSize ) )
- {
- V_memcpy( pNewDest, pOutput, outputSize );
- pNewDest += outputSize;
- free( pOutput );
- }
- else
- {
- // as is
- V_memcpy( pNewDest, pInput, inputSize );
- pNewDest += inputSize;
- }
-
- padding = AlignValue( (unsigned int)pNewDest - (unsigned int)pNewDestBase, 2048 );
- padding -= (unsigned int)pNewDest - (unsigned int)pNewDestBase;
- pNewDest += padding;
-
- pAnimBlock->dataend = (unsigned int)pNewDest - (unsigned int)pNewDestBase;
- }
-
- fixedFileSize = pNewDest - pNewDestBase;
- V_memcpy( pDestBase, pNewDestBase, fixedFileSize );
- free( pNewDestBase );
- }
-
- return fixedFileSize;
-}
-
-//----------------------------------------------------------------------
-// Write a .mdl file in big-endian format
-//----------------------------------------------------------------------
-int ByteswapMDLFile( void *pDestBase, void *pSrcBase, const int fileSize )
-{
- // Needed by fixup functions
- g_pDataSrcBase = pSrcBase;
- g_pfnFileProcessFunc = ProcessMDLFields;
- int fixedFileSize = fileSize;
-
- Q_memset( pDestBase, 0, fileSize );
-
- byte *pDataSrc = (byte*)pSrcBase;
- byte *pDataDest = (byte*)pDestBase;
-
- /** FILE HEADER **/
-
- DECLARE_OBJECT_POINTERS( pHdr, pData, studiohdr_t )
- WriteObjects( pHdrDest, pHdrSrc );
-
- /** BONES **/
-
- SET_INDEX_POINTERS_FIXUP( pData, pHdr, boneindex )
- DECLARE_OBJECT_POINTERS( pStudioBone, pData, mstudiobone_t )
- ITERATE_BLOCK( pStudioBone, pHdr->numbones )
- {
- WriteObjects( pStudioBoneDest, pStudioBoneSrc );
-
- if ( pStudioBone->procindex )
- {
- SET_INDEX_POINTERS_FIXUP( pData, pStudioBone, procindex )
-
- unsigned int index = SrcNative( &pStudioBone->proctype );
- switch( index )
- {
- case STUDIO_PROC_AXISINTERP:
- {
- /** AXIS-INTERP BONES **/
- DECLARE_OBJECT_POINTERS( pAxisInterpBone, pData, mstudioaxisinterpbone_t )
- WriteObjects( pAxisInterpBoneDest, pAxisInterpBoneSrc );
- break;
- }
- case STUDIO_PROC_QUATINTERP:
- {
- /** QUAT-INTERP BONES **/
- DECLARE_OBJECT_POINTERS( pQuatInterpBone, pData, mstudioquatinterpbone_t )
- WriteObjects( pQuatInterpBoneDest, pQuatInterpBoneSrc );
-
- /** QUAT-INTERP TRIGGERS **/
- SET_INDEX_POINTERS_FIXUP( pData, pQuatInterpBone, triggerindex )
- WriteObjects<mstudioquatinterpinfo_t>( pDataDest, pDataSrc, SrcNative( &pQuatInterpBone->numtriggers ) );
- break;
- }
- case STUDIO_PROC_JIGGLE:
- {
- /** JIGGLE BONES **/
- DECLARE_OBJECT_POINTERS( pJiggleBone, pData, mstudiojigglebone_t )
- WriteObjects( pJiggleBoneDest, pJiggleBoneSrc );
- break;
- }
- case STUDIO_PROC_AIMATBONE:
- case STUDIO_PROC_AIMATATTACH:
- {
- /** AIM AT BONES **/
- DECLARE_OBJECT_POINTERS( pAimAtBone, pData, mstudioaimatbone_t )
- WriteObjects( pAimAtBoneDest, pAimAtBoneSrc );
- break;
- }
- default:
- Assert( 0 );
- Warning( "Unknown bone type %d found!\n", index );
- }
- }
- }
-
- /** BONE CONTROLLERS **/
-
- SET_INDEX_POINTERS_FIXUP( pData, pHdr, bonecontrollerindex )
- WriteObjects<mstudiobonecontroller_t>( pDataDest, pDataSrc, SrcNative( &pHdr->numbonecontrollers ) );
-
- /** ATTACHMENTS **/
-
- SET_INDEX_POINTERS_FIXUP( pData, pHdr, localattachmentindex )
- WriteObjects<mstudioattachment_t>( pDataDest, pDataSrc, SrcNative( &pHdr->numlocalattachments ) );
-
- /** HITBOX SETS **/
-
- SET_INDEX_POINTERS_FIXUP( pData, pHdr, hitboxsetindex )
- DECLARE_OBJECT_POINTERS( pHitboxSet, pData, mstudiohitboxset_t )
- ITERATE_BLOCK( pHitboxSet, pHdr->numhitboxsets )
- {
- WriteObjects( pHitboxSetDest, pHitboxSetSrc );
-
- /** HITBOXES **/
-
- SET_INDEX_POINTERS_FIXUP( pData, pHitboxSet, hitboxindex )
- WriteObjects<mstudiobbox_t>( pDataDest, pDataSrc, SrcNative( &pHitboxSet->numhitboxes ) );
- }
-
- /** BONE TABLE **/
-
- SET_INDEX_POINTERS( pData, pHdr, bonetablebynameindex )
- WriteBuffer<char>( pDataDest, pDataSrc, SrcNative( &pHdr->numbones ) );
-
- /** ANIMATION DESCRIPTIONS **/
-
- SET_INDEX_POINTERS_FIXUP( pData, pHdr, localanimindex )
- DECLARE_OBJECT_POINTERS( pAnimDesc, pData, mstudioanimdesc_t )
- ITERATE_BLOCK( pAnimDesc, pHdr->numlocalanim )
- {
- WriteObjects( pAnimDescDest, pAnimDescSrc );
-
- if ( pAnimDesc->animblock == -1 )
- {
- // out of date model format
- continue;
- }
-
- // section data can point to both internal and external blocks
- int numsections = 0;
- if ( pAnimDesc->sectionframes != 0 )
- {
- numsections = pAnimDesc->numframes / pAnimDesc->sectionframes + 2;
-
- SET_INDEX_POINTERS( pData, pAnimDesc, sectionindex )
- DECLARE_OBJECT_POINTERS( pSection, pData, mstudioanimsections_t )
-
- WriteObjects( pSectionDest, pSectionSrc, numsections );
- }
-
- if ( pAnimDesc->animblock == 0 )
- {
- if ( numsections == 0 )
- {
- SET_INDEX_POINTERS( pData, pAnimDesc, animindex )
- ByteswapAnimData( pAnimDesc, 0, pDataSrc, pDataDest );
- }
- else
- {
- for ( int i = 0; i < numsections; ++i )
- {
- if ( pAnimDesc->pSection( i )->animblock == 0 )
- {
- int index = pAnimDesc->pSection( i )->animindex;
-
- // Base address of the animation in the animblock
- byte *pDataSrc = (byte *)pAnimDescSrc + index;
- byte *pDataDest = (byte *)pAnimDescDest + index;
-
- ByteswapAnimData( pAnimDesc, i, pDataSrc, pDataDest );
- }
- }
- }
-
- /** IK RULES **/
-
- if ( pAnimDesc->ikruleindex )
- {
- SET_INDEX_POINTERS_FIXUP( pData, pAnimDesc, ikruleindex )
- DECLARE_OBJECT_POINTERS( pIKRule, pData, mstudioikrule_t )
-
- int numframes = SrcNative( &pAnimDesc->numframes );
- ByteswapIKRules( pHdrSrc, pAnimDesc->numikrules, numframes, pDataSrc, pDataDest, fixedFileSize, fileSize );
- }
-
- /** LOCAL HIERARCHY **/
-
- if ( pAnimDesc->localhierarchyindex )
- {
- SET_INDEX_POINTERS( pData, pAnimDesc, localhierarchyindex )
- DECLARE_OBJECT_POINTERS( pLocalHierarchy, pData, mstudiolocalhierarchy_t )
- ITERATE_BLOCK( pLocalHierarchy, pAnimDesc->numlocalhierarchy )
- {
- WriteObjects<mstudiolocalhierarchy_t>( pLocalHierarchyDest, pLocalHierarchySrc, SrcNative( &pAnimDesc->numlocalhierarchy ) );
-
- /** COMPRESSED IK ERRORS **/
-
- if ( pLocalHierarchy->localanimindex != 0 )
- {
- // Calculate the number of ikerrors by converting the ikerror start and end float values to
- // frame numbers. (See the generation of these values in simplify.cpp: ProcessIKRules()).
- int numFrames = SrcNative( &pAnimDesc->numframes );
- float start = floorf( SrcNative( &pLocalHierarchy->start ) * (numFrames - 1) + 0.5f );
- float end = floorf( SrcNative( &pLocalHierarchy->end ) * (numFrames - 1) + 0.5f );
- int totalerror = (int)( end - start + 1 );
- if ( end >= numFrames )
- totalerror += 2;
-
- SET_INDEX_POINTERS( pData, pLocalHierarchy, localanimindex )
- WriteObjects<mstudiocompressedikerror_t>( pDataDest, pDataSrc );
-
- mstudiocompressedikerror_t *pCompressed = (mstudiocompressedikerror_t *)pDataSrc;
-
- // Write the animvalues.
- for ( int idx = 0; idx < 6; ++idx )
- {
- if ( pCompressed->offset[idx] )
- {
- byte *pAnimvalueSrc = pDataSrc + SrcNative( &pCompressed->offset[idx] );
- byte *pAnimvalueDest = pDataDest + SrcNative( &pCompressed->offset[idx] );
-
- int numerror = 0;
- while ( numerror < totalerror )
- {
- // Write the first animation value (struct of 2 bytes)
- mstudioanimvalue_t *pDestAnimvalue = (mstudioanimvalue_t*)( g_bNativeSrc ? pAnimvalueSrc : pAnimvalueDest );
- WriteBuffer<char>( &pAnimvalueDest, &pAnimvalueSrc, 2 );
-
- // Write the remaining animation values from this group (shorts)
- WriteBuffer<short>( &pAnimvalueDest, &pAnimvalueSrc, pDestAnimvalue->num.valid );
-
- numerror += pDestAnimvalue->num.total;
- }
- }
- }
- }
- }
- } // Local Hierarchy block
- }
- } // Animdesc block
-
- /** MOVEMENTS **/
-
- // Separate loop required by format of mstudioanimdesc_t data
- SET_INDEX_POINTERS( pData, pHdr, localanimindex )
- SET_OBJECT_POINTERS( pAnimDesc, pData, mstudioanimdesc_t )
- ITERATE_BLOCK( pAnimDesc, pHdr->numlocalanim )
- {
- if ( pAnimDesc->nummovements )
- {
- SET_INDEX_POINTERS_FIXUP( pData, pAnimDesc, movementindex )
- WriteObjects<mstudiomovement_t>( pDataDest, pDataSrc, SrcNative( &pAnimDesc->nummovements ) );
- }
- }
-
- /** IK RULES (2nd pass) **/
-
- // This is required to support older models that had these lumps in a different
- // order - the model version didn't change, so there's no reliable way to detect it.
- SET_INDEX_POINTERS( pData, pHdr, localanimindex )
- SET_OBJECT_POINTERS( pAnimDesc, pData, mstudioanimdesc_t )
- ITERATE_BLOCK( pAnimDesc, pHdr->numlocalanim )
- {
- if ( pAnimDesc->ikruleindex )
- {
- // Only need to write the data again if a fixup happens
- byte *pTest = (byte*)pAnimDesc + SrcNative( &pAnimDesc->ikruleindex );
- SET_INDEX_POINTERS_FIXUP( pData, pAnimDesc, ikruleindex )
- if ( pTest == pDataSrc )
- continue;
-
- DECLARE_OBJECT_POINTERS( pIKRule, pData, mstudioikrule_t )
- ITERATE_BLOCK( pIKRule, pAnimDesc->numikrules )
- {
- WriteObjects<mstudioikrule_t>( pIKRuleDest, pIKRuleSrc );
-
- /** IK ERROR KEYS **/
-
- // Calculate the number of ikerrors by converting the ikerror start and end float values to
- // frame numbers. (See the generation of these values in simplify.cpp: ProcessIKRules()).
- int numFrames = SrcNative( &pAnimDesc->numframes );
- float start = floorf( SrcNative( &pIKRule->start ) * (numFrames - 1) + 0.5f );
- float end = floorf( SrcNative( &pIKRule->end ) * (numFrames - 1) + 0.5f );
- int totalerror = (int)( end - start + 1 );
- if ( end >= numFrames )
- totalerror += 2;
-
- // Uncompressed - only found in some older models (shipped hl2)
- if ( pIKRule->ikerrorindex )
- {
- SET_INDEX_POINTERS_FIXUP( pData, pIKRule, ikerrorindex )
- WriteObjects<mstudioikerror_t>( pDataDest, pDataSrc, totalerror );
- }
-
- // Compressed - all models since hl2
- if ( pIKRule->compressedikerrorindex )
- {
- SET_INDEX_POINTERS_FIXUP( pData, pIKRule, compressedikerrorindex )
- WriteObjects<mstudiocompressedikerror_t>( pDataDest, pDataSrc );
-
- mstudiocompressedikerror_t *pCompressed = (mstudiocompressedikerror_t *)pDataSrc;
-
- // Write the animvalues.
- for ( int idx = 0; idx < 6; ++idx )
- {
- if ( pCompressed->offset[idx] )
- {
- byte *pAnimvalueSrc = pDataSrc + SrcNative( &pCompressed->offset[idx] );
- byte *pAnimvalueDest = pDataDest + SrcNative( &pCompressed->offset[idx] );
-
- int numerror = 0;
- while ( numerror < totalerror )
- {
- // Write the first animation value (struct of 2 bytes)
- mstudioanimvalue_t *pDestAnimvalue = (mstudioanimvalue_t*)( g_bNativeSrc ? pAnimvalueSrc : pAnimvalueDest );
- WriteBuffer<char>( &pAnimvalueDest, &pAnimvalueSrc, 2 );
-
- // Write the remaining animation values from this group (shorts)
- WriteBuffer<short>( &pAnimvalueDest, &pAnimvalueSrc, pDestAnimvalue->num.valid );
-
- numerror += pDestAnimvalue->num.total;
- }
- }
- }
-
- if ( pIKRule->szattachmentindex )
- {
- SET_INDEX_POINTERS( pData, pIKRule, szattachmentindex )
- int size = strlen( (char*)pDataSrc ) + 1;
- WriteBuffer<char>( pDataDest, pDataSrc, size );
- }
- }
- }
- }
-
- // Local hierarchy keys don't exist in older models
- }
-
- /** ZERO FRAMES **/
-
- SET_INDEX_POINTERS( pData, pHdr, localanimindex )
- SET_OBJECT_POINTERS( pAnimDesc, pData, mstudioanimdesc_t )
- ITERATE_BLOCK( pAnimDesc, pHdr->numlocalanim )
- {
- if ( pAnimDesc->pZeroFrameData( ) != NULL )
- {
- int offset = pAnimDesc->pZeroFrameData( ) - (byte *)pAnimDesc;
-
- // Base address of the animation in the animblock
- byte *pZeroFrameSrc = (byte *)pAnimDescSrc + offset;
- byte *pZeroFrameDest = (byte *)pAnimDescDest + offset;
-
- SET_INDEX_POINTERS( pData, pHdr, boneindex )
- SET_OBJECT_POINTERS( pStudioBone, pData, mstudiobone_t )
- ITERATE_BLOCK( pStudioBone, pHdr->numbones )
- {
- if ( pStudioBone->flags & BONE_HAS_SAVEFRAME_POS )
- {
- for ( int j = 0; j < pAnimDesc->zeroframecount; j++)
- {
- WriteBuffer<short>( &pZeroFrameDest, &pZeroFrameSrc, 3 );
- }
- }
- if ( pStudioBone->flags & BONE_HAS_SAVEFRAME_ROT )
- {
- for ( int j = 0; j < pAnimDesc->zeroframecount; j++)
- {
- WriteBuffer<int64>( &pZeroFrameDest, &pZeroFrameSrc, 1 );
- }
- }
- }
- }
- }
-
- /** SEQUENCE INFO **/
-
- SET_INDEX_POINTERS_FIXUP( pData, pHdr, localseqindex )
- DECLARE_OBJECT_POINTERS( pSequence, pData, mstudioseqdesc_t )
- ITERATE_BLOCK( pSequence, pHdr->numlocalseq )
- {
- WriteObjects( pSequenceDest, pSequenceSrc );
-
- /** POSE KEYS **/
-
- if ( pSequence->posekeyindex )
- {
- SET_INDEX_POINTERS_FIXUP( pData, pSequence, posekeyindex )
- WriteBuffer<float>( pDataDest, pDataSrc, SrcNative( &pSequence->groupsize[0] ) + SrcNative( &pSequence->groupsize[1] ) );
- }
-
- /** STUDIO EVENTS **/
-
- SET_INDEX_POINTERS_FIXUP( pData, pSequence, eventindex )
- WriteObjects<mstudioevent_t>( pDataDest, pDataSrc, SrcNative( &pSequence->numevents ) );
-
- /** AUTOLAYERS **/
-
- SET_INDEX_POINTERS_FIXUP( pData, pSequence, autolayerindex )
- WriteObjects<mstudioautolayer_t>( pDataDest, pDataSrc, SrcNative( &pSequence->numautolayers ) );
-
- /** BONE WEIGHTS **/
-
- // Data may be shared across sequences
- DECLARE_INDEX_POINTERS_FIXUP( pWeight, pSequence, weightlistindex )
- if ( pWeightSrc >= pDataSrc )
- {
- int numBoneWeights = ( SrcNative( &pSequence->iklockindex ) - SrcNative( &pSequence->weightlistindex ) ) / sizeof(float);
- WriteBuffer<float>( pWeightDest, pWeightSrc, numBoneWeights );
- }
-
- /** IK LOCKS **/
-
- SET_INDEX_POINTERS_FIXUP( pData, pSequence, iklockindex )
- WriteObjects<mstudioiklock_t>( pDataDest, pDataSrc, SrcNative( &pSequence->numiklocks ) );
-
- /** ANIMATION INDICES **/
-
- if ( pSequence->animindexindex )
- {
- SET_INDEX_POINTERS( pData, pSequence, animindexindex )
- WriteBuffer<short>( pDataDest, pDataSrc, SrcNative( &pSequence->groupsize[0] ) * SrcNative( &pSequence->groupsize[1] ) );
- }
-
- /** KEYVALUES **/
-
- SET_INDEX_POINTERS( pData, pSequence, keyvalueindex )
- WriteBuffer<char>( pDataDest, pDataSrc, SrcNative( &pSequence->keyvaluesize ) );
- }
-
- /** TRANSITION GRAPH **/
-
- int numLocalNodes = SrcNative( &pHdr->numlocalnodes );
- SET_INDEX_POINTERS_FIXUP( pData, pHdr, localnodenameindex )
- WriteBuffer<int>( pDataDest, pDataSrc, numLocalNodes );
-
- /** LOCAL NODES **/
-
- SET_INDEX_POINTERS( pData, pHdr, localnodeindex )
- WriteBuffer<char>( pDataDest, pDataSrc, numLocalNodes * numLocalNodes );
-
- /** BODYPART INFO **/
-
- SET_INDEX_POINTERS_FIXUP( pData, pHdr, bodypartindex )
- DECLARE_OBJECT_POINTERS( pBodypart, pData, mstudiobodyparts_t )
- ITERATE_BLOCK( pBodypart, pHdr->numbodyparts )
- {
- WriteObjects( pBodypartDest, pBodypartSrc );
-
- /** MODEL INFO **/
-
- SET_INDEX_POINTERS_FIXUP( pData, pBodypart, modelindex )
- DECLARE_OBJECT_POINTERS( pModel, pData, mstudiomodel_t )
- ITERATE_BLOCK( pModel, pBodypart->nummodels )
- {
- WriteObjects( pModelDest, pModelSrc );
-
- /** MESHES **/
-
- SET_INDEX_POINTERS_FIXUP( pData, pModel, meshindex )
- DECLARE_OBJECT_POINTERS( pMesh, pData, mstudiomesh_t )
- ITERATE_BLOCK( pMesh, pModel->nummeshes )
- {
- WriteObjects( pMeshDest, pMeshSrc );
-
- if ( !pMesh->numflexes )
- continue;
-
- /** FLEXES **/
-
- SET_INDEX_POINTERS_FIXUP( pData, pMesh, flexindex )
- DECLARE_OBJECT_POINTERS( pFlex, pData, mstudioflex_t )
- ITERATE_BLOCK( pFlex, pMesh->numflexes )
- {
- WriteObjects( pFlexDest, pFlexSrc );
-
- /** VERT ANIMS **/
-
- SET_INDEX_POINTERS_FIXUP( pData, pFlex, vertindex )
- WriteObjects<mstudiovertanim_t>( pDataDest, pDataSrc, SrcNative( &pFlex->numverts ) );
- }
- }
-
- /** EYEBALLS **/
-
- SET_INDEX_POINTERS_FIXUP( pData, pModel, eyeballindex )
- WriteObjects<mstudioeyeball_t>( pDataDest, pDataSrc, SrcNative( &pModel->numeyeballs ) );
- }
- }
-
- /** GLOBAL FLEX NAMES **/
-
- SET_INDEX_POINTERS_FIXUP( pData, pHdr, flexdescindex )
- WriteObjects<mstudioflexdesc_t>( pDataDest, pDataSrc, SrcNative( &pHdr->numflexdesc ) );
-
- /** GLOBAL FLEX CONTROLLERS **/
-
- SET_INDEX_POINTERS_FIXUP( pData, pHdr, flexcontrollerindex )
- WriteObjects<mstudioflexcontroller_t>( pDataDest, pDataSrc, SrcNative( &pHdr->numflexcontrollers ) );
-
- /** GLOBAL FLEX CONTROLLER REMAPS **/
-
- SET_INDEX_POINTERS_FIXUP( pData, pHdr, flexcontrolleruiindex )
- WriteObjects<mstudioflexcontrollerui_t>( pDataDest, pDataSrc, SrcNative( &pHdr->numflexcontrollerui ) );
-
- // TODOKD: The remap indices after the flex controller remap headers need to be swapped as well?
-
- /** FLEX RULES **/
-
- SET_INDEX_POINTERS_FIXUP( pData, pHdr, flexruleindex )
- DECLARE_OBJECT_POINTERS( pFlexRule, pData, mstudioflexrule_t )
- ITERATE_BLOCK( pFlexRule, pHdr->numflexrules )
- {
- WriteObjects( pFlexRuleDest, pFlexRuleSrc );
-
- /** FLEX OPS **/
-
- SET_INDEX_POINTERS_FIXUP( pData, pFlexRule, opindex )
- WriteObjects<mstudioflexop_t>( pDataDest, pDataSrc, SrcNative( &pFlexRule->numops ) );
- }
-
- /** IK CHAINS **/
-
- SET_INDEX_POINTERS_FIXUP( pData, pHdr, ikchainindex )
- DECLARE_OBJECT_POINTERS( pIKChain, pData, mstudioikchain_t )
- ITERATE_BLOCK( pIKChain, pHdr->numikchains )
- {
- WriteObjects( pIKChainDest, pIKChainSrc );
-
- /** IK LINKS **/
-
- SET_INDEX_POINTERS( pData, pIKChain, linkindex )
- WriteObjects<mstudioiklink_t>( pDataDest, pDataSrc, SrcNative( &pIKChain->numlinks ) );
- }
-
- /** IK AUTOPLAY LOCKS **/
-
- SET_INDEX_POINTERS_FIXUP( pData, pHdr, localikautoplaylockindex )
- WriteObjects<mstudioiklock_t>( pDataDest, pDataSrc, SrcNative( &pHdr->numlocalikautoplaylocks ) );
-
- /** MOUTH INFO **/
-
- SET_INDEX_POINTERS_FIXUP( pData, pHdr, mouthindex )
- WriteObjects<mstudiomouth_t>( pDataDest, pDataSrc, SrcNative( &pHdr->nummouths ) );
-
- /** POSE PARAMATERS **/
-
- SET_INDEX_POINTERS_FIXUP( pData, pHdr, localposeparamindex )
- WriteObjects<mstudioposeparamdesc_t>( pDataDest, pDataSrc, SrcNative( &pHdr->numlocalposeparameters ) );
-
- /** MODEL GROUPS **/
-
- SET_INDEX_POINTERS_FIXUP( pData, pHdr, includemodelindex )
- WriteObjects<mstudiomodelgroup_t>( pDataDest, pDataSrc, SrcNative( &pHdr->numincludemodels ) );
-
- /** ANIMBLOCK GROUP INFO **/
-
- SET_INDEX_POINTERS_FIXUP( pData, pHdr, animblockindex )
- WriteObjects<mstudioanimblock_t>( pDataDest, pDataSrc, SrcNative( &pHdr->numanimblocks ) );
-
- /** TEXTURE INFO **/
-
- // While swapping, kill off unwanted textures by name
- SET_INDEX_POINTERS_FIXUP( pData, pHdr, textureindex )
- DECLARE_OBJECT_POINTERS( pTexture, pData, mstudiotexture_t )
- int textureCt = SrcNative( &pHdr->numtextures );
- int nameOffset = 0;
- for ( int i = 0; i < SrcNative( &pHdr->numtextures ); ++i, ++pTexture, ++pTextureSrc )
- {
- WriteObjects<mstudiotexture_t>( pTextureDest, pTextureSrc );
-
- int destnameindex = SrcNative( &pTexture->sznameindex ) + nameOffset;
- pTextureDest->sznameindex = DestNative( &destnameindex );
- char *pName = (char*)pTexture + SrcNative( &pTexture->sznameindex );
-#if 0 // Undone: Killing textures here can cause crashes at runtime.
- // Don't need pupil textures
- if ( Q_stristr( pName, "pupil_" ) || !Q_stricmp( pName, "pupil" ) )
- {
- --textureCt;
- nameOffset += sizeof(mstudiotexture_t);
- }
- else
-#endif
- {
- ++pTextureDest;
- }
- }
- pHdrDest->numtextures = DestNative( &textureCt );
-
- /** TEXTURE INDICES **/
-
- SET_INDEX_POINTERS_FIXUP( pData, pHdr, cdtextureindex )
- WriteBuffer<int>( &pDataDest, &pDataSrc, SrcNative( &pHdr->numcdtextures ) );
-
- /** TEXTURE DICTIONARY **/
-
- SET_INDEX_POINTERS( pData, pHdr, skinindex )
- WriteBuffer<short>( &pDataDest, &pDataSrc, SrcNative( &pHdr->numskinfamilies ) * SrcNative( &pHdr->numskinref ) );
-
- /** KEYVALUES **/
-
- SET_INDEX_POINTERS( pData, pHdr, keyvalueindex )
- WriteBuffer<char>( &pDataDest, &pDataSrc, SrcNative( &pHdr->keyvaluesize ) );
-
- /** STUDIOHDR2 **/
-
- if ( pHdr->studiohdr2index )
- {
- DECLARE_INDEX_POINTERS_FIXUP( pLocalData, pHdr, studiohdr2index )
- DECLARE_OBJECT_POINTERS( pStudioHdr2, pLocalData, studiohdr2_t )
-
- // HACK: Pre-swap the constant "1" here so the automatic swap inside ITERATE_BLOCK will restore it
- int studiohdr2ct = 1;
- studiohdr2ct = SrcNative( &studiohdr2ct );
- ITERATE_BLOCK( pStudioHdr2, studiohdr2ct )
- {
- WriteObjects( pStudioHdr2Dest, pStudioHdr2Src );
-
- /** SRC BONE TRANSFORMS **/
-
- if ( pStudioHdr2->numsrcbonetransform )
- {
- // Note, srcbonetransformindex is an offset from the start of the file, not the start of the studiohdr2
- // as is the convention. That's why the macros can't be used here.
- pDataSrc = (byte*)pHdrSrc + SrcNative( &pStudioHdr2->srcbonetransformindex );
- pDataDest = (byte*)pHdrDest + SrcNative( &pStudioHdr2->srcbonetransformindex );
- WriteObjects<mstudiosrcbonetransform_t>( &pDataDest, &pDataSrc, SrcNative( &pStudioHdr2->numsrcbonetransform ) );
- }
-
- if ( pStudioHdr2->linearboneindex )
- {
- SET_INDEX_POINTERS_FIXUP( pData, pStudioHdr2, linearboneindex )
- DECLARE_OBJECT_POINTERS( pLinearBone, pData, mstudiolinearbone_t )
-
- WriteObjects( pLinearBoneDest, pLinearBoneSrc );
-
- int numBones = SrcNative( &pLinearBone->numbones );
- SET_INDEX_POINTERS_FIXUP( pData, pLinearBone, flagsindex )
- WriteBuffer<int>( &pDataDest, &pDataSrc, numBones );
-
- SET_INDEX_POINTERS_FIXUP( pData, pLinearBone, parentindex )
- WriteBuffer<int>( &pDataDest, &pDataSrc, numBones );
-
- SET_INDEX_POINTERS_FIXUP( pData, pLinearBone, posindex )
- WriteBuffer<float>( &pDataDest, &pDataSrc, 3*numBones );
-
- SET_INDEX_POINTERS_FIXUP( pData, pLinearBone, quatindex )
- WriteBuffer<float>( &pDataDest, &pDataSrc, 4*numBones );
-
- SET_INDEX_POINTERS_FIXUP( pData, pLinearBone, rotindex )
- WriteBuffer<float>( &pDataDest, &pDataSrc, 3*numBones );
-
- SET_INDEX_POINTERS_FIXUP( pData, pLinearBone, posetoboneindex )
- WriteBuffer<float>( &pDataDest, &pDataSrc, 12*numBones );
-
- SET_INDEX_POINTERS_FIXUP( pData, pLinearBone, posscaleindex )
- WriteBuffer<float>( &pDataDest, &pDataSrc, 3*numBones );
-
- SET_INDEX_POINTERS_FIXUP( pData, pLinearBone, rotscaleindex )
- WriteBuffer<float>( &pDataDest, &pDataSrc, 3*numBones );
-
- SET_INDEX_POINTERS_FIXUP( pData, pLinearBone, qalignmentindex )
- WriteBuffer<float>( &pDataDest, &pDataSrc, 4*numBones );
- }
- }
- }
-
- /** STRING TABLE **/
-
- // NOTE: The block of data (above) swapped immediately before the string table MUST update the
- // pDataSrc pointer position, in order for this string table offset calculation to work correctly.
- // To update the pointer position, pass the pointer address to WriteObjects().
- int offset = pDataSrc - (byte*)pSrcBase;
- int stringTableBytes = fixedFileSize - offset;
- WriteBuffer<char>( pDataDest, pDataSrc, stringTableBytes );
-
- pHdrDest->length = DestNative( &fixedFileSize );
-
- // Cleanup texture paths
- // Some older MDL's have double terminal slashes
- SET_INDEX_POINTERS( pData, pHdr, cdtextureindex )
- int numCdTextures = SrcNative( &pHdr->numcdtextures );
- for ( int i = 0; i < numCdTextures; ++i )
- {
- char *pPath = (char*)pHdrDest + SrcNative( &((int *)pDataSrc)[i] );
- int len = strlen( pPath );
- if ( len >= 2 && ( pPath[len-1] == '\\' || pPath[len-1] == '/' ) && ( pPath[len-2] == '\\' || pPath[len-2] == '/' ) )
- {
- pPath[len-1] = '\0';
- }
- }
-
- return fixedFileSize;
-}
-
-//----------------------------------------------------------------------
-// Swap a .mdl in two passes - first pass fixes alignment errors by shifting
-// the data and updating offsets, then the second pass does the final swap.
-//----------------------------------------------------------------------
-int ByteswapMDL( void *pDestBase, const void *pSrcBase, const int fileSize )
-{
- // Make a working copy of the source to allow for alignment fixups
- void *pNewSrcBase = malloc( fileSize + BYTESWAP_ALIGNMENT_PADDING );
- Q_memcpy( pNewSrcBase, pSrcBase, fileSize );
-
- int fixedFileSize = ByteswapMDLFile( pDestBase, pNewSrcBase, fileSize );
- if ( fixedFileSize != fileSize )
- {
- int finalSize = ByteswapMDLFile( pDestBase, pNewSrcBase, fixedFileSize );
- if ( finalSize != fixedFileSize )
- {
- Warning( "Alignment fixups failed on MDL swap!\n" );
- fixedFileSize = 0;
- }
- }
-
- free( pNewSrcBase );
-
- // the compression needs to happen on the final or "fixed" pass
- if ( g_pCompressFunc && fixedFileSize )
- {
- void *pInput = pDestBase;
- int inputSize = fixedFileSize;
- void *pOutput;
- int outputSize;
- if ( g_pCompressFunc( pInput, inputSize, &pOutput, &outputSize ) )
- {
- V_memcpy( pDestBase, pOutput, outputSize );
- free( pOutput );
- fixedFileSize = outputSize;
- }
- }
-
- return fixedFileSize;
-}
-
-//----------------------------------------------------------------------
-// Determines what kind of file this is and calls the correct swap function
-//----------------------------------------------------------------------
-int ByteswapStudioFile( const char *pFilename, void *pOutBase, const void *pFileBase, int fileSize, studiohdr_t *pHdr, CompressFunc_t pCompressFunc )
-{
- assert( pFilename );
- assert( pOutBase != pFileBase );
-
- g_pCompressFunc = pCompressFunc;
-
- int retVal = 0;
-
- if ( Q_stristr( pFilename, ".mdl" ) )
- {
- retVal = ByteswapMDL( pOutBase, pFileBase, fileSize );
- }
- else if ( Q_stristr( pFilename, ".vvd" ) )
- {
- retVal = ByteswapVVD( pOutBase, pFileBase, fileSize );
- }
- else if ( Q_stristr( pFilename, ".vtx" ) )
- {
- retVal = ByteswapVTX( pOutBase, pFileBase, fileSize );
- }
- else if ( Q_stristr( pFilename, ".phy" ) )
- {
- retVal = ByteswapPHY( pOutBase, pFileBase, fileSize );
- }
- else if ( Q_stristr( pFilename, ".ani" ) )
- {
- // some dead .ani files exist in the tree
- // only process valid .ani files properly hooked to their .mdl
- if ( pHdr && pHdr->numanimblocks != 0 )
- {
- retVal = ByteswapANI( pHdr, pOutBase, pFileBase, fileSize );
- }
- }
-
- g_pCompressFunc = NULL;
-
- return retVal;
-}
-
-
-//----------------------------------------------------------------------
-// LEGACY ANI FIXUPS - No need to update this function
-//
-// If model data needs to be shifted to fix a misalignment, this function is
-// called with the process func "UpdateSrcIndexFields" to update every datadesc field
-// that was marked as FIELD_INDEX. Any index that "points" across
-// the shifted data location will have its value incremented or decremented
-// by the appropriate number of bytes. This misalignment issue only
-// applies to some pre-EP2 models, as all newly compiled models are guaranteed
-// to be aligned correctly. Therefore, this function should not need to change
-// when model formats are updated, as any model compiled with a new format will
-// naturally not require this fixup function to be called.
-//----------------------------------------------------------------------
-void ProcessANIFields( void *pDataBase, datadescProcessFunc_t pfnProcessFunc )
-{
- studiohdr_t *pHdr = g_pHdr;
- byte *pData = (byte*)pDataBase;
- byte *pSrcBase = (byte*)g_pDataSrcBase;
-
- // Since the animblocks and animdescs are native data, trick the system
- // into not swapping their index values during processing.
- bool bNativeSrc = g_bNativeSrc;
- g_bNativeSrc = true;
-
- // Update the .mdl's animblock offsets into the .ani file
- mstudioanimblock_t *pAnimBlock = pHdr->pAnimBlock( 1 );
- for ( int i = 1; i < pHdr->numanimblocks; ++i, ++pAnimBlock )
- {
- ProcessFields( pSrcBase, pAnimBlock, &mstudioanimblock_t::m_DataMap, pfnProcessFunc );
- }
-
- // Update the .mdl's animindex offsets into the .ani file
- // Don't bother with local hierarchy keys - they only exist in newer, properly aligned models
- mstudioanimdesc_t *pAnimDesc = pHdr->pLocalAnimdesc( 0 );
- for ( int i = 0; i < pHdr->numlocalanim; ++i, ++pAnimDesc )
- {
- mstudioanimblock_t *pAnimBlock = pHdr->pAnimBlock( pAnimDesc->animblock );
- byte *pBlockBase = (byte*)pSrcBase + pAnimBlock->datastart;
-
- ProcessFieldByName( pBlockBase, pAnimDesc, &mstudioanimdesc_t::m_DataMap, "animindex", pfnProcessFunc );
- ProcessFieldByName( pBlockBase, pAnimDesc, &mstudioanimdesc_t::m_DataMap, "animblockikruleindex", pfnProcessFunc );
- }
-
- // Restore the correct native setting
- g_bNativeSrc = bNativeSrc;
-
- // Update the .ani file's internal offsets
- pAnimDesc = pHdr->pLocalAnimdesc( 0 );
- for ( int i = 0; i < pHdr->numlocalanim; ++i, ++pAnimDesc )
- {
- pAnimBlock = pHdr->pAnimBlock( pAnimDesc->animblock );
- byte *pBlockBase = (byte*)pSrcBase + pAnimBlock->datastart;
-
- byte *pData = pBlockBase + pAnimDesc->animindex;
- mstudioanim_t* pAnimation = (mstudioanim_t*)pData;
- if ( pAnimation->bone == 255 )
- {
- // No animation data
- pAnimation = 0;
- }
-
- while( pAnimation )
- {
- ProcessFields( pAnimation, &mstudioanim_t::m_DataMap, pfnProcessFunc );
-
- if ( pAnimation->nextoffset )
- {
- pData = (byte*)pAnimation + SrcNative( &pAnimation->nextoffset );
- pAnimation = (mstudioanim_t*)pData;
- }
- else
- {
- pAnimation = NULL;
- }
- }
-
- if ( pAnimDesc->animblockikruleindex )
- {
- pData = (byte*)pBlockBase + pAnimDesc->animblockikruleindex;
-
- mstudioikrule_t *pIKRule = (mstudioikrule_t *)pData;
- for ( int i = 0; i < pAnimDesc->numikrules; ++i, ++pIKRule )
- {
- ProcessFields( pIKRule, &mstudioikrule_t::m_DataMap, pfnProcessFunc );
- }
- }
- }
-}
-
-//----------------------------------------------------------------------
-// LEGACY MDL FIXUPS - No need to update this function
-//
-// If model data needs to be shifted to fix a misalignment, this function is
-// called with the process func "UpdateSrcIndexFields" to update every datadesc field
-// that was marked as FIELD_INDEX. Any index that "points" across
-// the shifted data location will have its value incremented or decremented
-// by the appropriate number of bytes. This misalignment issue only
-// applies to some pre-EP2 models, as all newly compiled models are guaranteed
-// to be aligned correctly. Therefore, this function should not need to change
-// when model formats are updated, as any model compiled with a new format will
-// naturally not require this fixup function to be called.
-//----------------------------------------------------------------------
-void ProcessMDLFields( void *pDataBase, datadescProcessFunc_t pfnProcessFunc )
-{
- byte *pData = (byte*)pDataBase;
-
- /** FILE HEADER **/
-
- studiohdr_t *pHdr = (studiohdr_t*)pData;
- ProcessFields( pHdr, &studiohdr_t::m_DataMap, pfnProcessFunc );
-
- /** BONES **/
-
- pData = (byte*)pHdr + SrcNative( &pHdr->boneindex );
- mstudiobone_t *pBone = (mstudiobone_t*)pData;
- for ( int i = 0; i < SrcNative( &pHdr->numbones ); ++i, ++pBone )
- {
- ProcessFields( pBone, &mstudiobone_t::m_DataMap, pfnProcessFunc );
-
- if ( pBone->procindex )
- {
- pData = (byte*)pBone + SrcNative( &pBone->procindex );
-
- unsigned int proctype = SrcNative( &pBone->proctype );
- switch( proctype )
- {
- case STUDIO_PROC_AXISINTERP:
-
- /** AXIS-INTERP BONES **/
- ProcessFields( pData, &mstudioaxisinterpbone_t::m_DataMap, pfnProcessFunc );
- break;
-
- case STUDIO_PROC_QUATINTERP:
-
- /** QUAT-INTERP BONES **/
- ProcessFields( pData, &mstudioquatinterpbone_t::m_DataMap, pfnProcessFunc );
- break;
-
- case STUDIO_PROC_JIGGLE:
-
- /** JIGGLE BONES **/
- ProcessFields( pData, &mstudiojigglebone_t::m_DataMap, pfnProcessFunc );
- break;
-
- case STUDIO_PROC_AIMATBONE:
- case STUDIO_PROC_AIMATATTACH:
-
- /** AIM AT BONES **/
- ProcessFields( pData, &mstudioaimatbone_t::m_DataMap, pfnProcessFunc );
- break;
-
- }
- }
- }
-
- /** ATTACHMENTS **/
-
- pData = (byte*)pHdr + SrcNative( &pHdr->localattachmentindex );
- mstudioattachment_t *pAttachment = (mstudioattachment_t*)pData;
- for ( int i = 0; i < SrcNative( &pHdr->numlocalattachments ); ++i, ++pAttachment )
- {
- ProcessFields( pAttachment, &mstudioattachment_t::m_DataMap, pfnProcessFunc );
- }
-
- /** HITBOX SETS **/
-
- pData = (byte*)pHdr + SrcNative( &pHdr->hitboxsetindex );
- mstudiohitboxset_t* pHitboxSet = (mstudiohitboxset_t*)pData;
- for ( int i = 0; i < SrcNative( &pHdr->numhitboxsets ); ++i, ++pHitboxSet )
- {
- ProcessFields( pHitboxSet, &mstudiohitboxset_t::m_DataMap, pfnProcessFunc );
-
- /** HITBOXES **/
- pData = (byte*)pHitboxSet + SrcNative( &pHitboxSet->hitboxindex );
- mstudiobbox_t *pBBox = (mstudiobbox_t*)pData;
- for ( int i = 0; i < SrcNative( &pHitboxSet->numhitboxes ); ++i, ++pBBox )
- {
- ProcessFields( pBBox, &mstudiobbox_t::m_DataMap, pfnProcessFunc );
- }
- }
-
- /** ANIMATION DESCRIPTIONS **/
-
- pData = (byte*)pHdr + SrcNative( &pHdr->localanimindex );
- mstudioanimdesc_t* pAnimDesc = (mstudioanimdesc_t*)pData;
- for ( int i = 0; i < SrcNative( &pHdr->numlocalanim ); ++i, ++pAnimDesc )
- {
- // Can't update animindex or animblockindex for animations that are in a separate .ani file
- ProcessFieldByName( pAnimDesc, &mstudioanimdesc_t::m_DataMap, "baseptr", pfnProcessFunc );
- ProcessFieldByName( pAnimDesc, &mstudioanimdesc_t::m_DataMap, "sznameindex", pfnProcessFunc );
- ProcessFieldByName( pAnimDesc, &mstudioanimdesc_t::m_DataMap, "movementindex", pfnProcessFunc );
- ProcessFieldByName( pAnimDesc, &mstudioanimdesc_t::m_DataMap, "ikruleindex", pfnProcessFunc );
-
- /** ANIMATIONS **/
-
- if ( pAnimDesc->animblock == 0 )
- {
- // Now it's safe to update the animindex
- ProcessFieldByName( pAnimDesc, &mstudioanimdesc_t::m_DataMap, "animindex", pfnProcessFunc );
-
- pData = (byte*)pAnimDesc + SrcNative( &pAnimDesc->animindex );
- mstudioanim_t* pAnimation = (mstudioanim_t*)pData;
- while( pAnimation )
- {
- ProcessFields( pAnimation, &mstudioanim_t::m_DataMap, pfnProcessFunc );
-
- if ( pAnimation->nextoffset )
- {
- pData = (byte*)pAnimation + SrcNative( &pAnimation->nextoffset );
- pAnimation = (mstudioanim_t*)pData;
- }
- else
- {
- pAnimation = NULL;
- }
- }
- }
-
- if ( pAnimDesc->ikruleindex )
- {
- pData = (byte*)pAnimDesc + SrcNative( &pAnimDesc->ikruleindex );
-
- mstudioikrule_t *pIKRule = (mstudioikrule_t *)pData;
- for ( int i = 0; i < SrcNative( &pAnimDesc->numikrules ); ++i, ++pIKRule )
- {
- ProcessFields( pIKRule, &mstudioikrule_t::m_DataMap, pfnProcessFunc );
- }
- }
- }
-
- /** SEQUENCE INFO **/
-
- pData = (byte*)pHdr + SrcNative( &pHdr->localseqindex );
- mstudioseqdesc_t *pSequenceHdr = (mstudioseqdesc_t*)pData;
- for ( int i = 0; i < SrcNative( &pHdr->numlocalseq ); ++i, ++pSequenceHdr )
- {
- ProcessFields( pSequenceHdr, &mstudioseqdesc_t::m_DataMap, pfnProcessFunc );
-
- /** STUDIO EVENTS **/
-
- pData = (byte*)pHdr + SrcNative( &pSequenceHdr->eventindex );
- mstudioevent_t *pEvent = (mstudioevent_t*)pData;
- for ( int i = 0; i < SrcNative( &pSequenceHdr->numevents ); ++i, ++pEvent )
- {
- ProcessFields( pSequenceHdr, &mstudioevent_t::m_DataMap, pfnProcessFunc );
- }
- }
-
- /** BODYPART INFO **/
-
- pData = (byte*)pHdr + SrcNative( &pHdr->bodypartindex );
- mstudiobodyparts_t *pBodypart = (mstudiobodyparts_t*)pData;
- for ( int i = 0; i < SrcNative( &pHdr->numbodyparts ); ++i, ++pBodypart )
- {
- ProcessFields( pBodypart, &mstudiobodyparts_t::m_DataMap, pfnProcessFunc );
-
- /** MODEL INFO **/
-
- byte *pData = (byte*)pBodypart + SrcNative( &pBodypart->modelindex );
- mstudiomodel_t *pModel = (mstudiomodel_t*)pData;
- for ( int i = 0; i < SrcNative( &pBodypart->nummodels ); ++i, ++pModel )
- {
- ProcessFields( pModel, &mstudiomodel_t::m_DataMap, pfnProcessFunc );
-
- /** MESHES **/
-
- pData = (byte*)pModel + SrcNative( &pModel->meshindex );
- mstudiomesh_t *pMesh = (mstudiomesh_t*)pData;
- for ( int i = 0; i < SrcNative( &pModel->nummeshes ); ++i, ++pMesh )
- {
- ProcessFields( pMesh, &mstudiomesh_t::m_DataMap, pfnProcessFunc );
-
- if ( !pMesh->numflexes )
- continue;
-
- /** FLEXES **/
-
- pData = (byte*)pMesh + SrcNative( &pMesh->flexindex );
- mstudioflex_t *pFlex = (mstudioflex_t*)pData;
- for ( int i = 0; i < SrcNative( &pMesh->numflexes ); ++i, ++pFlex )
- {
- ProcessFields( pFlex, &mstudioflex_t::m_DataMap, pfnProcessFunc );
- }
- }
-
- /** EYEBALLS **/
-
- pData= (byte*)pModel + SrcNative( &pModel->eyeballindex );
- mstudioeyeball_t *pEyeball = (mstudioeyeball_t*)pData;
- for ( int i = 0; i < SrcNative( &pModel->numeyeballs ); ++i, ++pEyeball )
- {
- ProcessFields( pEyeball, &mstudioeyeball_t::m_DataMap, pfnProcessFunc );
- }
- }
- }
-
- /** GLOBAL FLEX NAMES **/
-
- pData = (byte*)pHdr + SrcNative( &pHdr->flexdescindex );
- mstudioflexdesc_t *pFlexDesc = (mstudioflexdesc_t*)pData;
- for ( int i = 0; i < SrcNative( &pHdr->numflexdesc ); ++i, ++pFlexDesc )
- {
- ProcessFields( pFlexDesc, &mstudioflexdesc_t::m_DataMap, pfnProcessFunc );
- }
-
- /** GLOBAL FLEX CONTROLLERS **/
-
- pData = (byte*)pHdr + SrcNative( &pHdr->flexcontrollerindex );
- mstudioflexcontroller_t *pFlexController = (mstudioflexcontroller_t*)pData;
- for ( int i = 0; i < SrcNative( &pHdr->numflexcontrollers ); ++i, ++pFlexController )
- {
- ProcessFields( pFlexController, &mstudioflexcontroller_t::m_DataMap, pfnProcessFunc );
- }
-
- /** GLOBAL FLEX CONTROLLER REMAPS **/
-
- pData = (byte*)pHdr + SrcNative( &pHdr->flexcontrolleruiindex );
- mstudioflexcontrollerui_t *pFlexControllerRemap = (mstudioflexcontrollerui_t*)pData;
- for ( int i = 0; i < SrcNative( &pHdr->numflexcontrollerui ); ++i, ++pFlexControllerRemap )
- {
- ProcessFields( pFlexControllerRemap, &mstudioflexcontrollerui_t::m_DataMap, pfnProcessFunc );
- }
-
- /** FLEX RULES **/
-
- pData = (byte*)pHdr + SrcNative( &pHdr->flexruleindex );
- mstudioflexrule_t *pFlexRule = (mstudioflexrule_t*)pData;
- for ( int i = 0; i < SrcNative( &pHdr->numflexrules ); ++i, ++pFlexRule )
- {
- ProcessFields( pFlexRule, &mstudioflexrule_t::m_DataMap, pfnProcessFunc );
- }
-
- /** IK CHAINS **/
-
- pData = (byte*)pHdr + SrcNative( &pHdr->ikchainindex );
- mstudioikchain_t *pIKChain = (mstudioikchain_t*)pData;
- for ( int i = 0; i < SrcNative( &pHdr->numikchains ); ++i, ++pIKChain )
- {
- ProcessFields( pIKChain, &mstudioikchain_t::m_DataMap, pfnProcessFunc );
- }
-
- /** POSE PARAMATERS **/
-
- pData = (byte*)pHdr + SrcNative( &pHdr->localposeparamindex );
- mstudioposeparamdesc_t *pPoseParam = (mstudioposeparamdesc_t*)pData;
- for ( int i = 0; i < SrcNative( &pHdr->numlocalposeparameters ); ++i, ++pPoseParam )
- {
- ProcessFields( pPoseParam, &mstudioposeparamdesc_t::m_DataMap, pfnProcessFunc );
- }
-
- /** MODEL GROUPS **/
-
- pData = (byte*)pHdr + SrcNative( &pHdr->includemodelindex );
- mstudiomodelgroup_t *pMdl = (mstudiomodelgroup_t*)pData;
- for ( int i = 0; i < SrcNative( &pHdr->numincludemodels ); ++i, ++pMdl )
- {
- ProcessFields( pMdl, &mstudiomodelgroup_t::m_DataMap, pfnProcessFunc );
- }
-
- /** TEXTURE INFO **/
-
- pData = (byte*)pHdr + SrcNative( &pHdr->textureindex );
- mstudiotexture_t *pTexture = (mstudiotexture_t*)pData;
- for ( int i = 0; i < SrcNative( &pHdr->numtextures ); ++i, ++pTexture )
- {
- ProcessFields( pTexture, &mstudiotexture_t::m_DataMap, pfnProcessFunc );
- }
-
- /** CDTEXTURE OFFSETS **/
-
- pData = (byte*)pHdr + SrcNative( &pHdr->cdtextureindex );
- int *pIdx = (int*)pData;
- for ( int i = 0; i < SrcNative( &pHdr->numcdtextures ); ++i, ++pIdx )
- {
- int idx = SrcNative( pIdx );
- UpdateIndex( pHdr, &idx );
- *pIdx = SrcNative( &idx );
- }
-
- /** STUDIOHDR2 **/
-
- if ( pHdr->studiohdr2index )
- {
- pData = (byte*)pHdr + SrcNative( &pHdr->studiohdr2index );
- studiohdr2_t *pStudioHdr2 = (studiohdr2_t*)pData;
- for ( int i = 0; i < 1; ++i, ++pStudioHdr2 )
- {
- ProcessFields( pStudioHdr2, &studiohdr2_t::m_DataMap, pfnProcessFunc );
-
- /** SRC BONE TRANSFORMS **/
-
- pData = (byte*)pHdr + SrcNative( &pStudioHdr2->srcbonetransformindex );
- mstudiosrcbonetransform_t *pSrcBoneTransform = (mstudiosrcbonetransform_t*)pData;
- for ( int i = 0; i < SrcNative( &pStudioHdr2->numsrcbonetransform ); ++i, ++pSrcBoneTransform )
- {
- ProcessFields( pSrcBoneTransform, &mstudiosrcbonetransform_t::m_DataMap, pfnProcessFunc );
- }
- }
- }
-}
-
-
-#pragma warning( pop ) // local variable is initialized but not referenced
-
-} // namespace StudioByteSwap
-
-// Data descriptions for byte swapping - only needed
-// for structures that are written to file for use by the game.
-// For any fields that reference other data in the file, use the
-// DEFINE_INDEX macro to identify them as such.
-BEGIN_BYTESWAP_DATADESC( studiohdr_t )
- DEFINE_FIELD( id, FIELD_INTEGER ),
- DEFINE_FIELD( version, FIELD_INTEGER ),
- DEFINE_FIELD( checksum, FIELD_INTEGER ),
- DEFINE_ARRAY( name, FIELD_CHARACTER, 64 ),
- DEFINE_FIELD( length, FIELD_INTEGER ),
- DEFINE_FIELD( eyeposition, FIELD_VECTOR ),
- DEFINE_FIELD( illumposition, FIELD_VECTOR ),
- DEFINE_FIELD( hull_min, FIELD_VECTOR ),
- DEFINE_FIELD( hull_max, FIELD_VECTOR ),
- DEFINE_FIELD( view_bbmin, FIELD_VECTOR ),
- DEFINE_FIELD( view_bbmax, FIELD_VECTOR ),
- DEFINE_FIELD( flags, FIELD_INTEGER ),
- DEFINE_FIELD( numbones, FIELD_INTEGER ), // bones
- DEFINE_INDEX( boneindex, FIELD_INTEGER ),
- DEFINE_FIELD( numbonecontrollers, FIELD_INTEGER ), // bone controllers
- DEFINE_INDEX( bonecontrollerindex, FIELD_INTEGER ),
- DEFINE_FIELD( numhitboxsets, FIELD_INTEGER ),
- DEFINE_INDEX( hitboxsetindex, FIELD_INTEGER ),
- DEFINE_FIELD( numlocalanim, FIELD_INTEGER ), // animations/poses
- DEFINE_INDEX( localanimindex, FIELD_INTEGER ), // animation descriptions
- DEFINE_FIELD( numlocalseq, FIELD_INTEGER ), // sequences
- DEFINE_INDEX( localseqindex, FIELD_INTEGER ),
- DEFINE_FIELD( activitylistversion, FIELD_INTEGER ), // initialization flag - have the sequences been indexed?
- DEFINE_FIELD( eventsindexed, FIELD_INTEGER ),
- DEFINE_FIELD( numtextures, FIELD_INTEGER ),
- DEFINE_INDEX( textureindex, FIELD_INTEGER ),
- DEFINE_FIELD( numcdtextures, FIELD_INTEGER ),
- DEFINE_INDEX( cdtextureindex, FIELD_INTEGER ),
- DEFINE_FIELD( numskinref, FIELD_INTEGER ),
- DEFINE_FIELD( numskinfamilies, FIELD_INTEGER ),
- DEFINE_INDEX( skinindex, FIELD_INTEGER ),
- DEFINE_FIELD( numbodyparts, FIELD_INTEGER ),
- DEFINE_INDEX( bodypartindex, FIELD_INTEGER ),
- DEFINE_FIELD( numlocalattachments, FIELD_INTEGER ),
- DEFINE_INDEX( localattachmentindex, FIELD_INTEGER ),
- DEFINE_FIELD( numlocalnodes, FIELD_INTEGER ),
- DEFINE_INDEX( localnodeindex, FIELD_INTEGER ),
- DEFINE_INDEX( localnodenameindex, FIELD_INTEGER ),
- DEFINE_FIELD( numflexdesc, FIELD_INTEGER ),
- DEFINE_INDEX( flexdescindex, FIELD_INTEGER ),
- DEFINE_FIELD( numflexcontrollers, FIELD_INTEGER ),
- DEFINE_INDEX( flexcontrollerindex, FIELD_INTEGER ),
- DEFINE_FIELD( numflexrules, FIELD_INTEGER ),
- DEFINE_INDEX( flexruleindex, FIELD_INTEGER ),
- DEFINE_FIELD( numikchains, FIELD_INTEGER ),
- DEFINE_INDEX( ikchainindex, FIELD_INTEGER ),
- DEFINE_FIELD( nummouths, FIELD_INTEGER ),
- DEFINE_INDEX( mouthindex, FIELD_INTEGER ),
- DEFINE_FIELD( numlocalposeparameters, FIELD_INTEGER ),
- DEFINE_INDEX( localposeparamindex, FIELD_INTEGER ),
- DEFINE_INDEX( surfacepropindex, FIELD_INTEGER ),
- DEFINE_INDEX( keyvalueindex, FIELD_INTEGER ),
- DEFINE_FIELD( keyvaluesize, FIELD_INTEGER ),
- DEFINE_FIELD( numlocalikautoplaylocks, FIELD_INTEGER ),
- DEFINE_INDEX( localikautoplaylockindex, FIELD_INTEGER ),
- DEFINE_FIELD( mass, FIELD_FLOAT ),
- DEFINE_FIELD( contents, FIELD_INTEGER ),
- DEFINE_FIELD( numincludemodels, FIELD_INTEGER ),
- DEFINE_INDEX( includemodelindex, FIELD_INTEGER ),
- DEFINE_FIELD( virtualModel, FIELD_INTEGER ), // void*
- DEFINE_INDEX( szanimblocknameindex, FIELD_INTEGER ),
- DEFINE_FIELD( numanimblocks, FIELD_INTEGER ),
- DEFINE_INDEX( animblockindex, FIELD_INTEGER ),
- DEFINE_FIELD( animblockModel, FIELD_INTEGER ), // void*
- DEFINE_INDEX( bonetablebynameindex, FIELD_INTEGER ),
- DEFINE_FIELD( pVertexBase, FIELD_INTEGER ), // void*
- DEFINE_FIELD( pIndexBase, FIELD_INTEGER ), // void*
- DEFINE_FIELD( constdirectionallightdot, FIELD_CHARACTER ), // byte
- DEFINE_FIELD( rootLOD, FIELD_CHARACTER ), // byte
- DEFINE_FIELD( numAllowedRootLODs, FIELD_CHARACTER ), // byte
- DEFINE_ARRAY( unused, FIELD_CHARACTER, 1 ), // byte
- DEFINE_INDEX( unused4, FIELD_INTEGER ),
- DEFINE_FIELD( numflexcontrollerui, FIELD_INTEGER ),
- DEFINE_INDEX( flexcontrolleruiindex, FIELD_INTEGER ),
- DEFINE_ARRAY( unused3, FIELD_INTEGER, 2 ),
- DEFINE_INDEX( studiohdr2index, FIELD_INTEGER ),
- DEFINE_ARRAY( unused2, FIELD_INTEGER, 1 ),
-END_BYTESWAP_DATADESC()
-
-// NOTE! Next time we up the .mdl file format, remove studiohdr2_t
-// and insert all fields in this structure into studiohdr_t.
-BEGIN_BYTESWAP_DATADESC( studiohdr2_t )
- DEFINE_FIELD( numsrcbonetransform, FIELD_INTEGER ),
- DEFINE_INDEX( srcbonetransformindex, FIELD_INTEGER ),
- DEFINE_FIELD( illumpositionattachmentindex, FIELD_INTEGER ),
- DEFINE_FIELD( flMaxEyeDeflection, FIELD_FLOAT ),
- DEFINE_INDEX( linearboneindex, FIELD_INTEGER ),
- DEFINE_INDEX( sznameindex, FIELD_INTEGER ),
- DEFINE_ARRAY( reserved, FIELD_INTEGER, 58 ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudiobone_t )
- DEFINE_INDEX( sznameindex, FIELD_INTEGER ),
- DEFINE_FIELD( parent, FIELD_INTEGER ),
- DEFINE_ARRAY( bonecontroller, FIELD_INTEGER, 6 ),
- DEFINE_FIELD( pos, FIELD_VECTOR ),
- DEFINE_FIELD( quat, FIELD_QUATERNION ),
- DEFINE_ARRAY( rot, FIELD_FLOAT, 3 ), // RadianEuler
- DEFINE_FIELD( posscale, FIELD_VECTOR ),
- DEFINE_FIELD( rotscale, FIELD_VECTOR ),
- DEFINE_ARRAY( poseToBone, FIELD_FLOAT, 12 ), // matrix3x4_t
- DEFINE_FIELD( qAlignment, FIELD_QUATERNION ),
- DEFINE_FIELD( flags, FIELD_INTEGER ),
- DEFINE_FIELD( proctype, FIELD_INTEGER ),
- DEFINE_INDEX( procindex, FIELD_INTEGER ),
- DEFINE_INDEX( physicsbone, FIELD_INTEGER ),
- DEFINE_INDEX( surfacepropidx, FIELD_INTEGER ),
- DEFINE_FIELD( contents, FIELD_INTEGER ),
- DEFINE_ARRAY( unused, FIELD_INTEGER, 8 ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudiolinearbone_t )
- DEFINE_FIELD( numbones, FIELD_INTEGER ),
- DEFINE_INDEX( flagsindex, FIELD_INTEGER ),
- DEFINE_INDEX( parentindex, FIELD_INTEGER ),
- DEFINE_INDEX( posindex, FIELD_INTEGER ),
- DEFINE_INDEX( quatindex, FIELD_INTEGER ),
- DEFINE_INDEX( rotindex, FIELD_INTEGER ),
- DEFINE_INDEX( posetoboneindex, FIELD_INTEGER ),
- DEFINE_INDEX( posscaleindex, FIELD_INTEGER ),
- DEFINE_INDEX( rotscaleindex, FIELD_INTEGER ),
- DEFINE_INDEX( qalignmentindex, FIELD_INTEGER ),
- DEFINE_ARRAY( unused, FIELD_INTEGER, 6 ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudioaxisinterpbone_t )
- DEFINE_FIELD( control, FIELD_INTEGER ),
- DEFINE_FIELD( axis, FIELD_INTEGER ),
- DEFINE_ARRAY( pos, FIELD_VECTOR, 6 ),
- DEFINE_ARRAY( quat, FIELD_QUATERNION, 6 ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudioquatinterpbone_t )
- DEFINE_FIELD( control, FIELD_INTEGER ),
- DEFINE_FIELD( numtriggers, FIELD_INTEGER ),
- DEFINE_INDEX( triggerindex, FIELD_INTEGER ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudiojigglebone_t )
- DEFINE_FIELD( flags, FIELD_INTEGER ),
- DEFINE_FIELD( length, FIELD_FLOAT ),
- DEFINE_FIELD( tipMass, FIELD_FLOAT ),
- DEFINE_FIELD( yawStiffness, FIELD_FLOAT ),
- DEFINE_FIELD( yawDamping, FIELD_FLOAT ),
- DEFINE_FIELD( pitchStiffness, FIELD_FLOAT ),
- DEFINE_FIELD( pitchDamping, FIELD_FLOAT ),
- DEFINE_FIELD( alongStiffness, FIELD_FLOAT ),
- DEFINE_FIELD( alongDamping, FIELD_FLOAT ),
- DEFINE_FIELD( angleLimit, FIELD_FLOAT ),
- DEFINE_FIELD( minYaw, FIELD_FLOAT ),
- DEFINE_FIELD( maxYaw, FIELD_FLOAT ),
- DEFINE_FIELD( yawFriction, FIELD_FLOAT ),
- DEFINE_FIELD( yawBounce, FIELD_FLOAT ),
- DEFINE_FIELD( minPitch, FIELD_FLOAT ),
- DEFINE_FIELD( maxPitch, FIELD_FLOAT ),
- DEFINE_FIELD( pitchFriction, FIELD_FLOAT ),
- DEFINE_FIELD( pitchBounce, FIELD_FLOAT ),
- DEFINE_FIELD( baseMass, FIELD_FLOAT ),
- DEFINE_FIELD( baseStiffness, FIELD_FLOAT ),
- DEFINE_FIELD( baseDamping, FIELD_FLOAT ),
- DEFINE_FIELD( baseMinLeft, FIELD_FLOAT ),
- DEFINE_FIELD( baseMaxLeft, FIELD_FLOAT ),
- DEFINE_FIELD( baseLeftFriction, FIELD_FLOAT ),
- DEFINE_FIELD( baseMinUp, FIELD_FLOAT ),
- DEFINE_FIELD( baseMaxUp, FIELD_FLOAT ),
- DEFINE_FIELD( baseUpFriction, FIELD_FLOAT ),
- DEFINE_FIELD( baseMinForward, FIELD_FLOAT ),
- DEFINE_FIELD( baseMaxForward, FIELD_FLOAT ),
- DEFINE_FIELD( baseForwardFriction, FIELD_FLOAT ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudioaimatbone_t )
- DEFINE_FIELD( parent, FIELD_INTEGER ),
- DEFINE_FIELD( aim, FIELD_INTEGER ),
- DEFINE_ARRAY( aimvector, FIELD_FLOAT, 3 ),
- DEFINE_ARRAY( upvector, FIELD_FLOAT, 3 ),
- DEFINE_ARRAY( basepos, FIELD_FLOAT, 3 ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudioquatinterpinfo_t )
- DEFINE_FIELD( inv_tolerance, FIELD_FLOAT ),
- DEFINE_FIELD( trigger, FIELD_QUATERNION ),
- DEFINE_FIELD( pos, FIELD_VECTOR ),
- DEFINE_FIELD( quat, FIELD_QUATERNION ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudiobonecontroller_t )
- DEFINE_FIELD( bone, FIELD_INTEGER ),
- DEFINE_FIELD( type, FIELD_INTEGER ),
- DEFINE_FIELD( start, FIELD_FLOAT ),
- DEFINE_FIELD( end, FIELD_FLOAT ),
- DEFINE_FIELD( rest, FIELD_INTEGER ),
- DEFINE_FIELD( inputfield, FIELD_INTEGER ),
- DEFINE_ARRAY( unused, FIELD_INTEGER, 8 ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudioattachment_t )
- DEFINE_INDEX( sznameindex, FIELD_INTEGER ),
- DEFINE_FIELD( flags, FIELD_INTEGER ),
- DEFINE_FIELD( localbone, FIELD_INTEGER ),
- DEFINE_ARRAY( local, FIELD_FLOAT, 12 ), // matrix3x4_t
- DEFINE_ARRAY( unused, FIELD_INTEGER, 8 ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudiohitboxset_t )
- DEFINE_INDEX( sznameindex, FIELD_INTEGER ),
- DEFINE_FIELD( numhitboxes, FIELD_INTEGER ),
- DEFINE_INDEX( hitboxindex, FIELD_INTEGER ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudiosrcbonetransform_t )
- DEFINE_INDEX( sznameindex, FIELD_INTEGER ),
- DEFINE_ARRAY( pretransform, FIELD_FLOAT, 12 ), // matrix3x4_t
- DEFINE_ARRAY( posttransform, FIELD_FLOAT, 12 ), // matrix3x4_t
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudiobbox_t )
- DEFINE_FIELD( bone, FIELD_INTEGER ),
- DEFINE_FIELD( group, FIELD_INTEGER ),
- DEFINE_FIELD( bbmin, FIELD_VECTOR ),
- DEFINE_FIELD( bbmax, FIELD_VECTOR ),
- DEFINE_INDEX( szhitboxnameindex, FIELD_INTEGER ),
- DEFINE_ARRAY( unused, FIELD_INTEGER, 8 ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudioanim_valueptr_t )
- DEFINE_ARRAY( offset, FIELD_SHORT, 3 ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudiolocalhierarchy_t )
- DEFINE_FIELD( iBone, FIELD_INTEGER ),
- DEFINE_FIELD( iNewParent, FIELD_INTEGER ),
- DEFINE_FIELD( start, FIELD_FLOAT ),
- DEFINE_FIELD( peak, FIELD_FLOAT ),
- DEFINE_FIELD( tail, FIELD_FLOAT ),
- DEFINE_FIELD( end, FIELD_FLOAT ),
- DEFINE_FIELD( iStart, FIELD_INTEGER ),
- DEFINE_INDEX( localanimindex, FIELD_INTEGER ),
- DEFINE_ARRAY( unused, FIELD_INTEGER, 4 ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudioanimsections_t )
- DEFINE_FIELD( animblock, FIELD_INTEGER ),
- DEFINE_INDEX( animindex, FIELD_INTEGER ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudioanimdesc_t )
- DEFINE_INDEX( baseptr, FIELD_INTEGER ),
- DEFINE_INDEX( sznameindex, FIELD_INTEGER ),
- DEFINE_FIELD( fps, FIELD_FLOAT ),
- DEFINE_FIELD( flags, FIELD_INTEGER ),
- DEFINE_FIELD( numframes, FIELD_INTEGER ),
- DEFINE_FIELD( nummovements, FIELD_INTEGER ),
- DEFINE_INDEX( movementindex, FIELD_INTEGER ),
- DEFINE_ARRAY( unused1, FIELD_INTEGER, 6 ),
- DEFINE_FIELD( animblock, FIELD_INTEGER ),
- DEFINE_INDEX( animindex, FIELD_INTEGER ),
- DEFINE_FIELD( numikrules, FIELD_INTEGER ),
- DEFINE_INDEX( ikruleindex, FIELD_INTEGER ),
- DEFINE_INDEX( animblockikruleindex, FIELD_INTEGER ),
- DEFINE_FIELD( numlocalhierarchy, FIELD_INTEGER ),
- DEFINE_INDEX( localhierarchyindex, FIELD_INTEGER ),
- DEFINE_INDEX( sectionindex, FIELD_INTEGER ),
- DEFINE_FIELD( sectionframes, FIELD_INTEGER ),
- DEFINE_FIELD( zeroframespan, FIELD_SHORT ),
- DEFINE_FIELD( zeroframecount, FIELD_SHORT ),
- DEFINE_INDEX( zeroframeindex, FIELD_INTEGER ),
- DEFINE_FIELD( zeroframestalltime, FIELD_FLOAT ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudioanim_t )
- DEFINE_FIELD( bone, FIELD_CHARACTER ),
- DEFINE_FIELD( flags, FIELD_CHARACTER ),
- DEFINE_INDEX( nextoffset, FIELD_SHORT ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudioikerror_t )
- DEFINE_FIELD( pos, FIELD_VECTOR ),
- DEFINE_FIELD( q, FIELD_QUATERNION ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudiocompressedikerror_t )
- DEFINE_ARRAY( scale, FIELD_FLOAT, 6 ),
- DEFINE_ARRAY( offset, FIELD_SHORT, 6 ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudioikrule_t )
- DEFINE_FIELD( index, FIELD_INTEGER ),
- DEFINE_FIELD( type, FIELD_INTEGER ),
- DEFINE_FIELD( chain, FIELD_INTEGER ),
- DEFINE_FIELD( bone, FIELD_INTEGER ),
- DEFINE_FIELD( slot, FIELD_INTEGER ),
- DEFINE_FIELD( height, FIELD_FLOAT ),
- DEFINE_FIELD( radius, FIELD_FLOAT ),
- DEFINE_FIELD( floor, FIELD_FLOAT ),
- DEFINE_FIELD( pos, FIELD_VECTOR ),
- DEFINE_FIELD( q, FIELD_QUATERNION ),
- DEFINE_INDEX( compressedikerrorindex, FIELD_INTEGER ),
- DEFINE_FIELD( unused2, FIELD_INTEGER ),
- DEFINE_FIELD( iStart, FIELD_INTEGER ),
- DEFINE_INDEX( ikerrorindex, FIELD_INTEGER ),
- DEFINE_FIELD( start, FIELD_FLOAT ),
- DEFINE_FIELD( peak, FIELD_FLOAT ),
- DEFINE_FIELD( tail, FIELD_FLOAT ),
- DEFINE_FIELD( end, FIELD_FLOAT ),
- DEFINE_FIELD( unused3, FIELD_FLOAT ),
- DEFINE_FIELD( contact, FIELD_FLOAT ),
- DEFINE_FIELD( drop, FIELD_FLOAT ),
- DEFINE_FIELD( top, FIELD_FLOAT ),
- DEFINE_FIELD( unused6, FIELD_INTEGER ),
- DEFINE_FIELD( unused7, FIELD_INTEGER ),
- DEFINE_FIELD( unused8, FIELD_INTEGER ),
- DEFINE_INDEX( szattachmentindex, FIELD_INTEGER ),
- DEFINE_ARRAY( unused, FIELD_INTEGER, 7 ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudiomovement_t )
- DEFINE_FIELD( endframe, FIELD_INTEGER ),
- DEFINE_FIELD( motionflags, FIELD_INTEGER ),
- DEFINE_FIELD( v0, FIELD_FLOAT ),
- DEFINE_FIELD( v1, FIELD_FLOAT ),
- DEFINE_FIELD( angle, FIELD_FLOAT ),
- DEFINE_FIELD( vector, FIELD_VECTOR ),
- DEFINE_FIELD( position, FIELD_VECTOR ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudioseqdesc_t )
- DEFINE_INDEX( baseptr, FIELD_INTEGER ),
- DEFINE_INDEX( szlabelindex, FIELD_INTEGER ),
- DEFINE_INDEX( szactivitynameindex, FIELD_INTEGER ),
- DEFINE_FIELD( flags, FIELD_INTEGER ), // looping/non-looping flags
- DEFINE_FIELD( activity, FIELD_INTEGER ), // initialized at loadtime to game DLL values
- DEFINE_FIELD( actweight, FIELD_INTEGER ),
- DEFINE_FIELD( numevents, FIELD_INTEGER ),
- DEFINE_INDEX( eventindex, FIELD_INTEGER ),
- DEFINE_FIELD( bbmin, FIELD_VECTOR ),
- DEFINE_FIELD( bbmax, FIELD_VECTOR ),
- DEFINE_FIELD( numblends, FIELD_INTEGER ),
- DEFINE_INDEX( animindexindex, FIELD_INTEGER ),
- DEFINE_INDEX( movementindex, FIELD_INTEGER ), // [blend] float array for blended movement
- DEFINE_ARRAY( groupsize, FIELD_INTEGER, 2 ),
- DEFINE_ARRAY( paramindex, FIELD_INTEGER, 2 ), // X, Y, Z, XR, YR, ZR
- DEFINE_ARRAY( paramstart, FIELD_FLOAT, 2 ), // local (0..1) starting value
- DEFINE_ARRAY( paramend, FIELD_FLOAT, 2 ), // local (0..1) ending value
- DEFINE_FIELD( paramparent, FIELD_INTEGER ),
- DEFINE_FIELD( fadeintime, FIELD_FLOAT ), // ideal cross fate in time (0.2 default)
- DEFINE_FIELD( fadeouttime, FIELD_FLOAT ), // ideal cross fade out time (0.2 default)
- DEFINE_FIELD( localentrynode, FIELD_INTEGER ), // transition node at entry
- DEFINE_FIELD( localexitnode, FIELD_INTEGER ), // transition node at exit
- DEFINE_FIELD( nodeflags, FIELD_INTEGER ), // transition rules
- DEFINE_FIELD( entryphase, FIELD_FLOAT ), // used to match entry gait
- DEFINE_FIELD( exitphase, FIELD_FLOAT ), // used to match exit gait
- DEFINE_FIELD( lastframe, FIELD_FLOAT ), // frame that should generation EndOfSequence
- DEFINE_FIELD( nextseq, FIELD_INTEGER ), // auto advancing sequences
- DEFINE_FIELD( pose, FIELD_INTEGER ), // index of delta animation between end and nextseq
- DEFINE_FIELD( numikrules, FIELD_INTEGER ),
- DEFINE_FIELD( numautolayers, FIELD_INTEGER ),
- DEFINE_INDEX( autolayerindex, FIELD_INTEGER ),
- DEFINE_INDEX( weightlistindex, FIELD_INTEGER ),
- DEFINE_INDEX( posekeyindex, FIELD_INTEGER ),
- DEFINE_FIELD( numiklocks, FIELD_INTEGER ),
- DEFINE_INDEX( iklockindex, FIELD_INTEGER ),
- DEFINE_INDEX( keyvalueindex, FIELD_INTEGER ),
- DEFINE_FIELD( keyvaluesize, FIELD_INTEGER ),
- DEFINE_INDEX( cycleposeindex, FIELD_INTEGER ),
- DEFINE_ARRAY( unused, FIELD_INTEGER, 7 ), // remove/add as appropriate (grow back to 8 ints on version change!)
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudioevent_t )
- DEFINE_FIELD( cycle, FIELD_FLOAT ),
- DEFINE_FIELD( event, FIELD_INTEGER ),
- DEFINE_FIELD( type, FIELD_INTEGER ),
- DEFINE_ARRAY( options, FIELD_CHARACTER, 64 ),
- DEFINE_INDEX( szeventindex, FIELD_INTEGER ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudioautolayer_t )
- DEFINE_FIELD( iSequence, FIELD_SHORT ),
- DEFINE_FIELD( iPose, FIELD_SHORT ),
- DEFINE_FIELD( flags, FIELD_INTEGER ),
- DEFINE_FIELD( start, FIELD_FLOAT ),
- DEFINE_FIELD( peak, FIELD_FLOAT ),
- DEFINE_FIELD( tail, FIELD_FLOAT ),
- DEFINE_FIELD( end, FIELD_FLOAT ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudioiklock_t )
- DEFINE_FIELD( chain, FIELD_INTEGER ),
- DEFINE_FIELD( flPosWeight, FIELD_FLOAT ),
- DEFINE_FIELD( flLocalQWeight, FIELD_FLOAT ),
- DEFINE_FIELD( flags, FIELD_INTEGER ),
- DEFINE_ARRAY( unused, FIELD_INTEGER, 4 ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudiobodyparts_t )
- DEFINE_INDEX( sznameindex, FIELD_INTEGER ),
- DEFINE_FIELD( nummodels, FIELD_INTEGER ),
- DEFINE_FIELD( base, FIELD_INTEGER ),
- DEFINE_INDEX( modelindex, FIELD_INTEGER ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudiomodel_t )
- DEFINE_ARRAY( name, FIELD_CHARACTER, 64 ),
- DEFINE_FIELD( type, FIELD_INTEGER ),
- DEFINE_FIELD( boundingradius, FIELD_FLOAT ),
- DEFINE_FIELD( nummeshes, FIELD_INTEGER ),
- DEFINE_INDEX( meshindex, FIELD_INTEGER ),
- DEFINE_FIELD( numvertices, FIELD_INTEGER ),
- DEFINE_INDEX( vertexindex, FIELD_INTEGER ),
- DEFINE_INDEX( tangentsindex, FIELD_INTEGER ),
- DEFINE_FIELD( numattachments, FIELD_INTEGER ),
- DEFINE_INDEX( attachmentindex, FIELD_INTEGER ),
- DEFINE_FIELD( numeyeballs, FIELD_INTEGER ),
- DEFINE_INDEX( eyeballindex, FIELD_INTEGER ),
- DEFINE_EMBEDDED( vertexdata ),
- DEFINE_ARRAY( unused, FIELD_INTEGER, 8 ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudio_modelvertexdata_t )
- DEFINE_FIELD( pVertexData, FIELD_INTEGER ), // void*
- DEFINE_FIELD( pTangentData, FIELD_INTEGER ), // void*
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudioflexdesc_t )
- DEFINE_INDEX( szFACSindex, FIELD_INTEGER ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudioflexcontroller_t )
- DEFINE_INDEX( sztypeindex, FIELD_INTEGER ),
- DEFINE_INDEX( sznameindex, FIELD_INTEGER ),
- DEFINE_FIELD( localToGlobal, FIELD_INTEGER ),
- DEFINE_FIELD( min, FIELD_FLOAT ),
- DEFINE_FIELD( max, FIELD_FLOAT ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudioflexcontrollerui_t )
- DEFINE_INDEX( sznameindex, FIELD_INTEGER ),
- DEFINE_INDEX( szindex0, FIELD_INTEGER ),
- DEFINE_INDEX( szindex1, FIELD_INTEGER ),
- DEFINE_INDEX( szindex2, FIELD_INTEGER ),
- DEFINE_FIELD( remaptype, FIELD_CHARACTER ),
- DEFINE_FIELD( stereo, FIELD_BOOLEAN ),
- DEFINE_ARRAY( unused, FIELD_CHARACTER, 2 ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudioflexrule_t )
- DEFINE_FIELD( flex, FIELD_INTEGER ),
- DEFINE_FIELD( numops, FIELD_INTEGER ),
- DEFINE_INDEX( opindex, FIELD_INTEGER ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudioflexop_t )
- DEFINE_FIELD( op, FIELD_INTEGER ),
- DEFINE_FIELD( d, FIELD_INTEGER ), // int/float union
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudioikchain_t )
- DEFINE_INDEX( sznameindex, FIELD_INTEGER ),
- DEFINE_FIELD( linktype, FIELD_INTEGER ),
- DEFINE_FIELD( numlinks, FIELD_INTEGER ),
- DEFINE_INDEX( linkindex, FIELD_INTEGER ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudioiklink_t )
- DEFINE_FIELD( bone, FIELD_INTEGER ),
- DEFINE_FIELD( kneeDir, FIELD_VECTOR ),
- DEFINE_FIELD( unused0, FIELD_VECTOR ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudiomouth_t )
- DEFINE_FIELD( bone, FIELD_INTEGER ),
- DEFINE_FIELD( forward, FIELD_VECTOR ),
- DEFINE_FIELD( flexdesc, FIELD_INTEGER ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudioposeparamdesc_t )
- DEFINE_INDEX( sznameindex, FIELD_INTEGER ),
- DEFINE_FIELD( flags, FIELD_INTEGER ),
- DEFINE_FIELD( start, FIELD_FLOAT ),
- DEFINE_FIELD( end, FIELD_FLOAT ),
- DEFINE_FIELD( loop, FIELD_FLOAT ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudiomesh_t )
- DEFINE_FIELD( material, FIELD_INTEGER ),
- DEFINE_INDEX( modelindex, FIELD_INTEGER ),
- DEFINE_FIELD( numvertices, FIELD_INTEGER ),
- DEFINE_FIELD( vertexoffset, FIELD_INTEGER ),
- DEFINE_FIELD( numflexes, FIELD_INTEGER ),
- DEFINE_INDEX( flexindex, FIELD_INTEGER ),
- DEFINE_FIELD( materialtype, FIELD_INTEGER ),
- DEFINE_FIELD( materialparam, FIELD_INTEGER ),
- DEFINE_FIELD( meshid, FIELD_INTEGER ),
- DEFINE_FIELD( center, FIELD_VECTOR ),
- DEFINE_EMBEDDED( vertexdata ),
- DEFINE_ARRAY( unused, FIELD_INTEGER, 8 ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudio_meshvertexdata_t )
- DEFINE_FIELD( modelvertexdata, FIELD_INTEGER ), // mstudio_modelvertexdata_t*
- DEFINE_ARRAY( numLODVertexes, FIELD_INTEGER, MAX_NUM_LODS ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudioeyeball_t )
- DEFINE_INDEX( sznameindex, FIELD_INTEGER ),
- DEFINE_FIELD( bone, FIELD_INTEGER ),
- DEFINE_FIELD( org, FIELD_VECTOR ),
- DEFINE_FIELD( zoffset, FIELD_FLOAT ),
- DEFINE_FIELD( radius, FIELD_FLOAT ),
- DEFINE_FIELD( up, FIELD_VECTOR ),
- DEFINE_FIELD( forward, FIELD_VECTOR ),
- DEFINE_FIELD( texture, FIELD_INTEGER ),
- DEFINE_FIELD( unused1, FIELD_INTEGER ),
- DEFINE_FIELD( iris_scale, FIELD_FLOAT ),
- DEFINE_FIELD( unused2, FIELD_INTEGER ),
- DEFINE_ARRAY( upperflexdesc, FIELD_INTEGER, 3 ),
- DEFINE_ARRAY( lowerflexdesc, FIELD_INTEGER, 3 ),
- DEFINE_ARRAY( uppertarget, FIELD_FLOAT, 3 ),
- DEFINE_ARRAY( lowertarget, FIELD_FLOAT, 3 ),
- DEFINE_FIELD( upperlidflexdesc, FIELD_INTEGER ),
- DEFINE_FIELD( lowerlidflexdesc, FIELD_INTEGER ),
- DEFINE_ARRAY( unused, FIELD_INTEGER, 4 ),
- DEFINE_FIELD( m_bNonFACS, FIELD_BOOLEAN ),
- DEFINE_ARRAY( unused3, FIELD_CHARACTER, 3 ),
- DEFINE_ARRAY( unused4, FIELD_INTEGER, 7 ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudioflex_t )
- DEFINE_FIELD( flexdesc, FIELD_INTEGER ),
- DEFINE_FIELD( target0, FIELD_FLOAT ),
- DEFINE_FIELD( target1, FIELD_FLOAT ),
- DEFINE_FIELD( target2, FIELD_FLOAT ),
- DEFINE_FIELD( target3, FIELD_FLOAT ),
- DEFINE_FIELD( numverts, FIELD_INTEGER ),
- DEFINE_INDEX( vertindex, FIELD_INTEGER ),
- DEFINE_FIELD( flexpair, FIELD_INTEGER ),
- DEFINE_FIELD( vertanimtype, FIELD_CHARACTER ),
- DEFINE_ARRAY( unusedchar, FIELD_CHARACTER, 3 ),
- DEFINE_ARRAY( unused, FIELD_INTEGER, 6 ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudiovertanim_t )
- DEFINE_FIELD( index, FIELD_SHORT ),
- DEFINE_FIELD( speed, FIELD_CHARACTER ),
- DEFINE_FIELD( side, FIELD_CHARACTER ),
- DEFINE_ARRAY( delta, FIELD_SHORT, 3 ), // short[3]/float16[3]union
- DEFINE_ARRAY( ndelta, FIELD_SHORT, 3 ), // short[3]/float16[3] union
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudiomodelgroup_t )
- DEFINE_INDEX( szlabelindex, FIELD_INTEGER ),
- DEFINE_INDEX( sznameindex, FIELD_INTEGER ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudioanimblock_t )
- DEFINE_INDEX( datastart, FIELD_INTEGER ),
- DEFINE_INDEX( dataend, FIELD_INTEGER ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudiotexture_t )
- DEFINE_INDEX( sznameindex, FIELD_INTEGER ),
- DEFINE_FIELD( flags, FIELD_INTEGER ),
- DEFINE_FIELD( used, FIELD_INTEGER ),
- DEFINE_FIELD( unused1, FIELD_INTEGER ),
- DEFINE_FIELD( material, FIELD_INTEGER ), // IMaterial*
- DEFINE_FIELD( clientmaterial, FIELD_INTEGER ), // void*
- DEFINE_ARRAY( unused, FIELD_INTEGER, 10 ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( vertexFileHeader_t )
- DEFINE_FIELD( id, FIELD_INTEGER ),
- DEFINE_FIELD( version, FIELD_INTEGER ),
- DEFINE_FIELD( checksum, FIELD_INTEGER ),
- DEFINE_FIELD( numLODs, FIELD_INTEGER ),
- DEFINE_ARRAY( numLODVertexes, FIELD_INTEGER, MAX_NUM_LODS ),
- DEFINE_FIELD( numFixups, FIELD_INTEGER ),
- DEFINE_FIELD( fixupTableStart, FIELD_INTEGER ),
- DEFINE_FIELD( vertexDataStart, FIELD_INTEGER ),
- DEFINE_FIELD( tangentDataStart, FIELD_INTEGER ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( vertexFileFixup_t )
- DEFINE_FIELD( lod, FIELD_INTEGER ),
- DEFINE_FIELD( sourceVertexID, FIELD_INTEGER ),
- DEFINE_FIELD( numVertexes, FIELD_INTEGER ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudioboneweight_t )
- DEFINE_ARRAY( weight, FIELD_FLOAT, MAX_NUM_BONES_PER_VERT ),
- DEFINE_ARRAY( bone, FIELD_CHARACTER, MAX_NUM_BONES_PER_VERT ),
- DEFINE_FIELD( numbones, FIELD_CHARACTER ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( mstudiovertex_t )
- DEFINE_EMBEDDED( m_BoneWeights ),
- DEFINE_FIELD( m_vecPosition, FIELD_VECTOR ),
- DEFINE_FIELD( m_vecNormal, FIELD_VECTOR ),
- DEFINE_ARRAY( m_vecTexCoord, FIELD_FLOAT, 2 ),
-END_BYTESWAP_DATADESC()
-
-// Data descriptions from OptimizedModel.h
-namespace OptimizedModel
-{
-
-BEGIN_BYTESWAP_DATADESC( BoneStateChangeHeader_t )
- DEFINE_FIELD( hardwareID, FIELD_INTEGER ),
- DEFINE_FIELD( newBoneID, FIELD_INTEGER ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( Vertex_t )
- DEFINE_ARRAY( boneWeightIndex, FIELD_CHARACTER, MAX_NUM_BONES_PER_VERT ),
- DEFINE_FIELD( numBones, FIELD_CHARACTER ),
- DEFINE_FIELD( origMeshVertID, FIELD_SHORT ),
- DEFINE_ARRAY( boneID, FIELD_CHARACTER, MAX_NUM_BONES_PER_VERT ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( StripHeader_t )
- DEFINE_FIELD( numIndices, FIELD_INTEGER ),
- DEFINE_FIELD( indexOffset, FIELD_INTEGER ),
- DEFINE_FIELD( numVerts, FIELD_INTEGER ),
- DEFINE_FIELD( vertOffset, FIELD_INTEGER ),
- DEFINE_FIELD( numBones, FIELD_SHORT ),
- DEFINE_FIELD( flags, FIELD_CHARACTER ),
- DEFINE_FIELD( numBoneStateChanges, FIELD_INTEGER ),
- DEFINE_FIELD( boneStateChangeOffset, FIELD_INTEGER ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( StripGroupHeader_t )
- DEFINE_FIELD( numVerts, FIELD_INTEGER ),
- DEFINE_FIELD( vertOffset, FIELD_INTEGER ),
- DEFINE_FIELD( numIndices, FIELD_INTEGER ),
- DEFINE_FIELD( indexOffset, FIELD_INTEGER ),
- DEFINE_FIELD( numStrips, FIELD_INTEGER ),
- DEFINE_FIELD( stripOffset, FIELD_INTEGER ),
- DEFINE_FIELD( flags, FIELD_CHARACTER ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( MeshHeader_t )
- DEFINE_FIELD( numStripGroups, FIELD_INTEGER ),
- DEFINE_FIELD( stripGroupHeaderOffset, FIELD_INTEGER ),
- DEFINE_FIELD( flags, FIELD_CHARACTER ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( ModelLODHeader_t )
- DEFINE_FIELD( numMeshes, FIELD_INTEGER ),
- DEFINE_FIELD( meshOffset, FIELD_INTEGER ),
- DEFINE_FIELD( switchPoint, FIELD_FLOAT ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( ModelHeader_t )
- DEFINE_FIELD( numLODs, FIELD_INTEGER ),
- DEFINE_FIELD( lodOffset, FIELD_INTEGER ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( BodyPartHeader_t )
- DEFINE_FIELD( numModels, FIELD_INTEGER ),
- DEFINE_FIELD( modelOffset, FIELD_INTEGER ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( MaterialReplacementHeader_t )
- DEFINE_FIELD( materialID, FIELD_SHORT ),
- DEFINE_FIELD( replacementMaterialNameOffset, FIELD_INTEGER ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( MaterialReplacementListHeader_t )
- DEFINE_FIELD( numReplacements, FIELD_INTEGER ),
- DEFINE_FIELD( replacementOffset, FIELD_INTEGER ),
-END_BYTESWAP_DATADESC()
-
-BEGIN_BYTESWAP_DATADESC( FileHeader_t )
- DEFINE_FIELD( version, FIELD_INTEGER ),
- DEFINE_FIELD( vertCacheSize, FIELD_INTEGER ),
- DEFINE_FIELD( maxBonesPerStrip, FIELD_SHORT ),
- DEFINE_FIELD( maxBonesPerTri, FIELD_SHORT ),
- DEFINE_FIELD( maxBonesPerVert, FIELD_INTEGER ),
- DEFINE_FIELD( checkSum, FIELD_INTEGER ),
- DEFINE_FIELD( numLODs, FIELD_INTEGER ),
- DEFINE_FIELD( materialReplacementListOffset, FIELD_INTEGER ),
- DEFINE_FIELD( numBodyParts, FIELD_INTEGER ),
- DEFINE_FIELD( bodyPartOffset, FIELD_INTEGER ),
-END_BYTESWAP_DATADESC()
-
-} // namespace OptimizedModel
-
-// Data descriptions from phyfile.h
-BEGIN_BYTESWAP_DATADESC( phyheader_t )
- DEFINE_FIELD( size, FIELD_INTEGER ),
- DEFINE_FIELD( id, FIELD_INTEGER ),
- DEFINE_FIELD( solidCount, FIELD_INTEGER ),
- DEFINE_FIELD( checkSum, FIELD_INTEGER ),
-END_BYTESWAP_DATADESC()
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Swaps the bytes in all file types generated by studiomdl +// (.vvd, .vtx, .mdl, .phy, .ani) so the files can be loaded +// on a big-endian machine, specifically the Xbox360. A new file is generated +// with an extra extension in the form of <filename>.360.<ext> +// +//=============================================================================// + +#include "studio.h" +#include "optimize.h" +#include "phyfile.h" +#include "studiobyteswap.h" +#include "vphysics_interface.h" + +#undef ALIGN4 +#undef ALIGN16 +#undef ALIGN32 +#define ALIGN4( a ) a = (byte *)((int)((byte *)a + 3) & ~ 3) +#define ALIGN16( a ) a = (byte *)((int)((byte *)a + 15) & ~ 15) +#define ALIGN32( a ) a = (byte *)((int)((byte *)a + 31) & ~ 31) +#define ALIGN64( a ) a = (byte *)((int)((byte *)a + 63) & ~ 63) + +// Fixup macros create variables that may not be referenced +#pragma warning( push ) +#pragma warning( disable:4189 ) // local variable is initialized but not referenced +#pragma warning( disable:4366 ) // The result of the unary '&' operator may be unaligned + +namespace StudioByteSwap +{ + +static bool g_bVerbose = true; +static bool g_bNativeSrc; +static CByteswap g_Swap; +static IPhysicsCollision *pCollision; +static CompressFunc_t g_pCompressFunc; + +void ActivateByteSwapping( bool activate ) +{ + g_Swap.ActivateByteSwapping( activate ); + SourceIsNative( IsPC() ); +} + +void SourceIsNative( bool bNative ) +{ + g_bNativeSrc = bNative; +} + +void SetCollisionInterface( IPhysicsCollision *pPhysicsCollision ) +{ + pCollision = pPhysicsCollision; +} + +void SetVerbose( bool bVerbose ) +{ + g_bVerbose = bVerbose; +} + +//---------------------------------------------------------------------- +// Helper to write a chunk of objects of the same type, and increment the buffer pointers. +//---------------------------------------------------------------------- +template<class T> inline void WriteObjects( byte **pOutputBuffer, byte **pBaseData, int objectCount = 1 ) +{ + T tempObject; + for ( int i = 0; i < objectCount; ++i ) + { + Q_memcpy( &tempObject, *pBaseData, sizeof(T) ); + g_Swap.SwapFieldsToTargetEndian( &tempObject, &tempObject ); + Q_memcpy( *pOutputBuffer, &tempObject, sizeof(T) ); + *pOutputBuffer += sizeof(T); + *pBaseData += sizeof(T); + } +} + +//---------------------------------------------------------------------- +// Helper to write a chunk of objects of the same type, and increment the buffer pointers. +//---------------------------------------------------------------------- +template<class T> inline void WriteObjects( T **pOutputBuffer, T **pBaseData, int objectCount = 1 ) +{ + T tempObject; + for ( int i = 0; i < objectCount; ++i ) + { + Q_memcpy( &tempObject, *pBaseData, sizeof(T) ); + g_Swap.SwapFieldsToTargetEndian( &tempObject, &tempObject ); + Q_memcpy( *pOutputBuffer, &tempObject, sizeof(T) ); + ++*pOutputBuffer; + ++*pBaseData; + } +} + +//---------------------------------------------------------------------- +// Helper to write a chunk of objects of the same type. +//---------------------------------------------------------------------- +template<class T> inline void WriteObjects( byte *pOutputBuffer, byte *pBaseData, int objectCount = 1 ) +{ + T tempObject; + for ( int i = 0; i < objectCount; ++i ) + { + Q_memcpy( &tempObject, pBaseData, sizeof(T) ); + g_Swap.SwapFieldsToTargetEndian( &tempObject, &tempObject ); + Q_memcpy( pOutputBuffer, &tempObject, sizeof(T) ); + pOutputBuffer += sizeof(T); + pBaseData += sizeof(T); + } +} + +//---------------------------------------------------------------------- +// Helper to write a chunk of objects of the same type. +//---------------------------------------------------------------------- +template<class T> inline void WriteObjects( T *pOutputBuffer, T *pBaseData, int objectCount = 1 ) +{ + T tempObject; + for ( int i = 0; i < objectCount; ++i ) + { + Q_memcpy( &tempObject, pBaseData, sizeof(T) ); + g_Swap.SwapFieldsToTargetEndian( &tempObject, &tempObject ); + Q_memcpy( pOutputBuffer, &tempObject, sizeof(T) ); + ++pOutputBuffer; + ++pBaseData; + } +} + +//---------------------------------------------------------------------- +// Helper to write a buffer of some integral type, and increment the buffer pointers. +//---------------------------------------------------------------------- +template<class T> inline void WriteBuffer( byte **pOutputBuffer, byte **pBaseData, int objectCount = 1 ) +{ + T tempObject; + for ( int i = 0; i < objectCount; ++i ) + { + Q_memcpy( &tempObject, *pBaseData, sizeof(T) ); + g_Swap.SwapBufferToTargetEndian( &tempObject, &tempObject ); + Q_memcpy( *pOutputBuffer, &tempObject, sizeof(T) ); + *pOutputBuffer += sizeof(T); + *pBaseData += sizeof(T); + } +} + +//---------------------------------------------------------------------- +// Helper to write a buffer of some integral type +//---------------------------------------------------------------------- +template<class T> inline void WriteBuffer( byte *pOutputBuffer, byte *pBaseData, int objectCount = 1 ) +{ + T tempObject; + for ( int i = 0; i < objectCount; ++i ) + { + Q_memcpy( &tempObject, pBaseData, sizeof(T) ); + g_Swap.SwapBufferToTargetEndian( &tempObject, &tempObject ); + Q_memcpy( pOutputBuffer, &tempObject, sizeof(T) ); + pOutputBuffer += sizeof(T); + pBaseData += sizeof(T); + } +} + +//---------------------------------------------------------------------- +// For getting values in the correct source/dest endian format +//---------------------------------------------------------------------- +template< class T > +T SrcNative( T *idx ) +{ + T ret = *idx; + if ( !g_bNativeSrc ) + { + g_Swap.SwapBuffer( &ret, idx ); + } + return ret; +} + +template< class T > +T DestNative( T *idx ) +{ + T ret = *idx; + if ( g_bNativeSrc ) + { + g_Swap.SwapBuffer( &ret, idx ); + } + return ret; +} + +//---------------------------------------------------------------------- +// Declares objects pointers for src/dest buffer +//---------------------------------------------------------------------- +#define DECLARE_OBJECT_POINTERS( objPtr, base, type ) \ + type* objPtr##Src = (type*)base##Src; \ + type* objPtr##Dest = (type*)base##Dest; \ + type* objPtr = objPtr##Src; + +//---------------------------------------------------------------------- +// Declares src/dest byte pointers and sets them to some index offset in the buffers. +//---------------------------------------------------------------------- +#define DECLARE_INDEX_POINTERS( ptr, base, index ) \ + byte *ptr##Src = (byte*)base##Src + SrcNative( &base##Src->index ); \ + byte *ptr##Dest = (byte*)base##Dest + SrcNative( &base##Src->index ); + +//---------------------------------------------------------------------- +// Declares src/dest byte pointers and sets them to some index offset in the buffers. +// If src pointer is misaligned, the fixup method is called. +//---------------------------------------------------------------------- +#define DECLARE_INDEX_POINTERS_FIXUP( ptr, base, index ) \ + byte *ptr##Src = (byte*)base##Src + SrcNative( &base##Src->index ); \ + byte *ptr##Dest = (byte*)base##Dest + SrcNative( &base##Src->index ); \ + FIXUP_OFFSETS( ptr, base, index ) + +//---------------------------------------------------------------------- +// Same as DECLARE_OBJECT_POINTERS, but reuses existing type pointers. +//---------------------------------------------------------------------- +#define SET_OBJECT_POINTERS( objPtr, base, type ) \ + objPtr##Src = (type*)base##Src; \ + objPtr##Dest = (type*)base##Dest; \ + objPtr = objPtr##Src; + +//---------------------------------------------------------------------- +// Same as DECLARE_INDEX_POINTERS, but reuses existing byte pointers. +//---------------------------------------------------------------------- +#define SET_INDEX_POINTERS( ptr, base, index ) \ + ptr##Src = (byte*)base##Src + SrcNative( &base##Src->index ); \ + ptr##Dest = (byte*)base##Dest + SrcNative( &base##Src->index ); + +//---------------------------------------------------------------------- +// Same as DECLARE_INDEX_POINTERS, but reuses existing byte pointers. +// If src pointer is misaligned, the fixup method is called. +//---------------------------------------------------------------------- +#define SET_INDEX_POINTERS_FIXUP( ptr, base, index ) \ + ptr##Src = (byte*)base##Src + SrcNative( &base##Src->index ); \ + ptr##Dest = (byte*)base##Dest + SrcNative( &base##Src->index ); \ + FIXUP_OFFSETS( ptr, base, index ) + +//---------------------------------------------------------------------- +// for() loop header, updates all three object pointers (src,dest,native) +//---------------------------------------------------------------------- +#define ITERATE_BLOCK( objPtr, count ) \ + for ( int objPtr##_idx = 0; objPtr##_idx < SrcNative( &count ); ++objPtr##_idx, ++objPtr, ++objPtr##Src, ++objPtr##Dest ) + +//---------------------------------------------------------------------- +// Checks for misaligned source pointer, then calculates the necessary fixup, +// calls the fixup function, and sets the src pointer to the new position. +//---------------------------------------------------------------------- +#define FIXUP_OFFSETS( ptr, base, index ) \ + { \ + byte *ptr##Fixup = ptr##Src; \ + ALIGN4( ptr##Fixup ); \ + if ( ptr##Fixup != ptr##Src ) \ + { \ + int nShiftBytes = ptr##Fixup - ptr##Src; \ + if ( g_bVerbose ) \ + Warning( "Shifting misaligned data block by %d bytes at " #base "->" #index "\n", nShiftBytes ); \ + int prevBytes = (byte*)ptr##Src - (byte*)g_pDataSrcBase; \ + Q_memmove( (byte*)ptr##Src + nShiftBytes, ptr##Src, fixedFileSize - prevBytes ); \ + g_pFixPoint = ptr##Src; \ + g_nFixupBytes = nShiftBytes; \ + fixedFileSize += nShiftBytes; \ + if ( fixedFileSize > fileSize + BYTESWAP_ALIGNMENT_PADDING ) \ + { \ + Error( "Byteswap buffer overrun - increase BYTESWAP_ALIGNMENT_PADDING!\n" ); \ + return 0; \ + } \ + g_pfnFileProcessFunc( pHdrSrc, UpdateSrcIndexFields ); \ + g_pFixPoint = NULL; \ + g_nFixupBytes = 0; \ + ptr##Src = ptr##Fixup; \ + } \ + } + + +typedef void ( *datadescProcessFunc_t)( void *pBase, void *pData, typedescription_t *pFields ); +typedef void ( *pfnFixupFunc_t )( void *pDestBase, datadescProcessFunc_t ); + +static pfnFixupFunc_t g_pfnFileProcessFunc; +static studiohdr_t *g_pHdr; +static const void *g_pDataSrcBase; +static void *g_pFixPoint; +static int g_nFixupBytes; + +//----------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------- +bool UpdateIndex( void *pBase, int *indexMember ) +{ + bool bUpdateIndex = false; + int idx = *indexMember; + + // Update the index fields + if ( pBase < g_pFixPoint ) + { + if ( (byte*)pBase + idx >= g_pFixPoint ) + { + bUpdateIndex = true; + } + } + else + { + if ( (byte*)pBase + idx < g_pFixPoint ) + { + bUpdateIndex = true; + } + } + + // Update the member offset by the global fixup + if ( bUpdateIndex && *indexMember ) + { + *indexMember = idx + g_nFixupBytes * Sign(idx); + return true; + } + return false; +} + +//----------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------- +int GetIntegerFromField( void *pData, int fieldType ) +{ + if ( fieldType == FIELD_INTEGER ) + { + return SrcNative( (int*)pData ); + } + else if ( fieldType == FIELD_SHORT ) + { + return SrcNative( (short*)pData ); + } + Error( "Byteswap macro DEFINE_INDEX using unsupported fieldType %d\n", fieldType ); + return 0; +} + +//----------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------- +void PutIntegerInField( void *pData, int index, int fieldType ) +{ + if ( fieldType == FIELD_INTEGER ) + { + *(int*)pData = SrcNative( &index ); + } + else if ( fieldType == FIELD_SHORT ) + { + *(short*)pData = SrcNative( &index ); + } + else + { + Error( "Byteswap macro DEFINE_INDEX using unsupported fieldType %d\n", fieldType ); + } +} + +//----------------------------------------------------------------------------- +// +//----------------------------------------------------------------------------- +void UpdateSrcIndexFields( void *pBase, void *pData, typedescription_t *pField ) +{ + if ( pField->flags & FTYPEDESC_INDEX ) + { + int index = GetIntegerFromField( pData, pField->fieldType ); + if ( UpdateIndex( pBase, &index ) ) + { + PutIntegerInField( pData, index, pField->fieldType ); + } + } +} + +//----------------------------------------------------------------------------- +// Pass a datadesc field to a processing function +//----------------------------------------------------------------------------- +void ProcessField( void *pBase, void *pData, typedescription_t *pField, datadescProcessFunc_t pfn ) +{ + if ( pfn ) + { + pfn( pBase, pData, pField ); + } +} + +//----------------------------------------------------------------------------- +// Process the fields of a datadesc. +//----------------------------------------------------------------------------- +void ProcessFields( void *pBaseAddress, void *pData, datamap_t *pDataMap, datadescProcessFunc_t pfnProcessFunc ) +{ + // deal with base class first + if ( pDataMap->baseMap ) + { + ProcessFields( pBaseAddress, pData, pDataMap->baseMap, pfnProcessFunc ); + } + + typedescription_t *pFields = pDataMap->dataDesc; + int fieldCount = pDataMap->dataNumFields; + for ( int i = 0; i < fieldCount; ++i ) + { + typedescription_t *pField = &pFields[i]; + ProcessField( pBaseAddress, (BYTE*)pData + pField->fieldOffset[ TD_OFFSET_NORMAL ], pField, pfnProcessFunc ); + } +} + +//----------------------------------------------------------------------------- +// Process the fields of a datadesc. +//----------------------------------------------------------------------------- +void ProcessFields( void *pData, datamap_t *pDataMap, datadescProcessFunc_t pfnProcessFunc ) +{ + ProcessFields( pData, pData, pDataMap, pfnProcessFunc ); +} + +//----------------------------------------------------------------------------- +// Process a datadesc field by name +//----------------------------------------------------------------------------- +void ProcessFieldByName( void *pBaseAddress, void *pData, datamap_t *pDataMap, const char *pName, datadescProcessFunc_t pfnProcessFunc ) +{ + // deal with base class first + if ( pDataMap->baseMap ) + { + ProcessFieldByName( pBaseAddress, pData, pDataMap->baseMap, pName, pfnProcessFunc ); + } + + typedescription_t *pFields = pDataMap->dataDesc; + int fieldCount = pDataMap->dataNumFields; + for ( int i = 0; i < fieldCount; ++i ) + { + typedescription_t *pField = &pFields[i]; + if ( !Q_stricmp( pField->fieldName, pName ) ) + { + ProcessField( pBaseAddress, (BYTE*)pData + pField->fieldOffset[ TD_OFFSET_NORMAL ], pField, pfnProcessFunc ); + break; + } + } +} + +//----------------------------------------------------------------------------- +// Process a datadesc field by name. +//----------------------------------------------------------------------------- +void ProcessFieldByName( void *pData, datamap_t *pDataMap, const char *pName, datadescProcessFunc_t pfnProcessFunc ) +{ + ProcessFieldByName( pData, pData, pDataMap, pName, pfnProcessFunc ); +} + +void ProcessANIFields( void *pDataBase, datadescProcessFunc_t pfnProcessFunc ); +void ProcessMDLFields( void *pDataBase, datadescProcessFunc_t pfnProcessFunc ); + +// Fake header declaration for easier phy swapping +struct swapcompactsurfaceheader_t +{ + DECLARE_BYTESWAP_DATADESC(); + int size; + int vphysicsID; + short version; + short modelType; + int surfaceSize; + Vector dragAxisAreas; + int axisMapSize; +}; + +BEGIN_BYTESWAP_DATADESC( swapcompactsurfaceheader_t ) + DEFINE_FIELD( size, FIELD_INTEGER ), + DEFINE_FIELD( vphysicsID, FIELD_INTEGER ), + DEFINE_FIELD( version, FIELD_SHORT ), + DEFINE_FIELD( modelType, FIELD_SHORT ), + DEFINE_FIELD( surfaceSize, FIELD_INTEGER ), + DEFINE_FIELD( dragAxisAreas, FIELD_VECTOR ), + DEFINE_FIELD( axisMapSize, FIELD_INTEGER ), +END_BYTESWAP_DATADESC() + +// Fake header declaration for old style phy format +#if defined( _X360 ) +#pragma bitfield_order( push, lsb_to_msb ) +#endif +struct legacysurfaceheader_t +{ + DECLARE_BYTESWAP_DATADESC(); + int size; + float mass_center[3]; + float rotation_inertia[3]; + float upper_limit_radius; + BEGIN_BITFIELD( bf ) + int max_deviation : 8; + int byte_size : 24; + END_BITFIELD() + int offset_ledgetree_root; + int dummy[3]; +}; +#if defined( _X360 ) +#pragma bitfield_order( pop ) +#endif + +BEGIN_BYTESWAP_DATADESC( legacysurfaceheader_t ) + DEFINE_FIELD( size, FIELD_INTEGER ), + DEFINE_ARRAY( mass_center, FIELD_FLOAT, 3 ), + DEFINE_ARRAY( rotation_inertia, FIELD_FLOAT, 3 ), + DEFINE_FIELD( upper_limit_radius, FIELD_FLOAT ), + DEFINE_BITFIELD( bf, FIELD_INTEGER, 32 ), + DEFINE_FIELD( offset_ledgetree_root, FIELD_INTEGER ), + DEFINE_ARRAY( dummy, FIELD_INTEGER, 3 ), +END_BYTESWAP_DATADESC() + +//---------------------------------------------------------------------- +// Swap a .phy file +// Fixes alignment errors +//---------------------------------------------------------------------- +int ByteswapPHY( void *pDestBase, const void *pSrcBase, const int fileSize ) +{ + Assert( pCollision ); + if ( !pCollision ) + return 0; + + Q_memset( pDestBase, 0, fileSize ); + + byte *pSrc = (byte*)pSrcBase; + byte *pDest = (byte*)pDestBase; + vcollide_t collide = {0}; + + // file header + phyheader_t *pHdr = (phyheader_t*)( g_bNativeSrc ? pSrc : pDest ); + WriteObjects<phyheader_t>( &pDest, &pSrc ); + + if ( g_bNativeSrc ) + { + // Reset the pointers and let ivp swap the binary physics data + pSrc = (byte*)pSrcBase + pHdr->size; + pDest = (byte*)pDestBase + pHdr->size; + + int bufSize = fileSize - pHdr->size; + pCollision->VCollideLoad( &collide, pHdr->solidCount, (const char *)pSrc, bufSize, false ); + } + + // Swap the collision data headers + for ( int i = 0; i < pHdr->solidCount; ++i ) + { + swapcompactsurfaceheader_t *baseHdr = (swapcompactsurfaceheader_t*)( g_bNativeSrc ? pSrc : pDest ); + WriteObjects<swapcompactsurfaceheader_t>( pDest, pSrc ); + + int srcIncrement = baseHdr->surfaceSize + sizeof(swapcompactsurfaceheader_t); + int destIncrement = srcIncrement; + bool bCopyToSrc = !g_bNativeSrc; + + if ( baseHdr->vphysicsID != MAKEID('V','P','H','Y') ) + { + // May be old phy format + legacysurfaceheader_t *legacyHdr = (legacysurfaceheader_t*)( g_bNativeSrc ? pSrc : pDest ); + WriteObjects<legacysurfaceheader_t>( pDest, pSrc ); + if ( legacyHdr->dummy[2] == MAKEID('I','V','P','S') || legacyHdr->dummy[2] == 0 ) + { + srcIncrement = legacyHdr->byte_size + sizeof(int); + destIncrement = legacyHdr->byte_size + sizeof(swapcompactsurfaceheader_t); + bCopyToSrc = false; + + if ( !g_bNativeSrc ) + { + // src needs the size member to be native to load vcollides + Q_memcpy( pSrc, pDest, sizeof(int) ); + } + } + else + { + // Not recognized + Assert(0); + return 0; + } + } + + if ( bCopyToSrc ) + { + // src needs the native header data to load the vcollides + Q_memcpy( pSrc, pDest, sizeof(swapcompactsurfaceheader_t) ); + } + + pSrc += srcIncrement; + pDest += destIncrement; + } + + // the rest of the file is text + int currPos = pSrc - (byte*)pSrcBase; + int remainingBytes = fileSize - currPos; + WriteBuffer<char>( &pDest, &pSrc, remainingBytes ); + + if ( !g_bNativeSrc ) + { + // let ivp swap the ledge tree + pSrc = (byte*)pSrcBase + pHdr->size; + int bufSize = fileSize - pHdr->size; + pCollision->VCollideLoad( &collide, pHdr->solidCount, (const char *)pSrc, bufSize, true ); + } + + // Write out the ledge tree data + pDest = (byte*)pDestBase + pHdr->size; + for ( int i = 0; i < collide.solidCount; ++i ) + { + // skip over the size + pDest += sizeof(int); + int offset = pCollision->CollideWrite( (char*)pDest, collide.solids[i], g_bNativeSrc ); + int destSize = g_bNativeSrc ? SwapLong( offset ) : offset; + Q_memcpy( pDest - sizeof(int), &destSize, sizeof(int) ); + pDest += offset; + } + + // Free the memory + pCollision->VCollideUnload( &collide ); + + int newFileSize = pDest - (byte*)pDestBase + remainingBytes; + + if ( g_pCompressFunc ) + { + // compress entire swapped PHY + void *pInput = pDestBase; + int inputSize = newFileSize; + void *pOutput; + int outputSize; + if ( g_pCompressFunc( pInput, inputSize, &pOutput, &outputSize ) ) + { + // put the compressed version in its place + V_memcpy( pDestBase, pOutput, outputSize ); + free( pOutput ); + newFileSize = outputSize; + } + } + + return newFileSize; +} + +//---------------------------------------------------------------------- +// Swap a .vvd file +// Doesn't do any alignment fixups +//---------------------------------------------------------------------- +int ByteswapVVD( void *pDestBase, const void *pSrcBase, const int fileSize ) +{ + Q_memset( pDestBase, 0, fileSize ); + + byte *pDataSrc = (byte*)pSrcBase; + byte *pDataDest = (byte*)pDestBase; + + /** FILE HEADER **/ + + DECLARE_OBJECT_POINTERS( pHdr, pData, vertexFileHeader_t ) + WriteObjects<vertexFileHeader_t>( &pDataDest, &pDataSrc ); + + /** FIXUP TABLE **/ + + SET_INDEX_POINTERS( pData, pHdr, fixupTableStart ) + WriteObjects<vertexFileFixup_t>( &pDataDest, &pDataSrc, SrcNative( &pHdr->numFixups ) ); + + /** VERTEX DATA **/ + + SET_INDEX_POINTERS( pData, pHdr, vertexDataStart ) + WriteObjects<mstudiovertex_t>( &pDataDest, &pDataSrc, SrcNative( &pHdr->numLODVertexes[0] ) ); + + /** TANGENT DATA **/ + + if ( pHdr->tangentDataStart != 0 ) + { + SET_INDEX_POINTERS( pData, pHdr, tangentDataStart ) + WriteBuffer<float>( &pDataDest, &pDataSrc, 4 * SrcNative( &pHdr->numLODVertexes[0] ) ); + } + + int newFileSize = pDataDest - (byte*)pDestBase; + + if ( g_pCompressFunc ) + { + void *pInput = (byte*)pDestBase + sizeof( vertexFileHeader_t ); + int inputSize = newFileSize - sizeof( vertexFileHeader_t ); + void *pOutput; + int outputSize; + if ( g_pCompressFunc( pInput, inputSize, &pOutput, &outputSize ) ) + { + // place the compressed data after the header + V_memcpy( pInput, pOutput, outputSize ); + free( pOutput ); + newFileSize = sizeof( vertexFileHeader_t ) + outputSize; + } + } + + return newFileSize; +} + + +//---------------------------------------------------------------------- +// Swap a .vtx file +// Doesn't do any alignment fixups +//---------------------------------------------------------------------- +int ByteswapVTX( void *pDestBase, const void *pSrcBase, const int fileSize ) +{ + Q_memset( pDestBase, 0, fileSize ); + + // Do a straight copy first so the string table is transferred + memcpy( pDestBase, pSrcBase, fileSize ); + + // Start writing the file + byte *pDataSrc = (byte*)pSrcBase; + byte *pDataDest = (byte*)pDestBase; + + DECLARE_OBJECT_POINTERS( pVtxHeader, pData, OptimizedModel::FileHeader_t ) + WriteObjects( pVtxHeaderDest, pVtxHeaderSrc ); + + /** BODY PARTS **/ + + SET_INDEX_POINTERS( pData, pVtxHeader, bodyPartOffset ) + DECLARE_OBJECT_POINTERS( pBodyPartHeader, pData, OptimizedModel::BodyPartHeader_t ) + ITERATE_BLOCK( pBodyPartHeader, pVtxHeader->numBodyParts ) + { + WriteObjects( pBodyPartHeaderDest, pBodyPartHeaderSrc ); + + /** MODELS **/ + + SET_INDEX_POINTERS( pData, pBodyPartHeader, modelOffset ) + DECLARE_OBJECT_POINTERS( pModelHeader, pData, OptimizedModel::ModelHeader_t ) + ITERATE_BLOCK( pModelHeader, pBodyPartHeader->numModels ) + { + WriteObjects( pModelHeaderDest, pModelHeaderSrc ); + + /** MODEL LODS **/ + + unsigned int meshOffset = 0; + SET_INDEX_POINTERS( pData, pModelHeader, lodOffset ) + DECLARE_OBJECT_POINTERS( pModelLODHeader, pData, OptimizedModel::ModelLODHeader_t ) + ITERATE_BLOCK( pModelLODHeader, pModelHeader->numLODs ) + { + WriteObjects( pModelLODHeaderDest, pModelLODHeaderSrc ); + + /** MESHES **/ + + unsigned int prevOffset = meshOffset; + meshOffset = SrcNative( &pModelLODHeader->meshOffset ); + if ( prevOffset - sizeof(OptimizedModel::ModelLODHeader_t) == meshOffset ) + { + // This LOD shares data with the previous LOD - don't reswap. + continue; + } + + SET_INDEX_POINTERS( pData, pModelLODHeader, meshOffset ) + DECLARE_OBJECT_POINTERS( pMeshHeader, pData, OptimizedModel::MeshHeader_t ) + ITERATE_BLOCK( pMeshHeader, pModelLODHeader->numMeshes ) + { + WriteObjects( pMeshHeaderDest, pMeshHeaderSrc ); + + /** STRIP GROUPS **/ + + SET_INDEX_POINTERS( pData, pMeshHeader, stripGroupHeaderOffset ) + DECLARE_OBJECT_POINTERS( pStripGroupHeader, pData, OptimizedModel::StripGroupHeader_t ) + ITERATE_BLOCK( pStripGroupHeader, pMeshHeader->numStripGroups ) + { + WriteObjects( pStripGroupHeaderDest, pStripGroupHeaderSrc ); + + /** STRIP VERTS **/ + + SET_INDEX_POINTERS( pData, pStripGroupHeader, vertOffset ) + WriteObjects<OptimizedModel::Vertex_t>( pDataDest, pDataSrc, SrcNative( &pStripGroupHeader->numVerts ) ); + + /** VERT INDICES **/ + + SET_INDEX_POINTERS( pData, pStripGroupHeader, indexOffset ) + WriteBuffer<short>( pDataDest, pDataSrc, SrcNative( &pStripGroupHeader->numIndices ) ); + + /** STRIPS **/ + + SET_INDEX_POINTERS( pData, pStripGroupHeader, stripOffset ) + DECLARE_OBJECT_POINTERS( pStripHeader, pData, OptimizedModel::StripHeader_t ) + ITERATE_BLOCK( pStripHeader, pStripGroupHeader->numStrips ) + { + WriteObjects( pStripHeaderDest, pStripHeaderSrc ); + + /** BONE STATE CHANGES **/ + + SET_INDEX_POINTERS( pData, pStripHeader, boneStateChangeOffset ) + WriteObjects<OptimizedModel::BoneStateChangeHeader_t>( pDataDest, pDataSrc, SrcNative( &pStripHeader->numBoneStateChanges ) ); + } + } + } + } + } + } + + /** MATERIAL REPLACEMENT HEADERS **/ + + SET_INDEX_POINTERS( pData, pVtxHeader, materialReplacementListOffset ) + DECLARE_OBJECT_POINTERS( pMatRepListHeader, pData, OptimizedModel::MaterialReplacementListHeader_t ) + ITERATE_BLOCK( pMatRepListHeader, pVtxHeader->numLODs ) + { + WriteObjects( pMatRepListHeaderDest, pMatRepListHeaderSrc ); + + /** MATERIAL REPLACEMENTS **/ + + SET_INDEX_POINTERS( pData, pMatRepListHeader, replacementOffset ) + WriteObjects<OptimizedModel::MaterialReplacementHeader_t>( &pDataDest, &pDataSrc, SrcNative( &pMatRepListHeader->numReplacements ) ); + } + + int newFileSize = fileSize; + + if ( g_pCompressFunc ) + { + void *pInput = (byte*)pDestBase + sizeof( OptimizedModel::FileHeader_t ); + int inputSize = fileSize - sizeof( OptimizedModel::FileHeader_t ); + void *pOutput; + int outputSize; + if ( g_pCompressFunc( pInput, inputSize, &pOutput, &outputSize ) ) + { + // place the compressed data after the header + V_memcpy( pInput, pOutput, outputSize ); + free( pOutput ); + newFileSize = sizeof( OptimizedModel::FileHeader_t ) + outputSize; + } + } + + return newFileSize; +} + +//---------------------------------------------------------------------- +// Swap animation data +// Fixes alignment errors +//---------------------------------------------------------------------- + +void ByteswapAnimData( mstudioanimdesc_t *pAnimDesc, int section, byte *&pDataSrc, byte *&pDataDest ) +{ + /** ANIMATIONS **/ + DECLARE_OBJECT_POINTERS( pAnimation, pData, mstudioanim_t ) + WriteObjects( pAnimationDest, pAnimationSrc ); + if ( pAnimation->bone == 255 ) + { + // No animation data + pAnimation = 0; + } + + while( pAnimation ) + { + if ( pAnimation->flags & ( STUDIO_ANIM_RAWROT | STUDIO_ANIM_RAWPOS | STUDIO_ANIM_RAWROT2 ) ) + { + if ( pAnimation->flags & STUDIO_ANIM_RAWROT ) + { + int offset = (byte*)pAnimation->pQuat48() - (byte*)pAnimation; + pDataSrc = (byte*)pAnimationSrc + offset; + pDataDest = (byte*)pAnimationDest + offset; + + // Write the quaternion (bit fields contained in 3 unsigned shorts) + WriteBuffer<short>( &pDataDest, &pDataSrc, 3 ); + } + + if ( pAnimation->flags & STUDIO_ANIM_RAWROT2 ) + { + int offset = (byte*)pAnimation->pQuat64() - (byte*)pAnimation; + pDataSrc = (byte*)pAnimationSrc + offset; + pDataDest = (byte*)pAnimationDest + offset; + + // Write the quaternion (bit fields contained in 1 64 bit int + WriteBuffer<int64>( &pDataDest, &pDataSrc, 1 ); + } + + if ( pAnimation->flags & STUDIO_ANIM_RAWPOS ) + { + int offset = (byte*)pAnimation->pPos() - (byte*)pAnimation; + pDataSrc = (byte*)pAnimationSrc + offset; + pDataDest = (byte*)pAnimationDest + offset; + + // Write the vector (3 float16) + WriteBuffer<short>( &pDataDest, &pDataSrc, 3 ); + } + } + else + { + int offset = (byte*)pAnimation->pRotV() - (byte*)pAnimation; + pDataSrc = (byte*)pAnimationSrc + offset; + pDataDest = (byte*)pAnimationDest + offset; + + mstudioanim_valueptr_t *rotvptr = (mstudioanim_valueptr_t*)pDataSrc; + WriteObjects<mstudioanim_valueptr_t>( &pDataDest, &pDataSrc ); + + int animValueCt = 0; + for ( int idx = 0; idx < 3; ++idx ) + { + animValueCt += rotvptr->offset[idx] ? 1 : 0; + } + + if ( pAnimation->flags & STUDIO_ANIM_ANIMPOS ) + { + int offset = (byte*)pAnimation->pPosV() - (byte*)pAnimation; + pDataSrc = (byte*)pAnimationSrc + offset; + pDataDest = (byte*)pAnimationDest + offset; + + mstudioanim_valueptr_t *posvptr = (mstudioanim_valueptr_t*)pDataSrc; + WriteObjects<mstudioanim_valueptr_t>( &pDataDest, &pDataSrc ); + + for ( int idx = 0; idx < 3; ++idx ) + { + animValueCt += posvptr->offset[idx] ? 1 : 0; + } + } + + // Write position and rotation animations + + // Note: destanimvalue_t is a union that can be either two bytes or a short. + // This structure is used to compress animation data using RLE. + // The first object of a chunk acts as the header, and uses the two bytes to + // store how many objects follow, and how many frames are encoded by them. + // The objects that follow use the short to store a value. + // The total number of chunks has been determined by counting the number of valid (non-zero) offsets. + for ( int animValue = 0; animValue < animValueCt; ++animValue ) + { + int encodedFrames = 0; + int totalFrames = SrcNative( &pAnimDesc->numframes ); + int sectionFrames = SrcNative( &pAnimDesc->sectionframes ); + if ( sectionFrames ) + { + int iStartFrame = section * sectionFrames; + int iEndFrame = (section + 1) * sectionFrames; + + iStartFrame = min( iStartFrame, totalFrames - 1 ); + iEndFrame = min( iEndFrame, totalFrames - 1 ); + + totalFrames = iEndFrame - iStartFrame + 1; + } + + while ( encodedFrames < totalFrames ) + { + // Write the first animation value (struct of 2 bytes) + mstudioanimvalue_t *pDestAnimvalue = (mstudioanimvalue_t*)( g_bNativeSrc ? pDataSrc : pDataDest ); + WriteBuffer<char>( &pDataDest, &pDataSrc, 2 ); + + // Write the remaining animation values from this group (shorts) + WriteBuffer<short>( &pDataDest, &pDataSrc, pDestAnimvalue->num.valid ); + + encodedFrames += pDestAnimvalue->num.total; + } + } + } + + // TODOKD: Could add a fixup here with some more work, hasn't been necessary yet + if ( pAnimation->nextoffset ) + { + // Set pointers to the next animation + pAnimationSrc = (mstudioanim_t*)( (byte*)pAnimationSrc + SrcNative( &pAnimation->nextoffset ) ); + pAnimationDest = (mstudioanim_t*)( (byte*)pAnimationDest + SrcNative( &pAnimation->nextoffset ) ); + pAnimation = pAnimationSrc; + + // Swap the next animation + WriteObjects( pAnimationDest, pAnimationSrc ); + } + else + { + pAnimation = 0; + pDataSrc += sizeof( mstudioanim_t ); + pDataDest += sizeof( mstudioanim_t ); + } + } + + ALIGN4( pDataSrc ); + ALIGN4( pDataDest ); +} + + +int ByteswapIKRules( studiohdr_t *&pHdrSrc, int numikrules, int numFrames, byte *&pDataSrc, byte *&pDataDest, int &fixedFileSize, const int fileSize ) +{ + DECLARE_OBJECT_POINTERS( pIKRule, pData, mstudioikrule_t ) + + ITERATE_BLOCK( pIKRule, numikrules ) + { + WriteObjects<mstudioikrule_t>( pIKRuleDest, pIKRuleSrc ); + + /** IK ERROR KEYS **/ + + // Calculate the number of ikerrors by converting the ikerror start and end float values to + // frame numbers. (See the generation of these values in simplify.cpp: ProcessIKRules()). + float start = floorf( SrcNative( &pIKRule->start ) * (numFrames - 1) + 0.5f ); + float end = floorf( SrcNative( &pIKRule->end ) * (numFrames - 1) + 0.5f ); + int totalerror = (int)( end - start + 1 ); + if ( end >= numFrames ) + totalerror += 2; + + // Uncompressed - only found in some older models (shipped hl2) + if ( pIKRule->ikerrorindex ) + { + SET_INDEX_POINTERS_FIXUP( pData, pIKRule, ikerrorindex ) + WriteObjects<mstudioikerror_t>( pDataDest, pDataSrc, totalerror ); + } + + // Compressed - all models since hl2 + if ( pIKRule->compressedikerrorindex ) + { + SET_INDEX_POINTERS_FIXUP( pData, pIKRule, compressedikerrorindex ) + WriteObjects<mstudiocompressedikerror_t>( pDataDest, pDataSrc ); + + mstudiocompressedikerror_t *pCompressed = (mstudiocompressedikerror_t *)pDataSrc; + + // Write the animvalues. + for ( int idx = 0; idx < 6; ++idx ) + { + if ( pCompressed->offset[idx] ) + { + byte *pAnimvalueSrc = pDataSrc + SrcNative( &pCompressed->offset[idx] ); + byte *pAnimvalueDest = pDataDest + SrcNative( &pCompressed->offset[idx] ); + + int numerror = 0; + while ( numerror < totalerror ) + { + // Write the first animation value (struct of 2 bytes) + mstudioanimvalue_t *pDestAnimvalue = (mstudioanimvalue_t*)( g_bNativeSrc ? pAnimvalueSrc : pAnimvalueDest ); + WriteBuffer<char>( &pAnimvalueDest, &pAnimvalueSrc, 2 ); + + // Write the remaining animation values from this group (shorts) + WriteBuffer<short>( &pAnimvalueDest, &pAnimvalueSrc, pDestAnimvalue->num.valid ); + + numerror += pDestAnimvalue->num.total; + } + } + } + + if ( pIKRule->szattachmentindex ) + { + SET_INDEX_POINTERS( pData, pIKRule, szattachmentindex ) + int size = strlen( (char*)pDataSrc ) + 1; + WriteBuffer<char>( pDataDest, pDataSrc, size ); + } + } + } + return fixedFileSize; +} + + + +//---------------------------------------------------------------------- +// Swap an .ani file +// Fixes alignment errors +//---------------------------------------------------------------------- +int ByteswapANIFile( studiohdr_t* pHdr, void *pDestBase, const void *pSrcBase, const int fileSize ) +{ + // Note, pHdr came from a native .mdl - + // so the header, animdescs and animblocks are already in native format. + Assert( pHdr ); + if ( !pHdr ) + return false; + + Q_memset( pDestBase, 0, fileSize ); + + // swap file header + { + byte *pHeaderSrc = (byte *)pSrcBase; + byte *pHeaderDest = (byte *)pDestBase; + DECLARE_OBJECT_POINTERS( pAniHeader, pHeader, studiohdr_t ) + WriteObjects( pAniHeaderDest, pAniHeaderSrc ); + } + + // for fixup functions + int fixedFileSize = fileSize; + g_pfnFileProcessFunc = ProcessANIFields; + g_pDataSrcBase = pSrcBase; + g_pHdr = pHdr; + studiohdr_t *pHdrSrc = pHdr; + + // The animdesc_t header is always contained in the mdl file, but its data may be in + // the mdl or the ani. When the data is contained in the mdl, the animdesc index fields + // represent offsets from the location of the animdesc header. When the data is in the ani, + // the index fields contain offsets from the start of the animblock in which the animdesc data is contained. + + mstudioanimdesc_t *pAnimDesc = pHdr->pLocalAnimdesc( 0 ); + for ( int i = 0; i < pHdr->numlocalanim; ++i, ++pAnimDesc ) + { + // printf("anim %d : %d : %d\n", i, pAnimDesc->animblock, pAnimDesc->sectionframes ); + if ( pAnimDesc->animblock == -1) + { + // out of date model format + continue; + } + + if ( pAnimDesc->animblock == 0 && pAnimDesc->sectionframes == 0) + { + // already saved out + continue; + } + + if ( pAnimDesc->sectionframes == 0 ) + { + mstudioanimblock_t *pAnimBlock = pHdr->pAnimBlock( pAnimDesc->animblock ); + + // printf("block %d : start %d + %d\n", pAnimDesc->animblock, pAnimBlock->datastart, pAnimDesc->animindex ); + // Base address of the animblock + byte *pBlockBaseSrc = (byte*)pSrcBase + pAnimBlock->datastart; + byte *pBlockBaseDest = (byte*)pDestBase + pAnimBlock->datastart; + + // Base address of the animation in the animblock + byte *pDataSrc = pBlockBaseSrc + pAnimDesc->animindex; + byte *pDataDest = pBlockBaseDest + pAnimDesc->animindex; + + ByteswapAnimData( pAnimDesc, 0, pDataSrc, pDataDest ); + } + else + { + int numsections = pAnimDesc->numframes / pAnimDesc->sectionframes + 2; + + for ( int i = 0; i < numsections; ++i ) + { + int block = pAnimDesc->pSection( i )->animblock; + int index = pAnimDesc->pSection( i )->animindex; + + if ( block != 0 ) + { + // printf("%s %d %d\n", pAnimDesc->pszName(), block, index ); + + mstudioanimblock_t *pAnimBlock = pHdr->pAnimBlock( block ); + + // Base address of the animblock + byte *pBlockBaseSrc = (byte*)pSrcBase + pAnimBlock->datastart; + byte *pBlockBaseDest = (byte*)pDestBase + pAnimBlock->datastart; + FIXUP_OFFSETS( pBlockBase, pAnimBlock, datastart ) + + // Base address of the animation in the animblock + byte *pDataSrc = pBlockBaseSrc + index; + byte *pDataDest = pBlockBaseDest + index; + + ByteswapAnimData( pAnimDesc, i, pDataSrc, pDataDest ); + } + } + } + + if ( pAnimDesc->animblock == 0) + { + // already saved out + continue; + } + + mstudioanimblock_t *pAnimBlock = pHdr->pAnimBlock( pAnimDesc->animblock ); + // Base address of the animblock + byte *pBlockBaseSrc = (byte*)pSrcBase + pAnimBlock->datastart; + byte *pBlockBaseDest = (byte*)pDestBase + pAnimBlock->datastart; + FIXUP_OFFSETS( pBlockBase, pAnimBlock, datastart ) + + // Base address of the animation in the animblock + byte *pDataSrc = pBlockBaseSrc + pAnimDesc->animindex; + byte *pDataDest = pBlockBaseDest + pAnimDesc->animindex; + FIXUP_OFFSETS( pData, pAnimDesc, animindex ) + + /** IK RULES **/ + + if ( pAnimDesc->animblockikruleindex ) + { + pDataSrc = (byte*)pBlockBaseSrc + pAnimDesc->animblockikruleindex; + pDataDest = (byte*)pBlockBaseDest + pAnimDesc->animblockikruleindex; + FIXUP_OFFSETS( pData, pAnimDesc, animblockikruleindex ) + + int numikrules = SrcNative( &pAnimDesc->numikrules ); + ByteswapIKRules( pHdrSrc, pAnimDesc->numikrules, pAnimDesc->numframes, pDataSrc, pDataDest, fixedFileSize, fileSize ); + } + + /** LOCAL HIERARCHY **/ + + if ( pAnimDesc->localhierarchyindex ) + { + pDataSrc = (byte*)pBlockBaseSrc + pAnimDesc->localhierarchyindex; + pDataDest = (byte*)pBlockBaseDest + pAnimDesc->localhierarchyindex; + DECLARE_OBJECT_POINTERS( pLocalHierarchy, pData, mstudiolocalhierarchy_t ) + + // HACK: Since animdescs are already native, pre-swap pAnimDesc->numlocalhierarchy + // here so the automatic swap inside ITERATE_BLOCK will restore it + int numlocalhierarchy = SrcNative( &pAnimDesc->numlocalhierarchy ); + ITERATE_BLOCK( pLocalHierarchy, numlocalhierarchy ) + { + WriteObjects<mstudiolocalhierarchy_t>( pLocalHierarchyDest, pLocalHierarchySrc, pAnimDesc->numlocalhierarchy ); + + /** COMPRESSED IK ERRORS **/ + + if ( pLocalHierarchy->localanimindex != 0 ) + { + // Calculate the number of ikerrors by converting the ikerror start and end float values to + // frame numbers. (See the generation of these values in simplify.cpp: ProcessIKRules()). + int numFrames = pAnimDesc->numframes; + float start = floorf( SrcNative( &pLocalHierarchy->start ) * (numFrames - 1) + 0.5f ); + float end = floorf( SrcNative( &pLocalHierarchy->end ) * (numFrames - 1) + 0.5f ); + int totalerror = (int)( end - start + 1 ); + if ( end >= numFrames ) + totalerror += 2; + + SET_INDEX_POINTERS( pData, pLocalHierarchy, localanimindex ) + WriteObjects<mstudiocompressedikerror_t>( pDataDest, pDataSrc ); + + mstudiocompressedikerror_t *pCompressed = (mstudiocompressedikerror_t *)pDataSrc; + + // Write the animvalues. + for ( int idx = 0; idx < 6; ++idx ) + { + if ( pCompressed->offset[idx] ) + { + byte *pAnimvalueSrc = pDataSrc + SrcNative( &pCompressed->offset[idx] ); + byte *pAnimvalueDest = pDataDest + SrcNative( &pCompressed->offset[idx] ); + + int numerror = 0; + while ( numerror < totalerror ) + { + // Write the first animation value (struct of 2 bytes) + mstudioanimvalue_t *pDestAnimvalue = (mstudioanimvalue_t*)( g_bNativeSrc ? pAnimvalueSrc : pAnimvalueDest ); + WriteBuffer<char>( &pAnimvalueDest, &pAnimvalueSrc, 2 ); + + // Write the remaining animation values from this group (shorts) + WriteBuffer<short>( &pAnimvalueDest, &pAnimvalueSrc, pDestAnimvalue->num.valid ); + + numerror += pDestAnimvalue->num.total; + } + } + } + } + } // Local Hierarchy block + } + } + + // printf("returning %d\n", fixedFileSize ); + + return fixedFileSize; +} + +int ByteswapANI( studiohdr_t* pHdr, void *pDestBase, const void *pSrcBase, const int fileSize ) +{ + // Make a working copy of the source to allow for alignment fixups + void *pNewSrcBase = malloc( fileSize + BYTESWAP_ALIGNMENT_PADDING ); + Q_memcpy( pNewSrcBase, pSrcBase, fileSize ); + + int fixedFileSize = ByteswapANIFile( pHdr, pDestBase, pNewSrcBase, fileSize ); + if ( fixedFileSize != fileSize ) + { + int finalSize = ByteswapANIFile( pHdr, pDestBase, pNewSrcBase, fixedFileSize ); + if ( finalSize != fixedFileSize ) + { + if ( g_bVerbose ) + Warning( "Alignment fixups failed on ANI swap!\n" ); + fixedFileSize = 0; + } + } + + free( pNewSrcBase ); + + // the compression needs to happen on the final or "fixed" pass + if ( g_pCompressFunc && pHdr->numanimblocks >= 2 && fixedFileSize ) + { + // assemble a new anim of compressed anim blocks + // start with original size, with room for alignment padding + fixedFileSize += (pHdr->numanimblocks + 1) * 2048; + byte *pNewDestBase = (byte *)malloc( fixedFileSize ); + Q_memset( pNewDestBase, 0, fixedFileSize ); + byte *pNewDest = pNewDestBase; + + // get the header payload as is + // assuming the header is up to the first anim block + mstudioanimblock_t *pAnimBlock = pHdr->pAnimBlock( 1 ); + V_memcpy( pNewDest, pDestBase, pAnimBlock->datastart ); + pNewDest += pAnimBlock->datastart; + + int padding = AlignValue( (unsigned int)pNewDest - (unsigned int)pNewDestBase, 2048 ); + padding -= (unsigned int)pNewDest - (unsigned int)pNewDestBase; + pNewDest += padding; + + // iterate and compress anim blocks + for ( int i = 1; i < pHdr->numanimblocks; ++i ) + { + pAnimBlock = pHdr->pAnimBlock( i ); + + void *pInput = (byte *)pDestBase + pAnimBlock->datastart; + int inputSize = pAnimBlock->dataend - pAnimBlock->datastart; + + pAnimBlock->datastart = (unsigned int)pNewDest - (unsigned int)pNewDestBase; + + void *pOutput; + int outputSize; + if ( g_pCompressFunc( pInput, inputSize, &pOutput, &outputSize ) ) + { + V_memcpy( pNewDest, pOutput, outputSize ); + pNewDest += outputSize; + free( pOutput ); + } + else + { + // as is + V_memcpy( pNewDest, pInput, inputSize ); + pNewDest += inputSize; + } + + padding = AlignValue( (unsigned int)pNewDest - (unsigned int)pNewDestBase, 2048 ); + padding -= (unsigned int)pNewDest - (unsigned int)pNewDestBase; + pNewDest += padding; + + pAnimBlock->dataend = (unsigned int)pNewDest - (unsigned int)pNewDestBase; + } + + fixedFileSize = pNewDest - pNewDestBase; + V_memcpy( pDestBase, pNewDestBase, fixedFileSize ); + free( pNewDestBase ); + } + + return fixedFileSize; +} + +//---------------------------------------------------------------------- +// Write a .mdl file in big-endian format +//---------------------------------------------------------------------- +int ByteswapMDLFile( void *pDestBase, void *pSrcBase, const int fileSize ) +{ + // Needed by fixup functions + g_pDataSrcBase = pSrcBase; + g_pfnFileProcessFunc = ProcessMDLFields; + int fixedFileSize = fileSize; + + Q_memset( pDestBase, 0, fileSize ); + + byte *pDataSrc = (byte*)pSrcBase; + byte *pDataDest = (byte*)pDestBase; + + /** FILE HEADER **/ + + DECLARE_OBJECT_POINTERS( pHdr, pData, studiohdr_t ) + WriteObjects( pHdrDest, pHdrSrc ); + + /** BONES **/ + + SET_INDEX_POINTERS_FIXUP( pData, pHdr, boneindex ) + DECLARE_OBJECT_POINTERS( pStudioBone, pData, mstudiobone_t ) + ITERATE_BLOCK( pStudioBone, pHdr->numbones ) + { + WriteObjects( pStudioBoneDest, pStudioBoneSrc ); + + if ( pStudioBone->procindex ) + { + SET_INDEX_POINTERS_FIXUP( pData, pStudioBone, procindex ) + + unsigned int index = SrcNative( &pStudioBone->proctype ); + switch( index ) + { + case STUDIO_PROC_AXISINTERP: + { + /** AXIS-INTERP BONES **/ + DECLARE_OBJECT_POINTERS( pAxisInterpBone, pData, mstudioaxisinterpbone_t ) + WriteObjects( pAxisInterpBoneDest, pAxisInterpBoneSrc ); + break; + } + case STUDIO_PROC_QUATINTERP: + { + /** QUAT-INTERP BONES **/ + DECLARE_OBJECT_POINTERS( pQuatInterpBone, pData, mstudioquatinterpbone_t ) + WriteObjects( pQuatInterpBoneDest, pQuatInterpBoneSrc ); + + /** QUAT-INTERP TRIGGERS **/ + SET_INDEX_POINTERS_FIXUP( pData, pQuatInterpBone, triggerindex ) + WriteObjects<mstudioquatinterpinfo_t>( pDataDest, pDataSrc, SrcNative( &pQuatInterpBone->numtriggers ) ); + break; + } + case STUDIO_PROC_JIGGLE: + { + /** JIGGLE BONES **/ + DECLARE_OBJECT_POINTERS( pJiggleBone, pData, mstudiojigglebone_t ) + WriteObjects( pJiggleBoneDest, pJiggleBoneSrc ); + break; + } + case STUDIO_PROC_AIMATBONE: + case STUDIO_PROC_AIMATATTACH: + { + /** AIM AT BONES **/ + DECLARE_OBJECT_POINTERS( pAimAtBone, pData, mstudioaimatbone_t ) + WriteObjects( pAimAtBoneDest, pAimAtBoneSrc ); + break; + } + default: + Assert( 0 ); + Warning( "Unknown bone type %d found!\n", index ); + } + } + } + + /** BONE CONTROLLERS **/ + + SET_INDEX_POINTERS_FIXUP( pData, pHdr, bonecontrollerindex ) + WriteObjects<mstudiobonecontroller_t>( pDataDest, pDataSrc, SrcNative( &pHdr->numbonecontrollers ) ); + + /** ATTACHMENTS **/ + + SET_INDEX_POINTERS_FIXUP( pData, pHdr, localattachmentindex ) + WriteObjects<mstudioattachment_t>( pDataDest, pDataSrc, SrcNative( &pHdr->numlocalattachments ) ); + + /** HITBOX SETS **/ + + SET_INDEX_POINTERS_FIXUP( pData, pHdr, hitboxsetindex ) + DECLARE_OBJECT_POINTERS( pHitboxSet, pData, mstudiohitboxset_t ) + ITERATE_BLOCK( pHitboxSet, pHdr->numhitboxsets ) + { + WriteObjects( pHitboxSetDest, pHitboxSetSrc ); + + /** HITBOXES **/ + + SET_INDEX_POINTERS_FIXUP( pData, pHitboxSet, hitboxindex ) + WriteObjects<mstudiobbox_t>( pDataDest, pDataSrc, SrcNative( &pHitboxSet->numhitboxes ) ); + } + + /** BONE TABLE **/ + + SET_INDEX_POINTERS( pData, pHdr, bonetablebynameindex ) + WriteBuffer<char>( pDataDest, pDataSrc, SrcNative( &pHdr->numbones ) ); + + /** ANIMATION DESCRIPTIONS **/ + + SET_INDEX_POINTERS_FIXUP( pData, pHdr, localanimindex ) + DECLARE_OBJECT_POINTERS( pAnimDesc, pData, mstudioanimdesc_t ) + ITERATE_BLOCK( pAnimDesc, pHdr->numlocalanim ) + { + WriteObjects( pAnimDescDest, pAnimDescSrc ); + + if ( pAnimDesc->animblock == -1 ) + { + // out of date model format + continue; + } + + // section data can point to both internal and external blocks + int numsections = 0; + if ( pAnimDesc->sectionframes != 0 ) + { + numsections = pAnimDesc->numframes / pAnimDesc->sectionframes + 2; + + SET_INDEX_POINTERS( pData, pAnimDesc, sectionindex ) + DECLARE_OBJECT_POINTERS( pSection, pData, mstudioanimsections_t ) + + WriteObjects( pSectionDest, pSectionSrc, numsections ); + } + + if ( pAnimDesc->animblock == 0 ) + { + if ( numsections == 0 ) + { + SET_INDEX_POINTERS( pData, pAnimDesc, animindex ) + ByteswapAnimData( pAnimDesc, 0, pDataSrc, pDataDest ); + } + else + { + for ( int i = 0; i < numsections; ++i ) + { + if ( pAnimDesc->pSection( i )->animblock == 0 ) + { + int index = pAnimDesc->pSection( i )->animindex; + + // Base address of the animation in the animblock + byte *pDataSrc = (byte *)pAnimDescSrc + index; + byte *pDataDest = (byte *)pAnimDescDest + index; + + ByteswapAnimData( pAnimDesc, i, pDataSrc, pDataDest ); + } + } + } + + /** IK RULES **/ + + if ( pAnimDesc->ikruleindex ) + { + SET_INDEX_POINTERS_FIXUP( pData, pAnimDesc, ikruleindex ) + DECLARE_OBJECT_POINTERS( pIKRule, pData, mstudioikrule_t ) + + int numframes = SrcNative( &pAnimDesc->numframes ); + ByteswapIKRules( pHdrSrc, pAnimDesc->numikrules, numframes, pDataSrc, pDataDest, fixedFileSize, fileSize ); + } + + /** LOCAL HIERARCHY **/ + + if ( pAnimDesc->localhierarchyindex ) + { + SET_INDEX_POINTERS( pData, pAnimDesc, localhierarchyindex ) + DECLARE_OBJECT_POINTERS( pLocalHierarchy, pData, mstudiolocalhierarchy_t ) + ITERATE_BLOCK( pLocalHierarchy, pAnimDesc->numlocalhierarchy ) + { + WriteObjects<mstudiolocalhierarchy_t>( pLocalHierarchyDest, pLocalHierarchySrc, SrcNative( &pAnimDesc->numlocalhierarchy ) ); + + /** COMPRESSED IK ERRORS **/ + + if ( pLocalHierarchy->localanimindex != 0 ) + { + // Calculate the number of ikerrors by converting the ikerror start and end float values to + // frame numbers. (See the generation of these values in simplify.cpp: ProcessIKRules()). + int numFrames = SrcNative( &pAnimDesc->numframes ); + float start = floorf( SrcNative( &pLocalHierarchy->start ) * (numFrames - 1) + 0.5f ); + float end = floorf( SrcNative( &pLocalHierarchy->end ) * (numFrames - 1) + 0.5f ); + int totalerror = (int)( end - start + 1 ); + if ( end >= numFrames ) + totalerror += 2; + + SET_INDEX_POINTERS( pData, pLocalHierarchy, localanimindex ) + WriteObjects<mstudiocompressedikerror_t>( pDataDest, pDataSrc ); + + mstudiocompressedikerror_t *pCompressed = (mstudiocompressedikerror_t *)pDataSrc; + + // Write the animvalues. + for ( int idx = 0; idx < 6; ++idx ) + { + if ( pCompressed->offset[idx] ) + { + byte *pAnimvalueSrc = pDataSrc + SrcNative( &pCompressed->offset[idx] ); + byte *pAnimvalueDest = pDataDest + SrcNative( &pCompressed->offset[idx] ); + + int numerror = 0; + while ( numerror < totalerror ) + { + // Write the first animation value (struct of 2 bytes) + mstudioanimvalue_t *pDestAnimvalue = (mstudioanimvalue_t*)( g_bNativeSrc ? pAnimvalueSrc : pAnimvalueDest ); + WriteBuffer<char>( &pAnimvalueDest, &pAnimvalueSrc, 2 ); + + // Write the remaining animation values from this group (shorts) + WriteBuffer<short>( &pAnimvalueDest, &pAnimvalueSrc, pDestAnimvalue->num.valid ); + + numerror += pDestAnimvalue->num.total; + } + } + } + } + } + } // Local Hierarchy block + } + } // Animdesc block + + /** MOVEMENTS **/ + + // Separate loop required by format of mstudioanimdesc_t data + SET_INDEX_POINTERS( pData, pHdr, localanimindex ) + SET_OBJECT_POINTERS( pAnimDesc, pData, mstudioanimdesc_t ) + ITERATE_BLOCK( pAnimDesc, pHdr->numlocalanim ) + { + if ( pAnimDesc->nummovements ) + { + SET_INDEX_POINTERS_FIXUP( pData, pAnimDesc, movementindex ) + WriteObjects<mstudiomovement_t>( pDataDest, pDataSrc, SrcNative( &pAnimDesc->nummovements ) ); + } + } + + /** IK RULES (2nd pass) **/ + + // This is required to support older models that had these lumps in a different + // order - the model version didn't change, so there's no reliable way to detect it. + SET_INDEX_POINTERS( pData, pHdr, localanimindex ) + SET_OBJECT_POINTERS( pAnimDesc, pData, mstudioanimdesc_t ) + ITERATE_BLOCK( pAnimDesc, pHdr->numlocalanim ) + { + if ( pAnimDesc->ikruleindex ) + { + // Only need to write the data again if a fixup happens + byte *pTest = (byte*)pAnimDesc + SrcNative( &pAnimDesc->ikruleindex ); + SET_INDEX_POINTERS_FIXUP( pData, pAnimDesc, ikruleindex ) + if ( pTest == pDataSrc ) + continue; + + DECLARE_OBJECT_POINTERS( pIKRule, pData, mstudioikrule_t ) + ITERATE_BLOCK( pIKRule, pAnimDesc->numikrules ) + { + WriteObjects<mstudioikrule_t>( pIKRuleDest, pIKRuleSrc ); + + /** IK ERROR KEYS **/ + + // Calculate the number of ikerrors by converting the ikerror start and end float values to + // frame numbers. (See the generation of these values in simplify.cpp: ProcessIKRules()). + int numFrames = SrcNative( &pAnimDesc->numframes ); + float start = floorf( SrcNative( &pIKRule->start ) * (numFrames - 1) + 0.5f ); + float end = floorf( SrcNative( &pIKRule->end ) * (numFrames - 1) + 0.5f ); + int totalerror = (int)( end - start + 1 ); + if ( end >= numFrames ) + totalerror += 2; + + // Uncompressed - only found in some older models (shipped hl2) + if ( pIKRule->ikerrorindex ) + { + SET_INDEX_POINTERS_FIXUP( pData, pIKRule, ikerrorindex ) + WriteObjects<mstudioikerror_t>( pDataDest, pDataSrc, totalerror ); + } + + // Compressed - all models since hl2 + if ( pIKRule->compressedikerrorindex ) + { + SET_INDEX_POINTERS_FIXUP( pData, pIKRule, compressedikerrorindex ) + WriteObjects<mstudiocompressedikerror_t>( pDataDest, pDataSrc ); + + mstudiocompressedikerror_t *pCompressed = (mstudiocompressedikerror_t *)pDataSrc; + + // Write the animvalues. + for ( int idx = 0; idx < 6; ++idx ) + { + if ( pCompressed->offset[idx] ) + { + byte *pAnimvalueSrc = pDataSrc + SrcNative( &pCompressed->offset[idx] ); + byte *pAnimvalueDest = pDataDest + SrcNative( &pCompressed->offset[idx] ); + + int numerror = 0; + while ( numerror < totalerror ) + { + // Write the first animation value (struct of 2 bytes) + mstudioanimvalue_t *pDestAnimvalue = (mstudioanimvalue_t*)( g_bNativeSrc ? pAnimvalueSrc : pAnimvalueDest ); + WriteBuffer<char>( &pAnimvalueDest, &pAnimvalueSrc, 2 ); + + // Write the remaining animation values from this group (shorts) + WriteBuffer<short>( &pAnimvalueDest, &pAnimvalueSrc, pDestAnimvalue->num.valid ); + + numerror += pDestAnimvalue->num.total; + } + } + } + + if ( pIKRule->szattachmentindex ) + { + SET_INDEX_POINTERS( pData, pIKRule, szattachmentindex ) + int size = strlen( (char*)pDataSrc ) + 1; + WriteBuffer<char>( pDataDest, pDataSrc, size ); + } + } + } + } + + // Local hierarchy keys don't exist in older models + } + + /** ZERO FRAMES **/ + + SET_INDEX_POINTERS( pData, pHdr, localanimindex ) + SET_OBJECT_POINTERS( pAnimDesc, pData, mstudioanimdesc_t ) + ITERATE_BLOCK( pAnimDesc, pHdr->numlocalanim ) + { + if ( pAnimDesc->pZeroFrameData( ) != NULL ) + { + int offset = pAnimDesc->pZeroFrameData( ) - (byte *)pAnimDesc; + + // Base address of the animation in the animblock + byte *pZeroFrameSrc = (byte *)pAnimDescSrc + offset; + byte *pZeroFrameDest = (byte *)pAnimDescDest + offset; + + SET_INDEX_POINTERS( pData, pHdr, boneindex ) + SET_OBJECT_POINTERS( pStudioBone, pData, mstudiobone_t ) + ITERATE_BLOCK( pStudioBone, pHdr->numbones ) + { + if ( pStudioBone->flags & BONE_HAS_SAVEFRAME_POS ) + { + for ( int j = 0; j < pAnimDesc->zeroframecount; j++) + { + WriteBuffer<short>( &pZeroFrameDest, &pZeroFrameSrc, 3 ); + } + } + if ( pStudioBone->flags & BONE_HAS_SAVEFRAME_ROT ) + { + for ( int j = 0; j < pAnimDesc->zeroframecount; j++) + { + WriteBuffer<int64>( &pZeroFrameDest, &pZeroFrameSrc, 1 ); + } + } + } + } + } + + /** SEQUENCE INFO **/ + + SET_INDEX_POINTERS_FIXUP( pData, pHdr, localseqindex ) + DECLARE_OBJECT_POINTERS( pSequence, pData, mstudioseqdesc_t ) + ITERATE_BLOCK( pSequence, pHdr->numlocalseq ) + { + WriteObjects( pSequenceDest, pSequenceSrc ); + + /** POSE KEYS **/ + + if ( pSequence->posekeyindex ) + { + SET_INDEX_POINTERS_FIXUP( pData, pSequence, posekeyindex ) + WriteBuffer<float>( pDataDest, pDataSrc, SrcNative( &pSequence->groupsize[0] ) + SrcNative( &pSequence->groupsize[1] ) ); + } + + /** STUDIO EVENTS **/ + + SET_INDEX_POINTERS_FIXUP( pData, pSequence, eventindex ) + WriteObjects<mstudioevent_t>( pDataDest, pDataSrc, SrcNative( &pSequence->numevents ) ); + + /** AUTOLAYERS **/ + + SET_INDEX_POINTERS_FIXUP( pData, pSequence, autolayerindex ) + WriteObjects<mstudioautolayer_t>( pDataDest, pDataSrc, SrcNative( &pSequence->numautolayers ) ); + + /** BONE WEIGHTS **/ + + // Data may be shared across sequences + DECLARE_INDEX_POINTERS_FIXUP( pWeight, pSequence, weightlistindex ) + if ( pWeightSrc >= pDataSrc ) + { + int numBoneWeights = ( SrcNative( &pSequence->iklockindex ) - SrcNative( &pSequence->weightlistindex ) ) / sizeof(float); + WriteBuffer<float>( pWeightDest, pWeightSrc, numBoneWeights ); + } + + /** IK LOCKS **/ + + SET_INDEX_POINTERS_FIXUP( pData, pSequence, iklockindex ) + WriteObjects<mstudioiklock_t>( pDataDest, pDataSrc, SrcNative( &pSequence->numiklocks ) ); + + /** ANIMATION INDICES **/ + + if ( pSequence->animindexindex ) + { + SET_INDEX_POINTERS( pData, pSequence, animindexindex ) + WriteBuffer<short>( pDataDest, pDataSrc, SrcNative( &pSequence->groupsize[0] ) * SrcNative( &pSequence->groupsize[1] ) ); + } + + /** KEYVALUES **/ + + SET_INDEX_POINTERS( pData, pSequence, keyvalueindex ) + WriteBuffer<char>( pDataDest, pDataSrc, SrcNative( &pSequence->keyvaluesize ) ); + } + + /** TRANSITION GRAPH **/ + + int numLocalNodes = SrcNative( &pHdr->numlocalnodes ); + SET_INDEX_POINTERS_FIXUP( pData, pHdr, localnodenameindex ) + WriteBuffer<int>( pDataDest, pDataSrc, numLocalNodes ); + + /** LOCAL NODES **/ + + SET_INDEX_POINTERS( pData, pHdr, localnodeindex ) + WriteBuffer<char>( pDataDest, pDataSrc, numLocalNodes * numLocalNodes ); + + /** BODYPART INFO **/ + + SET_INDEX_POINTERS_FIXUP( pData, pHdr, bodypartindex ) + DECLARE_OBJECT_POINTERS( pBodypart, pData, mstudiobodyparts_t ) + ITERATE_BLOCK( pBodypart, pHdr->numbodyparts ) + { + WriteObjects( pBodypartDest, pBodypartSrc ); + + /** MODEL INFO **/ + + SET_INDEX_POINTERS_FIXUP( pData, pBodypart, modelindex ) + DECLARE_OBJECT_POINTERS( pModel, pData, mstudiomodel_t ) + ITERATE_BLOCK( pModel, pBodypart->nummodels ) + { + WriteObjects( pModelDest, pModelSrc ); + + /** MESHES **/ + + SET_INDEX_POINTERS_FIXUP( pData, pModel, meshindex ) + DECLARE_OBJECT_POINTERS( pMesh, pData, mstudiomesh_t ) + ITERATE_BLOCK( pMesh, pModel->nummeshes ) + { + WriteObjects( pMeshDest, pMeshSrc ); + + if ( !pMesh->numflexes ) + continue; + + /** FLEXES **/ + + SET_INDEX_POINTERS_FIXUP( pData, pMesh, flexindex ) + DECLARE_OBJECT_POINTERS( pFlex, pData, mstudioflex_t ) + ITERATE_BLOCK( pFlex, pMesh->numflexes ) + { + WriteObjects( pFlexDest, pFlexSrc ); + + /** VERT ANIMS **/ + + SET_INDEX_POINTERS_FIXUP( pData, pFlex, vertindex ) + WriteObjects<mstudiovertanim_t>( pDataDest, pDataSrc, SrcNative( &pFlex->numverts ) ); + } + } + + /** EYEBALLS **/ + + SET_INDEX_POINTERS_FIXUP( pData, pModel, eyeballindex ) + WriteObjects<mstudioeyeball_t>( pDataDest, pDataSrc, SrcNative( &pModel->numeyeballs ) ); + } + } + + /** GLOBAL FLEX NAMES **/ + + SET_INDEX_POINTERS_FIXUP( pData, pHdr, flexdescindex ) + WriteObjects<mstudioflexdesc_t>( pDataDest, pDataSrc, SrcNative( &pHdr->numflexdesc ) ); + + /** GLOBAL FLEX CONTROLLERS **/ + + SET_INDEX_POINTERS_FIXUP( pData, pHdr, flexcontrollerindex ) + WriteObjects<mstudioflexcontroller_t>( pDataDest, pDataSrc, SrcNative( &pHdr->numflexcontrollers ) ); + + /** GLOBAL FLEX CONTROLLER REMAPS **/ + + SET_INDEX_POINTERS_FIXUP( pData, pHdr, flexcontrolleruiindex ) + WriteObjects<mstudioflexcontrollerui_t>( pDataDest, pDataSrc, SrcNative( &pHdr->numflexcontrollerui ) ); + + // TODOKD: The remap indices after the flex controller remap headers need to be swapped as well? + + /** FLEX RULES **/ + + SET_INDEX_POINTERS_FIXUP( pData, pHdr, flexruleindex ) + DECLARE_OBJECT_POINTERS( pFlexRule, pData, mstudioflexrule_t ) + ITERATE_BLOCK( pFlexRule, pHdr->numflexrules ) + { + WriteObjects( pFlexRuleDest, pFlexRuleSrc ); + + /** FLEX OPS **/ + + SET_INDEX_POINTERS_FIXUP( pData, pFlexRule, opindex ) + WriteObjects<mstudioflexop_t>( pDataDest, pDataSrc, SrcNative( &pFlexRule->numops ) ); + } + + /** IK CHAINS **/ + + SET_INDEX_POINTERS_FIXUP( pData, pHdr, ikchainindex ) + DECLARE_OBJECT_POINTERS( pIKChain, pData, mstudioikchain_t ) + ITERATE_BLOCK( pIKChain, pHdr->numikchains ) + { + WriteObjects( pIKChainDest, pIKChainSrc ); + + /** IK LINKS **/ + + SET_INDEX_POINTERS( pData, pIKChain, linkindex ) + WriteObjects<mstudioiklink_t>( pDataDest, pDataSrc, SrcNative( &pIKChain->numlinks ) ); + } + + /** IK AUTOPLAY LOCKS **/ + + SET_INDEX_POINTERS_FIXUP( pData, pHdr, localikautoplaylockindex ) + WriteObjects<mstudioiklock_t>( pDataDest, pDataSrc, SrcNative( &pHdr->numlocalikautoplaylocks ) ); + + /** MOUTH INFO **/ + + SET_INDEX_POINTERS_FIXUP( pData, pHdr, mouthindex ) + WriteObjects<mstudiomouth_t>( pDataDest, pDataSrc, SrcNative( &pHdr->nummouths ) ); + + /** POSE PARAMATERS **/ + + SET_INDEX_POINTERS_FIXUP( pData, pHdr, localposeparamindex ) + WriteObjects<mstudioposeparamdesc_t>( pDataDest, pDataSrc, SrcNative( &pHdr->numlocalposeparameters ) ); + + /** MODEL GROUPS **/ + + SET_INDEX_POINTERS_FIXUP( pData, pHdr, includemodelindex ) + WriteObjects<mstudiomodelgroup_t>( pDataDest, pDataSrc, SrcNative( &pHdr->numincludemodels ) ); + + /** ANIMBLOCK GROUP INFO **/ + + SET_INDEX_POINTERS_FIXUP( pData, pHdr, animblockindex ) + WriteObjects<mstudioanimblock_t>( pDataDest, pDataSrc, SrcNative( &pHdr->numanimblocks ) ); + + /** TEXTURE INFO **/ + + // While swapping, kill off unwanted textures by name + SET_INDEX_POINTERS_FIXUP( pData, pHdr, textureindex ) + DECLARE_OBJECT_POINTERS( pTexture, pData, mstudiotexture_t ) + int textureCt = SrcNative( &pHdr->numtextures ); + int nameOffset = 0; + for ( int i = 0; i < SrcNative( &pHdr->numtextures ); ++i, ++pTexture, ++pTextureSrc ) + { + WriteObjects<mstudiotexture_t>( pTextureDest, pTextureSrc ); + + int destnameindex = SrcNative( &pTexture->sznameindex ) + nameOffset; + pTextureDest->sznameindex = DestNative( &destnameindex ); + char *pName = (char*)pTexture + SrcNative( &pTexture->sznameindex ); +#if 0 // Undone: Killing textures here can cause crashes at runtime. + // Don't need pupil textures + if ( Q_stristr( pName, "pupil_" ) || !Q_stricmp( pName, "pupil" ) ) + { + --textureCt; + nameOffset += sizeof(mstudiotexture_t); + } + else +#endif + { + ++pTextureDest; + } + } + pHdrDest->numtextures = DestNative( &textureCt ); + + /** TEXTURE INDICES **/ + + SET_INDEX_POINTERS_FIXUP( pData, pHdr, cdtextureindex ) + WriteBuffer<int>( &pDataDest, &pDataSrc, SrcNative( &pHdr->numcdtextures ) ); + + /** TEXTURE DICTIONARY **/ + + SET_INDEX_POINTERS( pData, pHdr, skinindex ) + WriteBuffer<short>( &pDataDest, &pDataSrc, SrcNative( &pHdr->numskinfamilies ) * SrcNative( &pHdr->numskinref ) ); + + /** KEYVALUES **/ + + SET_INDEX_POINTERS( pData, pHdr, keyvalueindex ) + WriteBuffer<char>( &pDataDest, &pDataSrc, SrcNative( &pHdr->keyvaluesize ) ); + + /** STUDIOHDR2 **/ + + if ( pHdr->studiohdr2index ) + { + DECLARE_INDEX_POINTERS_FIXUP( pLocalData, pHdr, studiohdr2index ) + DECLARE_OBJECT_POINTERS( pStudioHdr2, pLocalData, studiohdr2_t ) + + // HACK: Pre-swap the constant "1" here so the automatic swap inside ITERATE_BLOCK will restore it + int studiohdr2ct = 1; + studiohdr2ct = SrcNative( &studiohdr2ct ); + ITERATE_BLOCK( pStudioHdr2, studiohdr2ct ) + { + WriteObjects( pStudioHdr2Dest, pStudioHdr2Src ); + + /** SRC BONE TRANSFORMS **/ + + if ( pStudioHdr2->numsrcbonetransform ) + { + // Note, srcbonetransformindex is an offset from the start of the file, not the start of the studiohdr2 + // as is the convention. That's why the macros can't be used here. + pDataSrc = (byte*)pHdrSrc + SrcNative( &pStudioHdr2->srcbonetransformindex ); + pDataDest = (byte*)pHdrDest + SrcNative( &pStudioHdr2->srcbonetransformindex ); + WriteObjects<mstudiosrcbonetransform_t>( &pDataDest, &pDataSrc, SrcNative( &pStudioHdr2->numsrcbonetransform ) ); + } + + if ( pStudioHdr2->linearboneindex ) + { + SET_INDEX_POINTERS_FIXUP( pData, pStudioHdr2, linearboneindex ) + DECLARE_OBJECT_POINTERS( pLinearBone, pData, mstudiolinearbone_t ) + + WriteObjects( pLinearBoneDest, pLinearBoneSrc ); + + int numBones = SrcNative( &pLinearBone->numbones ); + SET_INDEX_POINTERS_FIXUP( pData, pLinearBone, flagsindex ) + WriteBuffer<int>( &pDataDest, &pDataSrc, numBones ); + + SET_INDEX_POINTERS_FIXUP( pData, pLinearBone, parentindex ) + WriteBuffer<int>( &pDataDest, &pDataSrc, numBones ); + + SET_INDEX_POINTERS_FIXUP( pData, pLinearBone, posindex ) + WriteBuffer<float>( &pDataDest, &pDataSrc, 3*numBones ); + + SET_INDEX_POINTERS_FIXUP( pData, pLinearBone, quatindex ) + WriteBuffer<float>( &pDataDest, &pDataSrc, 4*numBones ); + + SET_INDEX_POINTERS_FIXUP( pData, pLinearBone, rotindex ) + WriteBuffer<float>( &pDataDest, &pDataSrc, 3*numBones ); + + SET_INDEX_POINTERS_FIXUP( pData, pLinearBone, posetoboneindex ) + WriteBuffer<float>( &pDataDest, &pDataSrc, 12*numBones ); + + SET_INDEX_POINTERS_FIXUP( pData, pLinearBone, posscaleindex ) + WriteBuffer<float>( &pDataDest, &pDataSrc, 3*numBones ); + + SET_INDEX_POINTERS_FIXUP( pData, pLinearBone, rotscaleindex ) + WriteBuffer<float>( &pDataDest, &pDataSrc, 3*numBones ); + + SET_INDEX_POINTERS_FIXUP( pData, pLinearBone, qalignmentindex ) + WriteBuffer<float>( &pDataDest, &pDataSrc, 4*numBones ); + } + } + } + + /** STRING TABLE **/ + + // NOTE: The block of data (above) swapped immediately before the string table MUST update the + // pDataSrc pointer position, in order for this string table offset calculation to work correctly. + // To update the pointer position, pass the pointer address to WriteObjects(). + int offset = pDataSrc - (byte*)pSrcBase; + int stringTableBytes = fixedFileSize - offset; + WriteBuffer<char>( pDataDest, pDataSrc, stringTableBytes ); + + pHdrDest->length = DestNative( &fixedFileSize ); + + // Cleanup texture paths + // Some older MDL's have double terminal slashes + SET_INDEX_POINTERS( pData, pHdr, cdtextureindex ) + int numCdTextures = SrcNative( &pHdr->numcdtextures ); + for ( int i = 0; i < numCdTextures; ++i ) + { + char *pPath = (char*)pHdrDest + SrcNative( &((int *)pDataSrc)[i] ); + int len = strlen( pPath ); + if ( len >= 2 && ( pPath[len-1] == '\\' || pPath[len-1] == '/' ) && ( pPath[len-2] == '\\' || pPath[len-2] == '/' ) ) + { + pPath[len-1] = '\0'; + } + } + + return fixedFileSize; +} + +//---------------------------------------------------------------------- +// Swap a .mdl in two passes - first pass fixes alignment errors by shifting +// the data and updating offsets, then the second pass does the final swap. +//---------------------------------------------------------------------- +int ByteswapMDL( void *pDestBase, const void *pSrcBase, const int fileSize ) +{ + // Make a working copy of the source to allow for alignment fixups + void *pNewSrcBase = malloc( fileSize + BYTESWAP_ALIGNMENT_PADDING ); + Q_memcpy( pNewSrcBase, pSrcBase, fileSize ); + + int fixedFileSize = ByteswapMDLFile( pDestBase, pNewSrcBase, fileSize ); + if ( fixedFileSize != fileSize ) + { + int finalSize = ByteswapMDLFile( pDestBase, pNewSrcBase, fixedFileSize ); + if ( finalSize != fixedFileSize ) + { + Warning( "Alignment fixups failed on MDL swap!\n" ); + fixedFileSize = 0; + } + } + + free( pNewSrcBase ); + + // the compression needs to happen on the final or "fixed" pass + if ( g_pCompressFunc && fixedFileSize ) + { + void *pInput = pDestBase; + int inputSize = fixedFileSize; + void *pOutput; + int outputSize; + if ( g_pCompressFunc( pInput, inputSize, &pOutput, &outputSize ) ) + { + V_memcpy( pDestBase, pOutput, outputSize ); + free( pOutput ); + fixedFileSize = outputSize; + } + } + + return fixedFileSize; +} + +//---------------------------------------------------------------------- +// Determines what kind of file this is and calls the correct swap function +//---------------------------------------------------------------------- +int ByteswapStudioFile( const char *pFilename, void *pOutBase, const void *pFileBase, int fileSize, studiohdr_t *pHdr, CompressFunc_t pCompressFunc ) +{ + assert( pFilename ); + assert( pOutBase != pFileBase ); + + g_pCompressFunc = pCompressFunc; + + int retVal = 0; + + if ( Q_stristr( pFilename, ".mdl" ) ) + { + retVal = ByteswapMDL( pOutBase, pFileBase, fileSize ); + } + else if ( Q_stristr( pFilename, ".vvd" ) ) + { + retVal = ByteswapVVD( pOutBase, pFileBase, fileSize ); + } + else if ( Q_stristr( pFilename, ".vtx" ) ) + { + retVal = ByteswapVTX( pOutBase, pFileBase, fileSize ); + } + else if ( Q_stristr( pFilename, ".phy" ) ) + { + retVal = ByteswapPHY( pOutBase, pFileBase, fileSize ); + } + else if ( Q_stristr( pFilename, ".ani" ) ) + { + // some dead .ani files exist in the tree + // only process valid .ani files properly hooked to their .mdl + if ( pHdr && pHdr->numanimblocks != 0 ) + { + retVal = ByteswapANI( pHdr, pOutBase, pFileBase, fileSize ); + } + } + + g_pCompressFunc = NULL; + + return retVal; +} + + +//---------------------------------------------------------------------- +// LEGACY ANI FIXUPS - No need to update this function +// +// If model data needs to be shifted to fix a misalignment, this function is +// called with the process func "UpdateSrcIndexFields" to update every datadesc field +// that was marked as FIELD_INDEX. Any index that "points" across +// the shifted data location will have its value incremented or decremented +// by the appropriate number of bytes. This misalignment issue only +// applies to some pre-EP2 models, as all newly compiled models are guaranteed +// to be aligned correctly. Therefore, this function should not need to change +// when model formats are updated, as any model compiled with a new format will +// naturally not require this fixup function to be called. +//---------------------------------------------------------------------- +void ProcessANIFields( void *pDataBase, datadescProcessFunc_t pfnProcessFunc ) +{ + studiohdr_t *pHdr = g_pHdr; + byte *pData = (byte*)pDataBase; + byte *pSrcBase = (byte*)g_pDataSrcBase; + + // Since the animblocks and animdescs are native data, trick the system + // into not swapping their index values during processing. + bool bNativeSrc = g_bNativeSrc; + g_bNativeSrc = true; + + // Update the .mdl's animblock offsets into the .ani file + mstudioanimblock_t *pAnimBlock = pHdr->pAnimBlock( 1 ); + for ( int i = 1; i < pHdr->numanimblocks; ++i, ++pAnimBlock ) + { + ProcessFields( pSrcBase, pAnimBlock, &mstudioanimblock_t::m_DataMap, pfnProcessFunc ); + } + + // Update the .mdl's animindex offsets into the .ani file + // Don't bother with local hierarchy keys - they only exist in newer, properly aligned models + mstudioanimdesc_t *pAnimDesc = pHdr->pLocalAnimdesc( 0 ); + for ( int i = 0; i < pHdr->numlocalanim; ++i, ++pAnimDesc ) + { + mstudioanimblock_t *pAnimBlock = pHdr->pAnimBlock( pAnimDesc->animblock ); + byte *pBlockBase = (byte*)pSrcBase + pAnimBlock->datastart; + + ProcessFieldByName( pBlockBase, pAnimDesc, &mstudioanimdesc_t::m_DataMap, "animindex", pfnProcessFunc ); + ProcessFieldByName( pBlockBase, pAnimDesc, &mstudioanimdesc_t::m_DataMap, "animblockikruleindex", pfnProcessFunc ); + } + + // Restore the correct native setting + g_bNativeSrc = bNativeSrc; + + // Update the .ani file's internal offsets + pAnimDesc = pHdr->pLocalAnimdesc( 0 ); + for ( int i = 0; i < pHdr->numlocalanim; ++i, ++pAnimDesc ) + { + pAnimBlock = pHdr->pAnimBlock( pAnimDesc->animblock ); + byte *pBlockBase = (byte*)pSrcBase + pAnimBlock->datastart; + + byte *pData = pBlockBase + pAnimDesc->animindex; + mstudioanim_t* pAnimation = (mstudioanim_t*)pData; + if ( pAnimation->bone == 255 ) + { + // No animation data + pAnimation = 0; + } + + while( pAnimation ) + { + ProcessFields( pAnimation, &mstudioanim_t::m_DataMap, pfnProcessFunc ); + + if ( pAnimation->nextoffset ) + { + pData = (byte*)pAnimation + SrcNative( &pAnimation->nextoffset ); + pAnimation = (mstudioanim_t*)pData; + } + else + { + pAnimation = NULL; + } + } + + if ( pAnimDesc->animblockikruleindex ) + { + pData = (byte*)pBlockBase + pAnimDesc->animblockikruleindex; + + mstudioikrule_t *pIKRule = (mstudioikrule_t *)pData; + for ( int i = 0; i < pAnimDesc->numikrules; ++i, ++pIKRule ) + { + ProcessFields( pIKRule, &mstudioikrule_t::m_DataMap, pfnProcessFunc ); + } + } + } +} + +//---------------------------------------------------------------------- +// LEGACY MDL FIXUPS - No need to update this function +// +// If model data needs to be shifted to fix a misalignment, this function is +// called with the process func "UpdateSrcIndexFields" to update every datadesc field +// that was marked as FIELD_INDEX. Any index that "points" across +// the shifted data location will have its value incremented or decremented +// by the appropriate number of bytes. This misalignment issue only +// applies to some pre-EP2 models, as all newly compiled models are guaranteed +// to be aligned correctly. Therefore, this function should not need to change +// when model formats are updated, as any model compiled with a new format will +// naturally not require this fixup function to be called. +//---------------------------------------------------------------------- +void ProcessMDLFields( void *pDataBase, datadescProcessFunc_t pfnProcessFunc ) +{ + byte *pData = (byte*)pDataBase; + + /** FILE HEADER **/ + + studiohdr_t *pHdr = (studiohdr_t*)pData; + ProcessFields( pHdr, &studiohdr_t::m_DataMap, pfnProcessFunc ); + + /** BONES **/ + + pData = (byte*)pHdr + SrcNative( &pHdr->boneindex ); + mstudiobone_t *pBone = (mstudiobone_t*)pData; + for ( int i = 0; i < SrcNative( &pHdr->numbones ); ++i, ++pBone ) + { + ProcessFields( pBone, &mstudiobone_t::m_DataMap, pfnProcessFunc ); + + if ( pBone->procindex ) + { + pData = (byte*)pBone + SrcNative( &pBone->procindex ); + + unsigned int proctype = SrcNative( &pBone->proctype ); + switch( proctype ) + { + case STUDIO_PROC_AXISINTERP: + + /** AXIS-INTERP BONES **/ + ProcessFields( pData, &mstudioaxisinterpbone_t::m_DataMap, pfnProcessFunc ); + break; + + case STUDIO_PROC_QUATINTERP: + + /** QUAT-INTERP BONES **/ + ProcessFields( pData, &mstudioquatinterpbone_t::m_DataMap, pfnProcessFunc ); + break; + + case STUDIO_PROC_JIGGLE: + + /** JIGGLE BONES **/ + ProcessFields( pData, &mstudiojigglebone_t::m_DataMap, pfnProcessFunc ); + break; + + case STUDIO_PROC_AIMATBONE: + case STUDIO_PROC_AIMATATTACH: + + /** AIM AT BONES **/ + ProcessFields( pData, &mstudioaimatbone_t::m_DataMap, pfnProcessFunc ); + break; + + } + } + } + + /** ATTACHMENTS **/ + + pData = (byte*)pHdr + SrcNative( &pHdr->localattachmentindex ); + mstudioattachment_t *pAttachment = (mstudioattachment_t*)pData; + for ( int i = 0; i < SrcNative( &pHdr->numlocalattachments ); ++i, ++pAttachment ) + { + ProcessFields( pAttachment, &mstudioattachment_t::m_DataMap, pfnProcessFunc ); + } + + /** HITBOX SETS **/ + + pData = (byte*)pHdr + SrcNative( &pHdr->hitboxsetindex ); + mstudiohitboxset_t* pHitboxSet = (mstudiohitboxset_t*)pData; + for ( int i = 0; i < SrcNative( &pHdr->numhitboxsets ); ++i, ++pHitboxSet ) + { + ProcessFields( pHitboxSet, &mstudiohitboxset_t::m_DataMap, pfnProcessFunc ); + + /** HITBOXES **/ + pData = (byte*)pHitboxSet + SrcNative( &pHitboxSet->hitboxindex ); + mstudiobbox_t *pBBox = (mstudiobbox_t*)pData; + for ( int i = 0; i < SrcNative( &pHitboxSet->numhitboxes ); ++i, ++pBBox ) + { + ProcessFields( pBBox, &mstudiobbox_t::m_DataMap, pfnProcessFunc ); + } + } + + /** ANIMATION DESCRIPTIONS **/ + + pData = (byte*)pHdr + SrcNative( &pHdr->localanimindex ); + mstudioanimdesc_t* pAnimDesc = (mstudioanimdesc_t*)pData; + for ( int i = 0; i < SrcNative( &pHdr->numlocalanim ); ++i, ++pAnimDesc ) + { + // Can't update animindex or animblockindex for animations that are in a separate .ani file + ProcessFieldByName( pAnimDesc, &mstudioanimdesc_t::m_DataMap, "baseptr", pfnProcessFunc ); + ProcessFieldByName( pAnimDesc, &mstudioanimdesc_t::m_DataMap, "sznameindex", pfnProcessFunc ); + ProcessFieldByName( pAnimDesc, &mstudioanimdesc_t::m_DataMap, "movementindex", pfnProcessFunc ); + ProcessFieldByName( pAnimDesc, &mstudioanimdesc_t::m_DataMap, "ikruleindex", pfnProcessFunc ); + + /** ANIMATIONS **/ + + if ( pAnimDesc->animblock == 0 ) + { + // Now it's safe to update the animindex + ProcessFieldByName( pAnimDesc, &mstudioanimdesc_t::m_DataMap, "animindex", pfnProcessFunc ); + + pData = (byte*)pAnimDesc + SrcNative( &pAnimDesc->animindex ); + mstudioanim_t* pAnimation = (mstudioanim_t*)pData; + while( pAnimation ) + { + ProcessFields( pAnimation, &mstudioanim_t::m_DataMap, pfnProcessFunc ); + + if ( pAnimation->nextoffset ) + { + pData = (byte*)pAnimation + SrcNative( &pAnimation->nextoffset ); + pAnimation = (mstudioanim_t*)pData; + } + else + { + pAnimation = NULL; + } + } + } + + if ( pAnimDesc->ikruleindex ) + { + pData = (byte*)pAnimDesc + SrcNative( &pAnimDesc->ikruleindex ); + + mstudioikrule_t *pIKRule = (mstudioikrule_t *)pData; + for ( int i = 0; i < SrcNative( &pAnimDesc->numikrules ); ++i, ++pIKRule ) + { + ProcessFields( pIKRule, &mstudioikrule_t::m_DataMap, pfnProcessFunc ); + } + } + } + + /** SEQUENCE INFO **/ + + pData = (byte*)pHdr + SrcNative( &pHdr->localseqindex ); + mstudioseqdesc_t *pSequenceHdr = (mstudioseqdesc_t*)pData; + for ( int i = 0; i < SrcNative( &pHdr->numlocalseq ); ++i, ++pSequenceHdr ) + { + ProcessFields( pSequenceHdr, &mstudioseqdesc_t::m_DataMap, pfnProcessFunc ); + + /** STUDIO EVENTS **/ + + pData = (byte*)pHdr + SrcNative( &pSequenceHdr->eventindex ); + mstudioevent_t *pEvent = (mstudioevent_t*)pData; + for ( int i = 0; i < SrcNative( &pSequenceHdr->numevents ); ++i, ++pEvent ) + { + ProcessFields( pSequenceHdr, &mstudioevent_t::m_DataMap, pfnProcessFunc ); + } + } + + /** BODYPART INFO **/ + + pData = (byte*)pHdr + SrcNative( &pHdr->bodypartindex ); + mstudiobodyparts_t *pBodypart = (mstudiobodyparts_t*)pData; + for ( int i = 0; i < SrcNative( &pHdr->numbodyparts ); ++i, ++pBodypart ) + { + ProcessFields( pBodypart, &mstudiobodyparts_t::m_DataMap, pfnProcessFunc ); + + /** MODEL INFO **/ + + byte *pData = (byte*)pBodypart + SrcNative( &pBodypart->modelindex ); + mstudiomodel_t *pModel = (mstudiomodel_t*)pData; + for ( int i = 0; i < SrcNative( &pBodypart->nummodels ); ++i, ++pModel ) + { + ProcessFields( pModel, &mstudiomodel_t::m_DataMap, pfnProcessFunc ); + + /** MESHES **/ + + pData = (byte*)pModel + SrcNative( &pModel->meshindex ); + mstudiomesh_t *pMesh = (mstudiomesh_t*)pData; + for ( int i = 0; i < SrcNative( &pModel->nummeshes ); ++i, ++pMesh ) + { + ProcessFields( pMesh, &mstudiomesh_t::m_DataMap, pfnProcessFunc ); + + if ( !pMesh->numflexes ) + continue; + + /** FLEXES **/ + + pData = (byte*)pMesh + SrcNative( &pMesh->flexindex ); + mstudioflex_t *pFlex = (mstudioflex_t*)pData; + for ( int i = 0; i < SrcNative( &pMesh->numflexes ); ++i, ++pFlex ) + { + ProcessFields( pFlex, &mstudioflex_t::m_DataMap, pfnProcessFunc ); + } + } + + /** EYEBALLS **/ + + pData= (byte*)pModel + SrcNative( &pModel->eyeballindex ); + mstudioeyeball_t *pEyeball = (mstudioeyeball_t*)pData; + for ( int i = 0; i < SrcNative( &pModel->numeyeballs ); ++i, ++pEyeball ) + { + ProcessFields( pEyeball, &mstudioeyeball_t::m_DataMap, pfnProcessFunc ); + } + } + } + + /** GLOBAL FLEX NAMES **/ + + pData = (byte*)pHdr + SrcNative( &pHdr->flexdescindex ); + mstudioflexdesc_t *pFlexDesc = (mstudioflexdesc_t*)pData; + for ( int i = 0; i < SrcNative( &pHdr->numflexdesc ); ++i, ++pFlexDesc ) + { + ProcessFields( pFlexDesc, &mstudioflexdesc_t::m_DataMap, pfnProcessFunc ); + } + + /** GLOBAL FLEX CONTROLLERS **/ + + pData = (byte*)pHdr + SrcNative( &pHdr->flexcontrollerindex ); + mstudioflexcontroller_t *pFlexController = (mstudioflexcontroller_t*)pData; + for ( int i = 0; i < SrcNative( &pHdr->numflexcontrollers ); ++i, ++pFlexController ) + { + ProcessFields( pFlexController, &mstudioflexcontroller_t::m_DataMap, pfnProcessFunc ); + } + + /** GLOBAL FLEX CONTROLLER REMAPS **/ + + pData = (byte*)pHdr + SrcNative( &pHdr->flexcontrolleruiindex ); + mstudioflexcontrollerui_t *pFlexControllerRemap = (mstudioflexcontrollerui_t*)pData; + for ( int i = 0; i < SrcNative( &pHdr->numflexcontrollerui ); ++i, ++pFlexControllerRemap ) + { + ProcessFields( pFlexControllerRemap, &mstudioflexcontrollerui_t::m_DataMap, pfnProcessFunc ); + } + + /** FLEX RULES **/ + + pData = (byte*)pHdr + SrcNative( &pHdr->flexruleindex ); + mstudioflexrule_t *pFlexRule = (mstudioflexrule_t*)pData; + for ( int i = 0; i < SrcNative( &pHdr->numflexrules ); ++i, ++pFlexRule ) + { + ProcessFields( pFlexRule, &mstudioflexrule_t::m_DataMap, pfnProcessFunc ); + } + + /** IK CHAINS **/ + + pData = (byte*)pHdr + SrcNative( &pHdr->ikchainindex ); + mstudioikchain_t *pIKChain = (mstudioikchain_t*)pData; + for ( int i = 0; i < SrcNative( &pHdr->numikchains ); ++i, ++pIKChain ) + { + ProcessFields( pIKChain, &mstudioikchain_t::m_DataMap, pfnProcessFunc ); + } + + /** POSE PARAMATERS **/ + + pData = (byte*)pHdr + SrcNative( &pHdr->localposeparamindex ); + mstudioposeparamdesc_t *pPoseParam = (mstudioposeparamdesc_t*)pData; + for ( int i = 0; i < SrcNative( &pHdr->numlocalposeparameters ); ++i, ++pPoseParam ) + { + ProcessFields( pPoseParam, &mstudioposeparamdesc_t::m_DataMap, pfnProcessFunc ); + } + + /** MODEL GROUPS **/ + + pData = (byte*)pHdr + SrcNative( &pHdr->includemodelindex ); + mstudiomodelgroup_t *pMdl = (mstudiomodelgroup_t*)pData; + for ( int i = 0; i < SrcNative( &pHdr->numincludemodels ); ++i, ++pMdl ) + { + ProcessFields( pMdl, &mstudiomodelgroup_t::m_DataMap, pfnProcessFunc ); + } + + /** TEXTURE INFO **/ + + pData = (byte*)pHdr + SrcNative( &pHdr->textureindex ); + mstudiotexture_t *pTexture = (mstudiotexture_t*)pData; + for ( int i = 0; i < SrcNative( &pHdr->numtextures ); ++i, ++pTexture ) + { + ProcessFields( pTexture, &mstudiotexture_t::m_DataMap, pfnProcessFunc ); + } + + /** CDTEXTURE OFFSETS **/ + + pData = (byte*)pHdr + SrcNative( &pHdr->cdtextureindex ); + int *pIdx = (int*)pData; + for ( int i = 0; i < SrcNative( &pHdr->numcdtextures ); ++i, ++pIdx ) + { + int idx = SrcNative( pIdx ); + UpdateIndex( pHdr, &idx ); + *pIdx = SrcNative( &idx ); + } + + /** STUDIOHDR2 **/ + + if ( pHdr->studiohdr2index ) + { + pData = (byte*)pHdr + SrcNative( &pHdr->studiohdr2index ); + studiohdr2_t *pStudioHdr2 = (studiohdr2_t*)pData; + for ( int i = 0; i < 1; ++i, ++pStudioHdr2 ) + { + ProcessFields( pStudioHdr2, &studiohdr2_t::m_DataMap, pfnProcessFunc ); + + /** SRC BONE TRANSFORMS **/ + + pData = (byte*)pHdr + SrcNative( &pStudioHdr2->srcbonetransformindex ); + mstudiosrcbonetransform_t *pSrcBoneTransform = (mstudiosrcbonetransform_t*)pData; + for ( int i = 0; i < SrcNative( &pStudioHdr2->numsrcbonetransform ); ++i, ++pSrcBoneTransform ) + { + ProcessFields( pSrcBoneTransform, &mstudiosrcbonetransform_t::m_DataMap, pfnProcessFunc ); + } + } + } +} + + +#pragma warning( pop ) // local variable is initialized but not referenced + +} // namespace StudioByteSwap + +// Data descriptions for byte swapping - only needed +// for structures that are written to file for use by the game. +// For any fields that reference other data in the file, use the +// DEFINE_INDEX macro to identify them as such. +BEGIN_BYTESWAP_DATADESC( studiohdr_t ) + DEFINE_FIELD( id, FIELD_INTEGER ), + DEFINE_FIELD( version, FIELD_INTEGER ), + DEFINE_FIELD( checksum, FIELD_INTEGER ), + DEFINE_ARRAY( name, FIELD_CHARACTER, 64 ), + DEFINE_FIELD( length, FIELD_INTEGER ), + DEFINE_FIELD( eyeposition, FIELD_VECTOR ), + DEFINE_FIELD( illumposition, FIELD_VECTOR ), + DEFINE_FIELD( hull_min, FIELD_VECTOR ), + DEFINE_FIELD( hull_max, FIELD_VECTOR ), + DEFINE_FIELD( view_bbmin, FIELD_VECTOR ), + DEFINE_FIELD( view_bbmax, FIELD_VECTOR ), + DEFINE_FIELD( flags, FIELD_INTEGER ), + DEFINE_FIELD( numbones, FIELD_INTEGER ), // bones + DEFINE_INDEX( boneindex, FIELD_INTEGER ), + DEFINE_FIELD( numbonecontrollers, FIELD_INTEGER ), // bone controllers + DEFINE_INDEX( bonecontrollerindex, FIELD_INTEGER ), + DEFINE_FIELD( numhitboxsets, FIELD_INTEGER ), + DEFINE_INDEX( hitboxsetindex, FIELD_INTEGER ), + DEFINE_FIELD( numlocalanim, FIELD_INTEGER ), // animations/poses + DEFINE_INDEX( localanimindex, FIELD_INTEGER ), // animation descriptions + DEFINE_FIELD( numlocalseq, FIELD_INTEGER ), // sequences + DEFINE_INDEX( localseqindex, FIELD_INTEGER ), + DEFINE_FIELD( activitylistversion, FIELD_INTEGER ), // initialization flag - have the sequences been indexed? + DEFINE_FIELD( eventsindexed, FIELD_INTEGER ), + DEFINE_FIELD( numtextures, FIELD_INTEGER ), + DEFINE_INDEX( textureindex, FIELD_INTEGER ), + DEFINE_FIELD( numcdtextures, FIELD_INTEGER ), + DEFINE_INDEX( cdtextureindex, FIELD_INTEGER ), + DEFINE_FIELD( numskinref, FIELD_INTEGER ), + DEFINE_FIELD( numskinfamilies, FIELD_INTEGER ), + DEFINE_INDEX( skinindex, FIELD_INTEGER ), + DEFINE_FIELD( numbodyparts, FIELD_INTEGER ), + DEFINE_INDEX( bodypartindex, FIELD_INTEGER ), + DEFINE_FIELD( numlocalattachments, FIELD_INTEGER ), + DEFINE_INDEX( localattachmentindex, FIELD_INTEGER ), + DEFINE_FIELD( numlocalnodes, FIELD_INTEGER ), + DEFINE_INDEX( localnodeindex, FIELD_INTEGER ), + DEFINE_INDEX( localnodenameindex, FIELD_INTEGER ), + DEFINE_FIELD( numflexdesc, FIELD_INTEGER ), + DEFINE_INDEX( flexdescindex, FIELD_INTEGER ), + DEFINE_FIELD( numflexcontrollers, FIELD_INTEGER ), + DEFINE_INDEX( flexcontrollerindex, FIELD_INTEGER ), + DEFINE_FIELD( numflexrules, FIELD_INTEGER ), + DEFINE_INDEX( flexruleindex, FIELD_INTEGER ), + DEFINE_FIELD( numikchains, FIELD_INTEGER ), + DEFINE_INDEX( ikchainindex, FIELD_INTEGER ), + DEFINE_FIELD( nummouths, FIELD_INTEGER ), + DEFINE_INDEX( mouthindex, FIELD_INTEGER ), + DEFINE_FIELD( numlocalposeparameters, FIELD_INTEGER ), + DEFINE_INDEX( localposeparamindex, FIELD_INTEGER ), + DEFINE_INDEX( surfacepropindex, FIELD_INTEGER ), + DEFINE_INDEX( keyvalueindex, FIELD_INTEGER ), + DEFINE_FIELD( keyvaluesize, FIELD_INTEGER ), + DEFINE_FIELD( numlocalikautoplaylocks, FIELD_INTEGER ), + DEFINE_INDEX( localikautoplaylockindex, FIELD_INTEGER ), + DEFINE_FIELD( mass, FIELD_FLOAT ), + DEFINE_FIELD( contents, FIELD_INTEGER ), + DEFINE_FIELD( numincludemodels, FIELD_INTEGER ), + DEFINE_INDEX( includemodelindex, FIELD_INTEGER ), + DEFINE_FIELD( virtualModel, FIELD_INTEGER ), // void* + DEFINE_INDEX( szanimblocknameindex, FIELD_INTEGER ), + DEFINE_FIELD( numanimblocks, FIELD_INTEGER ), + DEFINE_INDEX( animblockindex, FIELD_INTEGER ), + DEFINE_FIELD( animblockModel, FIELD_INTEGER ), // void* + DEFINE_INDEX( bonetablebynameindex, FIELD_INTEGER ), + DEFINE_FIELD( pVertexBase, FIELD_INTEGER ), // void* + DEFINE_FIELD( pIndexBase, FIELD_INTEGER ), // void* + DEFINE_FIELD( constdirectionallightdot, FIELD_CHARACTER ), // byte + DEFINE_FIELD( rootLOD, FIELD_CHARACTER ), // byte + DEFINE_FIELD( numAllowedRootLODs, FIELD_CHARACTER ), // byte + DEFINE_ARRAY( unused, FIELD_CHARACTER, 1 ), // byte + DEFINE_INDEX( unused4, FIELD_INTEGER ), + DEFINE_FIELD( numflexcontrollerui, FIELD_INTEGER ), + DEFINE_INDEX( flexcontrolleruiindex, FIELD_INTEGER ), + DEFINE_ARRAY( unused3, FIELD_INTEGER, 2 ), + DEFINE_INDEX( studiohdr2index, FIELD_INTEGER ), + DEFINE_ARRAY( unused2, FIELD_INTEGER, 1 ), +END_BYTESWAP_DATADESC() + +// NOTE! Next time we up the .mdl file format, remove studiohdr2_t +// and insert all fields in this structure into studiohdr_t. +BEGIN_BYTESWAP_DATADESC( studiohdr2_t ) + DEFINE_FIELD( numsrcbonetransform, FIELD_INTEGER ), + DEFINE_INDEX( srcbonetransformindex, FIELD_INTEGER ), + DEFINE_FIELD( illumpositionattachmentindex, FIELD_INTEGER ), + DEFINE_FIELD( flMaxEyeDeflection, FIELD_FLOAT ), + DEFINE_INDEX( linearboneindex, FIELD_INTEGER ), + DEFINE_INDEX( sznameindex, FIELD_INTEGER ), + DEFINE_ARRAY( reserved, FIELD_INTEGER, 58 ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudiobone_t ) + DEFINE_INDEX( sznameindex, FIELD_INTEGER ), + DEFINE_FIELD( parent, FIELD_INTEGER ), + DEFINE_ARRAY( bonecontroller, FIELD_INTEGER, 6 ), + DEFINE_FIELD( pos, FIELD_VECTOR ), + DEFINE_FIELD( quat, FIELD_QUATERNION ), + DEFINE_ARRAY( rot, FIELD_FLOAT, 3 ), // RadianEuler + DEFINE_FIELD( posscale, FIELD_VECTOR ), + DEFINE_FIELD( rotscale, FIELD_VECTOR ), + DEFINE_ARRAY( poseToBone, FIELD_FLOAT, 12 ), // matrix3x4_t + DEFINE_FIELD( qAlignment, FIELD_QUATERNION ), + DEFINE_FIELD( flags, FIELD_INTEGER ), + DEFINE_FIELD( proctype, FIELD_INTEGER ), + DEFINE_INDEX( procindex, FIELD_INTEGER ), + DEFINE_INDEX( physicsbone, FIELD_INTEGER ), + DEFINE_INDEX( surfacepropidx, FIELD_INTEGER ), + DEFINE_FIELD( contents, FIELD_INTEGER ), + DEFINE_ARRAY( unused, FIELD_INTEGER, 8 ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudiolinearbone_t ) + DEFINE_FIELD( numbones, FIELD_INTEGER ), + DEFINE_INDEX( flagsindex, FIELD_INTEGER ), + DEFINE_INDEX( parentindex, FIELD_INTEGER ), + DEFINE_INDEX( posindex, FIELD_INTEGER ), + DEFINE_INDEX( quatindex, FIELD_INTEGER ), + DEFINE_INDEX( rotindex, FIELD_INTEGER ), + DEFINE_INDEX( posetoboneindex, FIELD_INTEGER ), + DEFINE_INDEX( posscaleindex, FIELD_INTEGER ), + DEFINE_INDEX( rotscaleindex, FIELD_INTEGER ), + DEFINE_INDEX( qalignmentindex, FIELD_INTEGER ), + DEFINE_ARRAY( unused, FIELD_INTEGER, 6 ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudioaxisinterpbone_t ) + DEFINE_FIELD( control, FIELD_INTEGER ), + DEFINE_FIELD( axis, FIELD_INTEGER ), + DEFINE_ARRAY( pos, FIELD_VECTOR, 6 ), + DEFINE_ARRAY( quat, FIELD_QUATERNION, 6 ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudioquatinterpbone_t ) + DEFINE_FIELD( control, FIELD_INTEGER ), + DEFINE_FIELD( numtriggers, FIELD_INTEGER ), + DEFINE_INDEX( triggerindex, FIELD_INTEGER ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudiojigglebone_t ) + DEFINE_FIELD( flags, FIELD_INTEGER ), + DEFINE_FIELD( length, FIELD_FLOAT ), + DEFINE_FIELD( tipMass, FIELD_FLOAT ), + DEFINE_FIELD( yawStiffness, FIELD_FLOAT ), + DEFINE_FIELD( yawDamping, FIELD_FLOAT ), + DEFINE_FIELD( pitchStiffness, FIELD_FLOAT ), + DEFINE_FIELD( pitchDamping, FIELD_FLOAT ), + DEFINE_FIELD( alongStiffness, FIELD_FLOAT ), + DEFINE_FIELD( alongDamping, FIELD_FLOAT ), + DEFINE_FIELD( angleLimit, FIELD_FLOAT ), + DEFINE_FIELD( minYaw, FIELD_FLOAT ), + DEFINE_FIELD( maxYaw, FIELD_FLOAT ), + DEFINE_FIELD( yawFriction, FIELD_FLOAT ), + DEFINE_FIELD( yawBounce, FIELD_FLOAT ), + DEFINE_FIELD( minPitch, FIELD_FLOAT ), + DEFINE_FIELD( maxPitch, FIELD_FLOAT ), + DEFINE_FIELD( pitchFriction, FIELD_FLOAT ), + DEFINE_FIELD( pitchBounce, FIELD_FLOAT ), + DEFINE_FIELD( baseMass, FIELD_FLOAT ), + DEFINE_FIELD( baseStiffness, FIELD_FLOAT ), + DEFINE_FIELD( baseDamping, FIELD_FLOAT ), + DEFINE_FIELD( baseMinLeft, FIELD_FLOAT ), + DEFINE_FIELD( baseMaxLeft, FIELD_FLOAT ), + DEFINE_FIELD( baseLeftFriction, FIELD_FLOAT ), + DEFINE_FIELD( baseMinUp, FIELD_FLOAT ), + DEFINE_FIELD( baseMaxUp, FIELD_FLOAT ), + DEFINE_FIELD( baseUpFriction, FIELD_FLOAT ), + DEFINE_FIELD( baseMinForward, FIELD_FLOAT ), + DEFINE_FIELD( baseMaxForward, FIELD_FLOAT ), + DEFINE_FIELD( baseForwardFriction, FIELD_FLOAT ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudioaimatbone_t ) + DEFINE_FIELD( parent, FIELD_INTEGER ), + DEFINE_FIELD( aim, FIELD_INTEGER ), + DEFINE_ARRAY( aimvector, FIELD_FLOAT, 3 ), + DEFINE_ARRAY( upvector, FIELD_FLOAT, 3 ), + DEFINE_ARRAY( basepos, FIELD_FLOAT, 3 ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudioquatinterpinfo_t ) + DEFINE_FIELD( inv_tolerance, FIELD_FLOAT ), + DEFINE_FIELD( trigger, FIELD_QUATERNION ), + DEFINE_FIELD( pos, FIELD_VECTOR ), + DEFINE_FIELD( quat, FIELD_QUATERNION ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudiobonecontroller_t ) + DEFINE_FIELD( bone, FIELD_INTEGER ), + DEFINE_FIELD( type, FIELD_INTEGER ), + DEFINE_FIELD( start, FIELD_FLOAT ), + DEFINE_FIELD( end, FIELD_FLOAT ), + DEFINE_FIELD( rest, FIELD_INTEGER ), + DEFINE_FIELD( inputfield, FIELD_INTEGER ), + DEFINE_ARRAY( unused, FIELD_INTEGER, 8 ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudioattachment_t ) + DEFINE_INDEX( sznameindex, FIELD_INTEGER ), + DEFINE_FIELD( flags, FIELD_INTEGER ), + DEFINE_FIELD( localbone, FIELD_INTEGER ), + DEFINE_ARRAY( local, FIELD_FLOAT, 12 ), // matrix3x4_t + DEFINE_ARRAY( unused, FIELD_INTEGER, 8 ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudiohitboxset_t ) + DEFINE_INDEX( sznameindex, FIELD_INTEGER ), + DEFINE_FIELD( numhitboxes, FIELD_INTEGER ), + DEFINE_INDEX( hitboxindex, FIELD_INTEGER ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudiosrcbonetransform_t ) + DEFINE_INDEX( sznameindex, FIELD_INTEGER ), + DEFINE_ARRAY( pretransform, FIELD_FLOAT, 12 ), // matrix3x4_t + DEFINE_ARRAY( posttransform, FIELD_FLOAT, 12 ), // matrix3x4_t +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudiobbox_t ) + DEFINE_FIELD( bone, FIELD_INTEGER ), + DEFINE_FIELD( group, FIELD_INTEGER ), + DEFINE_FIELD( bbmin, FIELD_VECTOR ), + DEFINE_FIELD( bbmax, FIELD_VECTOR ), + DEFINE_INDEX( szhitboxnameindex, FIELD_INTEGER ), + DEFINE_ARRAY( unused, FIELD_INTEGER, 8 ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudioanim_valueptr_t ) + DEFINE_ARRAY( offset, FIELD_SHORT, 3 ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudiolocalhierarchy_t ) + DEFINE_FIELD( iBone, FIELD_INTEGER ), + DEFINE_FIELD( iNewParent, FIELD_INTEGER ), + DEFINE_FIELD( start, FIELD_FLOAT ), + DEFINE_FIELD( peak, FIELD_FLOAT ), + DEFINE_FIELD( tail, FIELD_FLOAT ), + DEFINE_FIELD( end, FIELD_FLOAT ), + DEFINE_FIELD( iStart, FIELD_INTEGER ), + DEFINE_INDEX( localanimindex, FIELD_INTEGER ), + DEFINE_ARRAY( unused, FIELD_INTEGER, 4 ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudioanimsections_t ) + DEFINE_FIELD( animblock, FIELD_INTEGER ), + DEFINE_INDEX( animindex, FIELD_INTEGER ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudioanimdesc_t ) + DEFINE_INDEX( baseptr, FIELD_INTEGER ), + DEFINE_INDEX( sznameindex, FIELD_INTEGER ), + DEFINE_FIELD( fps, FIELD_FLOAT ), + DEFINE_FIELD( flags, FIELD_INTEGER ), + DEFINE_FIELD( numframes, FIELD_INTEGER ), + DEFINE_FIELD( nummovements, FIELD_INTEGER ), + DEFINE_INDEX( movementindex, FIELD_INTEGER ), + DEFINE_ARRAY( unused1, FIELD_INTEGER, 6 ), + DEFINE_FIELD( animblock, FIELD_INTEGER ), + DEFINE_INDEX( animindex, FIELD_INTEGER ), + DEFINE_FIELD( numikrules, FIELD_INTEGER ), + DEFINE_INDEX( ikruleindex, FIELD_INTEGER ), + DEFINE_INDEX( animblockikruleindex, FIELD_INTEGER ), + DEFINE_FIELD( numlocalhierarchy, FIELD_INTEGER ), + DEFINE_INDEX( localhierarchyindex, FIELD_INTEGER ), + DEFINE_INDEX( sectionindex, FIELD_INTEGER ), + DEFINE_FIELD( sectionframes, FIELD_INTEGER ), + DEFINE_FIELD( zeroframespan, FIELD_SHORT ), + DEFINE_FIELD( zeroframecount, FIELD_SHORT ), + DEFINE_INDEX( zeroframeindex, FIELD_INTEGER ), + DEFINE_FIELD( zeroframestalltime, FIELD_FLOAT ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudioanim_t ) + DEFINE_FIELD( bone, FIELD_CHARACTER ), + DEFINE_FIELD( flags, FIELD_CHARACTER ), + DEFINE_INDEX( nextoffset, FIELD_SHORT ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudioikerror_t ) + DEFINE_FIELD( pos, FIELD_VECTOR ), + DEFINE_FIELD( q, FIELD_QUATERNION ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudiocompressedikerror_t ) + DEFINE_ARRAY( scale, FIELD_FLOAT, 6 ), + DEFINE_ARRAY( offset, FIELD_SHORT, 6 ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudioikrule_t ) + DEFINE_FIELD( index, FIELD_INTEGER ), + DEFINE_FIELD( type, FIELD_INTEGER ), + DEFINE_FIELD( chain, FIELD_INTEGER ), + DEFINE_FIELD( bone, FIELD_INTEGER ), + DEFINE_FIELD( slot, FIELD_INTEGER ), + DEFINE_FIELD( height, FIELD_FLOAT ), + DEFINE_FIELD( radius, FIELD_FLOAT ), + DEFINE_FIELD( floor, FIELD_FLOAT ), + DEFINE_FIELD( pos, FIELD_VECTOR ), + DEFINE_FIELD( q, FIELD_QUATERNION ), + DEFINE_INDEX( compressedikerrorindex, FIELD_INTEGER ), + DEFINE_FIELD( unused2, FIELD_INTEGER ), + DEFINE_FIELD( iStart, FIELD_INTEGER ), + DEFINE_INDEX( ikerrorindex, FIELD_INTEGER ), + DEFINE_FIELD( start, FIELD_FLOAT ), + DEFINE_FIELD( peak, FIELD_FLOAT ), + DEFINE_FIELD( tail, FIELD_FLOAT ), + DEFINE_FIELD( end, FIELD_FLOAT ), + DEFINE_FIELD( unused3, FIELD_FLOAT ), + DEFINE_FIELD( contact, FIELD_FLOAT ), + DEFINE_FIELD( drop, FIELD_FLOAT ), + DEFINE_FIELD( top, FIELD_FLOAT ), + DEFINE_FIELD( unused6, FIELD_INTEGER ), + DEFINE_FIELD( unused7, FIELD_INTEGER ), + DEFINE_FIELD( unused8, FIELD_INTEGER ), + DEFINE_INDEX( szattachmentindex, FIELD_INTEGER ), + DEFINE_ARRAY( unused, FIELD_INTEGER, 7 ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudiomovement_t ) + DEFINE_FIELD( endframe, FIELD_INTEGER ), + DEFINE_FIELD( motionflags, FIELD_INTEGER ), + DEFINE_FIELD( v0, FIELD_FLOAT ), + DEFINE_FIELD( v1, FIELD_FLOAT ), + DEFINE_FIELD( angle, FIELD_FLOAT ), + DEFINE_FIELD( vector, FIELD_VECTOR ), + DEFINE_FIELD( position, FIELD_VECTOR ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudioseqdesc_t ) + DEFINE_INDEX( baseptr, FIELD_INTEGER ), + DEFINE_INDEX( szlabelindex, FIELD_INTEGER ), + DEFINE_INDEX( szactivitynameindex, FIELD_INTEGER ), + DEFINE_FIELD( flags, FIELD_INTEGER ), // looping/non-looping flags + DEFINE_FIELD( activity, FIELD_INTEGER ), // initialized at loadtime to game DLL values + DEFINE_FIELD( actweight, FIELD_INTEGER ), + DEFINE_FIELD( numevents, FIELD_INTEGER ), + DEFINE_INDEX( eventindex, FIELD_INTEGER ), + DEFINE_FIELD( bbmin, FIELD_VECTOR ), + DEFINE_FIELD( bbmax, FIELD_VECTOR ), + DEFINE_FIELD( numblends, FIELD_INTEGER ), + DEFINE_INDEX( animindexindex, FIELD_INTEGER ), + DEFINE_INDEX( movementindex, FIELD_INTEGER ), // [blend] float array for blended movement + DEFINE_ARRAY( groupsize, FIELD_INTEGER, 2 ), + DEFINE_ARRAY( paramindex, FIELD_INTEGER, 2 ), // X, Y, Z, XR, YR, ZR + DEFINE_ARRAY( paramstart, FIELD_FLOAT, 2 ), // local (0..1) starting value + DEFINE_ARRAY( paramend, FIELD_FLOAT, 2 ), // local (0..1) ending value + DEFINE_FIELD( paramparent, FIELD_INTEGER ), + DEFINE_FIELD( fadeintime, FIELD_FLOAT ), // ideal cross fate in time (0.2 default) + DEFINE_FIELD( fadeouttime, FIELD_FLOAT ), // ideal cross fade out time (0.2 default) + DEFINE_FIELD( localentrynode, FIELD_INTEGER ), // transition node at entry + DEFINE_FIELD( localexitnode, FIELD_INTEGER ), // transition node at exit + DEFINE_FIELD( nodeflags, FIELD_INTEGER ), // transition rules + DEFINE_FIELD( entryphase, FIELD_FLOAT ), // used to match entry gait + DEFINE_FIELD( exitphase, FIELD_FLOAT ), // used to match exit gait + DEFINE_FIELD( lastframe, FIELD_FLOAT ), // frame that should generation EndOfSequence + DEFINE_FIELD( nextseq, FIELD_INTEGER ), // auto advancing sequences + DEFINE_FIELD( pose, FIELD_INTEGER ), // index of delta animation between end and nextseq + DEFINE_FIELD( numikrules, FIELD_INTEGER ), + DEFINE_FIELD( numautolayers, FIELD_INTEGER ), + DEFINE_INDEX( autolayerindex, FIELD_INTEGER ), + DEFINE_INDEX( weightlistindex, FIELD_INTEGER ), + DEFINE_INDEX( posekeyindex, FIELD_INTEGER ), + DEFINE_FIELD( numiklocks, FIELD_INTEGER ), + DEFINE_INDEX( iklockindex, FIELD_INTEGER ), + DEFINE_INDEX( keyvalueindex, FIELD_INTEGER ), + DEFINE_FIELD( keyvaluesize, FIELD_INTEGER ), + DEFINE_INDEX( cycleposeindex, FIELD_INTEGER ), + DEFINE_ARRAY( unused, FIELD_INTEGER, 7 ), // remove/add as appropriate (grow back to 8 ints on version change!) +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudioevent_t ) + DEFINE_FIELD( cycle, FIELD_FLOAT ), + DEFINE_FIELD( event, FIELD_INTEGER ), + DEFINE_FIELD( type, FIELD_INTEGER ), + DEFINE_ARRAY( options, FIELD_CHARACTER, 64 ), + DEFINE_INDEX( szeventindex, FIELD_INTEGER ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudioautolayer_t ) + DEFINE_FIELD( iSequence, FIELD_SHORT ), + DEFINE_FIELD( iPose, FIELD_SHORT ), + DEFINE_FIELD( flags, FIELD_INTEGER ), + DEFINE_FIELD( start, FIELD_FLOAT ), + DEFINE_FIELD( peak, FIELD_FLOAT ), + DEFINE_FIELD( tail, FIELD_FLOAT ), + DEFINE_FIELD( end, FIELD_FLOAT ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudioiklock_t ) + DEFINE_FIELD( chain, FIELD_INTEGER ), + DEFINE_FIELD( flPosWeight, FIELD_FLOAT ), + DEFINE_FIELD( flLocalQWeight, FIELD_FLOAT ), + DEFINE_FIELD( flags, FIELD_INTEGER ), + DEFINE_ARRAY( unused, FIELD_INTEGER, 4 ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudiobodyparts_t ) + DEFINE_INDEX( sznameindex, FIELD_INTEGER ), + DEFINE_FIELD( nummodels, FIELD_INTEGER ), + DEFINE_FIELD( base, FIELD_INTEGER ), + DEFINE_INDEX( modelindex, FIELD_INTEGER ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudiomodel_t ) + DEFINE_ARRAY( name, FIELD_CHARACTER, 64 ), + DEFINE_FIELD( type, FIELD_INTEGER ), + DEFINE_FIELD( boundingradius, FIELD_FLOAT ), + DEFINE_FIELD( nummeshes, FIELD_INTEGER ), + DEFINE_INDEX( meshindex, FIELD_INTEGER ), + DEFINE_FIELD( numvertices, FIELD_INTEGER ), + DEFINE_INDEX( vertexindex, FIELD_INTEGER ), + DEFINE_INDEX( tangentsindex, FIELD_INTEGER ), + DEFINE_FIELD( numattachments, FIELD_INTEGER ), + DEFINE_INDEX( attachmentindex, FIELD_INTEGER ), + DEFINE_FIELD( numeyeballs, FIELD_INTEGER ), + DEFINE_INDEX( eyeballindex, FIELD_INTEGER ), + DEFINE_EMBEDDED( vertexdata ), + DEFINE_ARRAY( unused, FIELD_INTEGER, 8 ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudio_modelvertexdata_t ) + DEFINE_FIELD( pVertexData, FIELD_INTEGER ), // void* + DEFINE_FIELD( pTangentData, FIELD_INTEGER ), // void* +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudioflexdesc_t ) + DEFINE_INDEX( szFACSindex, FIELD_INTEGER ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudioflexcontroller_t ) + DEFINE_INDEX( sztypeindex, FIELD_INTEGER ), + DEFINE_INDEX( sznameindex, FIELD_INTEGER ), + DEFINE_FIELD( localToGlobal, FIELD_INTEGER ), + DEFINE_FIELD( min, FIELD_FLOAT ), + DEFINE_FIELD( max, FIELD_FLOAT ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudioflexcontrollerui_t ) + DEFINE_INDEX( sznameindex, FIELD_INTEGER ), + DEFINE_INDEX( szindex0, FIELD_INTEGER ), + DEFINE_INDEX( szindex1, FIELD_INTEGER ), + DEFINE_INDEX( szindex2, FIELD_INTEGER ), + DEFINE_FIELD( remaptype, FIELD_CHARACTER ), + DEFINE_FIELD( stereo, FIELD_BOOLEAN ), + DEFINE_ARRAY( unused, FIELD_CHARACTER, 2 ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudioflexrule_t ) + DEFINE_FIELD( flex, FIELD_INTEGER ), + DEFINE_FIELD( numops, FIELD_INTEGER ), + DEFINE_INDEX( opindex, FIELD_INTEGER ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudioflexop_t ) + DEFINE_FIELD( op, FIELD_INTEGER ), + DEFINE_FIELD( d, FIELD_INTEGER ), // int/float union +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudioikchain_t ) + DEFINE_INDEX( sznameindex, FIELD_INTEGER ), + DEFINE_FIELD( linktype, FIELD_INTEGER ), + DEFINE_FIELD( numlinks, FIELD_INTEGER ), + DEFINE_INDEX( linkindex, FIELD_INTEGER ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudioiklink_t ) + DEFINE_FIELD( bone, FIELD_INTEGER ), + DEFINE_FIELD( kneeDir, FIELD_VECTOR ), + DEFINE_FIELD( unused0, FIELD_VECTOR ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudiomouth_t ) + DEFINE_FIELD( bone, FIELD_INTEGER ), + DEFINE_FIELD( forward, FIELD_VECTOR ), + DEFINE_FIELD( flexdesc, FIELD_INTEGER ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudioposeparamdesc_t ) + DEFINE_INDEX( sznameindex, FIELD_INTEGER ), + DEFINE_FIELD( flags, FIELD_INTEGER ), + DEFINE_FIELD( start, FIELD_FLOAT ), + DEFINE_FIELD( end, FIELD_FLOAT ), + DEFINE_FIELD( loop, FIELD_FLOAT ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudiomesh_t ) + DEFINE_FIELD( material, FIELD_INTEGER ), + DEFINE_INDEX( modelindex, FIELD_INTEGER ), + DEFINE_FIELD( numvertices, FIELD_INTEGER ), + DEFINE_FIELD( vertexoffset, FIELD_INTEGER ), + DEFINE_FIELD( numflexes, FIELD_INTEGER ), + DEFINE_INDEX( flexindex, FIELD_INTEGER ), + DEFINE_FIELD( materialtype, FIELD_INTEGER ), + DEFINE_FIELD( materialparam, FIELD_INTEGER ), + DEFINE_FIELD( meshid, FIELD_INTEGER ), + DEFINE_FIELD( center, FIELD_VECTOR ), + DEFINE_EMBEDDED( vertexdata ), + DEFINE_ARRAY( unused, FIELD_INTEGER, 8 ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudio_meshvertexdata_t ) + DEFINE_FIELD( modelvertexdata, FIELD_INTEGER ), // mstudio_modelvertexdata_t* + DEFINE_ARRAY( numLODVertexes, FIELD_INTEGER, MAX_NUM_LODS ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudioeyeball_t ) + DEFINE_INDEX( sznameindex, FIELD_INTEGER ), + DEFINE_FIELD( bone, FIELD_INTEGER ), + DEFINE_FIELD( org, FIELD_VECTOR ), + DEFINE_FIELD( zoffset, FIELD_FLOAT ), + DEFINE_FIELD( radius, FIELD_FLOAT ), + DEFINE_FIELD( up, FIELD_VECTOR ), + DEFINE_FIELD( forward, FIELD_VECTOR ), + DEFINE_FIELD( texture, FIELD_INTEGER ), + DEFINE_FIELD( unused1, FIELD_INTEGER ), + DEFINE_FIELD( iris_scale, FIELD_FLOAT ), + DEFINE_FIELD( unused2, FIELD_INTEGER ), + DEFINE_ARRAY( upperflexdesc, FIELD_INTEGER, 3 ), + DEFINE_ARRAY( lowerflexdesc, FIELD_INTEGER, 3 ), + DEFINE_ARRAY( uppertarget, FIELD_FLOAT, 3 ), + DEFINE_ARRAY( lowertarget, FIELD_FLOAT, 3 ), + DEFINE_FIELD( upperlidflexdesc, FIELD_INTEGER ), + DEFINE_FIELD( lowerlidflexdesc, FIELD_INTEGER ), + DEFINE_ARRAY( unused, FIELD_INTEGER, 4 ), + DEFINE_FIELD( m_bNonFACS, FIELD_BOOLEAN ), + DEFINE_ARRAY( unused3, FIELD_CHARACTER, 3 ), + DEFINE_ARRAY( unused4, FIELD_INTEGER, 7 ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudioflex_t ) + DEFINE_FIELD( flexdesc, FIELD_INTEGER ), + DEFINE_FIELD( target0, FIELD_FLOAT ), + DEFINE_FIELD( target1, FIELD_FLOAT ), + DEFINE_FIELD( target2, FIELD_FLOAT ), + DEFINE_FIELD( target3, FIELD_FLOAT ), + DEFINE_FIELD( numverts, FIELD_INTEGER ), + DEFINE_INDEX( vertindex, FIELD_INTEGER ), + DEFINE_FIELD( flexpair, FIELD_INTEGER ), + DEFINE_FIELD( vertanimtype, FIELD_CHARACTER ), + DEFINE_ARRAY( unusedchar, FIELD_CHARACTER, 3 ), + DEFINE_ARRAY( unused, FIELD_INTEGER, 6 ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudiovertanim_t ) + DEFINE_FIELD( index, FIELD_SHORT ), + DEFINE_FIELD( speed, FIELD_CHARACTER ), + DEFINE_FIELD( side, FIELD_CHARACTER ), + DEFINE_ARRAY( delta, FIELD_SHORT, 3 ), // short[3]/float16[3]union + DEFINE_ARRAY( ndelta, FIELD_SHORT, 3 ), // short[3]/float16[3] union +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudiomodelgroup_t ) + DEFINE_INDEX( szlabelindex, FIELD_INTEGER ), + DEFINE_INDEX( sznameindex, FIELD_INTEGER ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudioanimblock_t ) + DEFINE_INDEX( datastart, FIELD_INTEGER ), + DEFINE_INDEX( dataend, FIELD_INTEGER ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudiotexture_t ) + DEFINE_INDEX( sznameindex, FIELD_INTEGER ), + DEFINE_FIELD( flags, FIELD_INTEGER ), + DEFINE_FIELD( used, FIELD_INTEGER ), + DEFINE_FIELD( unused1, FIELD_INTEGER ), + DEFINE_FIELD( material, FIELD_INTEGER ), // IMaterial* + DEFINE_FIELD( clientmaterial, FIELD_INTEGER ), // void* + DEFINE_ARRAY( unused, FIELD_INTEGER, 10 ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( vertexFileHeader_t ) + DEFINE_FIELD( id, FIELD_INTEGER ), + DEFINE_FIELD( version, FIELD_INTEGER ), + DEFINE_FIELD( checksum, FIELD_INTEGER ), + DEFINE_FIELD( numLODs, FIELD_INTEGER ), + DEFINE_ARRAY( numLODVertexes, FIELD_INTEGER, MAX_NUM_LODS ), + DEFINE_FIELD( numFixups, FIELD_INTEGER ), + DEFINE_FIELD( fixupTableStart, FIELD_INTEGER ), + DEFINE_FIELD( vertexDataStart, FIELD_INTEGER ), + DEFINE_FIELD( tangentDataStart, FIELD_INTEGER ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( vertexFileFixup_t ) + DEFINE_FIELD( lod, FIELD_INTEGER ), + DEFINE_FIELD( sourceVertexID, FIELD_INTEGER ), + DEFINE_FIELD( numVertexes, FIELD_INTEGER ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudioboneweight_t ) + DEFINE_ARRAY( weight, FIELD_FLOAT, MAX_NUM_BONES_PER_VERT ), + DEFINE_ARRAY( bone, FIELD_CHARACTER, MAX_NUM_BONES_PER_VERT ), + DEFINE_FIELD( numbones, FIELD_CHARACTER ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( mstudiovertex_t ) + DEFINE_EMBEDDED( m_BoneWeights ), + DEFINE_FIELD( m_vecPosition, FIELD_VECTOR ), + DEFINE_FIELD( m_vecNormal, FIELD_VECTOR ), + DEFINE_ARRAY( m_vecTexCoord, FIELD_FLOAT, 2 ), +END_BYTESWAP_DATADESC() + +// Data descriptions from OptimizedModel.h +namespace OptimizedModel +{ + +BEGIN_BYTESWAP_DATADESC( BoneStateChangeHeader_t ) + DEFINE_FIELD( hardwareID, FIELD_INTEGER ), + DEFINE_FIELD( newBoneID, FIELD_INTEGER ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( Vertex_t ) + DEFINE_ARRAY( boneWeightIndex, FIELD_CHARACTER, MAX_NUM_BONES_PER_VERT ), + DEFINE_FIELD( numBones, FIELD_CHARACTER ), + DEFINE_FIELD( origMeshVertID, FIELD_SHORT ), + DEFINE_ARRAY( boneID, FIELD_CHARACTER, MAX_NUM_BONES_PER_VERT ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( StripHeader_t ) + DEFINE_FIELD( numIndices, FIELD_INTEGER ), + DEFINE_FIELD( indexOffset, FIELD_INTEGER ), + DEFINE_FIELD( numVerts, FIELD_INTEGER ), + DEFINE_FIELD( vertOffset, FIELD_INTEGER ), + DEFINE_FIELD( numBones, FIELD_SHORT ), + DEFINE_FIELD( flags, FIELD_CHARACTER ), + DEFINE_FIELD( numBoneStateChanges, FIELD_INTEGER ), + DEFINE_FIELD( boneStateChangeOffset, FIELD_INTEGER ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( StripGroupHeader_t ) + DEFINE_FIELD( numVerts, FIELD_INTEGER ), + DEFINE_FIELD( vertOffset, FIELD_INTEGER ), + DEFINE_FIELD( numIndices, FIELD_INTEGER ), + DEFINE_FIELD( indexOffset, FIELD_INTEGER ), + DEFINE_FIELD( numStrips, FIELD_INTEGER ), + DEFINE_FIELD( stripOffset, FIELD_INTEGER ), + DEFINE_FIELD( flags, FIELD_CHARACTER ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( MeshHeader_t ) + DEFINE_FIELD( numStripGroups, FIELD_INTEGER ), + DEFINE_FIELD( stripGroupHeaderOffset, FIELD_INTEGER ), + DEFINE_FIELD( flags, FIELD_CHARACTER ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( ModelLODHeader_t ) + DEFINE_FIELD( numMeshes, FIELD_INTEGER ), + DEFINE_FIELD( meshOffset, FIELD_INTEGER ), + DEFINE_FIELD( switchPoint, FIELD_FLOAT ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( ModelHeader_t ) + DEFINE_FIELD( numLODs, FIELD_INTEGER ), + DEFINE_FIELD( lodOffset, FIELD_INTEGER ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( BodyPartHeader_t ) + DEFINE_FIELD( numModels, FIELD_INTEGER ), + DEFINE_FIELD( modelOffset, FIELD_INTEGER ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( MaterialReplacementHeader_t ) + DEFINE_FIELD( materialID, FIELD_SHORT ), + DEFINE_FIELD( replacementMaterialNameOffset, FIELD_INTEGER ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( MaterialReplacementListHeader_t ) + DEFINE_FIELD( numReplacements, FIELD_INTEGER ), + DEFINE_FIELD( replacementOffset, FIELD_INTEGER ), +END_BYTESWAP_DATADESC() + +BEGIN_BYTESWAP_DATADESC( FileHeader_t ) + DEFINE_FIELD( version, FIELD_INTEGER ), + DEFINE_FIELD( vertCacheSize, FIELD_INTEGER ), + DEFINE_FIELD( maxBonesPerStrip, FIELD_SHORT ), + DEFINE_FIELD( maxBonesPerTri, FIELD_SHORT ), + DEFINE_FIELD( maxBonesPerVert, FIELD_INTEGER ), + DEFINE_FIELD( checkSum, FIELD_INTEGER ), + DEFINE_FIELD( numLODs, FIELD_INTEGER ), + DEFINE_FIELD( materialReplacementListOffset, FIELD_INTEGER ), + DEFINE_FIELD( numBodyParts, FIELD_INTEGER ), + DEFINE_FIELD( bodyPartOffset, FIELD_INTEGER ), +END_BYTESWAP_DATADESC() + +} // namespace OptimizedModel + +// Data descriptions from phyfile.h +BEGIN_BYTESWAP_DATADESC( phyheader_t ) + DEFINE_FIELD( size, FIELD_INTEGER ), + DEFINE_FIELD( id, FIELD_INTEGER ), + DEFINE_FIELD( solidCount, FIELD_INTEGER ), + DEFINE_FIELD( checkSum, FIELD_INTEGER ), +END_BYTESWAP_DATADESC() diff --git a/mp/src/common/studiobyteswap.h b/mp/src/common/studiobyteswap.h index 20e8d47b..3bec9eaf 100644 --- a/mp/src/common/studiobyteswap.h +++ b/mp/src/common/studiobyteswap.h @@ -1,38 +1,38 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose: StudioMDL byteswapping functions.
-//
-// $NoKeywords: $
-//=============================================================================
-#ifndef STUDIOBYTESWAP_H
-#define STUDIOBYTESWAP_H
-
-#if defined(_WIN32)
-#pragma once
-#endif
-
-#include "byteswap.h"
-struct studiohdr_t;
-class IPhysicsCollision;
-
-namespace StudioByteSwap
-{
-typedef bool (*CompressFunc_t)( const void *pInput, int inputSize, void **pOutput, int *pOutputSize );
-
-//void SetTargetBigEndian( bool bigEndian );
-void ActivateByteSwapping( bool bActivate );
-void SourceIsNative( bool bActivate );
-void SetVerbose( bool bVerbose );
-void SetCollisionInterface( IPhysicsCollision *pPhysicsCollision );
-
-int ByteswapStudioFile( const char *pFilename, void *pOutBase, const void *pFileBase, int fileSize, studiohdr_t *pHdr, CompressFunc_t pCompressFunc = NULL );
-int ByteswapPHY( void *pOutBase, const void *pFileBase, int fileSize );
-int ByteswapANI( studiohdr_t* pHdr, void *pOutBase, const void *pFileBase, int filesize );
-int ByteswapVVD( void *pOutBase, const void *pFileBase, int fileSize );
-int ByteswapVTX( void *pOutBase, const void *pFileBase, int fileSize );
-int ByteswapMDL( void *pOutBase, const void *pFileBase, int fileSize );
-
-#define BYTESWAP_ALIGNMENT_PADDING 4096
-}
-
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: StudioMDL byteswapping functions. +// +// $NoKeywords: $ +//============================================================================= +#ifndef STUDIOBYTESWAP_H +#define STUDIOBYTESWAP_H + +#if defined(_WIN32) +#pragma once +#endif + +#include "byteswap.h" +struct studiohdr_t; +class IPhysicsCollision; + +namespace StudioByteSwap +{ +typedef bool (*CompressFunc_t)( const void *pInput, int inputSize, void **pOutput, int *pOutputSize ); + +//void SetTargetBigEndian( bool bigEndian ); +void ActivateByteSwapping( bool bActivate ); +void SourceIsNative( bool bActivate ); +void SetVerbose( bool bVerbose ); +void SetCollisionInterface( IPhysicsCollision *pPhysicsCollision ); + +int ByteswapStudioFile( const char *pFilename, void *pOutBase, const void *pFileBase, int fileSize, studiohdr_t *pHdr, CompressFunc_t pCompressFunc = NULL ); +int ByteswapPHY( void *pOutBase, const void *pFileBase, int fileSize ); +int ByteswapANI( studiohdr_t* pHdr, void *pOutBase, const void *pFileBase, int filesize ); +int ByteswapVVD( void *pOutBase, const void *pFileBase, int fileSize ); +int ByteswapVTX( void *pOutBase, const void *pFileBase, int fileSize ); +int ByteswapMDL( void *pOutBase, const void *pFileBase, int fileSize ); + +#define BYTESWAP_ALIGNMENT_PADDING 4096 +} + #endif // STUDIOBYTESWAP_H
\ No newline at end of file diff --git a/mp/src/common/userid.h b/mp/src/common/userid.h index 48968a44..7882bc0b 100644 --- a/mp/src/common/userid.h +++ b/mp/src/common/userid.h @@ -1,35 +1,35 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-// $NoKeywords: $
-//=============================================================================//
-
-#ifndef USERID_H
-#define USERID_H
-#ifdef _WIN32
-#pragma once
-#endif
-
-#if !defined( INCLUDED_STEAM_STEAMUSERIDTYPES_H )
- #include "SteamCommon.h"
-#endif
-
-#define IDTYPE_WON 0
-#define IDTYPE_STEAM 1
-#define IDTYPE_VALVE 2
-#define IDTYPE_HLTV 3
-#define IDTYPE_REPLAY 4
-typedef struct USERID_s
-{
- int idtype;
-
- union
- {
- TSteamGlobalUserID steamid;
- } uid;
-
-// unsigned int clientip;
-} USERID_t;
-
-#endif // USERID_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +//=============================================================================// + +#ifndef USERID_H +#define USERID_H +#ifdef _WIN32 +#pragma once +#endif + +#if !defined( INCLUDED_STEAM_STEAMUSERIDTYPES_H ) + #include "SteamCommon.h" +#endif + +#define IDTYPE_WON 0 +#define IDTYPE_STEAM 1 +#define IDTYPE_VALVE 2 +#define IDTYPE_HLTV 3 +#define IDTYPE_REPLAY 4 +typedef struct USERID_s +{ + int idtype; + + union + { + TSteamGlobalUserID steamid; + } uid; + +// unsigned int clientip; +} USERID_t; + +#endif // USERID_H diff --git a/mp/src/common/xbox/xboxstubs.h b/mp/src/common/xbox/xboxstubs.h index 0e375fb9..fa3448f5 100644 --- a/mp/src/common/xbox/xboxstubs.h +++ b/mp/src/common/xbox/xboxstubs.h @@ -1,237 +1,237 @@ -//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose: Win32 replacements for XBox.
-//
-//=============================================================================
-
-#if !defined( XBOXSTUBS_H ) && !defined( _X360 )
-#define XBOXSTUBS_H
-
-#ifdef _WIN32
-#pragma once
-#endif
-
-#include "tier0/platform.h"
-
-// Content creation/open flags
-#define XCONTENTFLAG_NONE 0x00
-#define XCONTENTFLAG_CREATENEW 0x00
-#define XCONTENTFLAG_CREATEALWAYS 0x00
-#define XCONTENTFLAG_OPENEXISTING 0x00
-#define XCONTENTFLAG_OPENALWAYS 0x00
-#define XCONTENTFLAG_TRUNCATEEXISTING 0x00
-
-// Content attributes
-#define XCONTENTFLAG_NOPROFILE_TRANSFER 0x00
-#define XCONTENTFLAG_NODEVICE_TRANSFER 0x00
-#define XCONTENTFLAG_STRONG_SIGNED 0x00
-#define XCONTENTFLAG_ALLOWPROFILE_TRANSFER 0x00
-#define XCONTENTFLAG_MOVEONLY_TRANSFER 0x00
-
-// Console device ports
-#define XDEVICE_PORT0 0
-#define XDEVICE_PORT1 1
-#define XDEVICE_PORT2 2
-#define XDEVICE_PORT3 3
-#define XUSER_MAX_COUNT 4
-#define XUSER_INDEX_NONE 0x000000FE
-
-#define XBX_CLR_DEFAULT 0xFF000000
-#define XBX_CLR_WARNING 0x0000FFFF
-#define XBX_CLR_ERROR 0x000000FF
-
-#define XBOX_MINBORDERSAFE 0
-#define XBOX_MAXBORDERSAFE 0
-
-typedef enum
-{
- XK_NULL,
- XK_BUTTON_UP,
- XK_BUTTON_DOWN,
- XK_BUTTON_LEFT,
- XK_BUTTON_RIGHT,
- XK_BUTTON_START,
- XK_BUTTON_BACK,
- XK_BUTTON_STICK1,
- XK_BUTTON_STICK2,
- XK_BUTTON_A,
- XK_BUTTON_B,
- XK_BUTTON_X,
- XK_BUTTON_Y,
- XK_BUTTON_LEFT_SHOULDER,
- XK_BUTTON_RIGHT_SHOULDER,
- XK_BUTTON_LTRIGGER,
- XK_BUTTON_RTRIGGER,
- XK_STICK1_UP,
- XK_STICK1_DOWN,
- XK_STICK1_LEFT,
- XK_STICK1_RIGHT,
- XK_STICK2_UP,
- XK_STICK2_DOWN,
- XK_STICK2_LEFT,
- XK_STICK2_RIGHT,
- XK_MAX_KEYS,
-} xKey_t;
-
-//typedef enum
-//{
-// XVRB_NONE, // off
-// XVRB_ERROR, // fatal error
-// XVRB_ALWAYS, // no matter what
-// XVRB_WARNING, // non-fatal warnings
-// XVRB_STATUS, // status reports
-// XVRB_ALL,
-//} xverbose_e;
-
-typedef unsigned short WORD;
-#ifndef POSIX
-typedef unsigned long DWORD;
-typedef void* HANDLE;
-typedef unsigned __int64 ULONGLONG;
-#endif
-
-#ifdef POSIX
-typedef DWORD COLORREF;
-#endif
-
-#ifndef INVALID_HANDLE_VALUE
-#define INVALID_HANDLE_VALUE ((HANDLE)-1)
-#endif
-
-// typedef struct {
-// IN_ADDR ina; // IP address (zero if not static/DHCP)
-// IN_ADDR inaOnline; // Online IP address (zero if not online)
-// WORD wPortOnline; // Online port
-// BYTE abEnet[6]; // Ethernet MAC address
-// BYTE abOnline[20]; // Online identification
-// } XNADDR;
-
-typedef int XNADDR;
-typedef uint64 XUID;
-
-typedef struct {
- BYTE ab[8]; // xbox to xbox key identifier
-} XNKID;
-
-typedef struct {
- BYTE ab[16]; // xbox to xbox key exchange key
-} XNKEY;
-
-typedef struct _XSESSION_INFO
-{
- XNKID sessionID; // 8 bytes
- XNADDR hostAddress; // 36 bytes
- XNKEY keyExchangeKey; // 16 bytes
-} XSESSION_INFO, *PXSESSION_INFO;
-
-typedef struct _XUSER_DATA
-{
- BYTE type;
-
- union
- {
- int nData; // XUSER_DATA_TYPE_INT32
- int64 i64Data; // XUSER_DATA_TYPE_INT64
- double dblData; // XUSER_DATA_TYPE_DOUBLE
- struct // XUSER_DATA_TYPE_UNICODE
- {
- uint cbData; // Includes null-terminator
- char * pwszData;
- } string;
- float fData; // XUSER_DATA_TYPE_FLOAT
- struct // XUSER_DATA_TYPE_BINARY
- {
- uint cbData;
- char * pbData;
- } binary;
- };
-} XUSER_DATA, *PXUSER_DATA;
-
-typedef struct _XUSER_PROPERTY
-{
- DWORD dwPropertyId;
- XUSER_DATA value;
-} XUSER_PROPERTY, *PXUSER_PROPERTY;
-
-typedef struct _XUSER_CONTEXT
-{
- DWORD dwContextId;
- DWORD dwValue;
-} XUSER_CONTEXT, *PXUSER_CONTEXT;
-
-typedef struct _XSESSION_SEARCHRESULT
-{
- XSESSION_INFO info;
- DWORD dwOpenPublicSlots;
- DWORD dwOpenPrivateSlots;
- DWORD dwFilledPublicSlots;
- DWORD dwFilledPrivateSlots;
- DWORD cProperties;
- DWORD cContexts;
- PXUSER_PROPERTY pProperties;
- PXUSER_CONTEXT pContexts;
-} XSESSION_SEARCHRESULT, *PXSESSION_SEARCHRESULT;
-
-typedef struct _XSESSION_SEARCHRESULT_HEADER
-{
- DWORD dwSearchResults;
- XSESSION_SEARCHRESULT *pResults;
-} XSESSION_SEARCHRESULT_HEADER, *PXSESSION_SEARCHRESULT_HEADER;
-
-typedef struct _XSESSION_REGISTRANT
-{
- uint64 qwMachineID;
- DWORD bTrustworthiness;
- DWORD bNumUsers;
- XUID *rgUsers;
-
-} XSESSION_REGISTRANT;
-
-typedef struct _XSESSION_REGISTRATION_RESULTS
-{
- DWORD wNumRegistrants;
- XSESSION_REGISTRANT *rgRegistrants;
-} XSESSION_REGISTRATION_RESULTS, *PXSESSION_REGISTRATION_RESULTS;
-
-typedef struct {
- BYTE bFlags;
- BYTE bReserved;
- WORD cProbesXmit;
- WORD cProbesRecv;
- WORD cbData;
- BYTE * pbData;
- WORD wRttMinInMsecs;
- WORD wRttMedInMsecs;
- DWORD dwUpBitsPerSec;
- DWORD dwDnBitsPerSec;
-} XNQOSINFO;
-
-typedef struct {
- uint cxnqos;
- uint cxnqosPending;
- XNQOSINFO axnqosinfo[1];
-} XNQOS;
-
-#define XSESSION_CREATE_HOST 0
-#define XUSER_DATA_TYPE_INT32 0
-#define XSESSION_CREATE_USES_ARBITRATION 0
-#define XNET_QOS_LISTEN_ENABLE 0
-#define XNET_QOS_LISTEN_DISABLE 0
-#define XNET_QOS_LISTEN_SET_DATA 0
-
-FORCEINLINE void XBX_ProcessEvents() {}
-FORCEINLINE unsigned int XBX_GetSystemTime() { return 0; }
-FORCEINLINE int XBX_GetPrimaryUserId() { return 0; }
-FORCEINLINE void XBX_SetPrimaryUserId( DWORD idx ) {}
-FORCEINLINE int XBX_GetStorageDeviceId() { return 0; }
-FORCEINLINE void XBX_SetStorageDeviceId( DWORD idx ) {}
-FORCEINLINE const char *XBX_GetLanguageString() { return ""; }
-FORCEINLINE bool XBX_IsLocalized() { return false; }
-
-#define XCONTENT_MAX_DISPLAYNAME_LENGTH 128
-#define XCONTENT_MAX_FILENAME_LENGTH 42
-
-#define XBX_INVALID_STORAGE_ID ((DWORD) -1)
-#define XBX_STORAGE_DECLINED ((DWORD) -2)
-
-#endif // XBOXSTUBS_H
+//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Win32 replacements for XBox. +// +//============================================================================= + +#if !defined( XBOXSTUBS_H ) && !defined( _X360 ) +#define XBOXSTUBS_H + +#ifdef _WIN32 +#pragma once +#endif + +#include "tier0/platform.h" + +// Content creation/open flags +#define XCONTENTFLAG_NONE 0x00 +#define XCONTENTFLAG_CREATENEW 0x00 +#define XCONTENTFLAG_CREATEALWAYS 0x00 +#define XCONTENTFLAG_OPENEXISTING 0x00 +#define XCONTENTFLAG_OPENALWAYS 0x00 +#define XCONTENTFLAG_TRUNCATEEXISTING 0x00 + +// Content attributes +#define XCONTENTFLAG_NOPROFILE_TRANSFER 0x00 +#define XCONTENTFLAG_NODEVICE_TRANSFER 0x00 +#define XCONTENTFLAG_STRONG_SIGNED 0x00 +#define XCONTENTFLAG_ALLOWPROFILE_TRANSFER 0x00 +#define XCONTENTFLAG_MOVEONLY_TRANSFER 0x00 + +// Console device ports +#define XDEVICE_PORT0 0 +#define XDEVICE_PORT1 1 +#define XDEVICE_PORT2 2 +#define XDEVICE_PORT3 3 +#define XUSER_MAX_COUNT 4 +#define XUSER_INDEX_NONE 0x000000FE + +#define XBX_CLR_DEFAULT 0xFF000000 +#define XBX_CLR_WARNING 0x0000FFFF +#define XBX_CLR_ERROR 0x000000FF + +#define XBOX_MINBORDERSAFE 0 +#define XBOX_MAXBORDERSAFE 0 + +typedef enum +{ + XK_NULL, + XK_BUTTON_UP, + XK_BUTTON_DOWN, + XK_BUTTON_LEFT, + XK_BUTTON_RIGHT, + XK_BUTTON_START, + XK_BUTTON_BACK, + XK_BUTTON_STICK1, + XK_BUTTON_STICK2, + XK_BUTTON_A, + XK_BUTTON_B, + XK_BUTTON_X, + XK_BUTTON_Y, + XK_BUTTON_LEFT_SHOULDER, + XK_BUTTON_RIGHT_SHOULDER, + XK_BUTTON_LTRIGGER, + XK_BUTTON_RTRIGGER, + XK_STICK1_UP, + XK_STICK1_DOWN, + XK_STICK1_LEFT, + XK_STICK1_RIGHT, + XK_STICK2_UP, + XK_STICK2_DOWN, + XK_STICK2_LEFT, + XK_STICK2_RIGHT, + XK_MAX_KEYS, +} xKey_t; + +//typedef enum +//{ +// XVRB_NONE, // off +// XVRB_ERROR, // fatal error +// XVRB_ALWAYS, // no matter what +// XVRB_WARNING, // non-fatal warnings +// XVRB_STATUS, // status reports +// XVRB_ALL, +//} xverbose_e; + +typedef unsigned short WORD; +#ifndef POSIX +typedef unsigned long DWORD; +typedef void* HANDLE; +typedef unsigned __int64 ULONGLONG; +#endif + +#ifdef POSIX +typedef DWORD COLORREF; +#endif + +#ifndef INVALID_HANDLE_VALUE +#define INVALID_HANDLE_VALUE ((HANDLE)-1) +#endif + +// typedef struct { +// IN_ADDR ina; // IP address (zero if not static/DHCP) +// IN_ADDR inaOnline; // Online IP address (zero if not online) +// WORD wPortOnline; // Online port +// BYTE abEnet[6]; // Ethernet MAC address +// BYTE abOnline[20]; // Online identification +// } XNADDR; + +typedef int XNADDR; +typedef uint64 XUID; + +typedef struct { + BYTE ab[8]; // xbox to xbox key identifier +} XNKID; + +typedef struct { + BYTE ab[16]; // xbox to xbox key exchange key +} XNKEY; + +typedef struct _XSESSION_INFO +{ + XNKID sessionID; // 8 bytes + XNADDR hostAddress; // 36 bytes + XNKEY keyExchangeKey; // 16 bytes +} XSESSION_INFO, *PXSESSION_INFO; + +typedef struct _XUSER_DATA +{ + BYTE type; + + union + { + int nData; // XUSER_DATA_TYPE_INT32 + int64 i64Data; // XUSER_DATA_TYPE_INT64 + double dblData; // XUSER_DATA_TYPE_DOUBLE + struct // XUSER_DATA_TYPE_UNICODE + { + uint cbData; // Includes null-terminator + char * pwszData; + } string; + float fData; // XUSER_DATA_TYPE_FLOAT + struct // XUSER_DATA_TYPE_BINARY + { + uint cbData; + char * pbData; + } binary; + }; +} XUSER_DATA, *PXUSER_DATA; + +typedef struct _XUSER_PROPERTY +{ + DWORD dwPropertyId; + XUSER_DATA value; +} XUSER_PROPERTY, *PXUSER_PROPERTY; + +typedef struct _XUSER_CONTEXT +{ + DWORD dwContextId; + DWORD dwValue; +} XUSER_CONTEXT, *PXUSER_CONTEXT; + +typedef struct _XSESSION_SEARCHRESULT +{ + XSESSION_INFO info; + DWORD dwOpenPublicSlots; + DWORD dwOpenPrivateSlots; + DWORD dwFilledPublicSlots; + DWORD dwFilledPrivateSlots; + DWORD cProperties; + DWORD cContexts; + PXUSER_PROPERTY pProperties; + PXUSER_CONTEXT pContexts; +} XSESSION_SEARCHRESULT, *PXSESSION_SEARCHRESULT; + +typedef struct _XSESSION_SEARCHRESULT_HEADER +{ + DWORD dwSearchResults; + XSESSION_SEARCHRESULT *pResults; +} XSESSION_SEARCHRESULT_HEADER, *PXSESSION_SEARCHRESULT_HEADER; + +typedef struct _XSESSION_REGISTRANT +{ + uint64 qwMachineID; + DWORD bTrustworthiness; + DWORD bNumUsers; + XUID *rgUsers; + +} XSESSION_REGISTRANT; + +typedef struct _XSESSION_REGISTRATION_RESULTS +{ + DWORD wNumRegistrants; + XSESSION_REGISTRANT *rgRegistrants; +} XSESSION_REGISTRATION_RESULTS, *PXSESSION_REGISTRATION_RESULTS; + +typedef struct { + BYTE bFlags; + BYTE bReserved; + WORD cProbesXmit; + WORD cProbesRecv; + WORD cbData; + BYTE * pbData; + WORD wRttMinInMsecs; + WORD wRttMedInMsecs; + DWORD dwUpBitsPerSec; + DWORD dwDnBitsPerSec; +} XNQOSINFO; + +typedef struct { + uint cxnqos; + uint cxnqosPending; + XNQOSINFO axnqosinfo[1]; +} XNQOS; + +#define XSESSION_CREATE_HOST 0 +#define XUSER_DATA_TYPE_INT32 0 +#define XSESSION_CREATE_USES_ARBITRATION 0 +#define XNET_QOS_LISTEN_ENABLE 0 +#define XNET_QOS_LISTEN_DISABLE 0 +#define XNET_QOS_LISTEN_SET_DATA 0 + +FORCEINLINE void XBX_ProcessEvents() {} +FORCEINLINE unsigned int XBX_GetSystemTime() { return 0; } +FORCEINLINE int XBX_GetPrimaryUserId() { return 0; } +FORCEINLINE void XBX_SetPrimaryUserId( DWORD idx ) {} +FORCEINLINE int XBX_GetStorageDeviceId() { return 0; } +FORCEINLINE void XBX_SetStorageDeviceId( DWORD idx ) {} +FORCEINLINE const char *XBX_GetLanguageString() { return ""; } +FORCEINLINE bool XBX_IsLocalized() { return false; } + +#define XCONTENT_MAX_DISPLAYNAME_LENGTH 128 +#define XCONTENT_MAX_FILENAME_LENGTH 42 + +#define XBX_INVALID_STORAGE_ID ((DWORD) -1) +#define XBX_STORAGE_DECLINED ((DWORD) -2) + +#endif // XBOXSTUBS_H |