| 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 |   | 
        
           | 175 | 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) )
 | 
        
           | 197 | cycrow | 103 | 		addWareText ( rest );
 | 
        
           | 1 | cycrow | 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 | */
 | 
        
           | 175 | cycrow | 120 | Utils::String CSpkFile::createValuesLine () const
 | 
        
           | 1 | cycrow | 121 | {
 | 
        
           | 175 | 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 )
 | 
        
           | 197 | cycrow | 139 | 			values += Utils::String("Ware: ") + Utils::WString(ware->cType).toString() + ":" + ware->iPrice + ":" + (long)ware->iSize + ":" + (long)ware->iVolumn + ":" + ware->sID.toString() + ":" + (long)ware->iNotority + ":" + (long)ware->iTextID + "," + (long)ware->iTextPage + "\n";
 | 
        
           | 1 | cycrow | 140 | 		else
 | 
        
           | 197 | cycrow | 141 | 			values += Utils::String("Ware: ") + Utils::WString(ware->cType).toString() + ":" + ware->iPrice + ":" + (long)ware->iSize + ":" + (long)ware->iVolumn + ":" + ware->sID.toString() + ":" + (long)ware->iNotority + "\n";
 | 
        
           | 14 | cycrow | 142 | 		for ( CListNode<SWaresText> *wtNode = ware->lText.Front(); wtNode; wtNode = wtNode->next() )
 | 
        
           | 197 | cycrow | 143 | 			values += Utils::String("WareText: ") + (long)wtNode->Data()->iLang + " " + wtNode->Data()->sName.toString() + "|" + wtNode->Data()->sDesc.toString() + "\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 |   | 
        
           | 175 | cycrow | 219 | bool CSpkFile::writeHeader(CFileIO &file, int valueheader, int valueComprLen) const
 | 
        
           | 1 | cycrow | 220 | {
 | 
        
           | 52 | cycrow | 221 | 	return file.write("SPKCycrow;%.2f;%d;%d\n", FILEVERSION, valueheader, valueComprLen);
 | 
        
           | 1 | cycrow | 222 | }
 | 
        
           |  |  | 223 |   | 
        
           | 197 | cycrow | 224 | void CSpkFile::addWareText(const Utils::WString &sData)
 | 
        
           | 1 | cycrow | 225 | {
 | 
        
           |  |  | 226 | 	if ( !m_pLastWare )
 | 
        
           |  |  | 227 | 		return;
 | 
        
           |  |  | 228 |   | 
        
           |  |  | 229 | 	SWaresText *wt = new SWaresText;
 | 
        
           | 197 | cycrow | 230 | 	wt->iLang = sData.token(L" ", 1);
 | 
        
           |  |  | 231 | 	wt->sName = sData.tokens(L" ", 2).token(L"|", 1);
 | 
        
           |  |  | 232 | 	wt->sDesc = sData.tokens(L" ", 2).tokens(L"|", 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);
 | 
        
           | 197 | cycrow | 247 | 	ware->sID = sData.token(":", 5).toWString();
 | 
        
           | 10 | cycrow | 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 |   | 
        
           | 197 | cycrow | 314 | 	SWares *newware = this->FindWare(ware->sID.toString());
 | 
        
           | 10 | cycrow | 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 |   | 
        
           | 197 | cycrow | 323 | void CSpkFile::addWareText(SWares *pWare, int iLang, const Utils::WString &sName, const Utils::WString &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 |   | 
        
           | 197 | cycrow | 384 | 		Utils::WString basename = file->baseName();
 | 
        
           |  |  | 385 | 		if ( basename.right(15).Compare(L".initplayership") )
 | 
        
           | 1 | cycrow | 386 | 			return 0;
 | 
        
           |  |  | 387 | 	}
 | 
        
           |  |  | 388 | 	if ( !IsAnotherMod() )
 | 
        
           |  |  | 389 | 		return 1;
 | 
        
           |  |  | 390 | 	else
 | 
        
           |  |  | 391 | 		return 2;
 | 
        
           |  |  | 392 | }
 | 
        
           |  |  | 393 |   | 
        
           | 175 | cycrow | 394 | bool CSpkFile::computeSigned(bool updateFiles) const
 | 
        
           | 1 | cycrow | 395 | {
 | 
        
           |  |  | 396 | 	// check for any custom wares
 | 
        
           |  |  | 397 | 	// patch mods and custom starts are also not signed
 | 
        
           | 175 | cycrow | 398 | 	if ((!m_lWares.empty()) || (this->IsPatch()) || (this->IsCustomStart()))
 | 
        
           | 1 | cycrow | 399 | 		return false;
 | 
        
           |  |  | 400 |   | 
        
           | 175 | cycrow | 401 | 	return CBaseFile::computeSigned(updateFiles);
 | 
        
           | 1 | cycrow | 402 | }
 | 
        
           |  |  | 403 |   | 
        
           | 14 | cycrow | 404 | SSettingType *CSpkFile::AddSetting(const Utils::String &key, int type )
 | 
        
           | 1 | cycrow | 405 | {
 | 
        
           | 39 | cycrow | 406 | 	Utils::String sKey = key.remove('|');
 | 
        
           | 10 | cycrow | 407 |   | 
        
           | 1 | cycrow | 408 | 	SSettingType *t;
 | 
        
           |  |  | 409 | 	for ( t = m_lSettings.First(); t; t = m_lSettings.Next() )
 | 
        
           |  |  | 410 | 	{
 | 
        
           | 10 | cycrow | 411 | 		if ( t->sKey.Compare(sKey) )
 | 
        
           | 1 | cycrow | 412 | 			return NULL;
 | 
        
           |  |  | 413 | 	}
 | 
        
           |  |  | 414 |   | 
        
           |  |  | 415 | 	switch ( type )
 | 
        
           |  |  | 416 | 	{
 | 
        
           |  |  | 417 | 		case SETTING_STRING:
 | 
        
           |  |  | 418 | 			t = new SSettingString;
 | 
        
           |  |  | 419 | 			break;
 | 
        
           |  |  | 420 | 		case SETTING_INTEGER:
 | 
        
           |  |  | 421 | 			t = new SSettingInteger;
 | 
        
           |  |  | 422 | 			break;
 | 
        
           |  |  | 423 | 		case SETTING_CHECK:
 | 
        
           |  |  | 424 | 			t = new SSettingCheck;
 | 
        
           |  |  | 425 | 			break;
 | 
        
           |  |  | 426 | 	}
 | 
        
           |  |  | 427 |   | 
        
           |  |  | 428 | 	if ( !t )
 | 
        
           |  |  | 429 | 		return NULL;
 | 
        
           |  |  | 430 |   | 
        
           | 10 | cycrow | 431 | 	t->sKey = sKey;
 | 
        
           | 1 | cycrow | 432 | 	t->iType = type;
 | 
        
           |  |  | 433 |   | 
        
           |  |  | 434 | 	m_lSettings.push_back ( t );
 | 
        
           | 50 | cycrow | 435 | 	_changed();
 | 
        
           | 1 | cycrow | 436 |   | 
        
           |  |  | 437 | 	return t;
 | 
        
           |  |  | 438 | }
 | 
        
           |  |  | 439 |   | 
        
           | 10 | cycrow | 440 | void CSpkFile::ConvertSetting ( SSettingType *t, const Utils::String &set ) const
 | 
        
           | 1 | cycrow | 441 | {
 | 
        
           |  |  | 442 | 	if ( !t )
 | 
        
           |  |  | 443 | 		return;
 | 
        
           |  |  | 444 |   | 
        
           |  |  | 445 | 	switch ( t->iType )
 | 
        
           |  |  | 446 | 	{
 | 
        
           |  |  | 447 | 		case SETTING_STRING:
 | 
        
           |  |  | 448 | 			((SSettingString *)t)->sValue = set;
 | 
        
           |  |  | 449 | 			break;
 | 
        
           |  |  | 450 | 		case SETTING_INTEGER:
 | 
        
           | 10 | cycrow | 451 | 			((SSettingInteger *)t)->iValue = set;
 | 
        
           | 1 | cycrow | 452 | 			break;
 | 
        
           |  |  | 453 | 		case SETTING_CHECK:
 | 
        
           | 10 | cycrow | 454 | 			((SSettingCheck *)t)->bValue = set;
 | 
        
           | 1 | cycrow | 455 | 			break;
 | 
        
           |  |  | 456 | 	}
 | 
        
           |  |  | 457 | }
 | 
        
           | 10 | cycrow | 458 | Utils::String CSpkFile::GetSetting ( SSettingType *t ) const
 | 
        
           | 1 | cycrow | 459 | {
 | 
        
           |  |  | 460 | 	if ( !t )
 | 
        
           |  |  | 461 | 		return "";
 | 
        
           |  |  | 462 |   | 
        
           |  |  | 463 | 	switch ( t->iType )
 | 
        
           |  |  | 464 | 	{
 | 
        
           |  |  | 465 | 		case SETTING_STRING:
 | 
        
           |  |  | 466 | 			return ((SSettingString *)t)->sValue;
 | 
        
           |  |  | 467 | 		case SETTING_INTEGER:
 | 
        
           | 50 | cycrow | 468 | 			return Utils::String::Number(((SSettingInteger *)t)->iValue);
 | 
        
           | 1 | cycrow | 469 | 		case SETTING_CHECK:
 | 
        
           |  |  | 470 | 			return (((SSettingInteger *)t)->iValue) ? "1" : "0";
 | 
        
           |  |  | 471 | 	}
 | 
        
           |  |  | 472 |   | 
        
           |  |  | 473 | 	return "";
 | 
        
           |  |  | 474 | }
 | 
        
           |  |  | 475 |   | 
        
           |  |  | 476 | void CSpkFile::ClearSettings ()
 | 
        
           |  |  | 477 | {
 | 
        
           |  |  | 478 | 	m_lSettings.clear(true);
 | 
        
           | 50 | cycrow | 479 | 	_changed();
 | 
        
           | 1 | cycrow | 480 | }
 | 
        
           |  |  | 481 |   | 
        
           |  |  | 482 |   | 
        
           | 13 | cycrow | 483 | bool CSpkFile::IsMatchingMod(const Utils::String &mod) const
 | 
        
           | 1 | cycrow | 484 | {
 | 
        
           |  |  | 485 | 	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
 | 
        
           |  |  | 486 | 	{
 | 
        
           |  |  | 487 | 		C_File *file = node->Data();
 | 
        
           |  |  | 488 | 		if ( file->GetFileType() != FILETYPE_MOD )
 | 
        
           |  |  | 489 | 			continue;
 | 
        
           |  |  | 490 |   | 
        
           |  |  | 491 | 		if ( file->IsFakePatch() )
 | 
        
           |  |  | 492 | 			continue;
 | 
        
           |  |  | 493 |   | 
        
           | 197 | cycrow | 494 | 		Utils::WString filename = file->baseName();
 | 
        
           | 10 | cycrow | 495 | 		if ( filename.Compare(mod) )
 | 
        
           | 1 | cycrow | 496 | 			return true;
 | 
        
           |  |  | 497 | 	}
 | 
        
           |  |  | 498 | 	return false;
 | 
        
           |  |  | 499 | }
 | 
        
           |  |  | 500 |   | 
        
           | 13 | cycrow | 501 | Utils::String CSpkFile::GetScriptTypeString(int lang) const
 | 
        
           | 1 | cycrow | 502 | {
 | 
        
           |  |  | 503 | 	int iType = m_iScriptType;
 | 
        
           |  |  | 504 |   | 
        
           |  |  | 505 | 	if ( this->IsLibrary() )
 | 
        
           |  |  | 506 | 		return "Library";
 | 
        
           |  |  | 507 | 	else if ( this->IsPackageUpdate() )
 | 
        
           |  |  | 508 | 		return "Package Update";
 | 
        
           |  |  | 509 | 	else if ( this->IsCustomStart() )
 | 
        
           |  |  | 510 | 		return "Custom Start";
 | 
        
           |  |  | 511 | 	else if ( this->IsPatch() )
 | 
        
           |  |  | 512 | 		return "Patch";
 | 
        
           |  |  | 513 | 	else if ( m_iScriptType == SCRIPTTYPE_CUSTOM )
 | 
        
           |  |  | 514 | 	{
 | 
        
           | 10 | cycrow | 515 | 		Utils::String type = this->GetCustomScriptType(lang);
 | 
        
           |  |  | 516 | 		if ( !type.empty() )
 | 
        
           | 1 | cycrow | 517 | 			return type;
 | 
        
           |  |  | 518 | 		iType = -1;
 | 
        
           |  |  | 519 | 	}
 | 
        
           |  |  | 520 |   | 
        
           |  |  | 521 | 	if (iType == -1)  // no script type
 | 
        
           |  |  | 522 | 	{
 | 
        
           |  |  | 523 | 		if ( this->IsFakePatch() )
 | 
        
           |  |  | 524 | 			return "Fake Patch";
 | 
        
           |  |  | 525 | 	}
 | 
        
           |  |  | 526 |   | 
        
           | 10 | cycrow | 527 | 	Utils::String sType = CSpkFile::GetScriptTypeStringStatic(m_iScriptType);
 | 
        
           | 1 | cycrow | 528 |   | 
        
           | 10 | cycrow | 529 | 	if ( sType.empty() )
 | 
        
           | 1 | cycrow | 530 | 		return "Other";
 | 
        
           |  |  | 531 |   | 
        
           |  |  | 532 | 	return sType;	
 | 
        
           |  |  | 533 | }
 | 
        
           |  |  | 534 |   | 
        
           | 10 | cycrow | 535 | int CSpkFile::ConvertScriptType(const Utils::String &sType)
 | 
        
           | 1 | cycrow | 536 | {
 | 
        
           |  |  | 537 | 	for ( int i = 0; i < SCRIPTTYPE_MAX; i++ )
 | 
        
           |  |  | 538 | 	{
 | 
        
           |  |  | 539 | 		if ( sType.Compare(CSpkFile::GetScriptTypeStringStatic(i)) )
 | 
        
           |  |  | 540 | 			return i;
 | 
        
           |  |  | 541 | 	}
 | 
        
           |  |  | 542 |   | 
        
           |  |  | 543 | 	return -1;
 | 
        
           |  |  | 544 | }
 | 
        
           |  |  | 545 |   | 
        
           | 10 | cycrow | 546 | Utils::String CSpkFile::GetScriptTypeStringStatic(int type)
 | 
        
           | 1 | cycrow | 547 | {
 | 
        
           |  |  | 548 | 	switch ( type )
 | 
        
           |  |  | 549 | 	{
 | 
        
           |  |  | 550 | 		case SCRIPTTYPE_CUSTOM:
 | 
        
           |  |  | 551 | 			return "Custom";
 | 
        
           |  |  | 552 | 		case SCRIPTTYPE_NAVIGATION:
 | 
        
           |  |  | 553 | 			return "Navigation";
 | 
        
           |  |  | 554 | 		case SCRIPTTYPE_COMBAT:
 | 
        
           |  |  | 555 | 			return "Combat";
 | 
        
           |  |  | 556 | 		case SCRIPTTYPE_MISSION:
 | 
        
           |  |  | 557 | 			return "Mission";
 | 
        
           |  |  | 558 | 		case SCRIPTTYPE_ALPLUGIN:
 | 
        
           |  |  | 559 | 			return "AL Plugin";
 | 
        
           |  |  | 560 | 		case SCRIPTTYPE_HOTKEY:
 | 
        
           |  |  | 561 | 			return "Hotkey";
 | 
        
           |  |  | 562 | 		case SCRIPTTYPE_SHIPUPGRADE:
 | 
        
           |  |  | 563 | 			return "Ship Upgrade";
 | 
        
           |  |  | 564 | 		case SCRIPTTYPE_SHIPCOMMAND:
 | 
        
           |  |  | 565 | 			return "Ship Command";
 | 
        
           |  |  | 566 | 		case SCRIPTTYPE_STATIONCOMMAND:
 | 
        
           |  |  | 567 | 			return "Station Command";
 | 
        
           |  |  | 568 | 		case SCRIPTTYPE_FLEET:
 | 
        
           |  |  | 569 | 			return "Fleet Management";
 | 
        
           |  |  | 570 | 		case SCRIPTTYPE_TRADE:
 | 
        
           |  |  | 571 | 			return "Trade";
 | 
        
           |  |  | 572 | 		case SCRIPTTYPE_PIRACY:
 | 
        
           |  |  | 573 | 			return "Piracy";
 | 
        
           |  |  | 574 | 		case SCRIPTTYPE_CHEAT:
 | 
        
           |  |  | 575 | 			return "Cheat";
 | 
        
           |  |  | 576 | 		case SCRIPTTYPE_EXTENSION:
 | 
        
           |  |  | 577 | 			return "Extension Mods";
 | 
        
           |  |  | 578 | 		case SCRIPTTYPE_REBALANCE:
 | 
        
           |  |  | 579 | 			return "Rebalance";
 | 
        
           |  |  | 580 | 		case SCRIPTTYPE_FIX:
 | 
        
           |  |  | 581 | 			return "Vanilla Fix";
 | 
        
           |  |  | 582 | 		case SCRIPTTYPE_GENERALMOD:
 | 
        
           |  |  | 583 | 			return "General Mod";
 | 
        
           |  |  | 584 | 		case SCRIPTTYPE_TOTAL:
 | 
        
           |  |  | 585 | 			return "Totel Conversion";
 | 
        
           |  |  | 586 | 		case SCRIPTTYPE_WINGCOMMAND:
 | 
        
           |  |  | 587 | 			return "Wing Command";
 | 
        
           |  |  | 588 | 	}
 | 
        
           |  |  | 589 |   | 
        
           |  |  | 590 | 	return "Other";
 | 
        
           |  |  | 591 | }
 | 
        
           |  |  | 592 |   | 
        
           | 197 | cycrow | 593 | bool CSpkFile::loadPackageData(const Utils::WString &sFirst, const Utils::WString &sRest, const Utils::WString &sMainGame, Utils::WStringList &otherGames, Utils::WStringList &gameAddons, CProgressInfo *progress)
 | 
        
           | 1 | cycrow | 594 | {
 | 
        
           | 197 | cycrow | 595 | 	if ( sFirst.Compare(L"ScriptType") )
 | 
        
           | 1 | cycrow | 596 | 	{
 | 
        
           | 197 | cycrow | 597 | 		if ( sRest.Compare(L"Library") || sRest.Compare(L"Library Script") )
 | 
        
           | 1 | cycrow | 598 | 			this->SetLibrary();
 | 
        
           | 197 | cycrow | 599 | 		else if ( sRest.Compare(L"Update") || sRest.Compare(L"Package Update") || sRest.Compare(L"Mod Update") )
 | 
        
           | 1 | cycrow | 600 | 			this->SetPackageUpdate();
 | 
        
           | 197 | cycrow | 601 | 		else if ( sRest.Compare(L"Start") || sRest.Compare(L"Custom Start") )
 | 
        
           | 1 | cycrow | 602 | 			this->SetCustomStart();
 | 
        
           | 197 | cycrow | 603 | 		else if ( sRest.Compare(L"Patch") || sRest.Compare(L"Patch Mod") )
 | 
        
           | 1 | cycrow | 604 | 			this->SetPatch();
 | 
        
           |  |  | 605 | 		else
 | 
        
           |  |  | 606 | 		{
 | 
        
           | 14 | cycrow | 607 | 			int check = sRest;
 | 
        
           | 197 | cycrow | 608 | 			if ( check || sRest == L"0" )
 | 
        
           | 1 | cycrow | 609 | 				m_iScriptType = check;
 | 
        
           |  |  | 610 | 			else
 | 
        
           |  |  | 611 | 			{
 | 
        
           | 197 | cycrow | 612 | 				m_iScriptType = CSpkFile::ConvertScriptType(sRest.toString());
 | 
        
           | 1 | cycrow | 613 | 				if ( m_iScriptType == -1 )
 | 
        
           | 197 | cycrow | 614 | 					m_sScriptType = sRest.toString();
 | 
        
           | 1 | cycrow | 615 | 			}
 | 
        
           |  |  | 616 | 		}
 | 
        
           |  |  | 617 | 	}
 | 
        
           | 197 | cycrow | 618 | 	else if (sFirst.Compare(L"AnotherMod"))
 | 
        
           | 1 | cycrow | 619 | 	{
 | 
        
           | 197 | cycrow | 620 | 		m_sOtherName = sRest.token(L"|", 1).toString();
 | 
        
           |  |  | 621 | 		m_sOtherAuthor = sRest.tokens(L"|", 2).toString();
 | 
        
           | 1 | cycrow | 622 | 	}
 | 
        
           | 197 | cycrow | 623 | 	else if ( sFirst.Compare(L"WareName") || sFirst.Compare(L"WareDesc") )
 | 
        
           | 1 | cycrow | 624 | 	{
 | 
        
           |  |  | 625 | 		// find the ware to use
 | 
        
           |  |  | 626 | 		SWares *useWare = m_pLastWare;
 | 
        
           | 197 | cycrow | 627 | 		Utils::WString id = sRest.token(L" ", 1);
 | 
        
           | 1 | cycrow | 628 | 		for ( CListNode<SWares> *wNode = m_lWares.Front(); wNode; wNode = wNode->next() )
 | 
        
           |  |  | 629 | 		{
 | 
        
           | 10 | cycrow | 630 | 			if ( wNode->Data()->sID.Compare(id.c_str()) )
 | 
        
           | 1 | cycrow | 631 | 			{
 | 
        
           |  |  | 632 | 				useWare = wNode->Data();
 | 
        
           |  |  | 633 | 				break;
 | 
        
           |  |  | 634 | 			}
 | 
        
           |  |  | 635 | 		}
 | 
        
           |  |  | 636 |   | 
        
           |  |  | 637 | 		// check if we have the id already
 | 
        
           |  |  | 638 | 		if ( useWare )
 | 
        
           |  |  | 639 | 		{
 | 
        
           | 197 | cycrow | 640 | 			int lang = sRest.token(L" ", 2);
 | 
        
           | 1 | cycrow | 641 | 			SWaresText *wt = NULL;
 | 
        
           |  |  | 642 | 			for ( CListNode<SWaresText> *tNode = useWare->lText.Front(); tNode; tNode = tNode->next() )
 | 
        
           |  |  | 643 | 			{
 | 
        
           |  |  | 644 | 				if ( tNode->Data()->iLang == lang )
 | 
        
           |  |  | 645 | 				{
 | 
        
           |  |  | 646 | 					wt = tNode->Data();
 | 
        
           |  |  | 647 | 					break;
 | 
        
           |  |  | 648 | 				}
 | 
        
           |  |  | 649 | 			}
 | 
        
           |  |  | 650 |   | 
        
           |  |  | 651 | 			if ( !wt )
 | 
        
           |  |  | 652 | 			{
 | 
        
           |  |  | 653 | 				wt = new SWaresText;
 | 
        
           |  |  | 654 | 				wt->iLang = lang;
 | 
        
           |  |  | 655 | 				useWare->lText.push_back(wt);
 | 
        
           |  |  | 656 | 			}
 | 
        
           |  |  | 657 |   | 
        
           | 197 | cycrow | 658 | 			if ( sFirst.Compare(L"WareName") )
 | 
        
           |  |  | 659 | 				wt->sName = sRest.tokens(L" ", 3);
 | 
        
           | 1 | cycrow | 660 | 			else
 | 
        
           | 197 | cycrow | 661 | 				wt->sDesc = sRest.tokens(L" ", 3);
 | 
        
           | 1 | cycrow | 662 | 		}
 | 
        
           |  |  | 663 | 	}
 | 
        
           | 197 | cycrow | 664 | 	else if ( sFirst.left(4).Compare(L"Ware") )
 | 
        
           | 1 | cycrow | 665 | 	{
 | 
        
           |  |  | 666 | 		SWares *ware = new SWares;
 | 
        
           |  |  | 667 | 		ware->iTextID = -1;
 | 
        
           |  |  | 668 | 		ware->iTextPage = 0;
 | 
        
           | 14 | cycrow | 669 | 		ware->cType = sFirst[4];
 | 
        
           | 197 | cycrow | 670 | 		ware->iPrice = sRest.token(L" ", 2);
 | 
        
           |  |  | 671 | 		ware->iSize = sRest.token(L" ", 3);
 | 
        
           |  |  | 672 | 		ware->iVolumn = sRest.token(L" ", 4);
 | 
        
           |  |  | 673 | 		ware->sID = sRest.token(L" ", 1);
 | 
        
           |  |  | 674 | 		ware->iNotority = sRest.token(L" ", 5);
 | 
        
           |  |  | 675 | 		if ( !sRest.token(L" ", 6).empty() )
 | 
        
           | 1 | cycrow | 676 | 		{
 | 
        
           | 197 | cycrow | 677 | 			ware->iTextID = sRest.token(L" ", 6).token(L",", 2);
 | 
        
           |  |  | 678 | 			ware->iTextPage = sRest.token(L" ", 6).token(L",", 1);
 | 
        
           | 1 | cycrow | 679 | 		}
 | 
        
           |  |  | 680 | 		m_lWares.push_back ( ware );
 | 
        
           |  |  | 681 | 		m_pLastWare = ware;
 | 
        
           |  |  | 682 | 	}
 | 
        
           |  |  | 683 |   | 
        
           | 197 | cycrow | 684 | 	else if ( CBaseFile::loadPackageData(sFirst, sRest, sMainGame, otherGames, gameAddons, progress) )
 | 
        
           | 1 | cycrow | 685 | 		return true;
 | 
        
           |  |  | 686 | 	else
 | 
        
           |  |  | 687 | 		return false;
 | 
        
           |  |  | 688 |   | 
        
           |  |  | 689 | 	return true;
 | 
        
           |  |  | 690 | }
 | 
        
           |  |  | 691 |   | 
        
           | 127 | cycrow | 692 | bool CSpkFile::GeneratePackagerScript(bool wildcard, Utils::CStringList *list, int game, const Utils::CStringList &gameAddons, bool datafile)
 | 
        
           | 1 | cycrow | 693 | {
 | 
        
           | 127 | cycrow | 694 | 	if ( !CBaseFile::GeneratePackagerScript(wildcard, list, game, gameAddons, datafile) )
 | 
        
           | 1 | cycrow | 695 | 		return false;
 | 
        
           |  |  | 696 |   | 
        
           | 126 | cycrow | 697 | 	list->pushBack("# File Type, Script or Ship");
 | 
        
           |  |  | 698 | 	list->pushBack("FileType: Script");
 | 
        
           |  |  | 699 | 	list->pushBack("");
 | 
        
           | 98 | cycrow | 700 |   | 
        
           | 126 | cycrow | 701 | 	list->pushBack("# Script Type, the type of package file, some are special types, others are just for show");
 | 
        
           | 1 | cycrow | 702 | 	if ( this->IsLibrary() )
 | 
        
           | 126 | cycrow | 703 | 		list->pushBack("ScriptType: Library");
 | 
        
           | 1 | cycrow | 704 | 	else if ( this->IsPackageUpdate() )
 | 
        
           | 126 | cycrow | 705 | 		list->pushBack("ScriptType: Package Update");
 | 
        
           | 1 | cycrow | 706 | 	else if ( this->IsCustomStart() )
 | 
        
           | 126 | cycrow | 707 | 		list->pushBack("ScriptType: Custom Start");
 | 
        
           | 1 | cycrow | 708 | 	else if ( this->IsPatch() )
 | 
        
           | 126 | cycrow | 709 | 		list->pushBack("ScriptType: Patch");
 | 
        
           | 1 | cycrow | 710 | 	else
 | 
        
           | 126 | cycrow | 711 | 		list->pushBack("ScriptType: " + this->GetScriptTypeString(44));
 | 
        
           |  |  | 712 | 	list->pushBack("");
 | 
        
           | 1 | cycrow | 713 |   | 
        
           |  |  | 714 | 	if ( this->IsAnotherMod() )
 | 
        
           |  |  | 715 | 	{
 | 
        
           | 126 | cycrow | 716 | 		list->pushBack("# For another mod/package, this is a child package");
 | 
        
           |  |  | 717 | 		list->pushBack("AnotherMod: " + m_sOtherName + "|" + m_sOtherAuthor);
 | 
        
           |  |  | 718 | 		list->pushBack("");
 | 
        
           | 1 | cycrow | 719 | 	}
 | 
        
           |  |  | 720 |   | 
        
           |  |  | 721 | 	if ( !m_lWares.empty() )
 | 
        
           |  |  | 722 | 	{
 | 
        
           | 126 | cycrow | 723 | 		list->pushBack("# Custom Wares, Ware<type>: <id> <price> <size> <volumn> <notority>");
 | 
        
           | 1 | cycrow | 724 | 		for ( CListNode<SWares> *node = m_lWares.Front(); node; node = node->next() )
 | 
        
           |  |  | 725 | 		{
 | 
        
           |  |  | 726 | 			SWares *w = node->Data();
 | 
        
           |  |  | 727 | 			if ( w->iTextID > 0 )
 | 
        
           | 197 | cycrow | 728 | 				list->pushBack(Utils::String("Ware") + (char)w->cType + ": " + w->sID.toString() + " " + (long)w->iPrice + " " + (long)w->iSize + " " + (long)w->iVolumn + " " + (long)w->iNotority + " " + (long)w->iTextPage + "," + (long)w->iTextID);
 | 
        
           | 1 | cycrow | 729 | 			else
 | 
        
           | 197 | cycrow | 730 | 				list->pushBack(Utils::String("Ware") + (char)w->cType + ": " + w->sID.toString() + " " + (long)w->iPrice + " " + (long)w->iSize + " " + (long)w->iVolumn + " " + (long)w->iNotority);
 | 
        
           | 1 | cycrow | 731 | 			for ( CListNode<SWaresText> *wNode = w->lText.Front(); wNode; wNode = wNode->next() )
 | 
        
           |  |  | 732 | 			{
 | 
        
           |  |  | 733 | 				SWaresText *wt = wNode->Data();
 | 
        
           | 10 | cycrow | 734 | 				if ( !wt->sName.empty() )
 | 
        
           | 197 | cycrow | 735 | 					list->pushBack("WareName: " + w->sID.toString() + " " + (long)wt->iLang + " " + wt->sName.toString());
 | 
        
           | 10 | cycrow | 736 | 				if ( !wt->sDesc.empty() )
 | 
        
           | 197 | cycrow | 737 | 					list->pushBack("WareDesc: " + w->sID.toString() + " " + (long)wt->iLang + " " + wt->sDesc.toString());
 | 
        
           | 1 | cycrow | 738 | 			}
 | 
        
           | 126 | cycrow | 739 | 			list->pushBack("");
 | 
        
           | 1 | cycrow | 740 | 		}
 | 
        
           |  |  | 741 | 	}
 | 
        
           |  |  | 742 |   | 
        
           |  |  | 743 | 	if ( !datafile )
 | 
        
           |  |  | 744 | 	{
 | 
        
           | 127 | cycrow | 745 | 		if ( !CBaseFile::GeneratePackagerScriptFile(wildcard, list, game, gameAddons) )
 | 
        
           | 1 | cycrow | 746 | 			return false;
 | 
        
           |  |  | 747 | 	}
 | 
        
           |  |  | 748 |   | 
        
           |  |  | 749 | 	return true;
 | 
        
           |  |  | 750 |   | 
        
           |  |  | 751 | }
 | 
        
           |  |  | 752 |   | 
        
           | 197 | cycrow | 753 | Utils::WString CSpkFile::GetWareText(SWares *w, int lang)
 | 
        
           | 1 | cycrow | 754 | {
 | 
        
           |  |  | 755 | 	// return the text page if being used
 | 
        
           |  |  | 756 | 	if ( w->iTextID > 0 && w->iTextPage > 0 )
 | 
        
           | 197 | cycrow | 757 | 		return Utils::WString(L"{") + (long)w->iTextPage + L"," + (long)w->iTextID + L"}";
 | 
        
           | 1 | cycrow | 758 |   | 
        
           | 197 | cycrow | 759 | 	Utils::WString name;
 | 
        
           | 1 | cycrow | 760 | 	for ( CListNode<SWaresText> *wt = w->lText.Front(); wt; wt = wt->next() )
 | 
        
           |  |  | 761 | 	{
 | 
        
           | 10 | cycrow | 762 | 		if ( wt->Data()->sName.empty() )
 | 
        
           | 1 | cycrow | 763 | 			continue;
 | 
        
           |  |  | 764 | 		if ( wt->Data()->iLang == lang )
 | 
        
           |  |  | 765 | 			name = wt->Data()->sName;
 | 
        
           | 10 | cycrow | 766 | 		else if ( name.empty() && wt->Data()->iLang == 44 )
 | 
        
           | 1 | cycrow | 767 | 			name = wt->Data()->sName;
 | 
        
           | 10 | cycrow | 768 | 		else if ( name.empty() )
 | 
        
           | 1 | cycrow | 769 | 			name = wt->Data()->sName;
 | 
        
           |  |  | 770 | 	}
 | 
        
           |  |  | 771 |   | 
        
           |  |  | 772 | 	return name;
 | 
        
           |  |  | 773 | }
 | 
        
           | 197 | cycrow | 774 | Utils::WString CSpkFile::GetWareDesc(SWares *w, int lang)
 | 
        
           | 1 | cycrow | 775 | {
 | 
        
           |  |  | 776 | 	// return the text page if being used
 | 
        
           |  |  | 777 | 	if ( w->iTextID > 0 && w->iTextPage > 0 )
 | 
        
           | 197 | cycrow | 778 | 		return Utils::WString(L"{") + (long)w->iTextPage + L"," + ((long)w->iTextID + 1) + L"}";
 | 
        
           | 1 | cycrow | 779 |   | 
        
           | 197 | cycrow | 780 | 	Utils::WString name;
 | 
        
           | 1 | cycrow | 781 | 	for ( CListNode<SWaresText> *wt = w->lText.Front(); wt; wt = wt->next() )
 | 
        
           |  |  | 782 | 	{
 | 
        
           | 10 | cycrow | 783 | 		if ( wt->Data()->sDesc.empty() )
 | 
        
           | 1 | cycrow | 784 | 			continue;
 | 
        
           |  |  | 785 |   | 
        
           |  |  | 786 | 		if ( wt->Data()->iLang == lang )
 | 
        
           |  |  | 787 | 			name = wt->Data()->sDesc;
 | 
        
           | 10 | cycrow | 788 | 		else if ( name.empty() && wt->Data()->iLang == 44 )
 | 
        
           | 1 | cycrow | 789 | 			name = wt->Data()->sDesc;
 | 
        
           | 10 | cycrow | 790 | 		else if ( name.empty() )
 | 
        
           | 1 | cycrow | 791 | 			name = wt->Data()->sDesc;
 | 
        
           |  |  | 792 | 	}
 | 
        
           |  |  | 793 |   | 
        
           |  |  | 794 | 	return name;
 | 
        
           |  |  | 795 | }
 | 
        
           |  |  | 796 |   | 
        
           | 13 | cycrow | 797 | Utils::String CSpkFile::GetCustomStartName() const
 | 
        
           | 1 | cycrow | 798 | {
 | 
        
           |  |  | 799 | 	if ( !this->IsCustomStart() )
 | 
        
           | 10 | cycrow | 800 | 		return "";
 | 
        
           | 1 | cycrow | 801 |   | 
        
           |  |  | 802 | 	// else find the custom start script
 | 
        
           |  |  | 803 | 	C_File *file = NULL;
 | 
        
           |  |  | 804 | 	for ( file = this->GetFirstFile(FILETYPE_SCRIPT); file; file = this->GetNextFile(file) )
 | 
        
           |  |  | 805 | 	{
 | 
        
           | 197 | cycrow | 806 | 		if ( file->filename().contains(L"initplayership") && file->filename().token(L".", 1).Compare(L"galaxy") )
 | 
        
           | 1 | cycrow | 807 | 			break;
 | 
        
           |  |  | 808 | 	}
 | 
        
           |  |  | 809 |   | 
        
           |  |  | 810 | 	if ( !file )
 | 
        
           | 10 | cycrow | 811 | 		return "";
 | 
        
           | 1 | cycrow | 812 |   | 
        
           | 197 | cycrow | 813 | 	return file->filename().token(L".", 2).toString();
 | 
        
           | 1 | cycrow | 814 | }
 | 
        
           |  |  | 815 |   | 
        
           |  |  | 816 | void CSpkFile::MergePackage(CBaseFile *base)
 | 
        
           |  |  | 817 | {
 | 
        
           |  |  | 818 | 	// update possible changes
 | 
        
           |  |  | 819 | 	if ( base->GetType() == TYPE_SPK )
 | 
        
           |  |  | 820 | 	{
 | 
        
           |  |  | 821 | 		CSpkFile *spk = (CSpkFile *)base;
 | 
        
           |  |  | 822 | 		m_bForceProfile = spk->IsForceProfile();
 | 
        
           |  |  | 823 |   | 
        
           |  |  | 824 | 		// add any new wares
 | 
        
           |  |  | 825 | 		if ( spk->AnyWares() )
 | 
        
           |  |  | 826 | 		{
 | 
        
           |  |  | 827 | 			for ( CListNode<SWares> *node = spk->GetWaresList()->Front(); node; node = node->next() )
 | 
        
           |  |  | 828 | 				this->AddWare(node->Data());
 | 
        
           |  |  | 829 | 			spk->GetWaresList()->clear(); // remove wares so they aren't deleted
 | 
        
           |  |  | 830 | 		}
 | 
        
           |  |  | 831 |   | 
        
           |  |  | 832 | 		// add any settings
 | 
        
           |  |  | 833 | 		if ( spk->AnySettings() )
 | 
        
           |  |  | 834 | 		{
 | 
        
           |  |  | 835 | 			for ( CListNode<SSettingType> *node = spk->GetSettingsList()->Front(); node; node = node->next() )
 | 
        
           |  |  | 836 | 				this->AddSetting(node->Data()->sKey, node->Data()->iType);
 | 
        
           |  |  | 837 | 		}
 | 
        
           |  |  | 838 |   | 
        
           | 10 | cycrow | 839 | 		if ( !spk->GetOtherName().empty() )
 | 
        
           | 1 | cycrow | 840 | 		{
 | 
        
           |  |  | 841 | 			m_sOtherName = spk->GetOtherName();
 | 
        
           |  |  | 842 | 			m_sOtherAuthor = spk->GetOtherAuthor();
 | 
        
           |  |  | 843 | 		}
 | 
        
           |  |  | 844 | 	}
 | 
        
           |  |  | 845 |   | 
        
           |  |  | 846 | 	// copy settings from base class
 | 
        
           | 46 | cycrow | 847 | 	_merge(base);
 | 
        
           | 1 | cycrow | 848 |   | 
        
           |  |  | 849 | 	for ( CListNode<SGameCompat> *gNode = base->GetGameCompatabilityList()->Front(); gNode; gNode = gNode->next() ) {
 | 
        
           | 46 | cycrow | 850 | 		if ( !gNode->Data()->sVersion.empty() )
 | 
        
           | 197 | cycrow | 851 | 			this->AddGameCompatability(gNode->Data()->iGame, gNode->Data()->sVersion.toString());
 | 
        
           | 1 | cycrow | 852 | 		else
 | 
        
           | 46 | cycrow | 853 | 			this->AddGameCompatability(gNode->Data()->iGame, (long)gNode->Data()->iVersion);
 | 
        
           | 1 | cycrow | 854 | 	}
 | 
        
           |  |  | 855 |   | 
        
           |  |  | 856 | 	// copy over needed librarys
 | 
        
           |  |  | 857 | 	for ( CListNode<SNeededLibrary> *lNode = base->GetNeededLibraries()->Front(); lNode; lNode = lNode->next() )
 | 
        
           | 203 | cycrow | 858 | 		this->addNeededLibrary(lNode->Data()->sName, lNode->Data()->sAuthor, lNode->Data()->sMinVersion);
 | 
        
           | 1 | cycrow | 859 |   | 
        
           |  |  | 860 | 	// web mirror address, add any new ones
 | 
        
           | 170 | cycrow | 861 | 	for(auto itr = base->webMirrors().begin(); itr != base->webMirrors().end(); itr++)
 | 
        
           | 162 | cycrow | 862 | 		this->addWebMirror((*itr)->str);
 | 
        
           | 1 | cycrow | 863 |   | 
        
           |  |  | 864 | 	// copy over package names
 | 
        
           | 170 | cycrow | 865 | 	for(auto itr = base->namesList()->begin(); itr != base->namesList()->end(); itr++)
 | 
        
           |  |  | 866 | 		this->addName((*itr)->iLanguage, (*itr)->sName);
 | 
        
           | 1 | cycrow | 867 |   | 
        
           |  |  | 868 | 	// finally do all the files
 | 
        
           | 170 | cycrow | 869 | 	for ( CListNode<C_File> *node = base->fileList().Front(); node; node = node->next() )
 | 
        
           | 1 | cycrow | 870 | 	{
 | 
        
           |  |  | 871 | 		C_File *f = node->Data();
 | 
        
           |  |  | 872 | 		// if it exists, remove the old
 | 
        
           |  |  | 873 | 		for ( CListNode<C_File> *thisNode = m_lFiles.Front(); thisNode; thisNode = thisNode->next() )
 | 
        
           |  |  | 874 | 		{
 | 
        
           | 158 | cycrow | 875 | 			if ( thisNode->Data()->GetFileType() == f->GetFileType() && thisNode->Data()->filename().Compare(f->filename()) && thisNode->Data()->dir().Compare(f->dir()) )
 | 
        
           | 1 | cycrow | 876 | 			{
 | 
        
           |  |  | 877 | 				m_lFiles.remove(thisNode);
 | 
        
           |  |  | 878 | 				break;
 | 
        
           |  |  | 879 | 			}
 | 
        
           |  |  | 880 | 		}
 | 
        
           |  |  | 881 |   | 
        
           |  |  | 882 | 		m_lFiles.push_back(f);
 | 
        
           |  |  | 883 | 	}
 | 
        
           |  |  | 884 |   | 
        
           |  |  | 885 | 	// clear the files so we dont delete them later
 | 
        
           |  |  | 886 | 	base->GetFileList()->clear();
 | 
        
           |  |  | 887 | }
 | 
        
           | 7 | cycrow | 888 |   | 
        
           | 8 | cycrow | 889 | unsigned char *CSpkFile::_convert_uncompressFile(const Utils::String &sOldFilename, int *pLen)
 | 
        
           | 7 | cycrow | 890 | {
 | 
        
           | 10 | cycrow | 891 | 	// firstcheck if the file exists
 | 
        
           |  |  | 892 | 	FILE *id = fopen(sOldFilename.c_str(), "rb" );
 | 
        
           |  |  | 893 | 	if ( !id ) {
 | 
        
           | 50 | cycrow | 894 | 		CLog::logf(CLog::Log_IO, 1, "Unable to open file: %s", sOldFilename.c_str());
 | 
        
           | 10 | cycrow | 895 | 		return false;
 | 
        
           |  |  | 896 | 	}
 | 
        
           | 7 | cycrow | 897 |   | 
        
           | 10 | cycrow | 898 | 	// read the first 3 charaters to check if its using the original "HiP" compression
 | 
        
           | 14 | cycrow | 899 | 	Utils::String check((char)fgetc(id));
 | 
        
           | 10 | cycrow | 900 | 	check += (char)fgetc ( id );
 | 
        
           |  |  | 901 | 	check += (char)fgetc ( id );
 | 
        
           | 7 | cycrow | 902 |   | 
        
           | 14 | cycrow | 903 | 	Utils::String removeFile;
 | 
        
           | 7 | cycrow | 904 |   | 
        
           | 10 | cycrow | 905 | 	unsigned char *uncomprData = NULL;
 | 
        
           |  |  | 906 | 	unsigned char *data = NULL;
 | 
        
           |  |  | 907 | 	long len = 0, newlen = 0;
 | 
        
           |  |  | 908 |   | 
        
           |  |  | 909 | 	if ( check == "HiP" ) {
 | 
        
           |  |  | 910 | 		fclose ( id );
 | 
        
           |  |  | 911 | 		bool opened = false;
 | 
        
           |  |  | 912 | 		if ( DecompressFile ( (char *)sOldFilename.c_str(), "uncompr.tmp" ) ) {
 | 
        
           |  |  | 913 | 			removeFile = "uncompr.tmp";
 | 
        
           |  |  | 914 | 			id = fopen ( "uncompr.tmp", "r" );
 | 
        
           |  |  | 915 | 			if ( id )
 | 
        
           |  |  | 916 | 				opened = true;
 | 
        
           |  |  | 917 | 		}
 | 
        
           |  |  | 918 |   | 
        
           |  |  | 919 | 		if ( !opened ) {
 | 
        
           | 50 | cycrow | 920 | 			CLog::log(CLog::Log_IO, 1, "Unable to uncompress file, exiting...");
 | 
        
           | 10 | cycrow | 921 | 			return false;
 | 
        
           |  |  | 922 | 		}
 | 
        
           |  |  | 923 |   | 
        
           | 50 | cycrow | 924 | 		CLog::log(CLog::Log_IO, 1, "* Reading file into memory...");
 | 
        
           | 10 | cycrow | 925 | 		// get file length
 | 
        
           |  |  | 926 | 		fseek ( id, 0, SEEK_END );
 | 
        
           |  |  | 927 | 		len = ftell ( id );
 | 
        
           |  |  | 928 |   | 
        
           |  |  | 929 | 		// move back to beginning
 | 
        
           |  |  | 930 | 		fseek ( id, 0, SEEK_SET );
 | 
        
           |  |  | 931 |   | 
        
           |  |  | 932 | 		// read the data from file into memory
 | 
        
           |  |  | 933 | 		uncomprData = new unsigned char[len + 1];
 | 
        
           |  |  | 934 | 		fread ( uncomprData, sizeof(unsigned char), len, id );
 | 
        
           |  |  | 935 |   | 
        
           |  |  | 936 | 		newlen = len;
 | 
        
           |  |  | 937 | 	}
 | 
        
           |  |  | 938 | 	else
 | 
        
           |  |  | 939 | 	{
 | 
        
           | 50 | cycrow | 940 | 		CLog::log(CLog::Log_IO, 1, "* Reading file into memory...");
 | 
        
           | 10 | cycrow | 941 | 		// get file length
 | 
        
           |  |  | 942 | 		fseek ( id, 0, SEEK_END );
 | 
        
           |  |  | 943 | 		len = ftell ( id );
 | 
        
           |  |  | 944 |   | 
        
           |  |  | 945 | 		// move back to beginning
 | 
        
           |  |  | 946 | 		fseek ( id, 0, SEEK_SET );
 | 
        
           |  |  | 947 |   | 
        
           |  |  | 948 | 		// read the data from file into memory
 | 
        
           |  |  | 949 | 		data = new unsigned char[len + 1];
 | 
        
           |  |  | 950 | 		fread ( data, sizeof(unsigned char), len, id );
 | 
        
           |  |  | 951 |   | 
        
           |  |  | 952 | 		// uncompress the file (currently only 7zip compression)
 | 
        
           | 50 | cycrow | 953 | 		CLog::log(CLog::Log_IO, 1, "* Uncompressing file...");
 | 
        
           | 10 | cycrow | 954 | 		newlen = len;
 | 
        
           |  |  | 955 | 	#ifdef _INCLUDE7ZIP
 | 
        
           |  |  | 956 | 		uncomprData = LZMADecodeData ( data, len, newlen, progress );
 | 
        
           |  |  | 957 | 	#else
 | 
        
           |  |  | 958 | 		uncomprData = LZMADecode_C ( (unsigned char *)data, len, (size_t*)&newlen, NULL );
 | 
        
           |  |  | 959 | 	#endif
 | 
        
           |  |  | 960 | 	}
 | 
        
           |  |  | 961 |   | 
        
           |  |  | 962 | 	*pLen = newlen;
 | 
        
           |  |  | 963 |   | 
        
           | 14 | cycrow | 964 | 	if ( !removeFile.empty() ) {
 | 
        
           | 52 | cycrow | 965 | 		CFileIO::Remove(removeFile);
 | 
        
           | 10 | cycrow | 966 | 	}
 | 
        
           |  |  | 967 |   | 
        
           | 7 | cycrow | 968 | 	return uncomprData;
 | 
        
           |  |  | 969 | }
 | 
        
           |  |  | 970 |   | 
        
           | 8 | cycrow | 971 | Utils::String CSpkFile::_convert_fileEndString(const Utils::String &sFile)
 | 
        
           | 7 | cycrow | 972 | {
 | 
        
           | 10 | cycrow | 973 | 	if ( sFile.Compare("Text") )
 | 
        
           |  |  | 974 | 		return "-- End of Script --";
 | 
        
           |  |  | 975 | 	else if ( sFile.Compare("Uninstall") )
 | 
        
           |  |  | 976 | 		return "-- End of Uninstall --";
 | 
        
           |  |  | 977 | 	else if ( sFile.Compare("Readme") )
 | 
        
           |  |  | 978 | 		return "-- End of Readme --";
 | 
        
           |  |  | 979 | 	else if ( sFile.Compare("Map") )
 | 
        
           |  |  | 980 | 		return "-- End of Map --";
 | 
        
           |  |  | 981 | 	else if ( sFile.Compare("Mod") || sFile.Compare("Extra") || sFile.Compare("Screen") || sFile.Compare("Sound") )
 | 
        
           |  |  | 982 | 		return "";
 | 
        
           |  |  | 983 | 	return "-- End of Script --";
 | 
        
           | 7 | cycrow | 984 | }
 | 
        
           |  |  | 985 |   | 
        
           | 127 | cycrow | 986 | FileType CSpkFile::_convert_fileType(const Utils::String &sFile)
 | 
        
           | 7 | cycrow | 987 | {
 | 
        
           | 10 | cycrow | 988 | 	if ( sFile.Compare("Text") )
 | 
        
           |  |  | 989 | 		return FILETYPE_TEXT;
 | 
        
           |  |  | 990 | 	else if ( sFile.Compare("Uninstall") )
 | 
        
           |  |  | 991 | 		return FILETYPE_UNINSTALL;
 | 
        
           |  |  | 992 | 	else if ( sFile.Compare("Readme") )
 | 
        
           |  |  | 993 | 		return FILETYPE_README;
 | 
        
           |  |  | 994 | 	else if ( sFile.Compare("Map") )
 | 
        
           |  |  | 995 | 		return FILETYPE_MAP;
 | 
        
           |  |  | 996 | 	else if ( sFile.Compare("Mod") )
 | 
        
           |  |  | 997 | 		return FILETYPE_MOD;
 | 
        
           |  |  | 998 | 	else if ( sFile.Compare("Extra") )
 | 
        
           |  |  | 999 | 		return FILETYPE_EXTRA;
 | 
        
           |  |  | 1000 | 	else if ( sFile.Compare("Screen") )
 | 
        
           |  |  | 1001 | 		return FILETYPE_SCREEN;
 | 
        
           |  |  | 1002 | 	else if ( sFile.Compare("Sound") )
 | 
        
           |  |  | 1003 | 		return FILETYPE_SOUND;
 | 
        
           |  |  | 1004 |   | 
        
           |  |  | 1005 | 	return FILETYPE_SCRIPT;
 | 
        
           | 7 | cycrow | 1006 | }
 | 
        
           |  |  | 1007 |   | 
        
           | 10 | cycrow | 1008 | void CSpkFile::_convert_parse(const Utils::String &sCmd, const Utils::String &sRest)
 | 
        
           | 7 | cycrow | 1009 | {
 | 
        
           | 10 | cycrow | 1010 | 	if ( sCmd == "Name:" )
 | 
        
           |  |  | 1011 | 	{
 | 
        
           | 50 | cycrow | 1012 | 		this->setName ( sRest );
 | 
        
           |  |  | 1013 | 		CLog::logf(CLog::Log_EditPackage, 3, "\tScript Name: %s", sRest.c_str() );
 | 
        
           | 10 | cycrow | 1014 | 	}
 | 
        
           |  |  | 1015 | 	else if ( sCmd == "Author:" )
 | 
        
           |  |  | 1016 | 	{
 | 
        
           | 50 | cycrow | 1017 | 		this->setAuthor(sRest);
 | 
        
           |  |  | 1018 | 		CLog::logf(CLog::Log_EditPackage, 3, "\tScript Author: %s", sRest.c_str() );
 | 
        
           | 10 | cycrow | 1019 | 	}
 | 
        
           |  |  | 1020 | 	else if ( sCmd == "CustomStart" )
 | 
        
           |  |  | 1021 | 	{
 | 
        
           |  |  | 1022 | 		this->SetCustomStart();
 | 
        
           | 50 | cycrow | 1023 | 		CLog::logf(CLog::Log_EditPackage, 3, "\tPackage is a custom start!!" );
 | 
        
           | 10 | cycrow | 1024 | 	}
 | 
        
           |  |  | 1025 | 	else if ( sCmd == "AnotherMod:" )
 | 
        
           |  |  | 1026 | 	{
 | 
        
           |  |  | 1027 | 		this->SetAnotherMod(sRest.token("|", 1), sRest.tokens("|", 2));
 | 
        
           | 50 | cycrow | 1028 | 		CLog::logf(CLog::Log_EditPackage, 3, "\tFor another Mod, Name: %s, Author: %s", this->GetOtherName().c_str(), this->GetOtherAuthor().c_str() );
 | 
        
           | 10 | cycrow | 1029 | 	}
 | 
        
           |  |  | 1030 | 	else if ( sCmd == "PATCH" )
 | 
        
           |  |  | 1031 | 	{
 | 
        
           |  |  | 1032 | 		this->SetPatch();
 | 
        
           | 50 | cycrow | 1033 | 		CLog::logf(CLog::Log_EditPackage, 3, "\tPackage is a Patch Mod!!" );
 | 
        
           | 10 | cycrow | 1034 | 	}
 | 
        
           |  |  | 1035 | 	else if ( sCmd == "Version:" )
 | 
        
           |  |  | 1036 | 	{
 | 
        
           | 50 | cycrow | 1037 | 		this->setVersion(sRest);
 | 
        
           |  |  | 1038 | 		CLog::logf(CLog::Log_EditPackage, 3,"\tScript Version: %s", sRest.c_str() );
 | 
        
           | 10 | cycrow | 1039 | 	}
 | 
        
           |  |  | 1040 | 	else if ( sCmd == "Date:" )
 | 
        
           |  |  | 1041 | 	{
 | 
        
           | 50 | cycrow | 1042 | 		this->setCreationDate ( sRest );
 | 
        
           |  |  | 1043 | 		CLog::logf(CLog::Log_EditPackage, 3,"\tScript Creation Date: %s", sRest.c_str() );
 | 
        
           | 10 | cycrow | 1044 | 	}
 | 
        
           | 48 | cycrow | 1045 | 	else if ( sCmd == "Desc:" ) {
 | 
        
           |  |  | 1046 | 		this->setDescription(sRest.findReplace("<br>", "\n") );
 | 
        
           | 50 | cycrow | 1047 | 		CLog::logf(CLog::Log_EditPackage, 3,"\tScript Description: %s", this->description().c_str() );
 | 
        
           | 10 | cycrow | 1048 | 	}
 | 
        
           | 49 | cycrow | 1049 | 	else if ( sCmd == "WebAddress:" ) {
 | 
        
           |  |  | 1050 | 		this->setWebAddress(sRest);
 | 
        
           | 50 | cycrow | 1051 | 		CLog::logf(CLog::Log_EditPackage, 3, "\tWeb Address: %s", sRest.c_str() );
 | 
        
           | 10 | cycrow | 1052 | 	}
 | 
        
           |  |  | 1053 | 	else if ( sCmd == "WebMirror1:" )
 | 
        
           |  |  | 1054 | 	{
 | 
        
           | 162 | cycrow | 1055 | 		this->addWebMirror(sRest);
 | 
        
           | 50 | cycrow | 1056 | 		CLog::logf(CLog::Log_EditPackage, 3, "\tWeb Mirror Address: %s", sRest.c_str() );
 | 
        
           | 10 | cycrow | 1057 | 	}
 | 
        
           |  |  | 1058 | 	else if ( sCmd == "WebMirror2:" )
 | 
        
           |  |  | 1059 | 	{
 | 
        
           | 162 | cycrow | 1060 | 		this->addWebMirror(sRest);
 | 
        
           | 50 | cycrow | 1061 | 		CLog::logf(CLog::Log_EditPackage, 3, "\tWeb Mirror Address: %s", sRest.c_str() );
 | 
        
           | 10 | cycrow | 1062 | 	}
 | 
        
           |  |  | 1063 |   | 
        
           |  |  | 1064 | 	else if ( sCmd == "ScriptType:" )
 | 
        
           |  |  | 1065 | 		this->SetScriptType (sRest);
 | 
        
           | 49 | cycrow | 1066 | 	else if ( sCmd == "WebSite:" ) {
 | 
        
           |  |  | 1067 | 		this->setWebSite ( sRest );
 | 
        
           | 50 | cycrow | 1068 | 		CLog::logf(CLog::Log_EditPackage, 3, "\tWeb Site: %s", sRest.c_str() );
 | 
        
           | 10 | cycrow | 1069 | 	}
 | 
        
           | 49 | cycrow | 1070 | 	else if ( sCmd == "Email:" ) {
 | 
        
           |  |  | 1071 | 		this->setEmail(sRest);
 | 
        
           | 50 | cycrow | 1072 | 		CLog::logf(CLog::Log_EditPackage, 3, "\tAuthor Email Address: %s", sRest.c_str() );
 | 
        
           | 10 | cycrow | 1073 | 	}
 | 
        
           |  |  | 1074 | 	else if ( sCmd == "GameVersion:" )
 | 
        
           |  |  | 1075 | 	{
 | 
        
           |  |  | 1076 | 		//TODO: fix this for new game version
 | 
        
           |  |  | 1077 | 		/*
 | 
        
           |  |  | 1078 | 		int version = sRest.ToInt();
 | 
        
           |  |  | 1079 | 		if ( version == 0 )
 | 
        
           |  |  | 1080 | 			this->SetGameVersion ( 1 );
 | 
        
           |  |  | 1081 | 		else if (version == 1 )
 | 
        
           |  |  | 1082 | 			this->SetGameVersion ( 0 );
 | 
        
           |  |  | 1083 | 		else
 | 
        
           |  |  | 1084 | 			this->SetGameVersion ( version );
 | 
        
           |  |  | 1085 | 		CLog::logf(CLog::Log_EditPackage, "\tGame Version: %d", this->GetGameVersion () );
 | 
        
           |  |  | 1086 | 		*/
 | 
        
           |  |  | 1087 | 	}
 | 
        
           |  |  | 1088 |   | 
        
           |  |  | 1089 | 	else if ( sCmd == "Ware:" )
 | 
        
           |  |  | 1090 | 	{
 | 
        
           |  |  | 1091 | 		this->AddWare ( sRest );
 | 
        
           | 50 | cycrow | 1092 | 		CLog::logf(CLog::Log_EditPackage, 3, "\tAdding Custom Ware" );
 | 
        
           | 10 | cycrow | 1093 | 	}
 | 
        
           |  |  | 1094 | 	else if ( sCmd == "WareText:" )
 | 
        
           | 197 | cycrow | 1095 | 		this->addWareText ( sRest );
 | 
        
           | 46 | cycrow | 1096 | 	else if ( sCmd == "UninstallAfter:" )	this->addUninstallText(sRest.token(" ", 1).toLong(), false, sRest.tokens(" ", 2));
 | 
        
           |  |  | 1097 | 	else if ( sCmd == "UninstallBefore:" )	this->addUninstallText(sRest.token(" ", 1).toLong(), true, sRest.tokens(" ", 2));
 | 
        
           |  |  | 1098 | 	else if ( sCmd == "InstallAfter:" )		this->addInstallText(sRest.token(" ", 1).toLong(), false, sRest.tokens(" ", 2));
 | 
        
           |  |  | 1099 | 	else if ( sCmd == "InstallBefore:" )	this->addInstallText(sRest.token(" ", 1).toLong(), true, sRest.tokens(" ", 2));
 | 
        
           | 10 | cycrow | 1100 | 	else if ( sCmd == "ScriptName:" )
 | 
        
           |  |  | 1101 | 	{
 | 
        
           |  |  | 1102 | 		Utils::String lang = sRest.token(":", 1);
 | 
        
           |  |  | 1103 | 		Utils::String name = sRest.tokens(":", 2);
 | 
        
           | 170 | cycrow | 1104 | 		this->addName(lang.toLong(), name);
 | 
        
           | 50 | cycrow | 1105 | 		CLog::logf(CLog::Log_EditPackage, 3, "\tScript Name Language (%s) %s", lang.c_str(), name.c_str() );
 | 
        
           | 10 | cycrow | 1106 | 	}
 | 
        
           | 7 | cycrow | 1107 | }
 | 
        
           |  |  | 1108 |   | 
        
           | 8 | cycrow | 1109 | Utils::String CSpkFile::_convert_parseFilename(const Utils::String &sRest, float fVersion, Utils::String *pDir)
 | 
        
           | 7 | cycrow | 1110 | {
 | 
        
           | 8 | cycrow | 1111 | 	Utils::String sFilename;
 | 
        
           | 7 | cycrow | 1112 |   | 
        
           | 10 | cycrow | 1113 | 	if ( fVersion >= 3.00f )
 | 
        
           |  |  | 1114 | 		sFilename = sRest.tokens(" ", 3);
 | 
        
           |  |  | 1115 | 	else if ( fVersion >= 2.00f )
 | 
        
           |  |  | 1116 | 		sFilename = sRest.tokens(" ", 2);
 | 
        
           |  |  | 1117 | 	else
 | 
        
           |  |  | 1118 | 		sFilename = sRest;
 | 
        
           |  |  | 1119 |   | 
        
           |  |  | 1120 | 	if ( sFilename.isin("<br>") ) {
 | 
        
           |  |  | 1121 | 		sFilename = sFilename.findReplace("<br>", "|");
 | 
        
           |  |  | 1122 | 		if ( sFilename[0] == '|' ) {
 | 
        
           |  |  | 1123 | 			sFilename = sFilename.token("|", 1);
 | 
        
           |  |  | 1124 | 		}
 | 
        
           |  |  | 1125 | 		else {
 | 
        
           |  |  | 1126 | 			*pDir = sFilename.token("|", 1);
 | 
        
           |  |  | 1127 | 			sFilename = sFilename.tokens("|", 2);
 | 
        
           |  |  | 1128 | 		}
 | 
        
           |  |  | 1129 | 	}
 | 
        
           |  |  | 1130 |   | 
        
           |  |  | 1131 | 	return sFilename;
 | 
        
           | 7 | cycrow | 1132 | }
 | 
        
           |  |  | 1133 |   | 
        
           | 10 | cycrow | 1134 | unsigned char *CSpkFile::_convert_parseFile(const Utils::String &sCmd, const Utils::String &sRest, float fVersion, unsigned char *d)
 | 
        
           | 7 | cycrow | 1135 | {
 | 
        
           | 10 | cycrow | 1136 | 	bool bShared = (sCmd.left(9) == "$$$Shared") ? true : false;
 | 
        
           |  |  | 1137 | 	Utils::String sFile = sCmd.right(-3).left(-1);
 | 
        
           |  |  | 1138 | 	Utils::String sEnd = this->_convert_fileEndString(sFile);
 | 
        
           | 127 | cycrow | 1139 | 	FileType iType = this->_convert_fileType(sFile);
 | 
        
           | 10 | cycrow | 1140 |   | 
        
           |  |  | 1141 | 	// convert the filename and directory
 | 
        
           |  |  | 1142 | 	Utils::String dir, filename = _convert_parseFilename(sRest, fVersion, &dir);
 | 
        
           |  |  | 1143 |   | 
        
           |  |  | 1144 | 	// get the size and time
 | 
        
           |  |  | 1145 | 	long time = 0, size = 0;
 | 
        
           |  |  | 1146 | 	if ( fVersion >= 2.00f ) time = sRest.token(" ", 1).toLong();
 | 
        
           |  |  | 1147 | 	if ( fVersion >= 3.00f ) size = sRest.token(" ", 2).toLong();
 | 
        
           | 196 | cycrow | 1148 | 	bool binaryRead = (CFileIO(filename).isFileExtension(L"PCK")) ? true : false;
 | 
        
           | 10 | cycrow | 1149 | 	if ( sEnd.empty() ) binaryRead = true;
 | 
        
           |  |  | 1150 |   | 
        
           |  |  | 1151 | 	C_File *file = new C_File ();
 | 
        
           |  |  | 1152 |   | 
        
           | 50 | cycrow | 1153 | 	if ( bShared )	CLog::logf(CLog::Log_File, 2, "\tFound %s File (Shared): %s, Reading...", sFile.c_str(), filename.c_str() );
 | 
        
           |  |  | 1154 | 	else			CLog::logf(CLog::Log_File, 2, "\tFound %s File: %s, Reading...", sFile.c_str(), filename.c_str() );
 | 
        
           | 10 | cycrow | 1155 |   | 
        
           |  |  | 1156 | 	// read the data
 | 
        
           |  |  | 1157 | 	if ( binaryRead )
 | 
        
           |  |  | 1158 | 	{
 | 
        
           |  |  | 1159 | 		file->ReadFromData ( (char *)d, size );
 | 
        
           |  |  | 1160 | 		d += size;
 | 
        
           |  |  | 1161 | 	}
 | 
        
           |  |  | 1162 | 	else
 | 
        
           |  |  | 1163 | 	{
 | 
        
           | 14 | cycrow | 1164 | 		Utils::String readData;
 | 
        
           | 10 | cycrow | 1165 | 		d = LineByLineRead ( d, sEnd, &readData );
 | 
        
           | 14 | cycrow | 1166 | 		file->ReadFromData ( (char *)readData.c_str(), (long)readData.length() );
 | 
        
           | 10 | cycrow | 1167 | 	}
 | 
        
           |  |  | 1168 |   | 
        
           |  |  | 1169 | 	// setup the file
 | 
        
           | 178 | cycrow | 1170 | 	file->setName ( filename );
 | 
        
           | 127 | cycrow | 1171 | 	file->setFileType(iType);
 | 
        
           | 10 | cycrow | 1172 | 	file->SetShared ( bShared );
 | 
        
           |  |  | 1173 | 	file->SetCreationTime ( time );
 | 
        
           |  |  | 1174 | 	if ( !dir.empty() )
 | 
        
           | 178 | cycrow | 1175 | 		file->setDir ( dir );
 | 
        
           | 10 | cycrow | 1176 |   | 
        
           |  |  | 1177 | 	this->AddFile ( file );
 | 
        
           |  |  | 1178 |   | 
        
           | 134 | cycrow | 1179 | 	CLog::logf(CLog::Log_File, 3, "Size: %s", file->dataSizeString().c_str() );
 | 
        
           | 10 | cycrow | 1180 |   | 
        
           |  |  | 1181 | 	return d;
 | 
        
           | 7 | cycrow | 1182 | }
 | 
        
           |  |  | 1183 |   | 
        
           | 9 | cycrow | 1184 | CSpkFile *CSpkFile::convertFromOld(const Utils::String &sOldFilename)
 | 
        
           |  |  | 1185 | {
 | 
        
           |  |  | 1186 | 	// check if the old file is actually in an old format
 | 
        
           | 10 | cycrow | 1187 | 	int ret = CBaseFile::CheckFile ( sOldFilename );
 | 
        
           |  |  | 1188 | 	if ( ret != SPKFILE_INVALID && ret != SPKFILE_OLD ) {
 | 
        
           |  |  | 1189 | 		return NULL;
 | 
        
           |  |  | 1190 |  	}
 | 
        
           |  |  | 1191 |   | 
        
           |  |  | 1192 | 	CSpkFile *pSpkFile = new CSpkFile();
 | 
        
           |  |  | 1193 | 	if ( !pSpkFile->convertOld(sOldFilename) ) {
 | 
        
           |  |  | 1194 | 		delete pSpkFile;
 | 
        
           |  |  | 1195 | 		return NULL;
 | 
        
           |  |  | 1196 | 	}
 | 
        
           |  |  | 1197 |   | 
        
           |  |  | 1198 | 	return pSpkFile;
 | 
        
           | 9 | cycrow | 1199 | }
 | 
        
           |  |  | 1200 |   | 
        
           | 8 | cycrow | 1201 | bool CSpkFile::convertOld(const Utils::String &sOldFilename)
 | 
        
           | 7 | cycrow | 1202 | {
 | 
        
           |  |  | 1203 | 	// check if the old file is actually in an old format
 | 
        
           | 10 | cycrow | 1204 | 	int ret = CBaseFile::CheckFile ( sOldFilename );
 | 
        
           |  |  | 1205 | 	if ( ret != SPKFILE_INVALID && ret != SPKFILE_OLD ) {
 | 
        
           |  |  | 1206 | 		return false;
 | 
        
           |  |  | 1207 |  	}
 | 
        
           |  |  | 1208 |   | 
        
           |  |  | 1209 | 	//uncomress the data
 | 
        
           |  |  | 1210 | 	int len;
 | 
        
           |  |  | 1211 | 	unsigned char *uncomprData = this->_convert_uncompressFile(sOldFilename, &len);
 | 
        
           |  |  | 1212 |   | 
        
           |  |  | 1213 | 	// uncomressed failed
 | 
        
           |  |  | 1214 | 	if ( !uncomprData ) {
 | 
        
           | 50 | cycrow | 1215 | 		CLog::log(CLog::Log_IO, 1, "Error: Unable to uncompress the file");
 | 
        
           | 10 | cycrow | 1216 | 		return false;
 | 
        
           |  |  | 1217 | 	}
 | 
        
           |  |  | 1218 |   | 
        
           |  |  | 1219 | 	// now we can read the data
 | 
        
           |  |  | 1220 | 	unsigned char *d = uncomprData;
 | 
        
           |  |  | 1221 | 	Utils::String str;
 | 
        
           |  |  | 1222 |   | 
        
           |  |  | 1223 | //	CMultiSpkFile *mspk = NULL;
 | 
        
           |  |  | 1224 | 	//SMultiSpkFile *cur_mspk = NULL;
 | 
        
           |  |  | 1225 |   | 
        
           |  |  | 1226 | 	int numscripts = 0, curscript = 0;
 | 
        
           |  |  | 1227 | 	float fVersion = 1;
 | 
        
           |  |  | 1228 |   | 
        
           | 50 | cycrow | 1229 | 	CLog::log(CLog::Log_IO, 1, "* Reading spk data...");
 | 
        
           | 10 | cycrow | 1230 | 	while ( d )
 | 
        
           |  |  | 1231 | 	{
 | 
        
           |  |  | 1232 | 		// read the next line
 | 
        
           |  |  | 1233 | 		d = str.readToEndOfLine(d);
 | 
        
           |  |  | 1234 | 		if ( !d || d[0] == 0 ) {
 | 
        
           |  |  | 1235 | 			break;
 | 
        
           |  |  | 1236 | 		}
 | 
        
           |  |  | 1237 | 		if ( str.empty() ) {
 | 
        
           |  |  | 1238 | 			continue;
 | 
        
           |  |  | 1239 | 		}
 | 
        
           |  |  | 1240 |   | 
        
           |  |  | 1241 | 		Utils::String sCmd = str.token(" ", 1);
 | 
        
           |  |  | 1242 |   | 
        
           |  |  | 1243 | 		//TODO: split this into CMultiSpkFile
 | 
        
           |  |  | 1244 | 		/*
 | 
        
           |  |  | 1245 | 		if ( first == "MultiPackage:" )
 | 
        
           |  |  | 1246 | 			mspk = new CMultiSpkFile;
 | 
        
           |  |  | 1247 | 		else if ( (first == "SelectScript:") && (mspk) )
 | 
        
           |  |  | 1248 | 		{
 | 
        
           |  |  | 1249 | 			mspk->AddFileEntry ( rest.GetToken ( 2, -1, ' ' ) + ".spk" );
 | 
        
           |  |  | 1250 | 			++numscripts;
 | 
        
           |  |  | 1251 | 		}
 | 
        
           |  |  | 1252 | 		else if ( (str == "AllowSelection") && (mspk) )
 | 
        
           |  |  | 1253 | 			mspk->SetSelection ( true );
 | 
        
           |  |  | 1254 | 		else if ( str == "-- Start New Script --" )
 | 
        
           |  |  | 1255 | 		{
 | 
        
           |  |  | 1256 | 			if ( !mspk )
 | 
        
           |  |  | 1257 | 			{
 | 
        
           |  |  | 1258 | 				printf ( "Invalid file format, seems to be multi package file but isn't\n" );
 | 
        
           |  |  | 1259 | 				CLEANUP
 | 
        
           |  |  | 1260 | 				exit ( 0 );
 | 
        
           |  |  | 1261 | 			}
 | 
        
           |  |  | 1262 | 			cur_mspk = mspk->GetFileList()->Get ( curscript );
 | 
        
           |  |  | 1263 | 			++curscript;
 | 
        
           |  |  | 1264 | 			cur_mspk->pFile = new CSpkFile;
 | 
        
           |  |  | 1265 | 			spkfile = (CSpkFile *)cur_mspk->pFile;
 | 
        
           |  |  | 1266 | 		}
 | 
        
           |  |  | 1267 | 		*/
 | 
        
           |  |  | 1268 | 		Utils::String sRest = str.tokens(" ", 2);
 | 
        
           |  |  | 1269 | 		if ( sCmd == "Packager:" ) {
 | 
        
           |  |  | 1270 | 			fVersion = sRest;
 | 
        
           | 50 | cycrow | 1271 | 			CLog::logf(CLog::Log_Read, 3, "\tPackager Version: %.2f", fVersion );
 | 
        
           | 10 | cycrow | 1272 | 		}
 | 
        
           |  |  | 1273 | 		else if ( sCmd == "Icon:" )
 | 
        
           |  |  | 1274 | 		{
 | 
        
           |  |  | 1275 | 			long size = sRest.token(" ", 1);
 | 
        
           |  |  | 1276 | 			Utils::String ext = sRest.token(" ", 2);
 | 
        
           |  |  | 1277 |   | 
        
           |  |  | 1278 | 			C_File *file = new C_File ();
 | 
        
           |  |  | 1279 | 			file->ReadFromData ( (char *)d, size );
 | 
        
           |  |  | 1280 |   | 
        
           |  |  | 1281 | 			d += size;
 | 
        
           |  |  | 1282 |   | 
        
           | 170 | cycrow | 1283 | 			this->setIcon(file, ext);
 | 
        
           | 10 | cycrow | 1284 |   | 
        
           | 134 | cycrow | 1285 | 			CLog::logf(CLog::Log_File, 3, "\tIcon (%s) Size: %s", ext.c_str(), file->dataSizeString ().c_str() );
 | 
        
           | 10 | cycrow | 1286 | 		}
 | 
        
           |  |  | 1287 | 		else if ( sCmd.left(3) == "$$$" )
 | 
        
           |  |  | 1288 | 			d = _convert_parseFile(sCmd, sRest, fVersion, d);
 | 
        
           |  |  | 1289 | 		else {
 | 
        
           |  |  | 1290 | 			this->_convert_parse(sCmd, sRest);
 | 
        
           |  |  | 1291 | 		}
 | 
        
           |  |  | 1292 | 	}
 | 
        
           |  |  | 1293 |   | 
        
           | 50 | cycrow | 1294 | 	CLog::logf(CLog::Log_IO, 1, "* Reading spk data..." );
 | 
        
           | 10 | cycrow | 1295 |   | 
        
           | 7 | cycrow | 1296 | 	return true;
 | 
        
           |  |  | 1297 | }
 |