#include "ACP_Base.h" #include "ToolsCPA.h" /*#include "SCR.h"*/ /*#include "DPT.h"*/ /*#include "GEO.h"*/ /*#include "GLI.h"*/ /*#include "TEX.h"*/ /*#include "SCR.h"*/ /*#include "VIG.h"*/ #include "RND.h" /*#include "LST.h"*/ #include "fonerm.h" #include "fonmem.h" #include "Structur/EngMode.h" /*#include "fonpub.h"*/ /*#include "FON_Eff.h"*/ #include "fonfont.h" #include "fonload.h" /*#include "fontext.h"*/ #include "ldt.h" /***************************************************************** Function name : fn_iCreateTextString Description : Author : Ovidiu Scripa (oscripa@ubisoft.ro) - ROMTEAM Creation Date : 13-Oct-98 Modified : Return type : int Argument : LDT_tdst_Link *pLink *****************************************************************/ int fn_iCreateTextString( LDT_tdst_Link *pLink ) { char *szAction; short wLanguageId; /*allocate the pointer of lists of languages*/ register unsigned short uwLanguage = 0; szAction = LDT_szGetSectionName(); /* by default if any problem*/ wLanguageId = 0; do { if ( !stricmp(szAction, g_stEngineStructure.p_stLanguageTable[uwLanguage].szLanguageCode) ) { wLanguageId = uwLanguage; uwLanguage = g_stEngineStructure.ucNbLanguages; } } while( uwLanguage++= FON_g_stGeneral.d_sLanguageArray[wLanguageId].uwMaxNumberOfTexts) { M_FONFatalError(E_uwFONNotEnoughStringSpace); } /* if the text is empty, try to find a non-empty version in any other language (the string is common to all)*/ if ( strlen(LDT_szGetParam(2)) == 0 ) { long lIndex; for (lIndex = 0; lIndex < FON_g_stGeneral.uwNumberOfLanguages; lIndex ++) if ( FON_g_stGeneral.d_sLanguageArray[lIndex].d_pTextsArray ) { /* get the text in the other language*/ hText = FON_g_stGeneral.d_sLanguageArray[lIndex].d_pTextsArray[FON_g_stGeneral.d_sLanguageArray[wLanguageId].uwNumberOfTexts]; if ( hText ) break; } } else { hText = FON_fn_p_vAllocInBloc(E_ucFONTextMemoryBlock,strlen(LDT_szGetParam(2))+1); strcpy(hText, LDT_szGetParam(2)); if ( !stricmp(szEntry,FON_C_SectionNewUpperString) ) strupr(hText); /* normally this line should occur once per text per language -> everything will be fine if a given text name*/ /* always has the same index in the section, because only one linktable entry may exist with a given name*/ SCR_fnp_st_Link_SetValue(&FON_g_stTextLinkTable, LDT_szGetParam(1), FON_g_stGeneral.d_sLanguageArray[wLanguageId].uwNumberOfTexts); } FON_g_stGeneral.d_sLanguageArray[wLanguageId].d_pTextsArray[FON_g_stGeneral.d_sLanguageArray[wLanguageId].uwNumberOfTexts] = hText; FON_g_stGeneral.d_sLanguageArray[wLanguageId].uwNumberOfTexts ++; } else if (!stricmp(szEntry, FON_C_SectionNewStringLength)) { char *hText; if (FON_g_stGeneral.d_sLanguageArray[wLanguageId].uwNumberOfTexts >= FON_g_stGeneral.d_sLanguageArray[wLanguageId].uwMaxNumberOfTexts) { M_FONFatalError(E_uwFONNotEnoughStringSpace); } /* if the text is empty, try to find a non-empty version in any other language (the string is common to all)*/ if ( atoi(LDT_szGetParam(2)) == 0 ) { long lIndex; for (lIndex = 0; lIndex < FON_g_stGeneral.uwNumberOfLanguages; lIndex ++) if ( FON_g_stGeneral.d_sLanguageArray[lIndex].d_pTextsArray ) { /* get the text in the other language*/ hText = FON_g_stGeneral.d_sLanguageArray[lIndex].d_pTextsArray[FON_g_stGeneral.d_sLanguageArray[wLanguageId].uwNumberOfTexts]; if ( hText ) break; } } else { long lSize; lSize = atoi(LDT_szGetParam(2)); /* allocate a string and fill it with whitespaces (so that strlen() is non-zero)*/ hText = FON_fn_p_vAllocInBloc(E_ucFONTextMemoryBlock,lSize + 1); memset(hText, 0, lSize + 1); memset(hText, ' ', lSize); *(short *) (hText + lSize) = (short) lSize; /* normally this line should occur once per text per language -> everything will be fine if a given text name*/ /* always has the same index in the section, because only one linktable entry may exist with a given name*/ SCR_fnp_st_Link_SetValue(&FON_g_stTextLinkTable, LDT_szGetParam(1), FON_g_stGeneral.d_sLanguageArray[wLanguageId].uwNumberOfTexts); } FON_g_stGeneral.d_sLanguageArray[wLanguageId].d_pTextsArray[FON_g_stGeneral.d_sLanguageArray[wLanguageId].uwNumberOfTexts] = hText; FON_g_stGeneral.d_sLanguageArray[wLanguageId].uwNumberOfTexts ++; } } } } return 0; }