
#include "lpgr.h"

#ifndef PandaWave_RESOURCES
#include "RevengeResources.h"
#endif

#include "RevengeApp.h"
#include <XMessages.h>
#include "tagpick.h"
#include <assert.h>
#include <XPopup.h>
#include <XWindow.h>
#include "skelmodel.h"

// ==============================  BYTE SWAPPING DATA  ========================================
static byte_swap_code local_projectile_group_definition_byte_swapping_data[]=
{
	_begin_bs_array, 1,

	// unsigned long flags;
	_4byte,
	
	// file_tag collection_reference_tag;
	// file_tag physics_tag;
	_4byte,
	_4byte,

	// short sequence_indexes[MAXIMUM_NUMBER_OF_LOCAL_PROJECTILE_GROUP_SEQUENCES];
	
		_begin_bs_array, MAXIMUM_NUMBER_OF_LOCAL_PROJECTILE_GROUP_SEQUENCES,
		
		_2byte,
		
		_end_bs_array,
	
	// short_fixed scale_lower_bound, scale_delta;
	// short_fixed animation_rate_lower_bound, animation_rate_delta;
	_2byte, _2byte,
	_2byte, _2byte,
	
	// short target_number_lower_bound, target_number_delta;
	// world_distance radius_lower_bound, radius_delta;
	_2byte, _2byte,
	_4byte, _4byte,
	
	// int expiration_time_lower_bound, expiration_time_delta;
	_4byte, _4byte,

	// short transfer_mode;
	_2byte,
	
	// short_world_distance height_offset;
	_2byte,
	
	// short startup_transition_time_lower_bound, startup_transition_time_delta;
	// short ending_transition_time_lower_bound, ending_transition_time_delta;
	// int duration_lower_bound, duration_delta;
	_2byte, _2byte,
	_2byte, _2byte,
	_4byte, _4byte,
	
	_2byte,	// short_world_distance initial_z_velocity
	_2byte, // short_world_distance z_acceleration
	
	// short startup_delay_lower_bound, startup_delay_delta;
	_2byte, _2byte,
	
	// short unused2[4];
	4*sizeof(short),
	
	// file_tag chain_to_lpgr
	_4byte,
	// file_tag local_light_tag
	_4byte,

	// short unused[14];
	14*sizeof(short),

	// computed during postprocessing
	
	// short collection_reference_index;
	// short collection_index, color_table_index;
	// short physics_index;
	// short chain_to_lpgr_index;
	// short local_light_index;
	6*sizeof(short),
	
	_end_bs_array
};

local_projectile_group_definition default_lpgr =
{
	0,
	-1,
	-1,
	0, 0,
	0, 0,
	0, 0,
	0, 0,
	0, 0,
	0, 0,
	0,
	0,
	0, 0,
	0, 0,
	0, 0,
	0,
	0,
	0, 0,
	0, 0, 0, 0,
	-1,
	-1,
	0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
	-1,
	-1, -1,
	-1,
	-1,
	-1
};


// ==============================  EDIT WINDOW  ========================================
void edit_lpgr( tag_entry* e )
{
	TlpgrEditForm* form = new TlpgrEditForm( e );
	form->AttachWindow( 1009 );
}


void dependency_lpgr( tag_entry *e )
{
	local_projectile_group_definition def;
	read_local_projectile_group_definition( &def, e );
	tag artType = (def.flags & _group_uses_skelmodel_flag) ? 'skmd' : (def.flags&_group_uses_sprite_flag) ? 'spri' : 'core';
	add_tag_dependency( artType, def.collection_reference_tag );
	add_tag_dependency( 'phys', def.physics_tag );
	add_tag_dependency( 'lpgr', def.chain_to_lpgr );
	add_tag_dependency( 'loli', def.local_light_tag );
}


// ==============================  READ TAG DATA  ========================================
bool read_local_projectile_group_definition( local_projectile_group_definition* def, tag_entry* e )
{
	return load_tag_data_into_struct( "lpgr", e, def, SIZEOF_STRUCT_LOCAL_PROJECTILE_GROUP_DEFINITION, 1, local_projectile_group_definition_byte_swapping_data);
}


void defaultnew_lpgr( tag_entry *e )
{
	local_projectile_group_definition def;
	byte_swap_move_be( "lpgr", &def, &default_lpgr, sizeof(local_projectile_group_definition), 1, local_projectile_group_definition_byte_swapping_data );
	set_entry_data( e, &def, sizeof(def), false );
}


// ==============================  SAVE TAG DATA  ========================================
bool save_local_projectile_group_definition( local_projectile_group_definition* def, tag_entry* e )
{
	return save_tag_data_from_struct( "lpgr", e, def, SIZEOF_STRUCT_LOCAL_PROJECTILE_GROUP_DEFINITION, 1, local_projectile_group_definition_byte_swapping_data);
}


// ==============================  READ TAG DATA (WITH ID) ========================================
bool read_local_projectile_group_definition( local_projectile_group_definition* def, tag id )
{
	tag_entry* e;
	
	assert( def );
	
	e = get_entry( 'lpgr', id );
	if( 0 == e ) {
		return FALSE;
	}
	
	return read_local_projectile_group_definition( def, e );	
}


// ==============================  SAVE TAG DATA (WITH ID) ========================================
bool save_local_projectile_group_definition( local_projectile_group_definition* def, tag id )
{
	tag_entry* e;
	
	assert( def );
	
	e = get_entry( 'lpgr', id );
	if( 0 == e ) {
		return FALSE;
	}

	return save_local_projectile_group_definition( def, e );
}


// ==============================  DISPATCH  ========================================
BEGINDISPATCH(TlpgrEditForm,TTagEditForm)
	DISPATCHTABLE(KXGControlClick,TlpgrEditForm::DoControlClick)
ENDDISPATCH


TlpgrEditForm::TlpgrEditForm( struct tag_entry *e ) : TTagEditForm( e )
{
}

// ==============================  INITIALIZE FORM =======================================
void TlpgrEditForm::DoFormInitialize()
{
	TTagEditForm::DoFormInitialize();

}


// ==============================  INPUT HANDLING  ========================================
long TlpgrEditForm::DoControlClick( long arg, void *ptr )
{
#ifdef __MWERKS__
	#pragma unused(ptr)
#endif

	tag_entry* e;
	tag new_id;
	tag artType = (def.flags & _group_uses_skelmodel_flag) ? 'skmd' : (def.flags&_group_uses_sprite_flag) ? 'spri' : 'core';
	
	switch( arg )
	{
		case 10901:		// Choose a tag
			new_id = pick_tag_of_type(artType, GetTag( arg ), fEntry );
			if(new_id != 0) SetTag( arg, artType, new_id );
		break; 
		
		case 10902:		// Open tag window
			e = get_entry(artType, GetTag( arg-1 ) );
			if(e) TRevengeApp::OpenItem( e );
		break;
		
		case 12000:		// Choose a tag
			new_id = pick_tag_of_type('loli', GetTag( arg ), fEntry );
			if(new_id != 0) SetTag( arg, 'loli', new_id );
		break; 
		
		case 12001:		// Open tag window
			e = get_entry('loli', GetTag( arg-1 ) );
			if(e) TRevengeApp::OpenItem( e );
		break;
		
		case 10903:		// Choose a tag
			new_id = pick_tag_of_type('phys', GetTag( arg ), fEntry );
			if(new_id != 0) SetTag( arg, 'phys', new_id );
		break; 
		
		case 10904:		// Open tag window
			e = get_entry('phys', GetTag( arg-1 ) );
			if(e) TRevengeApp::OpenItem( e );
		break;
		
		case 10970:		// Choose a tag
			new_id = pick_tag_of_type('lpgr', GetTag( arg ), fEntry );
			if(new_id != 0) SetTag( arg, 'lpgr', new_id );
		break; 
		
		case 10971:		// Open tag window
			e = get_entry('lpgr', GetTag( arg-1 ) );
			if(e) TRevengeApp::OpenItem( e );
		break;
		
		case 11000: {
			bool fl = !GetFlag(11000);
			SetFlag(11000, fl);
			def.flags = (fl) ? (def.flags|_group_uses_skelmodel_flag) : (def.flags&~_group_uses_skelmodel_flag);
			artType = (def.flags & _group_uses_skelmodel_flag) ? 'skmd' : (def.flags & _group_uses_sprite_flag) ? 'spri' : 'core';
			SetTag( 10901, artType, def.collection_reference_tag );
			LoadAnimLists();
		} break;
		
		case 11001: {
			bool fl = !GetFlag(11001);
			SetFlag(11001, fl);
			def.flags = (fl) ? (def.flags|_group_uses_sprite_flag) : (def.flags&~_group_uses_sprite_flag);
			artType = (def.flags & _group_uses_skelmodel_flag) ? 'skmd' : (def.flags & _group_uses_sprite_flag) ? 'spri' : 'core';
			SetTag( 10901, artType, def.collection_reference_tag );
			LoadAnimLists();
		} break;
		
		default:
			return -1;
	}
	
	return 0;
}

		
// ========================================  SAVE TO TAG  ==================================================
void TlpgrEditForm::CommitToTag()
{
	GetValues();
	save_local_projectile_group_definition( &def, fEntry );
}


// ========================================  RELOAD TAG  ==================================================
void TlpgrEditForm::ReloadTag()
{
	read_local_projectile_group_definition( &def, fEntry );
	SetValues();
}


// ========================================  TAG NEEDS UPDATING  ==================================================
bool TlpgrEditForm::NeedCommit()
{
	local_projectile_group_definition lpgr_new;

	GetValues();
	read_local_projectile_group_definition( &lpgr_new, fEntry );
	
	for( int ii = 0; ii < sizeof(local_projectile_group_definition); ii++ )
	{
		if( ((byte *)&def)[ii] != ((byte *)&lpgr_new)[ii] )
			return TRUE;
	}
	
	return FALSE;

//	return tag_data_needs_update( "lpgr", fEntry, &def, SIZEOF_STRUCT_LOCAL_PROJECTILE_GROUP_DEFINITION, 1, local_projectile_group_definition_byte_swapping_data);
}

static void ExtractCollectionNames( tag_entry* e, XGStringList* stli )
{
	for(int i = 0; i < 5; i++)
		stli->Insert(i, "someone set up us the bomb!");
}

void TlpgrEditForm::LoadAnimLists()
{
	int i;
	XGStringList stli;
	tag_entry* e;
	char buff[256];
	
	tag artType = (def.flags & _group_uses_skelmodel_flag) ? 'skmd' : (def.flags & _group_uses_sprite_flag) ? 'spri' : 'core';
	
	e = get_entry( artType, GetTag(10901) );
	if(e)
	{
		if( artType == 'skmd' )
			ExtractSKMDNames( e, &stli );
		else
			ExtractCollectionNames( e, &stli );
	}
	else
		stli.Insert(0, "(Entry Not Found)");
		
	XGPopControl* pList1;
	pList1 = dynamic_cast<XGPopControl*>(GetWindow()->FindViewByID( 10905 ));
	assert(pList1);
	pList1->DeleteAll();
	pList1->Insert(0, "(Static)");
	for (i = 0; i < stli.GetNumStrings(); i++) {
		stli.GetString(i, buff);
		pList1->Insert(i+1, buff);
	}
	pList1->SetValue( def.sequence_indexes[_group_sequence_in_flight]+1);

	XGPopControl* pList2;
	pList2 = dynamic_cast<XGPopControl*>(GetWindow()->FindViewByID( 10906 ));
	assert(pList2);
	pList2->DeleteAll();
	pList2->Insert(0, "(Static)");
	for (i = 0; i < stli.GetNumStrings(); i++) {
		stli.GetString(i, buff);
		pList2->Insert(i+1, buff);
	}
	pList2->SetValue( def.sequence_indexes[_group_sequence_stain]+1);
}

// ========================================  SET INTERFACE VALUES  ==================================================
void TlpgrEditForm::SetValues()
{
	tag artType = (def.flags & _group_uses_skelmodel_flag) ? 'skmd' : (def.flags & _group_uses_sprite_flag) ? 'spri' : 'core';
	
	SetTag( 10901, artType, def.collection_reference_tag );
	SetTag( 10903, 'phys', def.physics_tag );
	SetTag( 12000, 'loli', def.local_light_tag );
	
	SetFlag( 11000, (def.flags&_group_uses_skelmodel_flag)==_group_uses_skelmodel_flag);
	SetFlag( 11001, (def.flags&_group_uses_sprite_flag)==_group_uses_sprite_flag);
	
	LoadAnimLists();
	
	SetShortFixed( 10907, def.scale_lower_bound );
	SetShortFixed( 10908, get_upper_bound( def.scale_lower_bound, def.scale_delta ) );
	SetShortFixed( 10909, def.animation_rate_lower_bound );
	SetShortFixed( 10910, get_upper_bound( def.animation_rate_lower_bound, def.animation_rate_delta ) );
	SetInt( 10911, def.target_number_lower_bound );
	SetInt( 10912, get_upper_bound( def.target_number_lower_bound, def.target_number_delta ) );
	SetWorldDistance( 10913, def.radius_lower_bound );
	SetWorldDistance( 10914, get_upper_bound( def.radius_lower_bound, def.radius_delta ) );
	SetInt( 10915, def.expiration_time_lower_bound );
	SetInt( 10916, get_upper_bound( (long)def.expiration_time_lower_bound, (long)def.expiration_time_delta ) );

	SetShortWorldDistance( 10917, def.height_offset );

	XGPopControl* pList3;
	pList3 = dynamic_cast<XGPopControl*>(GetWindow()->FindViewByID( 10918 ));
	assert(pList3);
	pList3->DeleteAll();
	pList3->Insert(0, "Normal");
	pList3->Insert(1, "Fade In Over Time");
	pList3->Insert(2, "Fade In Over Animation");
	pList3->Insert(3, "Fade Out Over Time");
	pList3->Insert(4, "Fade Out Over Animation");
	pList3->SetValue( def.transfer_mode );

	SetFlag( 10919, FALSE );
	if(def.flags&_group_has_startup_transition_flag ) SetFlag( 10919, TRUE );

	SetFlag( 10920, FALSE );
	if(def.flags&_group_has_finite_duration_flag ) SetFlag( 10920, TRUE );

	SetFlag( 10921, FALSE );
	if(def.flags&_group_has_ending_transition_flag ) SetFlag( 10921, TRUE );

	SetFlag( 10922, FALSE );
	if(def.flags&_group_startup_transition_affects_transparency_flag ) SetFlag( 10922, TRUE );

	SetFlag( 10923, FALSE );
	if(def.flags&_group_startup_transition_affects_target_number_flag ) SetFlag( 10923, TRUE );

	SetFlag( 10924, FALSE );
	if(def.flags&_group_has_startup_delay_flag ) SetFlag( 10924, TRUE );

	SetInt( 10925, def.startup_delay_lower_bound );
	SetInt( 10926, get_upper_bound( def.startup_delay_lower_bound, def.startup_delay_delta ) );
	
	SetFlag( 10927, FALSE );
	if(def.flags&_group_startup_transition_affects_scale_flag ) SetFlag( 10927, TRUE );
	
	SetInt( 10930, def.startup_transition_time_lower_bound );
	SetInt( 10931, get_upper_bound( def.startup_transition_time_lower_bound, def.startup_transition_time_delta ) );

	SetInt( 10932, def.duration_lower_bound );
	SetInt( 10933, get_upper_bound( (long)def.duration_lower_bound, (long)def.duration_delta ) );

	SetFlag( 10934, FALSE );
	if(def.flags&_group_ending_transition_affects_transparency_flag ) SetFlag( 10934, TRUE );
	SetFlag( 10935, FALSE );
	if(def.flags&_group_ending_transition_affects_target_number_flag ) SetFlag( 10935, TRUE );
	SetFlag( 10936, FALSE );
	if(def.flags&_group_ending_transition_affects_scale_flag ) SetFlag( 10936, TRUE );

	SetFlag( 10942, FALSE );
	if(def.flags&_group_ending_transition_stop_creating_particles_flag ) SetFlag( 10942, TRUE );

	SetInt( 10943, def.ending_transition_time_lower_bound );
	SetInt( 10944, get_upper_bound( def.ending_transition_time_lower_bound, def.ending_transition_time_delta ) );
	
	SetWorldDistance( 10963, def.initial_z_velocity );
	SetWorldDistance( 10964, def.z_acceleration );

	SetFlag( 10945, FALSE );
	if(def.flags&_group_projectiles_affected_by_wind_flag ) SetFlag( 10945, TRUE );

	SetFlag( 10946, FALSE );
	if(def.flags&_group_projectiles_deleted_when_it_hits_the_ground_flag ) SetFlag( 10946, TRUE );

	SetFlag( 10947, FALSE );
	if(def.flags&_group_projectiles_deleted_after_time_expires_flag ) SetFlag( 10947, TRUE );

	SetFlag( 10948, FALSE );
	if(def.flags&_group_projectiles_deleted_after_animation_completes_flag ) SetFlag( 10948, TRUE );

	SetFlag( 10949, FALSE );
	if(def.flags&_group_projectiles_does_not_animate_flag ) SetFlag( 10949, TRUE );

	SetFlag( 10950, FALSE );
	if(def.flags&_group_projectiles_never_get_recreated_flag ) SetFlag( 10950, TRUE );

	SetFlag( 10951, FALSE );
	if(def.flags&_group_particles_stay_relative_to_the_center_flag ) SetFlag( 10951, TRUE );

	SetFlag( 10937, FALSE );
	if(def.flags&_group_particles_retain_spawn_center_flag ) SetFlag( 10937, TRUE );

	SetFlag( 10952, FALSE );
	if(def.flags&_group_projectiles_are_created_symmetrically_flag ) SetFlag( 10952, TRUE );

	SetFlag( 10953, FALSE );
	if(def.flags&_group_projectiles_dont_respect_height_above_ground_flag ) SetFlag( 10953, TRUE );

	SetFlag( 10954, FALSE );
	if(def.flags&_group_projectiles_always_start_at_first_animation_frame_flag ) SetFlag( 10954, TRUE );

	SetFlag( 10962, FALSE );
	if(def.flags&_group_projectiles_rotate_based_on_view_angle_flag ) SetFlag( 10962, TRUE );

	SetFlag( 10955, FALSE );
	if(def.flags&_group_always_update_physics_flag ) SetFlag( 10955, TRUE );

	SetFlag( 10956, FALSE );
	if(def.flags&_group_delete_after_particles_are_gone_flag ) SetFlag( 10956, TRUE );

	SetFlag( 10957, FALSE );
	if(def.flags&_group_casts_reflections_flag ) SetFlag( 10957, TRUE );

	SetFlag( 10958, FALSE );
	if(def.flags&_group_is_media_surface_effect_flag ) SetFlag( 10958, TRUE );

	SetFlag( 10959, FALSE );
	if(def.flags&_group_update_per_tick_flag ) SetFlag( 10959, TRUE );

	SetFlag( 10960, FALSE );
	if(def.flags&_group_uses_owner_color_table_index_flag ) SetFlag( 10960, TRUE );

	SetFlag( 10961, FALSE );
	if(def.flags&_group_chains_another_lpgr_flag ) SetFlag( 10961, TRUE );
	
	SetTag( 10970, 'lpgr', def.chain_to_lpgr );
}

// ========================================  GET INTERFACE VALUES  ==================================================
void TlpgrEditForm::GetValues()
{
	def.collection_reference_tag = GetTag( 10901 );
	def.physics_tag = GetTag( 10903 );
	def.local_light_tag = GetTag( 12000 );
	
	XGPopControl* pList1;
	pList1 = dynamic_cast<XGPopControl*>(GetWindow()->FindViewByID( 10905 ));
	assert(pList1);
	def.sequence_indexes[_group_sequence_in_flight] = pList1->GetValue()-1;

	XGPopControl* pList2;
	pList2 = dynamic_cast<XGPopControl*>(GetWindow()->FindViewByID( 10906 ));
	assert(pList2);
	def.sequence_indexes[_group_sequence_stain] = pList2->GetValue()-1;

	XGPopControl* pList3;
	pList3 = dynamic_cast<XGPopControl*>(GetWindow()->FindViewByID( 10918 ));
	assert(pList3);
	def.transfer_mode = pList3->GetValue();

	def.scale_lower_bound = GetShortFixed( 10907 );
	def.scale_delta = get_delta( GetShortFixed( 10907 ), GetShortFixed( 10908 ) );
	def.animation_rate_lower_bound = GetShortFixed( 10909 );
	def.animation_rate_delta = get_delta( GetShortFixed( 10909 ), GetShortFixed( 10910 ) );
	def.target_number_lower_bound = GetInt( 10911 );
	def.target_number_delta = get_delta( (long)GetInt( 10911 ), (long)GetInt( 10912 ) );
	def.radius_lower_bound = GetWorldDistance( 10913 );
	def.radius_delta = get_delta( GetWorldDistance( 10913 ), GetWorldDistance( 10914 ) );
	def.expiration_time_lower_bound = GetInt( 10915 );
	def.expiration_time_delta = get_delta( (long)GetInt( 10915 ), (long)GetInt( 10916 ) );
	def.height_offset = GetShortWorldDistance( 10917 );
	def.startup_delay_lower_bound = GetInt( 10925 );
	def.startup_delay_delta = get_delta( (long)GetInt( 10925 ), (long)GetInt( 10926 ) );
	def.startup_transition_time_lower_bound = GetInt( 10930 );
	def.startup_transition_time_delta = get_delta( (long)GetInt( 10930 ), (long)GetInt( 10931 ) );
	def.duration_lower_bound = GetInt( 10932 );
	def.duration_delta = get_delta( (long)GetInt( 10932 ), (long)GetInt( 10933 ) );
	def.ending_transition_time_lower_bound = GetInt( 10943 );
	def.ending_transition_time_delta = get_delta( (long)GetInt( 10943 ), (long)GetInt( 10944 ) );
	def.initial_z_velocity = GetWorldDistance( 10963 );
	def.z_acceleration = GetWorldDistance( 10964 );

	TOGGLE_FLAG( 11000, _group_uses_skelmodel_flag);
	TOGGLE_FLAG( 11001, _group_uses_sprite_flag );
	
	TOGGLE_FLAG( 10919, _group_has_startup_transition_flag );
	TOGGLE_FLAG( 10920, _group_has_finite_duration_flag );
	TOGGLE_FLAG( 10921, _group_has_ending_transition_flag );

	TOGGLE_FLAG( 10922, _group_startup_transition_affects_transparency_flag );
	TOGGLE_FLAG( 10923, _group_startup_transition_affects_target_number_flag );
	TOGGLE_FLAG( 10924, _group_has_startup_delay_flag );
	TOGGLE_FLAG( 10927, _group_startup_transition_affects_scale_flag );

	TOGGLE_FLAG( 10934, _group_ending_transition_affects_transparency_flag );
	TOGGLE_FLAG( 10935, _group_ending_transition_affects_target_number_flag );
	TOGGLE_FLAG( 10936, _group_ending_transition_affects_scale_flag );
	TOGGLE_FLAG( 10942, _group_ending_transition_stop_creating_particles_flag );
	TOGGLE_FLAG( 10962, _group_chains_another_lpgr_flag );

	TOGGLE_FLAG( 10945, _group_projectiles_affected_by_wind_flag );
	TOGGLE_FLAG( 10946, _group_projectiles_deleted_when_it_hits_the_ground_flag );
	TOGGLE_FLAG( 10947, _group_projectiles_deleted_after_time_expires_flag );
	TOGGLE_FLAG( 10948, _group_projectiles_deleted_after_animation_completes_flag );
	TOGGLE_FLAG( 10949, _group_projectiles_does_not_animate_flag );
	TOGGLE_FLAG( 10950, _group_projectiles_never_get_recreated_flag );
	TOGGLE_FLAG( 10951, _group_particles_stay_relative_to_the_center_flag );
	TOGGLE_FLAG( 10937, _group_particles_retain_spawn_center_flag );
	TOGGLE_FLAG( 10952, _group_projectiles_are_created_symmetrically_flag );
	TOGGLE_FLAG( 10953, _group_projectiles_dont_respect_height_above_ground_flag );
	TOGGLE_FLAG( 10954, _group_projectiles_always_start_at_first_animation_frame_flag );
	TOGGLE_FLAG( 10962, _group_projectiles_rotate_based_on_view_angle_flag );

	TOGGLE_FLAG( 10955, _group_always_update_physics_flag );
	TOGGLE_FLAG( 10956, _group_delete_after_particles_are_gone_flag );
	TOGGLE_FLAG( 10957, _group_casts_reflections_flag );
	TOGGLE_FLAG( 10958, _group_is_media_surface_effect_flag ); 
	TOGGLE_FLAG( 10959, _group_update_per_tick_flag );
	TOGGLE_FLAG( 10960, _group_uses_owner_color_table_index_flag );
	TOGGLE_FLAG( 10961, _group_chains_another_lpgr_flag );
	
	def.chain_to_lpgr = GetTag( 10970 );
}

