Subversion Repositories spk

Rev

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

Rev 127 Rev 160
Line 308... Line 308...
308
 
308
 
309
Utils::String CGameExe::GetGameBaseName(const Utils::String &gameExe) const
309
Utils::String CGameExe::GetGameBaseName(const Utils::String &gameExe) const
310
{
310
{
311
	int gameType = this->GetGameType(gameExe);
311
	int gameType = this->GetGameType(gameExe);
312
	Utils::String gameDir = this->GetProperDir(gameExe);
312
	Utils::String gameDir = this->GetProperDir(gameExe);
313
	Utils::String gameName = this->ExtractGameName(gameDir);
313
	Utils::String gameName = this->extractGameName(gameDir);
314
	if (gameName.empty())	gameName = this->GetGameNameFromType(gameType);
314
	if (gameName.empty())	gameName = this->GetGameNameFromType(gameType);
315
 
315
 
316
	return gameName;
316
	return gameName;
317
}
317
}
318
 
318
 
Line 532... Line 532...
532
	}
532
	}
533
 
533
 
534
	return -1;
534
	return -1;
535
}
535
}
536
 
536
 
537
Utils::String CGameExe::ExtractGameName(const Utils::String &gameDir) const
537
Utils::String CGameExe::extractGameName(const Utils::String &gameDir, Utils::String *extra) const
538
{
538
{
539
	Utils::String dir = this->GetProperDir(gameDir);
539
	Utils::String dir = this->GetProperDir(gameDir);
540
	CDirIO Dir(dir);
540
	CDirIO Dir(dir);
541
 
541
 
542
	Utils::String sText = this->_extractTextData(this->_readTextFile(dir), 1910, 1216, this->getTextID(gameDir));
542
	Utils::String sText = this->_extractTextData(this->_readTextFile(dir), 1910, 1216, this->getTextID(gameDir));
543
	if ( sText.empty() ) return "";
543
	if ( sText.empty() ) return "";
544
	int end = sText.findPos("\\n");
544
	int end = sText.findPos("\\n");
-
 
545
	if (end >= 0)
-
 
546
	{
545
	if ( end >= 0 ) return sText.left(end);
547
		sText = sText.left(end);
-
 
548
		sText = sText.findReplace("\\(", "(").findReplace("\\)", ")");
-
 
549
 
-
 
550
		if (sText.contains("(") && sText.contains(")"))
-
 
551
		{
-
 
552
			int pos = sText.findPos("(");
-
 
553
			int endPos;
-
 
554
			for (endPos = sText.length() - 1; endPos > pos; pos--)
-
 
555
			{
-
 
556
				if (sText[endPos] == ')')
-
 
557
					break;
-
 
558
			}
-
 
559
			Utils::String e = sText.substr(pos, endPos);
-
 
560
			sText = sText.findRemove(e).removeEndSpace();
-
 
561
			if (extra)
-
 
562
				(*extra) = e.mid(1, -1);
-
 
563
		}
-
 
564
 
-
 
565
		return sText;
-
 
566
	}
546
 
567
 
547
	return "";
568
	return "";
548
}
569
}
549
 
570
 
550
Utils::String CGameExe::_textFileName(const Utils::String &sGameDir) const
571
Utils::String CGameExe::_textFileName(const Utils::String &sGameDir) const
Line 570... Line 591...
570
	if ( !textFileName.empty() )
591
	if ( !textFileName.empty() )
571
	{
592
	{
572
		Utils::String sVersion;
593
		Utils::String sVersion;
573
 
594
 
574
		CDirIO Dir(sGameDir);
595
		CDirIO Dir(sGameDir);
575
		CFileIO File(Dir.File(textFileName));
596
		CFileIO File(Dir.file(textFileName));
576
		size_t fileSize;
597
		size_t fileSize;
577
		unsigned char *fileData = File.readAll(&fileSize);
598
		unsigned char *fileData = File.readAll(&fileSize);
578
		if ( fileData && fileSize) 
599
		if ( fileData && fileSize) 
579
		{
600
		{
580
			if (CFileIO(textFileName).isFileExtension("pck"))
601
			if (CFileIO(textFileName).isFileExtension("pck"))