#define D_RND_Input_StructureDefine #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 #ifndef RND_WITHOUT_SNA #include "sna.h" #endif #include "ldt.h" #define lTagComputeTable 'pmoC' #define lTagReadTable 'daeR' /***************************************************************** Function name : fn_iCreateRandom Description : Author : Ovidiu Scripa (oscripa@ubisoft.ro) - ROMTEAM Creation Date : 14-Oct-98 Modified : Return type : int Argument : LDT_tdst_Link *pLink *****************************************************************/ int fn_iCreateRandom( LDT_tdst_Link *pLink ) { RND_g_stRandomStructure.ulSizeOfTable = atoi(LDT_szGetParam(1)); 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 if ( SNA_M_bTestSaveGameDesc() ) SNA_fn_vWriteLongEntryToCurrentDscFile( SNA_C_ul_RandomDescTitle, atol(LDT_szGetParam(1)) ); #endif return 0; } /***************************************************************** Function name : fn_iLoadRandom Description : Author : Ovidiu Scripa (oscripa@ubisoft.ro) - ROMTEAM Creation Date : 14-Oct-98 Modified : Return type : int Argument : LDT_tdst_Link *pLink *****************************************************************/ int fn_iLoadRandom( LDT_tdst_Link *pLink ) { LDT_tdeParseResult result=ParseResult_BeginSection; char szFilename[_MAX_PATH]; FILE *p_stFile; while( result!=ParseResult_EndSection ) { result=LDT_GetNextEntry(); switch( result ) { case ParseResult_Entry: /* an entry */ { char *szEntry=LDT_szGetEntryName(); switch (*(long*)szEntry) { case lTagComputeTable : /* */ { RND_fn_vComputeRandomTable(); #ifndef RND_WITHOUT_SNA if ( SNA_M_bTestSaveGameDesc() ) SNA_fn_vWriteNoParamEntryToCurrentDscFile( SNA_C_ul_RandomComputeTable ); #endif RND_fn_vRemapRandomTable(); } break; case lTagReadTable : /* */ { char szSectionName[_MAX_PATH], szParent[_MAX_PATH], szType[_MAX_PATH], szId[_MAX_PATH] ; LDT_ComputeSectionName( pLink, szSectionName ); LDT_SplitSectionName( szSectionName, szFilename, szParent, szType, szId ); 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 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 } else { RND_fn_vComputeRandomTable(); #ifndef RND_WITHOUT_SNA if ( SNA_M_bTestSaveGameDesc() ) SNA_fn_vWriteNoParamEntryToCurrentDscFile( SNA_C_ul_RandomComputeTable ); #endif } RND_fn_vRemapRandomTable(); } break; } } } } #ifndef RND_WITHOUT_SNA if ( SNA_M_bTestSaveGameDesc() ) SNA_fn_vWriteNoParamEntryToCurrentDscFile( SNA_C_ulEndOfDescSection ); #endif return 0; }