 
#include "ToolsCPA.h"
 
#include "Options/Options.h"
#include "macros.h"
 
#include "Main.h"
 
#include "Actions/AllActs.h"
 
#include "Structur/GameScpt.h"
#include "Structur/ErrGame.h"
#include "Structur/Objects.h"
#include "Structur/MemGame.h"
#include "Structur/EngMode.h"
#include "Structur/Input_s.h"
 
#include "Engine.h"
#include "ZeMem.h"
#include "LoadGame.h"
#include "Input.h"
#include "Basic.h"
#include "GamOpt.h"
#include "LoadBin.h"
 
#include "sna.h"
 
#ifndef U64
extern char g_cCDROM;
extern int g_iComplete;
#endif
extern char g_sLanguage[255];
 
 
#define LDT_SCR_HYBRID_VERSION /* this is for script/ldt interfacing*/
 
/* MLT CC BEGIN 9/23/98 */
#ifdef CPA_USES_LDT
#include "ldt.h"
 
/*BEGIN FS 8/27/98*/
/*----------------------------------------------------------------------
 *  Description: Callback for DirectoriesDescription section from .dsc sript file
 *				 This section describs the directories scripts
 *----------------------------------------------------------------------
 *  Input:
 *  Output:
 *----------------------------------------------------------------------
 *  Author: FS
 *  Creation date:8/27/98
 *  Modif date:
 *----------------------------------------------------------------------*/
int LoadDirectoriesDescription( LDT_tdst_Link *pLink )
{
	LDT_tdeParseResult result=ParseResult_BeginSection;
	char szFileName[_MAX_PATH];
	char szPath[_MAX_PATH];
	static char szInventorDirectory[_MAX_PATH];
    char a256_cDataDirectory[_MAX_PATH];
	char *szEntryName;
	
	/*Working for BeginSection*/
	if ( SNA_M_bTestSaveGameDesc() )
		SNA_fn_vWriteNoParamEntryToCurrentDscFile( SNA_C_ul_DirectoryDescTitle );
 
	/* Working for Entries*/
	result=LDT_GetNextEntry();
	while( result!=ParseResult_EndSection )
	{
		szEntryName=LDT_szGetEntryName();
		switch (*(long*)(szEntryName+ 11 /*"DirectoryOf"*/))
		{
		case 'ignE': /*"EngineDLL"*/
			fn_vSetEngineDLLPath(LDT_szGetParam(1));
            if (SNA_M_bTestSaveGameDesc())
                SNA_fn_vWriteStringEntryToCurrentDscFile(SNA_C_ul_DirectoryOfEngineDLL,LDT_szGetParam(1));
			break;
		case 'emaG': /*"GameData"*/
			/* MLT CC BEGIN 10/6/98 */
/*			if(g_iComplete)*/
/*			{*/
				LDT_AddBaseDirectory(LDT_szGetParam(1));
				LDT_AddBaseDirectory(gsz_Version);
				LDT_AddBaseDirectory(gsz_Version1);
/*			}*/
			if(!g_iComplete)
			{
				sprintf(szPath,"%c:\\%s",g_cCDROM,LDT_szGetParam(1));
				LDT_AddBaseDirectory(szPath);
				sprintf(szPath,"%c:\\%s",g_cCDROM,gsz_Version);
				LDT_AddBaseDirectory(szPath);
				sprintf(szPath,"%c:\\%s",g_cCDROM,gsz_Version1);
				LDT_AddBaseDirectory(szPath);
			}
			LDT_RegisterPath("", "DSC FIX PGB MEM TXT RND");
			#ifdef LDT_SCR_HYBRID_VERSION
			SCR_fn_v_RdL0_RegisterPath(LDT_szGetParam(1));
			#endif
			/* MLT CC END   10/6/98 */
            if (SNA_M_bTestSaveGameDesc())
                SNA_fn_vWriteStringEntryToCurrentDscFile(SNA_C_ul_DirectoryOfGameData,LDT_szGetParam(1));
			break;
		case 'txeT':
			if ((*(long*)(szEntryName+12 /*"DirectoryOfT"*/))=='stxe')
			{	/*"Texts"*/
				/* MLT CC BEGIN 10/6/98 */
				LDT_RegisterPath(LDT_szGetParam(1), "TXT");
				sprintf(szPath,"%s\\%s",LDT_szGetParam(1),g_sLanguage);
				LDT_RegisterPath(szPath, "TXT");
				/* MLT CC END   10/6/98 */
				#ifdef LDT_SCR_HYBRID_VERSION
				strcpy(a256_cDataDirectory, g_a64_cGameDataDirectory);
				strcat(a256_cDataDirectory,LDT_szGetParam(1));
				fn_vSetTextsDataPath(a256_cDataDirectory);
				SCR_fn_v_RdL0_RegisterPath(a256_cDataDirectory);
 
				sprintf(szPath,"%s\\%s",a256_cDataDirectory,g_sLanguage);
				/*SCR_fn_v_RdL0_RegisterPath(a256_cDataDirectory);*/
		        SCR_fn_v_RdL0_RegisterPath(szPath);
				#endif
	            if ( SNA_M_bTestSaveGameDesc() )
		            SNA_fn_vWriteStringEntryToCurrentDscFile(SNA_C_ul_DirectoryOfTexts,LDT_szGetParam(1));
			}
			else
			{	/*"Texture"*/
				strcpy(a256_cDataDirectory, g_a64_cGameDataDirectory);
				strcat(a256_cDataDirectory,LDT_szGetParam(1));
				fn_vSetTexturesDataPath(a256_cDataDirectory);
				GLI_vSetPathOfTexture(fn_szGetTexturesDataPath());
	            if ( SNA_M_bTestSaveGameDesc() )
		            SNA_fn_vWriteStringEntryToCurrentDscFile(SNA_C_ul_DirectoryOfTexture,LDT_szGetParam(1));
			}
			break;
		case 'lroW': /*"World"*/
			strcpy(a256_cDataDirectory, g_a64_cGameDataDirectory);
			strcat(a256_cDataDirectory,LDT_szGetParam(1));
			fn_vSetWorldDataPath(a256_cDataDirectory);
			#ifdef LDT_SCR_HYBRID_VERSION
			SCR_fn_v_RdL0_RegisterPath(a256_cDataDirectory);
			#endif
            if ( SNA_M_bTestSaveGameDesc() )
                SNA_fn_vWriteStringEntryToCurrentDscFile(SNA_C_ul_DirectoryOfWorld,LDT_szGetParam(1));
			break;
		case 'eveL': /*"Levels"*/
			LDT_RegisterPath(LDT_szGetParam(1),"ALW CAR DSC GMT IPO LGT LVL MDF MEM MOD PGB PHY RLI SCT SPO SRF TEX VMT VSE WAY WP ZDX ZOO MDT");
			strcpy(a256_cDataDirectory, g_a64_cGameDataDirectory);
			strcat(a256_cDataDirectory,LDT_szGetParam(1));
			fn_vSetLevelsDataPath(a256_cDataDirectory);
			#ifdef LDT_SCR_HYBRID_VERSION
			SCR_fn_v_RdL0_RegisterPath(a256_cDataDirectory);
			#endif
            if ( SNA_M_bTestSaveGameDesc() )
                SNA_fn_vWriteStringEntryToCurrentDscFile(SNA_C_ul_DirectoryOfLevels,LDT_szGetParam(1));
			break;
		case 'imaF': /*"Families"*/
			LDT_RegisterPath(LDT_szGetParam(1),"ACE ACZ AI BDV CAR CHL DEC EDE EMA EMC ENL ERF ERU ESB GMT LGT MAC MOD PHY RFX RUL STA TEX TBL VMT VSE ZDX ZOO");
			strcpy(a256_cDataDirectory, g_a64_cGameDataDirectory);
			strcat(a256_cDataDirectory,LDT_szGetParam(1));
			fn_vSetFamiliesDataPath(a256_cDataDirectory);
			#ifdef LDT_SCR_HYBRID_VERSION
			SCR_fn_v_RdL0_RegisterPath(a256_cDataDirectory);
			#endif
            if ( SNA_M_bTestSaveGameDesc() )
                SNA_fn_vWriteStringEntryToCurrentDscFile(SNA_C_ul_DirectoryOfFamilies,LDT_szGetParam(1));
			break;
		case 'rahC': /*"Characters"*/
			LDT_RegisterPath(LDT_szGetParam(1),"CAR");
			strcpy(a256_cDataDirectory, g_a64_cGameDataDirectory);
			strcat(a256_cDataDirectory,LDT_szGetParam(1));
			fn_vSetCharactersDataPath(a256_cDataDirectory);
			#ifdef LDT_SCR_HYBRID_VERSION
			SCR_fn_v_RdL0_RegisterPath(a256_cDataDirectory);
			#endif
            if ( SNA_M_bTestSaveGameDesc() )
                SNA_fn_vWriteStringEntryToCurrentDscFile(SNA_C_ul_DirectoryOfCharacters,LDT_szGetParam(1));
			break;
		case 'minA': /*"Animations"*/
			LDT_RegisterPath(LDT_szGetParam(1),"A3D A3B");
			strcpy(a256_cDataDirectory, g_a64_cGameDataDirectory);
			strcat(a256_cDataDirectory,LDT_szGetParam(1));
			fn_vSetAnimDataPath(a256_cDataDirectory);
			#ifdef LDT_SCR_HYBRID_VERSION
			SCR_fn_v_RdL0_RegisterPath(a256_cDataDirectory);
			#endif
            if ( SNA_M_bTestSaveGameDesc() )
                SNA_fn_vWriteStringEntryToCurrentDscFile(SNA_C_ul_DirectoryOfAnimations,LDT_szGetParam(1));
			break;
		case 'parG':
			if ((*(long*)(szEntryName+19/*"DirectoryOfGraphics"*/))=='salC')
			{	/*"GraphicsClasses"*/
				LDT_RegisterPath(LDT_szGetParam(1),"GMT MOD PHY TBL TEX VMT VSE ZOO");
				strcpy(a256_cDataDirectory, g_a64_cGameDataDirectory);
				strcat(a256_cDataDirectory,LDT_szGetParam(1));
				fn_vSetGraphicsClassesDataPath(a256_cDataDirectory);
				#ifdef LDT_SCR_HYBRID_VERSION
				SCR_fn_v_RdL0_RegisterPath(a256_cDataDirectory);
				#endif
	            if ( SNA_M_bTestSaveGameDesc() )
		            SNA_fn_vWriteStringEntryToCurrentDscFile(SNA_C_ul_DirectoryOfGraphicsClasses,LDT_szGetParam(1));
			}
			else
			{	/*"GraphicsBanks"*/
				LDT_RegisterPath(LDT_szGetParam(1),"AI ACE ACZ BDV CHL DEC EDE EMA EMO EMC ENL ERF ERU ESB GMT MAC MOD PHY RFX RLI RUL SPO STA TBL TEX VMT VSE ZDX ZOO");
				strcpy(a256_cDataDirectory, g_a64_cGameDataDirectory);
				strcat(a256_cDataDirectory,LDT_szGetParam(1));
				fn_vSetGraphicsBanksDataPath(a256_cDataDirectory);
				#ifdef LDT_SCR_HYBRID_VERSION
				SCR_fn_v_RdL0_RegisterPath(a256_cDataDirectory);
				#endif
	            if ( SNA_M_bTestSaveGameDesc() )
		            SNA_fn_vWriteStringEntryToCurrentDscFile(SNA_C_ul_DirectoryOfGraphicsBanks,LDT_szGetParam(1));
			}
			break;
		case 'hceM': /*"Mechanics"*/
			LDT_RegisterPath(LDT_szGetParam(1),"MEC");
			strcpy(a256_cDataDirectory, g_a64_cGameDataDirectory);
			strcat(a256_cDataDirectory,LDT_szGetParam(1));
			fn_vSetMechanicsDataPath(a256_cDataDirectory);
			#ifdef LDT_SCR_HYBRID_VERSION
			SCR_fn_v_RdL0_RegisterPath(a256_cDataDirectory);
			#endif
            if ( SNA_M_bTestSaveGameDesc() )
                SNA_fn_vWriteStringEntryToCurrentDscFile(SNA_C_ul_DirectoryOfMechanics,LDT_szGetParam(1));
			break;
		case 'nuoS': /*"Sound"*/
			LDT_RegisterPath(LDT_szGetParam(1),"CSB LCB SIF");
			strcpy(a256_cDataDirectory, g_a64_cGameDataDirectory);
			strcat(a256_cDataDirectory,LDT_szGetParam(1));
			fn_vSetGraphicsClassesDataPath(a256_cDataDirectory);
			#ifdef LDT_SCR_HYBRID_VERSION
			SCR_fn_v_RdL0_RegisterPath(a256_cDataDirectory);
			#endif
			
			strcpy(szFileName, g_a64_cGameDataDirectory);
			strcat(szFileName,LDT_szGetParam(1));
			fn_vSetSoundDataPath(szFileName);
			#ifdef LDT_SCR_HYBRID_VERSION
			SCR_fn_v_RdL0_RegisterPath(szFileName);
			#endif
			strcat(szFileName,"\\");
			SND_fn_vAddDataDirectory(szFileName);
			sprintf(szPath,"%s%s\\",szFileName,g_sLanguage);
			SND_fn_vAddDataDirectory(szPath);
			if(!g_iComplete)
			{
				sprintf(szPath,"%c:\\%s",g_cCDROM,szFileName);
				strcpy( szFileName, szPath);
				SND_fn_vAddDataDirectory(szFileName);
				sprintf(szPath,"%s%s\\",szFileName,g_sLanguage);
				SND_fn_vAddDataDirectory(szPath);
			}
            if ( SNA_M_bTestSaveGameDesc() )
                SNA_fn_vWriteStringEntryToCurrentDscFile(SNA_C_ul_DirectoryOfSound,LDT_szGetParam(1));
			break;
		case 'usiV': /*"Visuals"*/
			LDT_RegisterPath(LDT_szGetParam(1),"VMT VSE TEX");
			strcpy(a256_cDataDirectory, g_a64_cGameDataDirectory);
			strcat(a256_cDataDirectory,LDT_szGetParam(1));
			fn_vSetVisualMaterialDataPath(a256_cDataDirectory);
			#ifdef LDT_SCR_HYBRID_VERSION
			SCR_fn_v_RdL0_RegisterPath(a256_cDataDirectory);
			#endif
            if ( SNA_M_bTestSaveGameDesc() )
                SNA_fn_vWriteStringEntryToCurrentDscFile(SNA_C_ul_DirectoryOfVisuals,LDT_szGetParam(1));
			break;
		case 'ivnE': /*"Environment"*/
			LDT_RegisterPath(LDT_szGetParam(1),"GEV MEV VEV");
			strcpy(a256_cDataDirectory, g_a64_cGameDataDirectory);
			strcat(a256_cDataDirectory,LDT_szGetParam(1));
			fn_vSetEnvironmentDataPath(a256_cDataDirectory);
			#ifdef LDT_SCR_HYBRID_VERSION
			SCR_fn_v_RdL0_RegisterPath(a256_cDataDirectory);
			#endif
            if ( SNA_M_bTestSaveGameDesc() )
                SNA_fn_vWriteStringEntryToCurrentDscFile(SNA_C_ul_DirectoryOfEnvironment,LDT_szGetParam(1));
			break;
		case 'etaM': /*"Materials"*/
			LDT_RegisterPath(LDT_szGetParam(1),"CMT EMC GMT MMT VMT");
			strcpy(a256_cDataDirectory, g_a64_cGameDataDirectory);
			strcat(a256_cDataDirectory,LDT_szGetParam(1));
			fn_vSetCollideMaterialDataPath(a256_cDataDirectory);
			fn_vSetSoundMaterialDataPath(a256_cDataDirectory);
			fn_vSetMechanicsMaterialDataPath(a256_cDataDirectory);
			fn_vSetGameMaterialDataPath(a256_cDataDirectory);
			#ifdef LDT_SCR_HYBRID_VERSION
			SCR_fn_v_RdL0_RegisterPath(a256_cDataDirectory);
			#endif
            if ( SNA_M_bTestSaveGameDesc() )
                SNA_fn_vWriteStringEntryToCurrentDscFile(SNA_C_ul_DirectoryOfMaterials,LDT_szGetParam(1));
			break;
		case 'evaS': /*"SaveGame"*/
			strcpy(a256_cDataDirectory, g_a64_cGameDataDirectory);
			strcat(a256_cDataDirectory,LDT_szGetParam(1));
			fn_vSetSaveGameDataPath(a256_cDataDirectory);
            if ( SNA_M_bTestSaveGameDesc() )
                SNA_fn_vWriteStringEntryToCurrentDscFile(SNA_C_ul_DirectoryOfSaveGame,LDT_szGetParam(1));
			break;
		case 'rtxE': /*"Extras"*/
			strcpy(a256_cDataDirectory, g_a64_cGameDataDirectory);
			strcat(a256_cDataDirectory,LDT_szGetParam(1));
			fn_vSetExtrasDataPath(a256_cDataDirectory);
            if ( SNA_M_bTestSaveGameDesc() )
                SNA_fn_vWriteStringEntryToCurrentDscFile(SNA_C_ul_DirectoryOfExtras,LDT_szGetParam(1));
			break;
		case 'ngiV': /*"Vignettes"*/
			strcpy(a256_cDataDirectory, g_a64_cGameDataDirectory);
			strcat(a256_cDataDirectory,LDT_szGetParam(1));
			fn_vSetVignettesDataPath(a256_cDataDirectory);
            if ( SNA_M_bTestSaveGameDesc() )
                SNA_fn_vWriteStringEntryToCurrentDscFile(SNA_C_ul_DirectoryOfVignettes,LDT_szGetParam(1));
			break;
		case 'itpO': /*"Options"*/
			LDT_RegisterPath(LDT_szGetParam(1),"IPT");
			strcpy(a256_cDataDirectory, g_a64_cGameDataDirectory);
			strcat(a256_cDataDirectory,LDT_szGetParam(1));
			fn_vSetOptionsDataPath(a256_cDataDirectory);
			#ifdef LDT_SCR_HYBRID_VERSION
			SCR_fn_v_RdL0_RegisterPath(a256_cDataDirectory);
			#endif
            if ( SNA_M_bTestSaveGameDesc() )
                SNA_fn_vWriteStringEntryToCurrentDscFile(SNA_C_ul_DirectoryOfOptions,LDT_szGetParam(1));
			break;
		case 'spiL': /*"LipsSync"*/
/*			LDT_RegisterPath(LDT_szGetParam(1),"");*/
/*			sprintf(szPath,"%s\\%s",,LDT_szGetParam(1),g_sLanguage);*/
/*			LDT_RegisterPath(szPath,"");*/
			strcpy(a256_cDataDirectory, g_a64_cGameDataDirectory);
			strcat(a256_cDataDirectory,LDT_szGetParam(1));
			#ifdef LDT_SCR_HYBRID_VERSION
			SCR_fn_v_RdL0_RegisterPath(a256_cDataDirectory);
			#endif
			sprintf(szPath,"%s\\%s",a256_cDataDirectory,g_sLanguage);
			fn_vSetSyncLipsDataPath(szPath);
			#ifdef LDT_SCR_HYBRID_VERSION
			SCR_fn_v_RdL0_RegisterPath(szPath);
			#endif
            if ( SNA_M_bTestSaveGameDesc() )
                SNA_fn_vWriteStringEntryToCurrentDscFile(SNA_C_ul_DirectoryOfLipsSync,LDT_szGetParam(1));
			break;
		case 'xdZ': /*"Zdx"*/
			strcpy(a256_cDataDirectory, g_a64_cGameDataDirectory);
			strcat(a256_cDataDirectory,LDT_szGetParam(1));
			fn_vSetZdxDataPath(a256_cDataDirectory);
            if ( SNA_M_bTestSaveGameDesc() )
                SNA_fn_vWriteStringEntryToCurrentDscFile(SNA_C_ul_DirectoryOfZdx,LDT_szGetParam(1));
			break;
		case 'effE': /*"Effects"*/
/*			LDT_RegisterPath(LDT_szGetParam(1),"");*/
			strcpy(a256_cDataDirectory, g_a64_cGameDataDirectory);
			strcat(a256_cDataDirectory,LDT_szGetParam(1));
			fn_vSetEffectsDataPath(a256_cDataDirectory);
			#ifdef LDT_SCR_HYBRID_VERSION
			SCR_fn_v_RdL0_RegisterPath(a256_cDataDirectory);
			#endif
            if ( SNA_M_bTestSaveGameDesc() )
                SNA_fn_vWriteStringEntryToCurrentDscFile(SNA_C_ul_DirectoryOfEffects,LDT_szGetParam(1));
		} /* end switch*/
		result=LDT_GetNextEntry();
	} /*end while for entries*/
 
 
	/* Working for EndSection*/
    if ( SNA_M_bTestSaveGameDesc() )
        SNA_fn_vWriteNoParamEntryToCurrentDscFile( SNA_C_ulEndOfDescSection );
 
#ifndef U64
#ifdef LDT_SCR_HYBRID_VERSION
	if (!g_iComplete)
	{
		strcpy( szFileName, fn_szGetGameDataPath() );
		sprintf(szPath,"%c:\\%s",g_cCDROM,szFileName);
		SCR_fn_v_RdL0_RegisterPath(szPath);
		strcpy( szFileName, fn_szGetWorldDataPath() );
		sprintf(szPath,"%c:\\%s",g_cCDROM,szFileName);
		SCR_fn_v_RdL0_RegisterPath(szPath);
 
		strcpy( szFileName, fn_szGetTextsDataPath() );
		sprintf(szPath,"%c:\\%s",g_cCDROM,szFileName);
		SCR_fn_v_RdL0_RegisterPath(szPath);
		sprintf(szFileName,"%s\\%s",szPath,g_sLanguage);
		SCR_fn_v_RdL0_RegisterPath(szFileName);
 
		strcpy( szFileName, fn_szGetFamiliesDataPath() );
		sprintf(szPath,"%c:\\%s",g_cCDROM,szFileName);
		SCR_fn_v_RdL0_RegisterPath(szPath);
		strcpy( szFileName, fn_szGetCharactersDataPath() );
		sprintf(szPath,"%c:\\%s",g_cCDROM,szFileName);
		SCR_fn_v_RdL0_RegisterPath(szPath);
		strcpy( szFileName, fn_szGetLevelsDataPath() );
		sprintf(szPath,"%c:\\%s",g_cCDROM,szFileName);
		SCR_fn_v_RdL0_RegisterPath(szPath);
		strcpy( szFileName, fn_szGetAnimDataPath() );
		sprintf(szPath,"%c:\\%s",g_cCDROM,szFileName);
		SCR_fn_v_RdL0_RegisterPath(szPath);
		strcpy( szFileName, fn_szGetGameMaterialDataPath() );
		sprintf(szPath,"%c:\\%s",g_cCDROM,szFileName);
		SCR_fn_v_RdL0_RegisterPath(szPath);
		strcpy( szFileName, fn_szGetVisualMaterialDataPath() );
		sprintf(szPath,"%c:\\%s",g_cCDROM,szFileName);
		SCR_fn_v_RdL0_RegisterPath(szPath);
		strcpy( szFileName, fn_szGetSoundDataPath() );
		sprintf(szPath,"%c:\\%s",g_cCDROM,szFileName);
		SCR_fn_v_RdL0_RegisterPath(szPath);
		strcat(szPath,"\\");
		SND_fn_vAddDataDirectory(szPath);
		sprintf(szFileName,"%s%s",szPath,g_sLanguage);
		SCR_fn_v_RdL0_RegisterPath(szFileName);
		strcat(szFileName,"\\");
		SND_fn_vAddDataDirectory(szFileName);
 
		strcpy( szFileName, fn_szGetGraphicsClassesDataPath() );
		sprintf(szPath,"%c:\\%s",g_cCDROM,szFileName);
		SCR_fn_v_RdL0_RegisterPath(szPath);
		strcpy( szFileName, fn_szGetGraphicsBanksDataPath() );
		sprintf(szPath,"%c:\\%s",g_cCDROM,szFileName);
		SCR_fn_v_RdL0_RegisterPath(szPath);
		strcpy( szFileName, fn_szGetMechanicsDataPath() );
		sprintf(szPath,"%c:\\%s",g_cCDROM,szFileName);
		SCR_fn_v_RdL0_RegisterPath(szPath);
		strcpy( szFileName, fn_szGetEnvironmentDataPath() );
		sprintf(szPath,"%c:\\%s",g_cCDROM,szFileName);
		SCR_fn_v_RdL0_RegisterPath(szPath);
		strcpy( szFileName, fn_szGetOptionsDataPath() );
		sprintf(szPath,"%c:\\%s",g_cCDROM,szFileName);
		SCR_fn_v_RdL0_RegisterPath(szPath);
		strcpy( szFileName, fn_szGetSyncLipsDataPath() );
		sprintf(szPath,"%c:\\%s",g_cCDROM,szFileName);
		SCR_fn_v_RdL0_RegisterPath(szPath);
		strcpy( szFileName, fn_szGetEffectsDataPath() );
		sprintf(szPath,"%c:\\%s",g_cCDROM,szFileName);
		SCR_fn_v_RdL0_RegisterPath(szPath);
 
		strcpy( szFileName, szInventorDirectory );
		sprintf(szPath,"%c:\\%s",g_cCDROM,szFileName);
		SCR_fn_v_RdL0_RegisterPath(szPath);
		sprintf(szFileName,"%s\\%s",szPath,g_sLanguage);
		SCR_fn_v_RdL0_RegisterPath(szFileName);
 	}
#endif
#endif
	return 0;
}
/*END FS 8/27/98*/
 
/*BEGIN FS 9/2/98*/
/*----------------------------------------------------------------------
 *  Description: Callback InputDeviceManager section from .dsc sript file
 *----------------------------------------------------------------------
 *  Input:
 *  Output:
 *----------------------------------------------------------------------
 *  Author: FS
 *  Creation date:9/2/98
 *  Modif date:
 *----------------------------------------------------------------------*/
int LoadInputDeviceManagerDescription( LDT_tdst_Link *pLink )
{
	LDT_tdeParseResult result=ParseResult_BeginSection;
	char *szEntryName;
	
	/* Working for Entries*/
	result=LDT_GetNextEntry();
	while( result!=ParseResult_EndSection )
	{
		szEntryName=LDT_szGetEntryName();
		switch (*(long*)(szEntryName))
		{
		case 'tinI': /*"InitInputDeviceManager"*/
			IPT_fn_vInitInput((short)fn_lAToI(LDT_szGetParam(1)),fn_hGetApplicationInstance(),fn_hGetApplicationWindow());
			break;
		case 'IddA': /*"AddInputDeviceFile"*/
/*			IPT_fn_vReadInputScript(LDT_szGetParam(1));*/
/*!!! functia de sus nu face decat instr. urmatoare*/
/*			SCR_fnp_st_RdL0_AnalyseSection(LDT_szGetParam(1), SCR_CDF_uw_Anl_ForceAnalyse);*/
/*!!! introduc LDT_LoadSection doar dupa implementare .IPT-uri*/
			LDT_LoadSection(LDT_szGetParam(1));
			break;
		} /* end switch*/
		result=LDT_GetNextEntry();
	} /*end while for entries*/
 
	return 0;
}
/*END FS 9/2/98*/
 
/*BEGIN FS 9/2/98*/
/*----------------------------------------------------------------------
 *  Description: callback for RandomManagerDescription section from .dsc script file
 *----------------------------------------------------------------------
 *  Input:
 *  Output:
 *----------------------------------------------------------------------
 *  Author: FS
 *  Creation date:9/2/98
 *  Modif date:
 *----------------------------------------------------------------------*/
int LoadRandomManagerDescription( LDT_tdst_Link *pLink )
{
	LDT_tdeParseResult result=ParseResult_BeginSection;
	char *szEntryName;
	
	/* Working for Entries*/
	result=LDT_GetNextEntry();
	while( result!=ParseResult_EndSection )
	{
		szEntryName=LDT_szGetEntryName();
		switch (*(long*)(szEntryName))
		{
		case 'tinI': /*"InitRandomManager"*/
			RND_fn_vInitRandom();
/*!!! aici se va lucra pe LDT cand se va implementa si .RND*/
			/*urmatoarea functie face un AnalyseSection la sectiunea al carui callback */
			/*	s-a inregistrat incarcat RND_fn_vInitRandom()*/
			RND_fn_vReadRandomScript(LDT_szGetParam(1));
			break;
		} /* end switch*/
		result=LDT_GetNextEntry();
	} /*end while for entries*/
 
	return 0;
}
/*END FS 9/2/98*/
 
/*BEGIN FS 9/2/98*/
/*----------------------------------------------------------------------
 *  Description: callback for GameOptionsFile section from .dsc sript file
 *----------------------------------------------------------------------
 *  Input:
 *  Output:
 *----------------------------------------------------------------------
 *  Author: FS
 *  Creation date:9/2/98
 *  Modif date:
 *----------------------------------------------------------------------*/
int LoadGameOptionsFileDescription( LDT_tdst_Link *pLink )
{
	LDT_tdeParseResult result=ParseResult_BeginSection;
	char *szEntryName;
	
	/* Working for BeginSection*/
    if ( SNA_M_bTestSaveGameDesc() )
        SNA_fn_vWriteNoParamEntryToCurrentDscFile( SNA_C_ul_GameOptionDescTitle );
 
	/* Working for Entries*/
	result=LDT_GetNextEntry();
	while( result!=ParseResult_EndSection )
	{
        if ( SNA_M_bTestSaveGameDesc() )
            SNA_fn_vWriteNoParamEntryToCurrentDscFile( SNA_C_ul_GameOptionDescTitle );
		szEntryName=LDT_szGetEntryName();
		switch (*(long*)(szEntryName))
		{
/*		case 'dreC': //"CreditsLevelName"*/
/*			strcpy(g_stEngineStructure.szCreditsLevelName,LDT_szGetParam(1));*/
/*			break;*/
/*		case 'pikS': //"SkipMainMenu"*/
/*			g_stEngineStructure.bSkipMainMenu = TRUE;*/
/*			break;*/
		case 'afeD': /*"DefaultFile"*/
			fn_vSetDefaultGameOptionsFileName(LDT_szGetParam(1));
	        if ( SNA_M_bTestSaveGameDesc() )
			    SNA_fn_vWriteStringEntryToCurrentDscFile(SNA_C_ul_BigFileTextures,LDT_szGetParam(1));
			break;
		case 'rruC': /*"CurrentFile"*/
			fn_vSetCurrentGameOptionsFileName(LDT_szGetParam(1));
	        if ( SNA_M_bTestSaveGameDesc() )
			    SNA_fn_vWriteStringEntryToCurrentDscFile(SNA_C_ul_BigFileTextures,LDT_szGetParam(1));
			break;
		case 'marF': /*"FrameSynchro"*/
			/* ON/OFF, NbFrame (0 for hysteresis) and %limit for hysteresis*/
			{
				char a[50], b[100], c[100];
				strcpy(a, LDT_szGetParam(1));
				strcpy(b, LDT_szGetParam(2));
				strcpy(c, LDT_szGetParam(3));
			GLD_vSetFrameSynchro( a,b,c);
	        if ( SNA_M_bTestSaveGameDesc() )
				SNA_fn_vWrite3StringsEntryToCurrentDscFile(SNA_C_ul_FrameSynchro, a,b,c);
			}
		} /* end switch*/
		result=LDT_GetNextEntry();
	} /*end while for entries*/
	if ( SNA_M_bTestSaveGameDesc() )
		SNA_fn_vWriteNoParamEntryToCurrentDscFile( SNA_C_ulEndOfDescSection );
 
	return 0;
}
/*END FS 9/2/98*/
 
 
/*BEGIN FS 9/2/98*/
/*----------------------------------------------------------------------
 *  Description: callback for FirstLevelDescription from .dsc sript file
 *----------------------------------------------------------------------
 *  Input:
 *  Output:
 *----------------------------------------------------------------------
 *  Author: FS
 *  Creation date:9/2/98
 *  Modif date:
 *----------------------------------------------------------------------*/
int LoadFirstLevelDescription( LDT_tdst_Link *pLink )
{
	LDT_tdeParseResult result=ParseResult_BeginSection;
	char *szEntryName;
	
	/* Working for BeginSection*/
	g_cChooseLevel = -1;
	g_stEngineStructure.ucNumberOfLevels = 0;
	g_stEngineStructure.ucCurrentLevel = (unsigned char) ((LDT_szGetParam(1)!=NULL ) ? atoi(LDT_szGetParam(1)) : 0);
	if ( SNA_M_bTestSaveGameDesc() )
		SNA_fn_vWriteLongEntryToCurrentDscFile(SNA_C_ul_LevelNameTitle,
											   g_stEngineStructure.ucCurrentLevel);
	result=LDT_GetNextEntry();
	/* Working for Entries*/
	while( result!=ParseResult_EndSection )
	{
		szEntryName=LDT_szGetEntryName();
		switch (*(long*)(szEntryName))
		{
		case 'eveL': /*"LevelName"*/
			if (LDT_iGetNbParams()-1!=1)
				M_GameFatalError(E_uwGameScriptBadNumberOfArg);
			/* CGHT Bin*/
			/*ANNECY TQ 09/04/98{*/
			/*if(SNA_fn_ucGetLoadType()!=SNA_SAVE_SNAPSHOT)*/
			/*ENDANNECY TQ}*/
			if ( !g_cIsLevelOk )
			{
				if ( (g_stEngineStructure.ucNumberOfLevels == g_stEngineStructure.ucCurrentLevel) || (g_stEngineStructure.ucNumberOfLevels == 0) )
					fn_vSetFirstLevelName(LDT_szGetParam(1));
			}
			strcpy( g_stEngineStructure.a_szLevelName[g_stEngineStructure.ucNumberOfLevels++],LDT_szGetParam(1));
			if ( SNA_M_bTestSaveGameDesc() )
				SNA_fn_vWriteStringEntryToCurrentDscFile (SNA_C_ul_LevelName,LDT_szGetParam(1));
			break;
		} /* end switch*/
		result=LDT_GetNextEntry();
	} /*end while for entries*/
	if ( SNA_M_bTestSaveGameDesc() )
		SNA_fn_vWriteNoParamEntryToCurrentDscFile ( SNA_C_ulEndOfDescSection );
 
	return 0;
}
/*END FS 9/2/98*/
 
/*BEGIN FS 9/2/98*/
/*----------------------------------------------------------------------
 *  Description: Callback for Texts section from .dsc sript file
 *----------------------------------------------------------------------
 *  Input:
 *  Output:
 *----------------------------------------------------------------------
 *  Author: FS
 *  Creation date:9/2/98
 *  Modif date:
 *----------------------------------------------------------------------*/
int LoadAddStringsFiles( LDT_tdst_Link *pLink )
{
	LDT_tdeParseResult result=ParseResult_BeginSection;
	char *szEntryName;
/*	unsigned char ucOldACPModeMalloc;*/
 
	/* Working for Entries*/
	result=LDT_GetNextEntry();
	while( result!=ParseResult_EndSection )
	{
		szEntryName=LDT_szGetEntryName();
		switch (*(long*)(szEntryName))
		{
		case 'SddA': /*"AddStringsFile"*/
			if (LDT_iGetNbParams()-1!=1)
				M_GameFatalError(E_uwGameScriptBadNumberOfArg);
/*			ucOldACPModeMalloc = GEO_M_ucGetMemMallocMode();*/
/*			GEO_xSelectMemoryChannel(ACP_TextMemoryChannel);*/
 
/*!!! introduc LDT_LoadSection dupa introducere .TXT*/
			LDT_LoadSection(LDT_szGetParam(1));
 
/*			SCR_fnp_st_RdL0_AnalyseSection(LDT_szGetParam(1), SCR_CDF_uw_Anl_Normal);*/
/*			GEO_xSelectMemoryChannel(ucOldACPModeMalloc);*/
			
			fn_vGameTestMemory();
			break;
		case 'FddA': /*"AddFontFile"*/
		/*	if (LDT_iGetNbParams()-1!=1)
				M_GameFatalError(E_uwGameScriptBadNumberOfArg);
			if(SNA_fn_ucGetLoadType()!=SNA_LOAD_SNAPSHOT)
				LDT_LoadSection(LDT_szGetParam(1));
			fn_vGameTestMemory();*/
			break;
		} /* end switch*/
		result=LDT_GetNextEntry();
	} /*end while for entries*/
 
	return 0;
	
}
/*END FS 9/2/98*/
 
/*BEGIN FS 8/27/98*/
/*----------------------------------------------------------------------
 *  Description: Callback for BigFiles section from .dsc sript file
 *----------------------------------------------------------------------
 *  Input:
 *  Output:
 *----------------------------------------------------------------------
 *  Author: FS
 *  Creation date:8/27/98
 *  Modif date:
 *----------------------------------------------------------------------*/
int LoadBigFile( LDT_tdst_Link *pLink )
{
	LDT_tdeParseResult result=ParseResult_BeginSection;
	char *szEntryName;
	char a256_cGameMemoryFile[256];
	
	/* Working for BeginSection*/
    if ( SNA_M_bTestSaveGameDesc() )
        SNA_fn_vWriteNoParamEntryToCurrentDscFile( SNA_C_ul_BigFileDescTitle );
 
	/* Working for Entries*/
	result=LDT_GetNextEntry();
	while( result!=ParseResult_EndSection )
	{
		szEntryName=LDT_szGetEntryName();
		switch (*(long*)(szEntryName))
		{
		case 'txeT': /*"Textures"*/
			if (LDT_iGetNbParams()-1!=1)
				M_GameFatalError(E_uwGameScriptBadNumberOfArg);
			GLI_fn_vCloseBigFileTextures();
			strcpy(a256_cGameMemoryFile,g_a64_cGameDataDirectory);
			strcat(a256_cGameMemoryFile,LDT_szGetParam(1));
			GLI_fn_vOpenBigFileTextures(a256_cGameMemoryFile);
            if ( SNA_M_bTestSaveGameDesc() )
		        SNA_fn_vWriteStringEntryToCurrentDscFile(SNA_C_ul_BigFileTextures,LDT_szGetParam(1));
			break;
		case 'ngiV': /*"Vignettes"*/
			if (LDT_iGetNbParams()-1!=1)
				M_GameFatalError(E_uwGameScriptBadNumberOfArg);
			VIG_fn_vCloseBigFileVignette();
			strcpy(a256_cGameMemoryFile,g_a64_cGameDataDirectory);
			strcat(a256_cGameMemoryFile,LDT_szGetParam(1));
			VIG_fn_vOpenBigFileVignette(a256_cGameMemoryFile);
	        if ( SNA_M_bTestSaveGameDesc() )
			    SNA_fn_vWriteStringEntryToCurrentDscFile(SNA_C_ul_BigFileVignettes,LDT_szGetParam(1));
		}/* end switch*/
		result=LDT_GetNextEntry();
	}/*end while for entries*/
	if ( SNA_M_bTestSaveGameDesc() )
	SNA_fn_vWriteNoParamEntryToCurrentDscFile( SNA_C_ulEndOfDescSection );
	return 0;
}
/*END FS 8/27/98*/
 
 
 
/*****************************************************************
Function name   : fn_iCreateLanguage
Description     : 
Author          : Ovidiu Scripa (oscripa@ubisoft.ro) - ROMTEAM
Creation Date   : 13-Oct-98
Modified        : 
Return type     : int 
Argument        : LDT_tdst_Link *pLink
*****************************************************************/
int fn_iCreateLanguage( LDT_tdst_Link *pLink )
{
 
	g_stEngineStructure.ucNbLanguages =(unsigned char) ((LDT_szGetParam(1) != NULL ) ? atoi( LDT_szGetParam(1) ) : 0);
	g_stEngineStructure.p_stLanguageTable = M_p_GameMallocInHLM( g_stEngineStructure.ucNbLanguages * sizeof(tdstLanguageStructure));
 
    return 0;
}
 
 
/*****************************************************************
Function name   : fn_iLoadLanguage
Description     : 
Author          : Ovidiu Scripa (oscripa@ubisoft.ro) - ROMTEAM
Creation Date   : 13-Oct-98
Modified        : 
Return type     : int 
Argument        : LDT_tdst_Link *pLink
*****************************************************************/
int fn_iLoadLanguage( LDT_tdst_Link *pLink )
{
    LDT_tdeParseResult result=ParseResult_BeginSection;
    static	ucLanguage;
 
    ucLanguage = 0;
 
    while( result!=ParseResult_EndSection ) 
    {
        result=LDT_GetNextEntry();
        switch( result )
        {
          case ParseResult_Entry: /* an entry */
          {
  	        char *szEntry=LDT_szGetEntryName();
  	        switch (*(long*)szEntry)
  	        {
 
  	          case  'LddA' : /*  */
  	          {
		        if (ucLanguage < g_stEngineStructure.ucNbLanguages)
		        {
			        strcpy( g_stEngineStructure.p_stLanguageTable[ucLanguage].szLanguageCode, LDT_szGetParam(1) );
			        strcpy( g_stEngineStructure.p_stLanguageTable[ucLanguage].szLanguageText, LDT_szGetParam(2) );
			        ucLanguage ++;
		        }
 
  	          }
  	          break;
              default:
                M_GameFatalError(E_uwGameLanguage);
 
  	        }
          }
        }
    }
 
 
  return 0;
}
 
 
 
#endif /* CPA_USES_LDT */
/* MLT CC END   9/23/98 */
