| 7 | 
           cycrow | 
           1 | 
           //header
  | 
        
        
           | 1 | 
           cycrow | 
           2 | 
           #include "SpkFile.h"
  | 
        
        
            | 
            | 
           3 | 
              | 
        
        
           | 7 | 
           cycrow | 
           4 | 
           // debug logging
  | 
        
        
            | 
            | 
           5 | 
           #include "Logging/Log.h"
  | 
        
        
            | 
            | 
           6 | 
              | 
        
        
            | 
            | 
           7 | 
           // old style compression (needed to convert old formats)
  | 
        
        
            | 
            | 
           8 | 
           #include "../../HiP/HiP.h"
  | 
        
        
            | 
            | 
           9 | 
              | 
        
        
           | 88 | 
           cycrow | 
           10 | 
           #include "TextDB.h"
  | 
        
        
            | 
            | 
           11 | 
              | 
        
        
           | 10 | 
           cycrow | 
           12 | 
           //TODO: remove this
  | 
        
        
           | 14 | 
           cycrow | 
           13 | 
           unsigned char *LineByLineRead ( unsigned char *data, const Utils::String &end, Utils::String *readData )
  | 
        
        
           | 10 | 
           cycrow | 
           14 | 
           {
  | 
        
        
           | 14 | 
           cycrow | 
           15 | 
           	Utils::String line;
  | 
        
        
           | 10 | 
           cycrow | 
           16 | 
           	while ( true )
  | 
        
        
            | 
            | 
           17 | 
           	{
  | 
        
        
           | 14 | 
           cycrow | 
           18 | 
           		data = line.readToEndOfLine(data);
  | 
        
        
           | 7 | 
           cycrow | 
           19 | 
              | 
        
        
           | 14 | 
           cycrow | 
           20 | 
           		if ( (*readData).empty() && line.empty() ) continue;
  | 
        
        
           | 10 | 
           cycrow | 
           21 | 
           		if ( line == end )
  | 
        
        
            | 
            | 
           22 | 
           			break;
  | 
        
        
            | 
            | 
           23 | 
           		*readData += (line + "\r\n");
  | 
        
        
            | 
            | 
           24 | 
           	}
  | 
        
        
            | 
            | 
           25 | 
              | 
        
        
            | 
            | 
           26 | 
           	return data;
  | 
        
        
            | 
            | 
           27 | 
           }
  | 
        
        
            | 
            | 
           28 | 
              | 
        
        
            | 
            | 
           29 | 
              | 
        
        
           | 1 | 
           cycrow | 
           30 | 
           CSpkFile::CSpkFile() : CBaseFile ()
  | 
        
        
            | 
            | 
           31 | 
           {
  | 
        
        
            | 
            | 
           32 | 
           	SetDefaults ();
  | 
        
        
            | 
            | 
           33 | 
           }
  | 
        
        
            | 
            | 
           34 | 
              | 
        
        
            | 
            | 
           35 | 
           CSpkFile::~CSpkFile()
  | 
        
        
            | 
            | 
           36 | 
           {
  | 
        
        
            | 
            | 
           37 | 
           	Delete ();
  | 
        
        
            | 
            | 
           38 | 
           }
  | 
        
        
            | 
            | 
           39 | 
           /*
  | 
        
        
            | 
            | 
           40 | 
           	Func:   SetDefaults
  | 
        
        
            | 
            | 
           41 | 
           	Desc:   Sets the  default values when class is created
  | 
        
        
            | 
            | 
           42 | 
           */
  | 
        
        
            | 
            | 
           43 | 
           void CSpkFile::SetDefaults ()
  | 
        
        
            | 
            | 
           44 | 
           {
  | 
        
        
            | 
            | 
           45 | 
           	m_pLastWare = NULL;
  | 
        
        
            | 
            | 
           46 | 
           	m_iPackageType = PACKAGETYPE_NORMAL;
  | 
        
        
            | 
            | 
           47 | 
           	m_bForceProfile = false;
  | 
        
        
            | 
            | 
           48 | 
           	m_iScriptType = SCRIPTTYPE_CUSTOM;
  | 
        
        
            | 
            | 
           49 | 
              | 
        
        
            | 
            | 
           50 | 
           	CBaseFile::SetDefaults ();
  | 
        
        
            | 
            | 
           51 | 
           }
  | 
        
        
            | 
            | 
           52 | 
              | 
        
        
            | 
            | 
           53 | 
           void CSpkFile::Delete ()
  | 
        
        
            | 
            | 
           54 | 
           {
  | 
        
        
            | 
            | 
           55 | 
           	m_lWares.clear(true);
  | 
        
        
            | 
            | 
           56 | 
           	m_lSettings.clear(true);
  | 
        
        
            | 
            | 
           57 | 
              | 
        
        
            | 
            | 
           58 | 
           	CBaseFile::Delete ();
  | 
        
        
            | 
            | 
           59 | 
           }
  | 
        
        
            | 
            | 
           60 | 
              | 
        
        
            | 
            | 
           61 | 
              | 
        
        
           | 14 | 
           cycrow | 
           62 | 
           bool CSpkFile::CheckHeader(const Utils::String header) const
  | 
        
        
           | 1 | 
           cycrow | 
           63 | 
           {
  | 
        
        
            | 
            | 
           64 | 
           	if ( header.Compare("SPKCycrow") )
  | 
        
        
            | 
            | 
           65 | 
           		return true;
  | 
        
        
            | 
            | 
           66 | 
           	return false;
  | 
        
        
            | 
            | 
           67 | 
           }
  | 
        
        
            | 
            | 
           68 | 
           /*
  | 
        
        
            | 
            | 
           69 | 
           	Func:   ParseValueLine
  | 
        
        
            | 
            | 
           70 | 
           	Input:  String - single line from a file to set
  | 
        
        
            | 
            | 
           71 | 
           	Return: Boolean - returns true if value exists
  | 
        
        
            | 
            | 
           72 | 
           	Desc:   Reads the line and assigns the parameters for the file
  | 
        
        
            | 
            | 
           73 | 
           */
  | 
        
        
           | 14 | 
           cycrow | 
           74 | 
           bool CSpkFile::ParseValueLine(const Utils::String &line)
  | 
        
        
           | 1 | 
           cycrow | 
           75 | 
           {
  | 
        
        
           | 14 | 
           cycrow | 
           76 | 
           	Utils::String first = line.token(" ", 1);
  | 
        
        
            | 
            | 
           77 | 
           	Utils::String rest  = line.tokens(" ", 2);
  | 
        
        
           | 1 | 
           cycrow | 
           78 | 
              | 
        
        
            | 
            | 
           79 | 
           	if ( first == "AnotherMod:" )
  | 
        
        
            | 
            | 
           80 | 
           	{
  | 
        
        
           | 10 | 
           cycrow | 
           81 | 
           		m_sOtherAuthor = rest.token("|", 1);
  | 
        
        
            | 
            | 
           82 | 
           		m_sOtherName = rest.tokens("|", 2);
  | 
        
        
           | 1 | 
           cycrow | 
           83 | 
           	}
  | 
        
        
            | 
            | 
           84 | 
           	else if ( line == "CustomStart" )
  | 
        
        
            | 
            | 
           85 | 
           		m_iPackageType = PACKAGETYPE_CUSTOMSTART;
  | 
        
        
            | 
            | 
           86 | 
           	else if ( line == "PackageUpdate" )
  | 
        
        
            | 
            | 
           87 | 
           		m_iPackageType = PACKAGETYPE_UPDATE;
  | 
        
        
            | 
            | 
           88 | 
           	else if ( line == "Patch" )
  | 
        
        
            | 
            | 
           89 | 
           		m_iPackageType = PACKAGETYPE_PATCH;
  | 
        
        
            | 
            | 
           90 | 
           	else if ( line == "ForceProfile" )
  | 
        
        
            | 
            | 
           91 | 
           		m_bForceProfile = true;
  | 
        
        
            | 
            | 
           92 | 
           	else if ( line == "Signed" )
  | 
        
        
            | 
            | 
           93 | 
           		m_bSigned = true;
  | 
        
        
            | 
            | 
           94 | 
           	else if ( first == "ScriptType:" )
  | 
        
        
            | 
            | 
           95 | 
           		m_sScriptType = rest;
  | 
        
        
            | 
            | 
           96 | 
           	else if ( first == "ScriptTypeNew:" )
  | 
        
        
           | 10 | 
           cycrow | 
           97 | 
           		m_iScriptType = rest;
  | 
        
        
           | 1 | 
           cycrow | 
           98 | 
           	else if ( first == "PackageType:" )
  | 
        
        
           | 10 | 
           cycrow | 
           99 | 
           		m_iPackageType = rest;
  | 
        
        
           | 1 | 
           cycrow | 
           100 | 
           	else if ( first == "Ware:" )
  | 
        
        
            | 
            | 
           101 | 
           		AddWare ( rest );
  | 
        
        
            | 
            | 
           102 | 
           	else if ( (first == "WareText:") && (m_pLastWare) )
  | 
        
        
            | 
            | 
           103 | 
           		AddWareText ( rest );
  | 
        
        
            | 
            | 
           104 | 
           	else if ( first == "Setting:" )
  | 
        
        
            | 
            | 
           105 | 
           	{
  | 
        
        
           | 10 | 
           cycrow | 
           106 | 
           		SSettingType *t = AddSetting ( rest.token("|", 2), rest.token("|", 1) );
  | 
        
        
            | 
            | 
           107 | 
           		ConvertSetting ( t, rest.tokens("|", 3));
  | 
        
        
           | 1 | 
           cycrow | 
           108 | 
           	}
  | 
        
        
            | 
            | 
           109 | 
           	else
  | 
        
        
            | 
            | 
           110 | 
           		return CBaseFile::ParseValueLine ( line );
  | 
        
        
            | 
            | 
           111 | 
              | 
        
        
            | 
            | 
           112 | 
           	return true;
  | 
        
        
            | 
            | 
           113 | 
           }
  | 
        
        
            | 
            | 
           114 | 
              | 
        
        
            | 
            | 
           115 | 
           /*
  | 
        
        
            | 
            | 
           116 | 
           	Func:   CreateValuesLine
  | 
        
        
            | 
            | 
           117 | 
           	Return: String - returns the full string for values
  | 
        
        
            | 
            | 
           118 | 
           	Desc:   Creates a single string for all values, this is used when compressing to write to the spk file
  | 
        
        
            | 
            | 
           119 | 
           */
  | 
        
        
           | 14 | 
           cycrow | 
           120 | 
           Utils::String CSpkFile::CreateValuesLine () const
  | 
        
        
           | 1 | 
           cycrow | 
           121 | 
           {
  | 
        
        
           | 14 | 
           cycrow | 
           122 | 
           	Utils::String values = CBaseFile::CreateValuesLine ();
  | 
        
        
           | 1 | 
           cycrow | 
           123 | 
           	// combine all values together
  | 
        
        
           | 10 | 
           cycrow | 
           124 | 
           	if ( (!m_sOtherAuthor.empty()) && (!m_sOtherName.empty()) )
  | 
        
        
           | 14 | 
           cycrow | 
           125 | 
           		values += "AnotherMod: " + m_sOtherAuthor + "|" + m_sOtherName + "\n";
  | 
        
        
           | 1 | 
           cycrow | 
           126 | 
           	if ( m_bForceProfile )
  | 
        
        
            | 
            | 
           127 | 
           		values += "ForceProfile\n";
  | 
        
        
           | 10 | 
           cycrow | 
           128 | 
           	if ( !m_sScriptType.empty() )
  | 
        
        
           | 14 | 
           cycrow | 
           129 | 
           		values += "ScriptType: " + m_sScriptType + "\n";
  | 
        
        
            | 
            | 
           130 | 
           	values += Utils::String("PackageType: ") + (long)m_iPackageType + "\n";
  | 
        
        
            | 
            | 
           131 | 
           	values += Utils::String("ScriptTypeNew: ") + (long)m_iScriptType + "\n";
  | 
        
        
           | 1 | 
           cycrow | 
           132 | 
              | 
        
        
           | 14 | 
           cycrow | 
           133 | 
           	for ( CListNode<SSettingType> *node = m_lSettings.Front(); node; node = node->next() )
  | 
        
        
            | 
            | 
           134 | 
           		values += Utils::String("Setting: ") + (long)node->Data()->iType + "|" + node->Data()->sKey + "|" + GetSetting(node->Data()) + "\n";
  | 
        
        
           | 1 | 
           cycrow | 
           135 | 
              | 
        
        
           | 14 | 
           cycrow | 
           136 | 
           	for ( CListNode<SWares> *wNode = m_lWares.Front(); wNode; wNode = wNode->next() ) {
  | 
        
        
            | 
            | 
           137 | 
           		SWares *ware = wNode->Data();
  | 
        
        
            | 
            | 
           138 | 
           		if ( wNode->Data()->iTextID > 0 )
  | 
        
        
            | 
            | 
           139 | 
           			values += Utils::String("Ware: ") + ware->cType + ":" + ware->iPrice + ":" + (long)ware->iSize + ":" + (long)ware->iVolumn + ":" + ware->sID + ":" + (long)ware->iNotority + ":" + (long)ware->iTextID + "," + (long)ware->iTextPage + "\n";
  | 
        
        
           | 1 | 
           cycrow | 
           140 | 
           		else
  | 
        
        
           | 14 | 
           cycrow | 
           141 | 
           			values += Utils::String("Ware: ") + ware->cType + ":" + ware->iPrice + ":" + (long)ware->iSize + ":" + (long)ware->iVolumn + ":" + ware->sID + ":" + (long)ware->iNotority + "\n";
  | 
        
        
            | 
            | 
           142 | 
           		for ( CListNode<SWaresText> *wtNode = ware->lText.Front(); wtNode; wtNode = wtNode->next() )
  | 
        
        
            | 
            | 
           143 | 
           			values += Utils::String("WareText: ") + (long)wtNode->Data()->iLang + " " + wtNode->Data()->sName + "|" + wtNode->Data()->sDesc + "\n";
  | 
        
        
           | 1 | 
           cycrow | 
           144 | 
           	}
  | 
        
        
            | 
            | 
           145 | 
              | 
        
        
            | 
            | 
           146 | 
           	return values;
  | 
        
        
            | 
            | 
           147 | 
           }
  | 
        
        
            | 
            | 
           148 | 
              | 
        
        
           | 13 | 
           cycrow | 
           149 | 
           Utils::String CSpkFile::GetCustomScriptType (int lang) const
  | 
        
        
           | 1 | 
           cycrow | 
           150 | 
           {
  | 
        
        
           | 10 | 
           cycrow | 
           151 | 
           	if ( !m_sScriptType.empty() )
  | 
        
        
           | 1 | 
           cycrow | 
           152 | 
           	{
  | 
        
        
            | 
            | 
           153 | 
           		int max;
  | 
        
        
           | 10 | 
           cycrow | 
           154 | 
           		Utils::String *split = m_sScriptType.tokenise("<br>", &max);
  | 
        
        
           | 1 | 
           cycrow | 
           155 | 
           		if ( max && split )
  | 
        
        
            | 
            | 
           156 | 
           		{
  | 
        
        
            | 
            | 
           157 | 
           			for ( int i = 1; i < max; i++ )
  | 
        
        
            | 
            | 
           158 | 
           			{
  | 
        
        
           | 10 | 
           cycrow | 
           159 | 
           				Utils::String str = split[i];
  | 
        
        
            | 
            | 
           160 | 
           				int num = str.token(":", 1);
  | 
        
        
            | 
            | 
           161 | 
           				Utils::String name = str.tokens(":", 2);
  | 
        
        
           | 1 | 
           cycrow | 
           162 | 
              | 
        
        
            | 
            | 
           163 | 
           				if ( num == lang )
  | 
        
        
            | 
            | 
           164 | 
           				{
  | 
        
        
            | 
            | 
           165 | 
           					CLEANSPLIT(split, max)
  | 
        
        
            | 
            | 
           166 | 
           					return name;
  | 
        
        
            | 
            | 
           167 | 
           				}
  | 
        
        
            | 
            | 
           168 | 
           			}
  | 
        
        
            | 
            | 
           169 | 
              | 
        
        
           | 10 | 
           cycrow | 
           170 | 
           			Utils::String ret = split[0];
  | 
        
        
           | 1 | 
           cycrow | 
           171 | 
           			CLEANSPLIT(split, max)
  | 
        
        
            | 
            | 
           172 | 
              | 
        
        
            | 
            | 
           173 | 
           			return ret;
  | 
        
        
            | 
            | 
           174 | 
           		}
  | 
        
        
            | 
            | 
           175 | 
           		CLEANSPLIT(split, max)
  | 
        
        
            | 
            | 
           176 | 
           	}
  | 
        
        
            | 
            | 
           177 | 
           	return m_sScriptType;
  | 
        
        
            | 
            | 
           178 | 
           }
  | 
        
        
            | 
            | 
           179 | 
              | 
        
        
           | 88 | 
           cycrow | 
           180 | 
           bool CSpkFile::readWares(int iLang, CLinkList<SWareEntry> &list, const Utils::String &empWares)
  | 
        
        
            | 
            | 
           181 | 
           {
  | 
        
        
            | 
            | 
           182 | 
           	if ( CBaseFile::readWares(iLang, list, empWares) ) {
  | 
        
        
            | 
            | 
           183 | 
           		for(CListNode<SWares> *node = m_lWares.Front(); node; node = node->next()) {
  | 
        
        
            | 
            | 
           184 | 
              | 
        
        
            | 
            | 
           185 | 
           			SWareEntry *ware = new SWareEntry;
  | 
        
        
            | 
            | 
           186 | 
              | 
        
        
            | 
            | 
           187 | 
           			for(CListNode<SWaresText> *textNode = node->Data()->lText.Front(); textNode; textNode = textNode->next()) {
  | 
        
        
            | 
            | 
           188 | 
           				ware->name = textNode->Data()->sName;
  | 
        
        
            | 
            | 
           189 | 
           				ware->description = textNode->Data()->sDesc;
  | 
        
        
            | 
            | 
           190 | 
           				if ( textNode->Data()->iLang == iLang )	{
  | 
        
        
            | 
            | 
           191 | 
           					break;
  | 
        
        
            | 
            | 
           192 | 
           				}
  | 
        
        
            | 
            | 
           193 | 
           			}
  | 
        
        
            | 
            | 
           194 | 
              | 
        
        
            | 
            | 
           195 | 
           			if ( ware->name.empty() ) {
  | 
        
        
            | 
            | 
           196 | 
           				ware->name = _pTextDB->get(iLang, node->Data()->iTextPage, node->Data()->iTextID);
  | 
        
        
            | 
            | 
           197 | 
           			}
  | 
        
        
            | 
            | 
           198 | 
           			if ( ware->description.empty() ) {
  | 
        
        
            | 
            | 
           199 | 
           				ware->description = _pTextDB->get(iLang, node->Data()->iTextPage, node->Data()->iDescID);
  | 
        
        
            | 
            | 
           200 | 
           			}
  | 
        
        
            | 
            | 
           201 | 
              | 
        
        
            | 
            | 
           202 | 
           			ware->id = node->Data()->sID;
  | 
        
        
            | 
            | 
           203 | 
           			ware->relval = node->Data()->iPrice;
  | 
        
        
            | 
            | 
           204 | 
           			ware->position = node->Data()->iPosID;
  | 
        
        
            | 
            | 
           205 | 
           			ware->type = Ware_Custom;
  | 
        
        
            | 
            | 
           206 | 
           			ware->notority = node->Data()->iNotority;
  | 
        
        
           | 89 | 
           cycrow | 
           207 | 
           			ware->position = 0;
  | 
        
        
            | 
            | 
           208 | 
           			ware->package = this;
  | 
        
        
           | 88 | 
           cycrow | 
           209 | 
              | 
        
        
            | 
            | 
           210 | 
           			list.push_back(ware);
  | 
        
        
            | 
            | 
           211 | 
           		}
  | 
        
        
            | 
            | 
           212 | 
              | 
        
        
            | 
            | 
           213 | 
           		return true;
  | 
        
        
            | 
            | 
           214 | 
           	}
  | 
        
        
            | 
            | 
           215 | 
              | 
        
        
            | 
            | 
           216 | 
           	return false;
  | 
        
        
            | 
            | 
           217 | 
           }
  | 
        
        
            | 
            | 
           218 | 
              | 
        
        
           | 52 | 
           cycrow | 
           219 | 
           bool CSpkFile::WriteHeader(CFileIO &file, int valueheader, int valueComprLen)
  | 
        
        
           | 1 | 
           cycrow | 
           220 | 
           {
  | 
        
        
           | 52 | 
           cycrow | 
           221 | 
           	return file.write("SPKCycrow;%.2f;%d;%d\n", FILEVERSION, valueheader, valueComprLen);
  | 
        
        
           | 1 | 
           cycrow | 
           222 | 
           }
  | 
        
        
            | 
            | 
           223 | 
              | 
        
        
           | 10 | 
           cycrow | 
           224 | 
           void CSpkFile::AddWareText(const Utils::String &sData)
  | 
        
        
           | 1 | 
           cycrow | 
           225 | 
           {
  | 
        
        
            | 
            | 
           226 | 
           	if ( !m_pLastWare )
  | 
        
        
            | 
            | 
           227 | 
           		return;
  | 
        
        
            | 
            | 
           228 | 
              | 
        
        
            | 
            | 
           229 | 
           	SWaresText *wt = new SWaresText;
  | 
        
        
           | 10 | 
           cycrow | 
           230 | 
           	wt->iLang = sData.token(" ", 1);
  | 
        
        
            | 
            | 
           231 | 
           	wt->sName = sData.tokens(" ", 2).token("|", 1);
  | 
        
        
            | 
            | 
           232 | 
           	wt->sDesc = sData.tokens(" ", 2).tokens("|", 2);
  | 
        
        
           | 1 | 
           cycrow | 
           233 | 
           	m_pLastWare->lText.push_back ( wt );
  | 
        
        
            | 
            | 
           234 | 
              | 
        
        
           | 50 | 
           cycrow | 
           235 | 
           	_changed();
  | 
        
        
           | 1 | 
           cycrow | 
           236 | 
           }
  | 
        
        
            | 
            | 
           237 | 
              | 
        
        
           | 10 | 
           cycrow | 
           238 | 
           void CSpkFile::AddWare(const Utils::String &sData)
  | 
        
        
           | 1 | 
           cycrow | 
           239 | 
           {
  | 
        
        
            | 
            | 
           240 | 
           	SWares *ware = new SWares;
  | 
        
        
            | 
            | 
           241 | 
           	ware->iTextID = -1;
  | 
        
        
            | 
            | 
           242 | 
           	ware->iTextPage = 0;
  | 
        
        
           | 10 | 
           cycrow | 
           243 | 
           	ware->cType = sData.token(":", 1)[0];
  | 
        
        
            | 
            | 
           244 | 
           	ware->iPrice = sData.token(":", 2);
  | 
        
        
            | 
            | 
           245 | 
           	ware->iSize = sData.token(":", 3);
  | 
        
        
            | 
            | 
           246 | 
           	ware->iVolumn = sData.token(":", 4);
  | 
        
        
            | 
            | 
           247 | 
           	ware->sID = sData.token(":", 5);
  | 
        
        
            | 
            | 
           248 | 
           	ware->iNotority = sData.token(":", 6);
  | 
        
        
            | 
            | 
           249 | 
           	if ( !sData.token(":", 7).empty() )
  | 
        
        
           | 1 | 
           cycrow | 
           250 | 
           	{
  | 
        
        
           | 10 | 
           cycrow | 
           251 | 
           		Utils::String r = sData.token(":", 7);
  | 
        
        
            | 
            | 
           252 | 
           		ware->iTextID = r.token(",", 1);
  | 
        
        
            | 
            | 
           253 | 
           		ware->iTextPage = r.token(",", 2);
  | 
        
        
           | 1 | 
           cycrow | 
           254 | 
           	}
  | 
        
        
            | 
            | 
           255 | 
           	m_lWares.push_back ( ware );
  | 
        
        
            | 
            | 
           256 | 
           	m_pLastWare = ware;
  | 
        
        
            | 
            | 
           257 | 
              | 
        
        
           | 50 | 
           cycrow | 
           258 | 
           	_changed();
  | 
        
        
           | 1 | 
           cycrow | 
           259 | 
           }
  | 
        
        
            | 
            | 
           260 | 
              | 
        
        
           | 13 | 
           cycrow | 
           261 | 
           bool CSpkFile::CheckValidReadmes () const
  | 
        
        
           | 1 | 
           cycrow | 
           262 | 
           {
  | 
        
        
            | 
            | 
           263 | 
           	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
  | 
        
        
            | 
            | 
           264 | 
           	{
  | 
        
        
            | 
            | 
           265 | 
           		C_File *file = node->Data();
  | 
        
        
            | 
            | 
           266 | 
           		if ( file->GetFileType() != FILETYPE_README )
  | 
        
        
            | 
            | 
           267 | 
           			continue;
  | 
        
        
            | 
            | 
           268 | 
           		if ( !file->CheckValidFilePointer() )
  | 
        
        
            | 
            | 
           269 | 
           			continue;
  | 
        
        
            | 
            | 
           270 | 
           		return true;
  | 
        
        
            | 
            | 
           271 | 
           	}
  | 
        
        
            | 
            | 
           272 | 
              | 
        
        
            | 
            | 
           273 | 
           	return false;
  | 
        
        
            | 
            | 
           274 | 
           }
  | 
        
        
            | 
            | 
           275 | 
              | 
        
        
            | 
            | 
           276 | 
           void CSpkFile::ClearWares()
  | 
        
        
            | 
            | 
           277 | 
           {
  | 
        
        
           | 10 | 
           cycrow | 
           278 | 
           	for ( CListNode<SWares> *node = m_lWares.Front(); node; node = node->next() ) {
  | 
        
        
           | 1 | 
           cycrow | 
           279 | 
           		node->Data()->lText.clear(true);
  | 
        
        
            | 
            | 
           280 | 
           		node->DeleteData();
  | 
        
        
            | 
            | 
           281 | 
           	}
  | 
        
        
           | 50 | 
           cycrow | 
           282 | 
           	_changed();
  | 
        
        
           | 1 | 
           cycrow | 
           283 | 
           	m_lWares.clear(true);
  | 
        
        
            | 
            | 
           284 | 
           }
  | 
        
        
            | 
            | 
           285 | 
              | 
        
        
           | 10 | 
           cycrow | 
           286 | 
           SWares *CSpkFile::FindWare(const Utils::String &id) const
  | 
        
        
           | 1 | 
           cycrow | 
           287 | 
           {
  | 
        
        
           | 10 | 
           cycrow | 
           288 | 
           	for ( CListNode<SWares> *node = m_lWares.Front(); node; node = node->next() ) {
  | 
        
        
            | 
            | 
           289 | 
           		SWares *w = node->Data();
  | 
        
        
            | 
            | 
           290 | 
           		if ( w->sID.Compare(id) ) {
  | 
        
        
           | 1 | 
           cycrow | 
           291 | 
           			return w;
  | 
        
        
           | 10 | 
           cycrow | 
           292 | 
           		}
  | 
        
        
           | 1 | 
           cycrow | 
           293 | 
           	}
  | 
        
        
            | 
            | 
           294 | 
           	return NULL;
  | 
        
        
            | 
            | 
           295 | 
           }
  | 
        
        
            | 
            | 
           296 | 
              | 
        
        
           | 10 | 
           cycrow | 
           297 | 
           void CSpkFile::RemoveWare(const Utils::String &id )
  | 
        
        
           | 1 | 
           cycrow | 
           298 | 
           {
  | 
        
        
           | 10 | 
           cycrow | 
           299 | 
           	for ( CListNode<SWares> *node = m_lWares.Front(); node; node = node->next() ) {
  | 
        
        
            | 
            | 
           300 | 
           		SWares *w = node->Data();
  | 
        
        
            | 
            | 
           301 | 
           		if ( w->sID.Compare(id) ) {
  | 
        
        
           | 1 | 
           cycrow | 
           302 | 
           			m_lWares.RemoveCurrent ();
  | 
        
        
            | 
            | 
           303 | 
           			delete w;
  | 
        
        
           | 50 | 
           cycrow | 
           304 | 
           			_changed();
  | 
        
        
           | 1 | 
           cycrow | 
           305 | 
           			return;
  | 
        
        
            | 
            | 
           306 | 
           		}
  | 
        
        
            | 
            | 
           307 | 
           	}
  | 
        
        
            | 
            | 
           308 | 
           }
  | 
        
        
            | 
            | 
           309 | 
              | 
        
        
           | 10 | 
           cycrow | 
           310 | 
           void CSpkFile::AddWare(SWares *ware)
  | 
        
        
           | 1 | 
           cycrow | 
           311 | 
           {
  | 
        
        
           | 10 | 
           cycrow | 
           312 | 
           	ware->sID.remove(' ');
  | 
        
        
           | 1 | 
           cycrow | 
           313 | 
              | 
        
        
           | 10 | 
           cycrow | 
           314 | 
           	SWares *newware = this->FindWare(ware->sID);
  | 
        
        
            | 
            | 
           315 | 
           	if ( newware ) {
  | 
        
        
            | 
            | 
           316 | 
           		m_lWares.remove(newware);
  | 
        
        
            | 
            | 
           317 | 
           	}
  | 
        
        
           | 1 | 
           cycrow | 
           318 | 
              | 
        
        
           | 10 | 
           cycrow | 
           319 | 
           	m_lWares.push_back(ware);
  | 
        
        
           | 50 | 
           cycrow | 
           320 | 
           	_changed();
  | 
        
        
           | 1 | 
           cycrow | 
           321 | 
           }
  | 
        
        
            | 
            | 
           322 | 
              | 
        
        
           | 10 | 
           cycrow | 
           323 | 
           void CSpkFile::AddWareText(SWares *pWare, int iLang, const Utils::String &sName, const Utils::String &sDesc)
  | 
        
        
           | 1 | 
           cycrow | 
           324 | 
           {
  | 
        
        
            | 
            | 
           325 | 
           	SWaresText *wt;
  | 
        
        
           | 10 | 
           cycrow | 
           326 | 
           	for ( CListNode<SWaresText> *node = pWare->lText.Front(); node; node = node->next() ) {
  | 
        
        
            | 
            | 
           327 | 
           		wt = node->Data();
  | 
        
        
            | 
            | 
           328 | 
           		if ( wt->iLang == iLang ) {
  | 
        
        
            | 
            | 
           329 | 
           			wt->sDesc = sDesc;
  | 
        
        
            | 
            | 
           330 | 
           			wt->sName = sName;
  | 
        
        
           | 1 | 
           cycrow | 
           331 | 
           			return;
  | 
        
        
            | 
            | 
           332 | 
           		}
  | 
        
        
            | 
            | 
           333 | 
           	}
  | 
        
        
            | 
            | 
           334 | 
              | 
        
        
            | 
            | 
           335 | 
           	wt = new SWaresText;
  | 
        
        
           | 10 | 
           cycrow | 
           336 | 
           	wt->iLang = iLang;
  | 
        
        
            | 
            | 
           337 | 
           	wt->sName = sName;
  | 
        
        
            | 
            | 
           338 | 
           	wt->sDesc = sDesc;
  | 
        
        
           | 1 | 
           cycrow | 
           339 | 
              | 
        
        
           | 10 | 
           cycrow | 
           340 | 
           	pWare->lText.push_back(wt);
  | 
        
        
           | 50 | 
           cycrow | 
           341 | 
           	_changed();
  | 
        
        
           | 1 | 
           cycrow | 
           342 | 
           }
  | 
        
        
            | 
            | 
           343 | 
              | 
        
        
            | 
            | 
           344 | 
              | 
        
        
           | 10 | 
           cycrow | 
           345 | 
           void CSpkFile::ClearWareText(const Utils::String &id)
  | 
        
        
           | 1 | 
           cycrow | 
           346 | 
           {
  | 
        
        
           | 10 | 
           cycrow | 
           347 | 
           	SWares *w = FindWare(id);
  | 
        
        
            | 
            | 
           348 | 
           	ClearWareText(w);
  | 
        
        
           | 1 | 
           cycrow | 
           349 | 
           }
  | 
        
        
            | 
            | 
           350 | 
              | 
        
        
           | 10 | 
           cycrow | 
           351 | 
           void CSpkFile::ClearWareText(SWares *w)
  | 
        
        
           | 1 | 
           cycrow | 
           352 | 
           {
  | 
        
        
            | 
            | 
           353 | 
           	if ( !w ) return;
  | 
        
        
            | 
            | 
           354 | 
              | 
        
        
            | 
            | 
           355 | 
           	w->lText.clear(true);
  | 
        
        
           | 50 | 
           cycrow | 
           356 | 
           	_changed();
  | 
        
        
           | 1 | 
           cycrow | 
           357 | 
           }
  | 
        
        
            | 
            | 
           358 | 
              | 
        
        
           | 10 | 
           cycrow | 
           359 | 
           void CSpkFile::RemoveWareText(const Utils::String &wid, int lang)
  | 
        
        
           | 1 | 
           cycrow | 
           360 | 
           {
  | 
        
        
           | 10 | 
           cycrow | 
           361 | 
           	SWares *w = FindWare(wid);
  | 
        
        
           | 1 | 
           cycrow | 
           362 | 
           	if ( w )
  | 
        
        
            | 
            | 
           363 | 
           	{
  | 
        
        
           | 10 | 
           cycrow | 
           364 | 
           		for ( CListNode<SWaresText> *node = w->lText.Front(); node; node = node->next() ) {
  | 
        
        
            | 
            | 
           365 | 
           			SWaresText *wt = node->Data();
  | 
        
        
            | 
            | 
           366 | 
           			if ( wt->iLang == lang ) {
  | 
        
        
           | 1 | 
           cycrow | 
           367 | 
           				w->lText.RemoveCurrent();
  | 
        
        
           | 50 | 
           cycrow | 
           368 | 
           				_changed();
  | 
        
        
           | 1 | 
           cycrow | 
           369 | 
           				delete wt;
  | 
        
        
            | 
            | 
           370 | 
           				break;
  | 
        
        
            | 
            | 
           371 | 
           			}
  | 
        
        
            | 
            | 
           372 | 
           		}
  | 
        
        
            | 
            | 
           373 | 
           	}
  | 
        
        
            | 
            | 
           374 | 
           }
  | 
        
        
            | 
            | 
           375 | 
              | 
        
        
           | 13 | 
           cycrow | 
           376 | 
           int CSpkFile::CheckValidCustomStart () const
  | 
        
        
           | 1 | 
           cycrow | 
           377 | 
           {
  | 
        
        
            | 
            | 
           378 | 
           	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
  | 
        
        
            | 
            | 
           379 | 
           	{
  | 
        
        
            | 
            | 
           380 | 
           		C_File *file = node->Data();
  | 
        
        
            | 
            | 
           381 | 
           		if ( file->GetFileType() != FILETYPE_SCRIPT )
  | 
        
        
            | 
            | 
           382 | 
           			continue;
  | 
        
        
            | 
            | 
           383 | 
              | 
        
        
           | 14 | 
           cycrow | 
           384 | 
           		Utils::String basename = file->GetName().GetToken ( 1, file->GetName().NumToken('.') - 1, '.' ).ToString();
  | 
        
        
            | 
            | 
           385 | 
           		if ( basename.right(15).Compare(".initplayership") )
  | 
        
        
           | 1 | 
           cycrow | 
           386 | 
           			return 0;
  | 
        
        
            | 
            | 
           387 | 
           	}
  | 
        
        
            | 
            | 
           388 | 
           	if ( !IsAnotherMod() )
  | 
        
        
            | 
            | 
           389 | 
           		return 1;
  | 
        
        
            | 
            | 
           390 | 
           	else
  | 
        
        
            | 
            | 
           391 | 
           		return 2;
  | 
        
        
            | 
            | 
           392 | 
           }
  | 
        
        
            | 
            | 
           393 | 
              | 
        
        
            | 
            | 
           394 | 
           bool CSpkFile::UpdateSigned (bool updateFiles)
  | 
        
        
            | 
            | 
           395 | 
           {
  | 
        
        
            | 
            | 
           396 | 
           	// check for any custom wares
  | 
        
        
            | 
            | 
           397 | 
           	// patch mods and custom starts are also not signed
  | 
        
        
            | 
            | 
           398 | 
           	if ( (!m_lWares.empty()) || (this->IsPatch()) || (this->IsCustomStart()) )
  | 
        
        
            | 
            | 
           399 | 
           	{
  | 
        
        
            | 
            | 
           400 | 
           		m_bSigned = false;
  | 
        
        
            | 
            | 
           401 | 
           		return false;
  | 
        
        
            | 
            | 
           402 | 
           	}
  | 
        
        
            | 
            | 
           403 | 
              | 
        
        
            | 
            | 
           404 | 
           	return CBaseFile::UpdateSigned(updateFiles);
  | 
        
        
            | 
            | 
           405 | 
           }
  | 
        
        
            | 
            | 
           406 | 
              | 
        
        
           | 14 | 
           cycrow | 
           407 | 
           SSettingType *CSpkFile::AddSetting(const Utils::String &key, int type )
  | 
        
        
           | 1 | 
           cycrow | 
           408 | 
           {
  | 
        
        
           | 39 | 
           cycrow | 
           409 | 
           	Utils::String sKey = key.remove('|');
  | 
        
        
           | 10 | 
           cycrow | 
           410 | 
              | 
        
        
           | 1 | 
           cycrow | 
           411 | 
           	SSettingType *t;
  | 
        
        
            | 
            | 
           412 | 
           	for ( t = m_lSettings.First(); t; t = m_lSettings.Next() )
  | 
        
        
            | 
            | 
           413 | 
           	{
  | 
        
        
           | 10 | 
           cycrow | 
           414 | 
           		if ( t->sKey.Compare(sKey) )
  | 
        
        
           | 1 | 
           cycrow | 
           415 | 
           			return NULL;
  | 
        
        
            | 
            | 
           416 | 
           	}
  | 
        
        
            | 
            | 
           417 | 
              | 
        
        
            | 
            | 
           418 | 
           	switch ( type )
  | 
        
        
            | 
            | 
           419 | 
           	{
  | 
        
        
            | 
            | 
           420 | 
           		case SETTING_STRING:
  | 
        
        
            | 
            | 
           421 | 
           			t = new SSettingString;
  | 
        
        
            | 
            | 
           422 | 
           			break;
  | 
        
        
            | 
            | 
           423 | 
           		case SETTING_INTEGER:
  | 
        
        
            | 
            | 
           424 | 
           			t = new SSettingInteger;
  | 
        
        
            | 
            | 
           425 | 
           			break;
  | 
        
        
            | 
            | 
           426 | 
           		case SETTING_CHECK:
  | 
        
        
            | 
            | 
           427 | 
           			t = new SSettingCheck;
  | 
        
        
            | 
            | 
           428 | 
           			break;
  | 
        
        
            | 
            | 
           429 | 
           	}
  | 
        
        
            | 
            | 
           430 | 
              | 
        
        
            | 
            | 
           431 | 
           	if ( !t )
  | 
        
        
            | 
            | 
           432 | 
           		return NULL;
  | 
        
        
            | 
            | 
           433 | 
              | 
        
        
           | 10 | 
           cycrow | 
           434 | 
           	t->sKey = sKey;
  | 
        
        
           | 1 | 
           cycrow | 
           435 | 
           	t->iType = type;
  | 
        
        
            | 
            | 
           436 | 
              | 
        
        
            | 
            | 
           437 | 
           	m_lSettings.push_back ( t );
  | 
        
        
           | 50 | 
           cycrow | 
           438 | 
           	_changed();
  | 
        
        
           | 1 | 
           cycrow | 
           439 | 
              | 
        
        
            | 
            | 
           440 | 
           	return t;
  | 
        
        
            | 
            | 
           441 | 
           }
  | 
        
        
            | 
            | 
           442 | 
              | 
        
        
           | 10 | 
           cycrow | 
           443 | 
           void CSpkFile::ConvertSetting ( SSettingType *t, const Utils::String &set ) const
  | 
        
        
           | 1 | 
           cycrow | 
           444 | 
           {
  | 
        
        
            | 
            | 
           445 | 
           	if ( !t )
  | 
        
        
            | 
            | 
           446 | 
           		return;
  | 
        
        
            | 
            | 
           447 | 
              | 
        
        
            | 
            | 
           448 | 
           	switch ( t->iType )
  | 
        
        
            | 
            | 
           449 | 
           	{
  | 
        
        
            | 
            | 
           450 | 
           		case SETTING_STRING:
  | 
        
        
            | 
            | 
           451 | 
           			((SSettingString *)t)->sValue = set;
  | 
        
        
            | 
            | 
           452 | 
           			break;
  | 
        
        
            | 
            | 
           453 | 
           		case SETTING_INTEGER:
  | 
        
        
           | 10 | 
           cycrow | 
           454 | 
           			((SSettingInteger *)t)->iValue = set;
  | 
        
        
           | 1 | 
           cycrow | 
           455 | 
           			break;
  | 
        
        
            | 
            | 
           456 | 
           		case SETTING_CHECK:
  | 
        
        
           | 10 | 
           cycrow | 
           457 | 
           			((SSettingCheck *)t)->bValue = set;
  | 
        
        
           | 1 | 
           cycrow | 
           458 | 
           			break;
  | 
        
        
            | 
            | 
           459 | 
           	}
  | 
        
        
            | 
            | 
           460 | 
           }
  | 
        
        
           | 10 | 
           cycrow | 
           461 | 
           Utils::String CSpkFile::GetSetting ( SSettingType *t ) const
  | 
        
        
           | 1 | 
           cycrow | 
           462 | 
           {
  | 
        
        
            | 
            | 
           463 | 
           	if ( !t )
  | 
        
        
            | 
            | 
           464 | 
           		return "";
  | 
        
        
            | 
            | 
           465 | 
              | 
        
        
            | 
            | 
           466 | 
           	switch ( t->iType )
  | 
        
        
            | 
            | 
           467 | 
           	{
  | 
        
        
            | 
            | 
           468 | 
           		case SETTING_STRING:
  | 
        
        
            | 
            | 
           469 | 
           			return ((SSettingString *)t)->sValue;
  | 
        
        
            | 
            | 
           470 | 
           		case SETTING_INTEGER:
  | 
        
        
           | 50 | 
           cycrow | 
           471 | 
           			return Utils::String::Number(((SSettingInteger *)t)->iValue);
  | 
        
        
           | 1 | 
           cycrow | 
           472 | 
           		case SETTING_CHECK:
  | 
        
        
            | 
            | 
           473 | 
           			return (((SSettingInteger *)t)->iValue) ? "1" : "0";
  | 
        
        
            | 
            | 
           474 | 
           	}
  | 
        
        
            | 
            | 
           475 | 
              | 
        
        
            | 
            | 
           476 | 
           	return "";
  | 
        
        
            | 
            | 
           477 | 
           }
  | 
        
        
            | 
            | 
           478 | 
              | 
        
        
            | 
            | 
           479 | 
           void CSpkFile::ClearSettings ()
  | 
        
        
            | 
            | 
           480 | 
           {
  | 
        
        
            | 
            | 
           481 | 
           	m_lSettings.clear(true);
  | 
        
        
           | 50 | 
           cycrow | 
           482 | 
           	_changed();
  | 
        
        
           | 1 | 
           cycrow | 
           483 | 
           }
  | 
        
        
            | 
            | 
           484 | 
              | 
        
        
            | 
            | 
           485 | 
              | 
        
        
           | 13 | 
           cycrow | 
           486 | 
           bool CSpkFile::IsMatchingMod(const Utils::String &mod) const
  | 
        
        
           | 1 | 
           cycrow | 
           487 | 
           {
  | 
        
        
            | 
            | 
           488 | 
           	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
  | 
        
        
            | 
            | 
           489 | 
           	{
  | 
        
        
            | 
            | 
           490 | 
           		C_File *file = node->Data();
  | 
        
        
            | 
            | 
           491 | 
           		if ( file->GetFileType() != FILETYPE_MOD )
  | 
        
        
            | 
            | 
           492 | 
           			continue;
  | 
        
        
            | 
            | 
           493 | 
              | 
        
        
            | 
            | 
           494 | 
           		if ( file->IsFakePatch() )
  | 
        
        
            | 
            | 
           495 | 
           			continue;
  | 
        
        
            | 
            | 
           496 | 
              | 
        
        
           | 10 | 
           cycrow | 
           497 | 
           		Utils::String filename = file->GetBaseName().ToString();
  | 
        
        
            | 
            | 
           498 | 
           		if ( filename.Compare(mod) )
  | 
        
        
           | 1 | 
           cycrow | 
           499 | 
           			return true;
  | 
        
        
            | 
            | 
           500 | 
           	}
  | 
        
        
            | 
            | 
           501 | 
           	return false;
  | 
        
        
            | 
            | 
           502 | 
           }
  | 
        
        
            | 
            | 
           503 | 
              | 
        
        
           | 13 | 
           cycrow | 
           504 | 
           Utils::String CSpkFile::GetScriptTypeString(int lang) const
  | 
        
        
           | 1 | 
           cycrow | 
           505 | 
           {
  | 
        
        
            | 
            | 
           506 | 
           	int iType = m_iScriptType;
  | 
        
        
            | 
            | 
           507 | 
              | 
        
        
            | 
            | 
           508 | 
           	if ( this->IsLibrary() )
  | 
        
        
            | 
            | 
           509 | 
           		return "Library";
  | 
        
        
            | 
            | 
           510 | 
           	else if ( this->IsPackageUpdate() )
  | 
        
        
            | 
            | 
           511 | 
           		return "Package Update";
  | 
        
        
            | 
            | 
           512 | 
           	else if ( this->IsCustomStart() )
  | 
        
        
            | 
            | 
           513 | 
           		return "Custom Start";
  | 
        
        
            | 
            | 
           514 | 
           	else if ( this->IsPatch() )
  | 
        
        
            | 
            | 
           515 | 
           		return "Patch";
  | 
        
        
            | 
            | 
           516 | 
           	else if ( m_iScriptType == SCRIPTTYPE_CUSTOM )
  | 
        
        
            | 
            | 
           517 | 
           	{
  | 
        
        
           | 10 | 
           cycrow | 
           518 | 
           		Utils::String type = this->GetCustomScriptType(lang);
  | 
        
        
            | 
            | 
           519 | 
           		if ( !type.empty() )
  | 
        
        
           | 1 | 
           cycrow | 
           520 | 
           			return type;
  | 
        
        
            | 
            | 
           521 | 
           		iType = -1;
  | 
        
        
            | 
            | 
           522 | 
           	}
  | 
        
        
            | 
            | 
           523 | 
              | 
        
        
            | 
            | 
           524 | 
           	if (iType == -1)  // no script type
  | 
        
        
            | 
            | 
           525 | 
           	{
  | 
        
        
            | 
            | 
           526 | 
           		if ( this->IsFakePatch() )
  | 
        
        
            | 
            | 
           527 | 
           			return "Fake Patch";
  | 
        
        
            | 
            | 
           528 | 
           	}
  | 
        
        
            | 
            | 
           529 | 
              | 
        
        
           | 10 | 
           cycrow | 
           530 | 
           	Utils::String sType = CSpkFile::GetScriptTypeStringStatic(m_iScriptType);
  | 
        
        
           | 1 | 
           cycrow | 
           531 | 
              | 
        
        
           | 10 | 
           cycrow | 
           532 | 
           	if ( sType.empty() )
  | 
        
        
           | 1 | 
           cycrow | 
           533 | 
           		return "Other";
  | 
        
        
            | 
            | 
           534 | 
              | 
        
        
            | 
            | 
           535 | 
           	return sType;	
  | 
        
        
            | 
            | 
           536 | 
           }
  | 
        
        
            | 
            | 
           537 | 
              | 
        
        
           | 10 | 
           cycrow | 
           538 | 
           int CSpkFile::ConvertScriptType(const Utils::String &sType)
  | 
        
        
           | 1 | 
           cycrow | 
           539 | 
           {
  | 
        
        
            | 
            | 
           540 | 
           	for ( int i = 0; i < SCRIPTTYPE_MAX; i++ )
  | 
        
        
            | 
            | 
           541 | 
           	{
  | 
        
        
            | 
            | 
           542 | 
           		if ( sType.Compare(CSpkFile::GetScriptTypeStringStatic(i)) )
  | 
        
        
            | 
            | 
           543 | 
           			return i;
  | 
        
        
            | 
            | 
           544 | 
           	}
  | 
        
        
            | 
            | 
           545 | 
              | 
        
        
            | 
            | 
           546 | 
           	return -1;
  | 
        
        
            | 
            | 
           547 | 
           }
  | 
        
        
            | 
            | 
           548 | 
              | 
        
        
           | 10 | 
           cycrow | 
           549 | 
           Utils::String CSpkFile::GetScriptTypeStringStatic(int type)
  | 
        
        
           | 1 | 
           cycrow | 
           550 | 
           {
  | 
        
        
            | 
            | 
           551 | 
           	switch ( type )
  | 
        
        
            | 
            | 
           552 | 
           	{
  | 
        
        
            | 
            | 
           553 | 
           		case SCRIPTTYPE_CUSTOM:
  | 
        
        
            | 
            | 
           554 | 
           			return "Custom";
  | 
        
        
            | 
            | 
           555 | 
           		case SCRIPTTYPE_NAVIGATION:
  | 
        
        
            | 
            | 
           556 | 
           			return "Navigation";
  | 
        
        
            | 
            | 
           557 | 
           		case SCRIPTTYPE_COMBAT:
  | 
        
        
            | 
            | 
           558 | 
           			return "Combat";
  | 
        
        
            | 
            | 
           559 | 
           		case SCRIPTTYPE_MISSION:
  | 
        
        
            | 
            | 
           560 | 
           			return "Mission";
  | 
        
        
            | 
            | 
           561 | 
           		case SCRIPTTYPE_ALPLUGIN:
  | 
        
        
            | 
            | 
           562 | 
           			return "AL Plugin";
  | 
        
        
            | 
            | 
           563 | 
           		case SCRIPTTYPE_HOTKEY:
  | 
        
        
            | 
            | 
           564 | 
           			return "Hotkey";
  | 
        
        
            | 
            | 
           565 | 
           		case SCRIPTTYPE_SHIPUPGRADE:
  | 
        
        
            | 
            | 
           566 | 
           			return "Ship Upgrade";
  | 
        
        
            | 
            | 
           567 | 
           		case SCRIPTTYPE_SHIPCOMMAND:
  | 
        
        
            | 
            | 
           568 | 
           			return "Ship Command";
  | 
        
        
            | 
            | 
           569 | 
           		case SCRIPTTYPE_STATIONCOMMAND:
  | 
        
        
            | 
            | 
           570 | 
           			return "Station Command";
  | 
        
        
            | 
            | 
           571 | 
           		case SCRIPTTYPE_FLEET:
  | 
        
        
            | 
            | 
           572 | 
           			return "Fleet Management";
  | 
        
        
            | 
            | 
           573 | 
           		case SCRIPTTYPE_TRADE:
  | 
        
        
            | 
            | 
           574 | 
           			return "Trade";
  | 
        
        
            | 
            | 
           575 | 
           		case SCRIPTTYPE_PIRACY:
  | 
        
        
            | 
            | 
           576 | 
           			return "Piracy";
  | 
        
        
            | 
            | 
           577 | 
           		case SCRIPTTYPE_CHEAT:
  | 
        
        
            | 
            | 
           578 | 
           			return "Cheat";
  | 
        
        
            | 
            | 
           579 | 
           		case SCRIPTTYPE_EXTENSION:
  | 
        
        
            | 
            | 
           580 | 
           			return "Extension Mods";
  | 
        
        
            | 
            | 
           581 | 
           		case SCRIPTTYPE_REBALANCE:
  | 
        
        
            | 
            | 
           582 | 
           			return "Rebalance";
  | 
        
        
            | 
            | 
           583 | 
           		case SCRIPTTYPE_FIX:
  | 
        
        
            | 
            | 
           584 | 
           			return "Vanilla Fix";
  | 
        
        
            | 
            | 
           585 | 
           		case SCRIPTTYPE_GENERALMOD:
  | 
        
        
            | 
            | 
           586 | 
           			return "General Mod";
  | 
        
        
            | 
            | 
           587 | 
           		case SCRIPTTYPE_TOTAL:
  | 
        
        
            | 
            | 
           588 | 
           			return "Totel Conversion";
  | 
        
        
            | 
            | 
           589 | 
           		case SCRIPTTYPE_WINGCOMMAND:
  | 
        
        
            | 
            | 
           590 | 
           			return "Wing Command";
  | 
        
        
            | 
            | 
           591 | 
           	}
  | 
        
        
            | 
            | 
           592 | 
              | 
        
        
            | 
            | 
           593 | 
           	return "Other";
  | 
        
        
            | 
            | 
           594 | 
           }
  | 
        
        
            | 
            | 
           595 | 
              | 
        
        
           | 134 | 
           cycrow | 
           596 | 
           bool CSpkFile::LoadPackageData(const Utils::String &sFirst, const Utils::String &sRest, const Utils::String &sMainGame, Utils::CStringList &otherGames, Utils::CStringList &gameAddons, CProgressInfo *progress)
  | 
        
        
           | 1 | 
           cycrow | 
           597 | 
           {
  | 
        
        
           | 14 | 
           cycrow | 
           598 | 
           	if ( sFirst.Compare("ScriptType") )
  | 
        
        
           | 1 | 
           cycrow | 
           599 | 
           	{
  | 
        
        
           | 14 | 
           cycrow | 
           600 | 
           		if ( sRest.Compare("Library") || sRest.Compare("Library Script") )
  | 
        
        
           | 1 | 
           cycrow | 
           601 | 
           			this->SetLibrary();
  | 
        
        
           | 14 | 
           cycrow | 
           602 | 
           		else if ( sRest.Compare("Update") || sRest.Compare("Package Update") || sRest.Compare("Mod Update") )
  | 
        
        
           | 1 | 
           cycrow | 
           603 | 
           			this->SetPackageUpdate();
  | 
        
        
           | 14 | 
           cycrow | 
           604 | 
           		else if ( sRest.Compare("Start") || sRest.Compare("Custom Start") )
  | 
        
        
           | 1 | 
           cycrow | 
           605 | 
           			this->SetCustomStart();
  | 
        
        
           | 14 | 
           cycrow | 
           606 | 
           		else if ( sRest.Compare("Patch") || sRest.Compare("Patch Mod") )
  | 
        
        
           | 1 | 
           cycrow | 
           607 | 
           			this->SetPatch();
  | 
        
        
            | 
            | 
           608 | 
           		else
  | 
        
        
            | 
            | 
           609 | 
           		{
  | 
        
        
           | 14 | 
           cycrow | 
           610 | 
           			int check = sRest;
  | 
        
        
            | 
            | 
           611 | 
           			if ( check || sRest == "0" )
  | 
        
        
           | 1 | 
           cycrow | 
           612 | 
           				m_iScriptType = check;
  | 
        
        
            | 
            | 
           613 | 
           			else
  | 
        
        
            | 
            | 
           614 | 
           			{
  | 
        
        
           | 14 | 
           cycrow | 
           615 | 
           				m_iScriptType = CSpkFile::ConvertScriptType(sRest);
  | 
        
        
           | 1 | 
           cycrow | 
           616 | 
           				if ( m_iScriptType == -1 )
  | 
        
        
           | 14 | 
           cycrow | 
           617 | 
           					m_sScriptType = sRest;
  | 
        
        
           | 1 | 
           cycrow | 
           618 | 
           			}
  | 
        
        
            | 
            | 
           619 | 
           		}
  | 
        
        
            | 
            | 
           620 | 
           	}
  | 
        
        
           | 14 | 
           cycrow | 
           621 | 
           	else if ( sFirst.Compare("AnotherMod") )
  | 
        
        
           | 1 | 
           cycrow | 
           622 | 
           	{
  | 
        
        
           | 14 | 
           cycrow | 
           623 | 
           		m_sOtherName = sRest.token("|", 1);
  | 
        
        
            | 
            | 
           624 | 
           		m_sOtherAuthor = sRest.tokens("|", 2);
  | 
        
        
           | 1 | 
           cycrow | 
           625 | 
           	}
  | 
        
        
           | 14 | 
           cycrow | 
           626 | 
           	else if ( sFirst.Compare("WareName") || sFirst.Compare("WareDesc") )
  | 
        
        
           | 1 | 
           cycrow | 
           627 | 
           	{
  | 
        
        
            | 
            | 
           628 | 
           		// find the ware to use
  | 
        
        
            | 
            | 
           629 | 
           		SWares *useWare = m_pLastWare;
  | 
        
        
           | 14 | 
           cycrow | 
           630 | 
           		Utils::String id = sRest.token(" ", 1);
  | 
        
        
           | 1 | 
           cycrow | 
           631 | 
           		for ( CListNode<SWares> *wNode = m_lWares.Front(); wNode; wNode = wNode->next() )
  | 
        
        
            | 
            | 
           632 | 
           		{
  | 
        
        
           | 10 | 
           cycrow | 
           633 | 
           			if ( wNode->Data()->sID.Compare(id.c_str()) )
  | 
        
        
           | 1 | 
           cycrow | 
           634 | 
           			{
  | 
        
        
            | 
            | 
           635 | 
           				useWare = wNode->Data();
  | 
        
        
            | 
            | 
           636 | 
           				break;
  | 
        
        
            | 
            | 
           637 | 
           			}
  | 
        
        
            | 
            | 
           638 | 
           		}
  | 
        
        
            | 
            | 
           639 | 
              | 
        
        
            | 
            | 
           640 | 
           		// check if we have the id already
  | 
        
        
            | 
            | 
           641 | 
           		if ( useWare )
  | 
        
        
            | 
            | 
           642 | 
           		{
  | 
        
        
           | 14 | 
           cycrow | 
           643 | 
           			int lang = sRest.token(" ", 2);
  | 
        
        
           | 1 | 
           cycrow | 
           644 | 
           			SWaresText *wt = NULL;
  | 
        
        
            | 
            | 
           645 | 
           			for ( CListNode<SWaresText> *tNode = useWare->lText.Front(); tNode; tNode = tNode->next() )
  | 
        
        
            | 
            | 
           646 | 
           			{
  | 
        
        
            | 
            | 
           647 | 
           				if ( tNode->Data()->iLang == lang )
  | 
        
        
            | 
            | 
           648 | 
           				{
  | 
        
        
            | 
            | 
           649 | 
           					wt = tNode->Data();
  | 
        
        
            | 
            | 
           650 | 
           					break;
  | 
        
        
            | 
            | 
           651 | 
           				}
  | 
        
        
            | 
            | 
           652 | 
           			}
  | 
        
        
            | 
            | 
           653 | 
              | 
        
        
            | 
            | 
           654 | 
           			if ( !wt )
  | 
        
        
            | 
            | 
           655 | 
           			{
  | 
        
        
            | 
            | 
           656 | 
           				wt = new SWaresText;
  | 
        
        
            | 
            | 
           657 | 
           				wt->iLang = lang;
  | 
        
        
            | 
            | 
           658 | 
           				useWare->lText.push_back(wt);
  | 
        
        
            | 
            | 
           659 | 
           			}
  | 
        
        
            | 
            | 
           660 | 
              | 
        
        
           | 14 | 
           cycrow | 
           661 | 
           			if ( sFirst.Compare("WareName") )
  | 
        
        
            | 
            | 
           662 | 
           				wt->sName = sRest.tokens(" ", 3);
  | 
        
        
           | 1 | 
           cycrow | 
           663 | 
           			else
  | 
        
        
           | 14 | 
           cycrow | 
           664 | 
           				wt->sDesc = sRest.tokens(" ", 3);
  | 
        
        
           | 1 | 
           cycrow | 
           665 | 
           		}
  | 
        
        
            | 
            | 
           666 | 
           	}
  | 
        
        
           | 14 | 
           cycrow | 
           667 | 
           	else if ( sFirst.left(4).Compare("Ware") )
  | 
        
        
           | 1 | 
           cycrow | 
           668 | 
           	{
  | 
        
        
            | 
            | 
           669 | 
           		SWares *ware = new SWares;
  | 
        
        
            | 
            | 
           670 | 
           		ware->iTextID = -1;
  | 
        
        
            | 
            | 
           671 | 
           		ware->iTextPage = 0;
  | 
        
        
           | 14 | 
           cycrow | 
           672 | 
           		ware->cType = sFirst[4];
  | 
        
        
            | 
            | 
           673 | 
           		ware->iPrice = sRest.token(" ", 2);
  | 
        
        
            | 
            | 
           674 | 
           		ware->iSize = sRest.token(" ", 3);
  | 
        
        
            | 
            | 
           675 | 
           		ware->iVolumn = sRest.token(" ", 4);
  | 
        
        
            | 
            | 
           676 | 
           		ware->sID = sRest.token(" ", 1);
  | 
        
        
            | 
            | 
           677 | 
           		ware->iNotority = sRest.token(" ", 5);
  | 
        
        
            | 
            | 
           678 | 
           		if ( !sRest.token(" ", 6).empty() )
  | 
        
        
           | 1 | 
           cycrow | 
           679 | 
           		{
  | 
        
        
           | 14 | 
           cycrow | 
           680 | 
           			ware->iTextID = sRest.token(" ", 6).token(",", 2);
  | 
        
        
            | 
            | 
           681 | 
           			ware->iTextPage = sRest.token(" ", 6).token(",", 1);
  | 
        
        
           | 1 | 
           cycrow | 
           682 | 
           		}
  | 
        
        
            | 
            | 
           683 | 
           		m_lWares.push_back ( ware );
  | 
        
        
            | 
            | 
           684 | 
           		m_pLastWare = ware;
  | 
        
        
            | 
            | 
           685 | 
           	}
  | 
        
        
            | 
            | 
           686 | 
              | 
        
        
           | 134 | 
           cycrow | 
           687 | 
           	else if ( CBaseFile::LoadPackageData(sFirst, sRest, sMainGame, otherGames, gameAddons, progress) )
  | 
        
        
           | 1 | 
           cycrow | 
           688 | 
           		return true;
  | 
        
        
            | 
            | 
           689 | 
           	else
  | 
        
        
            | 
            | 
           690 | 
           		return false;
  | 
        
        
            | 
            | 
           691 | 
              | 
        
        
            | 
            | 
           692 | 
           	return true;
  | 
        
        
            | 
            | 
           693 | 
           }
  | 
        
        
            | 
            | 
           694 | 
              | 
        
        
           | 127 | 
           cycrow | 
           695 | 
           bool CSpkFile::GeneratePackagerScript(bool wildcard, Utils::CStringList *list, int game, const Utils::CStringList &gameAddons, bool datafile)
  | 
        
        
           | 1 | 
           cycrow | 
           696 | 
           {
  | 
        
        
           | 127 | 
           cycrow | 
           697 | 
           	if ( !CBaseFile::GeneratePackagerScript(wildcard, list, game, gameAddons, datafile) )
  | 
        
        
           | 1 | 
           cycrow | 
           698 | 
           		return false;
  | 
        
        
            | 
            | 
           699 | 
              | 
        
        
           | 126 | 
           cycrow | 
           700 | 
           	list->pushBack("# File Type, Script or Ship");
  | 
        
        
            | 
            | 
           701 | 
           	list->pushBack("FileType: Script");
  | 
        
        
            | 
            | 
           702 | 
           	list->pushBack("");
  | 
        
        
           | 98 | 
           cycrow | 
           703 | 
              | 
        
        
           | 126 | 
           cycrow | 
           704 | 
           	list->pushBack("# Script Type, the type of package file, some are special types, others are just for show");
  | 
        
        
           | 1 | 
           cycrow | 
           705 | 
           	if ( this->IsLibrary() )
  | 
        
        
           | 126 | 
           cycrow | 
           706 | 
           		list->pushBack("ScriptType: Library");
  | 
        
        
           | 1 | 
           cycrow | 
           707 | 
           	else if ( this->IsPackageUpdate() )
  | 
        
        
           | 126 | 
           cycrow | 
           708 | 
           		list->pushBack("ScriptType: Package Update");
  | 
        
        
           | 1 | 
           cycrow | 
           709 | 
           	else if ( this->IsCustomStart() )
  | 
        
        
           | 126 | 
           cycrow | 
           710 | 
           		list->pushBack("ScriptType: Custom Start");
  | 
        
        
           | 1 | 
           cycrow | 
           711 | 
           	else if ( this->IsPatch() )
  | 
        
        
           | 126 | 
           cycrow | 
           712 | 
           		list->pushBack("ScriptType: Patch");
  | 
        
        
           | 1 | 
           cycrow | 
           713 | 
           	else
  | 
        
        
           | 126 | 
           cycrow | 
           714 | 
           		list->pushBack("ScriptType: " + this->GetScriptTypeString(44));
  | 
        
        
            | 
            | 
           715 | 
           	list->pushBack("");
  | 
        
        
           | 1 | 
           cycrow | 
           716 | 
              | 
        
        
            | 
            | 
           717 | 
           	if ( this->IsAnotherMod() )
  | 
        
        
            | 
            | 
           718 | 
           	{
  | 
        
        
           | 126 | 
           cycrow | 
           719 | 
           		list->pushBack("# For another mod/package, this is a child package");
  | 
        
        
            | 
            | 
           720 | 
           		list->pushBack("AnotherMod: " + m_sOtherName + "|" + m_sOtherAuthor);
  | 
        
        
            | 
            | 
           721 | 
           		list->pushBack("");
  | 
        
        
           | 1 | 
           cycrow | 
           722 | 
           	}
  | 
        
        
            | 
            | 
           723 | 
              | 
        
        
            | 
            | 
           724 | 
           	if ( !m_lWares.empty() )
  | 
        
        
            | 
            | 
           725 | 
           	{
  | 
        
        
           | 126 | 
           cycrow | 
           726 | 
           		list->pushBack("# Custom Wares, Ware<type>: <id> <price> <size> <volumn> <notority>");
  | 
        
        
           | 1 | 
           cycrow | 
           727 | 
           		for ( CListNode<SWares> *node = m_lWares.Front(); node; node = node->next() )
  | 
        
        
            | 
            | 
           728 | 
           		{
  | 
        
        
            | 
            | 
           729 | 
           			SWares *w = node->Data();
  | 
        
        
            | 
            | 
           730 | 
           			if ( w->iTextID > 0 )
  | 
        
        
           | 126 | 
           cycrow | 
           731 | 
           				list->pushBack(Utils::String("Ware") + (char)w->cType + ": " + w->sID + " " + (long)w->iPrice + " " + (long)w->iSize + " " + (long)w->iVolumn + " " + (long)w->iNotority + " " + (long)w->iTextPage + "," + (long)w->iTextID);
  | 
        
        
           | 1 | 
           cycrow | 
           732 | 
           			else
  | 
        
        
           | 126 | 
           cycrow | 
           733 | 
           				list->pushBack(Utils::String("Ware") + (char)w->cType + ": " + w->sID + " " + (long)w->iPrice + " " + (long)w->iSize + " " + (long)w->iVolumn + " " + (long)w->iNotority);
  | 
        
        
           | 1 | 
           cycrow | 
           734 | 
           			for ( CListNode<SWaresText> *wNode = w->lText.Front(); wNode; wNode = wNode->next() )
  | 
        
        
            | 
            | 
           735 | 
           			{
  | 
        
        
            | 
            | 
           736 | 
           				SWaresText *wt = wNode->Data();
  | 
        
        
           | 10 | 
           cycrow | 
           737 | 
           				if ( !wt->sName.empty() )
  | 
        
        
           | 126 | 
           cycrow | 
           738 | 
           					list->pushBack("WareName: " + w->sID + " " + (long)wt->iLang + " " + wt->sName);
  | 
        
        
           | 10 | 
           cycrow | 
           739 | 
           				if ( !wt->sDesc.empty() )
  | 
        
        
           | 126 | 
           cycrow | 
           740 | 
           					list->pushBack("WareDesc: " + w->sID + " " + (long)wt->iLang + " " + wt->sDesc);
  | 
        
        
           | 1 | 
           cycrow | 
           741 | 
           			}
  | 
        
        
           | 126 | 
           cycrow | 
           742 | 
           			list->pushBack("");
  | 
        
        
           | 1 | 
           cycrow | 
           743 | 
           		}
  | 
        
        
            | 
            | 
           744 | 
           	}
  | 
        
        
            | 
            | 
           745 | 
              | 
        
        
            | 
            | 
           746 | 
           	if ( !datafile )
  | 
        
        
            | 
            | 
           747 | 
           	{
  | 
        
        
           | 127 | 
           cycrow | 
           748 | 
           		if ( !CBaseFile::GeneratePackagerScriptFile(wildcard, list, game, gameAddons) )
  | 
        
        
           | 1 | 
           cycrow | 
           749 | 
           			return false;
  | 
        
        
            | 
            | 
           750 | 
           	}
  | 
        
        
            | 
            | 
           751 | 
              | 
        
        
            | 
            | 
           752 | 
           	return true;
  | 
        
        
            | 
            | 
           753 | 
              | 
        
        
            | 
            | 
           754 | 
           }
  | 
        
        
            | 
            | 
           755 | 
              | 
        
        
           | 10 | 
           cycrow | 
           756 | 
           Utils::String CSpkFile::GetWareText(SWares *w, int lang)
  | 
        
        
           | 1 | 
           cycrow | 
           757 | 
           {
  | 
        
        
            | 
            | 
           758 | 
           	// return the text page if being used
  | 
        
        
            | 
            | 
           759 | 
           	if ( w->iTextID > 0 && w->iTextPage > 0 )
  | 
        
        
           | 10 | 
           cycrow | 
           760 | 
           		return Utils::String("{") + (long)w->iTextPage + "," + (long)w->iTextID + "}";
  | 
        
        
           | 1 | 
           cycrow | 
           761 | 
              | 
        
        
           | 10 | 
           cycrow | 
           762 | 
           	Utils::String name;
  | 
        
        
           | 1 | 
           cycrow | 
           763 | 
           	for ( CListNode<SWaresText> *wt = w->lText.Front(); wt; wt = wt->next() )
  | 
        
        
            | 
            | 
           764 | 
           	{
  | 
        
        
           | 10 | 
           cycrow | 
           765 | 
           		if ( wt->Data()->sName.empty() )
  | 
        
        
           | 1 | 
           cycrow | 
           766 | 
           			continue;
  | 
        
        
            | 
            | 
           767 | 
           		if ( wt->Data()->iLang == lang )
  | 
        
        
            | 
            | 
           768 | 
           			name = wt->Data()->sName;
  | 
        
        
           | 10 | 
           cycrow | 
           769 | 
           		else if ( name.empty() && wt->Data()->iLang == 44 )
  | 
        
        
           | 1 | 
           cycrow | 
           770 | 
           			name = wt->Data()->sName;
  | 
        
        
           | 10 | 
           cycrow | 
           771 | 
           		else if ( name.empty() )
  | 
        
        
           | 1 | 
           cycrow | 
           772 | 
           			name = wt->Data()->sName;
  | 
        
        
            | 
            | 
           773 | 
           	}
  | 
        
        
            | 
            | 
           774 | 
              | 
        
        
            | 
            | 
           775 | 
           	return name;
  | 
        
        
            | 
            | 
           776 | 
           }
  | 
        
        
           | 10 | 
           cycrow | 
           777 | 
           Utils::String CSpkFile::GetWareDesc(SWares *w, int lang)
  | 
        
        
           | 1 | 
           cycrow | 
           778 | 
           {
  | 
        
        
            | 
            | 
           779 | 
           	// return the text page if being used
  | 
        
        
            | 
            | 
           780 | 
           	if ( w->iTextID > 0 && w->iTextPage > 0 )
  | 
        
        
           | 10 | 
           cycrow | 
           781 | 
           		return Utils::String("{") + (long)w->iTextPage + "," + ((long)w->iTextID + 1) + "}";
  | 
        
        
           | 1 | 
           cycrow | 
           782 | 
              | 
        
        
           | 10 | 
           cycrow | 
           783 | 
           	Utils::String name;
  | 
        
        
           | 1 | 
           cycrow | 
           784 | 
           	for ( CListNode<SWaresText> *wt = w->lText.Front(); wt; wt = wt->next() )
  | 
        
        
            | 
            | 
           785 | 
           	{
  | 
        
        
           | 10 | 
           cycrow | 
           786 | 
           		if ( wt->Data()->sDesc.empty() )
  | 
        
        
           | 1 | 
           cycrow | 
           787 | 
           			continue;
  | 
        
        
            | 
            | 
           788 | 
              | 
        
        
            | 
            | 
           789 | 
           		if ( wt->Data()->iLang == lang )
  | 
        
        
            | 
            | 
           790 | 
           			name = wt->Data()->sDesc;
  | 
        
        
           | 10 | 
           cycrow | 
           791 | 
           		else if ( name.empty() && wt->Data()->iLang == 44 )
  | 
        
        
           | 1 | 
           cycrow | 
           792 | 
           			name = wt->Data()->sDesc;
  | 
        
        
           | 10 | 
           cycrow | 
           793 | 
           		else if ( name.empty() )
  | 
        
        
           | 1 | 
           cycrow | 
           794 | 
           			name = wt->Data()->sDesc;
  | 
        
        
            | 
            | 
           795 | 
           	}
  | 
        
        
            | 
            | 
           796 | 
              | 
        
        
            | 
            | 
           797 | 
           	return name;
  | 
        
        
            | 
            | 
           798 | 
           }
  | 
        
        
            | 
            | 
           799 | 
              | 
        
        
           | 13 | 
           cycrow | 
           800 | 
           Utils::String CSpkFile::GetCustomStartName() const
  | 
        
        
           | 1 | 
           cycrow | 
           801 | 
           {
  | 
        
        
            | 
            | 
           802 | 
           	if ( !this->IsCustomStart() )
  | 
        
        
           | 10 | 
           cycrow | 
           803 | 
           		return "";
  | 
        
        
           | 1 | 
           cycrow | 
           804 | 
              | 
        
        
            | 
            | 
           805 | 
           	// else find the custom start script
  | 
        
        
            | 
            | 
           806 | 
           	C_File *file = NULL;
  | 
        
        
            | 
            | 
           807 | 
           	for ( file = this->GetFirstFile(FILETYPE_SCRIPT); file; file = this->GetNextFile(file) )
  | 
        
        
            | 
            | 
           808 | 
           	{
  | 
        
        
           | 158 | 
           cycrow | 
           809 | 
           		if ( file->filename().contains("initplayership") && file->filename().token(".", 1).Compare("galaxy") )
  | 
        
        
           | 1 | 
           cycrow | 
           810 | 
           			break;
  | 
        
        
            | 
            | 
           811 | 
           	}
  | 
        
        
            | 
            | 
           812 | 
              | 
        
        
            | 
            | 
           813 | 
           	if ( !file )
  | 
        
        
           | 10 | 
           cycrow | 
           814 | 
           		return "";
  | 
        
        
           | 1 | 
           cycrow | 
           815 | 
              | 
        
        
           | 158 | 
           cycrow | 
           816 | 
           	return file->filename().token(".", 2);
  | 
        
        
           | 1 | 
           cycrow | 
           817 | 
           }
  | 
        
        
            | 
            | 
           818 | 
              | 
        
        
            | 
            | 
           819 | 
           void CSpkFile::MergePackage(CBaseFile *base)
  | 
        
        
            | 
            | 
           820 | 
           {
  | 
        
        
            | 
            | 
           821 | 
           	// update possible changes
  | 
        
        
            | 
            | 
           822 | 
           	if ( base->GetType() == TYPE_SPK )
  | 
        
        
            | 
            | 
           823 | 
           	{
  | 
        
        
            | 
            | 
           824 | 
           		CSpkFile *spk = (CSpkFile *)base;
  | 
        
        
            | 
            | 
           825 | 
           		m_bForceProfile = spk->IsForceProfile();
  | 
        
        
            | 
            | 
           826 | 
              | 
        
        
            | 
            | 
           827 | 
           		// add any new wares
  | 
        
        
            | 
            | 
           828 | 
           		if ( spk->AnyWares() )
  | 
        
        
            | 
            | 
           829 | 
           		{
  | 
        
        
            | 
            | 
           830 | 
           			for ( CListNode<SWares> *node = spk->GetWaresList()->Front(); node; node = node->next() )
  | 
        
        
            | 
            | 
           831 | 
           				this->AddWare(node->Data());
  | 
        
        
            | 
            | 
           832 | 
           			spk->GetWaresList()->clear(); // remove wares so they aren't deleted
  | 
        
        
            | 
            | 
           833 | 
           		}
  | 
        
        
            | 
            | 
           834 | 
              | 
        
        
            | 
            | 
           835 | 
           		// add any settings
  | 
        
        
            | 
            | 
           836 | 
           		if ( spk->AnySettings() )
  | 
        
        
            | 
            | 
           837 | 
           		{
  | 
        
        
            | 
            | 
           838 | 
           			for ( CListNode<SSettingType> *node = spk->GetSettingsList()->Front(); node; node = node->next() )
  | 
        
        
            | 
            | 
           839 | 
           				this->AddSetting(node->Data()->sKey, node->Data()->iType);
  | 
        
        
            | 
            | 
           840 | 
           		}
  | 
        
        
            | 
            | 
           841 | 
              | 
        
        
           | 10 | 
           cycrow | 
           842 | 
           		if ( !spk->GetOtherName().empty() )
  | 
        
        
           | 1 | 
           cycrow | 
           843 | 
           		{
  | 
        
        
            | 
            | 
           844 | 
           			m_sOtherName = spk->GetOtherName();
  | 
        
        
            | 
            | 
           845 | 
           			m_sOtherAuthor = spk->GetOtherAuthor();
  | 
        
        
            | 
            | 
           846 | 
           		}
  | 
        
        
            | 
            | 
           847 | 
           	}
  | 
        
        
            | 
            | 
           848 | 
              | 
        
        
            | 
            | 
           849 | 
           	// copy settings from base class
  | 
        
        
           | 46 | 
           cycrow | 
           850 | 
           	_merge(base);
  | 
        
        
           | 1 | 
           cycrow | 
           851 | 
              | 
        
        
            | 
            | 
           852 | 
           	for ( CListNode<SGameCompat> *gNode = base->GetGameCompatabilityList()->Front(); gNode; gNode = gNode->next() ) {
  | 
        
        
           | 46 | 
           cycrow | 
           853 | 
           		if ( !gNode->Data()->sVersion.empty() )
  | 
        
        
           | 1 | 
           cycrow | 
           854 | 
           			this->AddGameCompatability(gNode->Data()->iGame, gNode->Data()->sVersion);
  | 
        
        
            | 
            | 
           855 | 
           		else
  | 
        
        
           | 46 | 
           cycrow | 
           856 | 
           			this->AddGameCompatability(gNode->Data()->iGame, (long)gNode->Data()->iVersion);
  | 
        
        
           | 1 | 
           cycrow | 
           857 | 
           	}
  | 
        
        
            | 
            | 
           858 | 
              | 
        
        
            | 
            | 
           859 | 
           	// copy over needed librarys
  | 
        
        
            | 
            | 
           860 | 
           	for ( CListNode<SNeededLibrary> *lNode = base->GetNeededLibraries()->Front(); lNode; lNode = lNode->next() )
  | 
        
        
            | 
            | 
           861 | 
           		this->AddNeededLibrary(lNode->Data()->sName, lNode->Data()->sAuthor, lNode->Data()->sMinVersion);
  | 
        
        
            | 
            | 
           862 | 
              | 
        
        
            | 
            | 
           863 | 
           	// web mirror address, add any new ones
  | 
        
        
           | 170 | 
           cycrow | 
           864 | 
           	for(auto itr = base->webMirrors().begin(); itr != base->webMirrors().end(); itr++)
  | 
        
        
           | 162 | 
           cycrow | 
           865 | 
           		this->addWebMirror((*itr)->str);
  | 
        
        
           | 1 | 
           cycrow | 
           866 | 
              | 
        
        
            | 
            | 
           867 | 
           	// copy over package names
  | 
        
        
           | 170 | 
           cycrow | 
           868 | 
           	for(auto itr = base->namesList()->begin(); itr != base->namesList()->end(); itr++)
  | 
        
        
            | 
            | 
           869 | 
           		this->addName((*itr)->iLanguage, (*itr)->sName);
  | 
        
        
           | 1 | 
           cycrow | 
           870 | 
              | 
        
        
            | 
            | 
           871 | 
           	// finally do all the files
  | 
        
        
           | 170 | 
           cycrow | 
           872 | 
           	for ( CListNode<C_File> *node = base->fileList().Front(); node; node = node->next() )
  | 
        
        
           | 1 | 
           cycrow | 
           873 | 
           	{
  | 
        
        
            | 
            | 
           874 | 
           		C_File *f = node->Data();
  | 
        
        
            | 
            | 
           875 | 
           		// if it exists, remove the old
  | 
        
        
            | 
            | 
           876 | 
           		for ( CListNode<C_File> *thisNode = m_lFiles.Front(); thisNode; thisNode = thisNode->next() )
  | 
        
        
            | 
            | 
           877 | 
           		{
  | 
        
        
           | 158 | 
           cycrow | 
           878 | 
           			if ( thisNode->Data()->GetFileType() == f->GetFileType() && thisNode->Data()->filename().Compare(f->filename()) && thisNode->Data()->dir().Compare(f->dir()) )
  | 
        
        
           | 1 | 
           cycrow | 
           879 | 
           			{
  | 
        
        
            | 
            | 
           880 | 
           				m_lFiles.remove(thisNode);
  | 
        
        
            | 
            | 
           881 | 
           				break;
  | 
        
        
            | 
            | 
           882 | 
           			}
  | 
        
        
            | 
            | 
           883 | 
           		}
  | 
        
        
            | 
            | 
           884 | 
              | 
        
        
            | 
            | 
           885 | 
           		m_lFiles.push_back(f);
  | 
        
        
            | 
            | 
           886 | 
           	}
  | 
        
        
            | 
            | 
           887 | 
              | 
        
        
            | 
            | 
           888 | 
           	// clear the files so we dont delete them later
  | 
        
        
            | 
            | 
           889 | 
           	base->GetFileList()->clear();
  | 
        
        
            | 
            | 
           890 | 
           }
  | 
        
        
           | 7 | 
           cycrow | 
           891 | 
              | 
        
        
           | 8 | 
           cycrow | 
           892 | 
           unsigned char *CSpkFile::_convert_uncompressFile(const Utils::String &sOldFilename, int *pLen)
  | 
        
        
           | 7 | 
           cycrow | 
           893 | 
           {
  | 
        
        
           | 10 | 
           cycrow | 
           894 | 
           	// firstcheck if the file exists
  | 
        
        
            | 
            | 
           895 | 
           	FILE *id = fopen(sOldFilename.c_str(), "rb" );
  | 
        
        
            | 
            | 
           896 | 
           	if ( !id ) {
  | 
        
        
           | 50 | 
           cycrow | 
           897 | 
           		CLog::logf(CLog::Log_IO, 1, "Unable to open file: %s", sOldFilename.c_str());
  | 
        
        
           | 10 | 
           cycrow | 
           898 | 
           		return false;
  | 
        
        
            | 
            | 
           899 | 
           	}
  | 
        
        
           | 7 | 
           cycrow | 
           900 | 
              | 
        
        
           | 10 | 
           cycrow | 
           901 | 
           	// read the first 3 charaters to check if its using the original "HiP" compression
  | 
        
        
           | 14 | 
           cycrow | 
           902 | 
           	Utils::String check((char)fgetc(id));
  | 
        
        
           | 10 | 
           cycrow | 
           903 | 
           	check += (char)fgetc ( id );
  | 
        
        
            | 
            | 
           904 | 
           	check += (char)fgetc ( id );
  | 
        
        
           | 7 | 
           cycrow | 
           905 | 
              | 
        
        
           | 14 | 
           cycrow | 
           906 | 
           	Utils::String removeFile;
  | 
        
        
           | 7 | 
           cycrow | 
           907 | 
              | 
        
        
           | 10 | 
           cycrow | 
           908 | 
           	unsigned char *uncomprData = NULL;
  | 
        
        
            | 
            | 
           909 | 
           	unsigned char *data = NULL;
  | 
        
        
            | 
            | 
           910 | 
           	long len = 0, newlen = 0;
  | 
        
        
            | 
            | 
           911 | 
              | 
        
        
            | 
            | 
           912 | 
           	if ( check == "HiP" ) {
  | 
        
        
            | 
            | 
           913 | 
           		fclose ( id );
  | 
        
        
            | 
            | 
           914 | 
           		bool opened = false;
  | 
        
        
            | 
            | 
           915 | 
           		if ( DecompressFile ( (char *)sOldFilename.c_str(), "uncompr.tmp" ) ) {
  | 
        
        
            | 
            | 
           916 | 
           			removeFile = "uncompr.tmp";
  | 
        
        
            | 
            | 
           917 | 
           			id = fopen ( "uncompr.tmp", "r" );
  | 
        
        
            | 
            | 
           918 | 
           			if ( id )
  | 
        
        
            | 
            | 
           919 | 
           				opened = true;
  | 
        
        
            | 
            | 
           920 | 
           		}
  | 
        
        
            | 
            | 
           921 | 
              | 
        
        
            | 
            | 
           922 | 
           		if ( !opened ) {
  | 
        
        
           | 50 | 
           cycrow | 
           923 | 
           			CLog::log(CLog::Log_IO, 1, "Unable to uncompress file, exiting...");
  | 
        
        
           | 10 | 
           cycrow | 
           924 | 
           			return false;
  | 
        
        
            | 
            | 
           925 | 
           		}
  | 
        
        
            | 
            | 
           926 | 
              | 
        
        
           | 50 | 
           cycrow | 
           927 | 
           		CLog::log(CLog::Log_IO, 1, "* Reading file into memory...");
  | 
        
        
           | 10 | 
           cycrow | 
           928 | 
           		// get file length
  | 
        
        
            | 
            | 
           929 | 
           		fseek ( id, 0, SEEK_END );
  | 
        
        
            | 
            | 
           930 | 
           		len = ftell ( id );
  | 
        
        
            | 
            | 
           931 | 
              | 
        
        
            | 
            | 
           932 | 
           		// move back to beginning
  | 
        
        
            | 
            | 
           933 | 
           		fseek ( id, 0, SEEK_SET );
  | 
        
        
            | 
            | 
           934 | 
              | 
        
        
            | 
            | 
           935 | 
           		// read the data from file into memory
  | 
        
        
            | 
            | 
           936 | 
           		uncomprData = new unsigned char[len + 1];
  | 
        
        
            | 
            | 
           937 | 
           		fread ( uncomprData, sizeof(unsigned char), len, id );
  | 
        
        
            | 
            | 
           938 | 
              | 
        
        
            | 
            | 
           939 | 
           		newlen = len;
  | 
        
        
            | 
            | 
           940 | 
           	}
  | 
        
        
            | 
            | 
           941 | 
           	else
  | 
        
        
            | 
            | 
           942 | 
           	{
  | 
        
        
           | 50 | 
           cycrow | 
           943 | 
           		CLog::log(CLog::Log_IO, 1, "* Reading file into memory...");
  | 
        
        
           | 10 | 
           cycrow | 
           944 | 
           		// get file length
  | 
        
        
            | 
            | 
           945 | 
           		fseek ( id, 0, SEEK_END );
  | 
        
        
            | 
            | 
           946 | 
           		len = ftell ( id );
  | 
        
        
            | 
            | 
           947 | 
              | 
        
        
            | 
            | 
           948 | 
           		// move back to beginning
  | 
        
        
            | 
            | 
           949 | 
           		fseek ( id, 0, SEEK_SET );
  | 
        
        
            | 
            | 
           950 | 
              | 
        
        
            | 
            | 
           951 | 
           		// read the data from file into memory
  | 
        
        
            | 
            | 
           952 | 
           		data = new unsigned char[len + 1];
  | 
        
        
            | 
            | 
           953 | 
           		fread ( data, sizeof(unsigned char), len, id );
  | 
        
        
            | 
            | 
           954 | 
              | 
        
        
            | 
            | 
           955 | 
           		// uncompress the file (currently only 7zip compression)
  | 
        
        
           | 50 | 
           cycrow | 
           956 | 
           		CLog::log(CLog::Log_IO, 1, "* Uncompressing file...");
  | 
        
        
           | 10 | 
           cycrow | 
           957 | 
           		newlen = len;
  | 
        
        
            | 
            | 
           958 | 
           	#ifdef _INCLUDE7ZIP
  | 
        
        
            | 
            | 
           959 | 
           		uncomprData = LZMADecodeData ( data, len, newlen, progress );
  | 
        
        
            | 
            | 
           960 | 
           	#else
  | 
        
        
            | 
            | 
           961 | 
           		uncomprData = LZMADecode_C ( (unsigned char *)data, len, (size_t*)&newlen, NULL );
  | 
        
        
            | 
            | 
           962 | 
           	#endif
  | 
        
        
            | 
            | 
           963 | 
           	}
  | 
        
        
            | 
            | 
           964 | 
              | 
        
        
            | 
            | 
           965 | 
           	*pLen = newlen;
  | 
        
        
            | 
            | 
           966 | 
              | 
        
        
           | 14 | 
           cycrow | 
           967 | 
           	if ( !removeFile.empty() ) {
  | 
        
        
           | 52 | 
           cycrow | 
           968 | 
           		CFileIO::Remove(removeFile);
  | 
        
        
           | 10 | 
           cycrow | 
           969 | 
           	}
  | 
        
        
            | 
            | 
           970 | 
              | 
        
        
           | 7 | 
           cycrow | 
           971 | 
           	return uncomprData;
  | 
        
        
            | 
            | 
           972 | 
           }
  | 
        
        
            | 
            | 
           973 | 
              | 
        
        
           | 8 | 
           cycrow | 
           974 | 
           Utils::String CSpkFile::_convert_fileEndString(const Utils::String &sFile)
  | 
        
        
           | 7 | 
           cycrow | 
           975 | 
           {
  | 
        
        
           | 10 | 
           cycrow | 
           976 | 
           	if ( sFile.Compare("Text") )
  | 
        
        
            | 
            | 
           977 | 
           		return "-- End of Script --";
  | 
        
        
            | 
            | 
           978 | 
           	else if ( sFile.Compare("Uninstall") )
  | 
        
        
            | 
            | 
           979 | 
           		return "-- End of Uninstall --";
  | 
        
        
            | 
            | 
           980 | 
           	else if ( sFile.Compare("Readme") )
  | 
        
        
            | 
            | 
           981 | 
           		return "-- End of Readme --";
  | 
        
        
            | 
            | 
           982 | 
           	else if ( sFile.Compare("Map") )
  | 
        
        
            | 
            | 
           983 | 
           		return "-- End of Map --";
  | 
        
        
            | 
            | 
           984 | 
           	else if ( sFile.Compare("Mod") || sFile.Compare("Extra") || sFile.Compare("Screen") || sFile.Compare("Sound") )
  | 
        
        
            | 
            | 
           985 | 
           		return "";
  | 
        
        
            | 
            | 
           986 | 
           	return "-- End of Script --";
  | 
        
        
           | 7 | 
           cycrow | 
           987 | 
           }
  | 
        
        
            | 
            | 
           988 | 
              | 
        
        
           | 127 | 
           cycrow | 
           989 | 
           FileType CSpkFile::_convert_fileType(const Utils::String &sFile)
  | 
        
        
           | 7 | 
           cycrow | 
           990 | 
           {
  | 
        
        
           | 10 | 
           cycrow | 
           991 | 
           	if ( sFile.Compare("Text") )
  | 
        
        
            | 
            | 
           992 | 
           		return FILETYPE_TEXT;
  | 
        
        
            | 
            | 
           993 | 
           	else if ( sFile.Compare("Uninstall") )
  | 
        
        
            | 
            | 
           994 | 
           		return FILETYPE_UNINSTALL;
  | 
        
        
            | 
            | 
           995 | 
           	else if ( sFile.Compare("Readme") )
  | 
        
        
            | 
            | 
           996 | 
           		return FILETYPE_README;
  | 
        
        
            | 
            | 
           997 | 
           	else if ( sFile.Compare("Map") )
  | 
        
        
            | 
            | 
           998 | 
           		return FILETYPE_MAP;
  | 
        
        
            | 
            | 
           999 | 
           	else if ( sFile.Compare("Mod") )
  | 
        
        
            | 
            | 
           1000 | 
           		return FILETYPE_MOD;
  | 
        
        
            | 
            | 
           1001 | 
           	else if ( sFile.Compare("Extra") )
  | 
        
        
            | 
            | 
           1002 | 
           		return FILETYPE_EXTRA;
  | 
        
        
            | 
            | 
           1003 | 
           	else if ( sFile.Compare("Screen") )
  | 
        
        
            | 
            | 
           1004 | 
           		return FILETYPE_SCREEN;
  | 
        
        
            | 
            | 
           1005 | 
           	else if ( sFile.Compare("Sound") )
  | 
        
        
            | 
            | 
           1006 | 
           		return FILETYPE_SOUND;
  | 
        
        
            | 
            | 
           1007 | 
              | 
        
        
            | 
            | 
           1008 | 
           	return FILETYPE_SCRIPT;
  | 
        
        
           | 7 | 
           cycrow | 
           1009 | 
           }
  | 
        
        
            | 
            | 
           1010 | 
              | 
        
        
           | 10 | 
           cycrow | 
           1011 | 
           void CSpkFile::_convert_parse(const Utils::String &sCmd, const Utils::String &sRest)
  | 
        
        
           | 7 | 
           cycrow | 
           1012 | 
           {
  | 
        
        
           | 10 | 
           cycrow | 
           1013 | 
           	if ( sCmd == "Name:" )
  | 
        
        
            | 
            | 
           1014 | 
           	{
  | 
        
        
           | 50 | 
           cycrow | 
           1015 | 
           		this->setName ( sRest );
  | 
        
        
            | 
            | 
           1016 | 
           		CLog::logf(CLog::Log_EditPackage, 3, "\tScript Name: %s", sRest.c_str() );
  | 
        
        
           | 10 | 
           cycrow | 
           1017 | 
           	}
  | 
        
        
            | 
            | 
           1018 | 
           	else if ( sCmd == "Author:" )
  | 
        
        
            | 
            | 
           1019 | 
           	{
  | 
        
        
           | 50 | 
           cycrow | 
           1020 | 
           		this->setAuthor(sRest);
  | 
        
        
            | 
            | 
           1021 | 
           		CLog::logf(CLog::Log_EditPackage, 3, "\tScript Author: %s", sRest.c_str() );
  | 
        
        
           | 10 | 
           cycrow | 
           1022 | 
           	}
  | 
        
        
            | 
            | 
           1023 | 
           	else if ( sCmd == "CustomStart" )
  | 
        
        
            | 
            | 
           1024 | 
           	{
  | 
        
        
            | 
            | 
           1025 | 
           		this->SetCustomStart();
  | 
        
        
           | 50 | 
           cycrow | 
           1026 | 
           		CLog::logf(CLog::Log_EditPackage, 3, "\tPackage is a custom start!!" );
  | 
        
        
           | 10 | 
           cycrow | 
           1027 | 
           	}
  | 
        
        
            | 
            | 
           1028 | 
           	else if ( sCmd == "AnotherMod:" )
  | 
        
        
            | 
            | 
           1029 | 
           	{
  | 
        
        
            | 
            | 
           1030 | 
           		this->SetAnotherMod(sRest.token("|", 1), sRest.tokens("|", 2));
  | 
        
        
           | 50 | 
           cycrow | 
           1031 | 
           		CLog::logf(CLog::Log_EditPackage, 3, "\tFor another Mod, Name: %s, Author: %s", this->GetOtherName().c_str(), this->GetOtherAuthor().c_str() );
  | 
        
        
           | 10 | 
           cycrow | 
           1032 | 
           	}
  | 
        
        
            | 
            | 
           1033 | 
           	else if ( sCmd == "PATCH" )
  | 
        
        
            | 
            | 
           1034 | 
           	{
  | 
        
        
            | 
            | 
           1035 | 
           		this->SetPatch();
  | 
        
        
           | 50 | 
           cycrow | 
           1036 | 
           		CLog::logf(CLog::Log_EditPackage, 3, "\tPackage is a Patch Mod!!" );
  | 
        
        
           | 10 | 
           cycrow | 
           1037 | 
           	}
  | 
        
        
            | 
            | 
           1038 | 
           	else if ( sCmd == "Version:" )
  | 
        
        
            | 
            | 
           1039 | 
           	{
  | 
        
        
           | 50 | 
           cycrow | 
           1040 | 
           		this->setVersion(sRest);
  | 
        
        
            | 
            | 
           1041 | 
           		CLog::logf(CLog::Log_EditPackage, 3,"\tScript Version: %s", sRest.c_str() );
  | 
        
        
           | 10 | 
           cycrow | 
           1042 | 
           	}
  | 
        
        
            | 
            | 
           1043 | 
           	else if ( sCmd == "Date:" )
  | 
        
        
            | 
            | 
           1044 | 
           	{
  | 
        
        
           | 50 | 
           cycrow | 
           1045 | 
           		this->setCreationDate ( sRest );
  | 
        
        
            | 
            | 
           1046 | 
           		CLog::logf(CLog::Log_EditPackage, 3,"\tScript Creation Date: %s", sRest.c_str() );
  | 
        
        
           | 10 | 
           cycrow | 
           1047 | 
           	}
  | 
        
        
           | 48 | 
           cycrow | 
           1048 | 
           	else if ( sCmd == "Desc:" ) {
  | 
        
        
            | 
            | 
           1049 | 
           		this->setDescription(sRest.findReplace("<br>", "\n") );
  | 
        
        
           | 50 | 
           cycrow | 
           1050 | 
           		CLog::logf(CLog::Log_EditPackage, 3,"\tScript Description: %s", this->description().c_str() );
  | 
        
        
           | 10 | 
           cycrow | 
           1051 | 
           	}
  | 
        
        
           | 49 | 
           cycrow | 
           1052 | 
           	else if ( sCmd == "WebAddress:" ) {
  | 
        
        
            | 
            | 
           1053 | 
           		this->setWebAddress(sRest);
  | 
        
        
           | 50 | 
           cycrow | 
           1054 | 
           		CLog::logf(CLog::Log_EditPackage, 3, "\tWeb Address: %s", sRest.c_str() );
  | 
        
        
           | 10 | 
           cycrow | 
           1055 | 
           	}
  | 
        
        
            | 
            | 
           1056 | 
           	else if ( sCmd == "WebMirror1:" )
  | 
        
        
            | 
            | 
           1057 | 
           	{
  | 
        
        
           | 162 | 
           cycrow | 
           1058 | 
           		this->addWebMirror(sRest);
  | 
        
        
           | 50 | 
           cycrow | 
           1059 | 
           		CLog::logf(CLog::Log_EditPackage, 3, "\tWeb Mirror Address: %s", sRest.c_str() );
  | 
        
        
           | 10 | 
           cycrow | 
           1060 | 
           	}
  | 
        
        
            | 
            | 
           1061 | 
           	else if ( sCmd == "WebMirror2:" )
  | 
        
        
            | 
            | 
           1062 | 
           	{
  | 
        
        
           | 162 | 
           cycrow | 
           1063 | 
           		this->addWebMirror(sRest);
  | 
        
        
           | 50 | 
           cycrow | 
           1064 | 
           		CLog::logf(CLog::Log_EditPackage, 3, "\tWeb Mirror Address: %s", sRest.c_str() );
  | 
        
        
           | 10 | 
           cycrow | 
           1065 | 
           	}
  | 
        
        
            | 
            | 
           1066 | 
              | 
        
        
            | 
            | 
           1067 | 
           	else if ( sCmd == "ScriptType:" )
  | 
        
        
            | 
            | 
           1068 | 
           		this->SetScriptType (sRest);
  | 
        
        
           | 49 | 
           cycrow | 
           1069 | 
           	else if ( sCmd == "WebSite:" ) {
  | 
        
        
            | 
            | 
           1070 | 
           		this->setWebSite ( sRest );
  | 
        
        
           | 50 | 
           cycrow | 
           1071 | 
           		CLog::logf(CLog::Log_EditPackage, 3, "\tWeb Site: %s", sRest.c_str() );
  | 
        
        
           | 10 | 
           cycrow | 
           1072 | 
           	}
  | 
        
        
           | 49 | 
           cycrow | 
           1073 | 
           	else if ( sCmd == "Email:" ) {
  | 
        
        
            | 
            | 
           1074 | 
           		this->setEmail(sRest);
  | 
        
        
           | 50 | 
           cycrow | 
           1075 | 
           		CLog::logf(CLog::Log_EditPackage, 3, "\tAuthor Email Address: %s", sRest.c_str() );
  | 
        
        
           | 10 | 
           cycrow | 
           1076 | 
           	}
  | 
        
        
            | 
            | 
           1077 | 
           	else if ( sCmd == "GameVersion:" )
  | 
        
        
            | 
            | 
           1078 | 
           	{
  | 
        
        
            | 
            | 
           1079 | 
           		//TODO: fix this for new game version
  | 
        
        
            | 
            | 
           1080 | 
           		/*
  | 
        
        
            | 
            | 
           1081 | 
           		int version = sRest.ToInt();
  | 
        
        
            | 
            | 
           1082 | 
           		if ( version == 0 )
  | 
        
        
            | 
            | 
           1083 | 
           			this->SetGameVersion ( 1 );
  | 
        
        
            | 
            | 
           1084 | 
           		else if (version == 1 )
  | 
        
        
            | 
            | 
           1085 | 
           			this->SetGameVersion ( 0 );
  | 
        
        
            | 
            | 
           1086 | 
           		else
  | 
        
        
            | 
            | 
           1087 | 
           			this->SetGameVersion ( version );
  | 
        
        
            | 
            | 
           1088 | 
           		CLog::logf(CLog::Log_EditPackage, "\tGame Version: %d", this->GetGameVersion () );
  | 
        
        
            | 
            | 
           1089 | 
           		*/
  | 
        
        
            | 
            | 
           1090 | 
           	}
  | 
        
        
            | 
            | 
           1091 | 
              | 
        
        
            | 
            | 
           1092 | 
           	else if ( sCmd == "Ware:" )
  | 
        
        
            | 
            | 
           1093 | 
           	{
  | 
        
        
            | 
            | 
           1094 | 
           		this->AddWare ( sRest );
  | 
        
        
           | 50 | 
           cycrow | 
           1095 | 
           		CLog::logf(CLog::Log_EditPackage, 3, "\tAdding Custom Ware" );
  | 
        
        
           | 10 | 
           cycrow | 
           1096 | 
           	}
  | 
        
        
            | 
            | 
           1097 | 
           	else if ( sCmd == "WareText:" )
  | 
        
        
            | 
            | 
           1098 | 
           		this->AddWareText ( sRest );
  | 
        
        
           | 46 | 
           cycrow | 
           1099 | 
           	else if ( sCmd == "UninstallAfter:" )	this->addUninstallText(sRest.token(" ", 1).toLong(), false, sRest.tokens(" ", 2));
  | 
        
        
            | 
            | 
           1100 | 
           	else if ( sCmd == "UninstallBefore:" )	this->addUninstallText(sRest.token(" ", 1).toLong(), true, sRest.tokens(" ", 2));
  | 
        
        
            | 
            | 
           1101 | 
           	else if ( sCmd == "InstallAfter:" )		this->addInstallText(sRest.token(" ", 1).toLong(), false, sRest.tokens(" ", 2));
  | 
        
        
            | 
            | 
           1102 | 
           	else if ( sCmd == "InstallBefore:" )	this->addInstallText(sRest.token(" ", 1).toLong(), true, sRest.tokens(" ", 2));
  | 
        
        
           | 10 | 
           cycrow | 
           1103 | 
           	else if ( sCmd == "ScriptName:" )
  | 
        
        
            | 
            | 
           1104 | 
           	{
  | 
        
        
            | 
            | 
           1105 | 
           		Utils::String lang = sRest.token(":", 1);
  | 
        
        
            | 
            | 
           1106 | 
           		Utils::String name = sRest.tokens(":", 2);
  | 
        
        
           | 170 | 
           cycrow | 
           1107 | 
           		this->addName(lang.toLong(), name);
  | 
        
        
           | 50 | 
           cycrow | 
           1108 | 
           		CLog::logf(CLog::Log_EditPackage, 3, "\tScript Name Language (%s) %s", lang.c_str(), name.c_str() );
  | 
        
        
           | 10 | 
           cycrow | 
           1109 | 
           	}
  | 
        
        
           | 7 | 
           cycrow | 
           1110 | 
           }
  | 
        
        
            | 
            | 
           1111 | 
              | 
        
        
           | 8 | 
           cycrow | 
           1112 | 
           Utils::String CSpkFile::_convert_parseFilename(const Utils::String &sRest, float fVersion, Utils::String *pDir)
  | 
        
        
           | 7 | 
           cycrow | 
           1113 | 
           {
  | 
        
        
           | 8 | 
           cycrow | 
           1114 | 
           	Utils::String sFilename;
  | 
        
        
           | 7 | 
           cycrow | 
           1115 | 
              | 
        
        
           | 10 | 
           cycrow | 
           1116 | 
           	if ( fVersion >= 3.00f )
  | 
        
        
            | 
            | 
           1117 | 
           		sFilename = sRest.tokens(" ", 3);
  | 
        
        
            | 
            | 
           1118 | 
           	else if ( fVersion >= 2.00f )
  | 
        
        
            | 
            | 
           1119 | 
           		sFilename = sRest.tokens(" ", 2);
  | 
        
        
            | 
            | 
           1120 | 
           	else
  | 
        
        
            | 
            | 
           1121 | 
           		sFilename = sRest;
  | 
        
        
            | 
            | 
           1122 | 
              | 
        
        
            | 
            | 
           1123 | 
           	if ( sFilename.isin("<br>") ) {
  | 
        
        
            | 
            | 
           1124 | 
           		sFilename = sFilename.findReplace("<br>", "|");
  | 
        
        
            | 
            | 
           1125 | 
           		if ( sFilename[0] == '|' ) {
  | 
        
        
            | 
            | 
           1126 | 
           			sFilename = sFilename.token("|", 1);
  | 
        
        
            | 
            | 
           1127 | 
           		}
  | 
        
        
            | 
            | 
           1128 | 
           		else {
  | 
        
        
            | 
            | 
           1129 | 
           			*pDir = sFilename.token("|", 1);
  | 
        
        
            | 
            | 
           1130 | 
           			sFilename = sFilename.tokens("|", 2);
  | 
        
        
            | 
            | 
           1131 | 
           		}
  | 
        
        
            | 
            | 
           1132 | 
           	}
  | 
        
        
            | 
            | 
           1133 | 
              | 
        
        
            | 
            | 
           1134 | 
           	return sFilename;
  | 
        
        
           | 7 | 
           cycrow | 
           1135 | 
           }
  | 
        
        
            | 
            | 
           1136 | 
              | 
        
        
           | 10 | 
           cycrow | 
           1137 | 
           unsigned char *CSpkFile::_convert_parseFile(const Utils::String &sCmd, const Utils::String &sRest, float fVersion, unsigned char *d)
  | 
        
        
           | 7 | 
           cycrow | 
           1138 | 
           {
  | 
        
        
           | 10 | 
           cycrow | 
           1139 | 
           	bool bShared = (sCmd.left(9) == "$$$Shared") ? true : false;
  | 
        
        
            | 
            | 
           1140 | 
           	Utils::String sFile = sCmd.right(-3).left(-1);
  | 
        
        
            | 
            | 
           1141 | 
           	Utils::String sEnd = this->_convert_fileEndString(sFile);
  | 
        
        
           | 127 | 
           cycrow | 
           1142 | 
           	FileType iType = this->_convert_fileType(sFile);
  | 
        
        
           | 10 | 
           cycrow | 
           1143 | 
              | 
        
        
            | 
            | 
           1144 | 
           	// convert the filename and directory
  | 
        
        
            | 
            | 
           1145 | 
           	Utils::String dir, filename = _convert_parseFilename(sRest, fVersion, &dir);
  | 
        
        
            | 
            | 
           1146 | 
              | 
        
        
            | 
            | 
           1147 | 
           	// get the size and time
  | 
        
        
            | 
            | 
           1148 | 
           	long time = 0, size = 0;
  | 
        
        
            | 
            | 
           1149 | 
           	if ( fVersion >= 2.00f ) time = sRest.token(" ", 1).toLong();
  | 
        
        
            | 
            | 
           1150 | 
           	if ( fVersion >= 3.00f ) size = sRest.token(" ", 2).toLong();
  | 
        
        
           | 160 | 
           cycrow | 
           1151 | 
           	bool binaryRead = (CFileIO(filename).isFileExtension("PCK")) ? true : false;
  | 
        
        
           | 10 | 
           cycrow | 
           1152 | 
           	if ( sEnd.empty() ) binaryRead = true;
  | 
        
        
            | 
            | 
           1153 | 
              | 
        
        
            | 
            | 
           1154 | 
           	C_File *file = new C_File ();
  | 
        
        
            | 
            | 
           1155 | 
              | 
        
        
           | 50 | 
           cycrow | 
           1156 | 
           	if ( bShared )	CLog::logf(CLog::Log_File, 2, "\tFound %s File (Shared): %s, Reading...", sFile.c_str(), filename.c_str() );
  | 
        
        
            | 
            | 
           1157 | 
           	else			CLog::logf(CLog::Log_File, 2, "\tFound %s File: %s, Reading...", sFile.c_str(), filename.c_str() );
  | 
        
        
           | 10 | 
           cycrow | 
           1158 | 
              | 
        
        
            | 
            | 
           1159 | 
           	// read the data
  | 
        
        
            | 
            | 
           1160 | 
           	if ( binaryRead )
  | 
        
        
            | 
            | 
           1161 | 
           	{
  | 
        
        
            | 
            | 
           1162 | 
           		file->ReadFromData ( (char *)d, size );
  | 
        
        
            | 
            | 
           1163 | 
           		d += size;
  | 
        
        
            | 
            | 
           1164 | 
           	}
  | 
        
        
            | 
            | 
           1165 | 
           	else
  | 
        
        
            | 
            | 
           1166 | 
           	{
  | 
        
        
           | 14 | 
           cycrow | 
           1167 | 
           		Utils::String readData;
  | 
        
        
           | 10 | 
           cycrow | 
           1168 | 
           		d = LineByLineRead ( d, sEnd, &readData );
  | 
        
        
           | 14 | 
           cycrow | 
           1169 | 
           		file->ReadFromData ( (char *)readData.c_str(), (long)readData.length() );
  | 
        
        
           | 10 | 
           cycrow | 
           1170 | 
           	}
  | 
        
        
            | 
            | 
           1171 | 
              | 
        
        
            | 
            | 
           1172 | 
           	// setup the file
  | 
        
        
            | 
            | 
           1173 | 
           	file->SetName ( filename );
  | 
        
        
           | 127 | 
           cycrow | 
           1174 | 
           	file->setFileType(iType);
  | 
        
        
           | 10 | 
           cycrow | 
           1175 | 
           	file->SetShared ( bShared );
  | 
        
        
            | 
            | 
           1176 | 
           	file->SetCreationTime ( time );
  | 
        
        
            | 
            | 
           1177 | 
           	if ( !dir.empty() )
  | 
        
        
            | 
            | 
           1178 | 
           		file->SetDir ( dir );
  | 
        
        
            | 
            | 
           1179 | 
              | 
        
        
            | 
            | 
           1180 | 
           	this->AddFile ( file );
  | 
        
        
            | 
            | 
           1181 | 
              | 
        
        
           | 134 | 
           cycrow | 
           1182 | 
           	CLog::logf(CLog::Log_File, 3, "Size: %s", file->dataSizeString().c_str() );
  | 
        
        
           | 10 | 
           cycrow | 
           1183 | 
              | 
        
        
            | 
            | 
           1184 | 
           	return d;
  | 
        
        
           | 7 | 
           cycrow | 
           1185 | 
           }
  | 
        
        
            | 
            | 
           1186 | 
              | 
        
        
           | 9 | 
           cycrow | 
           1187 | 
           CSpkFile *CSpkFile::convertFromOld(const Utils::String &sOldFilename)
  | 
        
        
            | 
            | 
           1188 | 
           {
  | 
        
        
            | 
            | 
           1189 | 
           	// check if the old file is actually in an old format
  | 
        
        
           | 10 | 
           cycrow | 
           1190 | 
           	int ret = CBaseFile::CheckFile ( sOldFilename );
  | 
        
        
            | 
            | 
           1191 | 
           	if ( ret != SPKFILE_INVALID && ret != SPKFILE_OLD ) {
  | 
        
        
            | 
            | 
           1192 | 
           		return NULL;
  | 
        
        
            | 
            | 
           1193 | 
            	}
  | 
        
        
            | 
            | 
           1194 | 
              | 
        
        
            | 
            | 
           1195 | 
           	CSpkFile *pSpkFile = new CSpkFile();
  | 
        
        
            | 
            | 
           1196 | 
           	if ( !pSpkFile->convertOld(sOldFilename) ) {
  | 
        
        
            | 
            | 
           1197 | 
           		delete pSpkFile;
  | 
        
        
            | 
            | 
           1198 | 
           		return NULL;
  | 
        
        
            | 
            | 
           1199 | 
           	}
  | 
        
        
            | 
            | 
           1200 | 
              | 
        
        
            | 
            | 
           1201 | 
           	return pSpkFile;
  | 
        
        
           | 9 | 
           cycrow | 
           1202 | 
           }
  | 
        
        
            | 
            | 
           1203 | 
              | 
        
        
           | 8 | 
           cycrow | 
           1204 | 
           bool CSpkFile::convertOld(const Utils::String &sOldFilename)
  | 
        
        
           | 7 | 
           cycrow | 
           1205 | 
           {
  | 
        
        
            | 
            | 
           1206 | 
           	// check if the old file is actually in an old format
  | 
        
        
           | 10 | 
           cycrow | 
           1207 | 
           	int ret = CBaseFile::CheckFile ( sOldFilename );
  | 
        
        
            | 
            | 
           1208 | 
           	if ( ret != SPKFILE_INVALID && ret != SPKFILE_OLD ) {
  | 
        
        
            | 
            | 
           1209 | 
           		return false;
  | 
        
        
            | 
            | 
           1210 | 
            	}
  | 
        
        
            | 
            | 
           1211 | 
              | 
        
        
            | 
            | 
           1212 | 
           	//uncomress the data
  | 
        
        
            | 
            | 
           1213 | 
           	int len;
  | 
        
        
            | 
            | 
           1214 | 
           	unsigned char *uncomprData = this->_convert_uncompressFile(sOldFilename, &len);
  | 
        
        
            | 
            | 
           1215 | 
              | 
        
        
            | 
            | 
           1216 | 
           	// uncomressed failed
  | 
        
        
            | 
            | 
           1217 | 
           	if ( !uncomprData ) {
  | 
        
        
           | 50 | 
           cycrow | 
           1218 | 
           		CLog::log(CLog::Log_IO, 1, "Error: Unable to uncompress the file");
  | 
        
        
           | 10 | 
           cycrow | 
           1219 | 
           		return false;
  | 
        
        
            | 
            | 
           1220 | 
           	}
  | 
        
        
            | 
            | 
           1221 | 
              | 
        
        
            | 
            | 
           1222 | 
           	// now we can read the data
  | 
        
        
            | 
            | 
           1223 | 
           	unsigned char *d = uncomprData;
  | 
        
        
            | 
            | 
           1224 | 
           	Utils::String str;
  | 
        
        
            | 
            | 
           1225 | 
              | 
        
        
            | 
            | 
           1226 | 
           //	CMultiSpkFile *mspk = NULL;
  | 
        
        
            | 
            | 
           1227 | 
           	//SMultiSpkFile *cur_mspk = NULL;
  | 
        
        
            | 
            | 
           1228 | 
              | 
        
        
            | 
            | 
           1229 | 
           	int numscripts = 0, curscript = 0;
  | 
        
        
            | 
            | 
           1230 | 
           	float fVersion = 1;
  | 
        
        
            | 
            | 
           1231 | 
              | 
        
        
           | 50 | 
           cycrow | 
           1232 | 
           	CLog::log(CLog::Log_IO, 1, "* Reading spk data...");
  | 
        
        
           | 10 | 
           cycrow | 
           1233 | 
           	while ( d )
  | 
        
        
            | 
            | 
           1234 | 
           	{
  | 
        
        
            | 
            | 
           1235 | 
           		// read the next line
  | 
        
        
            | 
            | 
           1236 | 
           		d = str.readToEndOfLine(d);
  | 
        
        
            | 
            | 
           1237 | 
           		if ( !d || d[0] == 0 ) {
  | 
        
        
            | 
            | 
           1238 | 
           			break;
  | 
        
        
            | 
            | 
           1239 | 
           		}
  | 
        
        
            | 
            | 
           1240 | 
           		if ( str.empty() ) {
  | 
        
        
            | 
            | 
           1241 | 
           			continue;
  | 
        
        
            | 
            | 
           1242 | 
           		}
  | 
        
        
            | 
            | 
           1243 | 
              | 
        
        
            | 
            | 
           1244 | 
           		Utils::String sCmd = str.token(" ", 1);
  | 
        
        
            | 
            | 
           1245 | 
              | 
        
        
            | 
            | 
           1246 | 
           		//TODO: split this into CMultiSpkFile
  | 
        
        
            | 
            | 
           1247 | 
           		/*
  | 
        
        
            | 
            | 
           1248 | 
           		if ( first == "MultiPackage:" )
  | 
        
        
            | 
            | 
           1249 | 
           			mspk = new CMultiSpkFile;
  | 
        
        
            | 
            | 
           1250 | 
           		else if ( (first == "SelectScript:") && (mspk) )
  | 
        
        
            | 
            | 
           1251 | 
           		{
  | 
        
        
            | 
            | 
           1252 | 
           			mspk->AddFileEntry ( rest.GetToken ( 2, -1, ' ' ) + ".spk" );
  | 
        
        
            | 
            | 
           1253 | 
           			++numscripts;
  | 
        
        
            | 
            | 
           1254 | 
           		}
  | 
        
        
            | 
            | 
           1255 | 
           		else if ( (str == "AllowSelection") && (mspk) )
  | 
        
        
            | 
            | 
           1256 | 
           			mspk->SetSelection ( true );
  | 
        
        
            | 
            | 
           1257 | 
           		else if ( str == "-- Start New Script --" )
  | 
        
        
            | 
            | 
           1258 | 
           		{
  | 
        
        
            | 
            | 
           1259 | 
           			if ( !mspk )
  | 
        
        
            | 
            | 
           1260 | 
           			{
  | 
        
        
            | 
            | 
           1261 | 
           				printf ( "Invalid file format, seems to be multi package file but isn't\n" );
  | 
        
        
            | 
            | 
           1262 | 
           				CLEANUP
  | 
        
        
            | 
            | 
           1263 | 
           				exit ( 0 );
  | 
        
        
            | 
            | 
           1264 | 
           			}
  | 
        
        
            | 
            | 
           1265 | 
           			cur_mspk = mspk->GetFileList()->Get ( curscript );
  | 
        
        
            | 
            | 
           1266 | 
           			++curscript;
  | 
        
        
            | 
            | 
           1267 | 
           			cur_mspk->pFile = new CSpkFile;
  | 
        
        
            | 
            | 
           1268 | 
           			spkfile = (CSpkFile *)cur_mspk->pFile;
  | 
        
        
            | 
            | 
           1269 | 
           		}
  | 
        
        
            | 
            | 
           1270 | 
           		*/
  | 
        
        
            | 
            | 
           1271 | 
           		Utils::String sRest = str.tokens(" ", 2);
  | 
        
        
            | 
            | 
           1272 | 
           		if ( sCmd == "Packager:" ) {
  | 
        
        
            | 
            | 
           1273 | 
           			fVersion = sRest;
  | 
        
        
           | 50 | 
           cycrow | 
           1274 | 
           			CLog::logf(CLog::Log_Read, 3, "\tPackager Version: %.2f", fVersion );
  | 
        
        
           | 10 | 
           cycrow | 
           1275 | 
           		}
  | 
        
        
            | 
            | 
           1276 | 
           		else if ( sCmd == "Icon:" )
  | 
        
        
            | 
            | 
           1277 | 
           		{
  | 
        
        
            | 
            | 
           1278 | 
           			long size = sRest.token(" ", 1);
  | 
        
        
            | 
            | 
           1279 | 
           			Utils::String ext = sRest.token(" ", 2);
  | 
        
        
            | 
            | 
           1280 | 
              | 
        
        
            | 
            | 
           1281 | 
           			C_File *file = new C_File ();
  | 
        
        
            | 
            | 
           1282 | 
           			file->ReadFromData ( (char *)d, size );
  | 
        
        
            | 
            | 
           1283 | 
              | 
        
        
            | 
            | 
           1284 | 
           			d += size;
  | 
        
        
            | 
            | 
           1285 | 
              | 
        
        
           | 170 | 
           cycrow | 
           1286 | 
           			this->setIcon(file, ext);
  | 
        
        
           | 10 | 
           cycrow | 
           1287 | 
              | 
        
        
           | 134 | 
           cycrow | 
           1288 | 
           			CLog::logf(CLog::Log_File, 3, "\tIcon (%s) Size: %s", ext.c_str(), file->dataSizeString ().c_str() );
  | 
        
        
           | 10 | 
           cycrow | 
           1289 | 
           		}
  | 
        
        
            | 
            | 
           1290 | 
           		else if ( sCmd.left(3) == "$$$" )
  | 
        
        
            | 
            | 
           1291 | 
           			d = _convert_parseFile(sCmd, sRest, fVersion, d);
  | 
        
        
            | 
            | 
           1292 | 
           		else {
  | 
        
        
            | 
            | 
           1293 | 
           			this->_convert_parse(sCmd, sRest);
  | 
        
        
            | 
            | 
           1294 | 
           		}
  | 
        
        
            | 
            | 
           1295 | 
           	}
  | 
        
        
            | 
            | 
           1296 | 
              | 
        
        
           | 50 | 
           cycrow | 
           1297 | 
           	CLog::logf(CLog::Log_IO, 1, "* Reading spk data..." );
  | 
        
        
           | 10 | 
           cycrow | 
           1298 | 
              | 
        
        
           | 7 | 
           cycrow | 
           1299 | 
           	return true;
  | 
        
        
            | 
            | 
           1300 | 
           }
  |