mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
Add framework for adding externalized emails
Emails from new GameDir file TableData/Email/Emails.xml can be added via lua scripting using calls to AddEmailFromXML & AddPreReadEmailFromXML. The order of emails in Emails.xml acts as the index to be referenced and provided when calling lua functions. An error message will be displayed if an email is added with an out-of-scope index but game will be able to continue. Localization is supported and was tested on Chinese localization.
This commit is contained in:
+53
-30
@@ -1184,40 +1184,61 @@ if( g_lang != i18n::Lang::en ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( ReadXMLEmail == TRUE )
|
||||
{
|
||||
if ( ReadXMLEmail == TRUE )
|
||||
{
|
||||
// Externalized emails
|
||||
strcpy(fileName, directoryName);
|
||||
strcat(fileName, EMAILSFILENAME);
|
||||
// Only load external emails if we find the file
|
||||
if ( FileExists(fileName) )
|
||||
{
|
||||
DebugMsg(TOPIC_JA2, DBG_LEVEL_3, String("LoadExternalGameplayData, fileName = %s", fileName));
|
||||
SGP_THROW_IFFALSE(ReadInExternalizedEmails(fileName, FALSE), EMAILSFILENAME);
|
||||
|
||||
if ( g_lang != i18n::Lang::en )
|
||||
{
|
||||
AddLanguagePrefix(fileName);
|
||||
if ( FileExists(fileName) )
|
||||
{
|
||||
DebugMsg(TOPIC_JA2, DBG_LEVEL_3, String("LoadExternalGameplayData, fileName = %s", fileName));
|
||||
if ( !ReadInExternalizedEmails(fileName, TRUE) )
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// EMAIL MERC AVAILABLE by Jazz
|
||||
strcpy(fileName, directoryName);
|
||||
strcat(fileName, EMAILMERCAVAILABLE);
|
||||
DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("LoadExternalGameplayData, fileName = %s", fileName));
|
||||
SGP_THROW_IFFALSE(ReadInEmailMercAvailable(fileName,FALSE), EMAILMERCAVAILABLE);
|
||||
DebugMsg(TOPIC_JA2, DBG_LEVEL_3, String("LoadExternalGameplayData, fileName = %s", fileName));
|
||||
SGP_THROW_IFFALSE(ReadInEmailMercAvailable(fileName, FALSE), EMAILMERCAVAILABLE);
|
||||
|
||||
if( g_lang != i18n::Lang::en ) {
|
||||
AddLanguagePrefix(fileName);
|
||||
if ( FileExists(fileName) )
|
||||
if ( g_lang != i18n::Lang::en )
|
||||
{
|
||||
DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("LoadExternalGameplayData, fileName = %s", fileName));
|
||||
if(!ReadInEmailMercAvailable(fileName,TRUE))
|
||||
return FALSE;
|
||||
AddLanguagePrefix(fileName);
|
||||
if ( FileExists(fileName) )
|
||||
{
|
||||
DebugMsg(TOPIC_JA2, DBG_LEVEL_3, String("LoadExternalGameplayData, fileName = %s", fileName));
|
||||
if ( !ReadInEmailMercAvailable(fileName, TRUE) )
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// EMAIL MERC LEVEL UP by Jazz
|
||||
strcpy(fileName, directoryName);
|
||||
strcat(fileName, EMAILMERCLEVELUP);
|
||||
DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("LoadExternalGameplayData, fileName = %s", fileName));
|
||||
SGP_THROW_IFFALSE(ReadInEmailMercLevelUp(fileName,FALSE), EMAILMERCLEVELUP);
|
||||
DebugMsg(TOPIC_JA2, DBG_LEVEL_3, String("LoadExternalGameplayData, fileName = %s", fileName));
|
||||
SGP_THROW_IFFALSE(ReadInEmailMercLevelUp(fileName, FALSE), EMAILMERCLEVELUP);
|
||||
|
||||
if( g_lang != i18n::Lang::en ) {
|
||||
AddLanguagePrefix(fileName);
|
||||
if ( FileExists(fileName) )
|
||||
{
|
||||
DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("LoadExternalGameplayData, fileName = %s", fileName));
|
||||
if(!ReadInEmailMercLevelUp(fileName,TRUE))
|
||||
return FALSE;
|
||||
if ( g_lang != i18n::Lang::en ) {
|
||||
AddLanguagePrefix(fileName);
|
||||
if ( FileExists(fileName) )
|
||||
{
|
||||
DebugMsg(TOPIC_JA2, DBG_LEVEL_3, String("LoadExternalGameplayData, fileName = %s", fileName));
|
||||
if ( !ReadInEmailMercLevelUp(fileName, TRUE) )
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
// EMAIL OTHER by Jazz
|
||||
strcpy(fileName, directoryName);
|
||||
@@ -1225,16 +1246,18 @@ if( g_lang != i18n::Lang::en ) {
|
||||
DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("LoadExternalGameplayData, fileName = %s", fileName));
|
||||
SGP_THROW_IFFALSE(ReadInEmailOther(fileName,FALSE), EMAILOTHER);
|
||||
|
||||
if( g_lang != i18n::Lang::en ) {
|
||||
AddLanguagePrefix(fileName);
|
||||
if ( FileExists(fileName) )
|
||||
{
|
||||
DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("LoadExternalGameplayData, fileName = %s", fileName));
|
||||
if(!ReadInEmailOther(fileName,TRUE))
|
||||
return FALSE;
|
||||
if( g_lang != i18n::Lang::en ) {
|
||||
AddLanguagePrefix(fileName);
|
||||
if ( FileExists(fileName) )
|
||||
{
|
||||
DebugMsg (TOPIC_JA2,DBG_LEVEL_3,String("LoadExternalGameplayData, fileName = %s", fileName));
|
||||
if(!ReadInEmailOther(fileName,TRUE))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
//new vehicles by Jazz
|
||||
|
||||
InitNewVehicles ();
|
||||
|
||||
+155
-246
@@ -1,295 +1,204 @@
|
||||
#include "sgp.h"
|
||||
#include "Debug Control.h"
|
||||
#include "expat.h"
|
||||
#include "XML.h"
|
||||
#include "Interface.h"
|
||||
#include "LuaInitNPCs.h"
|
||||
#include "email.h"
|
||||
#include "sgp.h"
|
||||
#include "Debug Control.h"
|
||||
#include "expat.h"
|
||||
#include "XML.h"
|
||||
#include "Interface.h"
|
||||
#include "LuaInitNPCs.h"
|
||||
#include "email.h"
|
||||
|
||||
struct
|
||||
{
|
||||
PARSE_STAGE curElement;
|
||||
PARSE_STAGE curElement;
|
||||
|
||||
CHAR8 szCharData[MAIL_STRING_SIZE+1];
|
||||
EMAIL_OTHER_VALUES curEmailOther;
|
||||
CHAR8 szCharData[MAIL_STRING_SIZE + 1];
|
||||
CHAR16 currentMessage[MAIL_STRING_SIZE];
|
||||
UINT16 currentEmailIndex;
|
||||
UINT16 currentMessageIndex;
|
||||
|
||||
UINT32 maxArraySize;
|
||||
UINT32 curIndex;
|
||||
UINT32 currentDepth;
|
||||
UINT32 maxReadDepth;
|
||||
}
|
||||
UINT32 maxArraySize;
|
||||
UINT32 curIndex;
|
||||
UINT32 currentDepth;
|
||||
UINT32 maxReadDepth;
|
||||
} typedef EmailXMLParseData;
|
||||
|
||||
typedef EmailOtherParseData;
|
||||
|
||||
BOOLEAN EmailOther_TextOnly;
|
||||
BOOLEAN Emails_TextOnly;
|
||||
|
||||
static void XMLCALL
|
||||
EmailOtherStartElementHandle(void *userData, const XML_Char *name, const XML_Char **atts)
|
||||
EmailOtherStartElementHandle(void* userData, const XML_Char* name, const XML_Char** atts)
|
||||
{
|
||||
EmailOtherParseData * pData = (EmailOtherParseData *)userData;
|
||||
EmailXMLParseData* pData = (EmailXMLParseData*)userData;
|
||||
|
||||
if(pData->currentDepth <= pData->maxReadDepth) //are we reading this element?
|
||||
{
|
||||
if(strcmp(name, "NEW_EMAIL") == 0 && pData->curElement == ELEMENT_NONE)
|
||||
{
|
||||
pData->curElement = ELEMENT_LIST;
|
||||
if (pData->currentDepth <= pData->maxReadDepth) //are we reading this element?
|
||||
{
|
||||
if (strcmp(name, "EMAILS") == 0 && pData->curElement == ELEMENT_NONE)
|
||||
{
|
||||
pData->curElement = ELEMENT_LIST;
|
||||
|
||||
pData->maxReadDepth++; //we are not skipping this element
|
||||
}
|
||||
else if(strcmp(name, "EMAIL") == 0 && pData->curElement == ELEMENT_LIST)
|
||||
{
|
||||
pData->curElement = ELEMENT;
|
||||
pData->maxReadDepth++; //we are not skipping this element
|
||||
}
|
||||
else if (strcmp(name, "EMAIL") == 0 && pData->curElement == ELEMENT_LIST)
|
||||
{
|
||||
pData->curElement = ELEMENT;
|
||||
|
||||
pData->maxReadDepth++; //we are not skipping this element
|
||||
}
|
||||
else if(pData->curElement == ELEMENT &&
|
||||
(strcmp(name, "uiIndex") == 0 ||
|
||||
strcmp(name, "Subject") == 0 ||
|
||||
strcmp(name, "Message0") == 0 ||
|
||||
strcmp(name, "Message1") == 0 ||
|
||||
strcmp(name, "Message2") == 0 ||
|
||||
strcmp(name, "Message3") == 0 ||
|
||||
strcmp(name, "Message4") == 0 ||
|
||||
strcmp(name, "Message5") == 0 ||
|
||||
strcmp(name, "Message6") == 0 ||
|
||||
strcmp(name, "Message7") == 0 ||
|
||||
strcmp(name, "Message8") == 0 ||
|
||||
strcmp(name, "Message9") == 0 ||
|
||||
strcmp(name, "Message10") == 0 ||
|
||||
strcmp(name, "Message11") == 0 ||
|
||||
strcmp(name, "Message12") == 0 ||
|
||||
strcmp(name, "Message13") == 0 ||
|
||||
strcmp(name, "Message14") == 0 ||
|
||||
strcmp(name, "Message15") == 0 ||
|
||||
strcmp(name, "Message16") == 0 ||
|
||||
strcmp(name, "Message17") == 0 ||
|
||||
strcmp(name, "Message18") == 0 ||
|
||||
strcmp(name, "Message19") == 0 ||
|
||||
strcmp(name, "Message20") == 0 ||
|
||||
strcmp(name, "Message21") == 0 ||
|
||||
strcmp(name, "Message22") == 0 ||
|
||||
strcmp(name, "Message23") == 0 ||
|
||||
strcmp(name, "Message24") == 0 ||
|
||||
strcmp(name, "Message25") == 0 ||
|
||||
strcmp(name, "Message26") == 0 ||
|
||||
strcmp(name, "Message27") == 0 ||
|
||||
strcmp(name, "Message28") == 0 ||
|
||||
strcmp(name, "Message29") == 0 ))
|
||||
{
|
||||
pData->curElement = ELEMENT_PROPERTY;
|
||||
pData->maxReadDepth++; //we are not skipping this element
|
||||
}
|
||||
else if (pData->curElement == ELEMENT &&
|
||||
(strcmp(name, "Index") == 0 ||
|
||||
strcmp(name, "Sender") == 0 ||
|
||||
strcmp(name, "Subject") == 0 ||
|
||||
strcmp(name, "Message") == 0))
|
||||
{
|
||||
pData->curElement = ELEMENT_PROPERTY;
|
||||
|
||||
pData->maxReadDepth++; //we are not skipping this element
|
||||
}
|
||||
pData->maxReadDepth++; //we are not skipping this element
|
||||
}
|
||||
|
||||
pData->szCharData[0] = '\0';
|
||||
}
|
||||
pData->szCharData[0] = '\0';
|
||||
}
|
||||
|
||||
pData->currentDepth++;
|
||||
pData->currentDepth++;
|
||||
|
||||
}
|
||||
|
||||
static void XMLCALL
|
||||
EmailOtherCharacterDataHandle(void *userData, const XML_Char *str, int len)
|
||||
EmailOtherCharacterDataHandle(void* userData, const XML_Char* str, int len)
|
||||
{
|
||||
EmailOtherParseData * pData = (EmailOtherParseData *)userData;
|
||||
EmailXMLParseData* pData = (EmailXMLParseData*)userData;
|
||||
|
||||
if( (pData->currentDepth <= pData->maxReadDepth) &&
|
||||
(strlen(pData->szCharData) < MAX_CHAR_DATA_LENGTH)
|
||||
){
|
||||
strncat(pData->szCharData,str,__min((unsigned int)len,MAX_CHAR_DATA_LENGTH-strlen(pData->szCharData)));
|
||||
}
|
||||
if ((pData->currentDepth <= pData->maxReadDepth) &&
|
||||
(strlen(pData->szCharData) < MAX_CHAR_DATA_LENGTH)
|
||||
) {
|
||||
strncat(pData->szCharData, str, __min((unsigned int)len, MAX_CHAR_DATA_LENGTH - strlen(pData->szCharData)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void XMLCALL
|
||||
EmailOtherEndElementHandle(void *userData, const XML_Char *name)
|
||||
EmailOtherEndElementHandle(void* userData, const XML_Char* name)
|
||||
{
|
||||
EmailOtherParseData * pData = (EmailOtherParseData *)userData;
|
||||
EmailXMLParseData* pData = (EmailXMLParseData*)userData;
|
||||
|
||||
if(pData->currentDepth <= pData->maxReadDepth)
|
||||
{
|
||||
if(strcmp(name, "NEW_EMAIL") == 0)
|
||||
{
|
||||
pData->curElement = ELEMENT_NONE;
|
||||
}
|
||||
else if(strcmp(name, "EMAIL") == 0)
|
||||
{
|
||||
pData->curElement = ELEMENT_LIST;
|
||||
|
||||
if (!EmailOther_TextOnly)
|
||||
{
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szSubject, pData->curEmailOther.szSubject);
|
||||
// L"12345678901234567890123456789" <- max lenght (szMessage[30])
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[0], L"1. sdssdsfs dfg fdgd fg test" ); //pData-curEmailOther.szMessage[0]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[1], L"2. sdssdsfs dfg fgfgffds test" );
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[2], L"3. sdssdsfsd gdfg fdfgsf test" );
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[3], L"4. sdssdsf dgdfg dgsfdsf test" );
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[4], L"5. sdssdsfdgdfg dgfddsf test" );
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[5], L"6. sdssdsfsffdsf test" );
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[6], L"7. sdssdsfsffdsf test" );
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[7], L"8. sdssdsfsfdgdgfgfdsf test" );
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[8], L"9. sdssdsfsff dg gdg dsf test" );
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[9], L"10. sdssdsfsfgdsgdfgfdsf test" );
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[10], L"11. sdssdsfsff dgfgd dsf test" );
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[11], L"12. sdssdsfsf dfgdfg dsf test" );
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[12], L"13. sdssdsfsf dfgg gfdsf test" );
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[13], L"14. sdssdsf dgdf gsffdsf test" );
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[14], L"15. sdssdsf dgdf f ffdsf test" );
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[15], L"16. sdssdsfs dgdf gffdsf test" );
|
||||
if (pData->currentDepth <= pData->maxReadDepth)
|
||||
{
|
||||
if (strcmp(name, "EMAILS") == 0)
|
||||
{
|
||||
pData->curElement = ELEMENT_NONE;
|
||||
}
|
||||
else if (strcmp(name, "EMAIL") == 0)
|
||||
{
|
||||
pData->curElement = ELEMENT_LIST;
|
||||
if ( Emails_TextOnly )
|
||||
{
|
||||
pData->currentEmailIndex += 1;
|
||||
pData->currentMessageIndex = 0;
|
||||
}
|
||||
}
|
||||
else if (strcmp(name, "Sender") == 0)
|
||||
{
|
||||
pData->curElement = ELEMENT;
|
||||
if ( !Emails_TextOnly )
|
||||
{
|
||||
gEmails.push_back(EMAIL_XML {});
|
||||
gEmails.back().Sender = atol(pData->szCharData);
|
||||
}
|
||||
}
|
||||
else if (strcmp(name, "Subject") == 0)
|
||||
{
|
||||
pData->curElement = ELEMENT;
|
||||
if ( !Emails_TextOnly )
|
||||
{
|
||||
MultiByteToWideChar(CP_UTF8, 0, pData->szCharData, -1, gEmails.back().Subject, sizeof(gEmails.back().Subject) / sizeof(gEmails.back().Subject[0]));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Replace existing text with localized version
|
||||
const auto i = pData->currentEmailIndex;
|
||||
MultiByteToWideChar(CP_UTF8, 0, pData->szCharData, -1, gEmails[i].Subject, sizeof(gEmails[i].Subject) / sizeof(gEmails[i].Subject[0]));
|
||||
}
|
||||
}
|
||||
else if (strcmp(name, "Message") == 0)
|
||||
{
|
||||
pData->curElement = ELEMENT;
|
||||
MultiByteToWideChar(CP_UTF8, 0, pData->szCharData, -1, pData->currentMessage, sizeof(pData->currentMessage) / sizeof(pData->currentMessage[0]));
|
||||
|
||||
/*
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[1], pData->curEmailOther.szMessage[1]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[2], pData->curEmailOther.szMessage[2]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[3], pData->curEmailOther.szMessage[3]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[4], pData->curEmailOther.szMessage[4]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[5], pData->curEmailOther.szMessage[5]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[6], pData->curEmailOther.szMessage[6]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[7], pData->curEmailOther.szMessage[7]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[8], pData->curEmailOther.szMessage[8]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[9], pData->curEmailOther.szMessage[9]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[10], pData->curEmailOther.szMessage[10]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[11], pData->curEmailOther.szMessage[11]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[12], pData->curEmailOther.szMessage[12]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[13], pData->curEmailOther.szMessage[13]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[14], pData->curEmailOther.szMessage[14]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[15], pData->curEmailOther.szMessage[15]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[16], pData->curEmailOther.szMessage[16]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[17], pData->curEmailOther.szMessage[17]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[18], pData->curEmailOther.szMessage[18]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[19], pData->curEmailOther.szMessage[19]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[20], pData->curEmailOther.szMessage[20]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[21], pData->curEmailOther.szMessage[21]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[22], pData->curEmailOther.szMessage[22]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[23], pData->curEmailOther.szMessage[23]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[24], pData->curEmailOther.szMessage[24]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[25], pData->curEmailOther.szMessage[25]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[26], pData->curEmailOther.szMessage[26]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[27], pData->curEmailOther.szMessage[27]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[28], pData->curEmailOther.szMessage[28]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[29], pData->curEmailOther.szMessage[29]);
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szSubject, pData->curEmailOther.szSubject);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[0], L"sdssdsfsffdsf test" ); //pData->curEmailOther.szMessage[0]);
|
||||
/*
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[1], pData->curEmailOther.szMessage[1]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[2], pData->curEmailOther.szMessage[2]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[3], pData->curEmailOther.szMessage[3]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[4], pData->curEmailOther.szMessage[4]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[5], pData->curEmailOther.szMessage[5]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[6], pData->curEmailOther.szMessage[6]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[7], pData->curEmailOther.szMessage[7]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[8], pData->curEmailOther.szMessage[8]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[9], pData->curEmailOther.szMessage[9]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[10], pData->curEmailOther.szMessage[10]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[11], pData->curEmailOther.szMessage[11]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[12], pData->curEmailOther.szMessage[12]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[13], pData->curEmailOther.szMessage[13]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[14], pData->curEmailOther.szMessage[14]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[15], pData->curEmailOther.szMessage[15]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[16], pData->curEmailOther.szMessage[16]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[17], pData->curEmailOther.szMessage[17]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[18], pData->curEmailOther.szMessage[18]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[19], pData->curEmailOther.szMessage[19]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[20], pData->curEmailOther.szMessage[20]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[21], pData->curEmailOther.szMessage[21]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[22], pData->curEmailOther.szMessage[22]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[23], pData->curEmailOther.szMessage[23]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[24], pData->curEmailOther.szMessage[24]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[25], pData->curEmailOther.szMessage[25]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[26], pData->curEmailOther.szMessage[26]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[27], pData->curEmailOther.szMessage[27]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[28], pData->curEmailOther.szMessage[28]);
|
||||
wcscpy(EmailOtherText[pData->curEmailOther.uiIndex].szMessage[29], pData->curEmailOther.szMessage[29]);
|
||||
*/
|
||||
}
|
||||
}
|
||||
else if(strcmp(name, "uiIndex") == 0)
|
||||
{
|
||||
pData->curElement = ELEMENT;
|
||||
pData->curEmailOther.uiIndex = (UINT8) atol(pData->szCharData);
|
||||
}
|
||||
else if(strcmp(name, "Subject") == 0 )
|
||||
{
|
||||
pData->curElement = ELEMENT;
|
||||
if ( !Emails_TextOnly )
|
||||
{
|
||||
gEmails.back().Messages.emplace_back(pData->currentMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Replace existing text with localized version
|
||||
const auto i = pData->currentEmailIndex;
|
||||
const auto j = pData->currentMessageIndex;
|
||||
gEmails[i].Messages[j] = pData->currentMessage;
|
||||
|
||||
MultiByteToWideChar( CP_UTF8, 0, pData->szCharData, -1, pData->curEmailOther.szSubject, sizeof(pData->curEmailOther.szSubject)/sizeof(pData->curEmailOther.szSubject[0]) );
|
||||
pData->curEmailOther.szSubject[sizeof(pData->curEmailOther.szSubject)/sizeof(pData->curEmailOther.szSubject[0]) - 1] = '\0';
|
||||
}
|
||||
/*
|
||||
else if(strcmp(name, "Message0") == 0 )
|
||||
{
|
||||
pData->curElement = ELEMENT;
|
||||
pData->currentMessageIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
MultiByteToWideChar( CP_UTF8, 0, pData->szCharData, -1, pData->curEmailOther.szMessage[0], sizeof(pData->curEmailOther.szMessage[0])/sizeof(pData->curEmailOther.szMessage[0]) );
|
||||
pData->curEmailOther.szMessage[sizeof(pData->curEmailOther.szMessage[0])/sizeof(pData->curEmailOther.szMessage[0]) - 1][0] = '\0';
|
||||
}
|
||||
*/
|
||||
pData->maxReadDepth--;
|
||||
}
|
||||
pData->currentDepth--;
|
||||
pData->maxReadDepth--;
|
||||
}
|
||||
pData->currentDepth--;
|
||||
}
|
||||
|
||||
BOOLEAN ReadInEmailOther(STR fileName, BOOLEAN localizedVersion)
|
||||
BOOLEAN ReadInExternalizedEmails(STR fileName, BOOLEAN localizedVersion)
|
||||
{
|
||||
HWFILE hFile;
|
||||
UINT32 uiBytesRead;
|
||||
UINT32 uiFSize;
|
||||
CHAR8 * lpcBuffer;
|
||||
XML_Parser parser = XML_ParserCreate(NULL);
|
||||
HWFILE hFile;
|
||||
UINT32 uiBytesRead;
|
||||
UINT32 uiFSize;
|
||||
CHAR8* lpcBuffer;
|
||||
XML_Parser parser = XML_ParserCreate(NULL);
|
||||
|
||||
EmailOtherParseData pData;
|
||||
EmailXMLParseData pData;
|
||||
|
||||
DebugMsg(TOPIC_JA2, DBG_LEVEL_3, "Loading EmailOther.xml" );
|
||||
DebugMsg(TOPIC_JA2, DBG_LEVEL_3, "Loading Emails.xml");
|
||||
|
||||
EmailOther_TextOnly = localizedVersion;
|
||||
|
||||
// Open file
|
||||
hFile = FileOpen( fileName, FILE_ACCESS_READ, FALSE );
|
||||
if ( !hFile )
|
||||
return( localizedVersion );
|
||||
Emails_TextOnly = localizedVersion;
|
||||
|
||||
uiFSize = FileGetSize(hFile);
|
||||
lpcBuffer = (CHAR8 *) MemAlloc(uiFSize+1);
|
||||
// Open file
|
||||
hFile = FileOpen(fileName, FILE_ACCESS_READ, FALSE);
|
||||
if (!hFile)
|
||||
return(localizedVersion);
|
||||
|
||||
//Read in block
|
||||
if ( !FileRead( hFile, lpcBuffer, uiFSize, &uiBytesRead ) )
|
||||
{
|
||||
MemFree(lpcBuffer);
|
||||
return( FALSE );
|
||||
}
|
||||
uiFSize = FileGetSize(hFile);
|
||||
lpcBuffer = (CHAR8*)MemAlloc(uiFSize + 1);
|
||||
|
||||
lpcBuffer[uiFSize] = 0; //add a null terminator
|
||||
//Read in block
|
||||
if (!FileRead(hFile, lpcBuffer, uiFSize, &uiBytesRead))
|
||||
{
|
||||
MemFree(lpcBuffer);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
FileClose( hFile );
|
||||
lpcBuffer[uiFSize] = 0; //add a null terminator
|
||||
|
||||
FileClose(hFile);
|
||||
|
||||
|
||||
XML_SetElementHandler(parser, EmailOtherStartElementHandle, EmailOtherEndElementHandle);
|
||||
XML_SetCharacterDataHandler(parser, EmailOtherCharacterDataHandle);
|
||||
XML_SetElementHandler(parser, EmailOtherStartElementHandle, EmailOtherEndElementHandle);
|
||||
XML_SetCharacterDataHandler(parser, EmailOtherCharacterDataHandle);
|
||||
|
||||
|
||||
memset(&pData,0,sizeof(pData));
|
||||
XML_SetUserData(parser, &pData);
|
||||
memset(&pData, 0, sizeof(pData));
|
||||
XML_SetUserData(parser, &pData);
|
||||
|
||||
gEmails.reserve(50);
|
||||
if (!XML_Parse(parser, lpcBuffer, uiFSize, TRUE))
|
||||
{
|
||||
CHAR8 errorBuf[511];
|
||||
|
||||
sprintf(errorBuf, "XML Parser Error in Emails.xml: %s at line %d", XML_ErrorString(XML_GetErrorCode(parser)), XML_GetCurrentLineNumber(parser));
|
||||
LiveMessage(errorBuf);
|
||||
|
||||
MemFree(lpcBuffer);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
MemFree(lpcBuffer);
|
||||
|
||||
|
||||
if(!XML_Parse(parser, lpcBuffer, uiFSize, TRUE))
|
||||
{
|
||||
CHAR8 errorBuf[511];
|
||||
|
||||
sprintf(errorBuf, "XML Parser Error in EmailOther.xml: %s at line %d", XML_ErrorString(XML_GetErrorCode(parser)), XML_GetCurrentLineNumber(parser));
|
||||
LiveMessage(errorBuf);
|
||||
|
||||
MemFree(lpcBuffer);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
MemFree(lpcBuffer);
|
||||
XML_ParserFree(parser);
|
||||
|
||||
|
||||
XML_ParserFree(parser);
|
||||
|
||||
|
||||
return( TRUE );
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
+105
-51
@@ -22,6 +22,7 @@
|
||||
#include <string>
|
||||
#include "soldier profile type.h"
|
||||
#include "strategicmap.h"
|
||||
#include "message.h"
|
||||
|
||||
#ifdef JA2UB
|
||||
#include "Ja25_Tactical.h"
|
||||
@@ -261,6 +262,7 @@ EMAIL_OTHER_VALUES EmailOtherText[EMAIL_INDEX];
|
||||
EMAIL_MERC_INSURANCE_VALUES EmailInsuranceText[NUM_PROFILES];
|
||||
BOOLEAN ReadXMLEmail = TRUE; // TRUE - read email from XML, FALSE - read email from EDT
|
||||
EMAIL_TYPE gEmailT[EMAIL_VAL];
|
||||
std::vector<EMAIL_XML> gEmails{};
|
||||
BOOLEAN SaveNewEmailDataToSaveGameFile( HWFILE hFile );
|
||||
BOOLEAN LoadNewEmailDataFromLoadGameFile( HWFILE hFile );
|
||||
|
||||
@@ -839,6 +841,18 @@ void AddEmailTypeXML( INT32 iMessageOffset, INT32 iMessageLength, UINT8 ubSender
|
||||
}
|
||||
}
|
||||
|
||||
static void AddEmailFromXML(INT32 iMessageOffset, INT32 iDate, INT32 iCurrentIMPPosition, INT16 iCurrentShipmentDestinationID, BOOLEAN alreadyRead)
|
||||
{
|
||||
if ( iMessageOffset < gEmails.size() )
|
||||
{
|
||||
auto& email = gEmails[iMessageOffset];
|
||||
AddEmailMessage(iMessageOffset, email.Messages.size(), email.Subject, iDate, email.Sender, alreadyRead, 0, 0, iCurrentIMPPosition, iCurrentShipmentDestinationID, TYPE_EMAIL_XML, TYPE_E_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
ScreenMsg(FONT_LTRED, MSG_INTERFACE, L"%s%d %s", L"Tried to add email #", iMessageOffset, L"but could not find it in Emails.xml! If playing unmodded 1.13, please report this at https://github.com/1dot13/source/issues");
|
||||
}
|
||||
}
|
||||
#ifdef JA2UB
|
||||
void AddBobbyREmailJA2(INT32 iMessageOffset, INT32 iMessageLength, UINT8 ubSender, INT32 iDate, INT32 iCurrentIMPPosition, INT16 iCurrentShipmentDestinationID, UINT8 EmailType )
|
||||
{
|
||||
@@ -902,36 +916,51 @@ void AddEmail(INT32 iMessageOffset, INT32 iMessageLength, UINT8 ubSender, INT32
|
||||
//MessagePtr pMessageList;
|
||||
//MessagePtr pMessage;
|
||||
//CHAR16 pMessageString[320];
|
||||
|
||||
#ifdef JA2UB
|
||||
if ( EmailType == TYPE_EMAIL_XML )
|
||||
{
|
||||
AddEmailFromXML(iMessageOffset, iDate, iCurrentIMPPosition, iCurrentShipmentDestinationID, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( EmailType == TYPE_EMAIL_EMAIL_EDT )
|
||||
{
|
||||
if ( FileExists(EMAIL_EDT_FILE_JA25) )
|
||||
LoadEncryptedDataFromFile(EMAIL_EDT_FILE_JA25, pSubject, 640 * (iMessageOffset), 640);
|
||||
else
|
||||
LoadEncryptedDataFromFile(EMAIL_EDT_FILE_JA2, pSubject, 640 * (iMessageOffset), 640);
|
||||
}
|
||||
else if ( EmailType == TYPE_EMAIL_BOBBY_R_EMAIL_JA2_EDT || EmailType == TYPE_EMAIL_INSURANCE_COMPANY_EMAIL_JA2_EDT || EmailType == TYPE_EMAIL_DEAD_MERC_AIM_SITE_EMAIL_JA2_EDT )
|
||||
{
|
||||
LoadEncryptedDataFromFile(EMAIL_EDT_FILE_JA2, pSubject, 640 * (iMessageOffset), 640);
|
||||
}
|
||||
else if ( EmailType == TYPE_EMAIL_BOBBY_R )
|
||||
{
|
||||
/* if (EmailBobbyRText[0] !='\0')
|
||||
wcscpy( pSubject, EmailBobbyRText[0] );
|
||||
else
|
||||
wcscpy( pSubject, L"None" );
|
||||
*/
|
||||
}
|
||||
// add message to list
|
||||
AddEmailMessage(iMessageOffset, iMessageLength, pSubject, iDate, ubSender, FALSE, 0, 0, iCurrentIMPPosition, iCurrentShipmentDestinationID, EmailType, TYPE_E_NONE);
|
||||
}
|
||||
|
||||
if ( EmailType == TYPE_EMAIL_EMAIL_EDT )
|
||||
{
|
||||
if (FileExists(EMAIL_EDT_FILE_JA25))
|
||||
LoadEncryptedDataFromFile(EMAIL_EDT_FILE_JA25, pSubject, 640*(iMessageOffset), 640);
|
||||
else
|
||||
LoadEncryptedDataFromFile(EMAIL_EDT_FILE_JA2, pSubject, 640*(iMessageOffset), 640);
|
||||
}
|
||||
else if ( EmailType == TYPE_EMAIL_BOBBY_R_EMAIL_JA2_EDT || EmailType == TYPE_EMAIL_INSURANCE_COMPANY_EMAIL_JA2_EDT || EmailType == TYPE_EMAIL_DEAD_MERC_AIM_SITE_EMAIL_JA2_EDT )
|
||||
{
|
||||
LoadEncryptedDataFromFile(EMAIL_EDT_FILE_JA2, pSubject, 640*(iMessageOffset), 640);
|
||||
}
|
||||
else if ( EmailType == TYPE_EMAIL_BOBBY_R )
|
||||
{
|
||||
/* if (EmailBobbyRText[0] !='\0')
|
||||
wcscpy( pSubject, EmailBobbyRText[0] );
|
||||
else
|
||||
wcscpy( pSubject, L"None" );
|
||||
*/
|
||||
}
|
||||
|
||||
#else
|
||||
// WANNE: Short work in both ways
|
||||
LoadEncryptedDataFromFile("BINARYDATA\\Email.edt", pSubject, 640*(iMessageOffset), 640);
|
||||
#endif
|
||||
// add message to list
|
||||
AddEmailMessage(iMessageOffset,iMessageLength, pSubject, iDate, ubSender, FALSE, 0, 0, iCurrentIMPPosition, iCurrentShipmentDestinationID, EmailType, TYPE_E_NONE);
|
||||
|
||||
// if we are in fact int he laptop, redraw icons, might be change in mail status
|
||||
if ( EmailType == TYPE_EMAIL_XML )
|
||||
{
|
||||
AddEmailFromXML(iMessageOffset, iDate, iCurrentIMPPosition, iCurrentShipmentDestinationID, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// WANNE: Short work in both ways
|
||||
LoadEncryptedDataFromFile("BINARYDATA\\Email.edt", pSubject, 640 * (iMessageOffset), 640);
|
||||
// add message to list
|
||||
AddEmailMessage(iMessageOffset, iMessageLength, pSubject, iDate, ubSender, FALSE, 0, 0, iCurrentIMPPosition, iCurrentShipmentDestinationID, EmailType, TYPE_E_NONE);
|
||||
}
|
||||
#endif
|
||||
|
||||
if( fCurrentlyInLaptop == TRUE )
|
||||
{
|
||||
@@ -950,31 +979,49 @@ void AddPreReadEmail(INT32 iMessageOffset, INT32 iMessageLength, UINT8 ubSender,
|
||||
//CHAR16 pMessageString[320];
|
||||
|
||||
#ifdef JA2UB
|
||||
if ( EmailType == TYPE_EMAIL_EMAIL_EDT )
|
||||
if ( EmailType == TYPE_EMAIL_XML )
|
||||
{
|
||||
if (FileExists(EMAIL_EDT_FILE_JA25) )
|
||||
LoadEncryptedDataFromFile(EMAIL_EDT_FILE_JA25, pSubject, 640*(iMessageOffset), 640);
|
||||
else
|
||||
LoadEncryptedDataFromFile(EMAIL_EDT_FILE_JA2, pSubject, 640*(iMessageOffset), 640);
|
||||
AddEmailFromXML(iMessageOffset, iDate, -1, -1, true);
|
||||
}
|
||||
else if ( EmailType == TYPE_EMAIL_BOBBY_R_EMAIL_JA2_EDT || EmailType == TYPE_EMAIL_INSURANCE_COMPANY_EMAIL_JA2_EDT || EmailType == TYPE_EMAIL_DEAD_MERC_AIM_SITE_EMAIL_JA2_EDT )
|
||||
else
|
||||
{
|
||||
LoadEncryptedDataFromFile(EMAIL_EDT_FILE_JA2, pSubject, 640*(iMessageOffset), 640);
|
||||
if ( EmailType == TYPE_EMAIL_EMAIL_EDT )
|
||||
{
|
||||
if ( FileExists(EMAIL_EDT_FILE_JA25) )
|
||||
LoadEncryptedDataFromFile(EMAIL_EDT_FILE_JA25, pSubject, 640 * (iMessageOffset), 640);
|
||||
else
|
||||
LoadEncryptedDataFromFile(EMAIL_EDT_FILE_JA2, pSubject, 640 * (iMessageOffset), 640);
|
||||
}
|
||||
else if ( EmailType == TYPE_EMAIL_BOBBY_R_EMAIL_JA2_EDT || EmailType == TYPE_EMAIL_INSURANCE_COMPANY_EMAIL_JA2_EDT || EmailType == TYPE_EMAIL_DEAD_MERC_AIM_SITE_EMAIL_JA2_EDT )
|
||||
{
|
||||
LoadEncryptedDataFromFile(EMAIL_EDT_FILE_JA2, pSubject, 640 * (iMessageOffset), 640);
|
||||
}
|
||||
|
||||
// add message to list
|
||||
AddEmailMessage(iMessageOffset, iMessageLength, pSubject, iDate, ubSender, TRUE, 0, 0, -1, -1, EmailType, TYPE_E_NONE);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
if ( EmailType == TYPE_EMAIL_XML )
|
||||
{
|
||||
AddEmailFromXML(iMessageOffset, iDate, -1, -1, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
// starts at iSubjectOffset amd goes iSubjectLength, reading in string
|
||||
LoadEncryptedDataFromFile("BINARYDATA\\Email.edt", pSubject, 640 * (iMessageOffset), 640);
|
||||
// add message to list
|
||||
AddEmailMessage( iMessageOffset,iMessageLength, pSubject, iDate, ubSender, TRUE, 0, 0, -1, -1 , EmailType, TYPE_E_NONE );
|
||||
}
|
||||
#else
|
||||
// starts at iSubjectOffset amd goes iSubjectLength, reading in string
|
||||
LoadEncryptedDataFromFile("BINARYDATA\\Email.edt", pSubject, 640*(iMessageOffset), 640);
|
||||
#endif
|
||||
// add message to list
|
||||
AddEmailMessage( iMessageOffset,iMessageLength, pSubject, iDate, ubSender, TRUE, 0, 0, -1, -1 , EmailType, TYPE_E_NONE );
|
||||
|
||||
// if we are in fact int he laptop, redraw icons, might be change in mail status
|
||||
|
||||
if( fCurrentlyInLaptop == TRUE )
|
||||
{
|
||||
// redraw icons, might be new mail
|
||||
DrawLapTopIcons();
|
||||
}
|
||||
// if we are in fact in the laptop, redraw icons, might be change in mail status
|
||||
if ( fCurrentlyInLaptop == TRUE )
|
||||
{
|
||||
// redraw icons, might be new mail
|
||||
DrawLapTopIcons();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -1688,7 +1735,7 @@ void DrawSender(INT32 iCounter, UINT8 ubSender, BOOLEAN fRead, UINT8 EmailType)
|
||||
else
|
||||
mprintf(SENDER_X,(( UINT16 )( 4 + MIDDLE_Y + iCounter * MIDDLE_WIDTH ) ) ,L"None");
|
||||
}
|
||||
else if ( EmailType == TYPE_EMAIL_EMAIL_EDT || EmailType == TYPE_EMAIL_BOBBY_R || EmailType == TYPE_EMAIL_BOBBY_R_EMAIL_JA2_EDT || EmailType == TYPE_EMAIL_INSURANCE_COMPANY_EMAIL_JA2_EDT || EmailType == TYPE_EMAIL_DEAD_MERC_AIM_SITE_EMAIL_JA2_EDT || EmailType == TYPE_EMAIL_OTHER )
|
||||
else if ( EmailType == TYPE_EMAIL_EMAIL_EDT || EmailType == TYPE_EMAIL_BOBBY_R || EmailType == TYPE_EMAIL_BOBBY_R_EMAIL_JA2_EDT || EmailType == TYPE_EMAIL_INSURANCE_COMPANY_EMAIL_JA2_EDT || EmailType == TYPE_EMAIL_DEAD_MERC_AIM_SITE_EMAIL_JA2_EDT || EmailType == TYPE_EMAIL_OTHER || EmailType == TYPE_EMAIL_XML )
|
||||
{
|
||||
mprintf(SENDER_X,(( UINT16 )( 4 + MIDDLE_Y + iCounter * MIDDLE_WIDTH ) ) ,pSenderNameList[ubSender]);
|
||||
}
|
||||
@@ -1783,7 +1830,9 @@ void DisplayEmailList()
|
||||
DrawSender(iCounter, pEmail->ubSender, pEmail->fRead, pEmail->EmailVersion);
|
||||
else if ( pEmail->EmailVersion == TYPE_EMAIL_EMAIL_EDT || pEmail->EmailVersion == TYPE_EMAIL_EMAIL_EDT_NAME_MERC || pEmail->EmailVersion == TYPE_EMAIL_BOBBY_R || pEmail->EmailVersion == TYPE_EMAIL_BOBBY_R_EMAIL_JA2_EDT || pEmail->EmailVersion == TYPE_EMAIL_INSURANCE_COMPANY_EMAIL_JA2_EDT || pEmail->EmailVersion == TYPE_EMAIL_DEAD_MERC_AIM_SITE_EMAIL_JA2_EDT || pEmail->EmailVersion == TYPE_EMAIL_OTHER )
|
||||
DrawSender(iCounter, pEmail->ubSender, pEmail->fRead, pEmail->EmailVersion);
|
||||
|
||||
else if ( pEmail->EmailVersion == TYPE_EMAIL_XML )
|
||||
DrawSender(iCounter, pEmail->ubSender, pEmail->fRead, pEmail->EmailVersion);
|
||||
|
||||
DrawDate(iCounter, pEmail->iDate, pEmail->fRead );
|
||||
|
||||
++iCounter;
|
||||
@@ -3194,7 +3243,7 @@ void DisplayEmailMessageSubjectDateFromLines( EmailPtr pMail , INT32 iViewerY)
|
||||
else
|
||||
mprintf( MESSAGE_HEADER_X+MESSAGE_HEADER_WIDTH-13, MESSAGE_FROM_Y + iViewerY, L"None");
|
||||
}
|
||||
else if ( pMail->EmailVersion == TYPE_EMAIL_EMAIL_EDT || pMail->EmailVersion == TYPE_EMAIL_BOBBY_R || pMail->EmailVersion == TYPE_EMAIL_BOBBY_R_EMAIL_JA2_EDT || pMail->EmailVersion == TYPE_EMAIL_INSURANCE_COMPANY_EMAIL_JA2_EDT || pMail->EmailVersion == TYPE_EMAIL_DEAD_MERC_AIM_SITE_EMAIL_JA2_EDT || pMail->EmailVersion == TYPE_EMAIL_OTHER )
|
||||
else if ( pMail->EmailVersion == TYPE_EMAIL_EMAIL_EDT || pMail->EmailVersion == TYPE_EMAIL_BOBBY_R || pMail->EmailVersion == TYPE_EMAIL_BOBBY_R_EMAIL_JA2_EDT || pMail->EmailVersion == TYPE_EMAIL_INSURANCE_COMPANY_EMAIL_JA2_EDT || pMail->EmailVersion == TYPE_EMAIL_DEAD_MERC_AIM_SITE_EMAIL_JA2_EDT || pMail->EmailVersion == TYPE_EMAIL_OTHER || pMail->EmailVersion == TYPE_EMAIL_XML)
|
||||
{
|
||||
mprintf( MESSAGE_HEADER_X+MESSAGE_HEADER_WIDTH-13, MESSAGE_FROM_Y + iViewerY, pSenderNameList[pMail->ubSender]);
|
||||
}
|
||||
@@ -5600,6 +5649,11 @@ void PreProcessEmail( EmailPtr pMail )
|
||||
wcscat( pString, EmailOtherText[iEmailOther].szMessage[pMail->usLength]);
|
||||
// wcscat( pString, EmailOtherText[0].szMessage[1]);
|
||||
}
|
||||
else if ( pMail->EmailVersion == TYPE_EMAIL_XML )
|
||||
{
|
||||
wcscpy(pString, L"\0");
|
||||
wcscat(pString, gEmails[pMail->usOffset].Messages[iCounter].c_str());
|
||||
}
|
||||
|
||||
// ----------------
|
||||
// New MERC Merc
|
||||
@@ -5773,7 +5827,7 @@ void PreProcessEmail( EmailPtr pMail )
|
||||
|
||||
//def removed
|
||||
// pass the subject line
|
||||
if( pTempRecord && pMail->usOffset != IMP_EMAIL_PROFILE_RESULTS)
|
||||
if ( pTempRecord && pMail->usOffset != IMP_EMAIL_PROFILE_RESULTS && pMail->EmailVersion != TYPE_EMAIL_XML )
|
||||
{
|
||||
pTempRecord = pTempRecord->Next;
|
||||
}
|
||||
@@ -5825,7 +5879,7 @@ void PreProcessEmail( EmailPtr pMail )
|
||||
{
|
||||
fOnLastPageFlag = TRUE;
|
||||
|
||||
if( pTempRecord && pMail->usOffset != IMP_EMAIL_PROFILE_RESULTS)
|
||||
if( pTempRecord && pMail->usOffset != IMP_EMAIL_PROFILE_RESULTS && pMail->EmailVersion != TYPE_EMAIL_XML )
|
||||
{
|
||||
pTempRecord = pTempRecord->Next;
|
||||
}
|
||||
@@ -5870,7 +5924,7 @@ void PreProcessEmail( EmailPtr pMail )
|
||||
fOnLastPageFlag = FALSE;
|
||||
pTempList = pMessageRecordList;
|
||||
|
||||
if( pTempList && pMail->usOffset != IMP_EMAIL_PROFILE_RESULTS)
|
||||
if( pTempList && pMail->usOffset != IMP_EMAIL_PROFILE_RESULTS && pMail->EmailVersion != TYPE_EMAIL_XML )
|
||||
{
|
||||
pTempList = pTempList->Next;
|
||||
}
|
||||
|
||||
@@ -594,6 +594,14 @@ void AddCustomEmail(INT32 iMessageOffset, INT32 iMessageLength, UINT8 ubSender,
|
||||
void AddAllEmails();
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 Sender;
|
||||
CHAR16 Subject[EMAIL_SUBJECT_LENGTH];
|
||||
std::vector<std::wstring> Messages;
|
||||
} EMAIL_XML;
|
||||
extern std::vector<EMAIL_XML> gEmails;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 uiIndex;
|
||||
@@ -674,6 +682,7 @@ enum {
|
||||
TYPE_EMAIL_KING_PIN,
|
||||
TYPE_EMAIL_JOHN_KULBA,
|
||||
TYPE_EMAIL_AIM_SITE,
|
||||
TYPE_EMAIL_XML,
|
||||
|
||||
TYPE_EMAIL_OTHER,
|
||||
};
|
||||
|
||||
@@ -408,6 +408,8 @@ static int l_AddEmail(lua_State* L);
|
||||
static int l_AddEmailXML(lua_State* L);
|
||||
static int l_AddEmailXML2(lua_State* L);
|
||||
static int l_AddEmailLevelUpXML(lua_State* L);
|
||||
static int l_AddEmailFromXML(lua_State* L);
|
||||
static int l_AddPreReadEmailFromXML(lua_State* L);
|
||||
|
||||
static int l_EVENT_SoldierGotHit(lua_State* L);
|
||||
static int l_EVENT_InitNewSoldierAnim(lua_State* L);
|
||||
@@ -1030,6 +1032,8 @@ static void IniFunction(lua_State* L, BOOLEAN bQuests)
|
||||
lua_register(L, "AddEmailMercAvailableXML", l_AddEmailXML);
|
||||
lua_register(L, "AddEmailMercLevelUpXML", l_AddEmailLevelUpXML);
|
||||
lua_register(L, "AddEmailXML", l_AddEmailXML2);
|
||||
lua_register(L, "AddPreReadEmailFromXML", l_AddPreReadEmailFromXML);
|
||||
lua_register(L, "AddEmailFromXML", l_AddEmailFromXML);
|
||||
|
||||
//------Time------
|
||||
|
||||
@@ -7531,6 +7535,41 @@ static int l_AddPreReadEmail(lua_State* L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// New externalized emails
|
||||
//AddEmail
|
||||
static int l_AddEmailFromXML(lua_State* L)
|
||||
{
|
||||
if (lua_gettop(L))
|
||||
{
|
||||
UINT8 index = lua_tointeger(L, 1);
|
||||
INT32 iCurrentIMPPosition = -1;
|
||||
INT16 iCurrentShipmentDestinationID = -1;
|
||||
INT32 unused = 0;
|
||||
|
||||
if ( lua_gettop(L) >= 3 )
|
||||
{
|
||||
iCurrentIMPPosition = lua_tointeger(L, 2);
|
||||
iCurrentShipmentDestinationID = lua_tointeger(L, 3);
|
||||
}
|
||||
AddEmail(index, unused, unused, GetWorldTotalMin(), iCurrentIMPPosition, iCurrentShipmentDestinationID, TYPE_EMAIL_XML);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//AddPreReadEmail
|
||||
static int l_AddPreReadEmailFromXML(lua_State* L)
|
||||
{
|
||||
if (lua_gettop(L))
|
||||
{
|
||||
UINT8 index = lua_tointeger(L, 1);
|
||||
INT32 unused = 0;
|
||||
AddPreReadEmail(index, unused, unused, GetWorldTotalMin(), TYPE_EMAIL_XML);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//gfBoxerFought
|
||||
static int l_SetgfBoxerFought(lua_State* L)
|
||||
{
|
||||
|
||||
+2
-1
@@ -181,6 +181,7 @@ typedef PARSE_STAGE;
|
||||
#define LAPTOPFUNERALLOCATIONFILENAME "Laptop\\FuneralPositions.xml"
|
||||
#define LAPTOPADDITIONALFILESFILENAME "AdditionalFiles.xml"
|
||||
|
||||
#define EMAILSFILENAME "Email\\Emails.xml"
|
||||
#define EMAILSENDERNAMELIST "Email\\EmailSenderNameList.xml"
|
||||
#define EMAILMERCAVAILABLE "Email\\EmailMercAvailable.xml"
|
||||
#define EMAILMERCLEVELUP "Email\\EmailMercLevelUp.xml"
|
||||
@@ -558,7 +559,7 @@ extern BOOLEAN WriteInActionItems( STR fileName);
|
||||
|
||||
extern BOOLEAN ReadInEmailMercAvailable(STR fileName, BOOLEAN localizedVersion);
|
||||
extern BOOLEAN ReadInEmailMercLevelUp(STR fileName, BOOLEAN localizedVersion);
|
||||
extern BOOLEAN ReadInEmailOther(STR fileName, BOOLEAN localizedVersion);
|
||||
extern BOOLEAN ReadInExternalizedEmails(STR fileName, BOOLEAN localizedVersion);
|
||||
|
||||
extern BOOLEAN ReadInBriefingRoom(STR fileName, BOOLEAN localizedVersion, BRIEFINGROOM_M_DATA *Ency, UINT32 FileType2 );
|
||||
extern BOOLEAN ReadInMinerals(STR fileName, BOOLEAN localizedVersion);
|
||||
|
||||
Reference in New Issue
Block a user