124 lines
3.2 KiB
C
124 lines
3.2 KiB
C
/*=========================================================================
|
|
* RND_Scpt.c :
|
|
* Script read
|
|
*
|
|
* (c) Ubi Studios 1997
|
|
*=======================================================================*/
|
|
|
|
#define D_RND_Input_StructureDefine
|
|
#include "Acp_base.h"
|
|
|
|
#include "RND_CPA.h"
|
|
#include "MemRND.h"
|
|
#include "ErrRND.h"
|
|
|
|
#include "RND_Main.h"
|
|
#include "RND_Scpt.h"
|
|
|
|
#include "RND_Str.h"
|
|
#undef D_RND_Input_StructureDefine
|
|
|
|
/*#define RND_WITHOUT_SNA // just for Concat*/
|
|
/*************************************************************************/
|
|
|
|
#if (!defined(U64))
|
|
|
|
#ifndef RND_WITHOUT_SNA
|
|
#include "sna.h"
|
|
#endif
|
|
|
|
SCR_tde_Anl_ReturnValue RND_fn_eRandomScriptCallBack(SCR_tdst_File_Description *_p_stFile,char *_p_szName,char *_ap_szParams[],SCR_tde_Anl_Action _eAction)
|
|
{
|
|
FILE *p_stFile;
|
|
SCR_tde_Anl_ReturnValue eReturnValue = SCR_ERV_Anl_NormalReturn;
|
|
char szFilename[_MAX_PATH];
|
|
|
|
_p_stFile = _p_stFile;
|
|
|
|
if (M_IsTitle)
|
|
{
|
|
M_CheckScriptParamNumber(1);
|
|
RND_g_stRandomStructure.ulSizeOfTable = atoi(_ap_szParams[0]);
|
|
Mmg_M_InitBlock(RND,E_ucRNDMemoryBlock,C_uwAllocSize+RND_g_stRandomStructure.ulSizeOfTable*sizeof(unsigned long));
|
|
Mmg_M_SetModeAlloc4Ch(RND,E_ucRNDMemoryBlock,C_ucMmgDefaultChannel);
|
|
MMG_fn_vAddMemoryInfo (MMG_C_lTypeRND , MMG_C_lSubTypeRND , NULL);
|
|
RND_g_stRandomStructure.p_ulTable = Mmg_fn_p_vAlloc4Ch(RND_g_stRandomStructure.ulSizeOfTable*sizeof(unsigned long),C_ucMmgDefaultChannel);
|
|
|
|
/* GuS 98/08/07 */
|
|
#ifndef RND_WITHOUT_SNA
|
|
#ifndef RETAIL
|
|
if ( SNA_M_bTestSaveGameDesc() )
|
|
SNA_fn_vWriteLongEntryToCurrentDscFile( SNA_C_ul_RandomDescTitle, atol(_ap_szParams[0]) );
|
|
#endif
|
|
#endif
|
|
}
|
|
else if (M_IsEntry)
|
|
{
|
|
if (M_ActionIs("ComputeTable"))
|
|
{
|
|
RND_fn_vComputeRandomTable();
|
|
|
|
#ifndef RND_WITHOUT_SNA
|
|
#ifndef RETAIL
|
|
if ( SNA_M_bTestSaveGameDesc() )
|
|
SNA_fn_vWriteNoParamEntryToCurrentDscFile( SNA_C_ul_RandomComputeTable );
|
|
#endif
|
|
#endif
|
|
}
|
|
else if (M_ActionIs("ReadTable"))
|
|
{
|
|
strcpy(szFilename,SCR_M_RdL0_GetOpenFileNameR(0));
|
|
if (strrchr(szFilename,'.')!=NULL)
|
|
*strrchr(szFilename,'.') = 0;
|
|
strcat(szFilename,".trn");
|
|
if ((p_stFile=fopen(szFilename,"rb"))!=NULL)
|
|
{
|
|
fread(RND_g_stRandomStructure.p_ulTable,RND_g_stRandomStructure.ulSizeOfTable,sizeof(unsigned long),p_stFile);
|
|
fclose(p_stFile);
|
|
|
|
#ifndef RND_WITHOUT_SNA
|
|
#ifndef RETAIL
|
|
if ( SNA_M_bTestSaveGameDesc() )
|
|
{
|
|
SNA_fn_vWriteNoParamEntryToCurrentDscFile( SNA_C_ul_RandomReadTable );
|
|
SNA_fn_vWriteBlockToCurrentDscFile
|
|
(
|
|
(char *)RND_g_stRandomStructure.p_ulTable,
|
|
RND_g_stRandomStructure.ulSizeOfTable * sizeof(unsigned long)
|
|
);
|
|
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
}
|
|
else
|
|
{
|
|
RND_fn_vComputeRandomTable();
|
|
|
|
#ifndef RND_WITHOUT_SNA
|
|
#ifndef RETAIL
|
|
if ( SNA_M_bTestSaveGameDesc() )
|
|
SNA_fn_vWriteNoParamEntryToCurrentDscFile( SNA_C_ul_RandomComputeTable );
|
|
#endif
|
|
#endif
|
|
}
|
|
|
|
}
|
|
RND_fn_vRemapRandomTable();
|
|
}
|
|
#ifndef RND_WITHOUT_SNA
|
|
#ifndef RETAIL
|
|
else if( M_IsEnd )
|
|
{
|
|
if ( SNA_M_bTestSaveGameDesc() )
|
|
SNA_fn_vWriteNoParamEntryToCurrentDscFile( SNA_C_ulEndOfDescSection );
|
|
}
|
|
#endif
|
|
#endif
|
|
|
|
return(eReturnValue);
|
|
}
|
|
#endif /* !U64*/
|
|
/*************************************************************************/
|