Subversion Repositories spk

Rev

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

Rev 126 Rev 127
Line 249... Line 249...
249
			continue;
249
			continue;
250
		if ( f->GetName() != file->GetName () )
250
		if ( f->GetName() != file->GetName () )
251
			continue;
251
			continue;
252
		if ( f->GetDir() != file->GetDir() )
252
		if ( f->GetDir() != file->GetDir() )
253
			continue;
253
			continue;
254
		if ( f->GetGame() != file->GetGame() )
254
		if ( f->game() != file->game() )
255
			continue;
255
			continue;
256
 
256
 
257
		m_lFiles.remove(node, true);
257
		m_lFiles.remove(node, true);
258
		break;
258
		break;
259
	}
259
	}
260
 
260
 
261
	_addFile(file);
261
	_addFile(file);
262
}
262
}
263
 
263
 
264
C_File *CBaseFile::AddFile ( CyString file, CyString dir, int type, int game )
264
C_File *CBaseFile::AddFile(CyString file, CyString dir, int type, int game)
265
{
265
{
-
 
266
	return addFile(file.ToString(), dir.ToString(), (FileType)type, game);
-
 
267
}
-
 
268
C_File *CBaseFile::addFile(const Utils::String &file, const Utils::String &dir, FileType type, int game)
-
 
269
{
266
	C_File *newfile = new C_File ( file );
270
	C_File *newfile = new C_File(file);
267
	newfile->SetDir ( dir );
271
	newfile->SetDir(dir);
268
	newfile->SetFileType ( type );
272
	newfile->SetFileType(type);
269
	newfile->SetGame(game);
273
	newfile->setGame(game);
270
 
274
 
271
	// first check if the file already exists
275
	// first check if the file already exists
272
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
276
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
273
	{
277
	{
274
		C_File *f = node->Data();
278
		C_File *f = node->Data();
Line 276... Line 280...
276
			continue;
280
			continue;
277
		if ( f->GetName() != newfile->GetName () )
281
		if ( f->GetName() != newfile->GetName () )
278
			continue;
282
			continue;
279
		if ( f->GetDir() != newfile->GetDir() )
283
		if ( f->GetDir() != newfile->GetDir() )
280
			continue;
284
			continue;
281
		if ( f->GetGame() != newfile->GetGame() )
285
		if ( f->game() != newfile->game() )
282
			continue;
286
			continue;
283
 
287
 
284
		// must already exist, delete this one
288
		// must already exist, delete this one
285
		m_lFiles.remove(node, true);
289
		m_lFiles.remove(node, true);
286
		break;
290
		break;
Line 360... Line 364...
360
 
364
 
361
		if ( type != f->GetFileType() )
365
		if ( type != f->GetFileType() )
362
			continue;
366
			continue;
363
		if ( dir != f->GetDir() )
367
		if ( dir != f->GetDir() )
364
			continue;
368
			continue;
365
		if ( game != f->GetGame() )
369
		if ( game != f->game() )
366
			continue;
370
			continue;
367
		if ( f->GetName().ToLower() == lfile )
371
		if ( f->GetName().ToLower() == lfile )
368
			return f;
372
			return f;
369
	}
373
	}
370
	return NULL;
374
	return NULL;
Line 481... Line 485...
481
		bool uncomprToFile = false;
485
		bool uncomprToFile = false;
482
 
486
 
483
		if ( progress )
487
		if ( progress )
484
			progress->SwitchSecond();
488
			progress->SwitchSecond();
485
 
489
 
486
		if ( !fit->UncompressData ( progress ) )
490
		if(!fit->isExternalFile())
487
		{
491
		{
488
			if ( fit->GetCompressionType() == SPKCOMPRESS_7ZIP )
492
			if (!fit->UncompressData(progress))
489
			{
493
			{
490
				if ( !fit->UncompressToFile ( "temp", this, false, progress ) )
494
				if (fit->GetCompressionType() == SPKCOMPRESS_7ZIP)
491
					return false;
-
 
492
				else
-
 
493
				{
495
				{
-
 
496
					if (!fit->UncompressToFile("temp", this, false, progress))
-
 
497
						return false;
-
 
498
					else
-
 
499
					{
494
					uncomprToFile = true;
500
						uncomprToFile = true;
495
					fit->SetFullDir ( "temp" );
501
						fit->SetFullDir("temp");
-
 
502
					}
496
				}
503
				}
497
			}
-
 
498
 
504
 
499
			if ( !uncomprToFile )
505
				if (!uncomprToFile)
500
				return false;
506
					return false;
-
 
507
			}
501
		}
508
		}
502
 
509
 
503
		if ( progress )
510
		if ( progress )
504
			progress->SwitchSecond();
511
			progress->SwitchSecond();
505
	}
512
	}
Line 955... Line 962...
955
		C_File checkfile;
962
		C_File checkfile;
956
		CyString checkfilename = sDestination;
963
		CyString checkfilename = sDestination;
957
		if ( !checkfilename.Empty() ) checkfilename += "/";
964
		if ( !checkfilename.Empty() ) checkfilename += "/";
958
		checkfilename += pFile->GetNameDirectory(this);
965
		checkfilename += pFile->GetNameDirectory(this);
959
		checkfile.SetFilename ( checkfilename );
966
		checkfile.SetFilename ( checkfilename );
960
		checkfile.SetFileType ( pFile->GetFileType() );
967
		checkfile.setFileType(pFile->fileType());
961
		if ( checkfile.CheckValidFilePointer() ) {
968
		if ( checkfile.CheckValidFilePointer() ) {
962
			if ( checkfile.ReadScriptVersion() > pFile->GetVersion() ) {
969
			if ( checkfile.ReadScriptVersion() > pFile->GetVersion() ) {
963
				CLog::log(CLog::Log_Install, 1, "Newer version of the file found in directory, skipping");
970
				CLog::log(CLog::Log_Install, 1, "Newer version of the file found in directory, skipping");
964
				return false;
971
				return false;
965
			}
972
			}
Line 1460... Line 1467...
1460
	Func:   ParseFilesLine
1467
	Func:   ParseFilesLine
1461
	Input:  String - single line from a file to set
1468
	Input:  String - single line from a file to set
1462
	Return: Boolean - returns true if value exists
1469
	Return: Boolean - returns true if value exists
1463
	Desc:   Reads the line and assigns the parameters for the file
1470
	Desc:   Reads the line and assigns the parameters for the file
1464
*/
1471
*/
1465
bool CBaseFile::ParseFilesLine ( CyString line )
1472
bool CBaseFile::ParseFilesLine ( CyString sLine )
1466
{
1473
{
-
 
1474
	Utils::String line = sLine.ToString();
-
 
1475
 
1467
	if ( !line.IsIn(":") )
1476
	if ( !line.contains(":") )
1468
		return false;
1477
		return false;
1469
 
1478
 
1470
	CyString command = line.GetToken ( 1, ':' );
1479
	Utils::String command = line.token(":", 1);
1471
 
1480
 
1472
	long size = line.GetToken ( 2, ':').ToInt ();
1481
	long size = line.token(":", 2).toInt();
1473
	long usize = line.GetToken ( 3, ':').ToInt ();
1482
	long usize = line.token(":", 3).toInt ();
1474
	long compression = line.GetToken ( 4, ':').ToInt ();
1483
	long compression = line.token(":", 4).toInt ();
1475
 
1484
 
1476
	if ( command == "Icon" )
1485
	if ( command == "Icon" )
1477
	{
1486
	{
1478
		m_sIconExt = line.GetToken ( 5, ':' );
1487
		m_sIconExt = line.token (":", 5);
1479
		m_pIconFile = new C_File ();
1488
		m_pIconFile = new C_File ();
1480
		m_pIconFile->SetDataSize ( size - 4 );
1489
		m_pIconFile->SetDataSize ( size - 4 );
1481
		m_pIconFile->SetDataCompression ( compression );
1490
		m_pIconFile->SetDataCompression ( compression );
1482
		m_pIconFile->SetUncompressedDataSize ( usize );
1491
		m_pIconFile->SetUncompressedDataSize ( usize );
1483
 
1492
 
1484
		return true;
1493
		return true;
1485
	}
1494
	}
1486
 
1495
 
1487
	time_t time = line.GetToken ( 5,':' ).ToLong();
1496
	time_t time = line.token(":", 5).toLong();
1488
	bool compressToFile = (line.GetToken ( 6, ':').ToInt() == 1) ? true : false;
1497
	bool compressToFile = (line.token(":", 6).toInt() == 1) ? true : false;
1489
	CyString name  = line.GetToken ( 7, ':' );
1498
	Utils::String name  = line.token(":", 7);
1490
	CyString dir = line.GetToken ( 8, ':' );
1499
	Utils::String dir = line.token(":", 8);
1491
 
1500
 
1492
	if ( name.Empty() )
1501
	if ( name.empty() )
1493
		return true;
1502
		return true;
1494
 
1503
 
1495
	bool shared = false;
1504
	bool shared = false;
1496
	if ( command.Left(1) == "$" )
1505
	if ( command.left(1) == "$" )
1497
	{
1506
	{
1498
		shared = true;
1507
		shared = true;
1499
		command.Erase ( 0, 1 );
1508
		command.erase(0, 1);
1500
	}
1509
	}
1501
 
1510
 
1502
	int type = -1;
1511
	FileType type = FILETYPE_UNKNOWN;
1503
	if ( command == "Script" )
1512
	if ( command == "Script" )
1504
		type = FILETYPE_SCRIPT;
1513
		type = FILETYPE_SCRIPT;
1505
	else if ( command == "Text" )
1514
	else if ( command == "Text" )
1506
		type = FILETYPE_TEXT;
1515
		type = FILETYPE_TEXT;
1507
	else if ( command == "Readme" )
1516
	else if ( command == "Readme" )
Line 1531... Line 1540...
1531
	else if ( command == "ShipOther" )
1540
	else if ( command == "ShipOther" )
1532
		type = FILETYPE_SHIPOTHER;
1541
		type = FILETYPE_SHIPOTHER;
1533
	else if ( command == "ShipModel" )
1542
	else if ( command == "ShipModel" )
1534
		type = FILETYPE_SHIPMODEL;
1543
		type = FILETYPE_SHIPMODEL;
1535
 
1544
 
1536
	if ( type == -1 )
1545
	if (type == FILETYPE_UNKNOWN)
1537
		return false;
1546
		return false;
1538
 
1547
 
1539
	C_File *file = new C_File ();
1548
	C_File *file = new C_File();
1540
 
1549
 
1541
	if ( dir.Left(5).Compare("GAME_") ) {
1550
	if (dir.left(5).Compare("GAME_")) {
1542
		file->SetGame(dir.GetToken("_", 2, 2).ToInt());
1551
		file->setGame(1 << 31 | 1 << dir.token("_", 2).toInt());
1543
		dir = NullString;
1552
		dir = Utils::String::Null();
1544
	} 
1553
	} 
1545
	else if ( line.NumToken(":") >= 9 ) {
1554
	else if ( line.countToken(":") >= 9 ) 
-
 
1555
	{
-
 
1556
		Utils::String game = line.token(":", 9);
-
 
1557
		if (game.contains("_"))
1546
		file->SetGame(line.GetToken(":", 9, 9).GetToken("_", 2, 2).ToInt());
1558
			file->setGame(1 << 31 | 1 << game.token("_", 2).toInt());
-
 
1559
		else
-
 
1560
		{
-
 
1561
			int iGame = game.toInt();
-
 
1562
			if (iGame & (1 << 31))
-
 
1563
				file->setGame(iGame);
-
 
1564
			else
-
 
1565
				file->setGame(1 << 31 | 1 << iGame);
-
 
1566
		}
1547
	}
1567
	}
1548
 
1568
 
-
 
1569
	if (dir.Compare("NULL")) {
-
 
1570
		dir = Utils::String::Null();
-
 
1571
	}
-
 
1572
 
1549
	file->SetFileType ( type );
1573
	file->setFileType(type);
1550
	file->SetCreationTime ( time );
1574
	file->SetCreationTime ( time );
1551
	file->SetName ( name );
1575
	file->SetName ( name );
1552
	file->SetDir ( dir );
1576
	file->SetDir ( dir );
1553
	file->SetDataSize ( size - 4 );
1577
	file->SetDataSize ( size - 4 );
1554
	file->SetDataCompression ( compression );
1578
	file->SetDataCompression ( compression );
Line 2253... Line 2277...
2253
 
2277
 
2254
	if ( !version.empty() )	this->AddNeededLibrary("<package>", "<author>", version);
2278
	if ( !version.empty() )	this->AddNeededLibrary("<package>", "<author>", version);
2255
}
2279
}
2256
 
2280
 
2257
 
2281
 
2258
bool CBaseFile::GeneratePackagerScript(bool wildcard, Utils::CStringList *list, int game, bool datafile)
2282
bool CBaseFile::GeneratePackagerScript(bool wildcard, Utils::CStringList *list, int game, const Utils::CStringList &gameAddons, bool datafile)
2259
{
2283
{
2260
	list->pushBack("#");
2284
	list->pushBack("#");
2261
	list->pushBack("# Packager Script");
2285
	list->pushBack("# Packager Script");
2262
	list->pushBack("# -- Generated by SPK Libraries V" + Utils::String::FromFloat(GetLibraryVersion(), 2) + " --");
2286
	list->pushBack("# -- Generated by SPK Libraries V" + Utils::String::FromFloat(GetLibraryVersion(), 2) + " --");
2263
	list->pushBack("#");
2287
	list->pushBack("#");
Line 2423... Line 2447...
2423
	list->pushBack("");
2447
	list->pushBack("");
2424
 
2448
 
2425
	return true;
2449
	return true;
2426
}
2450
}
2427
 
2451
 
2428
bool CBaseFile::GeneratePackagerScriptFile(bool wildcard, Utils::CStringList *list, int game)
2452
bool CBaseFile::GeneratePackagerScriptFile(bool wildcard, Utils::CStringList *list, int game, const Utils::CStringList &gameAddons)
2429
{
2453
{
2430
	// now do files and wildcards
2454
	// now do files and wildcards
2431
	Utils::CStringList files;
2455
	Utils::CStringList files;
2432
	for ( CListNode<C_File> *f = m_lFiles.Front(); f; f = f->next() )
2456
	for ( CListNode<C_File> *f = m_lFiles.Front(); f; f = f->next() )
2433
	{
2457
	{
2434
		if (game && f->Data()->GetGame() != game)
2458
		if (game && !(f->Data()->game() & 1 << game))
2435
			continue;
2459
			continue;
2436
 
2460
 
2437
		Utils::String name = "$GAMEDIR/";
2461
		Utils::String name = "$GAMEDIR/";
2438
 
2462
 
-
 
2463
		// addon directory?
-
 
2464
		unsigned int checkGame = f->Data()->game() & ~(1 << 31);
-
 
2465
		unsigned int foundGame = 0;
-
 
2466
		for (int i = 0; i < 31; ++i)
-
 
2467
		{
-
 
2468
			if (checkGame == 1 << i)
-
 
2469
			{
-
 
2470
				foundGame = i;
-
 
2471
				break;
-
 
2472
			}
-
 
2473
		}
-
 
2474
 
-
 
2475
		if (foundGame)
-
 
2476
		{
-
 
2477
			Utils::String str = gameAddons.findString(Utils::String::Number(foundGame));
-
 
2478
			if(!str.empty())
-
 
2479
				name += str + "/";
-
 
2480
		}
-
 
2481
 
2439
		bool done = false;
2482
		bool done = false;
2440
		if ( wildcard )
2483
		if ( wildcard )
2441
		{
2484
		{
2442
			Utils::String base = f->Data()->GetBaseName().ToString();
2485
			Utils::String base = f->Data()->GetBaseName().ToString();
2443
			if ( f->Data()->GetFileType() == FILETYPE_SCRIPT )
2486
			if ( f->Data()->GetFileType() == FILETYPE_SCRIPT )
Line 2474... Line 2517...
2474
		if ( !f->Data()->GetDir().Empty() )
2517
		if ( !f->Data()->GetDir().Empty() )
2475
		{
2518
		{
2476
			name += "|";
2519
			name += "|";
2477
			name += f->Data()->GetDir().ToString();
2520
			name += f->Data()->GetDir().ToString();
2478
		}
2521
		}
-
 
2522
		Utils::String s = "GAME ";
-
 
2523
		if (!f->Data()->game() || f->Data()->game() == GAME_ALLNEW)
2479
		Utils::String s = "GAME " + CBaseFile::ConvertGameToString(f->Data()->GetGame()) + " " + name;
2524
			s += CBaseFile::ConvertGameToString(f->Data()->game());
-
 
2525
		else
-
 
2526
		{
-
 
2527
			bool first = true;
-
 
2528
			for (int i = 0; i < 31; ++i) 
-
 
2529
			{
-
 
2530
				if (f->Data()->game() & 1 << i)
-
 
2531
				{
-
 
2532
					if (first)
-
 
2533
						first = false;
-
 
2534
					else
-
 
2535
						s += "|";
-
 
2536
					s += CBaseFile::ConvertGameToString(i);
-
 
2537
				}
-
 
2538
			}
-
 
2539
		}
-
 
2540
 
-
 
2541
		s += " " + name;
2480
		if(!files.contains(s))
2542
		if(!files.contains(s))
2481
			files.pushBack(s, f->Data()->GetFileTypeString().ToString());
2543
			files.pushBack(s, f->Data()->GetFileTypeString().ToString());
2482
	}
2544
	}
2483
 
2545
 
2484
 
2546
 
Line 2577... Line 2639...
2577
	else
2639
	else
2578
		Found->iVersion = version;
2640
		Found->iVersion = version;
2579
	_changed();
2641
	_changed();
2580
}
2642
}
2581
 
2643
 
2582
bool CBaseFile::LoadPackageData(const Utils::String &sFirst, const Utils::String &sRest, const Utils::String &sMainGame, Utils::CStringList &otherGames)
2644
bool CBaseFile::LoadPackageData(const Utils::String &sFirst, const Utils::String &sRest, const Utils::String &sMainGame, Utils::CStringList &otherGames, Utils::CStringList &gameAddons)
2583
{
2645
{
2584
	if ( sFirst.Compare("Name") )					this->setName(sRest);
2646
	if ( sFirst.Compare("Name") )					this->setName(sRest);
2585
	else if ( sFirst.Compare("Author") )			this->setAuthor(sRest);
2647
	else if ( sFirst.Compare("Author") )			this->setAuthor(sRest);
2586
	else if ( sFirst.Compare("ScriptName") )
2648
	else if ( sFirst.Compare("ScriptName") )
2587
		AddLanguageName(ParseLanguage(sRest.token(" ", 1)), sRest.tokens(" ", 2));
2649
		AddLanguageName(ParseLanguage(sRest.token(" ", 1)), sRest.tokens(" ", 2));
Line 2683... Line 2745...
2683
			checkType = sFirst.right(-6);
2745
			checkType = sFirst.right(-6);
2684
			shared = true;
2746
			shared = true;
2685
		}
2747
		}
2686
 
2748
 
2687
		// now check type name
2749
		// now check type name
2688
		int filetype = GetFileTypeFromString(checkType);
2750
		FileType filetype = GetFileTypeFromString(checkType);
2689
		if ( filetype != -1 )
2751
		if (filetype != FILETYPE_UNKNOWN)
2690
			this->AddFileScript(filetype, shared, sRest, sMainGame, otherGames);
2752
			this->AddFileScript(filetype, shared, sRest, sMainGame, otherGames, gameAddons);
2691
		else if ( !checkType.Compare("changelog") )
2753
		else if ( !checkType.Compare("changelog") )
2692
			return false;
2754
			return false;
2693
	}
2755
	}
2694
 
2756
 
2695
	return true;
2757
	return true;
2696
}
2758
}
2697
 
2759
 
2698
void CBaseFile::AddFileScript(int filetype, bool shared, CyString rest, const Utils::String &sMainGame, Utils::CStringList &otherGames)
2760
void CBaseFile::AddFileScript(FileType filetype, bool shared, CyString sRest, const Utils::String &sMainGame, Utils::CStringList &otherGames, Utils::CStringList &gameAddons)
2699
{
2761
{
2700
	CyString dir;
2762
	Utils::String dir;
2701
	if ( rest.IsIn("|") )
-
 
2702
	{
-
 
2703
		dir = rest.GetToken("|", 2);
2763
	Utils::String rest = sRest.ToString();
2704
		rest = rest.GetToken("|", 1, 1);
-
 
2705
	}
-
 
2706
 
2764
 
2707
	int mainGame = CBaseFile::GetGameFromString(sMainGame);
2765
	unsigned int mainGame = CBaseFile::GetGameFromString(sMainGame);
-
 
2766
	unsigned int game = 0;
-
 
2767
	if ( rest.token(" ", 1).left(4).Compare("GAME") ) {
-
 
2768
		Utils::String gameStr = rest.token(" ", 2);
-
 
2769
		if (gameStr.contains("|"))
-
 
2770
		{
-
 
2771
			int max = 0;
-
 
2772
			Utils::String *games = gameStr.tokenise("|", &max);
-
 
2773
			for (int i = 0; i < max; ++i)
-
 
2774
			{
-
 
2775
				unsigned int g = CBaseFile::GetGameFromString(games[i]);
-
 
2776
				if (g)
-
 
2777
					game |= 1 << g;
-
 
2778
			}
-
 
2779
			CLEANSPLIT(games, max);
-
 
2780
		}
-
 
2781
		else
-
 
2782
			game = 1 << CBaseFile::GetGameFromString(gameStr);
-
 
2783
		rest = rest.tokens(" ", 3);
-
 
2784
	}
-
 
2785
	if (game)
-
 
2786
		game |= 1 << 31;
2708
 
2787
 
2709
	int game = 0;
2788
	if (rest.contains("|"))
-
 
2789
	{
2710
	if ( rest.GetToken(" ", 1, 1).Left(4).Compare("GAME") ) {
2790
		dir = rest.tokens("|", 2);
2711
		game = CBaseFile::GetGameFromString(rest.GetToken(" ", 2, 2).ToString());
-
 
2712
		rest = rest.GetToken(" ", 3);
2791
		rest = rest.token("|", 1);
2713
	}
2792
	}
2714
 
2793
 
2715
	rest = rest.FindReplace("\\", "/");
2794
	rest = rest.findReplace("\\", "/");
2716
 
2795
 
2717
	// wild cards
2796
	// wild cards
2718
	if ( rest.IsAnyIn("*?") )
2797
	if ( rest.containsAny("*?") )
2719
	{
2798
	{
2720
		CDirIO Dir(CFileIO(rest).dir());
2799
		CDirIO Dir(CFileIO(rest).dir());
2721
		CyStringList *dirList = Dir.DirList();
2800
		CyStringList *dirList = Dir.DirList();
2722
		if ( dirList )
2801
		if ( dirList )
2723
		{
2802
		{
2724
			for ( SStringList *strNode = dirList->Head(); strNode; strNode = strNode->next )
2803
			for ( SStringList *strNode = dirList->Head(); strNode; strNode = strNode->next )
2725
			{
2804
			{
2726
				CyString file = Dir.File(strNode->str);
2805
				Utils::String file = Dir.file(strNode->str.ToString());
2727
				if ( file.WildMatch(rest) )
2806
				if (file.match(rest))
2728
				{
2807
				{
2729
					int addGame = game;
2808
					int addGame = game;
2730
					// check if the file exists in the subdirectory too, if it does, add for each game
2809
					// check if the file exists in the subdirectory too, if it does, add for each game
2731
					if ( game == GAME_ALL && !sMainGame.empty() && !otherGames.empty() ) {
2810
					if ( game == GAME_ALL && !sMainGame.empty() && !otherGames.empty() ) {
2732
						CFileIO F(file);
2811
						CFileIO F(file);
Line 2748... Line 2827...
2748
			delete dirList;
2827
			delete dirList;
2749
		}
2828
		}
2750
	}
2829
	}
2751
	else
2830
	else
2752
	{
2831
	{
2753
		int addGame = game;
2832
		unsigned int addGame = game;
2754
		// check if the file exists in the subdirectory too, if it does, add for each game
2833
		// check if the file exists in the subdirectory too, if it does, add for each game
2755
		if ( game == GAME_ALL && !sMainGame.empty() && !otherGames.empty() ) {
2834
		if ( game == GAME_ALL && !sMainGame.empty() && !otherGames.empty() ) {
2756
			CFileIO F(rest);
2835
			CFileIO F(rest);
2757
			for(Utils::String g = otherGames.firstString(); !g.empty(); g = otherGames.nextString()) {
2836
			for(Utils::String g = otherGames.firstString(); !g.empty(); g = otherGames.nextString()) {
2758
				Utils::String checkDir = F.dir() + "/" + g;
2837
				Utils::String checkDir = F.dir() + "/" + g;
Line 2762... Line 2841...
2762
					if ( newfile ) newfile->SetShared(shared);
2841
					if ( newfile ) newfile->SetShared(shared);
2763
				}
2842
				}
2764
			}
2843
			}
2765
		}
2844
		}
2766
 
2845
 
-
 
2846
		unsigned int checkGame = addGame & ~(1 << 31);
-
 
2847
		unsigned int foundGame = 0;
-
 
2848
		for (int i = 0; i < 31; ++i)
-
 
2849
		{
-
 
2850
			if (1 << i == checkGame)
-
 
2851
			{
-
 
2852
				foundGame = i;
-
 
2853
				break;
-
 
2854
			}
-
 
2855
		}
-
 
2856
 
-
 
2857
		C_File *file = NULL;
-
 
2858
		if (foundGame)
-
 
2859
		{
-
 
2860
			Utils::String addon = gameAddons.findString(Utils::String::Number(foundGame));
-
 
2861
			if (!addon.empty())
-
 
2862
			{
-
 
2863
				Utils::String dir = C_File::GetDirectory(filetype, rest, this);
-
 
2864
				Utils::String filename = rest;
-
 
2865
				if (CCatFile::IsAddonDir(dir))
-
 
2866
					filename = filename.findReplace(dir + "/", addon + "/" + dir + "/");
-
 
2867
 
-
 
2868
				file = this->AppendFile(filename, filetype, addGame, dir);
-
 
2869
			}
-
 
2870
		}
-
 
2871
 
-
 
2872
		if(!file)
2767
		C_File *file = this->AppendFile(rest, filetype, addGame, dir);
2873
			file = this->AppendFile(rest, filetype, addGame, dir);
-
 
2874
 
2768
		if ( file )
2875
		if (file)
2769
			file->SetShared(shared);
2876
			file->SetShared(shared);
2770
	}
2877
	}
2771
}
2878
}
2772
 
2879
 
2773
 
2880
 
Line 2974... Line 3081...
2974
	}
3081
	}
2975
 
3082
 
2976
	for (CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next())
3083
	for (CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next())
2977
	{
3084
	{
2978
		if (game != -1) {
3085
		if (game != -1) {
2979
			if (game && node->Data()->GetGame() && node->Data()->GetGame() != game)
3086
			if (game && !(node->Data()->game() & (1 << game)))
2980
				continue;
3087
				continue;
-
 
3088
			// extracting for all games, so ignore files that have a game set
2981
			if (!game && node->Data()->GetGame())
3089
			if (!game && node->Data()->game() && node->Data()->game() != GAME_ALLNEW)
2982
				continue;
3090
				continue;
2983
		}
3091
		}
2984
		Utils::String fname = node->Data()->GetNameDirectory(this).ToString();
3092
		Utils::String fname = node->Data()->GetNameDirectory(this).ToString();
2985
 
3093
 
2986
		// use the addon directory
3094
		// use the addon directory
2987
		if (node->Data()->isFileInAddon() && exes)
3095
		if (node->Data()->isFileInAddon() && exes)
2988
		{
3096
		{
2989
			int whatGame = game;
3097
			unsigned int whatGame = game;
2990
			if (game == -1)
3098
			if (game == -1)
-
 
3099
			{
2991
				whatGame = node->Data()->GetGame();
3100
				unsigned int checkGame = node->Data()->game() & ~GAME_ALLNEW;
-
 
3101
				whatGame = 0;
-
 
3102
				for (int i = 0; i < 31; ++i)
-
 
3103
				{
-
 
3104
					if (1 << i == checkGame)
-
 
3105
					{
-
 
3106
						whatGame = i;
-
 
3107
						break;
-
 
3108
					}
-
 
3109
				}
-
 
3110
			}
2992
 
3111
 
2993
			SGameExe *e = exes->GetGame(whatGame - 1);
-
 
2994
			if (e)
3112
			if (whatGame > 0)
2995
			{
3113
			{
-
 
3114
				SGameExe *e = exes->GetGame(whatGame - 1);
-
 
3115
				if (e)
-
 
3116
				{
2996
				if (e->iFlags & EXEFLAG_ADDON)
3117
					if (e->iFlags & EXEFLAG_ADDON)
2997
					fname = e->sAddon + "/" + fname;
3118
						fname = e->sAddon + "/" + fname;
-
 
3119
				}
2998
			}
3120
			}
2999
		}
3121
		}
3000
 
3122
 
3001
		// create the directory
3123
		// create the directory
3002
		wsprintf(buf, L"%hs", fname.c_str());
3124
		wsprintf(buf, L"%hs", fname.c_str());
-
 
3125
		if (node->Data()->isExternalFile())
-
 
3126
		{
-
 
3127
			CFileIO file(node->Data()->filePointer());
-
 
3128
			size_t size = 0;
-
 
3129
			unsigned char *data = file.readAll(&size);
-
 
3130
			ZipAdd(hz, buf, data, size);
-
 
3131
			delete data;
-
 
3132
		}
-
 
3133
		else
3003
		ZipAdd(hz, buf, node->Data()->GetData(), node->Data()->GetDataSize());
3134
			ZipAdd(hz, buf, node->Data()->GetData(), node->Data()->GetDataSize());
3004
	}
3135
	}
3005
 
3136
 
3006
	// if its a ship, then add any generated files
3137
	// if its a ship, then add any generated files
3007
	this->addGeneratedFiles(hz);
3138
	this->addGeneratedFiles(hz);
3008
 
3139
 
3009
	// add the data file
3140
	// add the data file
3010
	Utils::CStringList list;
3141
	Utils::CStringList list;
-
 
3142
	Utils::CStringList addons;
3011
	if ( this->GeneratePackagerScript(false, &list, game, true) )
3143
	if ( this->GeneratePackagerScript(false, &list, game, addons, true) )
3012
	{
3144
	{
3013
		if ( CFileIO("test.tmp").writeFile(&list) )
3145
		if ( CFileIO("test.tmp").writeFile(&list) )
3014
		{
3146
		{
3015
			ZipAdd(hz, L"pluginmanager.txt", L"test.tmp");
3147
			ZipAdd(hz, L"pluginmanager.txt", L"test.tmp");
3016
			CFileIO::Remove("test.tmp");
3148
			CFileIO::Remove("test.tmp");
Line 3035... Line 3167...
3035
		iGame = GAME_X3TC;
3167
		iGame = GAME_X3TC;
3036
	else if (sGame.Compare("X3AP"))
3168
	else if (sGame.Compare("X3AP"))
3037
		iGame = GAME_X3AP;
3169
		iGame = GAME_X3AP;
3038
	else if (sGame.Compare("X3FL"))
3170
	else if (sGame.Compare("X3FL"))
3039
		iGame = GAME_X3FL;
3171
		iGame = GAME_X3FL;
3040
	else if ( sGame.Compare("XREBIRTH") )
-
 
3041
		iGame = GAME_XREBIRTH;
-
 
3042
	else if ( sGame.isNumber() )
3172
	else if ( sGame.isNumber() )
3043
		iGame = sGame;
3173
		iGame = sGame;
3044
 
3174
 
3045
	return iGame;
3175
	return iGame;
3046
}
3176
}
Line 3049... Line 3179...
3049
{
3179
{
3050
	Utils::String game = "ALL";
3180
	Utils::String game = "ALL";
3051
 
3181
 
3052
	switch(iGame) {
3182
	switch(iGame) {
3053
		case GAME_ALL:
3183
		case GAME_ALL:
-
 
3184
		case GAME_ALLNEW:
3054
			game = "ALL";
3185
			game = "ALL";
3055
			break;
3186
			break;
3056
		case GAME_X2:
3187
		case GAME_X2:
3057
			game = "X2";
3188
			game = "X2";
3058
			break;
3189
			break;
Line 3066... Line 3197...
3066
			game = "X3AP";
3197
			game = "X3AP";
3067
			break;
3198
			break;
3068
		case GAME_X3FL:
3199
		case GAME_X3FL:
3069
			game = "X3FL";
3200
			game = "X3FL";
3070
			break;
3201
			break;
3071
		case GAME_XREBIRTH:
-
 
3072
			game = "XREBIRTH";
-
 
3073
			break;
-
 
3074
		default:
3202
		default:
3075
			game = (long)iGame;
3203
			game = (long)iGame;
3076
	}
3204
	}
3077
 
3205
 
3078
	return game;
3206
	return game;