#include "SCR.h"
#include "SND.H"
#include "SIF.h"
#include "SifLoadS.h"
 
#include "ldt.h"
 
extern enum _SIF_eInfoTypeId
{
	ENVIRONMENT_INFO,
	MATERIAL_INFO,
	NB_INFO_TYPES,
} SIF_eInfoTypeId;
 
extern SIF_tdstInfoType SIF_ga_stInfoDescr[NB_INFO_TYPES];
 
 
 
 
/*****************************************************************
Function name   : fn_iLoadInfoType
Description     : 
Author          : Ovidiu Scripa (oscripa@ubisoft.ro) - ROMTEAM
Creation Date   : 14-Oct-98
Modified        : 
Return type     : int 
Argument        : LDT_tdst_Link *pLink
*****************************************************************/
int fn_iLoadInfoType( LDT_tdst_Link *pLink )
{
  LDT_tdeParseResult result=ParseResult_BeginSection;
  char* szAction = LDT_szGetSectionName();
 
	if (strcmp(szAction,"Material")==0) 
  {
    pLink->pObject = (void*)MATERIAL_INFO;
  }
	else if (strcmp(szAction,"Environment")==0) 
  {
    pLink->pObject = (void*)ENVIRONMENT_INFO;
  }
  else
  {	
	  SND_fn_vDisplayError(E_uwSndInvalidTypeOfResource,"SIF:Unknown Sound Info Type found in scrip");
    return 1;
  }
 
  while( result!=ParseResult_EndSection ) 
  {
  	result=LDT_GetNextEntry();
  	switch( result )
  	{
			case ParseResult_BeginSection: /* a subsection - CreateNewState*/
			{
				LDT_LoadSection( NULL );
			}
			break;
  	}
  }
 
  return 0;
}
 
 
 
/*****************************************************************
Function name   : fn_iLoadInfoValue
Description     : 
Author          : Ovidiu Scripa (oscripa@ubisoft.ro) - ROMTEAM
Creation Date   : 14-Oct-98
Modified        : 
Return type     : int 
Argument        : LDT_tdst_Link *pLink
*****************************************************************/
int fn_iLoadInfoValue( LDT_tdst_Link *pLink )
{
  LDT_tdeParseResult result=ParseResult_BeginSection;
	int iInfoType = (int)pLink->pParent->pObject;
	char szSectionName[_MAX_PATH];
/*	char szValueName[_MAX_PATH], szFile[_MAX_PATH], szParent[MAX_PATH], szType[_MAX_PATH];*/
    
  while( result!=ParseResult_EndSection ) 
  {
  	result=LDT_GetNextEntry();
  	switch( result )
  	{
  	  case ParseResult_Entry: /* an entry : SetValue*/
  	  {
        int iLen = LDT_ComputeSectionName( pLink, szSectionName );
 
				SCR_fnp_st_Link_SetValue(&SIF_ga_stInfoDescr[iInfoType].m_Table,/* Link table*/
											szSectionName + iLen,	/* Section name*/
											(unsigned long)(pLink->pObject = (void*)(atoi(LDT_szGetParam(1)))) );/* value*/
 
  	  }
  	}
  }
 
  
  return 0;
}
