Subversion Repositories spk

Rev

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

Rev 217 Rev 218
Line 1265... Line 1265...
1265
		case SPKFILE_INVALID:
1265
		case SPKFILE_INVALID:
1266
			// convert xsp
1266
			// convert xsp
1267
			if ( CFileIO(file).isFileExtension(L"xsp") )
1267
			if ( CFileIO(file).isFileExtension(L"xsp") )
1268
			{
1268
			{
1269
				installFile = new CXspFile();
1269
				installFile = new CXspFile();
1270
				if ( !((CXspFile *)installFile)->ConvertOld(file.toString()) )
1270
				if ( !((CXspFile *)installFile)->convertOld(file) )
1271
				{
1271
				{
1272
					delete installFile;
1272
					delete installFile;
1273
					return NULL;
1273
					return NULL;
1274
				}
1274
				}
1275
				break;
1275
				break;
1276
			}
1276
			}
1277
			*error = INSTALLERR_INVALID;
1277
			*error = INSTALLERR_INVALID;
1278
			return NULL;
1278
			return NULL;
1279
		case SPKFILE_BASE:
1279
		case SPKFILE_BASE:
1280
			installFile = new CBaseFile();
1280
			installFile = new CBaseFile();
1281
			if ( !installFile->readFile(file.toString(), readtype, progress))
1281
			if ( !installFile->readFile(file, readtype, progress))
1282
			{
1282
			{
1283
				delete installFile;
1283
				delete installFile;
1284
				return NULL;
1284
				return NULL;
1285
			}
1285
			}
1286
			break;
1286
			break;
1287
		case SPKFILE_SINGLE:
1287
		case SPKFILE_SINGLE:
1288
			installFile = new CSpkFile();
1288
			installFile = new CSpkFile();
1289
			if ( !((CSpkFile *)installFile)->readFile(file.toString(), readtype, progress))
1289
			if ( !((CSpkFile *)installFile)->readFile(file, readtype, progress))
1290
			{
1290
			{
1291
				delete installFile;
1291
				delete installFile;
1292
				return NULL;
1292
				return NULL;
1293
			}
1293
			}
1294
			break;
1294
			break;
1295
		case SPKFILE_MULTI:
1295
		case SPKFILE_MULTI:
1296
			*error = INSTALLERR_NOMULTI;
1296
			*error = INSTALLERR_NOMULTI;
1297
			return NULL;
1297
			return NULL;
1298
		case SPKFILE_SINGLESHIP:
1298
		case SPKFILE_SINGLESHIP:
1299
			installFile = new CXspFile();
1299
			installFile = new CXspFile();
1300
			if ( !((CXspFile *)installFile)->readFile(file.toString(), readtype, progress))
1300
			if ( !((CXspFile *)installFile)->readFile(file, readtype, progress))
1301
			{
1301
			{
1302
				delete installFile;
1302
				delete installFile;
1303
				return NULL;
1303
				return NULL;
1304
			}
1304
			}
1305
			break;
1305
			break;
Line 2291... Line 2291...
2291
	}
2291
	}
2292
	return L't';
2292
	return L't';
2293
}
2293
}
2294
int CPackages::ConvertWareType(wchar_t w)
2294
int CPackages::ConvertWareType(wchar_t w)
2295
{
2295
{
2296
	switch ( LOWER(w) )
2296
	switch (std::tolower(w))
2297
	{
2297
	{
2298
		case L'b':
2298
		case L'b':
2299
			return WARES_BIO;
2299
			return WARES_BIO;
2300
		case L'e':
2300
		case L'e':
2301
			return WARES_ENERGY;
2301
			return WARES_ENERGY;
Line 5292... Line 5292...
5292
			continue;
5292
			continue;
5293
 
5293
 
5294
		// lets extract the ware file
5294
		// lets extract the ware file
5295
		wchar_t wareType = CPackages::ConvertWareTypeBack(i);
5295
		wchar_t wareType = CPackages::ConvertWareTypeBack(i);
5296
		Utils::WString wareFile = L"TWare";
5296
		Utils::WString wareFile = L"TWare";
5297
		wareFile += (wchar_t)UPPER(wareType);
5297
		wareFile += (wchar_t)std::toupper(wareType);
5298
 
5298
 
5299
		Utils::WString openFile;
5299
		Utils::WString openFile;
5300
 
5300
 
5301
		int e;
5301
		int e;
5302
		if ( i == WARES_TECH && CFileIO::Exists(m_sTempDir + L"/TWareT.txt") )
5302
		if ( i == WARES_TECH && CFileIO::Exists(m_sTempDir + L"/TWareT.txt") )
Line 6470... Line 6470...
6470
	}
6470
	}
6471
 
6471
 
6472
	if ( !found )
6472
	if ( !found )
6473
		return;
6473
		return;
6474
 
6474
 
6475
	Utils::CStringList aniList;
6475
	Utils::WStringList aniList;
6476
	int e = extractGameFile(L"types/Animations.pck", m_sTempDir + L"/Animations.txt");
6476
	int e = extractGameFile(L"types/Animations.pck", m_sTempDir + L"/Animations.txt");
6477
	if ( e )
6477
	if ( e )
6478
	{
6478
	{
6479
		CFileIO File;
6479
		CFileIO File;
6480
		if ( File.open((e == -1) ? L"Animations.txt" : m_sTempDir + L"/Animations.txt") )
6480
		if ( File.open((e == -1) ? L"Animations.txt" : m_sTempDir + L"/Animations.txt") )
Line 6491... Line 6491...
6491
 
6491
 
6492
			File.remove();
6492
			File.remove();
6493
		}
6493
		}
6494
	}
6494
	}
6495
 
6495
 
6496
	Utils::CStringList parsedAniList;
6496
	Utils::WStringList parsedAniList;
6497
	CXspFile::ReadAnimations(aniList, parsedAniList, 0);
6497
	CXspFile::ReadAnimations(aniList, parsedAniList, 0);
6498
 
6498
 
6499
	for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
6499
	for ( CListNode<SGameShip> *node = m_lGameShips.Front(); node; node = node->next() )
6500
	{
6500
	{
6501
		SGameShip *s = node->Data();
6501
		SGameShip *s = node->Data();
Line 6510... Line 6510...
6510
		for(auto itr = s->pPackage->getAnimations().begin(); itr != s->pPackage->getAnimations().end(); itr++)
6510
		for(auto itr = s->pPackage->getAnimations().begin(); itr != s->pPackage->getAnimations().end(); itr++)
6511
			parsedAniList.pushBack((*itr)->str.toString());
6511
			parsedAniList.pushBack((*itr)->str.toString());
6512
	}
6512
	}
6513
 
6513
 
6514
	// format the list with added spaces
6514
	// format the list with added spaces
6515
	Utils::CStringList formatedAniList;
6515
	Utils::WStringList formatedAniList;
6516
	int lineCount = -1;
6516
	int lineCount = -1;
6517
	for(auto itr = parsedAniList.begin(); itr != parsedAniList.end(); itr++)
6517
	for(auto itr = parsedAniList.begin(); itr != parsedAniList.end(); itr++)
6518
	{
6518
	{
6519
		// format the comment to match the line number
6519
		// format the comment to match the line number
6520
		lineCount++;
6520
		lineCount++;
6521
		Utils::String oldComment = (*itr)->str.tokens("//", 2);
6521
		Utils::WString oldComment = (*itr)->str.tokens(L"//", 2);
6522
		Utils::String comment = "//" + Utils::String::Number(lineCount);
6522
		Utils::WString comment = L"//" + Utils::WString::Number(lineCount);
6523
		if (!oldComment.empty())
6523
		if (!oldComment.empty())
6524
		{
6524
		{
6525
			comment += " ";
6525
			comment += L" ";
6526
			oldComment.removeFirstSpace();
6526
			oldComment.removeFirstSpace();
6527
			if ( oldComment.token(" ", 1).isNumber() )
6527
			if ( oldComment.token(L" ", 1).isNumber() )
6528
				comment += oldComment.tokens(" ", 2);
6528
				comment += oldComment.tokens(L" ", 2);
6529
			else
6529
			else
6530
				comment += oldComment;
6530
				comment += oldComment;
6531
		}
6531
		}
6532
		Utils::String line = (*itr)->str.token("//", 1);
6532
		Utils::WString line = (*itr)->str.token(L"//", 1);
6533
 
6533
 
6534
		// split into seperate lines
6534
		// split into seperate lines
6535
		Utils::String first = line.token(";", 1);
6535
		Utils::WString first = line.token(L";", 1);
6536
		if ( first.Compare("TAT_TAGSINGLESTEP") )
6536
		if ( first.Compare(L"TAT_TAGSINGLESTEP") )
6537
		{
6537
		{
6538
			formatedAniList.pushBack(line.tokens(";", 1, 5) + ";");
6538
			formatedAniList.pushBack(line.tokens(L";", 1, 5) + L";");
6539
			int max;
6539
			std::vector<Utils::WString> sLines;
6540
			Utils::String *sLines = line.tokens(";", 6).tokenise(";&quot;, &max);
6540
			if(line.tokens(L";", 6).tokenise(L";&quot;, sLines))
6541
			if ( max && sLines )
-
 
6542
			{
6541
			{
-
 
6542
				size_t max = sLines.size();
6543
				if ( sLines[max - 1].empty() )
6543
				if ( sLines[max - 1].empty() )
6544
					--max; // remove the last ";"
6544
					--max; // remove the last ";"
6545
 
6545
 
6546
				for ( int i = 0; i < max; i++ )
6546
				for (size_t i = 0; i < max; i++ )
6547
				{
6547
				{
6548
					Utils::String l = "\t" + sLines[i] + ";";
6548
					Utils::WString l = L"\t" + sLines[i] + L";";
6549
					if ( i == (max - 1) )
6549
					if ( i == (max - 1) )
6550
						formatedAniList.pushBack(l + comment);
6550
						formatedAniList.pushBack(l + comment);
6551
					else
6551
					else
6552
						formatedAniList.pushBack(l);
6552
						formatedAniList.pushBack(l);
6553
				}
6553
				}
6554
			}
6554
			}
6555
			CLEANSPLIT(sLines, max);
-
 
6556
		}
6555
		}
6557
		else if ( (first.Compare("TAT_TAGONESHOT") || first.Compare("TAT_TAGLOOP")) && (line.contains("TATF_COORDS")) )
6556
		else if ( (first.Compare(L"TAT_TAGONESHOT") || first.Compare(L"TAT_TAGLOOP")) && (line.contains(L"TATF_COORDS")) )
6558
		{
6557
		{
6559
			formatedAniList.pushBack(line.tokens(";", 1, 5) + ";");
6558
			formatedAniList.pushBack(line.tokens(L";", 1, 5) + L";");
6560
			int max;
6559
			std::vector<Utils::WString> sLines;
6561
			Utils::String *sLines = line.tokens(";", 6).tokenise(";&quot;, &max);
6560
			if (line.tokens(L";", 6).tokenise(L";&quot;, sLines))
6562
			if ( max && sLines )
-
 
6563
			{
6561
			{
-
 
6562
				size_t max = sLines.size();
6564
				if ( sLines[max - 1].empty() )
6563
				if ( sLines[max - 1].empty() )
6565
					--max; // remove the last ";"
6564
					--max; // remove the last ";"
6566
 
6565
 
6567
				Utils::String prevLine;
6566
				Utils::WString prevLine;
6568
				for ( int i = 0; i < max; i++ )
6567
				for (size_t i = 0; i < max; i++ )
6569
				{
6568
				{
6570
					Utils::String l = sLines[i] + ";";
6569
					Utils::WString l = sLines[i] + L";";
6571
					if ( l.contains("TATF_COORDS") && !prevLine.empty() )
6570
					if ( l.contains(L"TATF_COORDS") && !prevLine.empty() )
6572
					{
6571
					{
6573
						formatedAniList.pushBack("\t" + prevLine);
6572
						formatedAniList.pushBack(L"\t" + prevLine);
6574
						prevLine = "";
6573
						prevLine = L"";
6575
					}
6574
					}
6576
					prevLine += l;
6575
					prevLine += l;
6577
				}
6576
				}
6578
 
6577
 
6579
				if ( !prevLine.empty() )
6578
				if ( !prevLine.empty() )
6580
					formatedAniList.pushBack("\t" + prevLine + comment);
6579
					formatedAniList.pushBack(L"\t" + prevLine + comment);
6581
 
6580
 
6582
			}
6581
			}
6583
			CLEANSPLIT(sLines, max);
-
 
6584
		}
6582
		}
6585
		else
6583
		else
6586
			formatedAniList.pushBack(line + comment);
6584
			formatedAniList.pushBack(line + comment);
6587
	}
6585
	}
6588
 
6586
 
6589
	formatedAniList.pushFront(Utils::String::Number(parsedAniList.size()) + ";");
6587
	formatedAniList.pushFront(Utils::WString::Number(parsedAniList.size()) + L";");
6590
	formatedAniList.pushFront("// Animations, created by SPK Libraries V" + Utils::String::FromFloat(GetLibraryVersion(), 2));
6588
	formatedAniList.pushFront(L"// Animations, created by SPK Libraries V" + Utils::WString::FromFloat(GetLibraryVersion(), 2));
6591
 
6589
 
6592
	// write the file to disk
6590
	// write the file to disk
6593
	CFileIO WriteFile(m_sTempDir + L"/Animations.txt");
6591
	CFileIO WriteFile(m_sTempDir + L"/Animations.txt");
6594
	if ( WriteFile.writeFile(&formatedAniList) )
6592
	if ( WriteFile.writeFile(&formatedAniList) )
6595
	{
6593
	{