//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
// $NoKeywords: $
//
//=============================================================================//
#include "cbase.h"
#include "ai_activity.h"
#include "activitylist.h"
#include "stringregistry.h"
#include "isaverestore.h"

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"

// NOTE: If CStringRegistry allowed storing arbitrary data, we could just use that.
// in this case we have the "isPrivate" member and the replacement rules 
// (activityIndex can be reused by private activities), so a custom table is necessary
struct activitylist_t
{
	int					activityIndex;
	unsigned short		stringKey;
	short				isPrivate;
};

CUtlVector<activitylist_t> g_ActivityList;

// This stores the actual activity names.  Also, the string ID in the registry is simply an index 
// into the g_ActivityList array.
CStringRegistry	g_ActivityStrings;

// this is just here to accelerate adds
static int g_HighestActivity = 0;

int g_nActivityListVersion = 1;


void ActivityList_Init( void )
{
	g_HighestActivity = 0;
}

void ActivityList_Free( void )
{
	g_ActivityStrings.ClearStrings();
	g_ActivityList.Purge();

	// So studiohdrs can reindex activity indices
	++g_nActivityListVersion;
}

// add a new activity to the database
activitylist_t *ActivityList_AddActivityEntry( const char *pName, int iActivityIndex, bool isPrivate )
{
	int index = g_ActivityList.AddToTail();
	activitylist_t *pList = &g_ActivityList[index];
	pList->activityIndex = iActivityIndex;
	pList->stringKey = g_ActivityStrings.AddString( pName, index );
	pList->isPrivate = isPrivate;
	
	// UNDONE: This implies that ALL shared activities are added before ANY custom activities
	// UNDONE: Segment these instead?  It's a 32-bit int, how many activities do we need?
	if ( iActivityIndex > g_HighestActivity )
	{
		g_HighestActivity = iActivityIndex;
	}

	return pList;
}

// get the database entry from a string
static activitylist_t *ListFromString( const char *pString )
{
	// just use the string registry to do this search/map
	int stringID = g_ActivityStrings.GetStringID( pString );
	if ( stringID < 0 )
		return NULL;

	return &g_ActivityList[stringID];
}

// Get the database entry for an index
static activitylist_t *ListFromActivity( int activityIndex )
{
	// ugly linear search
	for ( int i = 0; i < g_ActivityList.Size(); i++ )
	{
		if ( g_ActivityList[i].activityIndex == activityIndex )
		{
			return &g_ActivityList[i];
		}
	}

	return NULL;
}

bool ActivityList_RegisterSharedActivity( const char *pszActivityName, int iActivityIndex )
{
	// UNDONE: Do we want to do these checks when not in developer mode? or maybe DEBUG only?
	// They really only matter when you change the list of code controlled activities.  IDs
	// for content controlled activities never collide because they are generated.

	// technically order isn't dependent, but it's too damn easy to forget to add new ACT_'s to all three lists.
	static int lastActivityIndex = -1;
	Assert( iActivityIndex < LAST_SHARED_ACTIVITY && (iActivityIndex == lastActivityIndex + 1 || iActivityIndex == 0) );
	lastActivityIndex = iActivityIndex;

	// first, check to make sure the slot we're asking for is free. It must be for 
	// a shared activity.
	activitylist_t *pList = ListFromString( pszActivityName );
	if ( !pList )
	{
		pList = ListFromActivity( iActivityIndex );
	}

	if ( pList )
	{
		Warning( "***\nShared activity collision! %s<->%s\n***\n", pszActivityName, g_ActivityStrings.GetStringForKey( pList->stringKey ) );
		Assert(0);
		return false;
	}
	// ----------------------------------------------------------------

	ActivityList_AddActivityEntry( pszActivityName, iActivityIndex, false );
	return true;
}


Activity ActivityList_RegisterPrivateActivity( const char *pszActivityName )
{
	activitylist_t *pList = ListFromString( pszActivityName );
	if ( pList )
	{
		// this activity is already in the list. If the activity we collided with is also private, 
		// then the collision is OK. Otherwise, it's a bug.
		if ( pList->isPrivate )
		{
			return (Activity)pList->activityIndex;
		}
		else
		{
			// this private activity collides with a shared activity. That is not allowed.
			Warning( "***\nShared<->Private Activity collision!\n***\n" );
			Assert(0);
			return ACT_INVALID;
		}
	}

	pList = ActivityList_AddActivityEntry( pszActivityName, g_HighestActivity+1, true );
	return (Activity)pList->activityIndex;
}

// Get the index for a given activity name
// Done at load time for all models
int ActivityList_IndexForName( const char *pszActivityName )
{
	// this is a fast O(lgn) search (actually does 2 O(lgn) searches)
	activitylist_t *pList = ListFromString( pszActivityName );

	if ( pList )
	{
		return pList->activityIndex;
	}

	return -1;
}

// Get the name for a given index
// This should only be used in debug code, it does a linear search
// But at least it only compares integers
const char *ActivityList_NameForIndex( int activityIndex )
{
	activitylist_t *pList = ListFromActivity( activityIndex );
	if ( pList )
	{
		return g_ActivityStrings.GetStringForKey( pList->stringKey );
	}
	return NULL;
}

void ActivityList_RegisterSharedActivities( void )
{
	REGISTER_SHARED_ACTIVITY( ACT_RESET );
	REGISTER_SHARED_ACTIVITY( ACT_IDLE );
	REGISTER_SHARED_ACTIVITY( ACT_TRANSITION );
	REGISTER_SHARED_ACTIVITY( ACT_COVER );
	REGISTER_SHARED_ACTIVITY( ACT_COVER_MED );
	REGISTER_SHARED_ACTIVITY( ACT_COVER_LOW );
	REGISTER_SHARED_ACTIVITY( ACT_WALK );
	REGISTER_SHARED_ACTIVITY( ACT_WALK_AIM );
	REGISTER_SHARED_ACTIVITY( ACT_WALK_CROUCH );
	REGISTER_SHARED_ACTIVITY( ACT_WALK_CROUCH_AIM );
	REGISTER_SHARED_ACTIVITY( ACT_RUN );
	REGISTER_SHARED_ACTIVITY( ACT_RUN_AIM );
	REGISTER_SHARED_ACTIVITY( ACT_RUN_CROUCH );
	REGISTER_SHARED_ACTIVITY( ACT_RUN_CROUCH_AIM );
	REGISTER_SHARED_ACTIVITY( ACT_RUN_PROTECTED );
	REGISTER_SHARED_ACTIVITY( ACT_SCRIPT_CUSTOM_MOVE );
	REGISTER_SHARED_ACTIVITY( ACT_RANGE_ATTACK1 );
	REGISTER_SHARED_ACTIVITY( ACT_RANGE_ATTACK2 );
	REGISTER_SHARED_ACTIVITY( ACT_RANGE_ATTACK1_LOW );
	REGISTER_SHARED_ACTIVITY( ACT_RANGE_ATTACK2_LOW );
	REGISTER_SHARED_ACTIVITY( ACT_DIESIMPLE );
	REGISTER_SHARED_ACTIVITY( ACT_DIEBACKWARD );
	REGISTER_SHARED_ACTIVITY( ACT_DIEFORWARD );
	REGISTER_SHARED_ACTIVITY( ACT_DIEVIOLENT );
	REGISTER_SHARED_ACTIVITY( ACT_DIERAGDOLL );
	REGISTER_SHARED_ACTIVITY( ACT_FLY );
	REGISTER_SHARED_ACTIVITY( ACT_HOVER );
	REGISTER_SHARED_ACTIVITY( ACT_GLIDE );
	REGISTER_SHARED_ACTIVITY( ACT_SWIM );
	REGISTER_SHARED_ACTIVITY( ACT_JUMP );
	REGISTER_SHARED_ACTIVITY( ACT_HOP );
	REGISTER_SHARED_ACTIVITY( ACT_LEAP );
	REGISTER_SHARED_ACTIVITY( ACT_LAND );
	REGISTER_SHARED_ACTIVITY( ACT_CLIMB_UP );
	REGISTER_SHARED_ACTIVITY( ACT_CLIMB_DOWN );
	REGISTER_SHARED_ACTIVITY( ACT_CLIMB_DISMOUNT );
	REGISTER_SHARED_ACTIVITY( ACT_SHIPLADDER_UP );
	REGISTER_SHARED_ACTIVITY( ACT_SHIPLADDER_DOWN );
	REGISTER_SHARED_ACTIVITY( ACT_STRAFE_LEFT );
	REGISTER_SHARED_ACTIVITY( ACT_STRAFE_RIGHT );
	REGISTER_SHARED_ACTIVITY( ACT_ROLL_LEFT );
	REGISTER_SHARED_ACTIVITY( ACT_ROLL_RIGHT );
	REGISTER_SHARED_ACTIVITY( ACT_TURN_LEFT );
	REGISTER_SHARED_ACTIVITY( ACT_TURN_RIGHT );
	REGISTER_SHARED_ACTIVITY( ACT_CROUCH );
	REGISTER_SHARED_ACTIVITY( ACT_CROUCHIDLE );
	REGISTER_SHARED_ACTIVITY( ACT_STAND );
	REGISTER_SHARED_ACTIVITY( ACT_USE );
	REGISTER_SHARED_ACTIVITY( ACT_SIGNAL1 );
	REGISTER_SHARED_ACTIVITY( ACT_SIGNAL2 );
	REGISTER_SHARED_ACTIVITY( ACT_SIGNAL3 );

	REGISTER_SHARED_ACTIVITY( ACT_SIGNAL_ADVANCE );
	REGISTER_SHARED_ACTIVITY( ACT_SIGNAL_FORWARD );
	REGISTER_SHARED_ACTIVITY( ACT_SIGNAL_GROUP );
	REGISTER_SHARED_ACTIVITY( ACT_SIGNAL_HALT );
	REGISTER_SHARED_ACTIVITY( ACT_SIGNAL_LEFT );
	REGISTER_SHARED_ACTIVITY( ACT_SIGNAL_RIGHT );
	REGISTER_SHARED_ACTIVITY( ACT_SIGNAL_TAKECOVER );

	REGISTER_SHARED_ACTIVITY( ACT_LOOKBACK_RIGHT );
	REGISTER_SHARED_ACTIVITY( ACT_LOOKBACK_LEFT );
	REGISTER_SHARED_ACTIVITY( ACT_COWER );
	REGISTER_SHARED_ACTIVITY( ACT_SMALL_FLINCH );
	REGISTER_SHARED_ACTIVITY( ACT_BIG_FLINCH );
	REGISTER_SHARED_ACTIVITY( ACT_MELEE_ATTACK1 );
	REGISTER_SHARED_ACTIVITY( ACT_MELEE_ATTACK2 );
	REGISTER_SHARED_ACTIVITY( ACT_RELOAD );
	REGISTER_SHARED_ACTIVITY( ACT_RELOAD_LOW );
	REGISTER_SHARED_ACTIVITY( ACT_ARM );
	REGISTER_SHARED_ACTIVITY( ACT_DISARM );
	REGISTER_SHARED_ACTIVITY( ACT_PICKUP_GROUND );
	REGISTER_SHARED_ACTIVITY( ACT_PICKUP_RACK );
	REGISTER_SHARED_ACTIVITY( ACT_IDLE_ANGRY );

	REGISTER_SHARED_ACTIVITY( ACT_IDLE_RELAXED );
	REGISTER_SHARED_ACTIVITY( ACT_IDLE_STIMULATED );
	REGISTER_SHARED_ACTIVITY( ACT_IDLE_AGITATED );

	REGISTER_SHARED_ACTIVITY( ACT_WALK_RELAXED );
	REGISTER_SHARED_ACTIVITY( ACT_WALK_STIMULATED );
	REGISTER_SHARED_ACTIVITY( ACT_WALK_AGITATED );

	REGISTER_SHARED_ACTIVITY( ACT_RUN_RELAXED );
	REGISTER_SHARED_ACTIVITY( ACT_RUN_STIMULATED );
	REGISTER_SHARED_ACTIVITY( ACT_RUN_AGITATED );

	REGISTER_SHARED_ACTIVITY( ACT_IDLE_AIM_RELAXED );
	REGISTER_SHARED_ACTIVITY( ACT_IDLE_AIM_STIMULATED );
	REGISTER_SHARED_ACTIVITY( ACT_IDLE_AIM_AGITATED );

	REGISTER_SHARED_ACTIVITY( ACT_WALK_AIM_RELAXED );
	REGISTER_SHARED_ACTIVITY( ACT_WALK_AIM_STIMULATED );
	REGISTER_SHARED_ACTIVITY( ACT_WALK_AIM_AGITATED );

	REGISTER_SHARED_ACTIVITY( ACT_RUN_AIM_RELAXED );
	REGISTER_SHARED_ACTIVITY( ACT_RUN_AIM_STIMULATED );
	REGISTER_SHARED_ACTIVITY( ACT_RUN_AIM_AGITATED );

	REGISTER_SHARED_ACTIVITY( ACT_WALK_HURT );
	REGISTER_SHARED_ACTIVITY( ACT_RUN_HURT );
	REGISTER_SHARED_ACTIVITY( ACT_SPECIAL_ATTACK1 );
	REGISTER_SHARED_ACTIVITY( ACT_SPECIAL_ATTACK2 );
	REGISTER_SHARED_ACTIVITY( ACT_COMBAT_IDLE );
	REGISTER_SHARED_ACTIVITY( ACT_WALK_SCARED );
	REGISTER_SHARED_ACTIVITY( ACT_RUN_SCARED );
	REGISTER_SHARED_ACTIVITY( ACT_VICTORY_DANCE );
	
	REGISTER_SHARED_ACTIVITY( ACT_DIE_HEADSHOT );
	REGISTER_SHARED_ACTIVITY( ACT_DIE_CHESTSHOT );
	REGISTER_SHARED_ACTIVITY( ACT_DIE_GUTSHOT );
	REGISTER_SHARED_ACTIVITY( ACT_DIE_BACKSHOT );

	REGISTER_SHARED_ACTIVITY( ACT_FLINCH_HEAD );
	REGISTER_SHARED_ACTIVITY( ACT_FLINCH_CHEST );
	REGISTER_SHARED_ACTIVITY( ACT_FLINCH_STOMACH );
	REGISTER_SHARED_ACTIVITY( ACT_FLINCH_LEFTARM );
	REGISTER_SHARED_ACTIVITY( ACT_FLINCH_RIGHTARM );
	REGISTER_SHARED_ACTIVITY( ACT_FLINCH_LEFTLEG );
	REGISTER_SHARED_ACTIVITY( ACT_FLINCH_RIGHTLEG );
	REGISTER_SHARED_ACTIVITY( ACT_FLINCH_PHYSICS );

	REGISTER_SHARED_ACTIVITY( ACT_IDLE_ON_FIRE );
	REGISTER_SHARED_ACTIVITY( ACT_WALK_ON_FIRE );
	REGISTER_SHARED_ACTIVITY( ACT_RUN_ON_FIRE );

	REGISTER_SHARED_ACTIVITY( ACT_RAPPEL_LOOP );

	REGISTER_SHARED_ACTIVITY( ACT_180_LEFT );
	REGISTER_SHARED_ACTIVITY( ACT_180_RIGHT );
	REGISTER_SHARED_ACTIVITY( ACT_90_LEFT );
	REGISTER_SHARED_ACTIVITY( ACT_90_RIGHT );
	REGISTER_SHARED_ACTIVITY( ACT_STEP_LEFT );			
	REGISTER_SHARED_ACTIVITY( ACT_STEP_RIGHT );
	REGISTER_SHARED_ACTIVITY( ACT_STEP_BACK );
	REGISTER_SHARED_ACTIVITY( ACT_STEP_FORE );

	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_RANGE_ATTACK1 );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_RANGE_ATTACK2 );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_MELEE_ATTACK1 );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_MELEE_ATTACK2 );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_RANGE_ATTACK1_LOW );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_RANGE_ATTACK2_LOW );
	REGISTER_SHARED_ACTIVITY( ACT_MELEE_ATTACK_SWING_GESTURE );
	
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_SMALL_FLINCH );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_BIG_FLINCH );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_FLINCH_BLAST );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_FLINCH_HEAD );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_FLINCH_CHEST );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_FLINCH_STOMACH );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_FLINCH_LEFTARM );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_FLINCH_RIGHTARM );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_FLINCH_LEFTLEG );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_FLINCH_RIGHTLEG );

	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_TURN_LEFT );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_TURN_RIGHT );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_TURN_LEFT45 );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_TURN_RIGHT45 );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_TURN_LEFT90 );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_TURN_RIGHT90 );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_TURN_LEFT45_FLAT );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_TURN_RIGHT45_FLAT );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_TURN_LEFT90_FLAT );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_TURN_RIGHT90_FLAT );

	// registered for Half-Life HGRUNT compatability
	REGISTER_SHARED_ACTIVITY( ACT_BARNACLE_HIT );
	REGISTER_SHARED_ACTIVITY( ACT_BARNACLE_PULL );
	REGISTER_SHARED_ACTIVITY( ACT_BARNACLE_CHOMP );
	REGISTER_SHARED_ACTIVITY( ACT_BARNACLE_CHEW );

	REGISTER_SHARED_ACTIVITY( ACT_DO_NOT_DISTURB );

	// Viewmodel activities may belong elsewhere, but since where is unclear right now,
	// they'll be placed here.
	REGISTER_SHARED_ACTIVITY( ACT_VM_DRAW );
	REGISTER_SHARED_ACTIVITY( ACT_VM_HOLSTER );
	REGISTER_SHARED_ACTIVITY( ACT_VM_IDLE );
	REGISTER_SHARED_ACTIVITY( ACT_VM_FIDGET );
	REGISTER_SHARED_ACTIVITY( ACT_VM_PULLBACK );
	REGISTER_SHARED_ACTIVITY( ACT_VM_PULLBACK_HIGH );
	REGISTER_SHARED_ACTIVITY( ACT_VM_PULLBACK_LOW );
	REGISTER_SHARED_ACTIVITY( ACT_VM_THROW );
	REGISTER_SHARED_ACTIVITY( ACT_VM_PULLPIN );
	REGISTER_SHARED_ACTIVITY( ACT_VM_PRIMARYATTACK );
	REGISTER_SHARED_ACTIVITY( ACT_VM_SECONDARYATTACK );
	REGISTER_SHARED_ACTIVITY( ACT_VM_RELOAD );
	REGISTER_SHARED_ACTIVITY( ACT_VM_DRYFIRE );
	REGISTER_SHARED_ACTIVITY( ACT_VM_HITLEFT );
	REGISTER_SHARED_ACTIVITY( ACT_VM_HITLEFT2 );
	REGISTER_SHARED_ACTIVITY( ACT_VM_HITRIGHT );
	REGISTER_SHARED_ACTIVITY( ACT_VM_HITRIGHT2 );
	REGISTER_SHARED_ACTIVITY( ACT_VM_HITCENTER );
	REGISTER_SHARED_ACTIVITY( ACT_VM_HITCENTER2 );
	REGISTER_SHARED_ACTIVITY( ACT_VM_MISSLEFT );
	REGISTER_SHARED_ACTIVITY( ACT_VM_MISSLEFT2 );
	REGISTER_SHARED_ACTIVITY( ACT_VM_MISSRIGHT );
	REGISTER_SHARED_ACTIVITY( ACT_VM_MISSRIGHT2 );
	REGISTER_SHARED_ACTIVITY( ACT_VM_MISSCENTER );
	REGISTER_SHARED_ACTIVITY( ACT_VM_MISSCENTER2 );
	REGISTER_SHARED_ACTIVITY( ACT_VM_HAULBACK );
	REGISTER_SHARED_ACTIVITY( ACT_VM_SWINGHARD );
	REGISTER_SHARED_ACTIVITY( ACT_VM_SWINGMISS );
	REGISTER_SHARED_ACTIVITY( ACT_VM_SWINGHIT );
	REGISTER_SHARED_ACTIVITY( ACT_VM_IDLE_TO_LOWERED );
	REGISTER_SHARED_ACTIVITY( ACT_VM_IDLE_LOWERED );
	REGISTER_SHARED_ACTIVITY( ACT_VM_LOWERED_TO_IDLE );
	REGISTER_SHARED_ACTIVITY( ACT_VM_RECOIL1 );
	REGISTER_SHARED_ACTIVITY( ACT_VM_RECOIL2 );
	REGISTER_SHARED_ACTIVITY( ACT_VM_RECOIL3 );

	REGISTER_SHARED_ACTIVITY ( ACT_VM_ATTACH_SILENCER );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_DETACH_SILENCER );

//===========================
// HL2 Specific Activities
//===========================
	// SLAM Specialty Activites
	REGISTER_SHARED_ACTIVITY( ACT_SLAM_STICKWALL_IDLE);
	REGISTER_SHARED_ACTIVITY( ACT_SLAM_STICKWALL_ND_IDLE);
	REGISTER_SHARED_ACTIVITY( ACT_SLAM_STICKWALL_ATTACH);
	REGISTER_SHARED_ACTIVITY( ACT_SLAM_STICKWALL_ATTACH2);
	REGISTER_SHARED_ACTIVITY( ACT_SLAM_STICKWALL_ND_ATTACH);
	REGISTER_SHARED_ACTIVITY( ACT_SLAM_STICKWALL_ND_ATTACH2);
	REGISTER_SHARED_ACTIVITY( ACT_SLAM_STICKWALL_DETONATE);
	REGISTER_SHARED_ACTIVITY( ACT_SLAM_STICKWALL_DETONATOR_HOLSTER);
	REGISTER_SHARED_ACTIVITY( ACT_SLAM_STICKWALL_DRAW); 
  	REGISTER_SHARED_ACTIVITY( ACT_SLAM_STICKWALL_ND_DRAW); 
  	REGISTER_SHARED_ACTIVITY( ACT_SLAM_STICKWALL_TO_THROW); 
  	REGISTER_SHARED_ACTIVITY( ACT_SLAM_STICKWALL_TO_THROW_ND); 
	REGISTER_SHARED_ACTIVITY( ACT_SLAM_STICKWALL_TO_TRIPMINE_ND );
  	REGISTER_SHARED_ACTIVITY( ACT_SLAM_THROW_IDLE);
	REGISTER_SHARED_ACTIVITY( ACT_SLAM_THROW_ND_IDLE);
	REGISTER_SHARED_ACTIVITY( ACT_SLAM_THROW_THROW);
	REGISTER_SHARED_ACTIVITY( ACT_SLAM_THROW_THROW2);
	REGISTER_SHARED_ACTIVITY( ACT_SLAM_THROW_THROW_ND);
	REGISTER_SHARED_ACTIVITY( ACT_SLAM_THROW_THROW_ND2);
	REGISTER_SHARED_ACTIVITY( ACT_SLAM_THROW_DRAW); 
  	REGISTER_SHARED_ACTIVITY( ACT_SLAM_THROW_ND_DRAW); 
  	REGISTER_SHARED_ACTIVITY( ACT_SLAM_THROW_TO_STICKWALL); 
  	REGISTER_SHARED_ACTIVITY( ACT_SLAM_THROW_TO_STICKWALL_ND); 
	REGISTER_SHARED_ACTIVITY( ACT_SLAM_THROW_DETONATE);
	REGISTER_SHARED_ACTIVITY( ACT_SLAM_THROW_DETONATOR_HOLSTER);
	REGISTER_SHARED_ACTIVITY( ACT_SLAM_THROW_TO_TRIPMINE_ND );
  	REGISTER_SHARED_ACTIVITY( ACT_SLAM_TRIPMINE_IDLE);
  	REGISTER_SHARED_ACTIVITY( ACT_SLAM_TRIPMINE_DRAW);
  	REGISTER_SHARED_ACTIVITY( ACT_SLAM_TRIPMINE_ATTACH); 
  	REGISTER_SHARED_ACTIVITY( ACT_SLAM_TRIPMINE_ATTACH2); 
	REGISTER_SHARED_ACTIVITY( ACT_SLAM_TRIPMINE_TO_STICKWALL_ND );
	REGISTER_SHARED_ACTIVITY( ACT_SLAM_TRIPMINE_TO_THROW_ND );
  	REGISTER_SHARED_ACTIVITY( ACT_SLAM_DETONATOR_IDLE); 
  	REGISTER_SHARED_ACTIVITY( ACT_SLAM_DETONATOR_DRAW); 
  	REGISTER_SHARED_ACTIVITY( ACT_SLAM_DETONATOR_DETONATE);
  	REGISTER_SHARED_ACTIVITY( ACT_SLAM_DETONATOR_HOLSTER);
  	REGISTER_SHARED_ACTIVITY( ACT_SLAM_DETONATOR_STICKWALL_DRAW); 
  	REGISTER_SHARED_ACTIVITY( ACT_SLAM_DETONATOR_THROW_DRAW); 

	// SHOTGUN specialty activities
	REGISTER_SHARED_ACTIVITY( ACT_SHOTGUN_RELOAD_START);
	REGISTER_SHARED_ACTIVITY( ACT_SHOTGUN_RELOAD_FINISH);
	REGISTER_SHARED_ACTIVITY( ACT_SHOTGUN_PUMP);

	// SMG2 special activities
	REGISTER_SHARED_ACTIVITY( ACT_SMG2_IDLE2 );
	REGISTER_SHARED_ACTIVITY( ACT_SMG2_FIRE2 );
	REGISTER_SHARED_ACTIVITY( ACT_SMG2_DRAW2 );
	REGISTER_SHARED_ACTIVITY( ACT_SMG2_RELOAD2 );
	REGISTER_SHARED_ACTIVITY( ACT_SMG2_DRYFIRE2 );
	REGISTER_SHARED_ACTIVITY( ACT_SMG2_TOAUTO );
	REGISTER_SHARED_ACTIVITY( ACT_SMG2_TOBURST );

	// Physcannon special activities
	REGISTER_SHARED_ACTIVITY( ACT_PHYSCANNON_UPGRADE );

	// weapon override activities
	REGISTER_SHARED_ACTIVITY( ACT_RANGE_ATTACK_AR1 );
	REGISTER_SHARED_ACTIVITY( ACT_RANGE_ATTACK_AR2 );
	REGISTER_SHARED_ACTIVITY( ACT_RANGE_ATTACK_AR2_LOW );
	REGISTER_SHARED_ACTIVITY( ACT_RANGE_ATTACK_AR2_GRENADE );
	REGISTER_SHARED_ACTIVITY( ACT_RANGE_ATTACK_HMG1 );
	REGISTER_SHARED_ACTIVITY( ACT_RANGE_ATTACK_ML );
	REGISTER_SHARED_ACTIVITY( ACT_RANGE_ATTACK_SMG1 );
	REGISTER_SHARED_ACTIVITY( ACT_RANGE_ATTACK_SMG1_LOW );
	REGISTER_SHARED_ACTIVITY( ACT_RANGE_ATTACK_SMG2 );
	REGISTER_SHARED_ACTIVITY( ACT_RANGE_ATTACK_SHOTGUN );
	REGISTER_SHARED_ACTIVITY( ACT_RANGE_ATTACK_SHOTGUN_LOW );
	REGISTER_SHARED_ACTIVITY( ACT_RANGE_ATTACK_PISTOL );
	REGISTER_SHARED_ACTIVITY( ACT_RANGE_ATTACK_PISTOL_LOW );
	REGISTER_SHARED_ACTIVITY( ACT_RANGE_ATTACK_SLAM );
	REGISTER_SHARED_ACTIVITY( ACT_RANGE_ATTACK_TRIPWIRE );
	REGISTER_SHARED_ACTIVITY( ACT_RANGE_ATTACK_THROW );
	REGISTER_SHARED_ACTIVITY( ACT_RANGE_ATTACK_SNIPER_RIFLE );
	REGISTER_SHARED_ACTIVITY( ACT_RANGE_ATTACK_RPG );
	REGISTER_SHARED_ACTIVITY( ACT_MELEE_ATTACK_SWING );

	REGISTER_SHARED_ACTIVITY( ACT_RANGE_AIM_LOW );
	REGISTER_SHARED_ACTIVITY( ACT_RANGE_AIM_SMG1_LOW );
	REGISTER_SHARED_ACTIVITY( ACT_RANGE_AIM_PISTOL_LOW );
	REGISTER_SHARED_ACTIVITY( ACT_RANGE_AIM_AR2_LOW );

	REGISTER_SHARED_ACTIVITY( ACT_COVER_PISTOL_LOW );
	REGISTER_SHARED_ACTIVITY( ACT_COVER_SMG1_LOW );

	// weapon override activities
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_RANGE_ATTACK_AR1 );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_RANGE_ATTACK_AR2 );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_RANGE_ATTACK_AR2_GRENADE );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_RANGE_ATTACK_HMG1 );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_RANGE_ATTACK_ML );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_RANGE_ATTACK_SMG1 );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_RANGE_ATTACK_SMG1_LOW );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_RANGE_ATTACK_SMG2 );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_RANGE_ATTACK_SHOTGUN );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_RANGE_ATTACK_PISTOL );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_RANGE_ATTACK_PISTOL_LOW );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_RANGE_ATTACK_SLAM );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_RANGE_ATTACK_TRIPWIRE );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_RANGE_ATTACK_THROW );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_RANGE_ATTACK_SNIPER_RIFLE );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_MELEE_ATTACK_SWING );

	REGISTER_SHARED_ACTIVITY( ACT_IDLE_RIFLE );
	REGISTER_SHARED_ACTIVITY( ACT_IDLE_SMG1 );
	REGISTER_SHARED_ACTIVITY( ACT_IDLE_ANGRY_SMG1 );
	REGISTER_SHARED_ACTIVITY( ACT_IDLE_PISTOL );
	REGISTER_SHARED_ACTIVITY( ACT_IDLE_ANGRY_PISTOL );

	REGISTER_SHARED_ACTIVITY( ACT_IDLE_ANGRY_SHOTGUN );

	REGISTER_SHARED_ACTIVITY( ACT_IDLE_PACKAGE );
	REGISTER_SHARED_ACTIVITY( ACT_WALK_PACKAGE );
	REGISTER_SHARED_ACTIVITY( ACT_IDLE_SUITCASE );
	REGISTER_SHARED_ACTIVITY( ACT_WALK_SUITCASE );

	REGISTER_SHARED_ACTIVITY( ACT_IDLE_SMG1_RELAXED );
	REGISTER_SHARED_ACTIVITY( ACT_IDLE_SMG1_STIMULATED );

	REGISTER_SHARED_ACTIVITY( ACT_WALK_RIFLE_RELAXED );
	REGISTER_SHARED_ACTIVITY( ACT_RUN_RIFLE_RELAXED );
	REGISTER_SHARED_ACTIVITY( ACT_WALK_RIFLE_STIMULATED );
	REGISTER_SHARED_ACTIVITY( ACT_RUN_RIFLE_STIMULATED );

	REGISTER_SHARED_ACTIVITY( ACT_IDLE_AIM_RIFLE_STIMULATED );
	REGISTER_SHARED_ACTIVITY( ACT_WALK_AIM_RIFLE_STIMULATED );
	REGISTER_SHARED_ACTIVITY( ACT_RUN_AIM_RIFLE_STIMULATED );

	REGISTER_SHARED_ACTIVITY( ACT_IDLE_SHOTGUN_RELAXED );
	REGISTER_SHARED_ACTIVITY( ACT_IDLE_SHOTGUN_STIMULATED );
	REGISTER_SHARED_ACTIVITY( ACT_IDLE_SHOTGUN_AGITATED );

	// Policing activities
	REGISTER_SHARED_ACTIVITY( ACT_WALK_ANGRY );
	REGISTER_SHARED_ACTIVITY( ACT_POLICE_HARASS1 );
	REGISTER_SHARED_ACTIVITY( ACT_POLICE_HARASS2 );

	// Manned guns
	REGISTER_SHARED_ACTIVITY( ACT_IDLE_MANNEDGUN );

	// Melee weapon activities
	REGISTER_SHARED_ACTIVITY( ACT_IDLE_MELEE );
	REGISTER_SHARED_ACTIVITY( ACT_IDLE_ANGRY_MELEE );

	// RPG activities
	REGISTER_SHARED_ACTIVITY( ACT_IDLE_RPG_RELAXED );
	REGISTER_SHARED_ACTIVITY( ACT_IDLE_RPG ); 
	REGISTER_SHARED_ACTIVITY( ACT_IDLE_ANGRY_RPG );
	REGISTER_SHARED_ACTIVITY( ACT_COVER_LOW_RPG ); 
	REGISTER_SHARED_ACTIVITY( ACT_WALK_RPG );
	REGISTER_SHARED_ACTIVITY( ACT_RUN_RPG ); 
	REGISTER_SHARED_ACTIVITY( ACT_WALK_CROUCH_RPG ); 
	REGISTER_SHARED_ACTIVITY( ACT_RUN_CROUCH_RPG ); 
	REGISTER_SHARED_ACTIVITY( ACT_WALK_RPG_RELAXED ); 
	REGISTER_SHARED_ACTIVITY( ACT_RUN_RPG_RELAXED );

	REGISTER_SHARED_ACTIVITY( ACT_WALK_RIFLE );
	REGISTER_SHARED_ACTIVITY( ACT_WALK_AIM_RIFLE );
	REGISTER_SHARED_ACTIVITY( ACT_WALK_CROUCH_RIFLE );
	REGISTER_SHARED_ACTIVITY( ACT_WALK_CROUCH_AIM_RIFLE );
	REGISTER_SHARED_ACTIVITY( ACT_RUN_RIFLE );
	REGISTER_SHARED_ACTIVITY( ACT_RUN_AIM_RIFLE );
	REGISTER_SHARED_ACTIVITY( ACT_RUN_CROUCH_RIFLE );
	REGISTER_SHARED_ACTIVITY( ACT_RUN_CROUCH_AIM_RIFLE );

	REGISTER_SHARED_ACTIVITY( ACT_WALK_AIM_SHOTGUN );
	REGISTER_SHARED_ACTIVITY( ACT_RUN_AIM_SHOTGUN );

	REGISTER_SHARED_ACTIVITY( ACT_WALK_AIM_PISTOL );
	REGISTER_SHARED_ACTIVITY( ACT_RUN_AIM_PISTOL );

	// Reloads
	REGISTER_SHARED_ACTIVITY( ACT_RELOAD_PISTOL );
	REGISTER_SHARED_ACTIVITY( ACT_RELOAD_PISTOL_LOW );
	REGISTER_SHARED_ACTIVITY( ACT_RELOAD_SMG1 );
	REGISTER_SHARED_ACTIVITY( ACT_RELOAD_SMG1_LOW );

	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_RELOAD );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_RELOAD_PISTOL );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_RELOAD_SMG1 );

	// Busy animations
	REGISTER_SHARED_ACTIVITY( ACT_BUSY_LEAN_LEFT );
	REGISTER_SHARED_ACTIVITY( ACT_BUSY_LEAN_LEFT_ENTRY );
	REGISTER_SHARED_ACTIVITY( ACT_BUSY_LEAN_LEFT_EXIT );
	REGISTER_SHARED_ACTIVITY( ACT_BUSY_LEAN_BACK );
	REGISTER_SHARED_ACTIVITY( ACT_BUSY_LEAN_BACK_ENTRY );
	REGISTER_SHARED_ACTIVITY( ACT_BUSY_LEAN_BACK_EXIT );
	REGISTER_SHARED_ACTIVITY( ACT_BUSY_SIT_GROUND );
	REGISTER_SHARED_ACTIVITY( ACT_BUSY_SIT_GROUND_ENTRY );
	REGISTER_SHARED_ACTIVITY( ACT_BUSY_SIT_GROUND_EXIT );
	REGISTER_SHARED_ACTIVITY( ACT_BUSY_SIT_CHAIR );
	REGISTER_SHARED_ACTIVITY( ACT_BUSY_SIT_CHAIR_ENTRY );
	REGISTER_SHARED_ACTIVITY( ACT_BUSY_SIT_CHAIR_EXIT );
	REGISTER_SHARED_ACTIVITY( ACT_BUSY_STAND );
	REGISTER_SHARED_ACTIVITY( ACT_BUSY_QUEUE );

	REGISTER_SHARED_ACTIVITY( ACT_DIE_BARNACLE_SWALLOW );
	REGISTER_SHARED_ACTIVITY( ACT_GESTURE_BARNACLE_STRANGLE );
	REGISTER_SHARED_ACTIVITY( ACT_PHYSCANNON_DETACH );

	REGISTER_SHARED_ACTIVITY( ACT_DIE_FRONTSIDE );
	REGISTER_SHARED_ACTIVITY( ACT_DIE_RIGHTSIDE );
	REGISTER_SHARED_ACTIVITY( ACT_DIE_BACKSIDE );
	REGISTER_SHARED_ACTIVITY( ACT_DIE_LEFTSIDE );

	REGISTER_SHARED_ACTIVITY( ACT_OPEN_DOOR );


//===========================
// TF2 Specific Activities
//===========================
	REGISTER_SHARED_ACTIVITY( ACT_STARTDYING );
	REGISTER_SHARED_ACTIVITY( ACT_DYINGLOOP );
	REGISTER_SHARED_ACTIVITY( ACT_DYINGTODEAD );
	REGISTER_SHARED_ACTIVITY( ACT_RIDE_MANNED_GUN );

	// All viewmodels
	REGISTER_SHARED_ACTIVITY( ACT_VM_SPRINT_ENTER );
	REGISTER_SHARED_ACTIVITY( ACT_VM_SPRINT_IDLE );
	REGISTER_SHARED_ACTIVITY( ACT_VM_SPRINT_LEAVE );

	// Looping weapon firing
	REGISTER_SHARED_ACTIVITY( ACT_FIRE_START );
	REGISTER_SHARED_ACTIVITY( ACT_FIRE_LOOP );
	REGISTER_SHARED_ACTIVITY( ACT_FIRE_END );

	// TF2
	REGISTER_SHARED_ACTIVITY( ACT_CROUCHING_GRENADEIDLE );
	REGISTER_SHARED_ACTIVITY( ACT_CROUCHING_GRENADEREADY );
	REGISTER_SHARED_ACTIVITY( ACT_CROUCHING_PRIMARYATTACK );
	REGISTER_SHARED_ACTIVITY( ACT_OVERLAY_GRENADEIDLE );
	REGISTER_SHARED_ACTIVITY( ACT_OVERLAY_GRENADEREADY );
	REGISTER_SHARED_ACTIVITY( ACT_OVERLAY_PRIMARYATTACK );
	REGISTER_SHARED_ACTIVITY( ACT_OVERLAY_SHIELD_UP );
	REGISTER_SHARED_ACTIVITY( ACT_OVERLAY_SHIELD_DOWN );
	REGISTER_SHARED_ACTIVITY( ACT_OVERLAY_SHIELD_UP_IDLE );
	REGISTER_SHARED_ACTIVITY( ACT_OVERLAY_SHIELD_ATTACK );
	REGISTER_SHARED_ACTIVITY( ACT_OVERLAY_SHIELD_KNOCKBACK );
	REGISTER_SHARED_ACTIVITY( ACT_SHIELD_UP );
	REGISTER_SHARED_ACTIVITY( ACT_SHIELD_DOWN );
	REGISTER_SHARED_ACTIVITY( ACT_SHIELD_UP_IDLE );
	REGISTER_SHARED_ACTIVITY( ACT_SHIELD_ATTACK );
	REGISTER_SHARED_ACTIVITY( ACT_SHIELD_KNOCKBACK );
	REGISTER_SHARED_ACTIVITY( ACT_CROUCHING_SHIELD_UP );
	REGISTER_SHARED_ACTIVITY( ACT_CROUCHING_SHIELD_DOWN );
	REGISTER_SHARED_ACTIVITY( ACT_CROUCHING_SHIELD_UP_IDLE );
	REGISTER_SHARED_ACTIVITY( ACT_CROUCHING_SHIELD_ATTACK );
	REGISTER_SHARED_ACTIVITY( ACT_CROUCHING_SHIELD_KNOCKBACK );

	REGISTER_SHARED_ACTIVITY( ACT_TURNRIGHT45 );
	REGISTER_SHARED_ACTIVITY( ACT_TURNLEFT45 );

	REGISTER_SHARED_ACTIVITY( ACT_TURN );

	REGISTER_SHARED_ACTIVITY( ACT_OBJ_ASSEMBLING );
	REGISTER_SHARED_ACTIVITY( ACT_OBJ_DISMANTLING );
	REGISTER_SHARED_ACTIVITY( ACT_OBJ_STARTUP );
	REGISTER_SHARED_ACTIVITY( ACT_OBJ_RUNNING );
	REGISTER_SHARED_ACTIVITY( ACT_OBJ_IDLE );
	REGISTER_SHARED_ACTIVITY( ACT_OBJ_PLACING );
	REGISTER_SHARED_ACTIVITY( ACT_OBJ_DETERIORATING );

	// Deploy
	REGISTER_SHARED_ACTIVITY( ACT_DEPLOY );
	REGISTER_SHARED_ACTIVITY( ACT_DEPLOY_IDLE );
	REGISTER_SHARED_ACTIVITY( ACT_UNDEPLOY );

//===========================
// HL1 Specific Activities
//===========================

	// Grenades
	REGISTER_SHARED_ACTIVITY( ACT_GRENADE_ROLL );
	REGISTER_SHARED_ACTIVITY( ACT_GRENADE_TOSS );

	// Hand grenade
	REGISTER_SHARED_ACTIVITY( ACT_HANDGRENADE_THROW1 );
	REGISTER_SHARED_ACTIVITY( ACT_HANDGRENADE_THROW2 );
	REGISTER_SHARED_ACTIVITY( ACT_HANDGRENADE_THROW3 );

	// Shotgun
	REGISTER_SHARED_ACTIVITY( ACT_SHOTGUN_IDLE_DEEP );
	REGISTER_SHARED_ACTIVITY( ACT_SHOTGUN_IDLE4 );

	// Glock
	REGISTER_SHARED_ACTIVITY( ACT_GLOCK_SHOOTEMPTY );
	REGISTER_SHARED_ACTIVITY( ACT_GLOCK_SHOOT_RELOAD );

	// RPG
	REGISTER_SHARED_ACTIVITY( ACT_RPG_DRAW_UNLOADED );
	REGISTER_SHARED_ACTIVITY( ACT_RPG_HOLSTER_UNLOADED );
	REGISTER_SHARED_ACTIVITY( ACT_RPG_IDLE_UNLOADED );
	REGISTER_SHARED_ACTIVITY( ACT_RPG_FIDGET_UNLOADED );

	// Crossbow
	REGISTER_SHARED_ACTIVITY( ACT_CROSSBOW_DRAW_UNLOADED );
	REGISTER_SHARED_ACTIVITY( ACT_CROSSBOW_IDLE_UNLOADED );
	REGISTER_SHARED_ACTIVITY( ACT_CROSSBOW_FIDGET_UNLOADED );

	// Gauss
	REGISTER_SHARED_ACTIVITY( ACT_GAUSS_SPINUP );
	REGISTER_SHARED_ACTIVITY( ACT_GAUSS_SPINCYCLE );

	// Tripmine
	REGISTER_SHARED_ACTIVITY( ACT_TRIPMINE_GROUND );
	REGISTER_SHARED_ACTIVITY( ACT_TRIPMINE_WORLD );

//===========================
// CSPort Specific Activities
//===========================

	REGISTER_SHARED_ACTIVITY ( ACT_VM_PRIMARYATTACK_SILENCED );		// fire
	REGISTER_SHARED_ACTIVITY ( ACT_VM_RELOAD_SILENCED );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_DRYFIRE_SILENCED );				// fire with no ammo loaded.
	REGISTER_SHARED_ACTIVITY ( ACT_VM_IDLE_SILENCED );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_DRAW_SILENCED );

	REGISTER_SHARED_ACTIVITY ( ACT_VM_IDLE_EMPTY_LEFT );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_DRYFIRE_LEFT );

	REGISTER_SHARED_ACTIVITY ( ACT_PLAYER_IDLE_FIRE );
	REGISTER_SHARED_ACTIVITY ( ACT_PLAYER_CROUCH_FIRE );
	REGISTER_SHARED_ACTIVITY ( ACT_PLAYER_CROUCH_WALK_FIRE );
	REGISTER_SHARED_ACTIVITY ( ACT_PLAYER_WALK_FIRE );
	REGISTER_SHARED_ACTIVITY ( ACT_PLAYER_RUN_FIRE );
	REGISTER_SHARED_ACTIVITY ( ACT_IDLETORUN );
	REGISTER_SHARED_ACTIVITY ( ACT_RUNTOIDLE );

//===========================
// DoD Specific Activities
//===========================

	REGISTER_SHARED_ACTIVITY ( ACT_SPRINT );

	// To get in and out of prone state.
	REGISTER_SHARED_ACTIVITY ( ACT_GET_DOWN );
	REGISTER_SHARED_ACTIVITY ( ACT_GET_UP );
	REGISTER_SHARED_ACTIVITY ( ACT_PRONE_FORWARD );
	REGISTER_SHARED_ACTIVITY ( ACT_PRONE_IDLE );

	REGISTER_SHARED_ACTIVITY ( ACT_FIDGET );
 
	REGISTER_SHARED_ACTIVITY ( ACT_VM_RELOAD_DEPLOYED ); 
	REGISTER_SHARED_ACTIVITY ( ACT_VM_RELOAD_IDLE );

	//Weapon is empty activities
	REGISTER_SHARED_ACTIVITY ( ACT_VM_DRAW_EMPTY );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_PRIMARYATTACK_EMPTY );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_RELOAD_EMPTY );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_IDLE_EMPTY );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_IDLE_DEPLOYED_EMPTY );

	REGISTER_SHARED_ACTIVITY ( ACT_VM_IDLE_8 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_IDLE_7 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_IDLE_6 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_IDLE_5 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_IDLE_4 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_IDLE_3 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_IDLE_2 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_IDLE_1 );

	REGISTER_SHARED_ACTIVITY ( ACT_VM_IDLE_DEPLOYED );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_IDLE_DEPLOYED_8 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_IDLE_DEPLOYED_7 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_IDLE_DEPLOYED_6 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_IDLE_DEPLOYED_5 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_IDLE_DEPLOYED_4 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_IDLE_DEPLOYED_3 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_IDLE_DEPLOYED_2 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_IDLE_DEPLOYED_1 );

	// Animation from prone idle to standing/crouch idle. Number designates bullets left
	REGISTER_SHARED_ACTIVITY ( ACT_VM_UNDEPLOY );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_UNDEPLOY_8 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_UNDEPLOY_7 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_UNDEPLOY_6 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_UNDEPLOY_5 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_UNDEPLOY_4 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_UNDEPLOY_3 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_UNDEPLOY_2 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_UNDEPLOY_1 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_UNDEPLOY_EMPTY );

	// Animation from standing/crouch idle to prone idle. Number designates bullets left
	REGISTER_SHARED_ACTIVITY ( ACT_VM_DEPLOY );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_DEPLOY_8 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_DEPLOY_7 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_DEPLOY_6 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_DEPLOY_5 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_DEPLOY_4 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_DEPLOY_3 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_DEPLOY_2 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_DEPLOY_1 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_DEPLOY_EMPTY );

	// Shooting animations for standing/crouch position.  Number designates bullets left at START of animation
	REGISTER_SHARED_ACTIVITY ( ACT_VM_PRIMARYATTACK_8 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_PRIMARYATTACK_7 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_PRIMARYATTACK_6 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_PRIMARYATTACK_5 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_PRIMARYATTACK_4 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_PRIMARYATTACK_3 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_PRIMARYATTACK_2 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_PRIMARYATTACK_1 );

	// Shooting animations for prone position. Number designates bullets left at START of animation
	REGISTER_SHARED_ACTIVITY ( ACT_VM_PRIMARYATTACK_DEPLOYED );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_PRIMARYATTACK_DEPLOYED_8 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_PRIMARYATTACK_DEPLOYED_7 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_PRIMARYATTACK_DEPLOYED_6 ); 
	REGISTER_SHARED_ACTIVITY ( ACT_VM_PRIMARYATTACK_DEPLOYED_5 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_PRIMARYATTACK_DEPLOYED_4 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_PRIMARYATTACK_DEPLOYED_3 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_PRIMARYATTACK_DEPLOYED_2 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_PRIMARYATTACK_DEPLOYED_1 );
	REGISTER_SHARED_ACTIVITY ( ACT_VM_PRIMARYATTACK_DEPLOYED_EMPTY );

//HL2MP
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_IDLE );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_RUN );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_IDLE_CROUCH );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_WALK_CROUCH );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_GESTURE_RANGE_ATTACK );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_GESTURE_RELOAD );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_JUMP );
	
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_IDLE_PISTOL );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_RUN_PISTOL );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_IDLE_CROUCH_PISTOL );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_WALK_CROUCH_PISTOL );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_GESTURE_RANGE_ATTACK_PISTOL );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_GESTURE_RELOAD_PISTOL );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_JUMP_PISTOL );

	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_IDLE_SMG1 );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_RUN_SMG1 );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_IDLE_CROUCH_SMG1 );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_WALK_CROUCH_SMG1 );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_GESTURE_RANGE_ATTACK_SMG1 );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_GESTURE_RELOAD_SMG1 );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_JUMP_SMG1 );

  	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_IDLE_AR2 );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_RUN_AR2 );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_IDLE_CROUCH_AR2 );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_WALK_CROUCH_AR2 );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_GESTURE_RANGE_ATTACK_AR2 );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_GESTURE_RELOAD_AR2 );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_JUMP_AR2 );

  	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_IDLE_SHOTGUN );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_RUN_SHOTGUN );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_IDLE_CROUCH_SHOTGUN );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_WALK_CROUCH_SHOTGUN );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_GESTURE_RANGE_ATTACK_SHOTGUN );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_GESTURE_RELOAD_SHOTGUN );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_JUMP_SHOTGUN );

  	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_IDLE_RPG );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_RUN_RPG );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_IDLE_CROUCH_RPG );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_WALK_CROUCH_RPG );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_GESTURE_RANGE_ATTACK_RPG );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_GESTURE_RELOAD_RPG );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_JUMP_RPG );

  	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_IDLE_GRENADE );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_RUN_GRENADE );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_IDLE_CROUCH_GRENADE );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_WALK_CROUCH_GRENADE );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_GESTURE_RANGE_ATTACK_GRENADE );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_GESTURE_RELOAD_GRENADE );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_JUMP_GRENADE );

  	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_IDLE_PHYSGUN );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_RUN_PHYSGUN );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_IDLE_CROUCH_PHYSGUN );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_WALK_CROUCH_PHYSGUN );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_GESTURE_RANGE_ATTACK_PHYSGUN );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_GESTURE_RELOAD_PHYSGUN );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_JUMP_PHYSGUN );

  	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_IDLE_CROSSBOW );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_RUN_CROSSBOW );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_IDLE_CROUCH_CROSSBOW );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_WALK_CROUCH_CROSSBOW );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_GESTURE_RANGE_ATTACK_CROSSBOW );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_GESTURE_RELOAD_CROSSBOW );
	REGISTER_SHARED_ACTIVITY ( ACT_HL2MP_JUMP_CROSSBOW );
} 

// HACKHACK: Keep backwards compatibility on broken activities temporarily
#define ACTIVITY_FILE_TAG 0x80800000

class CActivityDataOps : public CDefSaveRestoreOps
{
public:
	// save data type interface
	virtual void Save( const SaveRestoreFieldInfo_t &fieldInfo, ISave *pSave ) 
	{
		int activityIndex = *((int *)fieldInfo.pField);
		const char *pActivityName = ActivityList_NameForIndex( activityIndex );
		if ( !pActivityName )
		{
			AssertOnce( activityIndex == -1 ); // FIXME: whatever activity this was, it's now being saved out as ACT_RESET
			pActivityName = ActivityList_NameForIndex( 0 );
		}
		int len = strlen(pActivityName) + 1;
		
		// Use the high 16-bits of this int to signify this file format
		// this makes this backwards compatible.
		// UNDONE: Remove after playtest save files are no longer needed
		len |= ACTIVITY_FILE_TAG;
		pSave->WriteInt( &len );
		pSave->WriteString( pActivityName );
	}

	virtual void Restore( const SaveRestoreFieldInfo_t &fieldInfo, IRestore *pRestore ) 
	{
		char nameBuf[1024];

		int *pActivityIndex = (int *)fieldInfo.pField;

		int nameLen = pRestore->ReadInt();
		if ( (nameLen & 0xFFFF0000) != ACTIVITY_FILE_TAG )
		{
			// old save file, this is an index, not a name
			*pActivityIndex = nameLen;
			return;
		}
		nameLen &= 0xFFFF;
		pRestore->ReadString( nameBuf, sizeof(nameBuf), nameLen );
		*pActivityIndex = ActivityList_IndexForName( nameBuf );
		if ( *pActivityIndex < 0 )
		{
			*pActivityIndex = 0;
		}
	}

	virtual bool IsEmpty( const SaveRestoreFieldInfo_t &fieldInfo ) 
	{ 
		int *pActivityIndex = (int *)fieldInfo.pField;
		return (*pActivityIndex == 0);
	}

	virtual void MakeEmpty( const SaveRestoreFieldInfo_t &fieldInfo ) 
	{
		int *pActivityIndex = (int *)fieldInfo.pField;
		*pActivityIndex = 0;
	}
};

static CActivityDataOps g_ActivityDataOps;

ISaveRestoreOps* ActivityDataOps()
{
	return &g_ActivityDataOps;
}
