| 6 | 
           cycrow | 
           1 | 
           // SpkFile.cpp: implementation of the CSpkFile class.
  | 
        
        
            | 
            | 
           2 | 
           //
  | 
        
        
            | 
            | 
           3 | 
           //////////////////////////////////////////////////////////////////////
  | 
        
        
            | 
            | 
           4 | 
              | 
        
        
            | 
            | 
           5 | 
           #include "BaseFile.h"
  | 
        
        
            | 
            | 
           6 | 
              | 
        
        
            | 
            | 
           7 | 
           //////////////////////////////////////////////////////////////////////
  | 
        
        
            | 
            | 
           8 | 
           // Construction/Destruction
  | 
        
        
            | 
            | 
           9 | 
           //////////////////////////////////////////////////////////////////////
  | 
        
        
            | 
            | 
           10 | 
              | 
        
        
            | 
            | 
           11 | 
           #include "spk.h"
  | 
        
        
            | 
            | 
           12 | 
              | 
        
        
            | 
            | 
           13 | 
           #include "DirIO.h"
  | 
        
        
            | 
            | 
           14 | 
           #include "File_IO.h"
  | 
        
        
            | 
            | 
           15 | 
           #include "CatFile.h"
  | 
        
        
            | 
            | 
           16 | 
           #include "Packages.h"
  | 
        
        
           | 88 | 
           cycrow | 
           17 | 
           #include "TextDB.h"
  | 
        
        
           | 6 | 
           cycrow | 
           18 | 
              | 
        
        
           | 46 | 
           cycrow | 
           19 | 
           #include <Package/InstallText.h>
  | 
        
        
           | 6 | 
           cycrow | 
           20 | 
              | 
        
        
           | 46 | 
           cycrow | 
           21 | 
           // remove these eventually
  | 
        
        
            | 
            | 
           22 | 
           using namespace SPK;
  | 
        
        
            | 
            | 
           23 | 
           using namespace Package;
  | 
        
        
           | 6 | 
           cycrow | 
           24 | 
              | 
        
        
            | 
            | 
           25 | 
           CArchiveFile::~CArchiveFile()
  | 
        
        
            | 
            | 
           26 | 
           {
  | 
        
        
            | 
            | 
           27 | 
           	Delete ();
  | 
        
        
            | 
            | 
           28 | 
           }
  | 
        
        
            | 
            | 
           29 | 
              | 
        
        
            | 
            | 
           30 | 
           CArchiveFile::CArchiveFile() : CBaseFile ()
  | 
        
        
            | 
            | 
           31 | 
           {
  | 
        
        
            | 
            | 
           32 | 
           	SetDefaults ();
  | 
        
        
            | 
            | 
           33 | 
           }
  | 
        
        
            | 
            | 
           34 | 
              | 
        
        
            | 
            | 
           35 | 
           void CBaseFile::SetDefaults ()
  | 
        
        
            | 
            | 
           36 | 
           {
  | 
        
        
           | 46 | 
           cycrow | 
           37 | 
           	_setDefaults();
  | 
        
        
            | 
            | 
           38 | 
              | 
        
        
           | 6 | 
           cycrow | 
           39 | 
           	m_pIconFile = NULL;
  | 
        
        
            | 
            | 
           40 | 
              | 
        
        
            | 
            | 
           41 | 
           	m_bAutoGenerateUpdateFile = false;
  | 
        
        
            | 
            | 
           42 | 
           	m_SHeader.iValueCompression = SPKCOMPRESS_ZLIB;
  | 
        
        
            | 
            | 
           43 | 
           	m_SHeader2.iFileCompression = SPKCOMPRESS_ZLIB;
  | 
        
        
            | 
            | 
           44 | 
           	m_SHeader2.iDataCompression = SPKCOMPRESS_LZMA;
  | 
        
        
            | 
            | 
           45 | 
           	m_pParent = NULL;
  | 
        
        
           | 50 | 
           cycrow | 
           46 | 
           	_changed();
  | 
        
        
           | 6 | 
           cycrow | 
           47 | 
           	m_bUpdate = false;
  | 
        
        
           | 130 | 
           cycrow | 
           48 | 
           	_bCombineFiles = false;
  | 
        
        
           | 6 | 
           cycrow | 
           49 | 
              | 
        
        
            | 
            | 
           50 | 
           	ClearError();
  | 
        
        
            | 
            | 
           51 | 
              | 
        
        
            | 
            | 
           52 | 
           	m_iLoadError = 0;
  | 
        
        
            | 
            | 
           53 | 
              | 
        
        
            | 
            | 
           54 | 
           	m_bFullyLoaded = false;
  | 
        
        
            | 
            | 
           55 | 
           	m_bSigned = false;
  | 
        
        
            | 
            | 
           56 | 
           	m_bEnable = m_bGlobal = m_bProfile = m_bModifiedEnabled = true;
  | 
        
        
            | 
            | 
           57 | 
           	m_bOverrideFiles = false;
  | 
        
        
            | 
            | 
           58 | 
           }
  | 
        
        
            | 
            | 
           59 | 
              | 
        
        
           | 88 | 
           cycrow | 
           60 | 
           CBaseFile::CBaseFile() : _pTextDB(NULL)
  | 
        
        
           | 6 | 
           cycrow | 
           61 | 
           {
  | 
        
        
            | 
            | 
           62 | 
           	SetDefaults ();
  | 
        
        
            | 
            | 
           63 | 
           }
  | 
        
        
            | 
            | 
           64 | 
           CBaseFile::~CBaseFile()
  | 
        
        
            | 
            | 
           65 | 
           {
  | 
        
        
            | 
            | 
           66 | 
           	Delete();
  | 
        
        
            | 
            | 
           67 | 
           }
  | 
        
        
            | 
            | 
           68 | 
              | 
        
        
           | 170 | 
           cycrow | 
           69 | 
              | 
        
        
           | 203 | 
           cycrow | 
           70 | 
           Utils::WString CBaseFile::getFullPackageName(int language, const Utils::WString &byString) const
  | 
        
        
           | 170 | 
           cycrow | 
           71 | 
           { 
  | 
        
        
            | 
            | 
           72 | 
           	return getFullPackageName(language, true, byString); 
  | 
        
        
            | 
            | 
           73 | 
           }
  | 
        
        
           | 203 | 
           cycrow | 
           74 | 
           Utils::WString CBaseFile::getFullPackageName(int language, bool includeVersion, const Utils::WString &byString) const
  | 
        
        
           | 170 | 
           cycrow | 
           75 | 
           {
  | 
        
        
           | 203 | 
           cycrow | 
           76 | 
           	Utils::WString p = this->name(language);
  | 
        
        
           | 170 | 
           cycrow | 
           77 | 
           	if (includeVersion)
  | 
        
        
            | 
            | 
           78 | 
           	{
  | 
        
        
           | 203 | 
           cycrow | 
           79 | 
           		p += L" V";
  | 
        
        
           | 204 | 
           cycrow | 
           80 | 
           		p += this->version();
  | 
        
        
           | 170 | 
           cycrow | 
           81 | 
           	}
  | 
        
        
           | 203 | 
           cycrow | 
           82 | 
           	p += L" ";
  | 
        
        
            | 
            | 
           83 | 
           	p += byString + L" " + this->author();
  | 
        
        
           | 170 | 
           cycrow | 
           84 | 
           	return p;
  | 
        
        
            | 
            | 
           85 | 
           }
  | 
        
        
            | 
            | 
           86 | 
              | 
        
        
           | 203 | 
           cycrow | 
           87 | 
           Utils::WString CBaseFile::getFullPackageName(const Utils::WString &format, int lang) const
  | 
        
        
           | 170 | 
           cycrow | 
           88 | 
           {
  | 
        
        
            | 
            | 
           89 | 
           	if (format.empty())
  | 
        
        
            | 
            | 
           90 | 
           		return getFullPackageName(lang);
  | 
        
        
            | 
            | 
           91 | 
              | 
        
        
           | 204 | 
           cycrow | 
           92 | 
           	Utils::WString args[3] = { this->name(lang), this->version(), this->author() };
  | 
        
        
           | 170 | 
           cycrow | 
           93 | 
           	return format.args(args, 3);
  | 
        
        
            | 
            | 
           94 | 
           }
  | 
        
        
            | 
            | 
           95 | 
              | 
        
        
           | 6 | 
           cycrow | 
           96 | 
           void CBaseFile::Delete ()
  | 
        
        
            | 
            | 
           97 | 
           {
  | 
        
        
           | 170 | 
           cycrow | 
           98 | 
           	m_lTempFiles.clear();
  | 
        
        
           | 6 | 
           cycrow | 
           99 | 
           	m_lFiles.clear(true);
  | 
        
        
            | 
            | 
           100 | 
              | 
        
        
            | 
            | 
           101 | 
           	if ( m_pIconFile )
  | 
        
        
            | 
            | 
           102 | 
           	{
  | 
        
        
            | 
            | 
           103 | 
           		delete m_pIconFile;
  | 
        
        
            | 
            | 
           104 | 
           		m_pIconFile = NULL;
  | 
        
        
            | 
            | 
           105 | 
           	}
  | 
        
        
            | 
            | 
           106 | 
              | 
        
        
           | 88 | 
           cycrow | 
           107 | 
           	if ( _pTextDB ) {
  | 
        
        
            | 
            | 
           108 | 
           		delete _pTextDB;
  | 
        
        
            | 
            | 
           109 | 
           		_pTextDB = NULL;
  | 
        
        
            | 
            | 
           110 | 
           	}
  | 
        
        
           | 6 | 
           cycrow | 
           111 | 
           }
  | 
        
        
            | 
            | 
           112 | 
              | 
        
        
            | 
            | 
           113 | 
              | 
        
        
            | 
            | 
           114 | 
           /*
  | 
        
        
            | 
            | 
           115 | 
           ##########################################################################################
  | 
        
        
            | 
            | 
           116 | 
           ##################                Base Class Functions                  ##################
  | 
        
        
            | 
            | 
           117 | 
           ##########################################################################################
  | 
        
        
            | 
            | 
           118 | 
           */
  | 
        
        
            | 
            | 
           119 | 
              | 
        
        
           | 170 | 
           cycrow | 
           120 | 
           const CLinkList<C_File> &CBaseFile::fileList() const
  | 
        
        
           | 131 | 
           cycrow | 
           121 | 
           {
  | 
        
        
           | 170 | 
           cycrow | 
           122 | 
           	return m_lFiles;
  | 
        
        
           | 131 | 
           cycrow | 
           123 | 
           }
  | 
        
        
           | 170 | 
           cycrow | 
           124 | 
           CLinkList<C_File> &CBaseFile::fileList(FileType type, CLinkList<C_File>& list) const
  | 
        
        
            | 
            | 
           125 | 
           { 
  | 
        
        
            | 
            | 
           126 | 
           	for (CListNode<C_File>* node = m_lFiles.Front(); node; node = node->next())
  | 
        
        
           | 6 | 
           cycrow | 
           127 | 
           	{
  | 
        
        
           | 170 | 
           cycrow | 
           128 | 
           		C_File* f = node->Data();
  | 
        
        
            | 
            | 
           129 | 
           		if (f->GetFileType() == type)
  | 
        
        
            | 
            | 
           130 | 
           			list.push_back(f);
  | 
        
        
           | 6 | 
           cycrow | 
           131 | 
           	}
  | 
        
        
            | 
            | 
           132 | 
              | 
        
        
            | 
            | 
           133 | 
           	return list;
  | 
        
        
            | 
            | 
           134 | 
           }
  | 
        
        
           | 170 | 
           cycrow | 
           135 | 
           CLinkList<C_File> &CBaseFile::fileList(FileType type)
  | 
        
        
            | 
            | 
           136 | 
           {
  | 
        
        
            | 
            | 
           137 | 
           	m_lTempFiles.clear();
  | 
        
        
            | 
            | 
           138 | 
           	return fileList(type, m_lTempFiles);
  | 
        
        
            | 
            | 
           139 | 
           }
  | 
        
        
           | 6 | 
           cycrow | 
           140 | 
              | 
        
        
           | 13 | 
           cycrow | 
           141 | 
           C_File *CBaseFile::GetNextFile(C_File *prev) const
  | 
        
        
           | 6 | 
           cycrow | 
           142 | 
           {
  | 
        
        
            | 
            | 
           143 | 
           	int type = -1;
  | 
        
        
            | 
            | 
           144 | 
           	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
  | 
        
        
            | 
            | 
           145 | 
           	{
  | 
        
        
            | 
            | 
           146 | 
           		C_File *f = node->Data();
  | 
        
        
            | 
            | 
           147 | 
           		if ( type == -1 )
  | 
        
        
            | 
            | 
           148 | 
           		{
  | 
        
        
            | 
            | 
           149 | 
           			if ( f == prev )
  | 
        
        
            | 
            | 
           150 | 
           				type = f->GetFileType();
  | 
        
        
            | 
            | 
           151 | 
           		}
  | 
        
        
            | 
            | 
           152 | 
           		else
  | 
        
        
            | 
            | 
           153 | 
           		{
  | 
        
        
            | 
            | 
           154 | 
           			if ( f->GetFileType() == type )
  | 
        
        
            | 
            | 
           155 | 
           				return f;
  | 
        
        
            | 
            | 
           156 | 
           		}
  | 
        
        
            | 
            | 
           157 | 
           	}
  | 
        
        
            | 
            | 
           158 | 
              | 
        
        
            | 
            | 
           159 | 
           	return NULL;
  | 
        
        
            | 
            | 
           160 | 
           }
  | 
        
        
            | 
            | 
           161 | 
              | 
        
        
           | 13 | 
           cycrow | 
           162 | 
           C_File *CBaseFile::GetPrevFile(C_File *next) const
  | 
        
        
           | 6 | 
           cycrow | 
           163 | 
           {
  | 
        
        
            | 
            | 
           164 | 
           	if ( !next )
  | 
        
        
            | 
            | 
           165 | 
           		return NULL;
  | 
        
        
            | 
            | 
           166 | 
              | 
        
        
            | 
            | 
           167 | 
           	int type = -1;
  | 
        
        
            | 
            | 
           168 | 
           	for ( CListNode<C_File> *node = m_lFiles.Back(); node; node = node->prev() )
  | 
        
        
            | 
            | 
           169 | 
           	{
  | 
        
        
            | 
            | 
           170 | 
           		C_File *f = node->Data();
  | 
        
        
            | 
            | 
           171 | 
           		if ( type == -1 )
  | 
        
        
            | 
            | 
           172 | 
           		{
  | 
        
        
            | 
            | 
           173 | 
           			if ( f == next )
  | 
        
        
            | 
            | 
           174 | 
           				type = f->GetFileType();
  | 
        
        
            | 
            | 
           175 | 
           		}
  | 
        
        
            | 
            | 
           176 | 
           		else
  | 
        
        
            | 
            | 
           177 | 
           		{
  | 
        
        
            | 
            | 
           178 | 
           			if ( f->GetFileType() == type )
  | 
        
        
            | 
            | 
           179 | 
           				return f;
  | 
        
        
            | 
            | 
           180 | 
           		}
  | 
        
        
            | 
            | 
           181 | 
           	}
  | 
        
        
            | 
            | 
           182 | 
              | 
        
        
            | 
            | 
           183 | 
           	return NULL;
  | 
        
        
            | 
            | 
           184 | 
           }
  | 
        
        
            | 
            | 
           185 | 
              | 
        
        
           | 13 | 
           cycrow | 
           186 | 
           C_File *CBaseFile::GetFirstFile(int type) const
  | 
        
        
           | 6 | 
           cycrow | 
           187 | 
           {
  | 
        
        
            | 
            | 
           188 | 
           	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
  | 
        
        
            | 
            | 
           189 | 
           	{
  | 
        
        
            | 
            | 
           190 | 
           		C_File *f = node->Data();
  | 
        
        
            | 
            | 
           191 | 
           		if ( f->GetFileType() == type )
  | 
        
        
            | 
            | 
           192 | 
           			return f;
  | 
        
        
            | 
            | 
           193 | 
           	}
  | 
        
        
            | 
            | 
           194 | 
              | 
        
        
            | 
            | 
           195 | 
           	return NULL;
  | 
        
        
            | 
            | 
           196 | 
           }
  | 
        
        
            | 
            | 
           197 | 
              | 
        
        
           | 197 | 
           cycrow | 
           198 | 
           int CBaseFile::CheckFile(const Utils::WString &filename, float *version )
  | 
        
        
           | 6 | 
           cycrow | 
           199 | 
           {
  | 
        
        
           | 91 | 
           cycrow | 
           200 | 
           	CFileIO File(filename);
  | 
        
        
            | 
            | 
           201 | 
           	if ( !File.startRead() ) return 0;
  | 
        
        
           | 197 | 
           cycrow | 
           202 | 
           	Utils::String line = File.readEndOfLineStr();
  | 
        
        
           | 51 | 
           cycrow | 
           203 | 
           	Utils::String type = line.token(";", 1);
  | 
        
        
            | 
            | 
           204 | 
           	File.close();
  | 
        
        
           | 6 | 
           cycrow | 
           205 | 
              | 
        
        
            | 
            | 
           206 | 
           	// check for old version
  | 
        
        
           | 51 | 
           cycrow | 
           207 | 
           	if ( line.left(3) == "HiP" ) return SPKFILE_OLD;
  | 
        
        
           | 6 | 
           cycrow | 
           208 | 
              | 
        
        
            | 
            | 
           209 | 
           	// check for format
  | 
        
        
           | 51 | 
           cycrow | 
           210 | 
           	if ( version ) *version = line.token(";", 2);
  | 
        
        
           | 6 | 
           cycrow | 
           211 | 
              | 
        
        
           | 51 | 
           cycrow | 
           212 | 
           	if ( type == "BaseCycrow" )	return SPKFILE_BASE;
  | 
        
        
            | 
            | 
           213 | 
           	if ( type == "SPKCycrow" )	return SPKFILE_SINGLE;
  | 
        
        
            | 
            | 
           214 | 
           	if ( type == "XSPCycrow" )	return SPKFILE_SINGLESHIP;
  | 
        
        
            | 
            | 
           215 | 
           	if ( type == "MSPKCycrow" )	return SPKFILE_MULTI;
  | 
        
        
           | 6 | 
           cycrow | 
           216 | 
           	return SPKFILE_INVALID;
  | 
        
        
            | 
            | 
           217 | 
           }
  | 
        
        
            | 
            | 
           218 | 
              | 
        
        
            | 
            | 
           219 | 
           void CBaseFile::ClearFileData()
  | 
        
        
            | 
            | 
           220 | 
           {
  | 
        
        
           | 88 | 
           cycrow | 
           221 | 
           	for ( CListNode<C_File> *f = m_lFiles.Front(); f; f = f->next() )
  | 
        
        
           | 6 | 
           cycrow | 
           222 | 
           	{
  | 
        
        
           | 88 | 
           cycrow | 
           223 | 
           		f->Data()->DeleteData();
  | 
        
        
           | 6 | 
           cycrow | 
           224 | 
           	}
  | 
        
        
            | 
            | 
           225 | 
           }
  | 
        
        
            | 
            | 
           226 | 
              | 
        
        
           | 197 | 
           cycrow | 
           227 | 
           Utils::WString CBaseFile::getNameValidFile() const
  | 
        
        
           | 6 | 
           cycrow | 
           228 | 
           {
  | 
        
        
           | 197 | 
           cycrow | 
           229 | 
           	Utils::WString name = this->name();
  | 
        
        
           | 130 | 
           cycrow | 
           230 | 
           	name.removeChar(':');
  | 
        
        
            | 
            | 
           231 | 
           	name.removeChar('/');
  | 
        
        
            | 
            | 
           232 | 
           	name.removeChar('\\');
  | 
        
        
            | 
            | 
           233 | 
           	name.removeChar('*');
  | 
        
        
            | 
            | 
           234 | 
           	name.removeChar('?');
  | 
        
        
            | 
            | 
           235 | 
           	name.removeChar('"');
  | 
        
        
            | 
            | 
           236 | 
           	name.removeChar('<');
  | 
        
        
            | 
            | 
           237 | 
           	name.removeChar('>');
  | 
        
        
            | 
            | 
           238 | 
           	name.removeChar('|');
  | 
        
        
            | 
            | 
           239 | 
           	return name;
  | 
        
        
            | 
            | 
           240 | 
           }
  | 
        
        
           | 6 | 
           cycrow | 
           241 | 
              | 
        
        
            | 
            | 
           242 | 
           void CBaseFile::SwitchFilePointer(C_File *oldFile, C_File *newFile)
  | 
        
        
            | 
            | 
           243 | 
           {
  | 
        
        
            | 
            | 
           244 | 
           	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
  | 
        
        
            | 
            | 
           245 | 
           	{
  | 
        
        
            | 
            | 
           246 | 
           		C_File *f = node->Data();
  | 
        
        
            | 
            | 
           247 | 
           		if ( f == oldFile )
  | 
        
        
            | 
            | 
           248 | 
           		{
  | 
        
        
            | 
            | 
           249 | 
           			node->ChangeData(newFile);
  | 
        
        
            | 
            | 
           250 | 
           			break;
  | 
        
        
            | 
            | 
           251 | 
           		}
  | 
        
        
            | 
            | 
           252 | 
           	}
  | 
        
        
            | 
            | 
           253 | 
           }
  | 
        
        
            | 
            | 
           254 | 
              | 
        
        
            | 
            | 
           255 | 
           bool CBaseFile::AnyFileType ( int type )
  | 
        
        
            | 
            | 
           256 | 
           {
  | 
        
        
            | 
            | 
           257 | 
           	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
  | 
        
        
            | 
            | 
           258 | 
           	{
  | 
        
        
            | 
            | 
           259 | 
           		C_File *f = node->Data();
  | 
        
        
            | 
            | 
           260 | 
           		if ( f->GetFileType() == type )
  | 
        
        
            | 
            | 
           261 | 
           			return true;
  | 
        
        
            | 
            | 
           262 | 
           	}
  | 
        
        
            | 
            | 
           263 | 
              | 
        
        
            | 
            | 
           264 | 
           	return false;
  | 
        
        
            | 
            | 
           265 | 
           }
  | 
        
        
            | 
            | 
           266 | 
              | 
        
        
            | 
            | 
           267 | 
           void CBaseFile::AddFile ( C_File *file )
  | 
        
        
            | 
            | 
           268 | 
           {
  | 
        
        
            | 
            | 
           269 | 
           	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
  | 
        
        
            | 
            | 
           270 | 
           	{
  | 
        
        
            | 
            | 
           271 | 
           		C_File *f = node->Data();
  | 
        
        
           | 130 | 
           cycrow | 
           272 | 
           		if ( f->fileType() != file->fileType() )
  | 
        
        
           | 6 | 
           cycrow | 
           273 | 
           			continue;
  | 
        
        
           | 130 | 
           cycrow | 
           274 | 
           		if ( f->name() != file->name () )
  | 
        
        
           | 6 | 
           cycrow | 
           275 | 
           			continue;
  | 
        
        
           | 170 | 
           cycrow | 
           276 | 
           		if ( f->dir() != file->dir() )
  | 
        
        
           | 6 | 
           cycrow | 
           277 | 
           			continue;
  | 
        
        
           | 127 | 
           cycrow | 
           278 | 
           		if ( f->game() != file->game() )
  | 
        
        
           | 6 | 
           cycrow | 
           279 | 
           			continue;
  | 
        
        
            | 
            | 
           280 | 
              | 
        
        
            | 
            | 
           281 | 
           		m_lFiles.remove(node, true);
  | 
        
        
            | 
            | 
           282 | 
           		break;
  | 
        
        
            | 
            | 
           283 | 
           	}
  | 
        
        
            | 
            | 
           284 | 
              | 
        
        
           | 88 | 
           cycrow | 
           285 | 
           	_addFile(file);
  | 
        
        
           | 6 | 
           cycrow | 
           286 | 
           }
  | 
        
        
            | 
            | 
           287 | 
              | 
        
        
           | 197 | 
           cycrow | 
           288 | 
           C_File *CBaseFile::addFile(const Utils::WString &file, const Utils::WString &dir, FileType type, int game, bool packed)
  | 
        
        
           | 127 | 
           cycrow | 
           289 | 
           {
  | 
        
        
            | 
            | 
           290 | 
           	C_File *newfile = new C_File(file);
  | 
        
        
           | 178 | 
           cycrow | 
           291 | 
           	newfile->setDir(dir);
  | 
        
        
           | 130 | 
           cycrow | 
           292 | 
           	newfile->setFileType(type);
  | 
        
        
           | 127 | 
           cycrow | 
           293 | 
           	newfile->setGame(game);
  | 
        
        
           | 6 | 
           cycrow | 
           294 | 
              | 
        
        
           | 155 | 
           cycrow | 
           295 | 
           	if (packed)
  | 
        
        
            | 
            | 
           296 | 
           	{
  | 
        
        
            | 
            | 
           297 | 
           		if (newfile->PCKFile())
  | 
        
        
           | 197 | 
           cycrow | 
           298 | 
           			newfile->setFilename(CFileIO(newfile->filePointer()).changeFileExtension(L"pck"));
  | 
        
        
           | 155 | 
           cycrow | 
           299 | 
           	}
  | 
        
        
            | 
            | 
           300 | 
              | 
        
        
           | 6 | 
           cycrow | 
           301 | 
           	// first check if the file already exists
  | 
        
        
            | 
            | 
           302 | 
           	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
  | 
        
        
            | 
            | 
           303 | 
           	{
  | 
        
        
            | 
            | 
           304 | 
           		C_File *f = node->Data();
  | 
        
        
           | 130 | 
           cycrow | 
           305 | 
           		if ( f->fileType() != newfile->fileType() )
  | 
        
        
           | 6 | 
           cycrow | 
           306 | 
           			continue;
  | 
        
        
           | 130 | 
           cycrow | 
           307 | 
           		if ( f->name() != newfile->name () )
  | 
        
        
           | 6 | 
           cycrow | 
           308 | 
           			continue;
  | 
        
        
           | 134 | 
           cycrow | 
           309 | 
           		if ( f->dir() != newfile->dir() )
  | 
        
        
           | 6 | 
           cycrow | 
           310 | 
           			continue;
  | 
        
        
           | 130 | 
           cycrow | 
           311 | 
           		if (f->game() != newfile->game())
  | 
        
        
            | 
            | 
           312 | 
           		{
  | 
        
        
            | 
            | 
           313 | 
           			//same file, for different game, check if they are the same and combine them
  | 
        
        
            | 
            | 
           314 | 
           			if (_bCombineFiles)
  | 
        
        
            | 
            | 
           315 | 
           			{
  | 
        
        
            | 
            | 
           316 | 
           				char *data = NULL;
  | 
        
        
            | 
            | 
           317 | 
           				char *newData = NULL;
  | 
        
        
            | 
            | 
           318 | 
           				size_t size = 0;
  | 
        
        
            | 
            | 
           319 | 
           				size_t newSize = 0;
  | 
        
        
            | 
            | 
           320 | 
              | 
        
        
            | 
            | 
           321 | 
           				if (f->GetData() && f->GetDataSize())
  | 
        
        
           | 143 | 
           cycrow | 
           322 | 
           					data = (char *)f->UncompressData((long *)&size, NULL);
  | 
        
        
           | 130 | 
           cycrow | 
           323 | 
           				else if(f->isExternalFile())
  | 
        
        
            | 
            | 
           324 | 
           					data = CFileIO(f->filePointer()).ReadToData(&size);
  | 
        
        
            | 
            | 
           325 | 
           				if (newfile->GetData() && newfile->GetDataSize())
  | 
        
        
           | 143 | 
           cycrow | 
           326 | 
           					newData = (char *)f->UncompressData((long *)&newSize, NULL);
  | 
        
        
           | 130 | 
           cycrow | 
           327 | 
           				else
  | 
        
        
            | 
            | 
           328 | 
           					newData = CFileIO(newfile->filePointer()).ReadToData(&newSize);
  | 
        
        
            | 
            | 
           329 | 
              | 
        
        
            | 
            | 
           330 | 
           				// compare bytes
  | 
        
        
            | 
            | 
           331 | 
           				bool matched = false;
  | 
        
        
            | 
            | 
           332 | 
           				if (size == newSize)
  | 
        
        
            | 
            | 
           333 | 
           				{
  | 
        
        
            | 
            | 
           334 | 
           					matched = true;
  | 
        
        
            | 
            | 
           335 | 
           					for (unsigned long i = 0; i < size; ++i)
  | 
        
        
            | 
            | 
           336 | 
           					{
  | 
        
        
            | 
            | 
           337 | 
           						if (data[i] != newData[i])
  | 
        
        
            | 
            | 
           338 | 
           						{
  | 
        
        
            | 
            | 
           339 | 
           							matched = false;
  | 
        
        
            | 
            | 
           340 | 
           							break;
  | 
        
        
            | 
            | 
           341 | 
           						}
  | 
        
        
            | 
            | 
           342 | 
           					}
  | 
        
        
            | 
            | 
           343 | 
           				}
  | 
        
        
            | 
            | 
           344 | 
              | 
        
        
           | 143 | 
           cycrow | 
           345 | 
           				if (data)
  | 
        
        
           | 130 | 
           cycrow | 
           346 | 
           					delete data;
  | 
        
        
           | 143 | 
           cycrow | 
           347 | 
           				if (newData)
  | 
        
        
           | 130 | 
           cycrow | 
           348 | 
           					delete newData;
  | 
        
        
            | 
            | 
           349 | 
              | 
        
        
            | 
            | 
           350 | 
           				if (matched)
  | 
        
        
            | 
            | 
           351 | 
           				{
  | 
        
        
            | 
            | 
           352 | 
           					if(!f->game() || f->game() == GAME_ALLNEW)
  | 
        
        
            | 
            | 
           353 | 
           						newfile->setGame(0);
  | 
        
        
            | 
            | 
           354 | 
           					else
  | 
        
        
            | 
            | 
           355 | 
           						newfile->setGame(newfile->game() | f->game());
  | 
        
        
            | 
            | 
           356 | 
           					m_lFiles.remove(node, true);
  | 
        
        
            | 
            | 
           357 | 
           					break;
  | 
        
        
            | 
            | 
           358 | 
           				}
  | 
        
        
            | 
            | 
           359 | 
           			}
  | 
        
        
           | 6 | 
           cycrow | 
           360 | 
           			continue;
  | 
        
        
           | 130 | 
           cycrow | 
           361 | 
           		}
  | 
        
        
           | 6 | 
           cycrow | 
           362 | 
              | 
        
        
            | 
            | 
           363 | 
           		// must already exist, delete this one
  | 
        
        
            | 
            | 
           364 | 
           		m_lFiles.remove(node, true);
  | 
        
        
            | 
            | 
           365 | 
           		break;
  | 
        
        
            | 
            | 
           366 | 
           	}
  | 
        
        
            | 
            | 
           367 | 
              | 
        
        
           | 88 | 
           cycrow | 
           368 | 
           	_addFile(newfile);
  | 
        
        
           | 6 | 
           cycrow | 
           369 | 
              | 
        
        
            | 
            | 
           370 | 
           	return newfile;
  | 
        
        
            | 
            | 
           371 | 
           }
  | 
        
        
            | 
            | 
           372 | 
              | 
        
        
           | 170 | 
           cycrow | 
           373 | 
           bool CBaseFile::addFileNow(const Utils::String &file, const Utils::String &dir, FileType type, CProgressInfo* progress)
  | 
        
        
           | 6 | 
           cycrow | 
           374 | 
           {
  | 
        
        
           | 170 | 
           cycrow | 
           375 | 
           	C_File* f = addFile(file, dir, type);
  | 
        
        
            | 
            | 
           376 | 
           	if (!f->ReadFromFile())
  | 
        
        
           | 6 | 
           cycrow | 
           377 | 
           		return false;
  | 
        
        
            | 
            | 
           378 | 
              | 
        
        
            | 
            | 
           379 | 
           	// compress the file
  | 
        
        
           | 170 | 
           cycrow | 
           380 | 
           	return f->CompressData(m_SHeader2.iDataCompression, progress);
  | 
        
        
           | 6 | 
           cycrow | 
           381 | 
           }
  | 
        
        
            | 
            | 
           382 | 
              | 
        
        
           | 197 | 
           cycrow | 
           383 | 
           C_File *CBaseFile::appendFile(const Utils::WString &file, int type, int game, bool packed, const Utils::WString &dir, CProgressInfo *progress )
  | 
        
        
           | 6 | 
           cycrow | 
           384 | 
           {
  | 
        
        
           | 155 | 
           cycrow | 
           385 | 
           	C_File *newfile = addFile(file, dir, static_cast<FileType>(type), game, packed);
  | 
        
        
           | 6 | 
           cycrow | 
           386 | 
           	if ( !newfile )
  | 
        
        
            | 
            | 
           387 | 
           		return NULL;
  | 
        
        
            | 
            | 
           388 | 
              | 
        
        
            | 
            | 
           389 | 
           	// read the file into memory
  | 
        
        
           | 155 | 
           cycrow | 
           390 | 
           	if (newfile->GetData() && newfile->GetDataSize())
  | 
        
        
            | 
            | 
           391 | 
           	{
  | 
        
        
            | 
            | 
           392 | 
           		// now compress the file
  | 
        
        
            | 
            | 
           393 | 
           		if (newfile->CompressData(m_SHeader2.iDataCompression, progress))
  | 
        
        
            | 
            | 
           394 | 
           			return newfile;
  | 
        
        
            | 
            | 
           395 | 
           	}
  | 
        
        
           | 6 | 
           cycrow | 
           396 | 
           	if ( newfile->ReadFromFile () )
  | 
        
        
            | 
            | 
           397 | 
           	{
  | 
        
        
            | 
            | 
           398 | 
           		// now compress the file
  | 
        
        
            | 
            | 
           399 | 
           		if ( newfile->CompressData ( m_SHeader2.iDataCompression, progress ) )
  | 
        
        
            | 
            | 
           400 | 
           			return newfile;
  | 
        
        
            | 
            | 
           401 | 
           	}
  | 
        
        
            | 
            | 
           402 | 
           	else if ( newfile->GetLastError() == SPKERR_MALLOC )
  | 
        
        
            | 
            | 
           403 | 
           	{
  | 
        
        
            | 
            | 
           404 | 
           		if ( newfile->CompressFile ( progress ) )
  | 
        
        
            | 
            | 
           405 | 
           			return newfile;
  | 
        
        
            | 
            | 
           406 | 
           	}
  | 
        
        
            | 
            | 
           407 | 
              | 
        
        
            | 
            | 
           408 | 
           	m_lFiles.pop_back ();
  | 
        
        
            | 
            | 
           409 | 
           	delete newfile;
  | 
        
        
            | 
            | 
           410 | 
              | 
        
        
            | 
            | 
           411 | 
           	return NULL;
  | 
        
        
            | 
            | 
           412 | 
           }
  | 
        
        
            | 
            | 
           413 | 
              | 
        
        
           | 170 | 
           cycrow | 
           414 | 
           C_File *CBaseFile::findFileAt(FileType filetype, size_t pos) const
  | 
        
        
           | 6 | 
           cycrow | 
           415 | 
           {
  | 
        
        
           | 170 | 
           cycrow | 
           416 | 
           	size_t count = 0;
  | 
        
        
           | 6 | 
           cycrow | 
           417 | 
           	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
  | 
        
        
            | 
            | 
           418 | 
           	{
  | 
        
        
            | 
            | 
           419 | 
           		C_File *file = node->Data();
  | 
        
        
            | 
            | 
           420 | 
           		if ( file->GetFileType() != filetype )
  | 
        
        
            | 
            | 
           421 | 
           			continue;
  | 
        
        
            | 
            | 
           422 | 
              | 
        
        
            | 
            | 
           423 | 
           		if ( count == pos )
  | 
        
        
            | 
            | 
           424 | 
           			return file;
  | 
        
        
            | 
            | 
           425 | 
              | 
        
        
            | 
            | 
           426 | 
           		++count;
  | 
        
        
            | 
            | 
           427 | 
           	}
  | 
        
        
            | 
            | 
           428 | 
              | 
        
        
            | 
            | 
           429 | 
           	return NULL;
  | 
        
        
            | 
            | 
           430 | 
           }
  | 
        
        
            | 
            | 
           431 | 
              | 
        
        
           | 197 | 
           cycrow | 
           432 | 
           C_File* CBaseFile::findFile(const Utils::WString &filename, FileType type, const Utils::WString &dir, int game) const
  | 
        
        
           | 170 | 
           cycrow | 
           433 | 
           {	
  | 
        
        
           | 197 | 
           cycrow | 
           434 | 
           	Utils::WString lfile = CFileIO(filename.lower()).filename();
  | 
        
        
           | 6 | 
           cycrow | 
           435 | 
              | 
        
        
           | 170 | 
           cycrow | 
           436 | 
           	CListNode<C_File>* node = m_lFiles.Front();
  | 
        
        
            | 
            | 
           437 | 
           	while (node)
  | 
        
        
           | 6 | 
           cycrow | 
           438 | 
           	{
  | 
        
        
           | 170 | 
           cycrow | 
           439 | 
           		C_File* f = node->Data();
  | 
        
        
           | 6 | 
           cycrow | 
           440 | 
           		node = node->next();
  | 
        
        
            | 
            | 
           441 | 
              | 
        
        
           | 170 | 
           cycrow | 
           442 | 
           		if (type != f->GetFileType())
  | 
        
        
           | 6 | 
           cycrow | 
           443 | 
           			continue;
  | 
        
        
           | 170 | 
           cycrow | 
           444 | 
           		if (dir != f->dir())
  | 
        
        
           | 6 | 
           cycrow | 
           445 | 
           			continue;
  | 
        
        
           | 170 | 
           cycrow | 
           446 | 
           		if (game != f->game())
  | 
        
        
           | 6 | 
           cycrow | 
           447 | 
           			continue;
  | 
        
        
           | 170 | 
           cycrow | 
           448 | 
           		if (f->name().lower() == lfile)
  | 
        
        
           | 6 | 
           cycrow | 
           449 | 
           			return f;
  | 
        
        
            | 
            | 
           450 | 
           	}
  | 
        
        
            | 
            | 
           451 | 
           	return NULL;
  | 
        
        
            | 
            | 
           452 | 
           }
  | 
        
        
            | 
            | 
           453 | 
              | 
        
        
           | 170 | 
           cycrow | 
           454 | 
           bool CBaseFile::removeFile(const Utils::String& file, FileType type, const Utils::String& dir, int game)
  | 
        
        
           | 6 | 
           cycrow | 
           455 | 
           {
  | 
        
        
           | 170 | 
           cycrow | 
           456 | 
           	C_File* f = findFile(file, type, dir, game);
  | 
        
        
            | 
            | 
           457 | 
           	if (!f)
  | 
        
        
           | 6 | 
           cycrow | 
           458 | 
           		return false;
  | 
        
        
           | 172 | 
           cycrow | 
           459 | 
           	return removeFile(f);
  | 
        
        
           | 6 | 
           cycrow | 
           460 | 
           }
  | 
        
        
            | 
            | 
           461 | 
              | 
        
        
           | 172 | 
           cycrow | 
           462 | 
           bool CBaseFile::removeFile(C_File *file)
  | 
        
        
           | 6 | 
           cycrow | 
           463 | 
           {
  | 
        
        
           | 172 | 
           cycrow | 
           464 | 
           	size_t count = 0;
  | 
        
        
           | 6 | 
           cycrow | 
           465 | 
           	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
  | 
        
        
            | 
            | 
           466 | 
           	{
  | 
        
        
            | 
            | 
           467 | 
           		C_File *f = node->Data();
  | 
        
        
            | 
            | 
           468 | 
           		if ( f == file )
  | 
        
        
           | 172 | 
           cycrow | 
           469 | 
           			return removeFile(count);
  | 
        
        
           | 6 | 
           cycrow | 
           470 | 
           		++count;
  | 
        
        
            | 
            | 
           471 | 
           	}
  | 
        
        
            | 
            | 
           472 | 
           	return false;
  | 
        
        
            | 
            | 
           473 | 
           }
  | 
        
        
            | 
            | 
           474 | 
              | 
        
        
           | 172 | 
           cycrow | 
           475 | 
           bool CBaseFile::removeFile(size_t pos)
  | 
        
        
           | 6 | 
           cycrow | 
           476 | 
           {
  | 
        
        
           | 172 | 
           cycrow | 
           477 | 
           	if (pos >= static_cast<size_t>(m_lFiles.size()))
  | 
        
        
           | 6 | 
           cycrow | 
           478 | 
           		return false;
  | 
        
        
            | 
            | 
           479 | 
              | 
        
        
            | 
            | 
           480 | 
           	C_File *file = m_lFiles.Get ( pos );
  | 
        
        
            | 
            | 
           481 | 
           	m_lFiles.erase ( pos + 1 );
  | 
        
        
            | 
            | 
           482 | 
              | 
        
        
            | 
            | 
           483 | 
           	if ( file )
  | 
        
        
            | 
            | 
           484 | 
           		delete file;
  | 
        
        
            | 
            | 
           485 | 
              | 
        
        
           | 50 | 
           cycrow | 
           486 | 
           	_changed();
  | 
        
        
           | 6 | 
           cycrow | 
           487 | 
              | 
        
        
            | 
            | 
           488 | 
           	return true;
  | 
        
        
            | 
            | 
           489 | 
           }
  | 
        
        
            | 
            | 
           490 | 
              | 
        
        
            | 
            | 
           491 | 
              | 
        
        
           | 129 | 
           cycrow | 
           492 | 
           void CBaseFile::removeAllFiles(FileType type, int game)
  | 
        
        
           | 6 | 
           cycrow | 
           493 | 
           {
  | 
        
        
            | 
            | 
           494 | 
           	if ( m_lFiles.empty() )
  | 
        
        
            | 
            | 
           495 | 
           		return;
  | 
        
        
            | 
            | 
           496 | 
              | 
        
        
            | 
            | 
           497 | 
           	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
  | 
        
        
            | 
            | 
           498 | 
           	{
  | 
        
        
           | 129 | 
           cycrow | 
           499 | 
           		if (game == 0 && node->Data()->game() && node->Data()->game() != GAME_ALLNEW)
  | 
        
        
            | 
            | 
           500 | 
           			continue;
  | 
        
        
            | 
            | 
           501 | 
           		if ( game > -1 )
  | 
        
        
            | 
            | 
           502 | 
           		{
  | 
        
        
            | 
            | 
           503 | 
           			unsigned int fileGame = node->Data()->game() & ~GAME_ALLNEW;
  | 
        
        
            | 
            | 
           504 | 
           			if (fileGame != (1 << game))
  | 
        
        
            | 
            | 
           505 | 
           			{
  | 
        
        
            | 
            | 
           506 | 
           				// just remove the game from file
  | 
        
        
            | 
            | 
           507 | 
           				if (fileGame & (1 << game))
  | 
        
        
            | 
            | 
           508 | 
           					node->Data()->setGame(node->Data()->game() & ~(1 << game));
  | 
        
        
           | 6 | 
           cycrow | 
           509 | 
           				continue;
  | 
        
        
           | 129 | 
           cycrow | 
           510 | 
           			}
  | 
        
        
           | 6 | 
           cycrow | 
           511 | 
           		}
  | 
        
        
           | 129 | 
           cycrow | 
           512 | 
           		if ( type == FILETYPE_UNKNOWN || node->Data()->GetFileType() == type )
  | 
        
        
           | 6 | 
           cycrow | 
           513 | 
           			node->DeleteData();
  | 
        
        
            | 
            | 
           514 | 
           	}
  | 
        
        
            | 
            | 
           515 | 
              | 
        
        
            | 
            | 
           516 | 
           	m_lFiles.RemoveEmpty();
  | 
        
        
            | 
            | 
           517 | 
              | 
        
        
           | 50 | 
           cycrow | 
           518 | 
           	_changed();
  | 
        
        
           | 6 | 
           cycrow | 
           519 | 
           }
  | 
        
        
            | 
            | 
           520 | 
              | 
        
        
            | 
            | 
           521 | 
           void CBaseFile::RecompressAllFiles ( int type, CProgressInfo *progress )
  | 
        
        
            | 
            | 
           522 | 
           {
  | 
        
        
            | 
            | 
           523 | 
           	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
  | 
        
        
            | 
            | 
           524 | 
           	{
  | 
        
        
            | 
            | 
           525 | 
           		C_File *file = node->Data();
  | 
        
        
            | 
            | 
           526 | 
           		if ( progress )
  | 
        
        
            | 
            | 
           527 | 
           			progress->UpdateFile(file);
  | 
        
        
            | 
            | 
           528 | 
              | 
        
        
            | 
            | 
           529 | 
           		if ( file->GetCompressionType() == type )
  | 
        
        
            | 
            | 
           530 | 
           			continue;
  | 
        
        
            | 
            | 
           531 | 
              | 
        
        
            | 
            | 
           532 | 
           		if ( !file->GetData() )
  | 
        
        
            | 
            | 
           533 | 
           			file->ReadFromFile();
  | 
        
        
            | 
            | 
           534 | 
              | 
        
        
            | 
            | 
           535 | 
           		file->ChangeCompression ( type, progress );
  | 
        
        
            | 
            | 
           536 | 
           	}
  | 
        
        
            | 
            | 
           537 | 
           }
  | 
        
        
            | 
            | 
           538 | 
              | 
        
        
           | 47 | 
           cycrow | 
           539 | 
           void CBaseFile::CompressAllFiles ( int type, CProgressInfo *progress, CProgressInfo *overallProgress, int level )
  | 
        
        
           | 6 | 
           cycrow | 
           540 | 
           {
  | 
        
        
           | 47 | 
           cycrow | 
           541 | 
           	if ( overallProgress ) overallProgress->SetMax(m_lFiles.size());
  | 
        
        
            | 
            | 
           542 | 
              | 
        
        
            | 
            | 
           543 | 
           	int iCount = 0;
  | 
        
        
           | 6 | 
           cycrow | 
           544 | 
           	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
  | 
        
        
            | 
            | 
           545 | 
           	{
  | 
        
        
            | 
            | 
           546 | 
           		C_File *file = node->Data();
  | 
        
        
            | 
            | 
           547 | 
           		if ( progress )
  | 
        
        
            | 
            | 
           548 | 
           			progress->UpdateFile(file);
  | 
        
        
            | 
            | 
           549 | 
              | 
        
        
            | 
            | 
           550 | 
           		if ( !file->GetData() )
  | 
        
        
            | 
            | 
           551 | 
           			file->ReadFromFile();
  | 
        
        
            | 
            | 
           552 | 
              | 
        
        
            | 
            | 
           553 | 
           		file->CompressData ( type, progress, level );
  | 
        
        
           | 47 | 
           cycrow | 
           554 | 
              | 
        
        
            | 
            | 
           555 | 
           		if ( overallProgress ) overallProgress->SetDone(++iCount);
  | 
        
        
           | 6 | 
           cycrow | 
           556 | 
           	}
  | 
        
        
            | 
            | 
           557 | 
           }
  | 
        
        
            | 
            | 
           558 | 
              | 
        
        
            | 
            | 
           559 | 
           bool CBaseFile::UncompressAllFiles ( CProgressInfo *progress )
  | 
        
        
            | 
            | 
           560 | 
           {
  | 
        
        
            | 
            | 
           561 | 
           	int countFile = 0;
  | 
        
        
            | 
            | 
           562 | 
           	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
  | 
        
        
            | 
            | 
           563 | 
           	{
  | 
        
        
            | 
            | 
           564 | 
           		C_File *fit = node->Data();
  | 
        
        
            | 
            | 
           565 | 
           		if ( progress )
  | 
        
        
            | 
            | 
           566 | 
           		{
  | 
        
        
            | 
            | 
           567 | 
           			progress->UpdateFile ( fit );
  | 
        
        
            | 
            | 
           568 | 
           			progress->UpdateProgress(countFile++, m_lFiles.size());
  | 
        
        
            | 
            | 
           569 | 
           		}
  | 
        
        
            | 
            | 
           570 | 
              | 
        
        
            | 
            | 
           571 | 
           		bool uncomprToFile = false;
  | 
        
        
            | 
            | 
           572 | 
              | 
        
        
            | 
            | 
           573 | 
           		if ( progress )
  | 
        
        
            | 
            | 
           574 | 
           			progress->SwitchSecond();
  | 
        
        
            | 
            | 
           575 | 
              | 
        
        
           | 127 | 
           cycrow | 
           576 | 
           		if(!fit->isExternalFile())
  | 
        
        
           | 6 | 
           cycrow | 
           577 | 
           		{
  | 
        
        
           | 127 | 
           cycrow | 
           578 | 
           			if (!fit->UncompressData(progress))
  | 
        
        
           | 6 | 
           cycrow | 
           579 | 
           			{
  | 
        
        
           | 127 | 
           cycrow | 
           580 | 
           				if (fit->GetCompressionType() == SPKCOMPRESS_7ZIP)
  | 
        
        
           | 6 | 
           cycrow | 
           581 | 
           				{
  | 
        
        
           | 178 | 
           cycrow | 
           582 | 
           					if (!fit->uncompressToFile("temp", this, false, progress))
  | 
        
        
           | 127 | 
           cycrow | 
           583 | 
           						return false;
  | 
        
        
            | 
            | 
           584 | 
           					else
  | 
        
        
            | 
            | 
           585 | 
           					{
  | 
        
        
            | 
            | 
           586 | 
           						uncomprToFile = true;
  | 
        
        
           | 178 | 
           cycrow | 
           587 | 
           						fit->setFullDir("temp");
  | 
        
        
           | 127 | 
           cycrow | 
           588 | 
           					}
  | 
        
        
           | 6 | 
           cycrow | 
           589 | 
           				}
  | 
        
        
           | 127 | 
           cycrow | 
           590 | 
              | 
        
        
            | 
            | 
           591 | 
           				if (!uncomprToFile)
  | 
        
        
            | 
            | 
           592 | 
           					return false;
  | 
        
        
           | 6 | 
           cycrow | 
           593 | 
           			}
  | 
        
        
            | 
            | 
           594 | 
           		}
  | 
        
        
            | 
            | 
           595 | 
              | 
        
        
            | 
            | 
           596 | 
           		if ( progress )
  | 
        
        
            | 
            | 
           597 | 
           			progress->SwitchSecond();
  | 
        
        
            | 
            | 
           598 | 
           	}
  | 
        
        
            | 
            | 
           599 | 
           	return true;
  | 
        
        
            | 
            | 
           600 | 
           }
  | 
        
        
            | 
            | 
           601 | 
              | 
        
        
           | 170 | 
           cycrow | 
           602 | 
           size_t CBaseFile::fileSize() const
  | 
        
        
           | 6 | 
           cycrow | 
           603 | 
           {
  | 
        
        
           | 170 | 
           cycrow | 
           604 | 
           	size_t fullsize = 1000;
  | 
        
        
           | 6 | 
           cycrow | 
           605 | 
              | 
        
        
           | 170 | 
           cycrow | 
           606 | 
           	for (CListNode<C_File>* node = m_lFiles.Front(); node; node = node->next())
  | 
        
        
           | 178 | 
           cycrow | 
           607 | 
           		fullsize += node->Data()->uncompressedDataSize();
  | 
        
        
           | 6 | 
           cycrow | 
           608 | 
              | 
        
        
           | 170 | 
           cycrow | 
           609 | 
           	if (m_pIconFile)
  | 
        
        
           | 178 | 
           cycrow | 
           610 | 
           		fullsize += m_pIconFile->uncompressedDataSize();
  | 
        
        
           | 6 | 
           cycrow | 
           611 | 
              | 
        
        
            | 
            | 
           612 | 
           	return fullsize;
  | 
        
        
            | 
            | 
           613 | 
           }
  | 
        
        
            | 
            | 
           614 | 
              | 
        
        
            | 
            | 
           615 | 
           /*
  | 
        
        
            | 
            | 
           616 | 
           	Func:   GetEndOfLine
  | 
        
        
            | 
            | 
           617 | 
           	Input:  id - The file id for the current file to read from
  | 
        
        
            | 
            | 
           618 | 
           	        line - Pointed to hold the line number thats read
  | 
        
        
            | 
            | 
           619 | 
           			upper - true if it converts to uppercase
  | 
        
        
            | 
            | 
           620 | 
           	Return: String - the string it has read
  | 
        
        
            | 
            | 
           621 | 
           	Desc:   Reads a string from a file, simlar to readLine() classes, reads to the end of the line in a file
  | 
        
        
            | 
            | 
           622 | 
           */
  | 
        
        
           | 175 | 
           cycrow | 
           623 | 
           Utils::String CBaseFile::GetEndOfLine ( FILE *id, int *line, bool upper )
  | 
        
        
           | 6 | 
           cycrow | 
           624 | 
           {
  | 
        
        
           | 175 | 
           cycrow | 
           625 | 
           	Utils::String word;
  | 
        
        
           | 6 | 
           cycrow | 
           626 | 
              | 
        
        
            | 
            | 
           627 | 
           	char c = fgetc ( id );
  | 
        
        
            | 
            | 
           628 | 
           	if ( c == -1 )
  | 
        
        
            | 
            | 
           629 | 
           		return "";
  | 
        
        
            | 
            | 
           630 | 
              | 
        
        
            | 
            | 
           631 | 
           	while ( (c != 13) && (!feof(id)) && (c != '\n') )
  | 
        
        
            | 
            | 
           632 | 
           	{
  | 
        
        
            | 
            | 
           633 | 
           		word += c;
  | 
        
        
            | 
            | 
           634 | 
           		c = fgetc ( id );
  | 
        
        
            | 
            | 
           635 | 
           	}
  | 
        
        
            | 
            | 
           636 | 
              | 
        
        
            | 
            | 
           637 | 
           	if ( line )
  | 
        
        
            | 
            | 
           638 | 
           		++(*line);
  | 
        
        
            | 
            | 
           639 | 
              | 
        
        
            | 
            | 
           640 | 
           	if ( upper )
  | 
        
        
           | 175 | 
           cycrow | 
           641 | 
           		return word.upper();
  | 
        
        
           | 6 | 
           cycrow | 
           642 | 
              | 
        
        
            | 
            | 
           643 | 
           	return word;
  | 
        
        
            | 
            | 
           644 | 
           }
  | 
        
        
            | 
            | 
           645 | 
              | 
        
        
           | 170 | 
           cycrow | 
           646 | 
           size_t CBaseFile::countFiles(FileType filetype) const
  | 
        
        
           | 6 | 
           cycrow | 
           647 | 
           {
  | 
        
        
           | 170 | 
           cycrow | 
           648 | 
           	size_t i = 0;
  | 
        
        
           | 6 | 
           cycrow | 
           649 | 
           	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
  | 
        
        
            | 
            | 
           650 | 
           	{
  | 
        
        
            | 
            | 
           651 | 
           		C_File *file = node->Data();
  | 
        
        
            | 
            | 
           652 | 
           		if ( file->GetFileType() != filetype )
  | 
        
        
            | 
            | 
           653 | 
           			continue;
  | 
        
        
            | 
            | 
           654 | 
           		++i;
  | 
        
        
            | 
            | 
           655 | 
           	}
  | 
        
        
            | 
            | 
           656 | 
              | 
        
        
            | 
            | 
           657 | 
           	return i;
  | 
        
        
            | 
            | 
           658 | 
           }
  | 
        
        
            | 
            | 
           659 | 
              | 
        
        
            | 
            | 
           660 | 
           /*
  | 
        
        
            | 
            | 
           661 | 
           	Func:   CreateFilesLine
  | 
        
        
            | 
            | 
           662 | 
           	Return: String - returns the full string for files list
  | 
        
        
            | 
            | 
           663 | 
           	Desc:   Creates a signle line list of all the files
  | 
        
        
            | 
            | 
           664 | 
           */
  | 
        
        
           | 175 | 
           cycrow | 
           665 | 
           Utils::String CBaseFile::createFilesLine(SSPKHeader2 *header, CProgressInfo* progress) const
  | 
        
        
           | 6 | 
           cycrow | 
           666 | 
           {
  | 
        
        
           | 197 | 
           cycrow | 
           667 | 
           	Utils::WString line;
  | 
        
        
           | 6 | 
           cycrow | 
           668 | 
              | 
        
        
           | 170 | 
           cycrow | 
           669 | 
           	if (progress)
  | 
        
        
           | 6 | 
           cycrow | 
           670 | 
           	{
  | 
        
        
            | 
            | 
           671 | 
           		progress->SetDone(0);
  | 
        
        
            | 
            | 
           672 | 
           		progress->UpdateStatus(STATUS_COMPRESS);
  | 
        
        
            | 
            | 
           673 | 
           	}
  | 
        
        
            | 
            | 
           674 | 
              | 
        
        
           | 175 | 
           cycrow | 
           675 | 
           	if (header)
  | 
        
        
           | 6 | 
           cycrow | 
           676 | 
           	{
  | 
        
        
           | 175 | 
           cycrow | 
           677 | 
           		header->iDataCompression = m_SHeader2.iDataCompression;
  | 
        
        
            | 
            | 
           678 | 
           		header->iFileCompression = m_SHeader2.iFileCompression;
  | 
        
        
            | 
            | 
           679 | 
           		header->lSize = m_SHeader2.lSize;
  | 
        
        
            | 
            | 
           680 | 
           		header->iNumFiles = 0;
  | 
        
        
            | 
            | 
           681 | 
           		header->lFullSize = 0;
  | 
        
        
           | 6 | 
           cycrow | 
           682 | 
           	}
  | 
        
        
            | 
            | 
           683 | 
              | 
        
        
           | 170 | 
           cycrow | 
           684 | 
           	if (m_pIconFile)
  | 
        
        
           | 6 | 
           cycrow | 
           685 | 
           	{
  | 
        
        
            | 
            | 
           686 | 
           		// no data, read it from file
  | 
        
        
           | 170 | 
           cycrow | 
           687 | 
           		if (!m_pIconFile->GetData())
  | 
        
        
            | 
            | 
           688 | 
           			m_pIconFile->ReadFromFile();
  | 
        
        
           | 6 | 
           cycrow | 
           689 | 
              | 
        
        
            | 
            | 
           690 | 
           		// compress the file
  | 
        
        
           | 170 | 
           cycrow | 
           691 | 
           		if (!m_pIconFile->CompressData(m_SHeader2.iDataCompression, progress))
  | 
        
        
           | 6 | 
           cycrow | 
           692 | 
           			m_pIconFile->SetDataCompression(SPKCOMPRESS_NONE);
  | 
        
        
            | 
            | 
           693 | 
              | 
        
        
           | 197 | 
           cycrow | 
           694 | 
           		line += L"Icon:" + Utils::WString::Number(m_pIconFile->GetDataSize() + (long)4) + L":" + m_pIconFile->uncompressedDataSize() + L":" + (long)m_pIconFile->GetCompressionType() + L":" + _sIconExt + L"\n";
  | 
        
        
           | 175 | 
           cycrow | 
           695 | 
           		if (header)
  | 
        
        
           | 6 | 
           cycrow | 
           696 | 
           		{
  | 
        
        
           | 175 | 
           cycrow | 
           697 | 
           			++header->iNumFiles;
  | 
        
        
            | 
            | 
           698 | 
           			header->lFullSize += (m_pIconFile->GetDataSize() + 4);
  | 
        
        
           | 6 | 
           cycrow | 
           699 | 
           		}
  | 
        
        
            | 
            | 
           700 | 
           	}
  | 
        
        
            | 
            | 
           701 | 
              | 
        
        
           | 170 | 
           cycrow | 
           702 | 
           	for (CListNode<C_File>* node = m_lFiles.Front(); node; node = node->next())
  | 
        
        
           | 6 | 
           cycrow | 
           703 | 
           	{
  | 
        
        
           | 170 | 
           cycrow | 
           704 | 
           		C_File* file = node->Data();
  | 
        
        
            | 
            | 
           705 | 
           		if (progress)
  | 
        
        
            | 
            | 
           706 | 
           			progress->UpdateFile(file);
  | 
        
        
           | 6 | 
           cycrow | 
           707 | 
              | 
        
        
            | 
            | 
           708 | 
           		// no data, read it from file
  | 
        
        
           | 170 | 
           cycrow | 
           709 | 
           		if (!file->GetData())
  | 
        
        
           | 6 | 
           cycrow | 
           710 | 
           		{
  | 
        
        
           | 170 | 
           cycrow | 
           711 | 
           			if (!file->ReadFromFile())
  | 
        
        
           | 6 | 
           cycrow | 
           712 | 
           			{
  | 
        
        
           | 170 | 
           cycrow | 
           713 | 
           				if (file->GetLastError() == SPKERR_MALLOC)
  | 
        
        
           | 6 | 
           cycrow | 
           714 | 
           				{
  | 
        
        
           | 170 | 
           cycrow | 
           715 | 
           					if (!file->CompressFile(progress))
  | 
        
        
           | 6 | 
           cycrow | 
           716 | 
           						continue;
  | 
        
        
            | 
            | 
           717 | 
           				}
  | 
        
        
            | 
            | 
           718 | 
           			}
  | 
        
        
            | 
            | 
           719 | 
           		}
  | 
        
        
            | 
            | 
           720 | 
              | 
        
        
           | 170 | 
           cycrow | 
           721 | 
           		if (!file->GetData())
  | 
        
        
           | 6 | 
           cycrow | 
           722 | 
           			continue;
  | 
        
        
            | 
            | 
           723 | 
              | 
        
        
            | 
            | 
           724 | 
           		// compress the file
  | 
        
        
           | 170 | 
           cycrow | 
           725 | 
           		if (!file->CompressData(m_SHeader2.iDataCompression, progress))
  | 
        
        
           | 6 | 
           cycrow | 
           726 | 
           		{
  | 
        
        
            | 
            | 
           727 | 
           			file->SetDataCompression(SPKCOMPRESS_NONE);
  | 
        
        
            | 
            | 
           728 | 
           			file->SetUncompressedDataSize(file->GetDataSize());
  | 
        
        
            | 
            | 
           729 | 
           		}
  | 
        
        
            | 
            | 
           730 | 
              | 
        
        
           | 197 | 
           cycrow | 
           731 | 
           		Utils::WString command = GetFileTypeString(file->GetFileType());
  | 
        
        
           | 170 | 
           cycrow | 
           732 | 
           		if (command.empty())
  | 
        
        
           | 6 | 
           cycrow | 
           733 | 
           			continue;
  | 
        
        
            | 
            | 
           734 | 
              | 
        
        
           | 170 | 
           cycrow | 
           735 | 
           		if (file->IsShared())
  | 
        
        
           | 197 | 
           cycrow | 
           736 | 
           			command = L"$" + command;
  | 
        
        
           | 6 | 
           cycrow | 
           737 | 
              | 
        
        
           | 170 | 
           cycrow | 
           738 | 
           		if (file->dir().empty())
  | 
        
        
           | 197 | 
           cycrow | 
           739 | 
           			line += command + L":" + (file->GetDataSize() + (long)4) + L":" + file->uncompressedDataSize() + L":" + (long)file->GetCompressionType() + L":" + (long)file->GetCreationTime() + L":" + ((file->IsCompressedToFile()) ? L"1" : L"0") + L":" + file->filename() + L":NULL:" + (long)file->game() + L"\n";
  | 
        
        
           | 6 | 
           cycrow | 
           740 | 
           		else
  | 
        
        
           | 197 | 
           cycrow | 
           741 | 
           			line += command + L":" + (file->GetDataSize() + (long)4) + L":" + file->uncompressedDataSize() + L":" + (long)file->GetCompressionType() + L":" + (long)file->GetCreationTime() + L":" + ((file->IsCompressedToFile()) ? L"1" : L"0") + L":" + file->filename() + L":" + file->dir() + L":" + (long)file->game() + L"\n";
  | 
        
        
           | 6 | 
           cycrow | 
           742 | 
              | 
        
        
           | 175 | 
           cycrow | 
           743 | 
           		if (header)
  | 
        
        
           | 6 | 
           cycrow | 
           744 | 
           		{
  | 
        
        
           | 175 | 
           cycrow | 
           745 | 
           			++header->iNumFiles;
  | 
        
        
            | 
            | 
           746 | 
           			header->lFullSize += (file->GetDataSize() + 4);
  | 
        
        
           | 6 | 
           cycrow | 
           747 | 
           		}
  | 
        
        
            | 
            | 
           748 | 
           	}
  | 
        
        
            | 
            | 
           749 | 
              | 
        
        
           | 197 | 
           cycrow | 
           750 | 
           	return line.toString();
  | 
        
        
           | 6 | 
           cycrow | 
           751 | 
           }
  | 
        
        
            | 
            | 
           752 | 
              | 
        
        
            | 
            | 
           753 | 
           /*
  | 
        
        
            | 
            | 
           754 | 
           ######################################################################################
  | 
        
        
            | 
            | 
           755 | 
           ##########							Reading Functions			    		##########
  | 
        
        
            | 
            | 
           756 | 
           ######################################################################################
  | 
        
        
            | 
            | 
           757 | 
           */
  | 
        
        
            | 
            | 
           758 | 
              | 
        
        
            | 
            | 
           759 | 
           void CBaseFile::ReadAllFilesToMemory ()
  | 
        
        
            | 
            | 
           760 | 
           {
  | 
        
        
            | 
            | 
           761 | 
           	// no file to read from
  | 
        
        
           | 50 | 
           cycrow | 
           762 | 
           	if ( this->filename().empty() ) return;
  | 
        
        
           | 6 | 
           cycrow | 
           763 | 
              | 
        
        
            | 
            | 
           764 | 
           	// now open the file
  | 
        
        
           | 58 | 
           cycrow | 
           765 | 
           	CFileIO File(this->filename());
  | 
        
        
            | 
            | 
           766 | 
           	if ( !File.startRead() ) return;
  | 
        
        
           | 6 | 
           cycrow | 
           767 | 
              | 
        
        
            | 
            | 
           768 | 
           	// read the header
  | 
        
        
           | 197 | 
           cycrow | 
           769 | 
           	File.readEndOfLineStr();
  | 
        
        
           | 6 | 
           cycrow | 
           770 | 
           	// skip past values
  | 
        
        
           | 58 | 
           cycrow | 
           771 | 
           	File.seek(4 + m_SHeader.lValueCompressSize);
  | 
        
        
           | 6 | 
           cycrow | 
           772 | 
              | 
        
        
            | 
            | 
           773 | 
           	// read the next header
  | 
        
        
           | 197 | 
           cycrow | 
           774 | 
           	File.readEndOfLineStr();
  | 
        
        
           | 6 | 
           cycrow | 
           775 | 
           	// skip past files
  | 
        
        
           | 58 | 
           cycrow | 
           776 | 
           	File.seek(4 + m_SHeader2.lSize);
  | 
        
        
           | 6 | 
           cycrow | 
           777 | 
              | 
        
        
            | 
            | 
           778 | 
           	if ( m_pIconFile )
  | 
        
        
            | 
            | 
           779 | 
           	{
  | 
        
        
            | 
            | 
           780 | 
           		if ( (!m_pIconFile->GetData()) && (!m_pIconFile->Skip()) )
  | 
        
        
           | 51 | 
           cycrow | 
           781 | 
           			m_pIconFile->readFromFile(File, m_pIconFile->GetDataSize());
  | 
        
        
           | 6 | 
           cycrow | 
           782 | 
           		else
  | 
        
        
           | 58 | 
           cycrow | 
           783 | 
           			File.seek(4 + m_pIconFile->GetDataSize());
  | 
        
        
           | 6 | 
           cycrow | 
           784 | 
           	}
  | 
        
        
            | 
            | 
           785 | 
              | 
        
        
            | 
            | 
           786 | 
           	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
  | 
        
        
            | 
            | 
           787 | 
           	{
  | 
        
        
            | 
            | 
           788 | 
           		C_File *fit = node->Data();
  | 
        
        
            | 
            | 
           789 | 
           		if ( (!fit->GetData()) && (!fit->Skip()) )
  | 
        
        
           | 51 | 
           cycrow | 
           790 | 
           			fit->readFromFile(File, fit->GetDataSize());
  | 
        
        
           | 6 | 
           cycrow | 
           791 | 
           		else
  | 
        
        
           | 58 | 
           cycrow | 
           792 | 
           			File.seek(4 + fit->GetDataSize());
  | 
        
        
           | 6 | 
           cycrow | 
           793 | 
           	}
  | 
        
        
            | 
            | 
           794 | 
              | 
        
        
           | 51 | 
           cycrow | 
           795 | 
           	File.close();
  | 
        
        
           | 6 | 
           cycrow | 
           796 | 
           }
  | 
        
        
            | 
            | 
           797 | 
              | 
        
        
            | 
            | 
           798 | 
           bool CBaseFile::ReadFileToMemory(C_File *f)
  | 
        
        
            | 
            | 
           799 | 
           {
  | 
        
        
           | 62 | 
           cycrow | 
           800 | 
           	if ( this->filename().empty() || !f ) return false;		// no filename to load from
  | 
        
        
           | 51 | 
           cycrow | 
           801 | 
           	if ( f->GetData() && f->GetDataSize() ) return true;	// already loaded the data
  | 
        
        
            | 
            | 
           802 | 
           	if ( !m_lFiles.FindData(f) ) return false;				// unable to find file entry
  | 
        
        
           | 6 | 
           cycrow | 
           803 | 
              | 
        
        
            | 
            | 
           804 | 
           	// now open the file
  | 
        
        
           | 58 | 
           cycrow | 
           805 | 
           	CFileIO *File = _startRead();
  | 
        
        
            | 
            | 
           806 | 
           	if ( !File ) return false;
  | 
        
        
           | 6 | 
           cycrow | 
           807 | 
              | 
        
        
           | 58 | 
           cycrow | 
           808 | 
           	if ( m_pIconFile ) File->seek(4 + m_pIconFile->GetDataSize());
  | 
        
        
           | 51 | 
           cycrow | 
           809 | 
           	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() ) {
  | 
        
        
           | 6 | 
           cycrow | 
           810 | 
           		C_File *fit = node->Data();
  | 
        
        
           | 51 | 
           cycrow | 
           811 | 
           		if (fit == f ) {
  | 
        
        
           | 58 | 
           cycrow | 
           812 | 
           			fit->readFromFile(*File, fit->GetDataSize());
  | 
        
        
           | 6 | 
           cycrow | 
           813 | 
           			break;
  | 
        
        
            | 
            | 
           814 | 
           		}
  | 
        
        
           | 58 | 
           cycrow | 
           815 | 
           		else File->seek(4 + fit->GetDataSize());
  | 
        
        
           | 6 | 
           cycrow | 
           816 | 
           	}
  | 
        
        
            | 
            | 
           817 | 
              | 
        
        
           | 58 | 
           cycrow | 
           818 | 
           	delete File;
  | 
        
        
           | 6 | 
           cycrow | 
           819 | 
           	return true;
  | 
        
        
            | 
            | 
           820 | 
           }
  | 
        
        
            | 
            | 
           821 | 
              | 
        
        
           | 58 | 
           cycrow | 
           822 | 
           CFileIO *CBaseFile::_startRead()
  | 
        
        
           | 6 | 
           cycrow | 
           823 | 
           {
  | 
        
        
            | 
            | 
           824 | 
           	// no file to read from
  | 
        
        
           | 58 | 
           cycrow | 
           825 | 
           	if ( this->filename().empty() ) return NULL;
  | 
        
        
           | 6 | 
           cycrow | 
           826 | 
              | 
        
        
            | 
            | 
           827 | 
           	// now open the file
  | 
        
        
           | 58 | 
           cycrow | 
           828 | 
           	CFileIO *File = new CFileIO(this->filename());
  | 
        
        
            | 
            | 
           829 | 
           	if ( !File->startRead() ) return NULL;
  | 
        
        
           | 6 | 
           cycrow | 
           830 | 
              | 
        
        
            | 
            | 
           831 | 
           	// read the header
  | 
        
        
           | 197 | 
           cycrow | 
           832 | 
           	File->readEndOfLineStr();
  | 
        
        
           | 6 | 
           cycrow | 
           833 | 
           	// skip past values
  | 
        
        
           | 58 | 
           cycrow | 
           834 | 
           	File->seek(4 + m_SHeader.lValueCompressSize);
  | 
        
        
           | 6 | 
           cycrow | 
           835 | 
              | 
        
        
            | 
            | 
           836 | 
           	// read the next header
  | 
        
        
           | 197 | 
           cycrow | 
           837 | 
           	File->readEndOfLineStr();
  | 
        
        
           | 6 | 
           cycrow | 
           838 | 
           	// skip past files
  | 
        
        
           | 58 | 
           cycrow | 
           839 | 
           	File->seek(4 + m_SHeader2.lSize);
  | 
        
        
           | 6 | 
           cycrow | 
           840 | 
              | 
        
        
           | 58 | 
           cycrow | 
           841 | 
           	return File;
  | 
        
        
            | 
            | 
           842 | 
           }
  | 
        
        
           | 6 | 
           cycrow | 
           843 | 
              | 
        
        
           | 88 | 
           cycrow | 
           844 | 
           void CBaseFile::_addFile(C_File *file, bool dontChange)
  | 
        
        
            | 
            | 
           845 | 
           {
  | 
        
        
            | 
            | 
           846 | 
           	if ( !dontChange ) {
  | 
        
        
            | 
            | 
           847 | 
           		file->UpdateSigned();
  | 
        
        
            | 
            | 
           848 | 
           		_changed();
  | 
        
        
            | 
            | 
           849 | 
           	}
  | 
        
        
            | 
            | 
           850 | 
           	m_lFiles.push_back(file);
  | 
        
        
            | 
            | 
           851 | 
              | 
        
        
            | 
            | 
           852 | 
           	_updateTextDB(file);
  | 
        
        
            | 
            | 
           853 | 
           }
  | 
        
        
            | 
            | 
           854 | 
              | 
        
        
            | 
            | 
           855 | 
           void CBaseFile::_updateTextDB(C_File *file)
  | 
        
        
            | 
            | 
           856 | 
           {
  | 
        
        
            | 
            | 
           857 | 
           	if ( !_pTextDB ) _pTextDB = new CTextDB();
  | 
        
        
            | 
            | 
           858 | 
              | 
        
        
            | 
            | 
           859 | 
           	if ( file->GetFileType() == FILETYPE_TEXT ) {
  | 
        
        
           | 196 | 
           cycrow | 
           860 | 
           		Utils::WString baseFile = CFileIO(file->filePointer()).baseName();
  | 
        
        
            | 
            | 
           861 | 
           		int lang = (baseFile.contains(L"-L")) ? baseFile.right(3) : baseFile.truncate(-4);
  | 
        
        
           | 88 | 
           cycrow | 
           862 | 
              | 
        
        
            | 
            | 
           863 | 
           		// read in the text file to the database
  | 
        
        
            | 
            | 
           864 | 
           		_pTextDB->parseTextFile(0, 0, file->filePointer(), lang);
  | 
        
        
            | 
            | 
           865 | 
           	}
  | 
        
        
            | 
            | 
           866 | 
           }
  | 
        
        
            | 
            | 
           867 | 
              | 
        
        
            | 
            | 
           868 | 
           void CBaseFile::_resetTextDB()
  | 
        
        
            | 
            | 
           869 | 
           {
  | 
        
        
            | 
            | 
           870 | 
           	if ( _pTextDB ) delete _pTextDB;
  | 
        
        
            | 
            | 
           871 | 
           	_pTextDB = new CTextDB();
  | 
        
        
            | 
            | 
           872 | 
              | 
        
        
            | 
            | 
           873 | 
           	for(CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next()) {
  | 
        
        
            | 
            | 
           874 | 
           		_updateTextDB(node->Data());
  | 
        
        
            | 
            | 
           875 | 
           	}
  | 
        
        
            | 
            | 
           876 | 
           }
  | 
        
        
            | 
            | 
           877 | 
              | 
        
        
           | 58 | 
           cycrow | 
           878 | 
           void CBaseFile::ReadIconFileToMemory ()
  | 
        
        
            | 
            | 
           879 | 
           {
  | 
        
        
            | 
            | 
           880 | 
           	if ( !m_pIconFile )	return;
  | 
        
        
            | 
            | 
           881 | 
           	CFileIO *File = _startRead();
  | 
        
        
            | 
            | 
           882 | 
           	if ( !File ) return;
  | 
        
        
            | 
            | 
           883 | 
              | 
        
        
            | 
            | 
           884 | 
           	if ( (!m_pIconFile->GetData()) && (!m_pIconFile->Skip()) )
  | 
        
        
            | 
            | 
           885 | 
           		m_pIconFile->readFromFile(*File, m_pIconFile->GetDataSize());
  | 
        
        
            | 
            | 
           886 | 
           	else
  | 
        
        
            | 
            | 
           887 | 
           		File->seek(4 + m_pIconFile->GetDataSize());
  | 
        
        
            | 
            | 
           888 | 
              | 
        
        
            | 
            | 
           889 | 
           	delete File;
  | 
        
        
           | 6 | 
           cycrow | 
           890 | 
           }
  | 
        
        
            | 
            | 
           891 | 
              | 
        
        
           | 14 | 
           cycrow | 
           892 | 
           void CBaseFile::_install_adjustFakePatches(CPackages *pPackages)
  | 
        
        
           | 6 | 
           cycrow | 
           893 | 
           {
  | 
        
        
           | 197 | 
           cycrow | 
           894 | 
           	Utils::WStringList lPatches;
  | 
        
        
           | 182 | 
           cycrow | 
           895 | 
           	int startfake = pPackages->findNextFakePatch();
  | 
        
        
           | 6 | 
           cycrow | 
           896 | 
              | 
        
        
           | 14 | 
           cycrow | 
           897 | 
           	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
  | 
        
        
            | 
            | 
           898 | 
           	{
  | 
        
        
            | 
            | 
           899 | 
           		C_File *fit = node->Data();
  | 
        
        
            | 
            | 
           900 | 
           		// only do fake patchs
  | 
        
        
            | 
            | 
           901 | 
           		if ( !fit->IsFakePatch() )
  | 
        
        
            | 
            | 
           902 | 
           			continue;
  | 
        
        
            | 
            | 
           903 | 
              | 
        
        
            | 
            | 
           904 | 
           		// we should only have cat and dat files, but lets check just incase they have been added incorrectly
  | 
        
        
           | 178 | 
           cycrow | 
           905 | 
           		if ( !fit->checkFileExt ("cat") && !fit->checkFileExt("dat") )
  | 
        
        
           | 14 | 
           cycrow | 
           906 | 
           			continue;
  | 
        
        
            | 
            | 
           907 | 
              | 
        
        
            | 
            | 
           908 | 
           		// search for the name on the list
  | 
        
        
           | 197 | 
           cycrow | 
           909 | 
           		Utils::WString newname;
  | 
        
        
           | 175 | 
           cycrow | 
           910 | 
           		bool isOpposite = false;
  | 
        
        
            | 
            | 
           911 | 
           		if (lPatches.contains(fit->baseName()))
  | 
        
        
            | 
            | 
           912 | 
           		{
  | 
        
        
            | 
            | 
           913 | 
           			newname = lPatches.findString(fit->baseName());
  | 
        
        
            | 
            | 
           914 | 
           			isOpposite = true;
  | 
        
        
            | 
            | 
           915 | 
           		}
  | 
        
        
           | 14 | 
           cycrow | 
           916 | 
           		else
  | 
        
        
            | 
            | 
           917 | 
           		{
  | 
        
        
           | 197 | 
           cycrow | 
           918 | 
           			newname = Utils::WString::PadNumber((long)startfake, 2);
  | 
        
        
           | 175 | 
           cycrow | 
           919 | 
           			lPatches.pushBack(fit->baseName(), newname);
  | 
        
        
           | 14 | 
           cycrow | 
           920 | 
           		}
  | 
        
        
            | 
            | 
           921 | 
              | 
        
        
            | 
            | 
           922 | 
           		// rename the file
  | 
        
        
            | 
            | 
           923 | 
           		fit->FixOriginalName();
  | 
        
        
           | 175 | 
           cycrow | 
           924 | 
           		CLog::logf(CLog::Log_Install, 2, "Adjusting fake patch number, %s => %s", fit->getNameDirectory(this).c_str(), (newname + "." + fit->fileExt()).c_str());
  | 
        
        
            | 
            | 
           925 | 
           		fit->setName(newname + "." + fit->fileExt());
  | 
        
        
           | 14 | 
           cycrow | 
           926 | 
              | 
        
        
            | 
            | 
           927 | 
           		// find the next gap
  | 
        
        
           | 175 | 
           cycrow | 
           928 | 
           		if ( !isOpposite ) {
  | 
        
        
           | 182 | 
           cycrow | 
           929 | 
           			startfake = pPackages->findNextFakePatch(startfake + 1);
  | 
        
        
           | 14 | 
           cycrow | 
           930 | 
           		}
  | 
        
        
            | 
            | 
           931 | 
           	}
  | 
        
        
            | 
            | 
           932 | 
           }
  | 
        
        
            | 
            | 
           933 | 
              | 
        
        
           | 43 | 
           cycrow | 
           934 | 
           void CBaseFile::_install_renameText(CPackages *pPackages)
  | 
        
        
           | 14 | 
           cycrow | 
           935 | 
           {
  | 
        
        
           | 130 | 
           cycrow | 
           936 | 
           	int starttext = pPackages->findNextTextFile();
  | 
        
        
           | 43 | 
           cycrow | 
           937 | 
           	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() ) {
  | 
        
        
            | 
            | 
           938 | 
           		C_File *fit = node->Data();
  | 
        
        
           | 130 | 
           cycrow | 
           939 | 
           		if ( !fit->isAutoTextFile() )
  | 
        
        
           | 43 | 
           cycrow | 
           940 | 
           			continue;
  | 
        
        
           | 6 | 
           cycrow | 
           941 | 
              | 
        
        
           | 197 | 
           cycrow | 
           942 | 
           		Utils::WString newname = SPK::FormatTextName(starttext, pPackages->GetLanguage(), (pPackages->GetCurrentGameFlags() & EXEFLAG_TCTEXT));
  | 
        
        
           | 43 | 
           cycrow | 
           943 | 
           		fit->FixOriginalName();
  | 
        
        
           | 130 | 
           cycrow | 
           944 | 
           		CLog::logf(CLog::Log_Install, 2, "Adjusting text file, %s => %s", fit->getNameDirectory(this).c_str(), (newname + "." + fit->fileExt()).c_str());
  | 
        
        
            | 
            | 
           945 | 
           		fit->setName(newname + "." + fit->fileExt());
  | 
        
        
           | 6 | 
           cycrow | 
           946 | 
              | 
        
        
           | 43 | 
           cycrow | 
           947 | 
           		++starttext;
  | 
        
        
            | 
            | 
           948 | 
           	}
  | 
        
        
            | 
            | 
           949 | 
           }
  | 
        
        
           | 6 | 
           cycrow | 
           950 | 
              | 
        
        
           | 50 | 
           cycrow | 
           951 | 
           bool CBaseFile::_install_setEnabled(bool bEnable, C_File *fit)
  | 
        
        
            | 
            | 
           952 | 
           {
  | 
        
        
            | 
            | 
           953 | 
           	if ( !bEnable )
  | 
        
        
            | 
            | 
           954 | 
           	{
  | 
        
        
            | 
            | 
           955 | 
           		if ( (fit->GetFileType() == FILETYPE_UNINSTALL) || (fit->GetFileType() == FILETYPE_README) || (fit->GetFileType() == FILETYPE_ADVERT) )
  | 
        
        
            | 
            | 
           956 | 
           			bEnable = true;
  | 
        
        
           | 178 | 
           cycrow | 
           957 | 
           		else if ( (fit->GetFileType() == FILETYPE_EXTRA) && (fit->dir().left(7).lower() == "Extras/") )
  | 
        
        
           | 50 | 
           cycrow | 
           958 | 
           			bEnable = true;
  | 
        
        
            | 
            | 
           959 | 
           		else if ( (IsPatch()) && (fit->GetFileType() == FILETYPE_MOD) && (!fit->IsFakePatch()) )
  | 
        
        
            | 
            | 
           960 | 
           			bEnable = true;
  | 
        
        
            | 
            | 
           961 | 
              | 
        
        
            | 
            | 
           962 | 
           		if ( bEnable ) CLog::logf(CLog::Log_Install, 3, "Filetype(%d) is always enabled, setting enabled flag", fit->GetFileType());
  | 
        
        
            | 
            | 
           963 | 
           	}
  | 
        
        
            | 
            | 
           964 | 
              | 
        
        
            | 
            | 
           965 | 
           	return bEnable;
  | 
        
        
            | 
            | 
           966 | 
           }
  | 
        
        
            | 
            | 
           967 | 
              | 
        
        
           | 197 | 
           cycrow | 
           968 | 
           bool CBaseFile::_install_uncompress(C_File *fit, CProgressInfo *progress, Utils::WStringList *errorStr, bool *uncomprToFile)
  | 
        
        
           | 50 | 
           cycrow | 
           969 | 
           {
  | 
        
        
            | 
            | 
           970 | 
           	*uncomprToFile = false;
  | 
        
        
           | 134 | 
           cycrow | 
           971 | 
           	_sLastError = fit->getNameDirectory(this);
  | 
        
        
            | 
            | 
           972 | 
           	_iLastError = SPKERR_UNCOMPRESS;
  | 
        
        
           | 96 | 
           cycrow | 
           973 | 
              | 
        
        
           | 50 | 
           cycrow | 
           974 | 
           	if ( !fit->UncompressData ( progress ) )
  | 
        
        
            | 
            | 
           975 | 
           	{
  | 
        
        
            | 
            | 
           976 | 
           		CLog::log(CLog::Log_Install, 2, "Failed to uncompress data, attempting file decompression");
  | 
        
        
            | 
            | 
           977 | 
           		if ( fit->GetCompressionType() == SPKCOMPRESS_7ZIP )
  | 
        
        
            | 
            | 
           978 | 
           		{
  | 
        
        
           | 197 | 
           cycrow | 
           979 | 
           			if ( fit->uncompressToFile(Utils::WString::Null(), this, false, progress ) )
  | 
        
        
           | 50 | 
           cycrow | 
           980 | 
           				*uncomprToFile = true;
  | 
        
        
            | 
            | 
           981 | 
           		}
  | 
        
        
            | 
            | 
           982 | 
              | 
        
        
            | 
            | 
           983 | 
           		if ( !uncomprToFile )
  | 
        
        
            | 
            | 
           984 | 
           		{
  | 
        
        
            | 
            | 
           985 | 
           			if ( errorStr )
  | 
        
        
           | 175 | 
           cycrow | 
           986 | 
           				errorStr->pushBack(_sLastError, ERRORLOG(SPKINSTALL_UNCOMPRESS_FAIL));
  | 
        
        
           | 50 | 
           cycrow | 
           987 | 
           			CLog::log(CLog::Log_Install, 1, "Unable to decompress file, skipping");
  | 
        
        
            | 
            | 
           988 | 
           			return false;
  | 
        
        
            | 
            | 
           989 | 
           		}
  | 
        
        
            | 
            | 
           990 | 
           	}
  | 
        
        
            | 
            | 
           991 | 
           	ClearError ();
  | 
        
        
            | 
            | 
           992 | 
              | 
        
        
            | 
            | 
           993 | 
           	return true;
  | 
        
        
            | 
            | 
           994 | 
           }
  | 
        
        
            | 
            | 
           995 | 
              | 
        
        
           | 197 | 
           cycrow | 
           996 | 
           bool CBaseFile::_install_checkVersion(C_File *pFile, const Utils::WString &sDestination)
  | 
        
        
           | 50 | 
           cycrow | 
           997 | 
           {
  | 
        
        
            | 
            | 
           998 | 
           	// new check if we should install the file
  | 
        
        
            | 
            | 
           999 | 
           	// first get the version
  | 
        
        
            | 
            | 
           1000 | 
           	if ( !m_bOverrideFiles && pFile->ReadScriptVersion() )
  | 
        
        
            | 
            | 
           1001 | 
           	{
  | 
        
        
            | 
            | 
           1002 | 
           		CLog::log(CLog::Log_Install, 2, "Checking for existing file version");
  | 
        
        
            | 
            | 
           1003 | 
           		C_File checkfile;
  | 
        
        
           | 197 | 
           cycrow | 
           1004 | 
           		Utils::WString checkfilename = sDestination;
  | 
        
        
            | 
            | 
           1005 | 
           		if ( !checkfilename.empty() ) checkfilename += L"/";
  | 
        
        
           | 175 | 
           cycrow | 
           1006 | 
           		checkfilename += pFile->getNameDirectory(this);
  | 
        
        
            | 
            | 
           1007 | 
           		checkfile.setFilename(checkfilename);
  | 
        
        
           | 127 | 
           cycrow | 
           1008 | 
           		checkfile.setFileType(pFile->fileType());
  | 
        
        
           | 50 | 
           cycrow | 
           1009 | 
           		if ( checkfile.CheckValidFilePointer() ) {
  | 
        
        
            | 
            | 
           1010 | 
           			if ( checkfile.ReadScriptVersion() > pFile->GetVersion() ) {
  | 
        
        
            | 
            | 
           1011 | 
           				CLog::log(CLog::Log_Install, 1, "Newer version of the file found in directory, skipping");
  | 
        
        
            | 
            | 
           1012 | 
           				return false;
  | 
        
        
            | 
            | 
           1013 | 
           			}
  | 
        
        
            | 
            | 
           1014 | 
           		}
  | 
        
        
            | 
            | 
           1015 | 
           	}
  | 
        
        
            | 
            | 
           1016 | 
              | 
        
        
            | 
            | 
           1017 | 
           	return true;
  | 
        
        
            | 
            | 
           1018 | 
           }
  | 
        
        
            | 
            | 
           1019 | 
              | 
        
        
           | 197 | 
           cycrow | 
           1020 | 
           Utils::String CBaseFile::_install_adjustFilepointer(C_File *pFile, bool bEnabled, const Utils::WString &sDestination)
  | 
        
        
           | 50 | 
           cycrow | 
           1021 | 
           {
  | 
        
        
           | 197 | 
           cycrow | 
           1022 | 
           	Utils::WString filename = sDestination;
  | 
        
        
            | 
            | 
           1023 | 
           	if ( !filename.empty() ) filename += L"/";
  | 
        
        
           | 50 | 
           cycrow | 
           1024 | 
              | 
        
        
           | 130 | 
           cycrow | 
           1025 | 
           	if ( (IsPatch()) && (pFile->fileType() == FILETYPE_MOD) )
  | 
        
        
           | 197 | 
           cycrow | 
           1026 | 
           		pFile->setDir(L"Patch");
  | 
        
        
           | 50 | 
           cycrow | 
           1027 | 
              | 
        
        
           | 160 | 
           cycrow | 
           1028 | 
           	if ( pFile->isInMod() )
  | 
        
        
           | 50 | 
           cycrow | 
           1029 | 
           	{
  | 
        
        
            | 
            | 
           1030 | 
           		if ( bEnabled )
  | 
        
        
           | 197 | 
           cycrow | 
           1031 | 
           			pFile->setFilename(filename + pFile->getInMod() + L"::" + pFile->getNameDirectory(this));
  | 
        
        
           | 50 | 
           cycrow | 
           1032 | 
           		else
  | 
        
        
           | 197 | 
           cycrow | 
           1033 | 
           			pFile->setFilename(filename + L"PluginManager/DisabledFiles.cat::" + pFile->getNameDirectory(this));
  | 
        
        
           | 50 | 
           cycrow | 
           1034 | 
           	}
  | 
        
        
            | 
            | 
           1035 | 
           	else
  | 
        
        
           | 130 | 
           cycrow | 
           1036 | 
           		pFile->setFilename ( filename + pFile->getNameDirectory(this) );
  | 
        
        
           | 50 | 
           cycrow | 
           1037 | 
              | 
        
        
            | 
            | 
           1038 | 
           	if ( !bEnabled )
  | 
        
        
            | 
            | 
           1039 | 
           	{
  | 
        
        
           | 160 | 
           cycrow | 
           1040 | 
           		if ( !pFile->isInMod() )
  | 
        
        
           | 50 | 
           cycrow | 
           1041 | 
           		{
  | 
        
        
            | 
            | 
           1042 | 
           			if ( pFile->IsFakePatch() )
  | 
        
        
           | 203 | 
           cycrow | 
           1043 | 
           				pFile->setFilename ( filename + L"PluginManager/Disabled/FakePatches/FakePatch_" + this->getNameValidFile() + L"_" + this->author() + L"_" + pFile->name());
  | 
        
        
           | 130 | 
           cycrow | 
           1044 | 
           			else if ( pFile->isAutoTextFile() )
  | 
        
        
           | 203 | 
           cycrow | 
           1045 | 
           				pFile->setFilename ( filename + L"PluginManager/Disabled/TextFiles/Text_" + this->getNameValidFile() + L"_" + this->author() + L"_" + pFile->name());
  | 
        
        
           | 50 | 
           cycrow | 
           1046 | 
           			else
  | 
        
        
           | 197 | 
           cycrow | 
           1047 | 
           				pFile->setFullDir ( filename + L"PluginManager/Disabled/" + pFile->getDirectory(this) );
  | 
        
        
           | 50 | 
           cycrow | 
           1048 | 
           		}
  | 
        
        
            | 
            | 
           1049 | 
           		pFile->SetDisabled(true);
  | 
        
        
            | 
            | 
           1050 | 
           	}
  | 
        
        
            | 
            | 
           1051 | 
              | 
        
        
           | 129 | 
           cycrow | 
           1052 | 
           	CLog::logf(CLog::Log_Install, 2, "Adjusting the file pointer to correct install destintation, %s", pFile->filePointer().c_str());
  | 
        
        
           | 50 | 
           cycrow | 
           1053 | 
              | 
        
        
           | 197 | 
           cycrow | 
           1054 | 
           	return filename.toString();
  | 
        
        
           | 50 | 
           cycrow | 
           1055 | 
           }
  | 
        
        
            | 
            | 
           1056 | 
              | 
        
        
           | 197 | 
           cycrow | 
           1057 | 
           C_File *CBaseFile::_install_checkFile(C_File *pFile, Utils::WStringList *errorStr, bool *bDoFile, CLinkList<C_File> *pFileList)
  | 
        
        
           | 50 | 
           cycrow | 
           1058 | 
           {
  | 
        
        
            | 
            | 
           1059 | 
           	if ( !pFile->IsFakePatch() && pFile->GetFileType() != FILETYPE_README )
  | 
        
        
            | 
            | 
           1060 | 
           	{
  | 
        
        
            | 
            | 
           1061 | 
           		C_File *cFile;
  | 
        
        
            | 
            | 
           1062 | 
           		for ( cFile = pFileList->First(); cFile; cFile = pFileList->Next() )
  | 
        
        
            | 
            | 
           1063 | 
           		{
  | 
        
        
            | 
            | 
           1064 | 
           			if ( !cFile->MatchFile(pFile) ) continue;
  | 
        
        
            | 
            | 
           1065 | 
           			if ( !m_bOverrideFiles && !cFile->CompareNew(pFile) ) {
  | 
        
        
           | 175 | 
           cycrow | 
           1066 | 
           				if ( errorStr ) errorStr->pushBack(pFile->getNameDirectory(this), ERRORLOG(SPKINSTALL_SKIPFILE));
  | 
        
        
           | 50 | 
           cycrow | 
           1067 | 
           				CLog::log(CLog::Log_Install, 1, "Newer version of the file already installed, skipping");
  | 
        
        
            | 
            | 
           1068 | 
           				*bDoFile = false;
  | 
        
        
            | 
            | 
           1069 | 
           			}
  | 
        
        
            | 
            | 
           1070 | 
           			break;
  | 
        
        
            | 
            | 
           1071 | 
           		}
  | 
        
        
            | 
            | 
           1072 | 
              | 
        
        
            | 
            | 
           1073 | 
           		return cFile;
  | 
        
        
            | 
            | 
           1074 | 
           	}
  | 
        
        
            | 
            | 
           1075 | 
              | 
        
        
            | 
            | 
           1076 | 
           	return NULL;
  | 
        
        
            | 
            | 
           1077 | 
           }
  | 
        
        
            | 
            | 
           1078 | 
              | 
        
        
           | 197 | 
           cycrow | 
           1079 | 
           bool CBaseFile::_install_checkFileEnable(C_File *pCheckFile, C_File *fit, const Utils::WString &sDestination, bool bEnabled, Utils::WStringList *errorStr)
  | 
        
        
           | 50 | 
           cycrow | 
           1080 | 
           {
  | 
        
        
            | 
            | 
           1081 | 
           	// found a file, check if its in the disabled directory
  | 
        
        
           | 196 | 
           cycrow | 
           1082 | 
           	Utils::WString dir = CFileIO(pCheckFile->filePointer()).dir();
  | 
        
        
            | 
            | 
           1083 | 
           	Utils::WString lastDir = CDirIO(dir).topDir().lower();
  | 
        
        
           | 50 | 
           cycrow | 
           1084 | 
              | 
        
        
            | 
            | 
           1085 | 
           	// if its disabled, rename it so its enabled
  | 
        
        
           | 196 | 
           cycrow | 
           1086 | 
           	if ( ((pCheckFile->IsDisabled()) || (lastDir == L"disabled") || (dir.lower().contains(L"/disabled/"))) && (bEnabled) )
  | 
        
        
           | 50 | 
           cycrow | 
           1087 | 
           	{
  | 
        
        
           | 125 | 
           cycrow | 
           1088 | 
           		CLog::logf(CLog::Log_Install, 2, "Existing file, %s, is disabled, re-enabling it", pCheckFile->filePointer().c_str());
  | 
        
        
           | 50 | 
           cycrow | 
           1089 | 
           		// first check if the directory exists
  | 
        
        
           | 160 | 
           cycrow | 
           1090 | 
           		if ( pCheckFile->isInMod() ) {
  | 
        
        
           | 197 | 
           cycrow | 
           1091 | 
           			Utils::WString tofile = pCheckFile->filePointer().token(L"::", 2);
  | 
        
        
           | 50 | 
           cycrow | 
           1092 | 
              | 
        
        
            | 
            | 
           1093 | 
           			CCatFile tocat;
  | 
        
        
           | 197 | 
           cycrow | 
           1094 | 
           			int err = tocat.open(fit->filePointer().token(L"::", 1), L"", CATREAD_CATDECRYPT, true);
  | 
        
        
           | 50 | 
           cycrow | 
           1095 | 
           			if ( (err == CATERR_NONE) || (err == CATERR_CREATED) ) {
  | 
        
        
           | 181 | 
           cycrow | 
           1096 | 
           				tocat.appendFile(pCheckFile->filePointer(), tofile);
  | 
        
        
           | 197 | 
           cycrow | 
           1097 | 
           				CLog::logf(CLog::Log_Install, 2, "Adding existing file into new mod File, %s => %s", fit->filePointer().token(L"::", 1).c_str(), tofile.c_str());
  | 
        
        
           | 50 | 
           cycrow | 
           1098 | 
           			}
  | 
        
        
            | 
            | 
           1099 | 
              | 
        
        
            | 
            | 
           1100 | 
           			CCatFile fromcat;
  | 
        
        
           | 197 | 
           cycrow | 
           1101 | 
           			err = fromcat.open(pCheckFile->filePointer().token(L"::", 1), L"", CATREAD_CATDECRYPT, false);
  | 
        
        
           | 50 | 
           cycrow | 
           1102 | 
           			if ( err == CATERR_NONE ) {
  | 
        
        
           | 175 | 
           cycrow | 
           1103 | 
           				fromcat.removeFile(tofile);
  | 
        
        
           | 197 | 
           cycrow | 
           1104 | 
           				CLog::logf(CLog::Log_Install, 2, "Removing file from existing mod, %s::%s", pCheckFile->filePointer().token(L"::", 1).c_str(), tofile.c_str());
  | 
        
        
           | 50 | 
           cycrow | 
           1105 | 
           			}
  | 
        
        
            | 
            | 
           1106 | 
              | 
        
        
           | 125 | 
           cycrow | 
           1107 | 
           			CLog::logf(CLog::Log_Install, 1, "Adjusting existing file name %s => %s", pCheckFile->filePointer().c_str(), fit->filePointer().c_str());
  | 
        
        
           | 178 | 
           cycrow | 
           1108 | 
           			pCheckFile->setFilename(fit->filePointer());
  | 
        
        
           | 160 | 
           cycrow | 
           1109 | 
           			CLog::logf(CLog::Log_Install, 2, "Adjusting In Mod setting, %s => %s", pCheckFile->getInMod().c_str(), fit->getInMod().c_str());
  | 
        
        
            | 
            | 
           1110 | 
           			pCheckFile->setInMod(fit->getInMod());
  | 
        
        
           | 50 | 
           cycrow | 
           1111 | 
           		}
  | 
        
        
            | 
            | 
           1112 | 
           		else {
  | 
        
        
           | 197 | 
           cycrow | 
           1113 | 
           			Utils::WString to = pCheckFile->getDirectory(this);
  | 
        
        
           | 50 | 
           cycrow | 
           1114 | 
           			CDirIO Dir(sDestination);
  | 
        
        
           | 160 | 
           cycrow | 
           1115 | 
           			if ( !Dir.exists(to) ) {
  | 
        
        
            | 
            | 
           1116 | 
           				if ( !Dir.create ( to ) ) {
  | 
        
        
           | 197 | 
           cycrow | 
           1117 | 
           					if ( errorStr )	errorStr->pushBack(to.toString(), ERRORLOG(SPKINSTALL_CREATEDIRECTORY_FAIL));
  | 
        
        
           | 50 | 
           cycrow | 
           1118 | 
           					return false;
  | 
        
        
            | 
            | 
           1119 | 
           				}
  | 
        
        
           | 197 | 
           cycrow | 
           1120 | 
           				if ( errorStr )	errorStr->pushBack(to.toString(), ERRORLOG(SPKINSTALL_CREATEDIRECTORY));
  | 
        
        
           | 50 | 
           cycrow | 
           1121 | 
           			}
  | 
        
        
            | 
            | 
           1122 | 
              | 
        
        
           | 197 | 
           cycrow | 
           1123 | 
           			Utils::WString destfile = sDestination + L"/" + pCheckFile->getNameDirectory(this);
  | 
        
        
            | 
            | 
           1124 | 
           			if ( CFileIO::Exists(destfile) ) CFileIO::Remove(destfile);
  | 
        
        
           | 178 | 
           cycrow | 
           1125 | 
           			CLog::logf(CLog::Log_Install, 1, "Adjusting existing filename, %s => %s", pCheckFile->filePointer().c_str(), destfile.c_str());
  | 
        
        
           | 197 | 
           cycrow | 
           1126 | 
           			CFileIO::Rename(pCheckFile->filePointer(), destfile);
  | 
        
        
            | 
            | 
           1127 | 
           			pCheckFile->setFilename (sDestination + L"/" + pCheckFile->getNameDirectory(this) );
  | 
        
        
           | 50 | 
           cycrow | 
           1128 | 
           		}
  | 
        
        
            | 
            | 
           1129 | 
           		pCheckFile->SetDisabled(false);
  | 
        
        
            | 
            | 
           1130 | 
              | 
        
        
           | 175 | 
           cycrow | 
           1131 | 
           		if ( errorStr ) errorStr->pushBack(pCheckFile->getNameDirectory(this), ERRORLOG(SPKINSTALL_ENABLEFILE));
  | 
        
        
           | 50 | 
           cycrow | 
           1132 | 
           	}
  | 
        
        
            | 
            | 
           1133 | 
              | 
        
        
            | 
            | 
           1134 | 
           	return true;
  | 
        
        
            | 
            | 
           1135 | 
           }
  | 
        
        
           | 51 | 
           cycrow | 
           1136 | 
              | 
        
        
           | 197 | 
           cycrow | 
           1137 | 
           bool CBaseFile::_install_createDirectory(CDirIO &Dir, const Utils::WString &sTo, C_File *pFile, Utils::WStringList *errorStr)
  | 
        
        
           | 51 | 
           cycrow | 
           1138 | 
           {
  | 
        
        
           | 134 | 
           cycrow | 
           1139 | 
           	_sLastError = sTo;
  | 
        
        
           | 197 | 
           cycrow | 
           1140 | 
           	if ( !sTo.contains(L"::"))
  | 
        
        
           | 51 | 
           cycrow | 
           1141 | 
           	{
  | 
        
        
           | 121 | 
           cycrow | 
           1142 | 
           		if ( !Dir.exists(sTo) )
  | 
        
        
           | 51 | 
           cycrow | 
           1143 | 
           		{
  | 
        
        
            | 
            | 
           1144 | 
           			CLog::logf(CLog::Log_Install, 2, "Creating directory to install file into, %s", sTo.c_str());
  | 
        
        
           | 160 | 
           cycrow | 
           1145 | 
           			if ( !Dir.create(sTo) )
  | 
        
        
           | 51 | 
           cycrow | 
           1146 | 
           			{
  | 
        
        
            | 
            | 
           1147 | 
           				if ( errorStr )
  | 
        
        
           | 175 | 
           cycrow | 
           1148 | 
           					errorStr->pushBack(sTo, ERRORLOG(SPKINSTALL_CREATEDIRECTORY_FAIL));
  | 
        
        
           | 51 | 
           cycrow | 
           1149 | 
           				return false;
  | 
        
        
            | 
            | 
           1150 | 
           			}
  | 
        
        
            | 
            | 
           1151 | 
           			if ( errorStr )
  | 
        
        
           | 175 | 
           cycrow | 
           1152 | 
           				errorStr->pushBack(sTo, ERRORLOG(SPKINSTALL_CREATEDIRECTORY));
  | 
        
        
           | 51 | 
           cycrow | 
           1153 | 
           		}
  | 
        
        
            | 
            | 
           1154 | 
           	}
  | 
        
        
            | 
            | 
           1155 | 
           	else {
  | 
        
        
           | 129 | 
           cycrow | 
           1156 | 
           		CLog::logf(CLog::Log_Install, 2, "Adjusting file extension for file in mod, %s => %s", pFile->filePointer().c_str(), CCatFile::PckChangeExtension(pFile->filePointer()).c_str());
  | 
        
        
           | 134 | 
           cycrow | 
           1157 | 
           		pFile->setFilename(CCatFile::PckChangeExtension(pFile->filePointer()));
  | 
        
        
           | 51 | 
           cycrow | 
           1158 | 
           	}
  | 
        
        
            | 
            | 
           1159 | 
              | 
        
        
            | 
            | 
           1160 | 
           	return true;
  | 
        
        
            | 
            | 
           1161 | 
           }
  | 
        
        
            | 
            | 
           1162 | 
              | 
        
        
           | 197 | 
           cycrow | 
           1163 | 
           void CBaseFile::_install_writeFile(C_File *pFile, const Utils::WString &sDestination, Utils::WStringList *errorStr)
  | 
        
        
           | 51 | 
           cycrow | 
           1164 | 
           {
  | 
        
        
           | 134 | 
           cycrow | 
           1165 | 
           	_iLastError = SPKERR_WRITEFILE;
  | 
        
        
            | 
            | 
           1166 | 
           	_sLastError = pFile->filePointer();
  | 
        
        
           | 197 | 
           cycrow | 
           1167 | 
           	Utils::WString sInstalledFile = pFile->getNameDirectory(this);
  | 
        
        
           | 51 | 
           cycrow | 
           1168 | 
           	if ( pFile->IsDisabled() )
  | 
        
        
            | 
            | 
           1169 | 
           	{
  | 
        
        
           | 134 | 
           cycrow | 
           1170 | 
           		sInstalledFile = pFile->filePointer().findRemove(sDestination);
  | 
        
        
           | 51 | 
           cycrow | 
           1171 | 
           		if ( sInstalledFile[0] == '/' || sInstalledFile[0] == '\\' )
  | 
        
        
           | 134 | 
           cycrow | 
           1172 | 
           			sInstalledFile.erase(0, 1);
  | 
        
        
           | 51 | 
           cycrow | 
           1173 | 
           	}
  | 
        
        
            | 
            | 
           1174 | 
              | 
        
        
           | 129 | 
           cycrow | 
           1175 | 
           	if ( !pFile->writeFilePointer() )
  | 
        
        
           | 51 | 
           cycrow | 
           1176 | 
           	{
  | 
        
        
            | 
            | 
           1177 | 
           		CLog::log(CLog::Log_Install, 1, "Failed to write the file");
  | 
        
        
            | 
            | 
           1178 | 
           		if ( errorStr )
  | 
        
        
           | 175 | 
           cycrow | 
           1179 | 
           			errorStr->pushBack(sInstalledFile, ERRORLOG(SPKINSTALL_WRITEFILE_FAIL));
  | 
        
        
           | 51 | 
           cycrow | 
           1180 | 
           	}
  | 
        
        
            | 
            | 
           1181 | 
           	else
  | 
        
        
            | 
            | 
           1182 | 
           	{
  | 
        
        
            | 
            | 
           1183 | 
           		CLog::log(CLog::Log_Install, 1, "File written successfully");
  | 
        
        
            | 
            | 
           1184 | 
           		CLog::log(CLog::Log_Install, 2, "Checking signed status of the file");
  | 
        
        
            | 
            | 
           1185 | 
           		pFile->UpdateSigned();
  | 
        
        
            | 
            | 
           1186 | 
           		if ( errorStr )
  | 
        
        
           | 175 | 
           cycrow | 
           1187 | 
           			errorStr->pushBack(sInstalledFile, ERRORLOG(SPKINSTALL_WRITEFILE));
  | 
        
        
           | 51 | 
           cycrow | 
           1188 | 
              | 
        
        
            | 
            | 
           1189 | 
           		switch(pFile->GetFileType())
  | 
        
        
            | 
            | 
           1190 | 
           		{
  | 
        
        
            | 
            | 
           1191 | 
           			case FILETYPE_SCRIPT:
  | 
        
        
            | 
            | 
           1192 | 
           			case FILETYPE_UNINSTALL:
  | 
        
        
            | 
            | 
           1193 | 
           				CLog::log(CLog::Log_Install, 2, "Updating file signature");
  | 
        
        
           | 160 | 
           cycrow | 
           1194 | 
           				pFile->updateSignature();
  | 
        
        
           | 51 | 
           cycrow | 
           1195 | 
           				break;
  | 
        
        
            | 
            | 
           1196 | 
           		}
  | 
        
        
            | 
            | 
           1197 | 
           	}
  | 
        
        
            | 
            | 
           1198 | 
           }
  | 
        
        
            | 
            | 
           1199 | 
              | 
        
        
           | 197 | 
           cycrow | 
           1200 | 
           bool CBaseFile::installFiles(const Utils::WString &destdir, CProgressInfo *progress, CLinkList<C_File> *filelist, Utils::WStringList *errorStr, bool enabled, CPackages *packages )
  | 
        
        
           | 43 | 
           cycrow | 
           1201 | 
           {
  | 
        
        
           | 50 | 
           cycrow | 
           1202 | 
           	//TODO: add errorStr and progress as member variables
  | 
        
        
           | 43 | 
           cycrow | 
           1203 | 
           	if ( enabled ) {
  | 
        
        
           | 14 | 
           cycrow | 
           1204 | 
           		this->_install_adjustFakePatches(packages);
  | 
        
        
           | 43 | 
           cycrow | 
           1205 | 
           		if ( packages ) this->_install_renameText(packages);
  | 
        
        
           | 6 | 
           cycrow | 
           1206 | 
           	}
  | 
        
        
            | 
            | 
           1207 | 
              | 
        
        
           | 50 | 
           cycrow | 
           1208 | 
           	bool bFailed = false;
  | 
        
        
            | 
            | 
           1209 | 
              | 
        
        
           | 6 | 
           cycrow | 
           1210 | 
           	CDirIO Dir(destdir);
  | 
        
        
            | 
            | 
           1211 | 
           	int fileCount = 0;
  | 
        
        
            | 
            | 
           1212 | 
           	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
  | 
        
        
            | 
            | 
           1213 | 
           	{
  | 
        
        
            | 
            | 
           1214 | 
           		C_File *fit = node->Data();
  | 
        
        
            | 
            | 
           1215 | 
              | 
        
        
           | 50 | 
           cycrow | 
           1216 | 
           		// start the install process, check if we need to the file enabled or disabled
  | 
        
        
           | 178 | 
           cycrow | 
           1217 | 
           		CLog::logf(CLog::Log_Install, 1, "Preparing to install file: %s", fit->getNameDirectory(this).c_str());
  | 
        
        
           | 50 | 
           cycrow | 
           1218 | 
           		bool fileEnabled = _install_setEnabled(enabled, fit);
  | 
        
        
            | 
            | 
           1219 | 
              | 
        
        
            | 
            | 
           1220 | 
           		// check if the file is for the correct game version
  | 
        
        
           | 147 | 
           cycrow | 
           1221 | 
           		if (!fit->isForGame(packages->GetGame())) 
  | 
        
        
            | 
            | 
           1222 | 
           		{
  | 
        
        
            | 
            | 
           1223 | 
           			CLog::logf(CLog::Log_Install, 1, "File didn't match game version, skipping, %d != %d", fit->game(), packages->GetGame());
  | 
        
        
            | 
            | 
           1224 | 
           			continue;
  | 
        
        
           | 6 | 
           cycrow | 
           1225 | 
           		}
  | 
        
        
            | 
            | 
           1226 | 
              | 
        
        
           | 50 | 
           cycrow | 
           1227 | 
           		// update the progress display to show we are processing this file
  | 
        
        
            | 
            | 
           1228 | 
           		if ( progress ) {
  | 
        
        
            | 
            | 
           1229 | 
           			if ( progress->IsSecond() ) progress->SwitchSecond();
  | 
        
        
           | 6 | 
           cycrow | 
           1230 | 
           			progress->UpdateFile ( fit );
  | 
        
        
            | 
            | 
           1231 | 
           			progress->UpdateProgress(fileCount++, m_lFiles.size());
  | 
        
        
            | 
            | 
           1232 | 
           			progress->SwitchSecond();
  | 
        
        
            | 
            | 
           1233 | 
           		}
  | 
        
        
            | 
            | 
           1234 | 
              | 
        
        
            | 
            | 
           1235 | 
           		// first uncompress the file
  | 
        
        
           | 50 | 
           cycrow | 
           1236 | 
           		//TODO: add this flag to C_File
  | 
        
        
            | 
            | 
           1237 | 
           		bool uncomprToFile;
  | 
        
        
            | 
            | 
           1238 | 
           		if ( !this->_install_uncompress(fit, progress, errorStr, &uncomprToFile) ) {
  | 
        
        
            | 
            | 
           1239 | 
           			bFailed = true;
  | 
        
        
            | 
            | 
           1240 | 
           			continue;
  | 
        
        
           | 6 | 
           cycrow | 
           1241 | 
           		}
  | 
        
        
            | 
            | 
           1242 | 
              | 
        
        
           | 175 | 
           cycrow | 
           1243 | 
           		bool dofile = _install_checkVersion(fit, destdir);
  | 
        
        
           | 6 | 
           cycrow | 
           1244 | 
              | 
        
        
            | 
            | 
           1245 | 
           		// change file pointer
  | 
        
        
           | 197 | 
           cycrow | 
           1246 | 
           		Utils::WString sInstallDir = _install_adjustFilepointer(fit, fileEnabled, destdir);
  | 
        
        
           | 6 | 
           cycrow | 
           1247 | 
              | 
        
        
            | 
            | 
           1248 | 
           		C_File *adjustPointer = NULL;
  | 
        
        
            | 
            | 
           1249 | 
              | 
        
        
           | 50 | 
           cycrow | 
           1250 | 
           		if ( filelist ) {
  | 
        
        
           | 98 | 
           cycrow | 
           1251 | 
           			C_File *cFile = _install_checkFile(fit, errorStr, &dofile, filelist);
  | 
        
        
           | 6 | 
           cycrow | 
           1252 | 
              | 
        
        
            | 
            | 
           1253 | 
           			// no matching file found, adding to main list
  | 
        
        
           | 50 | 
           cycrow | 
           1254 | 
           			if ( !cFile ) filelist->push_back ( fit );
  | 
        
        
           | 6 | 
           cycrow | 
           1255 | 
           			else
  | 
        
        
            | 
            | 
           1256 | 
           			{
  | 
        
        
            | 
            | 
           1257 | 
           				// if the file is not enabled, we need to check for any that might be enabled
  | 
        
        
           | 51 | 
           cycrow | 
           1258 | 
           				if ( !fileEnabled ) //_install_checkDisabled(cFile, destdir, errorStr);
  | 
        
        
           | 6 | 
           cycrow | 
           1259 | 
           				{
  | 
        
        
           | 50 | 
           cycrow | 
           1260 | 
           					//TODO: check what this is actually doing
  | 
        
        
           | 160 | 
           cycrow | 
           1261 | 
           					if ( !cFile->getUsed() )
  | 
        
        
           | 6 | 
           cycrow | 
           1262 | 
           					{
  | 
        
        
           | 160 | 
           cycrow | 
           1263 | 
           						CFileIO rFile(cFile->filePointer());
  | 
        
        
           | 52 | 
           cycrow | 
           1264 | 
           						if ( rFile.exists() )
  | 
        
        
           | 6 | 
           cycrow | 
           1265 | 
           						{
  | 
        
        
            | 
            | 
           1266 | 
           							if ( errorStr )
  | 
        
        
            | 
            | 
           1267 | 
           							{
  | 
        
        
           | 52 | 
           cycrow | 
           1268 | 
           								if ( rFile.remove() )
  | 
        
        
           | 175 | 
           cycrow | 
           1269 | 
           									errorStr->pushBack(cFile->filePointer().findRemove(destdir), ERRORLOG(SPKINSTALL_DELETEFILE));
  | 
        
        
           | 6 | 
           cycrow | 
           1270 | 
           								else
  | 
        
        
           | 175 | 
           cycrow | 
           1271 | 
           									errorStr->pushBack(cFile->filePointer().findRemove(destdir), ERRORLOG(SPKINSTALL_DELETEFILE_FAIL));
  | 
        
        
           | 6 | 
           cycrow | 
           1272 | 
           							}
  | 
        
        
            | 
            | 
           1273 | 
           						}
  | 
        
        
           | 160 | 
           cycrow | 
           1274 | 
           						cFile->setFilename(fit->filePointer());
  | 
        
        
           | 6 | 
           cycrow | 
           1275 | 
           						cFile->SetDisabled(true);
  | 
        
        
            | 
            | 
           1276 | 
           					}
  | 
        
        
            | 
            | 
           1277 | 
           					else
  | 
        
        
            | 
            | 
           1278 | 
           					{
  | 
        
        
           | 160 | 
           cycrow | 
           1279 | 
           						fit->setFullDir(sInstallDir + fit->getDirectory(this));
  | 
        
        
           | 51 | 
           cycrow | 
           1280 | 
           						fit->SetDisabled(false);
  | 
        
        
           | 6 | 
           cycrow | 
           1281 | 
           					}
  | 
        
        
            | 
            | 
           1282 | 
           				}
  | 
        
        
            | 
            | 
           1283 | 
           				// move it to enabled
  | 
        
        
           | 50 | 
           cycrow | 
           1284 | 
           				else {
  | 
        
        
           | 175 | 
           cycrow | 
           1285 | 
           					if ( !this->_install_checkFileEnable(cFile, fit, destdir, fileEnabled, errorStr) ) {
  | 
        
        
           | 50 | 
           cycrow | 
           1286 | 
           						bFailed = true;
  | 
        
        
            | 
            | 
           1287 | 
           						continue;
  | 
        
        
           | 6 | 
           cycrow | 
           1288 | 
           					}
  | 
        
        
            | 
            | 
           1289 | 
           				}
  | 
        
        
            | 
            | 
           1290 | 
              | 
        
        
            | 
            | 
           1291 | 
           				adjustPointer = cFile;
  | 
        
        
           | 50 | 
           cycrow | 
           1292 | 
           				if ( dofile ) adjustPointer->SetCreationTime(fit->GetCreationTime());
  | 
        
        
           | 6 | 
           cycrow | 
           1293 | 
           			}
  | 
        
        
            | 
            | 
           1294 | 
           		}
  | 
        
        
            | 
            | 
           1295 | 
              | 
        
        
            | 
            | 
           1296 | 
           		if ( dofile )
  | 
        
        
            | 
            | 
           1297 | 
           		{
  | 
        
        
            | 
            | 
           1298 | 
           			// uncompressed to file, rename and move
  | 
        
        
            | 
            | 
           1299 | 
           			if ( uncomprToFile )
  | 
        
        
            | 
            | 
           1300 | 
           			{
  | 
        
        
           | 134 | 
           cycrow | 
           1301 | 
           				_iLastError = SPKERR_WRITEFILE;
  | 
        
        
           | 197 | 
           cycrow | 
           1302 | 
           				Utils::WString to = fit->getDirectory(this);
  | 
        
        
            | 
            | 
           1303 | 
           				if ( !fileEnabled )	to = L"PluginManager/Disabled/" + to;
  | 
        
        
           | 6 | 
           cycrow | 
           1304 | 
              | 
        
        
           | 134 | 
           cycrow | 
           1305 | 
           				if ( !_install_createDirectory(Dir, to, fit, errorStr) ) {
  | 
        
        
           | 51 | 
           cycrow | 
           1306 | 
           					bFailed = true;
  | 
        
        
            | 
            | 
           1307 | 
           					continue;
  | 
        
        
           | 6 | 
           cycrow | 
           1308 | 
           				}
  | 
        
        
            | 
            | 
           1309 | 
              | 
        
        
           | 197 | 
           cycrow | 
           1310 | 
           				bool err = true;
  | 
        
        
           | 134 | 
           cycrow | 
           1311 | 
           				_sLastError = to;
  | 
        
        
           | 197 | 
           cycrow | 
           1312 | 
           				if ( !fit->getTempFile().empty())
  | 
        
        
            | 
            | 
           1313 | 
           					err = CFileIO::Rename(fit->getTempFile(), to);
  | 
        
        
           | 51 | 
           cycrow | 
           1314 | 
           				if ( err ) {
  | 
        
        
            | 
            | 
           1315 | 
           					bFailed = true;
  | 
        
        
            | 
            | 
           1316 | 
           					continue;
  | 
        
        
            | 
            | 
           1317 | 
           				}
  | 
        
        
           | 6 | 
           cycrow | 
           1318 | 
           			}
  | 
        
        
            | 
            | 
           1319 | 
           			//otherwise, just extract the file
  | 
        
        
            | 
            | 
           1320 | 
           			else
  | 
        
        
            | 
            | 
           1321 | 
           			{
  | 
        
        
            | 
            | 
           1322 | 
           				// old file is found in list, switch to using new one
  | 
        
        
           | 50 | 
           cycrow | 
           1323 | 
           				if ( (filelist) && (adjustPointer) ) {
  | 
        
        
           | 6 | 
           cycrow | 
           1324 | 
           					adjustPointer->CopyData(fit, false);
  | 
        
        
           | 50 | 
           cycrow | 
           1325 | 
           					CLog::log(CLog::Log_Install, 2, "Copying data into existing file");
  | 
        
        
            | 
            | 
           1326 | 
           				}
  | 
        
        
           | 6 | 
           cycrow | 
           1327 | 
              | 
        
        
           | 197 | 
           cycrow | 
           1328 | 
           				Utils::WString fpointer = fit->filePointer();
  | 
        
        
           | 134 | 
           cycrow | 
           1329 | 
           				_iLastError = SPKERR_CREATEDIRECTORY;
  | 
        
        
           | 197 | 
           cycrow | 
           1330 | 
           				Utils::WString dir = CFileIO(fit->filePointer()).dir().toString();
  | 
        
        
           | 6 | 
           cycrow | 
           1331 | 
              | 
        
        
           | 175 | 
           cycrow | 
           1332 | 
           				dir = dir.findRemove(destdir);
  | 
        
        
           | 149 | 
           cycrow | 
           1333 | 
           				if (!dir.empty() && (dir[0] == '/' || dir[0] == '\\')) 
  | 
        
        
            | 
            | 
           1334 | 
           					dir.erase(0, 1);
  | 
        
        
           | 6 | 
           cycrow | 
           1335 | 
              | 
        
        
           | 134 | 
           cycrow | 
           1336 | 
           				if ( !_install_createDirectory(Dir, dir, fit, errorStr) ) {
  | 
        
        
           | 51 | 
           cycrow | 
           1337 | 
           					bFailed = true;
  | 
        
        
            | 
            | 
           1338 | 
           					continue;
  | 
        
        
           | 6 | 
           cycrow | 
           1339 | 
           				}
  | 
        
        
            | 
            | 
           1340 | 
              | 
        
        
           | 175 | 
           cycrow | 
           1341 | 
           				_install_writeFile(fit, destdir, errorStr);
  | 
        
        
           | 6 | 
           cycrow | 
           1342 | 
           			}
  | 
        
        
            | 
            | 
           1343 | 
           			ClearError ();
  | 
        
        
            | 
            | 
           1344 | 
           		}
  | 
        
        
            | 
            | 
           1345 | 
              | 
        
        
            | 
            | 
           1346 | 
           		if ( adjustPointer )
  | 
        
        
            | 
            | 
           1347 | 
           		{
  | 
        
        
           | 50 | 
           cycrow | 
           1348 | 
           			CLog::log(CLog::Log_Install, 2, "Adjusting pointers to existing file and deleting new file pointer");
  | 
        
        
           | 6 | 
           cycrow | 
           1349 | 
           			node->ChangeData(adjustPointer);
  | 
        
        
            | 
            | 
           1350 | 
           			delete fit;
  | 
        
        
            | 
            | 
           1351 | 
           		}
  | 
        
        
           | 50 | 
           cycrow | 
           1352 | 
              | 
        
        
            | 
            | 
           1353 | 
           		CLog::log(CLog::Log_Install, 1, "File installation completed");
  | 
        
        
           | 6 | 
           cycrow | 
           1354 | 
           	}
  | 
        
        
            | 
            | 
           1355 | 
              | 
        
        
            | 
            | 
           1356 | 
           	// now clear or data memory
  | 
        
        
           | 50 | 
           cycrow | 
           1357 | 
           	CLog::log(CLog::Log_Install, 2, "Delting temporary file data from memory");
  | 
        
        
           | 51 | 
           cycrow | 
           1358 | 
           	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() ) node->Data()->DeleteData();
  | 
        
        
           | 6 | 
           cycrow | 
           1359 | 
              | 
        
        
           | 50 | 
           cycrow | 
           1360 | 
           	return !bFailed;
  | 
        
        
           | 6 | 
           cycrow | 
           1361 | 
           }
  | 
        
        
            | 
            | 
           1362 | 
              | 
        
        
            | 
            | 
           1363 | 
           /*######################################################################################################*/
  | 
        
        
            | 
            | 
           1364 | 
              | 
        
        
            | 
            | 
           1365 | 
              | 
        
        
            | 
            | 
           1366 | 
           /*
  | 
        
        
            | 
            | 
           1367 | 
           	Func:   ParseHeader
  | 
        
        
            | 
            | 
           1368 | 
           	Input:  Header String - string formated directly from the file
  | 
        
        
            | 
            | 
           1369 | 
           	Return: Boolean - If string is a valid header
  | 
        
        
            | 
            | 
           1370 | 
           	Desc:   Splits up the main header string to get all required settings
  | 
        
        
            | 
            | 
           1371 | 
           */
  | 
        
        
           | 175 | 
           cycrow | 
           1372 | 
           bool CBaseFile::_parseHeader(const Utils::String &header)
  | 
        
        
           | 6 | 
           cycrow | 
           1373 | 
           {
  | 
        
        
           | 175 | 
           cycrow | 
           1374 | 
           	if ( !this->_checkHeader(header.token(";", 1)))
  | 
        
        
           | 6 | 
           cycrow | 
           1375 | 
           		return false;
  | 
        
        
            | 
            | 
           1376 | 
              | 
        
        
           | 175 | 
           cycrow | 
           1377 | 
           	m_SHeader.fVersion = header.token(";", 2).toFloat();
  | 
        
        
           | 6 | 
           cycrow | 
           1378 | 
           	if ( m_SHeader.fVersion > FILEVERSION )
  | 
        
        
            | 
            | 
           1379 | 
           		return false;
  | 
        
        
            | 
            | 
           1380 | 
              | 
        
        
           | 175 | 
           cycrow | 
           1381 | 
           	m_SHeader.iValueCompression = header.token(";", 3).toInt();
  | 
        
        
            | 
            | 
           1382 | 
           	m_SHeader.lValueCompressSize = header.token(";", 4).toLong();
  | 
        
        
           | 6 | 
           cycrow | 
           1383 | 
              | 
        
        
            | 
            | 
           1384 | 
           	return true;
  | 
        
        
            | 
            | 
           1385 | 
           }
  | 
        
        
            | 
            | 
           1386 | 
              | 
        
        
           | 175 | 
           cycrow | 
           1387 | 
           bool CBaseFile::_checkHeader(const Utils::String header) const
  | 
        
        
           | 6 | 
           cycrow | 
           1388 | 
           {
  | 
        
        
            | 
            | 
           1389 | 
           	if ( header.Compare("BaseCycrow") )
  | 
        
        
            | 
            | 
           1390 | 
           		return true;
  | 
        
        
            | 
            | 
           1391 | 
           	return false;
  | 
        
        
            | 
            | 
           1392 | 
           }
  | 
        
        
            | 
            | 
           1393 | 
              | 
        
        
            | 
            | 
           1394 | 
           /*
  | 
        
        
            | 
            | 
           1395 | 
           	Func:   ParseFileHeader
  | 
        
        
            | 
            | 
           1396 | 
           	Input:  Header String - string formated directly from the file
  | 
        
        
            | 
            | 
           1397 | 
           	Return: Boolean - If string is a valid header
  | 
        
        
            | 
            | 
           1398 | 
           	Desc:   Splits up the file header string to get all required settings
  | 
        
        
            | 
            | 
           1399 | 
           */
  | 
        
        
           | 175 | 
           cycrow | 
           1400 | 
           bool CBaseFile::_parseFileHeader(const Utils::String &header)
  | 
        
        
           | 6 | 
           cycrow | 
           1401 | 
           {
  | 
        
        
           | 175 | 
           cycrow | 
           1402 | 
           	if (header.token(";", 1) != "FileHeader")
  | 
        
        
           | 6 | 
           cycrow | 
           1403 | 
           		return false;
  | 
        
        
            | 
            | 
           1404 | 
              | 
        
        
           | 175 | 
           cycrow | 
           1405 | 
           	m_SHeader2.iNumFiles = header.token(";", 2).toInt();
  | 
        
        
            | 
            | 
           1406 | 
           	m_SHeader2.lSize = header.token(";", 3).toInt();
  | 
        
        
            | 
            | 
           1407 | 
           	m_SHeader2.lFullSize = header.token(";", 4).toInt();
  | 
        
        
            | 
            | 
           1408 | 
           	m_SHeader2.iFileCompression = header.token(";", 5).toInt();
  | 
        
        
            | 
            | 
           1409 | 
           	m_SHeader2.iDataCompression = header.token(";", 6).toInt();
  | 
        
        
           | 6 | 
           cycrow | 
           1410 | 
              | 
        
        
            | 
            | 
           1411 | 
           	return true;
  | 
        
        
            | 
            | 
           1412 | 
           }
  | 
        
        
            | 
            | 
           1413 | 
              | 
        
        
            | 
            | 
           1414 | 
              | 
        
        
            | 
            | 
           1415 | 
           /*
  | 
        
        
            | 
            | 
           1416 | 
           	Func:   ParseValueLine
  | 
        
        
            | 
            | 
           1417 | 
           	Input:  String - single line from a file to set
  | 
        
        
            | 
            | 
           1418 | 
           	Return: Boolean - returns true if value exists
  | 
        
        
            | 
            | 
           1419 | 
           	Desc:   Reads the line and assigns the parameters for the file
  | 
        
        
            | 
            | 
           1420 | 
           */
  | 
        
        
           | 207 | 
           cycrow | 
           1421 | 
           bool CBaseFile::parseValueLine(const Utils::WString &sLine)
  | 
        
        
           | 6 | 
           cycrow | 
           1422 | 
           {
  | 
        
        
           | 207 | 
           cycrow | 
           1423 | 
           	Utils::WString first = sLine.token(L" ", 1);
  | 
        
        
            | 
            | 
           1424 | 
           	Utils::WString rest  = sLine.tokens(L" ", 2);
  | 
        
        
           | 6 | 
           cycrow | 
           1425 | 
              | 
        
        
           | 207 | 
           cycrow | 
           1426 | 
           	if ( first.Compare(L"Name:") )					this->setName(rest);
  | 
        
        
            | 
            | 
           1427 | 
           	else if ( first.Compare(L"Author:") )			this->setAuthor(rest);
  | 
        
        
            | 
            | 
           1428 | 
           	else if ( first.Compare(L"Version:") )			this->setVersion(rest);
  | 
        
        
            | 
            | 
           1429 | 
           	else if ( first.Compare(L"fGameVersion:") ) {
  | 
        
        
           | 6 | 
           cycrow | 
           1430 | 
           		if ( m_lGames.Back() ) {
  | 
        
        
           | 207 | 
           cycrow | 
           1431 | 
           			m_lGames.Back()->Data()->sVersion = rest;
  | 
        
        
           | 6 | 
           cycrow | 
           1432 | 
           		}
  | 
        
        
            | 
            | 
           1433 | 
           	}
  | 
        
        
           | 207 | 
           cycrow | 
           1434 | 
           	else if ( first.Compare(L"GameVersion:") ) {
  | 
        
        
           | 6 | 
           cycrow | 
           1435 | 
           		if ( m_lGames.Back() ) {
  | 
        
        
           | 197 | 
           cycrow | 
           1436 | 
           			m_lGames.Back()->Data()->iVersion = rest.toInt();
  | 
        
        
           | 6 | 
           cycrow | 
           1437 | 
           		}
  | 
        
        
            | 
            | 
           1438 | 
           	}
  | 
        
        
           | 207 | 
           cycrow | 
           1439 | 
           	else if ( first.Compare(L"Game:") )
  | 
        
        
            | 
            | 
           1440 | 
           		this->AddGameCompatability(rest, L"");
  | 
        
        
            | 
            | 
           1441 | 
           	else if ( first.Compare(L"GameCompat:") )
  | 
        
        
            | 
            | 
           1442 | 
           		this->AddGameCompatability(rest.token(L" ", 1), rest.tokens(L" ", 2).toString());
  | 
        
        
            | 
            | 
           1443 | 
           	else if ( first.Compare(L"GameCompatExact:") )
  | 
        
        
            | 
            | 
           1444 | 
           		this->AddGameCompatability(rest.token(L" ", 1), rest.tokens(L" ", 2).toString());
  | 
        
        
            | 
            | 
           1445 | 
           	else if ( first.Compare(L"Date:") )				this->setCreationDate(rest);
  | 
        
        
            | 
            | 
           1446 | 
           	else if ( first.Compare(L"WebAddress:") )		this->setWebAddress(rest);
  | 
        
        
            | 
            | 
           1447 | 
           	else if ( first.Compare(L"WebSite:") )			this->setWebSite(rest);
  | 
        
        
            | 
            | 
           1448 | 
           	else if ( first.Compare(L"Email:") )				this->setEmail(rest);
  | 
        
        
            | 
            | 
           1449 | 
           	else if ( first.Compare(L"WebMirror1:") || first.Compare(L"Mirror1:") || first.Compare(L"WebMirror:") )
  | 
        
        
            | 
            | 
           1450 | 
           		this->addWebMirror(rest.toString());
  | 
        
        
            | 
            | 
           1451 | 
           	else if ( first.Compare(L"WebMirror2:") || first.Compare(L"Mirror2:") )
  | 
        
        
            | 
            | 
           1452 | 
           		this->addWebMirror(rest.toString());
  | 
        
        
            | 
            | 
           1453 | 
           	else if ( first.Compare(L"PluginType:") )		this->setPluginType(rest);
  | 
        
        
            | 
            | 
           1454 | 
           	else if ( first.Compare(L"Desc:") )				this->setDescription(rest);
  | 
        
        
            | 
            | 
           1455 | 
           	else if ( first.Compare(L"UninstallAfter:") )	this->addUninstallText(parseLanguage(rest.token(L"|", 1)), false, rest.tokens(L"|", 2));
  | 
        
        
            | 
            | 
           1456 | 
           	else if ( first.Compare(L"UninstallBefore:") )	this->addUninstallText(parseLanguage(rest.token(L"|", 1)), true, rest.tokens(L"|", 2));
  | 
        
        
            | 
            | 
           1457 | 
           	else if ( first.Compare(L"InstallAfter:") )		this->addInstallText(parseLanguage(rest.token(L"|", 1)), false, rest.tokens(L"|", 2));
  | 
        
        
            | 
            | 
           1458 | 
           	else if ( first.Compare(L"InstallBefore:") )	this->addInstallText(parseLanguage(rest.token(L"|", 1)), true, rest.tokens(L"|", 2));
  | 
        
        
            | 
            | 
           1459 | 
           	else if ( first.Compare(L"ScriptName:") )		addName(parseLanguage(rest.token(L":", 1)), rest.token(L":", 2));
  | 
        
        
            | 
            | 
           1460 | 
           	else if ( first.Compare(L"GameChanging:") )		this->setGameChanging(rest);
  | 
        
        
            | 
            | 
           1461 | 
           	else if ( first.Compare(L"EaseOfUse:") )		this->setEaseOfUse(rest);
  | 
        
        
            | 
            | 
           1462 | 
           	else if ( first.Compare(L"Recommended:") )		this->setRecommended(rest);
  | 
        
        
            | 
            | 
           1463 | 
           	else if ( first.Compare(L"NeededLibrary:") )
  | 
        
        
            | 
            | 
           1464 | 
           		this->addNeededLibrary(rest.token(L"||", 1), rest.token(L"||", 2), rest.token(L"||", 3));
  | 
        
        
            | 
            | 
           1465 | 
           	else if ( first.Compare(L"FakePatchBefore:") )
  | 
        
        
            | 
            | 
           1466 | 
           		this->addFakePatchOrder(false, rest.token(L"||", 1), rest.token(L"||", 2));
  | 
        
        
            | 
            | 
           1467 | 
           	else if ( first.Compare(L"FakePatchAfter:") )
  | 
        
        
            | 
            | 
           1468 | 
           		this->addFakePatchOrder(true, rest.token(L"||", 1), rest.token(L"||", 2));
  | 
        
        
            | 
            | 
           1469 | 
           	else if ( first.Compare(L"ForumLink:") )			this->setForumLink(rest);
  | 
        
        
           | 6 | 
           cycrow | 
           1470 | 
           	else
  | 
        
        
            | 
            | 
           1471 | 
           		return false;
  | 
        
        
            | 
            | 
           1472 | 
              | 
        
        
            | 
            | 
           1473 | 
           	return true;
  | 
        
        
            | 
            | 
           1474 | 
           }
  | 
        
        
            | 
            | 
           1475 | 
              | 
        
        
           | 207 | 
           cycrow | 
           1476 | 
           int CBaseFile::parseLanguage(const Utils::WString &lang) const
  | 
        
        
           | 6 | 
           cycrow | 
           1477 | 
           {
  | 
        
        
           | 48 | 
           cycrow | 
           1478 | 
           	int langID = lang;
  | 
        
        
            | 
            | 
           1479 | 
           	if ( !langID ) {
  | 
        
        
           | 207 | 
           cycrow | 
           1480 | 
           		if (lang.Compare(L"english"))		return 44;
  | 
        
        
            | 
            | 
           1481 | 
           		else if (lang.Compare(L"default"))	return 0;
  | 
        
        
            | 
            | 
           1482 | 
           		else if (lang.Compare(L"german"))	return 49;
  | 
        
        
            | 
            | 
           1483 | 
           		else if (lang.Compare(L"russian"))	return 7;
  | 
        
        
            | 
            | 
           1484 | 
           		else if (lang.Compare(L"spanish"))	return 34;
  | 
        
        
            | 
            | 
           1485 | 
           		else if (lang.Compare(L"french"))	return 33;
  | 
        
        
           | 6 | 
           cycrow | 
           1486 | 
           	}
  | 
        
        
            | 
            | 
           1487 | 
              | 
        
        
            | 
            | 
           1488 | 
           	return langID;
  | 
        
        
            | 
            | 
           1489 | 
           }
  | 
        
        
            | 
            | 
           1490 | 
              | 
        
        
            | 
            | 
           1491 | 
           /*
  | 
        
        
            | 
            | 
           1492 | 
           	Func:   ReadValues
  | 
        
        
            | 
            | 
           1493 | 
           	Input:  String - values in one long line
  | 
        
        
            | 
            | 
           1494 | 
           	Desc:   splits the values data into each line to read the data
  | 
        
        
            | 
            | 
           1495 | 
           */
  | 
        
        
           | 207 | 
           cycrow | 
           1496 | 
           void CBaseFile::_readValues(const Utils::WString &values)
  | 
        
        
           | 6 | 
           cycrow | 
           1497 | 
           {
  | 
        
        
           | 207 | 
           cycrow | 
           1498 | 
           	std::vector<Utils::WString> lines;
  | 
        
        
            | 
            | 
           1499 | 
           	values.tokenise(L"\n", lines);
  | 
        
        
           | 6 | 
           cycrow | 
           1500 | 
              | 
        
        
           | 207 | 
           cycrow | 
           1501 | 
           	for (size_t i = 0; i < lines.size(); i++)
  | 
        
        
            | 
            | 
           1502 | 
           		parseValueLine(lines[i]);
  | 
        
        
           | 6 | 
           cycrow | 
           1503 | 
           }
  | 
        
        
            | 
            | 
           1504 | 
              | 
        
        
            | 
            | 
           1505 | 
           /*
  | 
        
        
            | 
            | 
           1506 | 
           	Func:   ParseFilesLine
  | 
        
        
            | 
            | 
           1507 | 
           	Input:  String - single line from a file to set
  | 
        
        
            | 
            | 
           1508 | 
           	Return: Boolean - returns true if value exists
  | 
        
        
            | 
            | 
           1509 | 
           	Desc:   Reads the line and assigns the parameters for the file
  | 
        
        
            | 
            | 
           1510 | 
           */
  | 
        
        
           | 175 | 
           cycrow | 
           1511 | 
           bool CBaseFile::_parseFilesLine(const Utils::String &line)
  | 
        
        
           | 6 | 
           cycrow | 
           1512 | 
           {
  | 
        
        
           | 127 | 
           cycrow | 
           1513 | 
           	if ( !line.contains(":") )
  | 
        
        
           | 6 | 
           cycrow | 
           1514 | 
           		return false;
  | 
        
        
            | 
            | 
           1515 | 
              | 
        
        
           | 127 | 
           cycrow | 
           1516 | 
           	Utils::String command = line.token(":", 1);
  | 
        
        
           | 6 | 
           cycrow | 
           1517 | 
              | 
        
        
           | 127 | 
           cycrow | 
           1518 | 
           	long size = line.token(":", 2).toInt();
  | 
        
        
            | 
            | 
           1519 | 
           	long usize = line.token(":", 3).toInt ();
  | 
        
        
            | 
            | 
           1520 | 
           	long compression = line.token(":", 4).toInt ();
  | 
        
        
           | 6 | 
           cycrow | 
           1521 | 
              | 
        
        
            | 
            | 
           1522 | 
           	if ( command == "Icon" )
  | 
        
        
            | 
            | 
           1523 | 
           	{
  | 
        
        
           | 197 | 
           cycrow | 
           1524 | 
           		_sIconExt = line.token(":", 5).toWString();
  | 
        
        
           | 6 | 
           cycrow | 
           1525 | 
           		m_pIconFile = new C_File ();
  | 
        
        
            | 
            | 
           1526 | 
           		m_pIconFile->SetDataSize ( size - 4 );
  | 
        
        
            | 
            | 
           1527 | 
           		m_pIconFile->SetDataCompression ( compression );
  | 
        
        
            | 
            | 
           1528 | 
           		m_pIconFile->SetUncompressedDataSize ( usize );
  | 
        
        
            | 
            | 
           1529 | 
              | 
        
        
            | 
            | 
           1530 | 
           		return true;
  | 
        
        
            | 
            | 
           1531 | 
           	}
  | 
        
        
            | 
            | 
           1532 | 
              | 
        
        
           | 127 | 
           cycrow | 
           1533 | 
           	time_t time = line.token(":", 5).toLong();
  | 
        
        
            | 
            | 
           1534 | 
           	bool compressToFile = (line.token(":", 6).toInt() == 1) ? true : false;
  | 
        
        
            | 
            | 
           1535 | 
           	Utils::String name  = line.token(":", 7);
  | 
        
        
            | 
            | 
           1536 | 
           	Utils::String dir = line.token(":", 8);
  | 
        
        
           | 6 | 
           cycrow | 
           1537 | 
              | 
        
        
           | 127 | 
           cycrow | 
           1538 | 
           	if ( name.empty() )
  | 
        
        
           | 6 | 
           cycrow | 
           1539 | 
           		return true;
  | 
        
        
            | 
            | 
           1540 | 
              | 
        
        
            | 
            | 
           1541 | 
           	bool shared = false;
  | 
        
        
           | 127 | 
           cycrow | 
           1542 | 
           	if ( command.left(1) == "$" )
  | 
        
        
           | 6 | 
           cycrow | 
           1543 | 
           	{
  | 
        
        
            | 
            | 
           1544 | 
           		shared = true;
  | 
        
        
           | 127 | 
           cycrow | 
           1545 | 
           		command.erase(0, 1);
  | 
        
        
           | 6 | 
           cycrow | 
           1546 | 
           	}
  | 
        
        
            | 
            | 
           1547 | 
              | 
        
        
           | 127 | 
           cycrow | 
           1548 | 
           	FileType type = FILETYPE_UNKNOWN;
  | 
        
        
           | 6 | 
           cycrow | 
           1549 | 
           	if ( command == "Script" )
  | 
        
        
            | 
            | 
           1550 | 
           		type = FILETYPE_SCRIPT;
  | 
        
        
            | 
            | 
           1551 | 
           	else if ( command == "Text" )
  | 
        
        
            | 
            | 
           1552 | 
           		type = FILETYPE_TEXT;
  | 
        
        
            | 
            | 
           1553 | 
           	else if ( command == "Readme" )
  | 
        
        
            | 
            | 
           1554 | 
           		type = FILETYPE_README;
  | 
        
        
            | 
            | 
           1555 | 
           	else if ( command == "Map" )
  | 
        
        
            | 
            | 
           1556 | 
           		type = FILETYPE_MAP;
  | 
        
        
            | 
            | 
           1557 | 
           	else if ( command == "Mod" )
  | 
        
        
            | 
            | 
           1558 | 
           		type = FILETYPE_MOD;
  | 
        
        
            | 
            | 
           1559 | 
           	else if ( command == "Uninstall" )
  | 
        
        
            | 
            | 
           1560 | 
           		type = FILETYPE_UNINSTALL;
  | 
        
        
            | 
            | 
           1561 | 
           	else if ( command == "Sound" )
  | 
        
        
            | 
            | 
           1562 | 
           		type = FILETYPE_SOUND;
  | 
        
        
            | 
            | 
           1563 | 
           	else if ( command == "Mission" )
  | 
        
        
            | 
            | 
           1564 | 
           		type = FILETYPE_MISSION;
  | 
        
        
            | 
            | 
           1565 | 
           	else if ( command == "Extra" )
  | 
        
        
            | 
            | 
           1566 | 
           		type = FILETYPE_EXTRA;
  | 
        
        
            | 
            | 
           1567 | 
           	else if ( command == "Screen" )
  | 
        
        
            | 
            | 
           1568 | 
           		type = FILETYPE_SCREEN;
  | 
        
        
            | 
            | 
           1569 | 
           	else if ( command == "Backup" )
  | 
        
        
            | 
            | 
           1570 | 
           		type = FILETYPE_BACKUP;
  | 
        
        
            | 
            | 
           1571 | 
           	else if ( command == "Advert" )
  | 
        
        
            | 
            | 
           1572 | 
           		type = FILETYPE_ADVERT;
  | 
        
        
            | 
            | 
           1573 | 
           	else if ( command == "ShipScene" )
  | 
        
        
            | 
            | 
           1574 | 
           		type = FILETYPE_SHIPSCENE;
  | 
        
        
            | 
            | 
           1575 | 
           	else if ( command == "CockpitScene" )
  | 
        
        
            | 
            | 
           1576 | 
           		type = FILETYPE_COCKPITSCENE;
  | 
        
        
            | 
            | 
           1577 | 
           	else if ( command == "ShipOther" )
  | 
        
        
            | 
            | 
           1578 | 
           		type = FILETYPE_SHIPOTHER;
  | 
        
        
            | 
            | 
           1579 | 
           	else if ( command == "ShipModel" )
  | 
        
        
            | 
            | 
           1580 | 
           		type = FILETYPE_SHIPMODEL;
  | 
        
        
            | 
            | 
           1581 | 
              | 
        
        
           | 127 | 
           cycrow | 
           1582 | 
           	if (type == FILETYPE_UNKNOWN)
  | 
        
        
           | 6 | 
           cycrow | 
           1583 | 
           		return false;
  | 
        
        
            | 
            | 
           1584 | 
              | 
        
        
           | 127 | 
           cycrow | 
           1585 | 
           	C_File *file = new C_File();
  | 
        
        
           | 6 | 
           cycrow | 
           1586 | 
              | 
        
        
           | 127 | 
           cycrow | 
           1587 | 
           	if (dir.left(5).Compare("GAME_")) {
  | 
        
        
           | 130 | 
           cycrow | 
           1588 | 
           		unsigned int iGame = dir.token("_", 2).toInt();
  | 
        
        
            | 
            | 
           1589 | 
           		if (!iGame)
  | 
        
        
            | 
            | 
           1590 | 
           			file->setGame(0);
  | 
        
        
            | 
            | 
           1591 | 
           		else
  | 
        
        
            | 
            | 
           1592 | 
           			file->setGame(1 << 31 | 1 << iGame);
  | 
        
        
           | 127 | 
           cycrow | 
           1593 | 
           		dir = Utils::String::Null();
  | 
        
        
           | 6 | 
           cycrow | 
           1594 | 
           	} 
  | 
        
        
           | 127 | 
           cycrow | 
           1595 | 
           	else if ( line.countToken(":") >= 9 ) 
  | 
        
        
            | 
            | 
           1596 | 
           	{
  | 
        
        
            | 
            | 
           1597 | 
           		Utils::String game = line.token(":", 9);
  | 
        
        
            | 
            | 
           1598 | 
           		if (game.contains("_"))
  | 
        
        
           | 130 | 
           cycrow | 
           1599 | 
           		{
  | 
        
        
            | 
            | 
           1600 | 
           			unsigned int iGame = game.token("_", 2).toInt();
  | 
        
        
            | 
            | 
           1601 | 
           			if (iGame)
  | 
        
        
            | 
            | 
           1602 | 
           				file->setGame(1 << 31 | 1 << iGame);
  | 
        
        
            | 
            | 
           1603 | 
           			else
  | 
        
        
            | 
            | 
           1604 | 
           				file->setGame(0);
  | 
        
        
            | 
            | 
           1605 | 
           		}
  | 
        
        
           | 127 | 
           cycrow | 
           1606 | 
           		else
  | 
        
        
            | 
            | 
           1607 | 
           		{
  | 
        
        
            | 
            | 
           1608 | 
           			int iGame = game.toInt();
  | 
        
        
            | 
            | 
           1609 | 
           			if (iGame & (1 << 31))
  | 
        
        
            | 
            | 
           1610 | 
           				file->setGame(iGame);
  | 
        
        
           | 130 | 
           cycrow | 
           1611 | 
           			else if (!iGame)
  | 
        
        
            | 
            | 
           1612 | 
           				file->setGame(0);
  | 
        
        
           | 127 | 
           cycrow | 
           1613 | 
           			else
  | 
        
        
            | 
            | 
           1614 | 
           				file->setGame(1 << 31 | 1 << iGame);
  | 
        
        
            | 
            | 
           1615 | 
           		}
  | 
        
        
           | 6 | 
           cycrow | 
           1616 | 
           	}
  | 
        
        
            | 
            | 
           1617 | 
              | 
        
        
           | 127 | 
           cycrow | 
           1618 | 
           	if (dir.Compare("NULL")) {
  | 
        
        
            | 
            | 
           1619 | 
           		dir = Utils::String::Null();
  | 
        
        
            | 
            | 
           1620 | 
           	}
  | 
        
        
            | 
            | 
           1621 | 
              | 
        
        
            | 
            | 
           1622 | 
           	file->setFileType(type);
  | 
        
        
           | 6 | 
           cycrow | 
           1623 | 
           	file->SetCreationTime ( time );
  | 
        
        
           | 178 | 
           cycrow | 
           1624 | 
           	file->setName(name);
  | 
        
        
            | 
            | 
           1625 | 
           	file->setDir(dir);
  | 
        
        
           | 6 | 
           cycrow | 
           1626 | 
           	file->SetDataSize ( size - 4 );
  | 
        
        
            | 
            | 
           1627 | 
           	file->SetDataCompression ( compression );
  | 
        
        
            | 
            | 
           1628 | 
           	file->SetUncompressedDataSize ( usize );
  | 
        
        
            | 
            | 
           1629 | 
           	file->SetShared ( shared );
  | 
        
        
            | 
            | 
           1630 | 
           	file->SetCompressedToFile ( compressToFile );
  | 
        
        
            | 
            | 
           1631 | 
              | 
        
        
           | 88 | 
           cycrow | 
           1632 | 
           	_addFile(file, true);
  | 
        
        
           | 6 | 
           cycrow | 
           1633 | 
              | 
        
        
            | 
            | 
           1634 | 
           	return true;
  | 
        
        
            | 
            | 
           1635 | 
           }
  | 
        
        
            | 
            | 
           1636 | 
              | 
        
        
            | 
            | 
           1637 | 
              | 
        
        
            | 
            | 
           1638 | 
           /*
  | 
        
        
            | 
            | 
           1639 | 
           	Func:   ParseFiles
  | 
        
        
            | 
            | 
           1640 | 
           	Input:  String - values in one long line
  | 
        
        
            | 
            | 
           1641 | 
           	Desc:   splits the files data into each line to read the data
  | 
        
        
            | 
            | 
           1642 | 
           */
  | 
        
        
           | 175 | 
           cycrow | 
           1643 | 
           void CBaseFile::_readFiles(const Utils::String &values)
  | 
        
        
           | 6 | 
           cycrow | 
           1644 | 
           {
  | 
        
        
            | 
            | 
           1645 | 
           	int num = 0;
  | 
        
        
           | 175 | 
           cycrow | 
           1646 | 
           	Utils::String *lines = values.tokenise("\n", &num);
  | 
        
        
           | 6 | 
           cycrow | 
           1647 | 
              | 
        
        
           | 175 | 
           cycrow | 
           1648 | 
           	for (int i = 0; i < num; i++)
  | 
        
        
            | 
            | 
           1649 | 
           		_parseFilesLine(lines[i]);
  | 
        
        
           | 6 | 
           cycrow | 
           1650 | 
              | 
        
        
            | 
            | 
           1651 | 
           	CLEANSPLIT(lines, num)
  | 
        
        
            | 
            | 
           1652 | 
           }
  | 
        
        
            | 
            | 
           1653 | 
              | 
        
        
            | 
            | 
           1654 | 
              | 
        
        
            | 
            | 
           1655 | 
              | 
        
        
            | 
            | 
           1656 | 
           /*
  | 
        
        
            | 
            | 
           1657 | 
           	Func:   ReadFile
  | 
        
        
            | 
            | 
           1658 | 
           	Input:  filename - the name of the file to open and read
  | 
        
        
            | 
            | 
           1659 | 
           			readdata - If falses, dont read the files to memory, just read the headers and values
  | 
        
        
            | 
            | 
           1660 | 
           	Return: boolean - return ture if acceptable format
  | 
        
        
            | 
            | 
           1661 | 
           	Desc:   Opens and reads the spk file and loads all data into class
  | 
        
        
            | 
            | 
           1662 | 
           */
  | 
        
        
           | 130 | 
           cycrow | 
           1663 | 
           bool CBaseFile::readFile(const Utils::String &filename, int readtype, CProgressInfo *progress)
  | 
        
        
            | 
            | 
           1664 | 
           {
  | 
        
        
            | 
            | 
           1665 | 
           	CFileIO File(filename);
  | 
        
        
           | 58 | 
           cycrow | 
           1666 | 
           	if ( !File.startRead() ) return false;
  | 
        
        
           | 6 | 
           cycrow | 
           1667 | 
              | 
        
        
           | 58 | 
           cycrow | 
           1668 | 
           	bool ret = this->readFile(File, readtype, progress);
  | 
        
        
           | 130 | 
           cycrow | 
           1669 | 
           	if ( ret ) this->setFilename(filename);
  | 
        
        
           | 6 | 
           cycrow | 
           1670 | 
              | 
        
        
           | 58 | 
           cycrow | 
           1671 | 
           	File.close();
  | 
        
        
           | 6 | 
           cycrow | 
           1672 | 
           	return ret;
  | 
        
        
            | 
            | 
           1673 | 
           }
  | 
        
        
           | 51 | 
           cycrow | 
           1674 | 
              | 
        
        
           | 109 | 
           cycrow | 
           1675 | 
           int CBaseFile::_read_Header(CFileIO &File, int iReadType, int iMaxProgress, CProgressInfo *pProgress)
  | 
        
        
           | 6 | 
           cycrow | 
           1676 | 
           {
  | 
        
        
           | 51 | 
           cycrow | 
           1677 | 
           	int doneLen = 0;
  | 
        
        
           | 6 | 
           cycrow | 
           1678 | 
              | 
        
        
           | 51 | 
           cycrow | 
           1679 | 
           	// read data to memory
  | 
        
        
           | 208 | 
           cycrow | 
           1680 | 
           	unsigned char *readData = 0;
  | 
        
        
           | 51 | 
           cycrow | 
           1681 | 
           	try {
  | 
        
        
            | 
            | 
           1682 | 
           		readData = new unsigned char[m_SHeader.lValueCompressSize];
  | 
        
        
            | 
            | 
           1683 | 
           	}
  | 
        
        
            | 
            | 
           1684 | 
           	catch (std::exception &e) {
  | 
        
        
            | 
            | 
           1685 | 
           		CLog::logf(CLog::Log_IO, 2, "CBaseFile::_read_Header() unable to malloc [header], %d (%s)", m_SHeader.lValueCompressSize, e.what());
  | 
        
        
            | 
            | 
           1686 | 
           		return -1;
  | 
        
        
            | 
            | 
           1687 | 
           	}
  | 
        
        
           | 6 | 
           cycrow | 
           1688 | 
              | 
        
        
           | 208 | 
           cycrow | 
           1689 | 
           	if (!readData)
  | 
        
        
            | 
            | 
           1690 | 
           		return -1;
  | 
        
        
            | 
            | 
           1691 | 
              | 
        
        
           | 51 | 
           cycrow | 
           1692 | 
           	unsigned char size[4];
  | 
        
        
           | 109 | 
           cycrow | 
           1693 | 
           	File.read(size, 4);
  | 
        
        
            | 
            | 
           1694 | 
           	File.read(readData, m_SHeader.lValueCompressSize);
  | 
        
        
           | 6 | 
           cycrow | 
           1695 | 
              | 
        
        
           | 51 | 
           cycrow | 
           1696 | 
           	unsigned long uncomprLen = (size[0] << 24) + (size[1] << 16) + (size[2] << 8) + size[3];
  | 
        
        
           | 6 | 
           cycrow | 
           1697 | 
              | 
        
        
           | 51 | 
           cycrow | 
           1698 | 
           	// check for zlib compression
  | 
        
        
            | 
            | 
           1699 | 
           	if ( m_SHeader.iValueCompression == SPKCOMPRESS_ZLIB ) {
  | 
        
        
            | 
            | 
           1700 | 
           		// uncomress the data
  | 
        
        
            | 
            | 
           1701 | 
           		try {
  | 
        
        
           | 6 | 
           cycrow | 
           1702 | 
           			unsigned char *uncompr = new unsigned char[uncomprLen];
  | 
        
        
            | 
            | 
           1703 | 
           			int err = uncompress ( uncompr, &uncomprLen, readData, m_SHeader.lValueCompressSize );
  | 
        
        
            | 
            | 
           1704 | 
           			// update the progress for each section
  | 
        
        
           | 51 | 
           cycrow | 
           1705 | 
           			if ( iReadType != SPKREAD_ALL && pProgress ) pProgress->UpdateProgress(2, iMaxProgress);
  | 
        
        
           | 208 | 
           cycrow | 
           1706 | 
           			if (err == Z_OK) 
  | 
        
        
            | 
            | 
           1707 | 
           			{
  | 
        
        
           | 209 | 
           cycrow | 
           1708 | 
           				if (m_SHeader.fVersion <= 4.3f)
  | 
        
        
            | 
            | 
           1709 | 
           				{
  | 
        
        
            | 
            | 
           1710 | 
           					std::string data((const char*)uncompr);
  | 
        
        
            | 
            | 
           1711 | 
           					_readValues(std::wstring(data.begin(), data.end()));
  | 
        
        
            | 
            | 
           1712 | 
           				}
  | 
        
        
            | 
            | 
           1713 | 
           				else
  | 
        
        
            | 
            | 
           1714 | 
           				{
  | 
        
        
            | 
            | 
           1715 | 
           					const wchar_t* data = (const wchar_t*)uncompr;
  | 
        
        
            | 
            | 
           1716 | 
           					_readValues(Utils::WString(data));
  | 
        
        
            | 
            | 
           1717 | 
           				}
  | 
        
        
           | 208 | 
           cycrow | 
           1718 | 
           			}
  | 
        
        
           | 6 | 
           cycrow | 
           1719 | 
           			doneLen = uncomprLen;
  | 
        
        
           | 208 | 
           cycrow | 
           1720 | 
           			delete []uncompr;
  | 
        
        
           | 6 | 
           cycrow | 
           1721 | 
           		}
  | 
        
        
           | 51 | 
           cycrow | 
           1722 | 
           		catch (std::exception &e) {
  | 
        
        
            | 
            | 
           1723 | 
           			CLog::logf(CLog::Log_IO, 2, "CBaseFile::_read_Header() unable to malloc [uncompr], %d (%s)", uncomprLen, e.what());
  | 
        
        
           | 53 | 
           cycrow | 
           1724 | 
           			delete []readData;
  | 
        
        
           | 51 | 
           cycrow | 
           1725 | 
           			return -1;
  | 
        
        
           | 6 | 
           cycrow | 
           1726 | 
           		}
  | 
        
        
           | 51 | 
           cycrow | 
           1727 | 
           	}
  | 
        
        
            | 
            | 
           1728 | 
           	else if ( m_SHeader.iValueCompression == SPKCOMPRESS_7ZIP ) {
  | 
        
        
            | 
            | 
           1729 | 
           		long len = uncomprLen;
  | 
        
        
            | 
            | 
           1730 | 
           		unsigned char *compr = LZMADecode_C ( readData, m_SHeader.lValueCompressSize, (size_t*)&len, NULL );
  | 
        
        
            | 
            | 
           1731 | 
           		// update the progress for each section
  | 
        
        
            | 
            | 
           1732 | 
           		if ( iReadType != SPKREAD_ALL && pProgress ) pProgress->UpdateProgress(2, iMaxProgress);
  | 
        
        
           | 6 | 
           cycrow | 
           1733 | 
              | 
        
        
           | 208 | 
           cycrow | 
           1734 | 
           		if (compr) 
  | 
        
        
            | 
            | 
           1735 | 
           		{
  | 
        
        
           | 209 | 
           cycrow | 
           1736 | 
           			if (m_SHeader.fVersion <= 4.3f)
  | 
        
        
            | 
            | 
           1737 | 
           			{
  | 
        
        
            | 
            | 
           1738 | 
           				std::string data((const char*)compr);
  | 
        
        
            | 
            | 
           1739 | 
           				_readValues(std::wstring(data.begin(), data.end()));
  | 
        
        
            | 
            | 
           1740 | 
           			}
  | 
        
        
            | 
            | 
           1741 | 
           			else
  | 
        
        
            | 
            | 
           1742 | 
           			{
  | 
        
        
            | 
            | 
           1743 | 
           				const wchar_t* data = (const wchar_t*)compr;
  | 
        
        
            | 
            | 
           1744 | 
           				_readValues(Utils::WString(data));
  | 
        
        
            | 
            | 
           1745 | 
           			}
  | 
        
        
           | 208 | 
           cycrow | 
           1746 | 
           		}
  | 
        
        
           | 6 | 
           cycrow | 
           1747 | 
           	}
  | 
        
        
           | 51 | 
           cycrow | 
           1748 | 
           	// no compression
  | 
        
        
            | 
            | 
           1749 | 
           	else
  | 
        
        
           | 208 | 
           cycrow | 
           1750 | 
           	{
  | 
        
        
           | 209 | 
           cycrow | 
           1751 | 
           		if (m_SHeader.fVersion <= 4.3f)
  | 
        
        
            | 
            | 
           1752 | 
           		{
  | 
        
        
            | 
            | 
           1753 | 
           			std::string data((const char*)readData);
  | 
        
        
            | 
            | 
           1754 | 
           			_readValues(std::wstring(data.begin(), data.end()));
  | 
        
        
            | 
            | 
           1755 | 
           		}
  | 
        
        
            | 
            | 
           1756 | 
           		else
  | 
        
        
            | 
            | 
           1757 | 
           		{
  | 
        
        
            | 
            | 
           1758 | 
           			const wchar_t* data = (const wchar_t*)readData;
  | 
        
        
            | 
            | 
           1759 | 
           			_readValues(Utils::WString(data));
  | 
        
        
            | 
            | 
           1760 | 
           		}
  | 
        
        
           | 208 | 
           cycrow | 
           1761 | 
           	}
  | 
        
        
           | 6 | 
           cycrow | 
           1762 | 
              | 
        
        
           | 53 | 
           cycrow | 
           1763 | 
           	delete []readData;
  | 
        
        
           | 6 | 
           cycrow | 
           1764 | 
              | 
        
        
           | 51 | 
           cycrow | 
           1765 | 
           	return doneLen;
  | 
        
        
            | 
            | 
           1766 | 
           }
  | 
        
        
           | 6 | 
           cycrow | 
           1767 | 
              | 
        
        
           | 109 | 
           cycrow | 
           1768 | 
           int CBaseFile::_read_FileHeader(CFileIO &File, int iReadType, int iMaxProgress, int iDoneLen, CProgressInfo *pProgress)
  | 
        
        
           | 51 | 
           cycrow | 
           1769 | 
           {
  | 
        
        
            | 
            | 
           1770 | 
           	unsigned char *readData;
  | 
        
        
            | 
            | 
           1771 | 
           	try {
  | 
        
        
            | 
            | 
           1772 | 
           		readData = new unsigned char[m_SHeader2.lSize];
  | 
        
        
            | 
            | 
           1773 | 
           	}
  | 
        
        
            | 
            | 
           1774 | 
           	catch (std::exception &e) {
  | 
        
        
            | 
            | 
           1775 | 
           		CLog::logf(CLog::Log_IO, 2, "CBaseFile::_read_FileHeader() unable to malloc [header], %d (%s)", m_SHeader2.lSize, e.what());
  | 
        
        
            | 
            | 
           1776 | 
           		return -1;
  | 
        
        
            | 
            | 
           1777 | 
           	}
  | 
        
        
           | 6 | 
           cycrow | 
           1778 | 
              | 
        
        
           | 51 | 
           cycrow | 
           1779 | 
           	unsigned char size[4];
  | 
        
        
           | 109 | 
           cycrow | 
           1780 | 
           	File.read(size, 4);
  | 
        
        
            | 
            | 
           1781 | 
           	File.read(readData, m_SHeader2.lSize);
  | 
        
        
           | 6 | 
           cycrow | 
           1782 | 
              | 
        
        
           | 51 | 
           cycrow | 
           1783 | 
           	unsigned long uncomprLen = (size[0] << 24) + (size[1] << 16) + (size[2] << 8) + size[3];
  | 
        
        
           | 6 | 
           cycrow | 
           1784 | 
              | 
        
        
           | 51 | 
           cycrow | 
           1785 | 
           	// check for zlib compression
  | 
        
        
            | 
            | 
           1786 | 
           	if ( m_SHeader.iValueCompression == SPKCOMPRESS_ZLIB ) {
  | 
        
        
            | 
            | 
           1787 | 
           		if ( uncomprLen < (unsigned long)iDoneLen ) uncomprLen = iDoneLen;
  | 
        
        
           | 6 | 
           cycrow | 
           1788 | 
              | 
        
        
           | 51 | 
           cycrow | 
           1789 | 
           		try {
  | 
        
        
           | 6 | 
           cycrow | 
           1790 | 
           			unsigned char *uncompr = new unsigned char[uncomprLen];
  | 
        
        
            | 
            | 
           1791 | 
           			int err = uncompress ( uncompr, &uncomprLen, readData, m_SHeader2.lSize );
  | 
        
        
            | 
            | 
           1792 | 
           			// update the progress for each section
  | 
        
        
           | 51 | 
           cycrow | 
           1793 | 
           			if ( iReadType != SPKREAD_ALL && pProgress ) pProgress->UpdateProgress(5, iMaxProgress);
  | 
        
        
           | 175 | 
           cycrow | 
           1794 | 
           			if ( err == Z_OK ) _readFiles((char *)uncompr);
  | 
        
        
           | 6 | 
           cycrow | 
           1795 | 
           			delete uncompr;
  | 
        
        
            | 
            | 
           1796 | 
           		}
  | 
        
        
           | 51 | 
           cycrow | 
           1797 | 
           		catch (std::exception &e) {
  | 
        
        
            | 
            | 
           1798 | 
           			CLog::logf(CLog::Log_IO, 2, "CBaseFile::_read_FileHeader() unable to malloc [uncompr], %d (%s)", uncomprLen, e.what());
  | 
        
        
           | 53 | 
           cycrow | 
           1799 | 
           			delete []readData;
  | 
        
        
           | 51 | 
           cycrow | 
           1800 | 
           			return -1;
  | 
        
        
           | 6 | 
           cycrow | 
           1801 | 
           		}
  | 
        
        
            | 
            | 
           1802 | 
              | 
        
        
            | 
            | 
           1803 | 
           	}
  | 
        
        
           | 51 | 
           cycrow | 
           1804 | 
           	else if ( m_SHeader.iValueCompression == SPKCOMPRESS_7ZIP )
  | 
        
        
            | 
            | 
           1805 | 
           	{
  | 
        
        
            | 
            | 
           1806 | 
           		long len = uncomprLen;
  | 
        
        
            | 
            | 
           1807 | 
           		unsigned char *compr = LZMADecode_C ( readData, m_SHeader2.lSize, (size_t*)&len, NULL );
  | 
        
        
            | 
            | 
           1808 | 
           		// update the progress for each section
  | 
        
        
            | 
            | 
           1809 | 
           		if ( iReadType != SPKREAD_ALL && pProgress ) pProgress->UpdateProgress(5, iMaxProgress);
  | 
        
        
           | 175 | 
           cycrow | 
           1810 | 
           		if ( compr ) _readFiles((char *)compr);
  | 
        
        
           | 51 | 
           cycrow | 
           1811 | 
           	}
  | 
        
        
            | 
            | 
           1812 | 
           	else
  | 
        
        
           | 175 | 
           cycrow | 
           1813 | 
           		_readFiles((char *)readData);
  | 
        
        
           | 6 | 
           cycrow | 
           1814 | 
              | 
        
        
           | 53 | 
           cycrow | 
           1815 | 
           	delete []readData;
  | 
        
        
           | 51 | 
           cycrow | 
           1816 | 
           	return true;
  | 
        
        
            | 
            | 
           1817 | 
           }
  | 
        
        
            | 
            | 
           1818 | 
              | 
        
        
           | 58 | 
           cycrow | 
           1819 | 
           bool CBaseFile::readFile(CFileIO &File, int readtype, CProgressInfo *progress)
  | 
        
        
           | 51 | 
           cycrow | 
           1820 | 
           {
  | 
        
        
            | 
            | 
           1821 | 
           	ClearError ();
  | 
        
        
            | 
            | 
           1822 | 
              | 
        
        
            | 
            | 
           1823 | 
           	// first read the header
  | 
        
        
           | 197 | 
           cycrow | 
           1824 | 
           	if ( !_parseHeader(File.readEndOfLineStr()) ) return false;
  | 
        
        
           | 51 | 
           cycrow | 
           1825 | 
           	if ( readtype == SPKREAD_HEADER ) return true;
  | 
        
        
            | 
            | 
           1826 | 
              | 
        
        
            | 
            | 
           1827 | 
           	// update the progress for each section
  | 
        
        
            | 
            | 
           1828 | 
           	int maxProgress = (readtype == SPKREAD_VALUES) ? 3 : 6;
  | 
        
        
            | 
            | 
           1829 | 
           	if ( readtype != SPKREAD_ALL && progress ) progress->UpdateProgress(1, maxProgress);
  | 
        
        
            | 
            | 
           1830 | 
              | 
        
        
            | 
            | 
           1831 | 
           	long doneLen = 0;
  | 
        
        
            | 
            | 
           1832 | 
           	// next read the data values for the spk files
  | 
        
        
           | 109 | 
           cycrow | 
           1833 | 
           	if ( m_SHeader.lValueCompressSize ) doneLen = this->_read_Header(File, readtype, maxProgress, progress);
  | 
        
        
           | 51 | 
           cycrow | 
           1834 | 
              | 
        
        
            | 
            | 
           1835 | 
           	// update the progress for each section
  | 
        
        
            | 
            | 
           1836 | 
           	if ( readtype != SPKREAD_ALL && progress ) progress->UpdateProgress(3, maxProgress);
  | 
        
        
            | 
            | 
           1837 | 
           	if ( readtype == SPKREAD_VALUES ) return true;
  | 
        
        
            | 
            | 
           1838 | 
              | 
        
        
            | 
            | 
           1839 | 
           	// next should be the next header
  | 
        
        
           | 197 | 
           cycrow | 
           1840 | 
           	if ( !_parseFileHeader(File.readEndOfLineStr()) ) return false;
  | 
        
        
           | 51 | 
           cycrow | 
           1841 | 
              | 
        
        
            | 
            | 
           1842 | 
           	// clear the current file list
  | 
        
        
            | 
            | 
           1843 | 
           	m_lFiles.clear(true);
  | 
        
        
           | 88 | 
           cycrow | 
           1844 | 
           	if ( _pTextDB ) {
  | 
        
        
            | 
            | 
           1845 | 
           		delete _pTextDB;
  | 
        
        
            | 
            | 
           1846 | 
           		_pTextDB = NULL;
  | 
        
        
            | 
            | 
           1847 | 
           	}
  | 
        
        
           | 51 | 
           cycrow | 
           1848 | 
              | 
        
        
            | 
            | 
           1849 | 
           	// update the progress for each section
  | 
        
        
            | 
            | 
           1850 | 
           	if ( readtype != SPKREAD_ALL && progress ) progress->UpdateProgress(4, maxProgress);
  | 
        
        
            | 
            | 
           1851 | 
              | 
        
        
           | 109 | 
           cycrow | 
           1852 | 
           	if ( m_SHeader2.lSize ) this->_read_FileHeader(File, readtype, maxProgress, doneLen, progress);
  | 
        
        
           | 51 | 
           cycrow | 
           1853 | 
              | 
        
        
           | 6 | 
           cycrow | 
           1854 | 
           	// file mismatch
  | 
        
        
            | 
            | 
           1855 | 
           	long numfiles = m_lFiles.size();
  | 
        
        
           | 51 | 
           cycrow | 
           1856 | 
           	if ( m_pIconFile ) ++numfiles;
  | 
        
        
            | 
            | 
           1857 | 
           	if ( m_SHeader2.iNumFiles != numfiles ) {
  | 
        
        
           | 134 | 
           cycrow | 
           1858 | 
           		_iLastError = SPKERR_FILEMISMATCH;
  | 
        
        
           | 6 | 
           cycrow | 
           1859 | 
           		return false;
  | 
        
        
            | 
            | 
           1860 | 
           	}
  | 
        
        
            | 
            | 
           1861 | 
              | 
        
        
            | 
            | 
           1862 | 
           	// update the progress for each section
  | 
        
        
           | 51 | 
           cycrow | 
           1863 | 
           	if ( readtype != SPKREAD_ALL && progress )	progress->UpdateProgress(6, maxProgress);
  | 
        
        
           | 6 | 
           cycrow | 
           1864 | 
              | 
        
        
           | 51 | 
           cycrow | 
           1865 | 
           	if ( readtype == SPKREAD_ALL ) {
  | 
        
        
           | 6 | 
           cycrow | 
           1866 | 
           		int fileCount = 2;
  | 
        
        
           | 58 | 
           cycrow | 
           1867 | 
           		if ( m_pIconFile ) m_pIconFile->readFromFile(File, m_pIconFile->GetDataSize());
  | 
        
        
           | 6 | 
           cycrow | 
           1868 | 
              | 
        
        
           | 51 | 
           cycrow | 
           1869 | 
           		// ok finally we need to read all the file
  | 
        
        
            | 
            | 
           1870 | 
           		for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() ) {
  | 
        
        
           | 58 | 
           cycrow | 
           1871 | 
           			node->Data()->readFromFile(File, node->Data()->GetDataSize());
  | 
        
        
           | 51 | 
           cycrow | 
           1872 | 
           			if ( progress )	progress->UpdateProgress(fileCount++, m_lFiles.size() + 2);
  | 
        
        
           | 6 | 
           cycrow | 
           1873 | 
           		}
  | 
        
        
            | 
            | 
           1874 | 
              | 
        
        
            | 
            | 
           1875 | 
           		m_bFullyLoaded = true;
  | 
        
        
            | 
            | 
           1876 | 
           	}
  | 
        
        
            | 
            | 
           1877 | 
              | 
        
        
            | 
            | 
           1878 | 
           	return true;
  | 
        
        
            | 
            | 
           1879 | 
           }
  | 
        
        
            | 
            | 
           1880 | 
              | 
        
        
            | 
            | 
           1881 | 
           bool CBaseFile::IsMod()
  | 
        
        
            | 
            | 
           1882 | 
           {
  | 
        
        
            | 
            | 
           1883 | 
           	// check for any mod files that are not fake patchs
  | 
        
        
            | 
            | 
           1884 | 
           	for ( CListNode<C_File> *fNode = m_lFiles.Front(); fNode; fNode = fNode->next() )
  | 
        
        
            | 
            | 
           1885 | 
           	{
  | 
        
        
            | 
            | 
           1886 | 
           		C_File *f = fNode->Data();
  | 
        
        
            | 
            | 
           1887 | 
           		if ( f->GetFileType() != FILETYPE_MOD )
  | 
        
        
            | 
            | 
           1888 | 
           			continue;
  | 
        
        
            | 
            | 
           1889 | 
              | 
        
        
            | 
            | 
           1890 | 
           		if ( !f->IsFakePatch() )
  | 
        
        
            | 
            | 
           1891 | 
           			return true;
  | 
        
        
            | 
            | 
           1892 | 
           	}
  | 
        
        
            | 
            | 
           1893 | 
              | 
        
        
            | 
            | 
           1894 | 
           	return false;
  | 
        
        
            | 
            | 
           1895 | 
           }
  | 
        
        
            | 
            | 
           1896 | 
              | 
        
        
           | 13 | 
           cycrow | 
           1897 | 
           bool CBaseFile::IsFakePatch() const
  | 
        
        
           | 6 | 
           cycrow | 
           1898 | 
           {
  | 
        
        
            | 
            | 
           1899 | 
           	// check for any mod files that are not fake patchs
  | 
        
        
            | 
            | 
           1900 | 
           	for ( CListNode<C_File> *fNode = m_lFiles.Front(); fNode; fNode = fNode->next() )
  | 
        
        
            | 
            | 
           1901 | 
           	{
  | 
        
        
            | 
            | 
           1902 | 
           		C_File *f = fNode->Data();
  | 
        
        
            | 
            | 
           1903 | 
           		if ( f->GetFileType() != FILETYPE_MOD )
  | 
        
        
            | 
            | 
           1904 | 
           			continue;
  | 
        
        
            | 
            | 
           1905 | 
              | 
        
        
            | 
            | 
           1906 | 
           		if ( f->IsFakePatch() )
  | 
        
        
            | 
            | 
           1907 | 
           			return true;
  | 
        
        
            | 
            | 
           1908 | 
           	}
  | 
        
        
            | 
            | 
           1909 | 
              | 
        
        
            | 
            | 
           1910 | 
           	return false;
  | 
        
        
            | 
            | 
           1911 | 
           }
  | 
        
        
            | 
            | 
           1912 | 
              | 
        
        
           | 207 | 
           cycrow | 
           1913 | 
           Utils::WString CBaseFile::createValuesLine () const
  | 
        
        
           | 6 | 
           cycrow | 
           1914 | 
           {
  | 
        
        
           | 203 | 
           cycrow | 
           1915 | 
           	Utils::WString values(L"Name: ");
  | 
        
        
            | 
            | 
           1916 | 
           	values += this->name() + L"\n";
  | 
        
        
            | 
            | 
           1917 | 
           	values += L"Author: " + this->author() + L"\n";
  | 
        
        
           | 204 | 
           cycrow | 
           1918 | 
           	values += L"Version: " + this->version() + L"\n";
  | 
        
        
           | 206 | 
           cycrow | 
           1919 | 
           	if ( !this->creationDate().empty() )values += L"Date: "			+ this->creationDate()	+ L"\n";
  | 
        
        
            | 
            | 
           1920 | 
           	if ( !this->webAddress().empty() )	values += L"WebAddress: "	+ this->webAddress()	+ L"\n";
  | 
        
        
            | 
            | 
           1921 | 
           	if ( !this->webSite().empty() )		values += L"WebSite: "		+ this->webSite()		+ L"\n";
  | 
        
        
            | 
            | 
           1922 | 
           	if ( !this->email().empty() )		values += L"Email: "		+ this->email()			+ L"\n";
  | 
        
        
            | 
            | 
           1923 | 
           	if ( !this->forumLink().empty() )	values += L"ForumLink: "	+ this->forumLink()		+ L"\n";
  | 
        
        
           | 49 | 
           cycrow | 
           1924 | 
              | 
        
        
           | 208 | 
           cycrow | 
           1925 | 
           	for(auto itr = webMirrors().begin(); itr != webMirrors().end(); itr++)
  | 
        
        
            | 
            | 
           1926 | 
           		values += Utils::WString(L"WebMirror: ") + (*itr)->str + L"\n";
  | 
        
        
           | 48 | 
           cycrow | 
           1927 | 
           	if ( !this->description().empty() ) {
  | 
        
        
           | 206 | 
           cycrow | 
           1928 | 
           		Utils::WString desc = this->description();
  | 
        
        
           | 203 | 
           cycrow | 
           1929 | 
           		desc = desc.findReplace(L"<newline>", L"<br>");
  | 
        
        
            | 
            | 
           1930 | 
           		desc = desc.findReplace(L"\n", "L<br>");
  | 
        
        
            | 
            | 
           1931 | 
           		desc.remove(L'\r');
  | 
        
        
            | 
            | 
           1932 | 
           		values += L"Desc: " + desc + L"\n";
  | 
        
        
           | 6 | 
           cycrow | 
           1933 | 
           	}
  | 
        
        
            | 
            | 
           1934 | 
              | 
        
        
            | 
            | 
           1935 | 
           	for ( CListNode<SGameCompat> *gc = m_lGames.Front(); gc; gc = gc->next() ) {
  | 
        
        
           | 46 | 
           cycrow | 
           1936 | 
           		if ( !gc->Data()->sVersion.empty() )
  | 
        
        
           | 203 | 
           cycrow | 
           1937 | 
           			values += Utils::WString(L"GameCompatExact: ") + (long)gc->Data()->iGame + L" " + gc->Data()->sVersion + L"\n";
  | 
        
        
           | 6 | 
           cycrow | 
           1938 | 
           		else
  | 
        
        
           | 203 | 
           cycrow | 
           1939 | 
           			values += Utils::WString(L"GameCompat: ") + (long)gc->Data()->iGame + L" " + (long)gc->Data()->iVersion + L"\n";
  | 
        
        
           | 6 | 
           cycrow | 
           1940 | 
           	}
  | 
        
        
            | 
            | 
           1941 | 
              | 
        
        
           | 175 | 
           cycrow | 
           1942 | 
           	if (computeSigned(true))
  | 
        
        
           | 203 | 
           cycrow | 
           1943 | 
           		values += L"Signed\n";
  | 
        
        
           | 6 | 
           cycrow | 
           1944 | 
              | 
        
        
           | 46 | 
           cycrow | 
           1945 | 
           	for ( int j = 0; j < 2; j++ ) {
  | 
        
        
            | 
            | 
           1946 | 
           		const CInstallText *text;
  | 
        
        
           | 203 | 
           cycrow | 
           1947 | 
           		Utils::WString textStart;
  | 
        
        
           | 46 | 
           cycrow | 
           1948 | 
           		switch(j) {
  | 
        
        
           | 203 | 
           cycrow | 
           1949 | 
           			case 0:	textStart = L"Uninstall"; text = this->uninstallText(); break;
  | 
        
        
            | 
            | 
           1950 | 
           			case 1: textStart = L"Install"; text = this->installText(); break;
  | 
        
        
           | 46 | 
           cycrow | 
           1951 | 
           		}
  | 
        
        
            | 
            | 
           1952 | 
           		for ( unsigned int i = 0; i < text->count(); i++ ) {
  | 
        
        
            | 
            | 
           1953 | 
           			int iLang = text->language(i);
  | 
        
        
           | 206 | 
           cycrow | 
           1954 | 
           			if ( !text->getBefore(iLang).empty() ) values += textStart + L"Before: " + (long)iLang + L"|" + text->getBefore(iLang) + L"\n";
  | 
        
        
            | 
            | 
           1955 | 
           			if ( !text->getAfter(iLang).empty() ) values += textStart + L"After: " + (long)iLang + L"|" + text->getAfter(iLang) + L"\n";
  | 
        
        
           | 46 | 
           cycrow | 
           1956 | 
           		}
  | 
        
        
           | 6 | 
           cycrow | 
           1957 | 
           	}
  | 
        
        
            | 
            | 
           1958 | 
              | 
        
        
           | 203 | 
           cycrow | 
           1959 | 
           	values += Utils::WString(L"GameChanging: ") + (long)gameChanging() + L"\n";
  | 
        
        
            | 
            | 
           1960 | 
           	values += Utils::WString(L"EaseOfUse: ") + (long)easeOfUse() + L"\n";
  | 
        
        
            | 
            | 
           1961 | 
           	values += Utils::WString(L"Recommended: ") + (long)recommended() + L"\n";
  | 
        
        
           | 6 | 
           cycrow | 
           1962 | 
              | 
        
        
           | 170 | 
           cycrow | 
           1963 | 
           	for(auto itr = namesList()->begin(); itr != namesList()->end(); itr++)
  | 
        
        
           | 204 | 
           cycrow | 
           1964 | 
           		values += Utils::WString(L"ScriptName: ") + (long)(*itr)->iLanguage + L":" + (*itr)->sName + L"\n";
  | 
        
        
           | 6 | 
           cycrow | 
           1965 | 
              | 
        
        
           | 14 | 
           cycrow | 
           1966 | 
           	for ( CListNode<SNeededLibrary> *libNode = m_lNeededLibrarys.Front(); libNode; libNode = libNode->next() ) {
  | 
        
        
           | 6 | 
           cycrow | 
           1967 | 
           		SNeededLibrary *l = libNode->Data();
  | 
        
        
           | 204 | 
           cycrow | 
           1968 | 
           		values += L"NeededLibrary: " + l->sName + L"||" + l->sAuthor + L"||" + l->sMinVersion + L"\n";
  | 
        
        
           | 6 | 
           cycrow | 
           1969 | 
           	}
  | 
        
        
            | 
            | 
           1970 | 
              | 
        
        
           | 160 | 
           cycrow | 
           1971 | 
           	for (auto itr = _lFakePatchBefore.begin(); itr != _lFakePatchBefore.end(); itr++)
  | 
        
        
           | 207 | 
           cycrow | 
           1972 | 
           		values += L"FakePatchBefore: " + (*itr)->str + L"||" + (*itr)->data + L"\n";
  | 
        
        
           | 160 | 
           cycrow | 
           1973 | 
           	for (auto itr = _lFakePatchAfter.begin(); itr != _lFakePatchAfter.end(); itr++)
  | 
        
        
           | 207 | 
           cycrow | 
           1974 | 
           		values += L"FakePatchAfter: " + (*itr)->str + L"||" + (*itr)->data + L"\n";
  | 
        
        
           | 6 | 
           cycrow | 
           1975 | 
              | 
        
        
           | 203 | 
           cycrow | 
           1976 | 
           	values += Utils::WString(L"PluginType: ") + (long)this->pluginType() + L"\n";
  | 
        
        
           | 6 | 
           cycrow | 
           1977 | 
              | 
        
        
           | 207 | 
           cycrow | 
           1978 | 
           	return values;
  | 
        
        
           | 6 | 
           cycrow | 
           1979 | 
           }
  | 
        
        
            | 
            | 
           1980 | 
              | 
        
        
            | 
            | 
           1981 | 
              | 
        
        
            | 
            | 
           1982 | 
           /*
  | 
        
        
            | 
            | 
           1983 | 
           	Func:   WriteFile
  | 
        
        
            | 
            | 
           1984 | 
           	Input:  filename - The filename of the spk file to write to
  | 
        
        
            | 
            | 
           1985 | 
           	Desc:   Writes the data to an spk file
  | 
        
        
            | 
            | 
           1986 | 
           */
  | 
        
        
           | 175 | 
           cycrow | 
           1987 | 
           bool CBaseFile::writeFile(const Utils::String &filename, CProgressInfo *progress) const
  | 
        
        
           | 6 | 
           cycrow | 
           1988 | 
           {
  | 
        
        
           | 52 | 
           cycrow | 
           1989 | 
           	CFileIO File(filename);
  | 
        
        
           | 175 | 
           cycrow | 
           1990 | 
           	if ( File.startWrite() ) return writeData(File, progress);
  | 
        
        
           | 52 | 
           cycrow | 
           1991 | 
           	return false;
  | 
        
        
           | 6 | 
           cycrow | 
           1992 | 
           }
  | 
        
        
            | 
            | 
           1993 | 
              | 
        
        
           | 175 | 
           cycrow | 
           1994 | 
           bool CBaseFile::writeHeader(CFileIO &file, int valueheader, int valueComprLen) const
  | 
        
        
           | 6 | 
           cycrow | 
           1995 | 
           {
  | 
        
        
           | 52 | 
           cycrow | 
           1996 | 
           	return file.write("BaseCycrow;%.2f;%d;%d\n", FILEVERSION, valueheader, valueComprLen);
  | 
        
        
           | 6 | 
           cycrow | 
           1997 | 
           }
  | 
        
        
            | 
            | 
           1998 | 
              | 
        
        
           | 175 | 
           cycrow | 
           1999 | 
           bool CBaseFile::writeData(CFileIO &file, CProgressInfo *progress ) const
  | 
        
        
           | 6 | 
           cycrow | 
           2000 | 
           {
  | 
        
        
            | 
            | 
           2001 | 
           	int valueheader = m_SHeader.iValueCompression, fileheader = m_SHeader.iValueCompression;
  | 
        
        
            | 
            | 
           2002 | 
           	if ( valueheader == SPKCOMPRESS_7ZIP )
  | 
        
        
            | 
            | 
           2003 | 
           		valueheader = SPKCOMPRESS_ZLIB;
  | 
        
        
            | 
            | 
           2004 | 
           	if ( fileheader == SPKCOMPRESS_7ZIP )
  | 
        
        
            | 
            | 
           2005 | 
           		fileheader = SPKCOMPRESS_ZLIB;
  | 
        
        
            | 
            | 
           2006 | 
              | 
        
        
            | 
            | 
           2007 | 
           	// get the script values
  | 
        
        
           | 207 | 
           cycrow | 
           2008 | 
           	Utils::WString values = this->createValuesLine();
  | 
        
        
           | 209 | 
           cycrow | 
           2009 | 
           	const char* data = (const char*)values.c_str();
  | 
        
        
           | 6 | 
           cycrow | 
           2010 | 
              | 
        
        
            | 
            | 
           2011 | 
           	// compress the values
  | 
        
        
           | 209 | 
           cycrow | 
           2012 | 
           	int valueUncomprLen = (int)(wcslen(values.c_str()) * sizeof(wchar_t)) / sizeof(char);
  | 
        
        
           | 6 | 
           cycrow | 
           2013 | 
           	unsigned long valueComprLen = 0;
  | 
        
        
            | 
            | 
           2014 | 
           	unsigned char *valueCompr = NULL;
  | 
        
        
            | 
            | 
           2015 | 
           	bool compressed = false;
  | 
        
        
           | 208 | 
           cycrow | 
           2016 | 
              | 
        
        
           | 6 | 
           cycrow | 
           2017 | 
           	if ( valueheader == SPKCOMPRESS_ZLIB )
  | 
        
        
            | 
            | 
           2018 | 
           	{
  | 
        
        
            | 
            | 
           2019 | 
           		valueComprLen = valueUncomprLen;
  | 
        
        
            | 
            | 
           2020 | 
           		if ( valueComprLen < 100 )
  | 
        
        
            | 
            | 
           2021 | 
           			valueComprLen = 200;
  | 
        
        
            | 
            | 
           2022 | 
           		else if ( valueComprLen < 1000 )
  | 
        
        
            | 
            | 
           2023 | 
           			valueComprLen *= 2;
  | 
        
        
            | 
            | 
           2024 | 
              | 
        
        
            | 
            | 
           2025 | 
           		valueCompr = (unsigned char *)calloc((unsigned int)valueComprLen, 1);
  | 
        
        
           | 209 | 
           cycrow | 
           2026 | 
           		int err = compress ( (unsigned char *)valueCompr, &valueComprLen, (const unsigned char *)data, (unsigned long)valueUncomprLen, 0 );
  | 
        
        
           | 6 | 
           cycrow | 
           2027 | 
           		if ( err == Z_OK )
  | 
        
        
            | 
            | 
           2028 | 
           			compressed = true;
  | 
        
        
            | 
            | 
           2029 | 
           	}
  | 
        
        
            | 
            | 
           2030 | 
              | 
        
        
            | 
            | 
           2031 | 
           	if ( !compressed )
  | 
        
        
            | 
            | 
           2032 | 
           	{
  | 
        
        
            | 
            | 
           2033 | 
           		valueComprLen = valueUncomprLen;
  | 
        
        
            | 
            | 
           2034 | 
           		valueCompr = (unsigned char *)calloc((unsigned int)valueComprLen, 1);
  | 
        
        
           | 209 | 
           cycrow | 
           2035 | 
           		memcpy ( valueCompr, (const unsigned char *)data, valueComprLen );
  | 
        
        
           | 6 | 
           cycrow | 
           2036 | 
           		valueheader = SPKCOMPRESS_NONE;
  | 
        
        
            | 
            | 
           2037 | 
           	}
  | 
        
        
            | 
            | 
           2038 | 
              | 
        
        
            | 
            | 
           2039 | 
           	// write the main header to the file
  | 
        
        
           | 175 | 
           cycrow | 
           2040 | 
           	if ( !this->writeHeader(file, valueheader, valueComprLen) )	return false;
  | 
        
        
           | 6 | 
           cycrow | 
           2041 | 
              | 
        
        
            | 
            | 
           2042 | 
           	// write the compressed data to file
  | 
        
        
           | 52 | 
           cycrow | 
           2043 | 
           	file.put(static_cast<unsigned char>(valueUncomprLen >> 24));
  | 
        
        
            | 
            | 
           2044 | 
           	file.put(static_cast<unsigned char>(valueUncomprLen >> 16));
  | 
        
        
            | 
            | 
           2045 | 
           	file.put(static_cast<unsigned char>(valueUncomprLen >> 8));
  | 
        
        
            | 
            | 
           2046 | 
           	file.put(static_cast<unsigned char>(valueUncomprLen));
  | 
        
        
            | 
            | 
           2047 | 
           	file.write(valueCompr, valueComprLen);
  | 
        
        
           | 6 | 
           cycrow | 
           2048 | 
           	free ( valueCompr );
  | 
        
        
            | 
            | 
           2049 | 
              | 
        
        
            | 
            | 
           2050 | 
           	// now compress the files header
  | 
        
        
            | 
            | 
           2051 | 
           	// create the files values
  | 
        
        
           | 175 | 
           cycrow | 
           2052 | 
           	SSPKHeader2 header;
  | 
        
        
            | 
            | 
           2053 | 
           	Utils::String files = createFilesLine(&header, progress);
  | 
        
        
            | 
            | 
           2054 | 
              | 
        
        
           | 6 | 
           cycrow | 
           2055 | 
           	// compress the files values
  | 
        
        
           | 170 | 
           cycrow | 
           2056 | 
           	long fileUncomprLen = (long)files.length(), fileComprLen = fileUncomprLen;
  | 
        
        
           | 6 | 
           cycrow | 
           2057 | 
           	unsigned char *fileCompr = NULL;
  | 
        
        
            | 
            | 
           2058 | 
              | 
        
        
            | 
            | 
           2059 | 
           	compressed = false;
  | 
        
        
            | 
            | 
           2060 | 
           	if ( fileUncomprLen )
  | 
        
        
            | 
            | 
           2061 | 
           	{
  | 
        
        
            | 
            | 
           2062 | 
           		if ( fileheader == SPKCOMPRESS_ZLIB )
  | 
        
        
            | 
            | 
           2063 | 
           		{
  | 
        
        
            | 
            | 
           2064 | 
           			if ( fileComprLen < 100 )
  | 
        
        
            | 
            | 
           2065 | 
           				fileComprLen = 200;
  | 
        
        
            | 
            | 
           2066 | 
           			else if ( fileComprLen < 1000 )
  | 
        
        
            | 
            | 
           2067 | 
           				fileComprLen *= 2;
  | 
        
        
            | 
            | 
           2068 | 
           			fileCompr = (unsigned char *)calloc((unsigned int)fileComprLen, 1);
  | 
        
        
           | 170 | 
           cycrow | 
           2069 | 
           			int err = compress ( (unsigned char *)fileCompr, (unsigned long *)&fileComprLen, (const unsigned char *)files.c_str(), (unsigned long)files.length(), 0 );
  | 
        
        
           | 6 | 
           cycrow | 
           2070 | 
           			if ( err == Z_OK )
  | 
        
        
            | 
            | 
           2071 | 
           				compressed = true;
  | 
        
        
            | 
            | 
           2072 | 
           		}
  | 
        
        
            | 
            | 
           2073 | 
           	}
  | 
        
        
            | 
            | 
           2074 | 
              | 
        
        
            | 
            | 
           2075 | 
           	// if unable to compress, store it as plain text
  | 
        
        
            | 
            | 
           2076 | 
           	if ( !compressed )
  | 
        
        
            | 
            | 
           2077 | 
           	{
  | 
        
        
            | 
            | 
           2078 | 
           		fileComprLen = fileUncomprLen;
  | 
        
        
            | 
            | 
           2079 | 
           		fileCompr = (unsigned char *)calloc((unsigned int)fileComprLen, 1);
  | 
        
        
            | 
            | 
           2080 | 
           		memcpy ( fileCompr, files.c_str(), fileComprLen );
  | 
        
        
            | 
            | 
           2081 | 
           		fileheader = SPKCOMPRESS_NONE;
  | 
        
        
            | 
            | 
           2082 | 
           	}
  | 
        
        
            | 
            | 
           2083 | 
              | 
        
        
            | 
            | 
           2084 | 
           	// now write the file header
  | 
        
        
           | 175 | 
           cycrow | 
           2085 | 
           	header.lSize = fileComprLen;
  | 
        
        
            | 
            | 
           2086 | 
           	file.write("FileHeader;%d;%ld;%ld;%d;%d\n", header.iNumFiles, header.lSize, header.lFullSize, fileheader, header.iDataCompression);
  | 
        
        
           | 6 | 
           cycrow | 
           2087 | 
              | 
        
        
           | 52 | 
           cycrow | 
           2088 | 
           	file.put(static_cast<unsigned char>(fileUncomprLen >> 24));
  | 
        
        
            | 
            | 
           2089 | 
           	file.put(static_cast<unsigned char>(fileUncomprLen >> 16));
  | 
        
        
            | 
            | 
           2090 | 
           	file.put(static_cast<unsigned char>(fileUncomprLen >> 8));
  | 
        
        
            | 
            | 
           2091 | 
           	file.put(static_cast<unsigned char>(fileUncomprLen));
  | 
        
        
            | 
            | 
           2092 | 
           	file.write(fileCompr, fileComprLen);
  | 
        
        
           | 6 | 
           cycrow | 
           2093 | 
           	free ( fileCompr );
  | 
        
        
            | 
            | 
           2094 | 
              | 
        
        
            | 
            | 
           2095 | 
           	if ( progress )
  | 
        
        
            | 
            | 
           2096 | 
           	{
  | 
        
        
            | 
            | 
           2097 | 
           		progress->UpdateStatus(STATUS_WRITE);
  | 
        
        
            | 
            | 
           2098 | 
           		progress->SetDone(0);
  | 
        
        
            | 
            | 
           2099 | 
           		long max = 0;
  | 
        
        
           | 88 | 
           cycrow | 
           2100 | 
           		for ( CListNode<C_File> *file = m_lFiles.Front(); file; file = file->next() )
  | 
        
        
            | 
            | 
           2101 | 
           			max += file->Data()->GetDataSize();
  | 
        
        
           | 6 | 
           cycrow | 
           2102 | 
           		if ( m_pIconFile )
  | 
        
        
            | 
            | 
           2103 | 
           			max += m_pIconFile->GetDataSize();
  | 
        
        
            | 
            | 
           2104 | 
           		progress->SetMax(max);
  | 
        
        
            | 
            | 
           2105 | 
           	}
  | 
        
        
            | 
            | 
           2106 | 
              | 
        
        
            | 
            | 
           2107 | 
           	// now finally, write all the file data
  | 
        
        
           | 52 | 
           cycrow | 
           2108 | 
           	if ( m_pIconFile ) {
  | 
        
        
            | 
            | 
           2109 | 
           		if ( progress )	progress->UpdateFile(m_pIconFile);
  | 
        
        
           | 178 | 
           cycrow | 
           2110 | 
           		file.writeSize(m_pIconFile->uncompressedDataSize());
  | 
        
        
           | 52 | 
           cycrow | 
           2111 | 
           		file.write(m_pIconFile->GetData(), m_pIconFile->GetDataSize());
  | 
        
        
            | 
            | 
           2112 | 
           		if ( progress )	progress->IncDone(m_pIconFile->GetDataSize());
  | 
        
        
           | 6 | 
           cycrow | 
           2113 | 
           	}
  | 
        
        
            | 
            | 
           2114 | 
              | 
        
        
            | 
            | 
           2115 | 
           	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
  | 
        
        
            | 
            | 
           2116 | 
           	{
  | 
        
        
           | 52 | 
           cycrow | 
           2117 | 
           		C_File *f = node->Data();
  | 
        
        
            | 
            | 
           2118 | 
           		if ( progress )	progress->UpdateFile(f);
  | 
        
        
           | 178 | 
           cycrow | 
           2119 | 
           		file.writeSize(f->uncompressedDataSize());
  | 
        
        
           | 52 | 
           cycrow | 
           2120 | 
           		unsigned char *data = f->GetData();
  | 
        
        
            | 
            | 
           2121 | 
           		size_t remaining = f->GetDataSize();
  | 
        
        
            | 
            | 
           2122 | 
           		while ( remaining )	{
  | 
        
        
           | 6 | 
           cycrow | 
           2123 | 
           			size_t writeSize = WRITECHUNK;
  | 
        
        
           | 52 | 
           cycrow | 
           2124 | 
           			if ( writeSize > remaining ) writeSize = remaining;
  | 
        
        
           | 6 | 
           cycrow | 
           2125 | 
              | 
        
        
           | 52 | 
           cycrow | 
           2126 | 
           			if ( file.write(data, writeSize) ) {
  | 
        
        
            | 
            | 
           2127 | 
           				data += writeSize;
  | 
        
        
            | 
            | 
           2128 | 
           				remaining -= writeSize;
  | 
        
        
            | 
            | 
           2129 | 
           			}
  | 
        
        
           | 6 | 
           cycrow | 
           2130 | 
              | 
        
        
           | 52 | 
           cycrow | 
           2131 | 
           			if ( progress ) progress->IncDone((int)writeSize);
  | 
        
        
           | 6 | 
           cycrow | 
           2132 | 
           		}
  | 
        
        
            | 
            | 
           2133 | 
           	}
  | 
        
        
            | 
            | 
           2134 | 
              | 
        
        
            | 
            | 
           2135 | 
           	return true;
  | 
        
        
            | 
            | 
           2136 | 
           }
  | 
        
        
            | 
            | 
           2137 | 
              | 
        
        
           | 131 | 
           cycrow | 
           2138 | 
           bool CBaseFile::extractFile(C_File *file, const Utils::String &dir, bool includedir, CProgressInfo *progress)
  | 
        
        
            | 
            | 
           2139 | 
           {
  | 
        
        
            | 
            | 
           2140 | 
           	if (ReadFileToMemory(file))
  | 
        
        
           | 6 | 
           cycrow | 
           2141 | 
           	{
  | 
        
        
            | 
            | 
           2142 | 
           		// now finally, uncompress the file
  | 
        
        
            | 
            | 
           2143 | 
           		long len = 0;
  | 
        
        
           | 131 | 
           cycrow | 
           2144 | 
           		unsigned char *data = file->UncompressData(&len, progress);
  | 
        
        
            | 
            | 
           2145 | 
           		if (!data)
  | 
        
        
           | 6 | 
           cycrow | 
           2146 | 
           		{
  | 
        
        
            | 
            | 
           2147 | 
           			// attempt a file decompress
  | 
        
        
           | 131 | 
           cycrow | 
           2148 | 
           			if (file->GetCompressionType() == SPKCOMPRESS_7ZIP)
  | 
        
        
           | 6 | 
           cycrow | 
           2149 | 
           			{
  | 
        
        
           | 178 | 
           cycrow | 
           2150 | 
           				if (file->uncompressToFile(dir, this, includedir, progress))
  | 
        
        
           | 6 | 
           cycrow | 
           2151 | 
           					return true;
  | 
        
        
            | 
            | 
           2152 | 
           			}
  | 
        
        
            | 
            | 
           2153 | 
           			return false;
  | 
        
        
            | 
            | 
           2154 | 
           		}
  | 
        
        
            | 
            | 
           2155 | 
              | 
        
        
           | 131 | 
           cycrow | 
           2156 | 
           		if (!file->writeToDir(dir, this, includedir, Utils::String::Null(), data, len))
  | 
        
        
           | 6 | 
           cycrow | 
           2157 | 
           			return false;
  | 
        
        
            | 
            | 
           2158 | 
              | 
        
        
            | 
            | 
           2159 | 
           		return true;
  | 
        
        
            | 
            | 
           2160 | 
              | 
        
        
            | 
            | 
           2161 | 
           	}
  | 
        
        
            | 
            | 
           2162 | 
           	else
  | 
        
        
            | 
            | 
           2163 | 
           		return false;
  | 
        
        
            | 
            | 
           2164 | 
           }
  | 
        
        
           | 197 | 
           cycrow | 
           2165 | 
           bool CBaseFile::extractFile(C_File *file, const Utils::String &dir, unsigned int game, const Utils::WStringList &gameAddons, bool includedir, CProgressInfo *progress)
  | 
        
        
           | 131 | 
           cycrow | 
           2166 | 
           {
  | 
        
        
            | 
            | 
           2167 | 
           	if (ReadFileToMemory(file))
  | 
        
        
            | 
            | 
           2168 | 
           	{
  | 
        
        
            | 
            | 
           2169 | 
           		CDirIO Dir(dir);
  | 
        
        
           | 197 | 
           cycrow | 
           2170 | 
           		Utils::WString addonDir;
  | 
        
        
           | 131 | 
           cycrow | 
           2171 | 
           		if (file->isFileInAddon())
  | 
        
        
            | 
            | 
           2172 | 
           		{
  | 
        
        
            | 
            | 
           2173 | 
           			int addonGame = file->getForSingleGame();
  | 
        
        
            | 
            | 
           2174 | 
           			if (!addonGame) addonGame = game;
  | 
        
        
           | 6 | 
           cycrow | 
           2175 | 
              | 
        
        
           | 131 | 
           cycrow | 
           2176 | 
           			if (addonGame > 0)
  | 
        
        
           | 197 | 
           cycrow | 
           2177 | 
           				addonDir = gameAddons.findString(Utils::WString::Number(addonGame));
  | 
        
        
           | 131 | 
           cycrow | 
           2178 | 
           		}
  | 
        
        
            | 
            | 
           2179 | 
              | 
        
        
            | 
            | 
           2180 | 
           		if (!addonDir.empty())
  | 
        
        
            | 
            | 
           2181 | 
           			Dir.cd(addonDir);
  | 
        
        
            | 
            | 
           2182 | 
              | 
        
        
            | 
            | 
           2183 | 
           		// create directory first
  | 
        
        
            | 
            | 
           2184 | 
           		Dir.create(file->getDirectory(this));
  | 
        
        
            | 
            | 
           2185 | 
              | 
        
        
            | 
            | 
           2186 | 
           		// now finally, uncompress the file
  | 
        
        
            | 
            | 
           2187 | 
           		long len = 0;
  | 
        
        
            | 
            | 
           2188 | 
           		unsigned char *data = file->UncompressData(&len, progress);
  | 
        
        
            | 
            | 
           2189 | 
           		if (!data)
  | 
        
        
            | 
            | 
           2190 | 
           		{
  | 
        
        
            | 
            | 
           2191 | 
           			// attempt a file decompress
  | 
        
        
            | 
            | 
           2192 | 
           			if (file->GetCompressionType() == SPKCOMPRESS_7ZIP)
  | 
        
        
            | 
            | 
           2193 | 
           			{
  | 
        
        
           | 196 | 
           cycrow | 
           2194 | 
           				if (file->uncompressToFile(Dir.dir().toString(), this, includedir, progress))
  | 
        
        
           | 131 | 
           cycrow | 
           2195 | 
           					return true;
  | 
        
        
            | 
            | 
           2196 | 
           			}
  | 
        
        
            | 
            | 
           2197 | 
           			return false;
  | 
        
        
            | 
            | 
           2198 | 
           		}
  | 
        
        
            | 
            | 
           2199 | 
              | 
        
        
           | 196 | 
           cycrow | 
           2200 | 
           		if (!file->writeToDir(Dir.dir().toString(), this, includedir, Utils::String::Null(), data, len))
  | 
        
        
           | 131 | 
           cycrow | 
           2201 | 
           			return false;
  | 
        
        
            | 
            | 
           2202 | 
              | 
        
        
            | 
            | 
           2203 | 
           		return true;
  | 
        
        
            | 
            | 
           2204 | 
              | 
        
        
            | 
            | 
           2205 | 
           	}
  | 
        
        
            | 
            | 
           2206 | 
           	else
  | 
        
        
            | 
            | 
           2207 | 
           		return false;
  | 
        
        
            | 
            | 
           2208 | 
           }
  | 
        
        
            | 
            | 
           2209 | 
              | 
        
        
           | 197 | 
           cycrow | 
           2210 | 
           bool CBaseFile::extractFile(int filenum, const Utils::String &dir, unsigned int game, const Utils::WStringList &gameAddons, bool includedir, CProgressInfo *progress)
  | 
        
        
           | 131 | 
           cycrow | 
           2211 | 
           {
  | 
        
        
            | 
            | 
           2212 | 
           	// invalid valus
  | 
        
        
            | 
            | 
           2213 | 
           	if (filenum < 0)
  | 
        
        
            | 
            | 
           2214 | 
           		return false;
  | 
        
        
            | 
            | 
           2215 | 
           	// out of range
  | 
        
        
            | 
            | 
           2216 | 
           	if (filenum > m_lFiles.size())
  | 
        
        
            | 
            | 
           2217 | 
           		return false;
  | 
        
        
            | 
            | 
           2218 | 
              | 
        
        
            | 
            | 
           2219 | 
           	// get the file pointer
  | 
        
        
            | 
            | 
           2220 | 
           	C_File *file = m_lFiles.Get(filenum);
  | 
        
        
            | 
            | 
           2221 | 
           	return extractFile(file, dir, game, gameAddons, includedir, progress);
  | 
        
        
            | 
            | 
           2222 | 
           }
  | 
        
        
            | 
            | 
           2223 | 
              | 
        
        
            | 
            | 
           2224 | 
           bool CBaseFile::extractFile(int filenum, const Utils::String &dir, bool includedir, CProgressInfo *progress)
  | 
        
        
            | 
            | 
           2225 | 
           {
  | 
        
        
            | 
            | 
           2226 | 
           	// invalid valus
  | 
        
        
            | 
            | 
           2227 | 
           	if (filenum < 0)
  | 
        
        
            | 
            | 
           2228 | 
           		return false;
  | 
        
        
            | 
            | 
           2229 | 
           	// out of range
  | 
        
        
            | 
            | 
           2230 | 
           	if (filenum > m_lFiles.size())
  | 
        
        
            | 
            | 
           2231 | 
           		return false;
  | 
        
        
            | 
            | 
           2232 | 
              | 
        
        
            | 
            | 
           2233 | 
           	// get the file pointer
  | 
        
        
            | 
            | 
           2234 | 
           	C_File *file = m_lFiles.Get(filenum);
  | 
        
        
           | 175 | 
           cycrow | 
           2235 | 
           	return extractFile(file, dir, includedir, progress);
  | 
        
        
           | 131 | 
           cycrow | 
           2236 | 
           }
  | 
        
        
            | 
            | 
           2237 | 
              | 
        
        
           | 129 | 
           cycrow | 
           2238 | 
           bool CBaseFile::extractAll(const Utils::String &dir, int game, const Utils::CStringList &gameAddons, bool includedir, CProgressInfo *progress)
  | 
        
        
           | 6 | 
           cycrow | 
           2239 | 
           {
  | 
        
        
            | 
            | 
           2240 | 
           	// no file to read from
  | 
        
        
           | 129 | 
           cycrow | 
           2241 | 
           	if (this->filename().empty())
  | 
        
        
           | 6 | 
           cycrow | 
           2242 | 
           		return false;
  | 
        
        
            | 
            | 
           2243 | 
              | 
        
        
            | 
            | 
           2244 | 
           	// now open the file
  | 
        
        
           | 58 | 
           cycrow | 
           2245 | 
           	CFileIO *File = _startRead();
  | 
        
        
           | 129 | 
           cycrow | 
           2246 | 
           	if (!File) return false;
  | 
        
        
           | 6 | 
           cycrow | 
           2247 | 
              | 
        
        
            | 
            | 
           2248 | 
           	// now were in the file section
  | 
        
        
            | 
            | 
           2249 | 
           	// skip past each one
  | 
        
        
           | 129 | 
           cycrow | 
           2250 | 
           	if (m_pIconFile) File->seek(4 + m_pIconFile->GetDataSize());
  | 
        
        
           | 6 | 
           cycrow | 
           2251 | 
              | 
        
        
           | 134 | 
           cycrow | 
           2252 | 
           	for (CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next()) 
  | 
        
        
            | 
            | 
           2253 | 
           	{
  | 
        
        
           | 6 | 
           cycrow | 
           2254 | 
           		C_File *fit = node->Data();
  | 
        
        
            | 
            | 
           2255 | 
              | 
        
        
           | 134 | 
           cycrow | 
           2256 | 
           		if ((!fit->GetDataSize()) || (!fit->GetData())) 
  | 
        
        
            | 
            | 
           2257 | 
           		{
  | 
        
        
            | 
            | 
           2258 | 
           			if (!fit->readFromFile(*File, fit->GetDataSize())) 
  | 
        
        
            | 
            | 
           2259 | 
           				return false;
  | 
        
        
           | 6 | 
           cycrow | 
           2260 | 
           		}
  | 
        
        
            | 
            | 
           2261 | 
           		else
  | 
        
        
           | 58 | 
           cycrow | 
           2262 | 
           			File->seek(fit->GetDataSize());
  | 
        
        
           | 6 | 
           cycrow | 
           2263 | 
              | 
        
        
           | 129 | 
           cycrow | 
           2264 | 
           		if (game && !fit->isForGame(game))
  | 
        
        
            | 
            | 
           2265 | 
           			continue;
  | 
        
        
            | 
            | 
           2266 | 
              | 
        
        
           | 134 | 
           cycrow | 
           2267 | 
           		if (progress)	
  | 
        
        
            | 
            | 
           2268 | 
           			progress->UpdateFile(fit);
  | 
        
        
            | 
            | 
           2269 | 
              | 
        
        
           | 129 | 
           cycrow | 
           2270 | 
           		CDirIO Dir(dir);
  | 
        
        
            | 
            | 
           2271 | 
           		Utils::String addonDir;
  | 
        
        
            | 
            | 
           2272 | 
           		if (fit->isFileInAddon())
  | 
        
        
            | 
            | 
           2273 | 
           		{
  | 
        
        
            | 
            | 
           2274 | 
           			int addonGame = fit->getForSingleGame();
  | 
        
        
            | 
            | 
           2275 | 
           			if (!addonGame) addonGame = game;
  | 
        
        
            | 
            | 
           2276 | 
              | 
        
        
            | 
            | 
           2277 | 
           			if (addonGame > 0)
  | 
        
        
            | 
            | 
           2278 | 
           				addonDir = gameAddons.findString(Utils::String::Number(addonGame));
  | 
        
        
           | 6 | 
           cycrow | 
           2279 | 
           		}
  | 
        
        
            | 
            | 
           2280 | 
              | 
        
        
           | 129 | 
           cycrow | 
           2281 | 
           		if (!addonDir.empty())
  | 
        
        
            | 
            | 
           2282 | 
           			Dir.cd(addonDir);
  | 
        
        
            | 
            | 
           2283 | 
              | 
        
        
           | 6 | 
           cycrow | 
           2284 | 
           		// create directory first
  | 
        
        
           | 129 | 
           cycrow | 
           2285 | 
           		Dir.create(fit->getDirectory(this));
  | 
        
        
           | 6 | 
           cycrow | 
           2286 | 
              | 
        
        
            | 
            | 
           2287 | 
           		long size = 0;
  | 
        
        
           | 129 | 
           cycrow | 
           2288 | 
           		unsigned char *data = fit->UncompressData(&size, progress);
  | 
        
        
            | 
            | 
           2289 | 
           		if ((!data) && (fit->GetCompressionType() == SPKCOMPRESS_7ZIP)) {
  | 
        
        
           | 196 | 
           cycrow | 
           2290 | 
           			if (!fit->uncompressToFile(Dir.dir().toString(), this, includedir, progress)) return false;
  | 
        
        
           | 6 | 
           cycrow | 
           2291 | 
           		}
  | 
        
        
           | 196 | 
           cycrow | 
           2292 | 
           		else if ((!data) || (!fit->writeToDir(Dir.dir().toString(), this, includedir, Utils::String::Null(), data, size))) return false;
  | 
        
        
           | 6 | 
           cycrow | 
           2293 | 
           	}
  | 
        
        
            | 
            | 
           2294 | 
              | 
        
        
           | 58 | 
           cycrow | 
           2295 | 
           	delete File;
  | 
        
        
           | 6 | 
           cycrow | 
           2296 | 
           	return true;
  | 
        
        
            | 
            | 
           2297 | 
           }
  | 
        
        
            | 
            | 
           2298 | 
              | 
        
        
            | 
            | 
           2299 | 
              | 
        
        
           | 175 | 
           cycrow | 
           2300 | 
           bool CBaseFile::computeSigned(bool updateFiles) const
  | 
        
        
           | 6 | 
           cycrow | 
           2301 | 
           {
  | 
        
        
           | 175 | 
           cycrow | 
           2302 | 
           	for (CListNode<C_File>* node = m_lFiles.Front(); node; node = node->next())
  | 
        
        
           | 6 | 
           cycrow | 
           2303 | 
           	{
  | 
        
        
           | 175 | 
           cycrow | 
           2304 | 
           		C_File* file = node->Data();
  | 
        
        
            | 
            | 
           2305 | 
           		if (updateFiles)
  | 
        
        
           | 6 | 
           cycrow | 
           2306 | 
           			file->UpdateSigned();
  | 
        
        
            | 
            | 
           2307 | 
           		// extra, text, soundtrack, readmes and screen files do not require a modified game directly
  | 
        
        
           | 175 | 
           cycrow | 
           2308 | 
           		if ((file->GetFileType() == FILETYPE_EXTRA) || (file->GetFileType() == FILETYPE_TEXT) || (file->GetFileType() == FILETYPE_SOUND) || (file->GetFileType() == FILETYPE_SCREEN) || (file->GetFileType() == FILETYPE_README))
  | 
        
        
           | 6 | 
           cycrow | 
           2309 | 
           			continue;
  | 
        
        
            | 
            | 
           2310 | 
           		// mods and maps always need modified game
  | 
        
        
           | 175 | 
           cycrow | 
           2311 | 
           		else if ((file->GetFileType() == FILETYPE_MOD) || (file->GetFileType() == FILETYPE_MAP))
  | 
        
        
            | 
            | 
           2312 | 
           			return false;
  | 
        
        
           | 6 | 
           cycrow | 
           2313 | 
              | 
        
        
            | 
            | 
           2314 | 
           		// else should be a script file, script or uninstall type
  | 
        
        
            | 
            | 
           2315 | 
           		// all scripts must be signed, if any are not, then no signed status
  | 
        
        
           | 175 | 
           cycrow | 
           2316 | 
           		if (!file->IsSigned())
  | 
        
        
            | 
            | 
           2317 | 
           			return false;
  | 
        
        
           | 6 | 
           cycrow | 
           2318 | 
           	}
  | 
        
        
            | 
            | 
           2319 | 
              | 
        
        
           | 175 | 
           cycrow | 
           2320 | 
           	return true;
  | 
        
        
            | 
            | 
           2321 | 
           }
  | 
        
        
            | 
            | 
           2322 | 
              | 
        
        
            | 
            | 
           2323 | 
           bool CBaseFile::updateSigned(bool updateFiles)
  | 
        
        
            | 
            | 
           2324 | 
           {
  | 
        
        
            | 
            | 
           2325 | 
           	m_bSigned = computeSigned(updateFiles);
  | 
        
        
           | 6 | 
           cycrow | 
           2326 | 
           	return m_bSigned;
  | 
        
        
            | 
            | 
           2327 | 
           }
  | 
        
        
            | 
            | 
           2328 | 
              | 
        
        
           | 203 | 
           cycrow | 
           2329 | 
           bool CBaseFile::isPackageNeeded(const Utils::WString &scriptName, const Utils::WString &author)
  | 
        
        
           | 6 | 
           cycrow | 
           2330 | 
           {
  | 
        
        
            | 
            | 
           2331 | 
           	for ( CListNode<SNeededLibrary> *node = m_lNeededLibrarys.Front(); node; node = node->next() )
  | 
        
        
            | 
            | 
           2332 | 
           	{
  | 
        
        
            | 
            | 
           2333 | 
           		SNeededLibrary *l = node->Data();
  | 
        
        
            | 
            | 
           2334 | 
           		if ( l->sName.Compare(scriptName) && l->sAuthor.Compare(author) )
  | 
        
        
            | 
            | 
           2335 | 
           			return true;
  | 
        
        
            | 
            | 
           2336 | 
           	}
  | 
        
        
            | 
            | 
           2337 | 
              | 
        
        
            | 
            | 
           2338 | 
           	return false;
  | 
        
        
            | 
            | 
           2339 | 
           }
  | 
        
        
            | 
            | 
           2340 | 
              | 
        
        
           | 203 | 
           cycrow | 
           2341 | 
           SNeededLibrary *CBaseFile::findPackageNeeded(const Utils::WString &scriptName, const Utils::WString &author)
  | 
        
        
           | 6 | 
           cycrow | 
           2342 | 
           {
  | 
        
        
            | 
            | 
           2343 | 
           	for ( CListNode<SNeededLibrary> *node = m_lNeededLibrarys.Front(); node; node = node->next() )
  | 
        
        
            | 
            | 
           2344 | 
           	{
  | 
        
        
            | 
            | 
           2345 | 
           		SNeededLibrary *l = node->Data();
  | 
        
        
            | 
            | 
           2346 | 
           		if ( l->sName.Compare(scriptName) && l->sAuthor.Compare(author) )
  | 
        
        
            | 
            | 
           2347 | 
           			return l;
  | 
        
        
            | 
            | 
           2348 | 
           	}
  | 
        
        
            | 
            | 
           2349 | 
              | 
        
        
            | 
            | 
           2350 | 
           	return NULL;
  | 
        
        
            | 
            | 
           2351 | 
           }
  | 
        
        
            | 
            | 
           2352 | 
              | 
        
        
           | 207 | 
           cycrow | 
           2353 | 
           void CBaseFile::removeFakePatchOrder(const Utils::WString &scriptName, const Utils::WString &author)
  | 
        
        
           | 6 | 
           cycrow | 
           2354 | 
           {
  | 
        
        
           | 160 | 
           cycrow | 
           2355 | 
           	removeFakePatchOrder(true, scriptName, author);
  | 
        
        
            | 
            | 
           2356 | 
           	removeFakePatchOrder(false, scriptName, author);
  | 
        
        
           | 6 | 
           cycrow | 
           2357 | 
           }
  | 
        
        
           | 207 | 
           cycrow | 
           2358 | 
           void CBaseFile::removeFakePatchOrder(bool after, const Utils::WString &scriptName, const Utils::WString &author)
  | 
        
        
           | 6 | 
           cycrow | 
           2359 | 
           {
  | 
        
        
           | 207 | 
           cycrow | 
           2360 | 
           	Utils::WStringList *list;
  | 
        
        
           | 6 | 
           cycrow | 
           2361 | 
           	if ( after )
  | 
        
        
           | 160 | 
           cycrow | 
           2362 | 
           		list = &_lFakePatchAfter;
  | 
        
        
           | 6 | 
           cycrow | 
           2363 | 
           	else
  | 
        
        
           | 160 | 
           cycrow | 
           2364 | 
           		list = &_lFakePatchBefore;
  | 
        
        
           | 6 | 
           cycrow | 
           2365 | 
              | 
        
        
           | 160 | 
           cycrow | 
           2366 | 
           	int found = list->findStringAndData(scriptName, author);
  | 
        
        
            | 
            | 
           2367 | 
           	while (found != -1)
  | 
        
        
           | 6 | 
           cycrow | 
           2368 | 
           	{
  | 
        
        
           | 160 | 
           cycrow | 
           2369 | 
           		list->removeAt(found);
  | 
        
        
            | 
            | 
           2370 | 
           		found = list->findStringAndData(scriptName, author);
  | 
        
        
           | 6 | 
           cycrow | 
           2371 | 
           	}
  | 
        
        
            | 
            | 
           2372 | 
           }
  | 
        
        
            | 
            | 
           2373 | 
              | 
        
        
           | 207 | 
           cycrow | 
           2374 | 
           void CBaseFile::addFakePatchOrder(bool after, const Utils::WString &scriptName, const Utils::WString &author)
  | 
        
        
           | 6 | 
           cycrow | 
           2375 | 
           {
  | 
        
        
           | 207 | 
           cycrow | 
           2376 | 
           	Utils::WStringList *list;
  | 
        
        
           | 6 | 
           cycrow | 
           2377 | 
           	if ( after )
  | 
        
        
           | 160 | 
           cycrow | 
           2378 | 
           		list = &_lFakePatchAfter;
  | 
        
        
           | 6 | 
           cycrow | 
           2379 | 
           	else
  | 
        
        
           | 160 | 
           cycrow | 
           2380 | 
           		list = &_lFakePatchBefore;
  | 
        
        
           | 6 | 
           cycrow | 
           2381 | 
              | 
        
        
            | 
            | 
           2382 | 
           	// check if the package already exists
  | 
        
        
           | 160 | 
           cycrow | 
           2383 | 
           	if (!list->containsStringAndData(scriptName, author))
  | 
        
        
           | 6 | 
           cycrow | 
           2384 | 
           	{
  | 
        
        
           | 160 | 
           cycrow | 
           2385 | 
           		// cant have it on both list
  | 
        
        
            | 
            | 
           2386 | 
           		removeFakePatchOrder(!after, scriptName, author);
  | 
        
        
            | 
            | 
           2387 | 
              | 
        
        
            | 
            | 
           2388 | 
           		list->pushBack(scriptName, author);
  | 
        
        
           | 6 | 
           cycrow | 
           2389 | 
           	}
  | 
        
        
            | 
            | 
           2390 | 
           }
  | 
        
        
           | 204 | 
           cycrow | 
           2391 | 
           void CBaseFile::addNeededLibrary(const Utils::WString &scriptName, const Utils::WString &author, const Utils::WString &minVersion)
  | 
        
        
           | 6 | 
           cycrow | 
           2392 | 
           {
  | 
        
        
           | 203 | 
           cycrow | 
           2393 | 
           	SNeededLibrary *l = this->findPackageNeeded(scriptName, author);
  | 
        
        
           | 6 | 
           cycrow | 
           2394 | 
           	if ( !l )
  | 
        
        
            | 
            | 
           2395 | 
           	{
  | 
        
        
            | 
            | 
           2396 | 
           		l = new SNeededLibrary;
  | 
        
        
            | 
            | 
           2397 | 
           		l->sName = scriptName;
  | 
        
        
            | 
            | 
           2398 | 
           		l->sAuthor = author;
  | 
        
        
            | 
            | 
           2399 | 
           		m_lNeededLibrarys.push_back(l);
  | 
        
        
            | 
            | 
           2400 | 
           	}
  | 
        
        
            | 
            | 
           2401 | 
           	l->sMinVersion = minVersion;
  | 
        
        
            | 
            | 
           2402 | 
           }
  | 
        
        
            | 
            | 
           2403 | 
              | 
        
        
           | 203 | 
           cycrow | 
           2404 | 
           void CBaseFile::removePackageNeeded(const Utils::WString &scriptName, const Utils::WString &author)
  | 
        
        
           | 6 | 
           cycrow | 
           2405 | 
           {
  | 
        
        
           | 203 | 
           cycrow | 
           2406 | 
           	SNeededLibrary *l = this->findPackageNeeded(scriptName, author);
  | 
        
        
           | 6 | 
           cycrow | 
           2407 | 
           	if ( l )
  | 
        
        
            | 
            | 
           2408 | 
           	{
  | 
        
        
            | 
            | 
           2409 | 
           		m_lNeededLibrarys.remove(l);
  | 
        
        
            | 
            | 
           2410 | 
           		delete l;
  | 
        
        
            | 
            | 
           2411 | 
           	}
  | 
        
        
            | 
            | 
           2412 | 
           }
  | 
        
        
            | 
            | 
           2413 | 
              | 
        
        
            | 
            | 
           2414 | 
           void CBaseFile::ClearNeededPackages()
  | 
        
        
            | 
            | 
           2415 | 
           {
  | 
        
        
           | 203 | 
           cycrow | 
           2416 | 
           	SNeededLibrary *ns = this->findPackageNeeded(L"<package>", L"<author>");
  | 
        
        
           | 204 | 
           cycrow | 
           2417 | 
           	Utils::WString version;
  | 
        
        
           | 46 | 
           cycrow | 
           2418 | 
           	if ( ns ) version = ns->sMinVersion;
  | 
        
        
            | 
            | 
           2419 | 
              | 
        
        
           | 6 | 
           cycrow | 
           2420 | 
           	for ( CListNode<SNeededLibrary> *node = m_lNeededLibrarys.Front(); node; node = node->next() )
  | 
        
        
            | 
            | 
           2421 | 
           		node->DeleteData();
  | 
        
        
            | 
            | 
           2422 | 
           	m_lNeededLibrarys.clear();
  | 
        
        
            | 
            | 
           2423 | 
              | 
        
        
           | 203 | 
           cycrow | 
           2424 | 
           	if ( !version.empty() )	this->addNeededLibrary(L"<package>", L"<author>", version);
  | 
        
        
           | 6 | 
           cycrow | 
           2425 | 
           }
  | 
        
        
            | 
            | 
           2426 | 
              | 
        
        
            | 
            | 
           2427 | 
              | 
        
        
           | 127 | 
           cycrow | 
           2428 | 
           bool CBaseFile::GeneratePackagerScript(bool wildcard, Utils::CStringList *list, int game, const Utils::CStringList &gameAddons, bool datafile)
  | 
        
        
           | 6 | 
           cycrow | 
           2429 | 
           {
  | 
        
        
           | 126 | 
           cycrow | 
           2430 | 
           	list->pushBack("#");
  | 
        
        
            | 
            | 
           2431 | 
           	list->pushBack("# Packager Script");
  | 
        
        
            | 
            | 
           2432 | 
           	list->pushBack("# -- Generated by SPK Libraries V" + Utils::String::FromFloat(GetLibraryVersion(), 2) + " --");
  | 
        
        
            | 
            | 
           2433 | 
           	list->pushBack("#");
  | 
        
        
            | 
            | 
           2434 | 
           	list->pushBack("");
  | 
        
        
           | 6 | 
           cycrow | 
           2435 | 
           	if ( !datafile )
  | 
        
        
            | 
            | 
           2436 | 
           	{
  | 
        
        
           | 126 | 
           cycrow | 
           2437 | 
           		list->pushBack("# Variable for your game directory, where to get files from");
  | 
        
        
            | 
            | 
           2438 | 
           		list->pushBack("# $PATH variable is used to get the current path");
  | 
        
        
            | 
            | 
           2439 | 
           		list->pushBack("Variable: $GAMEDIR $PATH");
  | 
        
        
            | 
            | 
           2440 | 
           		list->pushBack("");
  | 
        
        
           | 6 | 
           cycrow | 
           2441 | 
           	}
  | 
        
        
           | 126 | 
           cycrow | 
           2442 | 
           	list->pushBack("# The name of the script");
  | 
        
        
           | 203 | 
           cycrow | 
           2443 | 
           	list->pushBack("Name: " + this->name().toString());
  | 
        
        
           | 126 | 
           cycrow | 
           2444 | 
           	list->pushBack("");
  | 
        
        
            | 
            | 
           2445 | 
           	list->pushBack("# The author of the script, ie, you");
  | 
        
        
           | 203 | 
           cycrow | 
           2446 | 
           	list->pushBack("Author: " + this->author().toString());
  | 
        
        
           | 126 | 
           cycrow | 
           2447 | 
           	list->pushBack("");
  | 
        
        
            | 
            | 
           2448 | 
           	list->pushBack("# The creation data, when it was created");
  | 
        
        
           | 6 | 
           cycrow | 
           2449 | 
           	if ( datafile )
  | 
        
        
           | 204 | 
           cycrow | 
           2450 | 
           		list->pushBack("Date: " + this->creationDate().toString());
  | 
        
        
           | 50 | 
           cycrow | 
           2451 | 
           	else {
  | 
        
        
           | 126 | 
           cycrow | 
           2452 | 
           		list->pushBack("# $DATE variable is used to get the current date");
  | 
        
        
            | 
            | 
           2453 | 
           		list->pushBack("Date: $DATE");
  | 
        
        
           | 6 | 
           cycrow | 
           2454 | 
           	}
  | 
        
        
           | 126 | 
           cycrow | 
           2455 | 
           	list->pushBack("");
  | 
        
        
            | 
            | 
           2456 | 
           	list->pushBack("# The version of script");
  | 
        
        
           | 6 | 
           cycrow | 
           2457 | 
           	if ( datafile )
  | 
        
        
           | 204 | 
           cycrow | 
           2458 | 
           		list->pushBack("Version: " + this->version().toString());
  | 
        
        
           | 6 | 
           cycrow | 
           2459 | 
           	else
  | 
        
        
            | 
            | 
           2460 | 
           	{
  | 
        
        
           | 126 | 
           cycrow | 
           2461 | 
           		list->pushBack("# $ASK variable is used to get an input when creating");
  | 
        
        
            | 
            | 
           2462 | 
           		list->pushBack("Version: $ASK");
  | 
        
        
           | 6 | 
           cycrow | 
           2463 | 
           	}
  | 
        
        
           | 126 | 
           cycrow | 
           2464 | 
           	list->pushBack("");
  | 
        
        
           | 6 | 
           cycrow | 
           2465 | 
              | 
        
        
            | 
            | 
           2466 | 
           	if ( !m_lGames.empty() ) {
  | 
        
        
           | 126 | 
           cycrow | 
           2467 | 
           		list->pushBack("# The game version the script is for <game> <version> (can have multiple games)");
  | 
        
        
           | 6 | 
           cycrow | 
           2468 | 
           		for ( SGameCompat *g = m_lGames.First(); g; g = m_lGames.Next() ) {
  | 
        
        
           | 126 | 
           cycrow | 
           2469 | 
           			if (game > 0 && g->iGame != game)
  | 
        
        
            | 
            | 
           2470 | 
           				continue;
  | 
        
        
            | 
            | 
           2471 | 
              | 
        
        
           | 197 | 
           cycrow | 
           2472 | 
           			Utils::WString game = CBaseFile::ConvertGameToString(g->iGame);
  | 
        
        
           | 6 | 
           cycrow | 
           2473 | 
              | 
        
        
           | 46 | 
           cycrow | 
           2474 | 
           			if ( !g->sVersion.empty() )
  | 
        
        
           | 6 | 
           cycrow | 
           2475 | 
           			{
  | 
        
        
           | 197 | 
           cycrow | 
           2476 | 
           				game += L" ";
  | 
        
        
           | 46 | 
           cycrow | 
           2477 | 
           				game += g->sVersion;
  | 
        
        
           | 6 | 
           cycrow | 
           2478 | 
           			}
  | 
        
        
            | 
            | 
           2479 | 
           			else
  | 
        
        
            | 
            | 
           2480 | 
           			{
  | 
        
        
           | 197 | 
           cycrow | 
           2481 | 
           				game += L" ";
  | 
        
        
           | 6 | 
           cycrow | 
           2482 | 
           				game += (long)g->iVersion;
  | 
        
        
            | 
            | 
           2483 | 
           			}
  | 
        
        
            | 
            | 
           2484 | 
              | 
        
        
           | 197 | 
           cycrow | 
           2485 | 
           			list->pushBack("Game: " + game.toString());
  | 
        
        
           | 6 | 
           cycrow | 
           2486 | 
           		}
  | 
        
        
            | 
            | 
           2487 | 
              | 
        
        
           | 126 | 
           cycrow | 
           2488 | 
           		list->pushBack("");
  | 
        
        
           | 6 | 
           cycrow | 
           2489 | 
           	}
  | 
        
        
            | 
            | 
           2490 | 
              | 
        
        
           | 48 | 
           cycrow | 
           2491 | 
           	if ( !this->description().empty() ) {
  | 
        
        
           | 126 | 
           cycrow | 
           2492 | 
           		list->pushBack("# The description of the script, displays when installing");
  | 
        
        
           | 206 | 
           cycrow | 
           2493 | 
           		list->pushBack("Description: " + this->description().toString());
  | 
        
        
           | 126 | 
           cycrow | 
           2494 | 
           		list->pushBack("");
  | 
        
        
           | 6 | 
           cycrow | 
           2495 | 
           	}
  | 
        
        
            | 
            | 
           2496 | 
              | 
        
        
           | 49 | 
           cycrow | 
           2497 | 
           	if ( !this->webSite().empty() ) {
  | 
        
        
           | 126 | 
           cycrow | 
           2498 | 
           		list->pushBack("# A link to the website for the script, ie for an online help page");
  | 
        
        
           | 206 | 
           cycrow | 
           2499 | 
           		list->pushBack("WebSite: " + this->webSite().toString());
  | 
        
        
           | 126 | 
           cycrow | 
           2500 | 
           		list->pushBack("");
  | 
        
        
           | 6 | 
           cycrow | 
           2501 | 
           	}
  | 
        
        
            | 
            | 
           2502 | 
              | 
        
        
           | 49 | 
           cycrow | 
           2503 | 
           	if ( !this->forumLink().empty() ) {
  | 
        
        
           | 126 | 
           cycrow | 
           2504 | 
           		list->pushBack("# A direct link to the thread in the egosoft forum");
  | 
        
        
           | 206 | 
           cycrow | 
           2505 | 
           		list->pushBack("ForumLink: " + this->forumLink().toString());
  | 
        
        
           | 126 | 
           cycrow | 
           2506 | 
           		list->pushBack("");
  | 
        
        
           | 6 | 
           cycrow | 
           2507 | 
           	}
  | 
        
        
            | 
            | 
           2508 | 
              | 
        
        
           | 49 | 
           cycrow | 
           2509 | 
           	if ( !this->webAddress().empty() ) {
  | 
        
        
           | 126 | 
           cycrow | 
           2510 | 
           		list->pushBack("# A link to the address for the update file");
  | 
        
        
           | 206 | 
           cycrow | 
           2511 | 
           		list->pushBack("WebAddress: " + this->webAddress().toString());
  | 
        
        
           | 126 | 
           cycrow | 
           2512 | 
           		list->pushBack("");
  | 
        
        
           | 6 | 
           cycrow | 
           2513 | 
           	}
  | 
        
        
            | 
            | 
           2514 | 
              | 
        
        
           | 49 | 
           cycrow | 
           2515 | 
           	if ( !this->email().empty() ) {
  | 
        
        
           | 126 | 
           cycrow | 
           2516 | 
           		list->pushBack("# The email address of the author, to allow users to contract if needed");
  | 
        
        
           | 206 | 
           cycrow | 
           2517 | 
           		list->pushBack("Email: " + this->email().toString());
  | 
        
        
           | 126 | 
           cycrow | 
           2518 | 
           		list->pushBack("");
  | 
        
        
           | 6 | 
           cycrow | 
           2519 | 
           	}
  | 
        
        
            | 
            | 
           2520 | 
              | 
        
        
           | 208 | 
           cycrow | 
           2521 | 
           	if (webMirrors().size())
  | 
        
        
           | 6 | 
           cycrow | 
           2522 | 
           	{
  | 
        
        
           | 126 | 
           cycrow | 
           2523 | 
           		list->pushBack("# A link to the mirror address for the update file, can have many of these");
  | 
        
        
           | 208 | 
           cycrow | 
           2524 | 
           		for(auto itr = webMirrors().begin(); itr != webMirrors().end(); itr++)
  | 
        
        
            | 
            | 
           2525 | 
           			list->pushBack(Utils::String("WebMirror: ") + (*itr)->str.toString());
  | 
        
        
           | 126 | 
           cycrow | 
           2526 | 
           		list->pushBack("");
  | 
        
        
           | 6 | 
           cycrow | 
           2527 | 
           	}
  | 
        
        
            | 
            | 
           2528 | 
              | 
        
        
            | 
            | 
           2529 | 
           	if ( m_bAutoGenerateUpdateFile )
  | 
        
        
            | 
            | 
           2530 | 
           	{
  | 
        
        
           | 126 | 
           cycrow | 
           2531 | 
           		list->pushBack("# Auto generate the package update file when created");
  | 
        
        
            | 
            | 
           2532 | 
           		list->pushBack("GenerateUpdateFile");
  | 
        
        
           | 6 | 
           cycrow | 
           2533 | 
           	}
  | 
        
        
            | 
            | 
           2534 | 
              | 
        
        
            | 
            | 
           2535 | 
           	if ( m_lNeededLibrarys.size() )
  | 
        
        
            | 
            | 
           2536 | 
           	{
  | 
        
        
           | 126 | 
           cycrow | 
           2537 | 
           		list->pushBack("# Needed Library dependacies, require these to be installed");
  | 
        
        
           | 6 | 
           cycrow | 
           2538 | 
           		for ( CListNode<SNeededLibrary> *node = m_lNeededLibrarys.Front(); node; node = node->next() )
  | 
        
        
           | 204 | 
           cycrow | 
           2539 | 
           			list->pushBack((L"Depend: " + node->Data()->sName + L"|" + node->Data()->sMinVersion + L"|" + node->Data()->sAuthor).toString());
  | 
        
        
           | 6 | 
           cycrow | 
           2540 | 
              | 
        
        
           | 126 | 
           cycrow | 
           2541 | 
           		list->pushBack("");
  | 
        
        
           | 6 | 
           cycrow | 
           2542 | 
           	}
  | 
        
        
            | 
            | 
           2543 | 
              | 
        
        
           | 46 | 
           cycrow | 
           2544 | 
           	if ( !_noRatings() )
  | 
        
        
           | 6 | 
           cycrow | 
           2545 | 
           	{
  | 
        
        
           | 126 | 
           cycrow | 
           2546 | 
           		list->pushBack("# Ratings Values, 0 to 5, <ease> <changing> <recommended>");
  | 
        
        
            | 
            | 
           2547 | 
           		list->pushBack(Utils::String("Ratings: ") + (long)easeOfUse() + " " + (long)gameChanging() + " " + (long)recommended());
  | 
        
        
            | 
            | 
           2548 | 
           		list->pushBack("");
  | 
        
        
           | 6 | 
           cycrow | 
           2549 | 
           	}
  | 
        
        
            | 
            | 
           2550 | 
              | 
        
        
           | 170 | 
           cycrow | 
           2551 | 
           	if (namesList()->size())
  | 
        
        
           | 6 | 
           cycrow | 
           2552 | 
           	{
  | 
        
        
           | 126 | 
           cycrow | 
           2553 | 
           		list->pushBack("# Package names, uses different names for different languages");
  | 
        
        
           | 170 | 
           cycrow | 
           2554 | 
           		for(auto itr = namesList()->begin(); itr != namesList()->end(); itr++)
  | 
        
        
           | 204 | 
           cycrow | 
           2555 | 
           			list->pushBack((Utils::WString("ScriptName: ") + (long)(*itr)->iLanguage + L" " + (*itr)->sName).toString());
  | 
        
        
           | 126 | 
           cycrow | 
           2556 | 
           		list->pushBack("");
  | 
        
        
           | 6 | 
           cycrow | 
           2557 | 
           	}
  | 
        
        
            | 
            | 
           2558 | 
              | 
        
        
           | 46 | 
           cycrow | 
           2559 | 
           	for ( int j = 0; j < 2; j++ ) {
  | 
        
        
           | 206 | 
           cycrow | 
           2560 | 
           		Utils::WString installText = (j == 0) ? L"Install" : L"Uninstall";
  | 
        
        
           | 46 | 
           cycrow | 
           2561 | 
           		const CInstallText *pText = (j == 0) ? this->installText() : this->uninstallText();
  | 
        
        
            | 
            | 
           2562 | 
           		if ( pText->any() )
  | 
        
        
           | 6 | 
           cycrow | 
           2563 | 
           		{
  | 
        
        
           | 206 | 
           cycrow | 
           2564 | 
           			list->pushBack((L"# " + installText + L" Texts, display text before and/or after " + installText + L"ing to inform the use of special conditions").toString());
  | 
        
        
           | 46 | 
           cycrow | 
           2565 | 
           			for ( unsigned int i = 0; i < pText->count(); i++ ) {
  | 
        
        
            | 
            | 
           2566 | 
           				long iLang = pText->language(i);
  | 
        
        
           | 206 | 
           cycrow | 
           2567 | 
           				if ( !pText->getBefore(iLang).empty() )	list->pushBack((installText + "Before: " + iLang + L" " + pText->getBefore(iLang)).toString());
  | 
        
        
            | 
            | 
           2568 | 
           				if ( !pText->getAfter(iLang).empty()  )	list->pushBack((installText + "After: " + iLang + L" " + pText->getAfter(iLang)).toString());
  | 
        
        
           | 46 | 
           cycrow | 
           2569 | 
           			}
  | 
        
        
           | 126 | 
           cycrow | 
           2570 | 
           			list->pushBack("");
  | 
        
        
           | 6 | 
           cycrow | 
           2571 | 
           		}
  | 
        
        
            | 
            | 
           2572 | 
           	}
  | 
        
        
            | 
            | 
           2573 | 
              | 
        
        
           | 126 | 
           cycrow | 
           2574 | 
           	list->pushBack("# Plugin Type, the type the plugin is, mainly used to show users the type, types include: Normal, Stable, Experimental, Cheat, Mod");
  | 
        
        
           | 48 | 
           cycrow | 
           2575 | 
           	switch ( this->pluginType() )
  | 
        
        
           | 6 | 
           cycrow | 
           2576 | 
           	{
  | 
        
        
            | 
            | 
           2577 | 
           		case PLUGIN_NORMAL:
  | 
        
        
           | 126 | 
           cycrow | 
           2578 | 
           			list->pushBack("PluginType: Normal");
  | 
        
        
           | 6 | 
           cycrow | 
           2579 | 
           			break;
  | 
        
        
            | 
            | 
           2580 | 
           		case PLUGIN_STABLE:
  | 
        
        
           | 126 | 
           cycrow | 
           2581 | 
           			list->pushBack("PluginType: Stable");
  | 
        
        
           | 6 | 
           cycrow | 
           2582 | 
           			break;
  | 
        
        
            | 
            | 
           2583 | 
           		case PLUGIN_EXPERIMENTAL:
  | 
        
        
           | 126 | 
           cycrow | 
           2584 | 
           			list->pushBack("PluginType: Experimental");
  | 
        
        
           | 6 | 
           cycrow | 
           2585 | 
           			break;
  | 
        
        
            | 
            | 
           2586 | 
           		case PLUGIN_CHEAT:
  | 
        
        
           | 126 | 
           cycrow | 
           2587 | 
           			list->pushBack("PluginType: Cheat");
  | 
        
        
           | 6 | 
           cycrow | 
           2588 | 
           			break;
  | 
        
        
            | 
            | 
           2589 | 
           		case PLUGIN_MOD:
  | 
        
        
           | 126 | 
           cycrow | 
           2590 | 
           			list->pushBack("PluginType: Mod");
  | 
        
        
           | 6 | 
           cycrow | 
           2591 | 
           			break;
  | 
        
        
            | 
            | 
           2592 | 
           	}
  | 
        
        
           | 126 | 
           cycrow | 
           2593 | 
           	list->pushBack("");
  | 
        
        
           | 6 | 
           cycrow | 
           2594 | 
              | 
        
        
            | 
            | 
           2595 | 
           	return true;
  | 
        
        
            | 
            | 
           2596 | 
           }
  | 
        
        
            | 
            | 
           2597 | 
              | 
        
        
           | 127 | 
           cycrow | 
           2598 | 
           bool CBaseFile::GeneratePackagerScriptFile(bool wildcard, Utils::CStringList *list, int game, const Utils::CStringList &gameAddons)
  | 
        
        
           | 6 | 
           cycrow | 
           2599 | 
           {
  | 
        
        
            | 
            | 
           2600 | 
           	// now do files and wildcards
  | 
        
        
           | 197 | 
           cycrow | 
           2601 | 
           	Utils::WStringList files;
  | 
        
        
           | 6 | 
           cycrow | 
           2602 | 
           	for ( CListNode<C_File> *f = m_lFiles.Front(); f; f = f->next() )
  | 
        
        
            | 
            | 
           2603 | 
           	{
  | 
        
        
           | 127 | 
           cycrow | 
           2604 | 
           		if (game && !(f->Data()->game() & 1 << game))
  | 
        
        
           | 126 | 
           cycrow | 
           2605 | 
           			continue;
  | 
        
        
           | 6 | 
           cycrow | 
           2606 | 
              | 
        
        
           | 197 | 
           cycrow | 
           2607 | 
           		Utils::WString name = L"$GAMEDIR/";
  | 
        
        
           | 126 | 
           cycrow | 
           2608 | 
              | 
        
        
           | 127 | 
           cycrow | 
           2609 | 
           		// addon directory?
  | 
        
        
            | 
            | 
           2610 | 
           		unsigned int checkGame = f->Data()->game() & ~(1 << 31);
  | 
        
        
            | 
            | 
           2611 | 
           		unsigned int foundGame = 0;
  | 
        
        
            | 
            | 
           2612 | 
           		for (int i = 0; i < 31; ++i)
  | 
        
        
            | 
            | 
           2613 | 
           		{
  | 
        
        
            | 
            | 
           2614 | 
           			if (checkGame == 1 << i)
  | 
        
        
            | 
            | 
           2615 | 
           			{
  | 
        
        
            | 
            | 
           2616 | 
           				foundGame = i;
  | 
        
        
            | 
            | 
           2617 | 
           				break;
  | 
        
        
            | 
            | 
           2618 | 
           			}
  | 
        
        
            | 
            | 
           2619 | 
           		}
  | 
        
        
            | 
            | 
           2620 | 
              | 
        
        
            | 
            | 
           2621 | 
           		if (foundGame)
  | 
        
        
            | 
            | 
           2622 | 
           		{
  | 
        
        
           | 197 | 
           cycrow | 
           2623 | 
           			Utils::WString str = gameAddons.findString(Utils::String::Number(foundGame));
  | 
        
        
           | 127 | 
           cycrow | 
           2624 | 
           			if(!str.empty())
  | 
        
        
           | 197 | 
           cycrow | 
           2625 | 
           				name += str + L"/";
  | 
        
        
           | 127 | 
           cycrow | 
           2626 | 
           		}
  | 
        
        
            | 
            | 
           2627 | 
              | 
        
        
           | 6 | 
           cycrow | 
           2628 | 
           		bool done = false;
  | 
        
        
            | 
            | 
           2629 | 
           		if ( wildcard )
  | 
        
        
            | 
            | 
           2630 | 
           		{
  | 
        
        
           | 197 | 
           cycrow | 
           2631 | 
           			Utils::WString base = f->Data()->baseName();
  | 
        
        
           | 131 | 
           cycrow | 
           2632 | 
           			if ( f->Data()->fileType() == FILETYPE_SCRIPT )
  | 
        
        
           | 6 | 
           cycrow | 
           2633 | 
           			{
  | 
        
        
           | 197 | 
           cycrow | 
           2634 | 
           				if ( base.token(L".", 1).Compare(L"plugin") || base.token(L".", 1).Compare(L"lib") )
  | 
        
        
           | 6 | 
           cycrow | 
           2635 | 
           				{
  | 
        
        
           | 197 | 
           cycrow | 
           2636 | 
           					name += f->Data()->getDirectory(this) + "/" + base.tokens(L".", 1, 2) + L".*";
  | 
        
        
           | 6 | 
           cycrow | 
           2637 | 
           					done = true;
  | 
        
        
            | 
            | 
           2638 | 
           				}
  | 
        
        
           | 197 | 
           cycrow | 
           2639 | 
           				else if ( base.token(L".", 1).Compare(L"al") && !base.token(L".", 2).Compare(L"plugin") )
  | 
        
        
           | 6 | 
           cycrow | 
           2640 | 
           				{
  | 
        
        
           | 197 | 
           cycrow | 
           2641 | 
           					name += f->Data()->getDirectory(this) + L"/" + base.tokens(L".", 1, 2) + L".*";
  | 
        
        
           | 6 | 
           cycrow | 
           2642 | 
           					done = true;
  | 
        
        
            | 
            | 
           2643 | 
           				}
  | 
        
        
            | 
            | 
           2644 | 
           			}
  | 
        
        
           | 131 | 
           cycrow | 
           2645 | 
           			else if ( f->Data()->fileType() == FILETYPE_TEXT )
  | 
        
        
           | 6 | 
           cycrow | 
           2646 | 
           			{
  | 
        
        
           | 197 | 
           cycrow | 
           2647 | 
           				if ( base.contains(L"-L") )
  | 
        
        
           | 6 | 
           cycrow | 
           2648 | 
           				{
  | 
        
        
           | 197 | 
           cycrow | 
           2649 | 
           					name += f->Data()->getDirectory(this) + L"/" + base.token(L"-L", 1) + L"-L*";
  | 
        
        
           | 6 | 
           cycrow | 
           2650 | 
           					done = true;
  | 
        
        
            | 
            | 
           2651 | 
           				}
  | 
        
        
            | 
            | 
           2652 | 
           				else
  | 
        
        
            | 
            | 
           2653 | 
           				{
  | 
        
        
           | 197 | 
           cycrow | 
           2654 | 
           					name += f->Data()->getDirectory(this) + L"/*" + base.right(4) + L".*";
  | 
        
        
           | 6 | 
           cycrow | 
           2655 | 
           					done = true;
  | 
        
        
            | 
            | 
           2656 | 
           				}
  | 
        
        
            | 
            | 
           2657 | 
           			}
  | 
        
        
            | 
            | 
           2658 | 
           		}
  | 
        
        
            | 
            | 
           2659 | 
              | 
        
        
            | 
            | 
           2660 | 
           		if ( !done )
  | 
        
        
           | 131 | 
           cycrow | 
           2661 | 
           			name += f->Data()->getNameDirectory(this);
  | 
        
        
           | 6 | 
           cycrow | 
           2662 | 
              | 
        
        
           | 131 | 
           cycrow | 
           2663 | 
           		if ( !f->Data()->dir().empty() )
  | 
        
        
           | 6 | 
           cycrow | 
           2664 | 
           		{
  | 
        
        
           | 197 | 
           cycrow | 
           2665 | 
           			name += L"|";
  | 
        
        
           | 131 | 
           cycrow | 
           2666 | 
           			name += f->Data()->dir();
  | 
        
        
           | 6 | 
           cycrow | 
           2667 | 
           		}
  | 
        
        
           | 197 | 
           cycrow | 
           2668 | 
           		Utils::WString s = L"GAME ";
  | 
        
        
           | 127 | 
           cycrow | 
           2669 | 
           		if (!f->Data()->game() || f->Data()->game() == GAME_ALLNEW)
  | 
        
        
            | 
            | 
           2670 | 
           			s += CBaseFile::ConvertGameToString(f->Data()->game());
  | 
        
        
            | 
            | 
           2671 | 
           		else
  | 
        
        
            | 
            | 
           2672 | 
           		{
  | 
        
        
            | 
            | 
           2673 | 
           			bool first = true;
  | 
        
        
            | 
            | 
           2674 | 
           			for (int i = 0; i < 31; ++i) 
  | 
        
        
            | 
            | 
           2675 | 
           			{
  | 
        
        
            | 
            | 
           2676 | 
           				if (f->Data()->game() & 1 << i)
  | 
        
        
            | 
            | 
           2677 | 
           				{
  | 
        
        
            | 
            | 
           2678 | 
           					if (first)
  | 
        
        
            | 
            | 
           2679 | 
           						first = false;
  | 
        
        
            | 
            | 
           2680 | 
           					else
  | 
        
        
            | 
            | 
           2681 | 
           						s += "|";
  | 
        
        
            | 
            | 
           2682 | 
           					s += CBaseFile::ConvertGameToString(i);
  | 
        
        
            | 
            | 
           2683 | 
           				}
  | 
        
        
            | 
            | 
           2684 | 
           			}
  | 
        
        
            | 
            | 
           2685 | 
           		}
  | 
        
        
            | 
            | 
           2686 | 
              | 
        
        
           | 197 | 
           cycrow | 
           2687 | 
           		s += L" " + name;
  | 
        
        
           | 126 | 
           cycrow | 
           2688 | 
           		if(!files.contains(s))
  | 
        
        
           | 178 | 
           cycrow | 
           2689 | 
           			files.pushBack(s, f->Data()->fileTypeString());
  | 
        
        
           | 6 | 
           cycrow | 
           2690 | 
           	}
  | 
        
        
            | 
            | 
           2691 | 
              | 
        
        
            | 
            | 
           2692 | 
              | 
        
        
           | 126 | 
           cycrow | 
           2693 | 
           	if ( !files.empty() )
  | 
        
        
           | 6 | 
           cycrow | 
           2694 | 
           	{
  | 
        
        
           | 126 | 
           cycrow | 
           2695 | 
           		list->pushBack("# Files List, all the files to add, can include wild cards");
  | 
        
        
            | 
            | 
           2696 | 
           		for(auto itr = files.begin(); itr != files.end(); itr++)
  | 
        
        
           | 197 | 
           cycrow | 
           2697 | 
           			list->pushBack((*itr)->data.toString() + ": " + (*itr)->str.toString());
  | 
        
        
           | 126 | 
           cycrow | 
           2698 | 
           		list->pushBack("");
  | 
        
        
           | 6 | 
           cycrow | 
           2699 | 
           	}
  | 
        
        
            | 
            | 
           2700 | 
              | 
        
        
            | 
            | 
           2701 | 
           	return true;
  | 
        
        
            | 
            | 
           2702 | 
           }
  | 
        
        
            | 
            | 
           2703 | 
              | 
        
        
           | 203 | 
           cycrow | 
           2704 | 
           Utils::WString CBaseFile::getAutosaveName() const
  | 
        
        
           | 6 | 
           cycrow | 
           2705 | 
           {
  | 
        
        
           | 204 | 
           cycrow | 
           2706 | 
           	return this->name() + L"-V" + this->version() + L"-" + this->creationDate().findReplace("/", ".");
  | 
        
        
           | 6 | 
           cycrow | 
           2707 | 
           }
  | 
        
        
            | 
            | 
           2708 | 
              | 
        
        
            | 
            | 
           2709 | 
           bool CBaseFile::CheckGameCompatability(int game)
  | 
        
        
            | 
            | 
           2710 | 
           {
  | 
        
        
            | 
            | 
           2711 | 
           	if ( m_lGames.empty() )
  | 
        
        
            | 
            | 
           2712 | 
           		return true; // no game compatability added, assume its ok for all
  | 
        
        
            | 
            | 
           2713 | 
              | 
        
        
            | 
            | 
           2714 | 
           	for ( CListNode<SGameCompat> *node = m_lGames.Front(); node; node = node->next() ) {
  | 
        
        
            | 
            | 
           2715 | 
           		if ( node->Data()->iGame == 0 || node->Data()->iGame == game )
  | 
        
        
            | 
            | 
           2716 | 
           			return true;
  | 
        
        
            | 
            | 
           2717 | 
           	}
  | 
        
        
            | 
            | 
           2718 | 
           	return false;
  | 
        
        
            | 
            | 
           2719 | 
           }
  | 
        
        
            | 
            | 
           2720 | 
              | 
        
        
           | 197 | 
           cycrow | 
           2721 | 
           bool CBaseFile::checkGameVersionCompatability(int game, const Utils::WString &sVersion, int iVersion) const
  | 
        
        
           | 6 | 
           cycrow | 
           2722 | 
           {
  | 
        
        
           | 170 | 
           cycrow | 
           2723 | 
           	if (m_lGames.empty())
  | 
        
        
           | 6 | 
           cycrow | 
           2724 | 
           		return true; // no game compatability added, assume its ok for all
  | 
        
        
            | 
            | 
           2725 | 
              | 
        
        
            | 
            | 
           2726 | 
           	bool foundAll = false;
  | 
        
        
            | 
            | 
           2727 | 
           	for ( CListNode<SGameCompat> *node = m_lGames.Front(); node; node = node->next() ) {
  | 
        
        
            | 
            | 
           2728 | 
           		if ( node->Data()->iGame == 0 )
  | 
        
        
            | 
            | 
           2729 | 
           			foundAll = true;
  | 
        
        
            | 
            | 
           2730 | 
           		else if ( node->Data()->iGame == game ) { // now check the version
  | 
        
        
           | 46 | 
           cycrow | 
           2731 | 
           			if ( node->Data()->sVersion.empty() ) {
  | 
        
        
           | 170 | 
           cycrow | 
           2732 | 
           				if (node->Data()->sVersion.compareVersion(sVersion) == COMPARE_OLDER)
  | 
        
        
           | 6 | 
           cycrow | 
           2733 | 
           					return false;
  | 
        
        
            | 
            | 
           2734 | 
           				return true;
  | 
        
        
            | 
            | 
           2735 | 
           			}
  | 
        
        
            | 
            | 
           2736 | 
           			else {
  | 
        
        
            | 
            | 
           2737 | 
           				if ( node->Data()->iVersion > iVersion )
  | 
        
        
            | 
            | 
           2738 | 
           					return false;
  | 
        
        
            | 
            | 
           2739 | 
           				return true;
  | 
        
        
            | 
            | 
           2740 | 
           			}
  | 
        
        
            | 
            | 
           2741 | 
           		}
  | 
        
        
            | 
            | 
           2742 | 
           	}
  | 
        
        
            | 
            | 
           2743 | 
           	return foundAll;
  | 
        
        
            | 
            | 
           2744 | 
           }
  | 
        
        
            | 
            | 
           2745 | 
              | 
        
        
            | 
            | 
           2746 | 
           bool CBaseFile::RemoveGameCompatability(int game)
  | 
        
        
            | 
            | 
           2747 | 
           {
  | 
        
        
            | 
            | 
           2748 | 
           	for ( CListNode<SGameCompat> *node = m_lGames.Front(); node; node = node->next() ) {
  | 
        
        
            | 
            | 
           2749 | 
           		if ( node->Data()->iGame == game ) {
  | 
        
        
            | 
            | 
           2750 | 
           			m_lGames.remove(node);
  | 
        
        
           | 50 | 
           cycrow | 
           2751 | 
           			_changed();
  | 
        
        
           | 6 | 
           cycrow | 
           2752 | 
           			return true;
  | 
        
        
            | 
            | 
           2753 | 
           		}
  | 
        
        
            | 
            | 
           2754 | 
           	}
  | 
        
        
            | 
            | 
           2755 | 
              | 
        
        
            | 
            | 
           2756 | 
           	return false;
  | 
        
        
            | 
            | 
           2757 | 
           }
  | 
        
        
            | 
            | 
           2758 | 
              | 
        
        
            | 
            | 
           2759 | 
           SGameCompat *CBaseFile::GetGameCompatability(int game)
  | 
        
        
            | 
            | 
           2760 | 
           {
  | 
        
        
            | 
            | 
           2761 | 
           	for ( CListNode<SGameCompat> *node = m_lGames.Front(); node; node = node->next() ) {
  | 
        
        
            | 
            | 
           2762 | 
           		if ( node->Data()->iGame == game ) {
  | 
        
        
            | 
            | 
           2763 | 
           			return node->Data();
  | 
        
        
            | 
            | 
           2764 | 
           		}
  | 
        
        
            | 
            | 
           2765 | 
           	}
  | 
        
        
            | 
            | 
           2766 | 
              | 
        
        
            | 
            | 
           2767 | 
           	return NULL;
  | 
        
        
            | 
            | 
           2768 | 
           }
  | 
        
        
            | 
            | 
           2769 | 
              | 
        
        
           | 46 | 
           cycrow | 
           2770 | 
           void CBaseFile::AddGameCompatability(int game, const Utils::String &version)
  | 
        
        
           | 6 | 
           cycrow | 
           2771 | 
           {
  | 
        
        
            | 
            | 
           2772 | 
           	// first check if we already have it on the list
  | 
        
        
            | 
            | 
           2773 | 
           	SGameCompat *Found = this->GetGameCompatability(game);
  | 
        
        
            | 
            | 
           2774 | 
           	if ( !Found ) {
  | 
        
        
            | 
            | 
           2775 | 
           		Found = new SGameCompat;
  | 
        
        
            | 
            | 
           2776 | 
           		m_lGames.push_back(Found);
  | 
        
        
            | 
            | 
           2777 | 
           	}
  | 
        
        
            | 
            | 
           2778 | 
              | 
        
        
            | 
            | 
           2779 | 
           	Found->iGame = game;
  | 
        
        
            | 
            | 
           2780 | 
           	Found->iVersion = -1;
  | 
        
        
           | 46 | 
           cycrow | 
           2781 | 
           	Found->sVersion = "";
  | 
        
        
           | 6 | 
           cycrow | 
           2782 | 
              | 
        
        
           | 46 | 
           cycrow | 
           2783 | 
           	if ( version.isin(".") || !version.isNumber() )
  | 
        
        
           | 197 | 
           cycrow | 
           2784 | 
           		Found->sVersion = version.toWString();
  | 
        
        
           | 6 | 
           cycrow | 
           2785 | 
           	else
  | 
        
        
           | 197 | 
           cycrow | 
           2786 | 
           		Found->iVersion = version.toWString();
  | 
        
        
           | 50 | 
           cycrow | 
           2787 | 
           	_changed();
  | 
        
        
           | 6 | 
           cycrow | 
           2788 | 
           }
  | 
        
        
            | 
            | 
           2789 | 
              | 
        
        
           | 196 | 
           cycrow | 
           2790 | 
           Utils::WString CBaseFile::_replaceFilename(const Utils::WString &fname)
  | 
        
        
           | 131 | 
           cycrow | 
           2791 | 
           {
  | 
        
        
           | 196 | 
           cycrow | 
           2792 | 
           	Utils::WString filename = fname;
  | 
        
        
            | 
            | 
           2793 | 
           	Utils::WString cdate = this->creationDate().findReplace("/", ".").remove(' ');
  | 
        
        
            | 
            | 
           2794 | 
           	if (filename.contains(L"$AUTOSAVE"))
  | 
        
        
           | 131 | 
           cycrow | 
           2795 | 
           	{
  | 
        
        
            | 
            | 
           2796 | 
           		if (this->GetType() == TYPE_XSP)
  | 
        
        
           | 196 | 
           cycrow | 
           2797 | 
           			filename = filename.findReplace(L"$AUTOSAVE", L"$NAME-V$VERSION-$CDATE.xsp");
  | 
        
        
           | 131 | 
           cycrow | 
           2798 | 
           		else
  | 
        
        
           | 196 | 
           cycrow | 
           2799 | 
           			filename = filename.findReplace(L"$AUTOSAVE", L"$NAME-V$VERSION-$CDATE.spk");
  | 
        
        
           | 131 | 
           cycrow | 
           2800 | 
           	}
  | 
        
        
           | 203 | 
           cycrow | 
           2801 | 
           	filename = filename.findReplace(L"$NAME", this->name().remove(L' '));
  | 
        
        
            | 
            | 
           2802 | 
           	filename = filename.findReplace(L"$AUTHOR", this->author().remove(L' '));
  | 
        
        
           | 199 | 
           cycrow | 
           2803 | 
           	filename = filename.findReplace(L"$DATE", cdate);
  | 
        
        
            | 
            | 
           2804 | 
           	filename = filename.findReplace(L"$CDATE", cdate);
  | 
        
        
            | 
            | 
           2805 | 
           	filename = filename.findReplace(L"$VERSION", this->version());
  | 
        
        
           | 131 | 
           cycrow | 
           2806 | 
              | 
        
        
            | 
            | 
           2807 | 
           	return filename;
  | 
        
        
            | 
            | 
           2808 | 
           }
  | 
        
        
           | 197 | 
           cycrow | 
           2809 | 
           bool CBaseFile::loadPackageData(const Utils::WString &sFirst, const Utils::WString &sRest, const Utils::WString &sMainGame, Utils::WStringList &otherGames, Utils::WStringList &gameAddons, CProgressInfo *progress)
  | 
        
        
           | 6 | 
           cycrow | 
           2810 | 
           {
  | 
        
        
           | 207 | 
           cycrow | 
           2811 | 
           	if (sFirst.Compare(L"Name"))					this->setName(sRest);
  | 
        
        
            | 
            | 
           2812 | 
           	else if (sFirst.Compare(L"Author"))				this->setAuthor(sRest);
  | 
        
        
            | 
            | 
           2813 | 
           	else if (sFirst.Compare(L"ScriptName"))			addName(parseLanguage(sRest.token(L" ", 1)), sRest.tokens(L" ", 2));
  | 
        
        
            | 
            | 
           2814 | 
           	else if (sFirst.Compare(L"UninstallBefore"))	this->addUninstallText(parseLanguage(sRest.token(L" ", 1)), true, sRest.tokens(L" ", 2));
  | 
        
        
            | 
            | 
           2815 | 
           	else if (sFirst.Compare(L"UninstallAfter"))		this->addUninstallText(parseLanguage(sRest.token(L" ", 1)), false, sRest.tokens(L" ", 2));
  | 
        
        
            | 
            | 
           2816 | 
           	else if (sFirst.Compare(L"InstallBefore"))		this->addInstallText(parseLanguage(sRest.token(L" ", 1)), true, sRest.tokens(L" ", 2));
  | 
        
        
            | 
            | 
           2817 | 
           	else if (sFirst.Compare(L"InstallAfter"))		this->addInstallText(parseLanguage(sRest.token(L" ", 1)), false, sRest.tokens(L" ", 2));
  | 
        
        
           | 197 | 
           cycrow | 
           2818 | 
           	else if (sFirst.Compare(L"Date"))				this->setCreationDate(sRest.toString());
  | 
        
        
            | 
            | 
           2819 | 
           	else if (sFirst.Compare(L"Version"))			this->setVersion(sRest.toString());
  | 
        
        
            | 
            | 
           2820 | 
           	else if (sFirst.Compare(L"GameVersion"))
  | 
        
        
            | 
            | 
           2821 | 
           		this->AddGameCompatability(-1, sRest.toString());
  | 
        
        
            | 
            | 
           2822 | 
           	else if (sFirst.Compare(L"PluginType")) {
  | 
        
        
           | 134 | 
           cycrow | 
           2823 | 
           		if (sRest.isNumber())						this->setPluginType(sRest);
  | 
        
        
           | 197 | 
           cycrow | 
           2824 | 
           		else if (sRest.Compare(L"Normal"))			this->setPluginType(PLUGIN_NORMAL);
  | 
        
        
            | 
            | 
           2825 | 
           		else if (sRest.Compare(L"Stable"))			this->setPluginType(PLUGIN_STABLE);
  | 
        
        
            | 
            | 
           2826 | 
           		else if (sRest.Compare(L"Experimental"))	this->setPluginType(PLUGIN_EXPERIMENTAL);
  | 
        
        
            | 
            | 
           2827 | 
           		else if (sRest.Compare(L"Cheat"))			this->setPluginType(PLUGIN_CHEAT);
  | 
        
        
            | 
            | 
           2828 | 
           		else if (sRest.Compare(L"Mod"))				this->setPluginType(PLUGIN_MOD);
  | 
        
        
           | 6 | 
           cycrow | 
           2829 | 
           	}
  | 
        
        
            | 
            | 
           2830 | 
           	// new version
  | 
        
        
           | 197 | 
           cycrow | 
           2831 | 
           	else if (sFirst.Compare(L"GenerateUpdateFile"))
  | 
        
        
           | 6 | 
           cycrow | 
           2832 | 
           		m_bAutoGenerateUpdateFile = true;
  | 
        
        
           | 197 | 
           cycrow | 
           2833 | 
           	else if (sFirst.Compare(L"Game"))
  | 
        
        
           | 6 | 
           cycrow | 
           2834 | 
           	{
  | 
        
        
           | 197 | 
           cycrow | 
           2835 | 
           		Utils::WString sGame = sRest.token(L" ", 1);
  | 
        
        
            | 
            | 
           2836 | 
           		this->AddGameCompatability(CBaseFile::GetGameFromString(sGame.toString()), sRest.token(L" ", 2).toString());
  | 
        
        
           | 6 | 
           cycrow | 
           2837 | 
           	}
  | 
        
        
           | 197 | 
           cycrow | 
           2838 | 
           	else if (sFirst.Compare(L"Description"))		this->setDescription(sRest.toString());
  | 
        
        
            | 
            | 
           2839 | 
           	else if (sFirst.Compare(L"AutoSave") || sFirst.Compare(L"AutoExport") || sFirst.Compare(L"AutoRarExport") || sFirst.Compare(L"AutoZipExport"))
  | 
        
        
           | 6 | 
           cycrow | 
           2840 | 
           	{
  | 
        
        
           | 196 | 
           cycrow | 
           2841 | 
           		Utils::WString filename = _replaceFilename(sRest);
  | 
        
        
           | 6 | 
           cycrow | 
           2842 | 
              | 
        
        
           | 197 | 
           cycrow | 
           2843 | 
           		if (sFirst.Compare(L"AutoZipExport") || sFirst.Compare(L"AutoExport"))
  | 
        
        
           | 196 | 
           cycrow | 
           2844 | 
           			this->setExportFilename(CFileIO(filename).changeFileExtension(L"zip").toString());
  | 
        
        
           | 197 | 
           cycrow | 
           2845 | 
           		else if (sFirst.Compare(L"AutoRarExport"))
  | 
        
        
           | 196 | 
           cycrow | 
           2846 | 
           			this->setExportFilename(CFileIO(filename).changeFileExtension(L"rar").toString());
  | 
        
        
           | 6 | 
           cycrow | 
           2847 | 
           		else
  | 
        
        
           | 197 | 
           cycrow | 
           2848 | 
           			this->setFilename(filename);
  | 
        
        
           | 6 | 
           cycrow | 
           2849 | 
           	}
  | 
        
        
           | 197 | 
           cycrow | 
           2850 | 
           	else if (sFirst.Compare(L"WebSite"))		this->setWebSite(sRest.toString());
  | 
        
        
            | 
            | 
           2851 | 
           	else if (sFirst.Compare(L"ForumLink") || sFirst.Compare("Forum")) this->setForumLink(sRest.toString());
  | 
        
        
            | 
            | 
           2852 | 
           	else if (sFirst.Compare(L"Email"))			this->setEmail(sRest.toString());
  | 
        
        
            | 
            | 
           2853 | 
           	else if (sFirst.Compare(L"WebAddress"))		this->setWebAddress(sRest.toString());
  | 
        
        
            | 
            | 
           2854 | 
           	else if (sFirst.Compare(L"WebMirror"))
  | 
        
        
            | 
            | 
           2855 | 
           		this->addWebMirror(sRest.toString());
  | 
        
        
            | 
            | 
           2856 | 
           	else if (sFirst.Compare(L"WebMirror1"))
  | 
        
        
            | 
            | 
           2857 | 
           		this->addWebMirror(sRest.toString());
  | 
        
        
            | 
            | 
           2858 | 
           	else if (sFirst.Compare(L"WebMirror2"))
  | 
        
        
            | 
            | 
           2859 | 
           		this->addWebMirror(sRest.toString());
  | 
        
        
            | 
            | 
           2860 | 
           	else if (sFirst.Compare(L"Ftp"))
  | 
        
        
            | 
            | 
           2861 | 
           		_sFtpAddr = sRest.toString();
  | 
        
        
            | 
            | 
           2862 | 
           	else if (sFirst.Compare(L"Ratings"))		_setRatings(sRest.token(L" ", 1), sRest.token(L" ", 2), sRest.token(L" ", 3));
  | 
        
        
            | 
            | 
           2863 | 
           	else if (sFirst.Compare(L"EaseOfUse"))		setEaseOfUse(sRest);
  | 
        
        
            | 
            | 
           2864 | 
           	else if (sFirst.Compare(L"GameChanging"))	setGameChanging(sRest);
  | 
        
        
            | 
            | 
           2865 | 
           	else if (sFirst.Compare(L"Recommended"))	setRecommended(sRest);
  | 
        
        
            | 
            | 
           2866 | 
           	else if (sFirst.Compare(L"Depend"))
  | 
        
        
           | 6 | 
           cycrow | 
           2867 | 
           	{
  | 
        
        
           | 197 | 
           cycrow | 
           2868 | 
           		Utils::WString version = sRest.token(L"|", 2);
  | 
        
        
            | 
            | 
           2869 | 
           		Utils::WString name = sRest.token(L"|", 1);
  | 
        
        
            | 
            | 
           2870 | 
           		Utils::WString author = sRest.tokens(L"|", 3);
  | 
        
        
           | 6 | 
           cycrow | 
           2871 | 
              | 
        
        
           | 203 | 
           cycrow | 
           2872 | 
           		this->addNeededLibrary(name, author, version.toString());
  | 
        
        
           | 6 | 
           cycrow | 
           2873 | 
           	}
  | 
        
        
           | 197 | 
           cycrow | 
           2874 | 
           	else if (sFirst.Compare(L"DependPackage"))
  | 
        
        
           | 6 | 
           cycrow | 
           2875 | 
           	{
  | 
        
        
            | 
            | 
           2876 | 
           		CPackages p;
  | 
        
        
           | 182 | 
           cycrow | 
           2877 | 
           		CBaseFile *spk = p.openPackage(sRest, 0, 0, SPKREAD_VALUES);
  | 
        
        
           | 134 | 
           cycrow | 
           2878 | 
           		if (spk)
  | 
        
        
           | 6 | 
           cycrow | 
           2879 | 
           		{
  | 
        
        
           | 203 | 
           cycrow | 
           2880 | 
           			this->addNeededLibrary(spk->name(), spk->author(), spk->version());
  | 
        
        
           | 6 | 
           cycrow | 
           2881 | 
           			delete spk;
  | 
        
        
            | 
            | 
           2882 | 
           		}
  | 
        
        
            | 
            | 
           2883 | 
           	}
  | 
        
        
           | 197 | 
           cycrow | 
           2884 | 
           	else if (sFirst.Compare(L"Icon"))
  | 
        
        
           | 6 | 
           cycrow | 
           2885 | 
           	{
  | 
        
        
           | 197 | 
           cycrow | 
           2886 | 
           		C_File *icon = new C_File(sRest);
  | 
        
        
           | 134 | 
           cycrow | 
           2887 | 
           		if (icon->ReadFromFile())
  | 
        
        
           | 196 | 
           cycrow | 
           2888 | 
           			this->setIcon(icon, CFileIO(sRest).extension().toString());
  | 
        
        
           | 6 | 
           cycrow | 
           2889 | 
           	}
  | 
        
        
           | 197 | 
           cycrow | 
           2890 | 
           	else if (sFirst.Compare(L"CombineGameFiles"))
  | 
        
        
            | 
            | 
           2891 | 
           		_bCombineFiles = sRest.Compare(L"true") || sRest.Compare(L"yes") || sRest.toInt();
  | 
        
        
            | 
            | 
           2892 | 
           	else if (sFirst.Compare(L"UpdateFile"))
  | 
        
        
           | 134 | 
           cycrow | 
           2893 | 
           		this->createUpdateFile(sRest);
  | 
        
        
           | 197 | 
           cycrow | 
           2894 | 
           	else if (sFirst.Compare(L"ExportZip"))
  | 
        
        
           | 131 | 
           cycrow | 
           2895 | 
           	{
  | 
        
        
           | 196 | 
           cycrow | 
           2896 | 
           		Utils::WString ext = L"zip";
  | 
        
        
           | 197 | 
           cycrow | 
           2897 | 
           		Utils::WString game = sRest.word(1);
  | 
        
        
           | 196 | 
           cycrow | 
           2898 | 
           		Utils::WString file = _replaceFilename(CFileIO(sRest.words(2)).fullFilename());
  | 
        
        
           | 197 | 
           cycrow | 
           2899 | 
           		if (game.contains(L"|"))
  | 
        
        
           | 131 | 
           cycrow | 
           2900 | 
           		{
  | 
        
        
           | 197 | 
           cycrow | 
           2901 | 
           			std::vector<Utils::WString> games;
  | 
        
        
            | 
            | 
           2902 | 
           			if(game.tokenise(L"|", games))
  | 
        
        
           | 131 | 
           cycrow | 
           2903 | 
           			{
  | 
        
        
           | 197 | 
           cycrow | 
           2904 | 
           				for (size_t i = 0; i < games.size(); ++i)
  | 
        
        
           | 131 | 
           cycrow | 
           2905 | 
           				{
  | 
        
        
           | 197 | 
           cycrow | 
           2906 | 
           					unsigned int g = CBaseFile::GetGameFromString(games[i].toString());
  | 
        
        
            | 
            | 
           2907 | 
           					Utils::WString filename = CFileIO(file).dir() + L"/" + CFileIO(file).baseName() + L"_" + CBaseFile::ConvertGameToString(g) + L"." + ext;
  | 
        
        
           | 196 | 
           cycrow | 
           2908 | 
           					this->addAutoExport(g, filename.toString());
  | 
        
        
           | 131 | 
           cycrow | 
           2909 | 
           				}
  | 
        
        
            | 
            | 
           2910 | 
           			}
  | 
        
        
            | 
            | 
           2911 | 
           		}
  | 
        
        
            | 
            | 
           2912 | 
           		else
  | 
        
        
            | 
            | 
           2913 | 
           		{
  | 
        
        
           | 197 | 
           cycrow | 
           2914 | 
           			unsigned int g = CBaseFile::GetGameFromString(game.toString());
  | 
        
        
            | 
            | 
           2915 | 
           			Utils::WString filename = CFileIO(file).dir() + L"/" + CFileIO(file).baseName() + L"_" + CBaseFile::ConvertGameToString(g) + L"." + ext;
  | 
        
        
           | 196 | 
           cycrow | 
           2916 | 
           			this->addAutoExport(g, filename.toString());
  | 
        
        
           | 131 | 
           cycrow | 
           2917 | 
           		}
  | 
        
        
            | 
            | 
           2918 | 
           	}
  | 
        
        
           | 197 | 
           cycrow | 
           2919 | 
           	else if (sFirst.Compare(L"Extract"))
  | 
        
        
           | 131 | 
           cycrow | 
           2920 | 
           	{
  | 
        
        
           | 197 | 
           cycrow | 
           2921 | 
           		Utils::WString game = sRest.word(1);
  | 
        
        
           | 196 | 
           cycrow | 
           2922 | 
           		Utils::WString dir = CDirIO(sRest.words(2)).dir();
  | 
        
        
           | 197 | 
           cycrow | 
           2923 | 
           		if (game.contains(L"|"))
  | 
        
        
           | 131 | 
           cycrow | 
           2924 | 
           		{
  | 
        
        
           | 197 | 
           cycrow | 
           2925 | 
           			std::vector<Utils::WString> games;
  | 
        
        
            | 
            | 
           2926 | 
           			if (game.tokenise(L"|", games))
  | 
        
        
           | 131 | 
           cycrow | 
           2927 | 
           			{
  | 
        
        
           | 197 | 
           cycrow | 
           2928 | 
           				for(size_t i = 0; i < games.size(); ++i)
  | 
        
        
            | 
            | 
           2929 | 
           					this->addAutoExtract(CBaseFile::GetGameFromString(games[i].toString()), dir.toString());
  | 
        
        
           | 131 | 
           cycrow | 
           2930 | 
           			}
  | 
        
        
            | 
            | 
           2931 | 
           		}
  | 
        
        
            | 
            | 
           2932 | 
           		else
  | 
        
        
           | 197 | 
           cycrow | 
           2933 | 
           			this->addAutoExtract(CBaseFile::GetGameFromString(game.toString()), dir.toString());
  | 
        
        
           | 131 | 
           cycrow | 
           2934 | 
           	}
  | 
        
        
           | 6 | 
           cycrow | 
           2935 | 
           	else
  | 
        
        
            | 
            | 
           2936 | 
           	{
  | 
        
        
           | 197 | 
           cycrow | 
           2937 | 
           		Utils::WString checkType = sFirst;
  | 
        
        
           | 6 | 
           cycrow | 
           2938 | 
           		bool shared = false;
  | 
        
        
           | 197 | 
           cycrow | 
           2939 | 
           		if (checkType.left(6).Compare(L"Shared"))
  | 
        
        
           | 6 | 
           cycrow | 
           2940 | 
           		{
  | 
        
        
           | 14 | 
           cycrow | 
           2941 | 
           			checkType = sFirst.right(-6);
  | 
        
        
           | 6 | 
           cycrow | 
           2942 | 
           			shared = true;
  | 
        
        
            | 
            | 
           2943 | 
           		}
  | 
        
        
           | 155 | 
           cycrow | 
           2944 | 
           		bool packed = false;
  | 
        
        
           | 197 | 
           cycrow | 
           2945 | 
           		if (checkType.right(3).Compare(L"PCK"))
  | 
        
        
           | 155 | 
           cycrow | 
           2946 | 
           		{
  | 
        
        
            | 
            | 
           2947 | 
           			checkType = sFirst.left(-3);
  | 
        
        
            | 
            | 
           2948 | 
           			packed = true;
  | 
        
        
            | 
            | 
           2949 | 
           		}
  | 
        
        
           | 6 | 
           cycrow | 
           2950 | 
              | 
        
        
            | 
            | 
           2951 | 
           		// now check type name
  | 
        
        
           | 127 | 
           cycrow | 
           2952 | 
           		FileType filetype = GetFileTypeFromString(checkType);
  | 
        
        
            | 
            | 
           2953 | 
           		if (filetype != FILETYPE_UNKNOWN)
  | 
        
        
           | 197 | 
           cycrow | 
           2954 | 
           			this->addFileScript(filetype, shared, packed, sRest, sMainGame, otherGames, gameAddons, progress);
  | 
        
        
           | 6 | 
           cycrow | 
           2955 | 
           		else if ( !checkType.Compare("changelog") )
  | 
        
        
            | 
            | 
           2956 | 
           			return false;
  | 
        
        
            | 
            | 
           2957 | 
           	}
  | 
        
        
            | 
            | 
           2958 | 
              | 
        
        
            | 
            | 
           2959 | 
           	return true;
  | 
        
        
            | 
            | 
           2960 | 
           }
  | 
        
        
            | 
            | 
           2961 | 
              | 
        
        
           | 197 | 
           cycrow | 
           2962 | 
           void CBaseFile::addFileScript(FileType filetype, bool shared, bool packed, const Utils::WString &sRest, const Utils::WString &sMainGame, Utils::WStringList &otherGames, Utils::WStringList &gameAddons, CProgressInfo *progress)
  | 
        
        
           | 6 | 
           cycrow | 
           2963 | 
           {
  | 
        
        
           | 197 | 
           cycrow | 
           2964 | 
           	Utils::WString dir;
  | 
        
        
            | 
            | 
           2965 | 
           	Utils::WString rest = sRest;
  | 
        
        
           | 127 | 
           cycrow | 
           2966 | 
              | 
        
        
           | 197 | 
           cycrow | 
           2967 | 
           	unsigned int mainGame = CBaseFile::GetGameFromString(sMainGame.toString());
  | 
        
        
           | 127 | 
           cycrow | 
           2968 | 
           	unsigned int game = 0;
  | 
        
        
           | 197 | 
           cycrow | 
           2969 | 
           	if ( rest.token(L" ", 1).left(4).Compare(L"GAME") ) {
  | 
        
        
            | 
            | 
           2970 | 
           		Utils::WString gameStr = rest.token(L" ", 2);
  | 
        
        
            | 
            | 
           2971 | 
           		if (gameStr.contains(L"|"))
  | 
        
        
           | 127 | 
           cycrow | 
           2972 | 
           		{
  | 
        
        
           | 197 | 
           cycrow | 
           2973 | 
           			std::vector<Utils::WString> games;
  | 
        
        
            | 
            | 
           2974 | 
           			gameStr.tokenise(L"|", games);
  | 
        
        
            | 
            | 
           2975 | 
           			for (size_t i = 0; i < games.size(); ++i)
  | 
        
        
           | 127 | 
           cycrow | 
           2976 | 
           			{
  | 
        
        
           | 197 | 
           cycrow | 
           2977 | 
           				unsigned int g = CBaseFile::GetGameFromString(games[i].toString());
  | 
        
        
           | 127 | 
           cycrow | 
           2978 | 
           				if (g)
  | 
        
        
            | 
            | 
           2979 | 
           					game |= 1 << g;
  | 
        
        
            | 
            | 
           2980 | 
           			}
  | 
        
        
            | 
            | 
           2981 | 
           		}
  | 
        
        
            | 
            | 
           2982 | 
           		else
  | 
        
        
           | 131 | 
           cycrow | 
           2983 | 
           		{
  | 
        
        
           | 197 | 
           cycrow | 
           2984 | 
           			unsigned int g = CBaseFile::GetGameFromString(gameStr.toString());
  | 
        
        
           | 131 | 
           cycrow | 
           2985 | 
           			if (g)
  | 
        
        
            | 
            | 
           2986 | 
           				game = 1 << g;
  | 
        
        
            | 
            | 
           2987 | 
           		}
  | 
        
        
           | 197 | 
           cycrow | 
           2988 | 
           		rest = rest.tokens(L" ", 3);
  | 
        
        
           | 6 | 
           cycrow | 
           2989 | 
           	}
  | 
        
        
           | 127 | 
           cycrow | 
           2990 | 
           	if (game)
  | 
        
        
            | 
            | 
           2991 | 
           		game |= 1 << 31;
  | 
        
        
           | 6 | 
           cycrow | 
           2992 | 
              | 
        
        
           | 197 | 
           cycrow | 
           2993 | 
           	if (rest.contains(L"|"))
  | 
        
        
           | 127 | 
           cycrow | 
           2994 | 
           	{
  | 
        
        
           | 197 | 
           cycrow | 
           2995 | 
           		dir = rest.tokens(L"|", 2);
  | 
        
        
            | 
            | 
           2996 | 
           		rest = rest.token(L"|", 1);
  | 
        
        
           | 6 | 
           cycrow | 
           2997 | 
           	}
  | 
        
        
            | 
            | 
           2998 | 
              | 
        
        
           | 197 | 
           cycrow | 
           2999 | 
           	rest = rest.findReplace(L"\\", L"/");
  | 
        
        
           | 6 | 
           cycrow | 
           3000 | 
              | 
        
        
            | 
            | 
           3001 | 
           	// wild cards
  | 
        
        
           | 197 | 
           cycrow | 
           3002 | 
           	if ( rest.containsAny(L"*?") )
  | 
        
        
           | 6 | 
           cycrow | 
           3003 | 
           	{
  | 
        
        
           | 102 | 
           cycrow | 
           3004 | 
           		CDirIO Dir(CFileIO(rest).dir());
  | 
        
        
           | 197 | 
           cycrow | 
           3005 | 
           		Utils::WStringList dirList;
  | 
        
        
           | 160 | 
           cycrow | 
           3006 | 
           		if(Dir.dirList(dirList))
  | 
        
        
           | 6 | 
           cycrow | 
           3007 | 
           		{
  | 
        
        
           | 160 | 
           cycrow | 
           3008 | 
           			for(auto itr = dirList.begin(); itr != dirList.end(); itr++)
  | 
        
        
           | 6 | 
           cycrow | 
           3009 | 
           			{
  | 
        
        
           | 196 | 
           cycrow | 
           3010 | 
           				Utils::WString file = Dir.file((*itr)->str);
  | 
        
        
           | 127 | 
           cycrow | 
           3011 | 
           				if (file.match(rest))
  | 
        
        
           | 6 | 
           cycrow | 
           3012 | 
           				{
  | 
        
        
           | 98 | 
           cycrow | 
           3013 | 
           					int addGame = game;
  | 
        
        
            | 
            | 
           3014 | 
           					// check if the file exists in the subdirectory too, if it does, add for each game
  | 
        
        
            | 
            | 
           3015 | 
           					if ( game == GAME_ALL && !sMainGame.empty() && !otherGames.empty() ) {
  | 
        
        
            | 
            | 
           3016 | 
           						CFileIO F(file);
  | 
        
        
           | 197 | 
           cycrow | 
           3017 | 
           						for(Utils::WString g = otherGames.firstString(); !g.empty(); g = otherGames.nextString()) {
  | 
        
        
            | 
            | 
           3018 | 
           							Utils::WString checkDir = F.dir() + L"/" + g;
  | 
        
        
           | 121 | 
           cycrow | 
           3019 | 
           							if ( CDirIO(checkDir).exists(F.filename()) ) {
  | 
        
        
           | 98 | 
           cycrow | 
           3020 | 
           								addGame = mainGame;
  | 
        
        
           | 197 | 
           cycrow | 
           3021 | 
           								C_File *newfile = this->appendFile(CDirIO(checkDir).file(F.filename()), filetype, CBaseFile::GetGameFromString(g.toString()), packed, dir);
  | 
        
        
           | 134 | 
           cycrow | 
           3022 | 
           								if (newfile && progress)
  | 
        
        
            | 
            | 
           3023 | 
           									progress->UpdateFile(newfile);
  | 
        
        
           | 98 | 
           cycrow | 
           3024 | 
           								if ( newfile ) newfile->SetShared(shared);
  | 
        
        
            | 
            | 
           3025 | 
           							}
  | 
        
        
            | 
            | 
           3026 | 
           						}
  | 
        
        
            | 
            | 
           3027 | 
           					}
  | 
        
        
            | 
            | 
           3028 | 
              | 
        
        
           | 197 | 
           cycrow | 
           3029 | 
           					C_File *newfile = this->appendFile(file, filetype, addGame, packed, dir);
  | 
        
        
           | 134 | 
           cycrow | 
           3030 | 
           					if (newfile && progress)
  | 
        
        
            | 
            | 
           3031 | 
           						progress->UpdateFile(newfile);
  | 
        
        
           | 6 | 
           cycrow | 
           3032 | 
           					if ( newfile )
  | 
        
        
            | 
            | 
           3033 | 
           						newfile->SetShared(shared);
  | 
        
        
            | 
            | 
           3034 | 
           				}
  | 
        
        
            | 
            | 
           3035 | 
           			}
  | 
        
        
            | 
            | 
           3036 | 
           		}
  | 
        
        
            | 
            | 
           3037 | 
           	}
  | 
        
        
            | 
            | 
           3038 | 
           	else
  | 
        
        
            | 
            | 
           3039 | 
           	{
  | 
        
        
           | 127 | 
           cycrow | 
           3040 | 
           		unsigned int addGame = game;
  | 
        
        
           | 98 | 
           cycrow | 
           3041 | 
           		// check if the file exists in the subdirectory too, if it does, add for each game
  | 
        
        
            | 
            | 
           3042 | 
           		if ( game == GAME_ALL && !sMainGame.empty() && !otherGames.empty() ) {
  | 
        
        
            | 
            | 
           3043 | 
           			CFileIO F(rest);
  | 
        
        
           | 197 | 
           cycrow | 
           3044 | 
           			for(Utils::WString g = otherGames.firstString(); !g.empty(); g = otherGames.nextString()) {
  | 
        
        
            | 
            | 
           3045 | 
           				Utils::WString checkDir = F.dir() + L"/" + g;
  | 
        
        
           | 121 | 
           cycrow | 
           3046 | 
           				if ( CDirIO(checkDir).exists(F.filename()) ) {
  | 
        
        
           | 98 | 
           cycrow | 
           3047 | 
           					addGame = mainGame;
  | 
        
        
           | 197 | 
           cycrow | 
           3048 | 
           					C_File *newfile = this->appendFile(CDirIO(checkDir).file(F.filename()), filetype, CBaseFile::GetGameFromString(g.toString()), packed, dir);
  | 
        
        
           | 134 | 
           cycrow | 
           3049 | 
           					if (newfile && progress)
  | 
        
        
            | 
            | 
           3050 | 
           						progress->UpdateFile(newfile);
  | 
        
        
           | 98 | 
           cycrow | 
           3051 | 
           					if ( newfile ) newfile->SetShared(shared);
  | 
        
        
            | 
            | 
           3052 | 
           				}
  | 
        
        
            | 
            | 
           3053 | 
           			}
  | 
        
        
            | 
            | 
           3054 | 
           		}
  | 
        
        
            | 
            | 
           3055 | 
              | 
        
        
           | 127 | 
           cycrow | 
           3056 | 
           		unsigned int checkGame = addGame & ~(1 << 31);
  | 
        
        
            | 
            | 
           3057 | 
           		unsigned int foundGame = 0;
  | 
        
        
            | 
            | 
           3058 | 
           		for (int i = 0; i < 31; ++i)
  | 
        
        
            | 
            | 
           3059 | 
           		{
  | 
        
        
            | 
            | 
           3060 | 
           			if (1 << i == checkGame)
  | 
        
        
            | 
            | 
           3061 | 
           			{
  | 
        
        
            | 
            | 
           3062 | 
           				foundGame = i;
  | 
        
        
            | 
            | 
           3063 | 
           				break;
  | 
        
        
            | 
            | 
           3064 | 
           			}
  | 
        
        
            | 
            | 
           3065 | 
           		}
  | 
        
        
            | 
            | 
           3066 | 
              | 
        
        
            | 
            | 
           3067 | 
           		C_File *file = NULL;
  | 
        
        
            | 
            | 
           3068 | 
           		if (foundGame)
  | 
        
        
            | 
            | 
           3069 | 
           		{
  | 
        
        
           | 197 | 
           cycrow | 
           3070 | 
           			Utils::WString addon = gameAddons.findString(Utils::WString::Number(foundGame));
  | 
        
        
           | 127 | 
           cycrow | 
           3071 | 
           			if (!addon.empty())
  | 
        
        
            | 
            | 
           3072 | 
           			{
  | 
        
        
           | 197 | 
           cycrow | 
           3073 | 
           				Utils::WString dir = C_File::GetDirectory(filetype, rest, this);
  | 
        
        
            | 
            | 
           3074 | 
           				Utils::WString filename = rest;
  | 
        
        
           | 130 | 
           cycrow | 
           3075 | 
           				if (CCatFile::IsAddonDir(dir) && !filename.contains(addon))
  | 
        
        
            | 
            | 
           3076 | 
           				{
  | 
        
        
           | 197 | 
           cycrow | 
           3077 | 
           					filename = filename.findReplace(dir + L"/", addon + L"/" + dir + L"/");
  | 
        
        
           | 155 | 
           cycrow | 
           3078 | 
           					file = this->appendFile(filename, filetype, addGame, packed, dir);
  | 
        
        
           | 130 | 
           cycrow | 
           3079 | 
           				}
  | 
        
        
           | 127 | 
           cycrow | 
           3080 | 
           			}
  | 
        
        
            | 
            | 
           3081 | 
           		}
  | 
        
        
            | 
            | 
           3082 | 
              | 
        
        
            | 
            | 
           3083 | 
           		if(!file)
  | 
        
        
           | 155 | 
           cycrow | 
           3084 | 
           			file = this->appendFile(rest, filetype, addGame, packed, dir);
  | 
        
        
           | 127 | 
           cycrow | 
           3085 | 
              | 
        
        
           | 134 | 
           cycrow | 
           3086 | 
           		if (file && progress)
  | 
        
        
            | 
            | 
           3087 | 
           			progress->UpdateFile(file);
  | 
        
        
           | 127 | 
           cycrow | 
           3088 | 
           		if (file)
  | 
        
        
           | 6 | 
           cycrow | 
           3089 | 
           			file->SetShared(shared);
  | 
        
        
            | 
            | 
           3090 | 
           	}
  | 
        
        
            | 
            | 
           3091 | 
           }
  | 
        
        
            | 
            | 
           3092 | 
              | 
        
        
            | 
            | 
           3093 | 
              | 
        
        
           | 197 | 
           cycrow | 
           3094 | 
           Utils::WString CBaseFile::fileSizeString() const { return SPK::GetSizeString ( this->fileSize() ); }
  | 
        
        
           | 6 | 
           cycrow | 
           3095 | 
              | 
        
        
           | 52 | 
           cycrow | 
           3096 | 
           // used for a multiple spk file
  | 
        
        
           | 197 | 
           cycrow | 
           3097 | 
           unsigned char *CBaseFile::createData(size_t *size, CProgressInfo *progress)
  | 
        
        
           | 6 | 
           cycrow | 
           3098 | 
           {
  | 
        
        
           | 175 | 
           cycrow | 
           3099 | 
           	if ( this->writeFile("temp.dat", progress) ) {
  | 
        
        
           | 197 | 
           cycrow | 
           3100 | 
           		CFileIO File(L"temp.dat");
  | 
        
        
           | 52 | 
           cycrow | 
           3101 | 
           		File.setAutoDelete(true);
  | 
        
        
            | 
            | 
           3102 | 
           		return File.readAll(size);
  | 
        
        
           | 6 | 
           cycrow | 
           3103 | 
           	}
  | 
        
        
            | 
            | 
           3104 | 
           	return NULL;
  | 
        
        
            | 
            | 
           3105 | 
           }
  | 
        
        
            | 
            | 
           3106 | 
              | 
        
        
            | 
            | 
           3107 | 
              | 
        
        
           | 170 | 
           cycrow | 
           3108 | 
           void CBaseFile::convertNormalMod(C_File *f, const Utils::String &to) const
  | 
        
        
           | 6 | 
           cycrow | 
           3109 | 
           {
  | 
        
        
           | 170 | 
           cycrow | 
           3110 | 
           	C_File *match = this->findMatchingMod(f);
  | 
        
        
           | 6 | 
           cycrow | 
           3111 | 
           	if ( match )
  | 
        
        
            | 
            | 
           3112 | 
           	{
  | 
        
        
            | 
            | 
           3113 | 
           		// file link
  | 
        
        
            | 
            | 
           3114 | 
           		if ( !match->GetData() )
  | 
        
        
            | 
            | 
           3115 | 
           			match->ReadFromFile();
  | 
        
        
           | 178 | 
           cycrow | 
           3116 | 
           		match->changeBaseName(to);
  | 
        
        
           | 6 | 
           cycrow | 
           3117 | 
           	}
  | 
        
        
            | 
            | 
           3118 | 
              | 
        
        
            | 
            | 
           3119 | 
           	// file link
  | 
        
        
            | 
            | 
           3120 | 
           	if ( !f->GetData() )
  | 
        
        
            | 
            | 
           3121 | 
           		f->ReadFromFile();
  | 
        
        
            | 
            | 
           3122 | 
              | 
        
        
           | 178 | 
           cycrow | 
           3123 | 
           	f->changeBaseName(to);
  | 
        
        
           | 6 | 
           cycrow | 
           3124 | 
           }
  | 
        
        
            | 
            | 
           3125 | 
              | 
        
        
           | 170 | 
           cycrow | 
           3126 | 
           void CBaseFile::convertAutoText(C_File *f) const
  | 
        
        
           | 6 | 
           cycrow | 
           3127 | 
           {
  | 
        
        
           | 197 | 
           cycrow | 
           3128 | 
           	Utils::WString to;
  | 
        
        
            | 
            | 
           3129 | 
           	if ( f->baseName().contains(L"-L") )
  | 
        
        
            | 
            | 
           3130 | 
           		to = L"0000-L" + f->baseName().token(L"-L", 2);
  | 
        
        
           | 178 | 
           cycrow | 
           3131 | 
           	else if ( f->baseName().contains("-l") )
  | 
        
        
           | 197 | 
           cycrow | 
           3132 | 
           		to = L"0000-L" + f->baseName().token(L"-l", 2);
  | 
        
        
           | 6 | 
           cycrow | 
           3133 | 
           	else
  | 
        
        
           | 197 | 
           cycrow | 
           3134 | 
           		to = f->baseName().left(-4) + L"0000";
  | 
        
        
           | 6 | 
           cycrow | 
           3135 | 
              | 
        
        
            | 
            | 
           3136 | 
           	// file link
  | 
        
        
            | 
            | 
           3137 | 
           	if ( !f->GetData() )
  | 
        
        
            | 
            | 
           3138 | 
           		f->ReadFromFile();
  | 
        
        
            | 
            | 
           3139 | 
              | 
        
        
           | 178 | 
           cycrow | 
           3140 | 
           	f->changeBaseName(to);
  | 
        
        
           | 6 | 
           cycrow | 
           3141 | 
           }
  | 
        
        
            | 
            | 
           3142 | 
              | 
        
        
           | 170 | 
           cycrow | 
           3143 | 
           void CBaseFile::convertFakePatch(C_File *f) const
  | 
        
        
           | 6 | 
           cycrow | 
           3144 | 
           {
  | 
        
        
            | 
            | 
           3145 | 
           	// find next available fake patch
  | 
        
        
            | 
            | 
           3146 | 
           	int num = 0;
  | 
        
        
            | 
            | 
           3147 | 
              | 
        
        
            | 
            | 
           3148 | 
           	bool found = true;
  | 
        
        
            | 
            | 
           3149 | 
           	while ( found )
  | 
        
        
            | 
            | 
           3150 | 
           	{
  | 
        
        
            | 
            | 
           3151 | 
           		++num;
  | 
        
        
            | 
            | 
           3152 | 
           		found = false;
  | 
        
        
           | 170 | 
           cycrow | 
           3153 | 
           		Utils::String find = Utils::String::PadNumber(num, 2);
  | 
        
        
           | 6 | 
           cycrow | 
           3154 | 
           		for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
  | 
        
        
            | 
            | 
           3155 | 
           		{
  | 
        
        
            | 
            | 
           3156 | 
           			if ( node->Data()->GetFileType() != FILETYPE_MOD )
  | 
        
        
            | 
            | 
           3157 | 
           				continue;
  | 
        
        
            | 
            | 
           3158 | 
           			if ( !node->Data()->IsFakePatch() )
  | 
        
        
            | 
            | 
           3159 | 
           				continue;
  | 
        
        
           | 170 | 
           cycrow | 
           3160 | 
           			if ( node->Data()->baseName().Compare(find) )
  | 
        
        
           | 6 | 
           cycrow | 
           3161 | 
           			{
  | 
        
        
            | 
            | 
           3162 | 
           				found = true;
  | 
        
        
            | 
            | 
           3163 | 
           				break;
  | 
        
        
            | 
            | 
           3164 | 
           			}
  | 
        
        
            | 
            | 
           3165 | 
           		}
  | 
        
        
            | 
            | 
           3166 | 
           	}
  | 
        
        
            | 
            | 
           3167 | 
              | 
        
        
           | 170 | 
           cycrow | 
           3168 | 
           	Utils::String to = Utils::String::PadNumber(num, 2);
  | 
        
        
            | 
            | 
           3169 | 
           	C_File *match = this->findMatchingMod(f);
  | 
        
        
           | 6 | 
           cycrow | 
           3170 | 
              | 
        
        
            | 
            | 
           3171 | 
           	// file link
  | 
        
        
            | 
            | 
           3172 | 
           	if ( !f->GetData() )
  | 
        
        
            | 
            | 
           3173 | 
           		f->ReadFromFile();
  | 
        
        
            | 
            | 
           3174 | 
              | 
        
        
           | 178 | 
           cycrow | 
           3175 | 
           	f->changeBaseName(to);
  | 
        
        
           | 6 | 
           cycrow | 
           3176 | 
           	if ( match )
  | 
        
        
            | 
            | 
           3177 | 
           	{
  | 
        
        
            | 
            | 
           3178 | 
           		// file link
  | 
        
        
            | 
            | 
           3179 | 
           		if ( !match->GetData() )
  | 
        
        
            | 
            | 
           3180 | 
           			match->ReadFromFile();
  | 
        
        
           | 178 | 
           cycrow | 
           3181 | 
           		match->changeBaseName(to);
  | 
        
        
           | 6 | 
           cycrow | 
           3182 | 
           	}
  | 
        
        
            | 
            | 
           3183 | 
           }
  | 
        
        
            | 
            | 
           3184 | 
              | 
        
        
           | 170 | 
           cycrow | 
           3185 | 
           C_File *CBaseFile::findMatchingMod(C_File *f) const
  | 
        
        
           | 6 | 
           cycrow | 
           3186 | 
           {
  | 
        
        
            | 
            | 
           3187 | 
           	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
  | 
        
        
            | 
            | 
           3188 | 
           	{
  | 
        
        
            | 
            | 
           3189 | 
           		if ( node->Data()->GetFileType() != FILETYPE_MOD )
  | 
        
        
            | 
            | 
           3190 | 
           			continue;
  | 
        
        
            | 
            | 
           3191 | 
              | 
        
        
           | 178 | 
           cycrow | 
           3192 | 
           		if ( f->fileExt().Compare(node->Data()->fileExt()) )
  | 
        
        
           | 6 | 
           cycrow | 
           3193 | 
           			continue;
  | 
        
        
            | 
            | 
           3194 | 
              | 
        
        
           | 178 | 
           cycrow | 
           3195 | 
           		if ( f->baseName().Compare(node->Data()->baseName()) )
  | 
        
        
           | 6 | 
           cycrow | 
           3196 | 
           			return node->Data();
  | 
        
        
            | 
            | 
           3197 | 
           	}
  | 
        
        
            | 
            | 
           3198 | 
              | 
        
        
            | 
            | 
           3199 | 
           	return NULL;
  | 
        
        
            | 
            | 
           3200 | 
           }
  | 
        
        
            | 
            | 
           3201 | 
              | 
        
        
           | 170 | 
           cycrow | 
           3202 | 
           void CBaseFile::renameFile(C_File *f, const Utils::String &baseName) const
  | 
        
        
           | 6 | 
           cycrow | 
           3203 | 
           {
  | 
        
        
            | 
            | 
           3204 | 
           	if ( f->GetFileType() == FILETYPE_MOD )
  | 
        
        
            | 
            | 
           3205 | 
           	{
  | 
        
        
           | 170 | 
           cycrow | 
           3206 | 
           		C_File *match = this->findMatchingMod(f);
  | 
        
        
           | 6 | 
           cycrow | 
           3207 | 
           		if ( match )
  | 
        
        
           | 178 | 
           cycrow | 
           3208 | 
           			match->changeBaseName(baseName);
  | 
        
        
           | 6 | 
           cycrow | 
           3209 | 
           	}
  | 
        
        
            | 
            | 
           3210 | 
              | 
        
        
            | 
            | 
           3211 | 
           	// need to edit the file
  | 
        
        
           | 134 | 
           cycrow | 
           3212 | 
           	if (f->GetFileType() == FILETYPE_SCRIPT || f->GetFileType() == FILETYPE_UNINSTALL)
  | 
        
        
           | 178 | 
           cycrow | 
           3213 | 
           		f->renameScript(baseName);
  | 
        
        
           | 6 | 
           cycrow | 
           3214 | 
              | 
        
        
           | 178 | 
           cycrow | 
           3215 | 
           	f->changeBaseName(baseName);
  | 
        
        
           | 6 | 
           cycrow | 
           3216 | 
           }
  | 
        
        
            | 
            | 
           3217 | 
              | 
        
        
           | 196 | 
           cycrow | 
           3218 | 
           Utils::WString CBaseFile::createUpdateFile(const Utils::WString &dir) const
  | 
        
        
           | 6 | 
           cycrow | 
           3219 | 
           {
  | 
        
        
           | 203 | 
           cycrow | 
           3220 | 
           	Utils::WString file = this->getNameValidFile() + L"_" + this->author() + L".dat";
  | 
        
        
           | 134 | 
           cycrow | 
           3221 | 
           	file.removeChar(' ');
  | 
        
        
           | 6 | 
           cycrow | 
           3222 | 
              | 
        
        
           | 203 | 
           cycrow | 
           3223 | 
           	Utils::WStringList write;
  | 
        
        
            | 
            | 
           3224 | 
           	write.pushBack(L"Package: " + this->name());
  | 
        
        
            | 
            | 
           3225 | 
           	write.pushBack(L"Author: " + this->author());
  | 
        
        
           | 204 | 
           cycrow | 
           3226 | 
           	write.pushBack(L"Version: " + this->version());
  | 
        
        
           | 203 | 
           cycrow | 
           3227 | 
           	write.pushBack(L"File: " + CFileIO(this->filename()).filename());
  | 
        
        
           | 6 | 
           cycrow | 
           3228 | 
              | 
        
        
           | 197 | 
           cycrow | 
           3229 | 
           	CFileIO File(dir + L"/" + file);
  | 
        
        
           | 134 | 
           cycrow | 
           3230 | 
           	if (File.writeFile(&write))
  | 
        
        
           | 102 | 
           cycrow | 
           3231 | 
           		return File.fullFilename();
  | 
        
        
           | 196 | 
           cycrow | 
           3232 | 
           	return Utils::WString::Null();
  | 
        
        
           | 6 | 
           cycrow | 
           3233 | 
           }
  | 
        
        
            | 
            | 
           3234 | 
              | 
        
        
           | 197 | 
           cycrow | 
           3235 | 
           Utils::WString CBaseFile::ErrorString(int error, const Utils::WString &errorStr)
  | 
        
        
           | 6 | 
           cycrow | 
           3236 | 
           {
  | 
        
        
           | 197 | 
           cycrow | 
           3237 | 
           	if (error == SPKERR_NONE) return Utils::WString::Null();
  | 
        
        
           | 6 | 
           cycrow | 
           3238 | 
              | 
        
        
           | 197 | 
           cycrow | 
           3239 | 
           	Utils::WString err;
  | 
        
        
           | 6 | 
           cycrow | 
           3240 | 
              | 
        
        
           | 126 | 
           cycrow | 
           3241 | 
           	switch (error)
  | 
        
        
           | 6 | 
           cycrow | 
           3242 | 
           	{
  | 
        
        
           | 126 | 
           cycrow | 
           3243 | 
           	case SPKERR_MALLOC:
  | 
        
        
           | 197 | 
           cycrow | 
           3244 | 
           		err = L"Memory Failed";
  | 
        
        
           | 126 | 
           cycrow | 
           3245 | 
           		break;
  | 
        
        
            | 
            | 
           3246 | 
           	case SPKERR_FILEOPEN:
  | 
        
        
           | 197 | 
           cycrow | 
           3247 | 
           		err = L"Failed to open file";
  | 
        
        
           | 126 | 
           cycrow | 
           3248 | 
           		break;
  | 
        
        
            | 
            | 
           3249 | 
           	case SPKERR_FILEREAD:
  | 
        
        
           | 197 | 
           cycrow | 
           3250 | 
           		err = L"Failed to read file";
  | 
        
        
           | 126 | 
           cycrow | 
           3251 | 
           		break;
  | 
        
        
            | 
            | 
           3252 | 
           	case SPKERR_UNCOMPRESS:
  | 
        
        
           | 197 | 
           cycrow | 
           3253 | 
           		err = L"Failed to Uncompress";
  | 
        
        
           | 126 | 
           cycrow | 
           3254 | 
           		break;
  | 
        
        
            | 
            | 
           3255 | 
           	case SPKERR_WRITEFILE:
  | 
        
        
           | 197 | 
           cycrow | 
           3256 | 
           		err = L"Failed to write file";
  | 
        
        
           | 126 | 
           cycrow | 
           3257 | 
           		break;
  | 
        
        
            | 
            | 
           3258 | 
           	case SPKERR_CREATEDIRECTORY:
  | 
        
        
           | 197 | 
           cycrow | 
           3259 | 
           		err = L"Failed to create directory";
  | 
        
        
           | 126 | 
           cycrow | 
           3260 | 
           		break;
  | 
        
        
            | 
            | 
           3261 | 
           	case SPKERR_FILEMISMATCH:
  | 
        
        
           | 197 | 
           cycrow | 
           3262 | 
           		err = L"File count mismatch";
  | 
        
        
           | 126 | 
           cycrow | 
           3263 | 
           		break;
  | 
        
        
           | 6 | 
           cycrow | 
           3264 | 
           	}
  | 
        
        
            | 
            | 
           3265 | 
              | 
        
        
           | 134 | 
           cycrow | 
           3266 | 
           	if (!err.empty())
  | 
        
        
           | 6 | 
           cycrow | 
           3267 | 
           	{
  | 
        
        
           | 134 | 
           cycrow | 
           3268 | 
           		if (!errorStr.empty())
  | 
        
        
           | 6 | 
           cycrow | 
           3269 | 
           		{
  | 
        
        
           | 197 | 
           cycrow | 
           3270 | 
           			err += L" (";
  | 
        
        
            | 
            | 
           3271 | 
           			err += errorStr + L")";
  | 
        
        
           | 6 | 
           cycrow | 
           3272 | 
           		}
  | 
        
        
            | 
            | 
           3273 | 
           		return err;
  | 
        
        
            | 
            | 
           3274 | 
           	}
  | 
        
        
            | 
            | 
           3275 | 
              | 
        
        
           | 197 | 
           cycrow | 
           3276 | 
           	return Utils::WString::Number((long)error);
  | 
        
        
           | 6 | 
           cycrow | 
           3277 | 
           }
  | 
        
        
            | 
            | 
           3278 | 
              | 
        
        
           | 131 | 
           cycrow | 
           3279 | 
           bool CBaseFile::saveToArchive(const Utils::String &filename, int game, const CGameExe *exes, CProgressInfo *progress)
  | 
        
        
            | 
            | 
           3280 | 
           {
  | 
        
        
            | 
            | 
           3281 | 
           	CDirIO Dir(CFileIO(filename).dir());
  | 
        
        
            | 
            | 
           3282 | 
           	if (!Dir.exists())
  | 
        
        
            | 
            | 
           3283 | 
           		Dir.create();
  | 
        
        
            | 
            | 
           3284 | 
              | 
        
        
           | 6 | 
           cycrow | 
           3285 | 
           	TCHAR buf[5000];
  | 
        
        
            | 
            | 
           3286 | 
           	wsprintf(buf, L"%hs", filename.c_str());
  | 
        
        
            | 
            | 
           3287 | 
              | 
        
        
            | 
            | 
           3288 | 
           	HZIP hz = CreateZip(buf, 0);
  | 
        
        
           | 126 | 
           cycrow | 
           3289 | 
           	if (!hz) return false;
  | 
        
        
           | 6 | 
           cycrow | 
           3290 | 
              | 
        
        
            | 
            | 
           3291 | 
           	// read files and compress
  | 
        
        
            | 
            | 
           3292 | 
           	ReadAllFilesToMemory();
  | 
        
        
           | 126 | 
           cycrow | 
           3293 | 
           	if (!UncompressAllFiles(progress))
  | 
        
        
           | 6 | 
           cycrow | 
           3294 | 
           	{
  | 
        
        
            | 
            | 
           3295 | 
           		CloseZip(hz);
  | 
        
        
            | 
            | 
           3296 | 
           		return false;
  | 
        
        
            | 
            | 
           3297 | 
           	}
  | 
        
        
            | 
            | 
           3298 | 
              | 
        
        
           | 126 | 
           cycrow | 
           3299 | 
           	for (CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next())
  | 
        
        
           | 6 | 
           cycrow | 
           3300 | 
           	{
  | 
        
        
           | 126 | 
           cycrow | 
           3301 | 
           		if (game != -1) {
  | 
        
        
           | 127 | 
           cycrow | 
           3302 | 
           			if (game && !(node->Data()->game() & (1 << game)))
  | 
        
        
           | 6 | 
           cycrow | 
           3303 | 
           				continue;
  | 
        
        
           | 127 | 
           cycrow | 
           3304 | 
           			// extracting for all games, so ignore files that have a game set
  | 
        
        
            | 
            | 
           3305 | 
           			if (!game && node->Data()->game() && node->Data()->game() != GAME_ALLNEW)
  | 
        
        
           | 6 | 
           cycrow | 
           3306 | 
           				continue;
  | 
        
        
            | 
            | 
           3307 | 
           		}
  | 
        
        
           | 197 | 
           cycrow | 
           3308 | 
           		Utils::WString fname = node->Data()->getNameDirectory(this);
  | 
        
        
           | 126 | 
           cycrow | 
           3309 | 
              | 
        
        
            | 
            | 
           3310 | 
           		// use the addon directory
  | 
        
        
            | 
            | 
           3311 | 
           		if (node->Data()->isFileInAddon() && exes)
  | 
        
        
            | 
            | 
           3312 | 
           		{
  | 
        
        
           | 127 | 
           cycrow | 
           3313 | 
           			unsigned int whatGame = game;
  | 
        
        
           | 126 | 
           cycrow | 
           3314 | 
           			if (game == -1)
  | 
        
        
           | 127 | 
           cycrow | 
           3315 | 
           			{
  | 
        
        
            | 
            | 
           3316 | 
           				unsigned int checkGame = node->Data()->game() & ~GAME_ALLNEW;
  | 
        
        
            | 
            | 
           3317 | 
           				whatGame = 0;
  | 
        
        
            | 
            | 
           3318 | 
           				for (int i = 0; i < 31; ++i)
  | 
        
        
            | 
            | 
           3319 | 
           				{
  | 
        
        
            | 
            | 
           3320 | 
           					if (1 << i == checkGame)
  | 
        
        
            | 
            | 
           3321 | 
           					{
  | 
        
        
            | 
            | 
           3322 | 
           						whatGame = i;
  | 
        
        
            | 
            | 
           3323 | 
           						break;
  | 
        
        
            | 
            | 
           3324 | 
           					}
  | 
        
        
            | 
            | 
           3325 | 
           				}
  | 
        
        
            | 
            | 
           3326 | 
           			}
  | 
        
        
           | 126 | 
           cycrow | 
           3327 | 
              | 
        
        
           | 127 | 
           cycrow | 
           3328 | 
           			if (whatGame > 0)
  | 
        
        
           | 126 | 
           cycrow | 
           3329 | 
           			{
  | 
        
        
           | 197 | 
           cycrow | 
           3330 | 
           				SGameExe *e = exes->game(whatGame - 1);
  | 
        
        
           | 127 | 
           cycrow | 
           3331 | 
           				if (e)
  | 
        
        
            | 
            | 
           3332 | 
           				{
  | 
        
        
            | 
            | 
           3333 | 
           					if (e->iFlags & EXEFLAG_ADDON)
  | 
        
        
           | 197 | 
           cycrow | 
           3334 | 
           						fname = e->sAddon + L"/" + fname;
  | 
        
        
           | 127 | 
           cycrow | 
           3335 | 
           				}
  | 
        
        
           | 126 | 
           cycrow | 
           3336 | 
           			}
  | 
        
        
            | 
            | 
           3337 | 
           		}
  | 
        
        
            | 
            | 
           3338 | 
              | 
        
        
           | 6 | 
           cycrow | 
           3339 | 
           		// create the directory
  | 
        
        
           | 197 | 
           cycrow | 
           3340 | 
           		//wsprintf(buf, L"%hs", fname.c_str());
  | 
        
        
           | 127 | 
           cycrow | 
           3341 | 
           		if (node->Data()->isExternalFile())
  | 
        
        
            | 
            | 
           3342 | 
           		{
  | 
        
        
            | 
            | 
           3343 | 
           			CFileIO file(node->Data()->filePointer());
  | 
        
        
            | 
            | 
           3344 | 
           			size_t size = 0;
  | 
        
        
            | 
            | 
           3345 | 
           			unsigned char *data = file.readAll(&size);
  | 
        
        
           | 197 | 
           cycrow | 
           3346 | 
           			ZipAdd(hz, fname.c_str(), data, size);
  | 
        
        
           | 127 | 
           cycrow | 
           3347 | 
           			delete data;
  | 
        
        
            | 
            | 
           3348 | 
           		}
  | 
        
        
            | 
            | 
           3349 | 
           		else
  | 
        
        
           | 197 | 
           cycrow | 
           3350 | 
           			ZipAdd(hz, fname.c_str(), node->Data()->GetData(), node->Data()->GetDataSize());
  | 
        
        
           | 6 | 
           cycrow | 
           3351 | 
           	}
  | 
        
        
            | 
            | 
           3352 | 
              | 
        
        
           | 109 | 
           cycrow | 
           3353 | 
           	// if its a ship, then add any generated files
  | 
        
        
            | 
            | 
           3354 | 
           	this->addGeneratedFiles(hz);
  | 
        
        
            | 
            | 
           3355 | 
              | 
        
        
           | 6 | 
           cycrow | 
           3356 | 
           	// add the data file
  | 
        
        
           | 126 | 
           cycrow | 
           3357 | 
           	Utils::CStringList list;
  | 
        
        
           | 127 | 
           cycrow | 
           3358 | 
           	Utils::CStringList addons;
  | 
        
        
            | 
            | 
           3359 | 
           	if ( this->GeneratePackagerScript(false, &list, game, addons, true) )
  | 
        
        
           | 6 | 
           cycrow | 
           3360 | 
           	{
  | 
        
        
           | 126 | 
           cycrow | 
           3361 | 
           		if ( CFileIO("test.tmp").writeFile(&list) )
  | 
        
        
           | 6 | 
           cycrow | 
           3362 | 
           		{
  | 
        
        
            | 
            | 
           3363 | 
           			ZipAdd(hz, L"pluginmanager.txt", L"test.tmp");
  | 
        
        
           | 52 | 
           cycrow | 
           3364 | 
           			CFileIO::Remove("test.tmp");
  | 
        
        
           | 6 | 
           cycrow | 
           3365 | 
           		}
  | 
        
        
            | 
            | 
           3366 | 
           	}
  | 
        
        
            | 
            | 
           3367 | 
              | 
        
        
            | 
            | 
           3368 | 
           	CloseZip(hz);
  | 
        
        
            | 
            | 
           3369 | 
              | 
        
        
            | 
            | 
           3370 | 
           	return true;
  | 
        
        
            | 
            | 
           3371 | 
           }
  | 
        
        
            | 
            | 
           3372 | 
              | 
        
        
           | 13 | 
           cycrow | 
           3373 | 
           int CBaseFile::GetGameFromString(const Utils::String &sGame)
  | 
        
        
           | 6 | 
           cycrow | 
           3374 | 
           {
  | 
        
        
            | 
            | 
           3375 | 
           	int iGame = GAME_ALL;
  | 
        
        
            | 
            | 
           3376 | 
           	if ( sGame.Compare("ALL") )
  | 
        
        
            | 
            | 
           3377 | 
           		iGame = GAME_ALL;
  | 
        
        
            | 
            | 
           3378 | 
           	else if ( sGame.Compare("X3") )
  | 
        
        
            | 
            | 
           3379 | 
           		iGame = GAME_X3;
  | 
        
        
            | 
            | 
           3380 | 
           	else if ( sGame.Compare("X2") )
  | 
        
        
            | 
            | 
           3381 | 
           		iGame = GAME_X2;
  | 
        
        
            | 
            | 
           3382 | 
           	else if ( sGame.Compare("X3TC") )
  | 
        
        
            | 
            | 
           3383 | 
           		iGame = GAME_X3TC;
  | 
        
        
           | 126 | 
           cycrow | 
           3384 | 
           	else if (sGame.Compare("X3AP"))
  | 
        
        
           | 6 | 
           cycrow | 
           3385 | 
           		iGame = GAME_X3AP;
  | 
        
        
           | 126 | 
           cycrow | 
           3386 | 
           	else if (sGame.Compare("X3FL"))
  | 
        
        
            | 
            | 
           3387 | 
           		iGame = GAME_X3FL;
  | 
        
        
           | 13 | 
           cycrow | 
           3388 | 
           	else if ( sGame.isNumber() )
  | 
        
        
            | 
            | 
           3389 | 
           		iGame = sGame;
  | 
        
        
           | 6 | 
           cycrow | 
           3390 | 
              | 
        
        
            | 
            | 
           3391 | 
           	return iGame;
  | 
        
        
            | 
            | 
           3392 | 
           }
  | 
        
        
            | 
            | 
           3393 | 
              | 
        
        
           | 197 | 
           cycrow | 
           3394 | 
           Utils::WString CBaseFile::ConvertGameToString(int iGame)
  | 
        
        
           | 6 | 
           cycrow | 
           3395 | 
           {
  | 
        
        
           | 197 | 
           cycrow | 
           3396 | 
           	Utils::WString game = L"ALL";
  | 
        
        
           | 6 | 
           cycrow | 
           3397 | 
              | 
        
        
            | 
            | 
           3398 | 
           	switch(iGame) {
  | 
        
        
            | 
            | 
           3399 | 
           		case GAME_ALL:
  | 
        
        
           | 127 | 
           cycrow | 
           3400 | 
           		case GAME_ALLNEW:
  | 
        
        
           | 197 | 
           cycrow | 
           3401 | 
           			game = L"ALL";
  | 
        
        
           | 6 | 
           cycrow | 
           3402 | 
           			break;
  | 
        
        
            | 
            | 
           3403 | 
           		case GAME_X2:
  | 
        
        
           | 197 | 
           cycrow | 
           3404 | 
           			game = L"X2";
  | 
        
        
           | 6 | 
           cycrow | 
           3405 | 
           			break;
  | 
        
        
            | 
            | 
           3406 | 
           		case GAME_X3:
  | 
        
        
           | 197 | 
           cycrow | 
           3407 | 
           			game = L"X3";
  | 
        
        
           | 6 | 
           cycrow | 
           3408 | 
           			break;
  | 
        
        
            | 
            | 
           3409 | 
           		case GAME_X3TC:
  | 
        
        
           | 197 | 
           cycrow | 
           3410 | 
           			game = L"X3TC";
  | 
        
        
           | 6 | 
           cycrow | 
           3411 | 
           			break;
  | 
        
        
            | 
            | 
           3412 | 
           		case GAME_X3AP:
  | 
        
        
           | 197 | 
           cycrow | 
           3413 | 
           			game = L"X3AP";
  | 
        
        
           | 6 | 
           cycrow | 
           3414 | 
           			break;
  | 
        
        
           | 126 | 
           cycrow | 
           3415 | 
           		case GAME_X3FL:
  | 
        
        
           | 197 | 
           cycrow | 
           3416 | 
           			game = L"X3FL";
  | 
        
        
           | 126 | 
           cycrow | 
           3417 | 
           			break;
  | 
        
        
           | 6 | 
           cycrow | 
           3418 | 
           		default:
  | 
        
        
            | 
            | 
           3419 | 
           			game = (long)iGame;
  | 
        
        
            | 
            | 
           3420 | 
           	}
  | 
        
        
            | 
            | 
           3421 | 
              | 
        
        
            | 
            | 
           3422 | 
           	return game;
  | 
        
        
            | 
            | 
           3423 | 
           }
  | 
        
        
            | 
            | 
           3424 | 
              | 
        
        
            | 
            | 
           3425 | 
           bool CBaseFile::IsGameInPackage(int game)
  | 
        
        
            | 
            | 
           3426 | 
           {
  | 
        
        
            | 
            | 
           3427 | 
           	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() ) {
  | 
        
        
            | 
            | 
           3428 | 
           		if ( node->Data()->GetGame() == game )
  | 
        
        
            | 
            | 
           3429 | 
           			return true;
  | 
        
        
            | 
            | 
           3430 | 
           	}
  | 
        
        
            | 
            | 
           3431 | 
              | 
        
        
            | 
            | 
           3432 | 
           	return false;
  | 
        
        
            | 
            | 
           3433 | 
           }
  | 
        
        
            | 
            | 
           3434 | 
              | 
        
        
            | 
            | 
           3435 | 
           bool CBaseFile::IsAnyGameInPackage()
  | 
        
        
            | 
            | 
           3436 | 
           {
  | 
        
        
            | 
            | 
           3437 | 
           	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() ) {
  | 
        
        
            | 
            | 
           3438 | 
           		if ( node->Data()->GetGame() )
  | 
        
        
            | 
            | 
           3439 | 
           			return true;
  | 
        
        
            | 
            | 
           3440 | 
           	}
  | 
        
        
            | 
            | 
           3441 | 
              | 
        
        
            | 
            | 
           3442 | 
           	return false;
  | 
        
        
            | 
            | 
           3443 | 
           }
  | 
        
        
            | 
            | 
           3444 | 
              | 
        
        
           | 88 | 
           cycrow | 
           3445 | 
           Utils::String builtInWares()
  | 
        
        
            | 
            | 
           3446 | 
           {
  | 
        
        
            | 
            | 
           3447 | 
           	Utils::String str;
  | 
        
        
            | 
            | 
           3448 | 
           	str += "28;0;0;0;0;59;5753;0;35714;1;1;0;35714;-100000;0;0;SS_WARE_SW_NEW1;\n";
  | 
        
        
            | 
            | 
           3449 | 
           	str += "28;0;0;0;0;60;5763;0;33232;1;1;0;33232;0;1043;0;SS_WARE_SW_NEW2;\n";
  | 
        
        
            | 
            | 
           3450 | 
           	str += "28;0;0;0;0;61;5773;0;21428;1;1;0;21428;0;1043;0;SS_WARE_SW_NEW3;\n";
  | 
        
        
            | 
            | 
           3451 | 
           	str += "28;0;0;0;0;62;5783;0;56;1;1;0;56;-100000;0;0;SS_WARE_SW_NEW4;\n";
  | 
        
        
            | 
            | 
           3452 | 
           	str += "28;0;0;0;0;63;5793;0;88;1;1;0;88;-100000;0;0;SS_WARE_SW_NEW5;\n";
  | 
        
        
            | 
            | 
           3453 | 
           	str += "28;0;0;0;0;64;5803;0;283;1;1;0;283;-100000;0;0;SS_WARE_SW_NEW6;\n";
  | 
        
        
            | 
            | 
           3454 | 
           	str += "28;0;0;0;0;65;5813;0;383;1;1;0;383;-100000;0;0;SS_WARE_SW_NEW7;\n";
  | 
        
        
            | 
            | 
           3455 | 
           	str += "28;0;0;0;0;66;5823;0;1389;1;1;0;1389;-100000;1043;0;SS_WARE_SW_NEW8;\n";
  | 
        
        
            | 
            | 
           3456 | 
           	str += "28;0;0;0;0;67;5833;0;3396;1;1;0;3396;-100000;0;0;SS_WARE_SW_NEW9;\n";
  | 
        
        
            | 
            | 
           3457 | 
           	str += "28;0;0;0;0;68;5843;0;4215;1;1;0;4215;-100000;0;0;SS_WARE_SW_NEW10;\n";
  | 
        
        
            | 
            | 
           3458 | 
           	str += "28;0;0;0;0;69;5853;0;5635;1;1;0;5635;-100000;0;0;SS_WARE_SW_NEW11;\n";
  | 
        
        
            | 
            | 
           3459 | 
           	str += "28;0;0;0;0;70;5863;0;65735;1;1;0;65735;-100000;0;0;SS_WARE_SW_NEW12;\n";
  | 
        
        
            | 
            | 
           3460 | 
           	str += "28;0;0;0;0;71;5873;0;17857;1;1;0;17857;333;1043;0;SS_WARE_SW_NEW13;\n";
  | 
        
        
            | 
            | 
           3461 | 
           	str += "28;0;0;0;0;72;5883;0;21428;1;1;0;21428;0;1043;0;SS_WARE_SW_NEW14;\n";
  | 
        
        
            | 
            | 
           3462 | 
           	str += "28;0;0;0;0;73;5893;0;324515;1;1;0;324515;-100000;0;0;SS_WARE_SW_NEW15;\n";
  | 
        
        
            | 
            | 
           3463 | 
           	str += "28;0;0;0;0;74;5903;0;638508;1;1;0;638508;-100000;0;0;SS_WARE_SW_NEW16;\n";
  | 
        
        
            | 
            | 
           3464 | 
           	str += "28;0;0;0;0;75;5913;0;225755;1;1;0;225755;-100000;0;0;SS_WARE_SW_NEW17;\n";
  | 
        
        
            | 
            | 
           3465 | 
           	str += "28;0;0;0;0;76;5923;0;1931535;1;1;0;1931535;1000;0;0;SS_WARE_SW_NEW18;\n";
  | 
        
        
            | 
            | 
           3466 | 
           	str += "28;0;0;0;0;77;5933;0;2209150;1;1;0;2209150;-100000;0;0;SS_WARE_SW_NEW19;\n";
  | 
        
        
            | 
            | 
           3467 | 
           	str += "28;0;0;0;0;78;5943;0;6727565;1;1;0;6727565;-100000;0;0;SS_WARE_SW_NEW20;\n";
  | 
        
        
            | 
            | 
           3468 | 
           	str += "28;0;0;0;0;85;9999;0;105;1;5;0;105;0;1043;0;SS_WARE_SW_X3TC_1;\n";
  | 
        
        
            | 
            | 
           3469 | 
           	str += "28;0;0;0;0;86;15053;0;105;1;5;0;105;0;1043;0;SS_WARE_SW_X3TC_2;\n";
  | 
        
        
            | 
            | 
           3470 | 
           	str += "28;0;0;0;0;87;15063;0;105;1;5;0;105;0;1043;0;SS_WARE_SW_X3TC_3;\n";
  | 
        
        
            | 
            | 
           3471 | 
           	str += "28;0;0;0;0;88;15073;0;105;1;5;0;105;0;1043;0;SS_WARE_SW_X3TC_4;\n";
  | 
        
        
            | 
            | 
           3472 | 
           	str += "28;0;0;0;0;89;15083;0;105;1;5;0;105;0;1043;0;SS_WARE_SW_X3TC_5;\n";
  | 
        
        
            | 
            | 
           3473 | 
           	str += "28;0;0;0;0;90;15093;0;105;1;5;0;105;0;1043;0;SS_WARE_SW_X3TC_6;\n";
  | 
        
        
            | 
            | 
           3474 | 
              | 
        
        
            | 
            | 
           3475 | 
           	return str;
  | 
        
        
            | 
            | 
           3476 | 
           }
  | 
        
        
            | 
            | 
           3477 | 
              | 
        
        
           | 197 | 
           cycrow | 
           3478 | 
           void CBaseFile::_addWaresToList(int iLang, CLinkList<SWareEntry> &list, const Utils::WString &wares, enum WareTypes eType)
  | 
        
        
           | 88 | 
           cycrow | 
           3479 | 
           {
  | 
        
        
           | 197 | 
           cycrow | 
           3480 | 
           	std::vector<Utils::WString> w;
  | 
        
        
            | 
            | 
           3481 | 
           	wares.tokenise(L"\n", w);
  | 
        
        
           | 88 | 
           cycrow | 
           3482 | 
              | 
        
        
           | 197 | 
           cycrow | 
           3483 | 
           	for(size_t i = 0; i < w.size(); i++) {
  | 
        
        
            | 
            | 
           3484 | 
           		int textId = w[i].token(L";", 7).toLong();
  | 
        
        
           | 88 | 
           cycrow | 
           3485 | 
           		int useLang = iLang;
  | 
        
        
            | 
            | 
           3486 | 
           		if ( !_pTextDB->exists(useLang, 17, textId) )
  | 
        
        
            | 
            | 
           3487 | 
           			useLang = 44;
  | 
        
        
            | 
            | 
           3488 | 
           		if ( !_pTextDB->exists(useLang, 17, textId) )
  | 
        
        
            | 
            | 
           3489 | 
           			useLang = 49;
  | 
        
        
            | 
            | 
           3490 | 
           		if ( _pTextDB->exists(useLang, 17, textId) ) {	
  | 
        
        
            | 
            | 
           3491 | 
           			SWareEntry *ware = new SWareEntry;
  | 
        
        
            | 
            | 
           3492 | 
           			ware->name = _pTextDB->get(useLang, 17, textId);
  | 
        
        
            | 
            | 
           3493 | 
           			ware->description = _pTextDB->get(useLang, 17, textId + 1);
  | 
        
        
           | 197 | 
           cycrow | 
           3494 | 
           			ware->id = w[i].token(L";", -2);
  | 
        
        
            | 
            | 
           3495 | 
           			ware->relval = w[i].token(L";", 9).toLong();
  | 
        
        
            | 
            | 
           3496 | 
           			ware->notority = w[i].token(L";", 14).toLong();
  | 
        
        
           | 88 | 
           cycrow | 
           3497 | 
           			ware->type = eType;
  | 
        
        
            | 
            | 
           3498 | 
           			ware->position = i;
  | 
        
        
           | 89 | 
           cycrow | 
           3499 | 
           			ware->package = this;
  | 
        
        
           | 88 | 
           cycrow | 
           3500 | 
           			list.push_back(ware);
  | 
        
        
            | 
            | 
           3501 | 
           		}
  | 
        
        
            | 
            | 
           3502 | 
           	}
  | 
        
        
            | 
            | 
           3503 | 
           }
  | 
        
        
            | 
            | 
           3504 | 
              | 
        
        
           | 197 | 
           cycrow | 
           3505 | 
           bool CBaseFile::readWares(int iLang, CLinkList<SWareEntry> &list, const Utils::WString &empWares)
  | 
        
        
           | 88 | 
           cycrow | 
           3506 | 
           {
  | 
        
        
            | 
            | 
           3507 | 
           	_pTextDB->setLanguage(iLang);
  | 
        
        
            | 
            | 
           3508 | 
              | 
        
        
            | 
            | 
           3509 | 
           	// now go through all emp wares and get the ones we have text for
  | 
        
        
            | 
            | 
           3510 | 
           	_addWaresToList(iLang, list, empWares, Ware_EMP);
  | 
        
        
            | 
            | 
           3511 | 
           	_addWaresToList(iLang, list, builtInWares(), Ware_BuiltIn);
  | 
        
        
            | 
            | 
           3512 | 
              | 
        
        
           | 89 | 
           cycrow | 
           3513 | 
           	return true;
  | 
        
        
            | 
            | 
           3514 | 
           }
  | 
        
        
           | 88 | 
           cycrow | 
           3515 | 
              | 
        
        
           | 89 | 
           cycrow | 
           3516 | 
           bool CBaseFile::_readCommands(int iLang, int iStartID, CLinkList<SCommandSlot> &list)
  | 
        
        
            | 
            | 
           3517 | 
           {
  | 
        
        
            | 
            | 
           3518 | 
           	_pTextDB->setLanguage(iLang);
  | 
        
        
            | 
            | 
           3519 | 
              | 
        
        
            | 
            | 
           3520 | 
           	for(int i = 2; i <= 13; i++) {
  | 
        
        
            | 
            | 
           3521 | 
           		for(int j = 0; j < 64; j++) {
  | 
        
        
            | 
            | 
           3522 | 
           			int id = (i * 100) + j;
  | 
        
        
            | 
            | 
           3523 | 
           			if ( _pTextDB->exists(iLang, iStartID + 2, id) ) {
  | 
        
        
            | 
            | 
           3524 | 
           				SCommandSlot *slot = new SCommandSlot;
  | 
        
        
            | 
            | 
           3525 | 
           				list.push_back(slot);
  | 
        
        
            | 
            | 
           3526 | 
              | 
        
        
            | 
            | 
           3527 | 
           				slot->id = _pTextDB->get(iLang, iStartID, id);
  | 
        
        
            | 
            | 
           3528 | 
           				slot->name = _pTextDB->get(iLang, iStartID + 2, id);
  | 
        
        
            | 
            | 
           3529 | 
           				slot->shortName = _pTextDB->get(iLang, iStartID + 3, id);
  | 
        
        
            | 
            | 
           3530 | 
           				slot->info = _pTextDB->get(iLang, iStartID + 14, id);
  | 
        
        
            | 
            | 
           3531 | 
           				slot->slot = id;
  | 
        
        
            | 
            | 
           3532 | 
           				slot->package = this;
  | 
        
        
            | 
            | 
           3533 | 
            			}
  | 
        
        
            | 
            | 
           3534 | 
           		}
  | 
        
        
            | 
            | 
           3535 | 
           	}
  | 
        
        
            | 
            | 
           3536 | 
              | 
        
        
            | 
            | 
           3537 | 
           	for(int i = 1400; i <= 2000; i++) {
  | 
        
        
            | 
            | 
           3538 | 
           		if ( _pTextDB->exists(iLang, iStartID + 2, i) ) {
  | 
        
        
            | 
            | 
           3539 | 
           			SCommandSlot *slot = new SCommandSlot;
  | 
        
        
            | 
            | 
           3540 | 
           			list.push_back(slot);
  | 
        
        
            | 
            | 
           3541 | 
              | 
        
        
            | 
            | 
           3542 | 
           			slot->id = _pTextDB->get(iLang, iStartID, i);
  | 
        
        
            | 
            | 
           3543 | 
           			slot->name = _pTextDB->get(iLang, iStartID + 2, i);
  | 
        
        
            | 
            | 
           3544 | 
           			slot->shortName = _pTextDB->get(iLang, iStartID + 3, i);
  | 
        
        
            | 
            | 
           3545 | 
           			slot->info = _pTextDB->get(iLang, iStartID + 14, i);
  | 
        
        
            | 
            | 
           3546 | 
           			slot->slot = i;
  | 
        
        
            | 
            | 
           3547 | 
           			slot->package = this;
  | 
        
        
            | 
            | 
           3548 | 
           		}
  | 
        
        
            | 
            | 
           3549 | 
           	}
  | 
        
        
            | 
            | 
           3550 | 
              | 
        
        
            | 
            | 
           3551 | 
           	for(int i = 6000; i <= 9999; i++) {
  | 
        
        
            | 
            | 
           3552 | 
           		if ( _pTextDB->exists(iLang, iStartID + 2, i) ) {
  | 
        
        
            | 
            | 
           3553 | 
           			SCommandSlot *slot = new SCommandSlot;
  | 
        
        
            | 
            | 
           3554 | 
           			list.push_back(slot);
  | 
        
        
            | 
            | 
           3555 | 
              | 
        
        
            | 
            | 
           3556 | 
           			slot->id = _pTextDB->get(iLang, iStartID, i);
  | 
        
        
            | 
            | 
           3557 | 
           			slot->name = _pTextDB->get(iLang, iStartID + 2, i);
  | 
        
        
            | 
            | 
           3558 | 
           			slot->shortName = _pTextDB->get(iLang, iStartID + 3, i);
  | 
        
        
            | 
            | 
           3559 | 
           			slot->info = _pTextDB->get(iLang, iStartID + 14, i);
  | 
        
        
            | 
            | 
           3560 | 
           			slot->slot = i;
  | 
        
        
            | 
            | 
           3561 | 
           			slot->package = this;
  | 
        
        
            | 
            | 
           3562 | 
           		}
  | 
        
        
            | 
            | 
           3563 | 
           	}
  | 
        
        
            | 
            | 
           3564 | 
              | 
        
        
           | 88 | 
           cycrow | 
           3565 | 
           	return true;
  | 
        
        
            | 
            | 
           3566 | 
           }
  | 
        
        
            | 
            | 
           3567 | 
              | 
        
        
           | 89 | 
           cycrow | 
           3568 | 
           bool CBaseFile::readWingCommands(int iLang, CLinkList<SCommandSlot> &list)
  | 
        
        
            | 
            | 
           3569 | 
           {
  | 
        
        
            | 
            | 
           3570 | 
           	return _readCommands(iLang, 2028, list);
  | 
        
        
            | 
            | 
           3571 | 
           }
  | 
        
        
            | 
            | 
           3572 | 
              | 
        
        
            | 
            | 
           3573 | 
           bool CBaseFile::readCommands(int iLang, CLinkList<SCommandSlot> &list)
  | 
        
        
            | 
            | 
           3574 | 
           {
  | 
        
        
            | 
            | 
           3575 | 
           	return _readCommands(iLang, 2008, list);
  | 
        
        
            | 
            | 
           3576 | 
           }
  | 
        
        
            | 
            | 
           3577 | 
              | 
        
        
           | 6 | 
           cycrow | 
           3578 | 
           int CBaseFile::FindFirstGameInPackage()
  | 
        
        
            | 
            | 
           3579 | 
           {
  | 
        
        
            | 
            | 
           3580 | 
           	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() ) {
  | 
        
        
            | 
            | 
           3581 | 
           		if ( node->Data()->GetGame() )
  | 
        
        
            | 
            | 
           3582 | 
           			return node->Data()->GetGame();
  | 
        
        
            | 
            | 
           3583 | 
           	}
  | 
        
        
            | 
            | 
           3584 | 
              | 
        
        
            | 
            | 
           3585 | 
           	return 0;
  | 
        
        
            | 
            | 
           3586 | 
           }
  | 
        
        
            | 
            | 
           3587 | 
           bool CBaseFile::IsMultipleGamesInPackage()
  | 
        
        
            | 
            | 
           3588 | 
           {
  | 
        
        
            | 
            | 
           3589 | 
           	int game = 0;
  | 
        
        
            | 
            | 
           3590 | 
           	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() ) {
  | 
        
        
            | 
            | 
           3591 | 
           		if ( node->Data()->GetGame() ) {
  | 
        
        
            | 
            | 
           3592 | 
           			if ( game != node->Data()->GetGame() )
  | 
        
        
            | 
            | 
           3593 | 
           				return true;
  | 
        
        
            | 
            | 
           3594 | 
           			game = node->Data()->GetGame();
  | 
        
        
            | 
            | 
           3595 | 
           		}
  | 
        
        
            | 
            | 
           3596 | 
           	}
  | 
        
        
            | 
            | 
           3597 | 
              | 
        
        
            | 
            | 
           3598 | 
           	return false;
  | 
        
        
            | 
            | 
           3599 | 
           }
  |