Subversion Repositories spk

Rev

Rev 129 | Rev 131 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 129 Rev 130
Line 1259... Line 1259...
1259
		case SPKFILE_OLD:
1259
		case SPKFILE_OLD:
1260
			*error = INSTALLERR_OLD;
1260
			*error = INSTALLERR_OLD;
1261
			return NULL;
1261
			return NULL;
1262
		case SPKFILE_INVALID:
1262
		case SPKFILE_INVALID:
1263
			// convert xsp
1263
			// convert xsp
1264
			if ( CFileIO(file).CheckFileExtension("xsp") )
1264
			if ( CFileIO(file).isFileExtension("xsp") )
1265
			{
1265
			{
1266
				installFile = new CXspFile();
1266
				installFile = new CXspFile();
1267
				if ( !((CXspFile *)installFile)->ConvertOld(file.ToString()) )
1267
				if ( !((CXspFile *)installFile)->ConvertOld(file.ToString()) )
1268
				{
1268
				{
1269
					delete installFile;
1269
					delete installFile;
Line 1273... Line 1273...
1273
			}
1273
			}
1274
			*error = INSTALLERR_INVALID;
1274
			*error = INSTALLERR_INVALID;
1275
			return NULL;
1275
			return NULL;
1276
		case SPKFILE_BASE:
1276
		case SPKFILE_BASE:
1277
			installFile = new CBaseFile();
1277
			installFile = new CBaseFile();
1278
			if ( !installFile->ReadFile(file, readtype, progress) )
1278
			if ( !installFile->readFile(file.ToString(), readtype, progress) )
1279
			{
1279
			{
1280
				delete installFile;
1280
				delete installFile;
1281
				return NULL;
1281
				return NULL;
1282
			}
1282
			}
1283
			break;
1283
			break;
1284
		case SPKFILE_SINGLE:
1284
		case SPKFILE_SINGLE:
1285
			installFile = new CSpkFile();
1285
			installFile = new CSpkFile();
1286
			if ( !((CSpkFile *)installFile)->ReadFile(file, readtype, progress) )
1286
			if ( !((CSpkFile *)installFile)->readFile(file.ToString(), readtype, progress) )
1287
			{
1287
			{
1288
				delete installFile;
1288
				delete installFile;
1289
				return NULL;
1289
				return NULL;
1290
			}
1290
			}
1291
			break;
1291
			break;
Line 1752... Line 1752...
1752
				{
1752
				{
1753
					CLog::logf(CLog::Log_Install, 1, "Removed unused file: %s", f->GetFilePointer().c_str());
1753
					CLog::logf(CLog::Log_Install, 1, "Removed unused file: %s", f->GetFilePointer().c_str());
1754
					// if a fake patch, we need to shufle
1754
					// if a fake patch, we need to shufle
1755
					if ( f->IsFakePatch() )
1755
					if ( f->IsFakePatch() )
1756
						shuffle = true;
1756
						shuffle = true;
1757
					else if ( f->IsAutoTextFile() )
1757
					else if ( f->isAutoTextFile() )
1758
						shuffle = true;
1758
						shuffle = true;
1759
				}
1759
				}
1760
			}
1760
			}
1761
 
1761
 
1762
			fnode = fnode->next();
1762
			fnode = fnode->next();
Line 1889... Line 1889...
1889
			m_lNonRemovedFiles.PushBack(f->GetFilePointer());
1889
			m_lNonRemovedFiles.PushBack(f->GetFilePointer());
1890
 
1890
 
1891
		// check for fake patchs
1891
		// check for fake patchs
1892
		if ( f->IsFakePatch() )
1892
		if ( f->IsFakePatch() )
1893
			shuffle = true;
1893
			shuffle = true;
1894
		else if ( f->IsAutoTextFile() )
1894
		else if ( f->isAutoTextFile() )
1895
			shuffle = true;
1895
			shuffle = true;
1896
 
1896
 
1897
		// remove the file from the main list as swell
1897
		// remove the file from the main list as swell
1898
		m_lFiles.remove(f, false);
1898
		m_lFiles.remove(f, false);
1899
		delete f;
1899
		delete f;
Line 3241... Line 3241...
3241
			{
3241
			{
3242
				newFilename = Utils::String(m_sCurrentDir.ToString()) + "/PluginManager/Disabled/FakePatches/FakePatch_" + checkPackage->GetNameValidFile().ToString() + "_" + checkPackage->author() + "_" + f->GetName().ToString();
3242
				newFilename = Utils::String(m_sCurrentDir.ToString()) + "/PluginManager/Disabled/FakePatches/FakePatch_" + checkPackage->GetNameValidFile().ToString() + "_" + checkPackage->author() + "_" + f->GetName().ToString();
3243
				shuffle = true;
3243
				shuffle = true;
3244
			}
3244
			}
3245
		}
3245
		}
3246
		else if ( f->IsAutoTextFile() )
3246
		else if ( f->isAutoTextFile() )
3247
		{
3247
		{
3248
			if ( checkPackage )
3248
			if ( checkPackage )
3249
			{
3249
			{
3250
				newFilename = Utils::String(m_sCurrentDir.ToString()) + "/PluginManager/Disabled/TextFiles/Text_" + checkPackage->GetNameValidFile().ToString() + "_" + checkPackage->author() + "_" + f->GetName().ToString();
3250
				newFilename = Utils::String(m_sCurrentDir.ToString()) + "/PluginManager/Disabled/TextFiles/Text_" + checkPackage->GetNameValidFile().ToString() + "_" + checkPackage->author() + "_" + f->GetName().ToString();
3251
				shuffle = true;
3251
				shuffle = true;
Line 4010... Line 4010...
4010
 
4010
 
4011
		if ( f->GetFileType() != FILETYPE_TEXT )
4011
		if ( f->GetFileType() != FILETYPE_TEXT )
4012
			continue;
4012
			continue;
4013
 
4013
 
4014
		// check if the file is an auto text file
4014
		// check if the file is an auto text file
4015
		if ( !f->IsAutoTextFile() )
4015
		if ( !f->isAutoTextFile() )
4016
			continue;
4016
			continue;
4017
 
4017
 
4018
		// we need to rename it
4018
		// we need to rename it
4019
		int current = FindNextTextFile();
4019
		int current = findNextTextFile();
4020
		if ( current < f->GetTextFileID() )
4020
		if ( current < f->GetTextFileID() )
4021
		{
4021
		{
4022
			CFileIO moveFile(f->GetFilePointer());
4022
			CFileIO moveFile(f->filePointer());
4023
	
4023
	
4024
			CyString newName = SPK::FormatTextName(current, m_iLanguage, (m_iGameFlags & EXEFLAG_TCTEXT)) + "." + moveFile.GetFileExtension();
4024
			Utils::String newName = SPK::FormatTextName(current, m_iLanguage, (m_iGameFlags & EXEFLAG_TCTEXT)) + "." + moveFile.extension();
4025
			if ( moveFile.Rename(m_sCurrentDir + "/t/" + newName) )
4025
			if ( moveFile.Rename(m_sCurrentDir + "/t/" + newName) )
4026
			{
4026
			{
4027
				this->AddLogEntry(SPKINSTALL_AUTOTEXT, f->GetName() + "~" + newName, errors);
4027
				this->AddLogEntry(SPKINSTALL_AUTOTEXT, f->name() + "~" + newName, errors);
4028
				f->SetName(newName);
4028
				f->SetName(newName);
4029
			}
4029
			}
4030
			else
4030
			else
4031
				this->AddLogEntry(SPKINSTALL_AUTOTEXT_FAIL, f->GetName() + "~" + newName, errors);
4031
				this->AddLogEntry(SPKINSTALL_AUTOTEXT_FAIL, f->name() + "~" + newName, errors);
4032
		}
4032
		}
4033
	}
4033
	}
4034
}
4034
}
4035
 
4035
 
4036
/**
4036
/**
Line 4358... Line 4358...
4358
}
4358
}
4359
 
4359
 
4360
/**
4360
/**
4361
 * Find next text file
4361
 * Find next text file
4362
 *
4362
 *
4363
 * Searching for the next gap in automatic text files, start with 0003-LXXX or XX0003
4363
 * Searching for the next gap in automatic text files, start with 0004-LXXX or XX0004
4364
 */
4364
 */
4365
int CPackages::FindNextTextFile(int start, CyString dir)
4365
unsigned int CPackages::findNextTextFile(unsigned int start) const
-
 
4366
{
-
 
4367
	return findNextTextFile(Utils::String::Null(), start);
-
 
4368
}
-
 
4369
unsigned int CPackages::findNextTextFile(const Utils::String &dir, unsigned int start) const
4366
{
4370
{
4367
	int check = start;
4371
	int check = start;
4368
	if ( check < 2 ) check = 2;
4372
	if ( check < 2 ) check = 2;
4369
	while ( check < 9999 )
4373
	while ( check < 9999 )
4370
	{
4374
	{
4371
		++check;
4375
		++check;
4372
		Utils::String newFilename = SPK::FormatTextName(check, m_iLanguage, (m_iGameFlags & EXEFLAG_TCTEXT)).ToString();
4376
		Utils::String newFilename = SPK::FormatTextName(check, m_iLanguage, (m_iGameFlags & EXEFLAG_TCTEXT));
4373
 
4377
 
4374
		// check the vfs
4378
		// check the vfs
4375
		if ( m_pGameVFS.isFileAvailable("t/" + newFilename + ".pck") ) continue;
4379
		if ( m_pGameVFS.isFileAvailable("t/" + newFilename + ".pck") ) continue;
4376
		if ( m_pGameVFS.isFileAvailable("t/" + newFilename + ".xml") ) continue;
4380
		if ( m_pGameVFS.isFileAvailable("t/" + newFilename + ".xml") ) continue;
4377
 
4381
 
Line 4388... Line 4392...
4388
 
4392
 
4389
	int check = start;
4393
	int check = start;
4390
	while ( check < 9999 )
4394
	while ( check < 9999 )
4391
	{
4395
	{
4392
		++check;
4396
		++check;
4393
		Utils::String newFilename = SPK::FormatTextName(check, m_iLanguage, (m_iGameFlags & EXEFLAG_TCTEXT)).ToString();
4397
		Utils::String newFilename = SPK::FormatTextName(check, m_iLanguage, (m_iGameFlags & EXEFLAG_TCTEXT));
4394
 
4398
 
4395
		// check if a packed file exists
4399
		// check if a packed file exists
4396
		if ( !Dir.exists(newFilename + ".pck") )
4400
		if ( !Dir.exists(newFilename + ".pck") )
4397
		{
4401
		{
4398
			// it doen't, check if theres an unpacked file
4402
			// it doen't, check if theres an unpacked file
Line 4545... Line 4549...
4545
 * Creates a new text file and copies an existing one
4549
 * Creates a new text file and copies an existing one
4546
 */
4550
 */
4547
bool CPackages::RenameTextFile(CyString textid, int languageid, CyStringList *errors)
4551
bool CPackages::RenameTextFile(CyString textid, int languageid, CyStringList *errors)
4548
{
4552
{
4549
	// lets check if the file already exists
4553
	// lets check if the file already exists
4550
	CyString newFilename = SPK::FormatTextName(textid.ToInt(), m_iLanguage, (m_iGameFlags & EXEFLAG_TCTEXT));
4554
	Utils::String newFilename = SPK::FormatTextName(textid.ToInt(), m_iLanguage, (m_iGameFlags & EXEFLAG_TCTEXT));
4551
	C_File *addFile = FindFile(FILETYPE_TEXT, newFilename + ".xml");
4555
	C_File *addFile = FindFile(FILETYPE_TEXT, newFilename + ".xml");
4552
	if ( !addFile )
4556
	if ( !addFile )
4553
		addFile = FindFile(FILETYPE_TEXT, newFilename + ".pck");
4557
		addFile = FindFile(FILETYPE_TEXT, newFilename + ".pck");
4554
 
4558
 
4555
	// we have found the file, lets just add it to our scripts
4559
	// we have found the file, lets just add it to our scripts
Line 4558... Line 4562...
4558
		AddTextFileToScripts(addFile, textid);
4562
		AddTextFileToScripts(addFile, textid);
4559
		return true;
4563
		return true;
4560
	}
4564
	}
4561
 
4565
 
4562
	// first we need to find our text file
4566
	// first we need to find our text file
4563
	CyString filename;
4567
	Utils::String filename;
4564
	if ( languageid != -1 )
4568
	if ( languageid != -1 )
4565
		filename = SPK::FormatTextName(textid.ToInt(), languageid, (m_iGameFlags & EXEFLAG_TCTEXT));
4569
		filename = SPK::FormatTextName(textid.ToInt(), languageid, (m_iGameFlags & EXEFLAG_TCTEXT));
4566
	else
4570
	else
4567
		filename = textid;
4571
		filename = textid.ToString();
4568
 
4572
 
4569
	C_File *textFile = FindFile(FILETYPE_TEXT, filename + ".xml");
4573
	C_File *textFile = FindFile(FILETYPE_TEXT, filename + ".xml");
4570
	if ( !textFile )
4574
	if ( !textFile )
4571
	{
4575
	{
4572
		textFile = FindFile(FILETYPE_TEXT, filename + ".pck");
4576
		textFile = FindFile(FILETYPE_TEXT, filename + ".pck");
Line 4600... Line 4604...
4600
	}
4604
	}
4601
 
4605
 
4602
	for(std::vector<CyString>::iterator it = frontLines.begin(); it != frontLines.end(); ++it)
4606
	for(std::vector<CyString>::iterator it = frontLines.begin(); it != frontLines.end(); ++it)
4603
		lines->insert(lines->begin(), *it);
4607
		lines->insert(lines->begin(), *it);
4604
 
4608
 
4605
	addFile = new C_File(newFilename.ToString() + ".xml");
4609
	addFile = new C_File(newFilename + ".xml");
4606
	addFile->SetFileType(FILETYPE_TEXT);
4610
	addFile->SetFileType(FILETYPE_TEXT);
4607
 
4611
 
4608
	CFileIO writeFile(m_sCurrentDir + "/" + addFile->GetNameDirectory(NULL));
4612
	CFileIO writeFile(m_sCurrentDir + "/" + addFile->GetNameDirectory(NULL));
4609
	if ( writeFile.WriteFile(lines) )
4613
	if ( writeFile.WriteFile(lines) )
4610
	{
4614
	{