Subversion Repositories spk

Rev

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

Rev 196 Rev 197
Line 19... Line 19...
19
#include <windows.h>
19
#include <windows.h>
20
#include <direct.h>
20
#include <direct.h>
21
#include <shlobj.h>
21
#include <shlobj.h>
22
#endif
22
#endif
23
 
23
 
24
CyString g_dir;
24
Utils::WString g_dir;
25
bool g_read;
25
bool g_read;
26
 
26
 
27
class CFileProgress : public CProgressInfo
27
class CFileProgress : public CProgressInfo
28
{
28
{
29
private:
29
private:
Line 44... Line 44...
44
	void ProgressUpdated(const long cur, const long max)
44
	void ProgressUpdated(const long cur, const long max)
45
	{
45
	{
46
	}
46
	}
47
	void DoingFile(C_File *file)
47
	void DoingFile(C_File *file)
48
	{
48
	{
49
		Utils::String game;
49
		Utils::WString game;
50
 
50
 
51
		if (!file->game() || file->game() == GAME_ALLNEW)
51
		if (!file->game() || file->game() == GAME_ALLNEW)
52
			game = "All Games";
52
			game = L"All Games";
53
		else if (_packages)
53
		else if (_packages)
54
		{
54
		{
55
			for (unsigned int i = 0; i < 31; ++i)
55
			for (unsigned int i = 0; i < 31; ++i)
56
			{
56
			{
57
				if (file->game() & (1 << i))
57
				if (file->game() & (1 << i))
58
				{
58
				{
59
					Utils::String g = _packages->GetGameExe()->GetGameNameFromType(i - 1);
59
					Utils::WString g = _packages->GetGameExe()->gameNameFromType(i - 1);
60
					if (!g.empty())
60
					if (!g.empty())
61
					{
61
					{
62
						if (game.empty())
62
						if (game.empty())
63
							game = g;
63
							game = g;
64
						else
64
						else
65
							game = game + ", " + g;
65
							game = game + L", " + g;
66
					}
66
					}
67
				}
67
				}
68
			}
68
			}
69
		}
69
		}
70
 
70
 
71
		if(game.empty())
71
		if(game.empty())
72
			printf("%s: %s\n", _display.c_str(), file->getNameDirectory(_package).c_str());
72
			wprintf(L"%hs: %s\n", _display.c_str(), file->getNameDirectory(_package).c_str());
73
		else
73
		else
74
			printf("%s: %s [%s]\n", _display.c_str(), file->getNameDirectory(_package).c_str(), game.c_str());
74
			wprintf(L"%hs: %s [%s]\n", _display.c_str(), file->getNameDirectory(_package).c_str(), game.c_str());
75
	}
75
	}
76
 
76
 
77
};
77
};
78
 
78
 
79
/*
79
/*
80
	Func:	GetInput
80
	Func:	GetInput
81
	Desc:	Gets an input from the user, ie, any settings required to be typed in
81
	Desc:	Gets an input from the user, ie, any settings required to be typed in
82
*/
82
*/
83
Utils::String GetInput ()
83
Utils::WString GetInput ()
84
{
84
{
85
	g_read = true;
85
	g_read = true;
86
 
86
 
87
	Utils::String line;
87
	Utils::String line;
88
	char c = getchar();
88
	char c = getchar();
Line 91... Line 91...
91
	{
91
	{
92
		line += c;
92
		line += c;
93
		c = getchar();
93
		c = getchar();
94
	}
94
	}
95
 
95
 
96
	return line;
96
	return line.toWString();
97
}
97
}
98
 
98
 
99
 
99
 
100
/*
100
/*
101
	Func:	PrintSyntax
101
	Func:	PrintSyntax
Line 218... Line 218...
218
	}
218
	}
219
	else
219
	else
220
		printf ( "File, %s, is not a valid SPK file\n", filename.c_str() );
220
		printf ( "File, %s, is not a valid SPK file\n", filename.c_str() );
221
}
221
}
222
 
222
 
223
Utils::String GetTerranConflictDir()
223
Utils::WString GetTerranConflictDir()
224
{
224
{
225
	while ( true )
225
	while ( true )
226
	{
226
	{
227
		printf ( "\nPlease enter the directory for terran conflict: ");
227
		printf ( "\nPlease enter the directory for terran conflict: ");
228
		Utils::String dir = GetInput();
228
		Utils::WString dir = GetInput();
229
		if ( dir.empty() )
229
		if ( dir.empty() )
230
			return Utils::String::Null();
230
			return Utils::WString::Null();
231
 
231
 
232
		// check if the directory exists
232
		// check if the directory exists
233
		if ( CFileIO::Exists(dir + "/x3tc.exe") )
233
		if ( CFileIO::Exists(dir + L"/x3tc.exe") )
234
			return dir;
234
			return dir;
235
		printf("\nTerran Conflict installation doesn't exist: %s\n\n", dir.c_str());
235
		wprintf(L"\nTerran Conflict installation doesn't exist: %s\n\n", dir.c_str());
236
	}
236
	}
237
 
237
 
238
	return Utils::String::Null();
238
	return Utils::WString::Null();
239
}
239
}
240
 
240
 
241
void ConvertXsp(const Utils::String &filename, const Utils::String &tofile, bool wizard)
241
void ConvertXsp(const Utils::String &filename, const Utils::String &tofile, bool wizard)
242
{
242
{
243
	// first chekc if file even exists
243
	// first chekc if file even exists
Line 261... Line 261...
261
			return;
261
			return;
262
		}
262
		}
263
 
263
 
264
		printf ( "[DONE]\n");
264
		printf ( "[DONE]\n");
265
 
265
 
266
		CyString dir;
266
		Utils::WString dir;
267
		printf ("Do you want to create weapon masks for Terran conflict? ");
267
		printf ("Do you want to create weapon masks for Terran conflict? ");
268
		CyString input = GetInput();
268
		Utils::WString input = GetInput();
269
		if ( input.Compare("y") || input.Compare("yes") )
269
		if ( input.Compare(L"y") || input.Compare(L"yes") )
270
		{
270
		{
271
			dir = GetTerranConflictDir();
271
			dir = GetTerranConflictDir();
272
			if ( !dir.Empty() )
272
			if (!dir.empty())
273
			{
273
			{
274
			}
274
			}
275
		}
275
		}
276
 
276
 
277
		printf ( "* Writing XSP File, %s... ", tofile.c_str() );
277
		printf ( "* Writing XSP File, %s... ", tofile.c_str() );
Line 283... Line 283...
283
	}
283
	}
284
	else
284
	else
285
		printf ( "Error: File, %s, is not an old style XSP file\n", filename.c_str() );
285
		printf ( "Error: File, %s, is not an old style XSP file\n", filename.c_str() );
286
}
286
}
287
 
287
 
288
void ExtractShip(const Utils::String &catfile, const Utils::String &to, Utils::String shipid)
288
void ExtractShip(const Utils::String &catfile, const Utils::String &to, Utils::WString shipid)
289
{
289
{
290
	if ( !CFileIO::Exists(catfile) )
290
	if ( !CFileIO::Exists(catfile) )
291
	{
291
	{
292
		printf ( "Error: Mod File, %s, does not exist\n", catfile.c_str() );
292
		printf ( "Error: Mod File, %s, does not exist\n", catfile.c_str() );
293
		return;
293
		return;
Line 298... Line 298...
298
		printf("Error: Unable to read mod file, %s\n", catfile.c_str());
298
		printf("Error: Unable to read mod file, %s\n", catfile.c_str());
299
		delete pVfs;
299
		delete pVfs;
300
		return;
300
		return;
301
	}
301
	}
302
 
302
 
303
	Utils::CStringList *ships = pVfs->getTShipsEntries();
303
	Utils::WStringList *ships = pVfs->getTShipsEntries();
304
	if ( !ships )
304
	if ( !ships )
305
	{
305
	{
306
		printf("Error: Failed to read %s::types\\TShips.pck\n", catfile.c_str());
306
		printf("Error: Failed to read %s::types\\TShips.pck\n", catfile.c_str());
307
		delete pVfs;
307
		delete pVfs;
308
		return;
308
		return;
309
	}
309
	}
310
 
310
 
311
	// now get the ship line to extract
311
	// now get the ship line to extract
312
	Utils::String tShipsLine;
312
	Utils::WString tShipsLine;
313
	if (shipid.empty())
313
	if (shipid.empty())
314
	{
314
	{
315
		// no ship id, lets get one
315
		// no ship id, lets get one
316
		Utils::String ids[2];
316
		Utils::WString ids[2];
317
		int i = 0;
317
		int i = 0;
318
		int id = 0;
318
		int id = 0;
319
		for ( Utils::SStringList *str = ships->first(); str; str = ships->next() )
319
		for ( Utils::WStringNode *str = ships->first(); str; str = ships->next() )
320
		{
320
		{
321
			ids[i++] = str->data;
321
			ids[i++] = str->data;
322
			if ( i >= 2 )
322
			if ( i >= 2 )
323
			{
323
			{
324
				printf("[%3d][%30s]\t[%3d][%30s]\n", id - 1, ids[0].c_str(), id, ids[1].c_str());
324
				wprintf(L"[%3d][%30s]\t[%3d][%30s]\n", id - 1, ids[0].c_str(), id, ids[1].c_str());
325
				for ( i = 0; i < 2; i++ )
325
				for ( i = 0; i < 2; i++ )
326
					ids[i] = "";
326
					ids[i] = L"";
327
				i = 0;
327
				i = 0;
328
			}
328
			}
329
			++id;
329
			++id;
330
		}
330
		}
331
		if ( i == 1 )
331
		if ( i == 1 )
332
			printf("[%3d][%30s]\n", id, ids[0].c_str());
332
			wprintf(L"[%3d][%30s]\n", id, ids[0].c_str());
333
		printf("Enter ID to use > ");
333
		printf("Enter ID to use > ");
334
		shipid = GetInput();
334
		shipid = GetInput();
335
 
335
 
336
		if ( shipid.isNumber() )
336
		if ( shipid.isNumber() )
337
			tShipsLine = ships->get(shipid.toInt())->str;
337
			tShipsLine = ships->get(shipid.toInt())->str;
Line 341... Line 341...
341
	else
341
	else
342
		ships->findData(shipid, true);
342
		ships->findData(shipid, true);
343
 
343
 
344
	if ( tShipsLine.empty() )
344
	if ( tShipsLine.empty() )
345
	{
345
	{
346
		printf("Error, %s is not a valid ship id to use\n", shipid.c_str());
346
		wprintf(L"Error, %s is not a valid ship id to use\n", shipid.c_str());
347
		delete pVfs;
347
		delete pVfs;
348
		return;
348
		return;
349
	}
349
	}
350
 
350
 
351
	// now we have the tships to use, lets start to extract the ship
351
	// now we have the tships to use, lets start to extract the ship
352
	printf("Extracting ship from %s, Ship=%s\n", catfile.c_str(), tShipsLine.token(";", -2).c_str());
352
	wprintf(L"Extracting ship from %hs, Ship=%s\n", catfile.c_str(), tShipsLine.token(L";", -2).c_str());
353
 
353
 
354
	CXspFile ship;
354
	CXspFile ship;
355
	if ( ship.extractShip(pVfs, tShipsLine.token(";", -2), 0) )
355
	if ( ship.extractShip(pVfs, tShipsLine.token(L";", -2).toString(), 0))
356
	{
356
	{
357
		printf ( "Ship has been successfully extracted\n" );
357
		printf ( "Ship has been successfully extracted\n" );
358
 
358
 
359
		printf("\t- Models:\t %d\n", ship.countFiles(FILETYPE_SHIPMODEL));
359
		printf("\t- Models:\t %d\n", ship.countFiles(FILETYPE_SHIPMODEL));
360
		printf("\t- Textures:\t %d\n", ship.countFiles(FILETYPE_SHIPOTHER));
360
		printf("\t- Textures:\t %d\n", ship.countFiles(FILETYPE_SHIPOTHER));
Line 363... Line 363...
363
		printf("\t- Bodies:\t %d\n", ship.getBodies().size());
363
		printf("\t- Bodies:\t %d\n", ship.getBodies().size());
364
		printf("\t- Cockpits:\t %d\n", ship.GetCockpits()->size());
364
		printf("\t- Cockpits:\t %d\n", ship.GetCockpits()->size());
365
		printf("\t- Text Entries:\t %d\n", ship.GetTexts()->size());
365
		printf("\t- Text Entries:\t %d\n", ship.GetTexts()->size());
366
 
366
 
367
		printf("\nEnter the name for the ship: ");
367
		printf("\nEnter the name for the ship: ");
368
		ship.setName(GetInput());
368
		ship.setName(GetInput().toString());
369
		printf("Enter the author for the ship: ");
369
		printf("Enter the author for the ship: ");
370
		ship.setAuthor(GetInput());
370
		ship.setAuthor(GetInput().toString());
371
		printf("Enter the version for the ship: V");
371
		printf("Enter the version for the ship: V");
372
		ship.setVersion(GetInput());
372
		ship.setVersion(GetInput().toString());
373
		printf("Enter the description for the ship: ");
373
		printf("Enter the description for the ship: ");
374
		ship.setDescription(GetInput());
374
		ship.setDescription(GetInput().toString());
375
 
375
 
376
		struct tm   *currDate;
376
		struct tm   *currDate;
377
		char    dateString[100];
377
		char    dateString[100];
378
		time_t now = time(NULL);
378
		time_t now = time(NULL);
379
		currDate = localtime( &now );
379
		currDate = localtime( &now );
Line 503... Line 503...
503
		//for game
503
		//for game
504
		printf("For Games: ");
504
		printf("For Games: ");
505
		if ( !pBaseFile->AnyGameCompatability() )
505
		if ( !pBaseFile->AnyGameCompatability() )
506
			printf("All");
506
			printf("All");
507
		else
507
		else
508
			printf("%s", p.getGameTypesString(pBaseFile, true).c_str());
508
			wprintf(L"%s", p.getGameTypesString(pBaseFile, true).c_str());
509
		printf("\n");
509
		printf("\n");
510
 
510
 
511
		if ( pXspFile )
511
		if ( pXspFile )
512
		{
512
		{
513
			printf ("Ship Display Name: %s\n", pXspFile->GetShipName(44).c_str());
513
			printf ("Ship Display Name: %s\n", pXspFile->GetShipName(44).c_str());
Line 590... Line 590...
590
			if ( !pSpkFile->GetWaresList()->empty() )
590
			if ( !pSpkFile->GetWaresList()->empty() )
591
			{
591
			{
592
				for ( CListNode<SWares> * wNode = pSpkFile->GetWaresList()->Front(); wNode; wNode = wNode->next() )
592
				for ( CListNode<SWares> * wNode = pSpkFile->GetWaresList()->Front(); wNode; wNode = wNode->next() )
593
				{
593
				{
594
					SWares *w = wNode->Data();
594
					SWares *w = wNode->Data();
595
					printf ( "Ware: (%c) %s\n", w->cType, CSpkFile::GetWareText(w, 44).c_str() );
595
					wprintf (L"Ware: (%c) %s\n", w->cType, CSpkFile::GetWareText(w, 44).c_str() );
596
					CyString desc = CSpkFile::GetWareDesc(w, 44);
596
					Utils::WString desc = CSpkFile::GetWareDesc(w, 44);
597
					if ( !desc.Empty() )
597
					if (!desc.empty())
598
						printf ( "\tDescription: %s\n", desc.c_str() );
598
						wprintf(L"\tDescription: %s\n", desc.c_str() );
599
				}
599
				}
600
			}
600
			}
601
		}
601
		}
602
		if ( !pBaseFile->forumLink().empty() ) printf ( "Forum Link: %s\n", pBaseFile->forumLink().c_str() );
602
		if ( !pBaseFile->forumLink().empty() ) printf ( "Forum Link: %s\n", pBaseFile->forumLink().c_str() );
603
		if ( !pBaseFile->webSite().empty() ) printf ( "Web Site Address: %s\n", pBaseFile->webSite().c_str() );
603
		if ( !pBaseFile->webSite().empty() ) printf ( "Web Site Address: %s\n", pBaseFile->webSite().c_str() );
Line 623... Line 623...
623
		}
623
		}
624
		if ( pBaseFile->easeOfUse() != -1 ) printf ( "Ease Of Use Rating: %d\n", pBaseFile->easeOfUse() );
624
		if ( pBaseFile->easeOfUse() != -1 ) printf ( "Ease Of Use Rating: %d\n", pBaseFile->easeOfUse() );
625
		if ( pBaseFile->gameChanging() != -1 ) printf ( "Game Changing Rating: %d\n", pBaseFile->gameChanging() );
625
		if ( pBaseFile->gameChanging() != -1 ) printf ( "Game Changing Rating: %d\n", pBaseFile->gameChanging() );
626
		if ( pBaseFile->recommended() != -1 ) printf ( "Recommendation Rating: %d\n", pBaseFile->recommended() );
626
		if ( pBaseFile->recommended() != -1 ) printf ( "Recommendation Rating: %d\n", pBaseFile->recommended() );
627
		if (pBaseFile->icon())
627
		if (pBaseFile->icon())
628
			printf ( "Icon File Found, Type: %s, Size: %s\n", pBaseFile->iconExt().c_str(), pBaseFile->icon()->dataSizeString().c_str() );
628
			wprintf(L"Icon File Found, Type: %s, Size: %s\n", pBaseFile->iconExt().c_str(), pBaseFile->icon()->dataSizeString().c_str() );
629
 
629
 
630
		if ( pBaseFile->GetFileList()->size() )
630
		if ( pBaseFile->GetFileList()->size() )
631
		{
631
		{
632
			printf("\nListing files in package:\n");
632
			printf("\nListing files in package:\n");
633
			CLinkList<C_File> *list = pBaseFile->GetFileList();
633
			CLinkList<C_File> *list = pBaseFile->GetFileList();
Line 645... Line 645...
645
 
645
 
646
					if (display)
646
					if (display)
647
					{
647
					{
648
						if (heading)
648
						if (heading)
649
						{
649
						{
650
							Utils::String sGame = p.GetGameExe()->GetGameNameFromType(game - 1);
650
							Utils::WString sGame = p.GetGameExe()->gameNameFromType(game - 1);
651
							printf("\tGame: %s\n", sGame.c_str());
651
							wprintf(L"\tGame: %s\n", sGame.c_str());
652
							heading = false;
652
							heading = false;
653
						}
653
						}
654
						printf("\t\t%s (%s) Size: %s\n", file->getNameDirectory(pBaseFile).c_str(), file->fileTypeString().c_str(), file->dataSizeString().c_str());
654
						wprintf(L"\t\t%s (%s) Size: %s\n", file->getNameDirectory(pBaseFile).c_str(), file->fileTypeString().c_str(), file->dataSizeString().c_str());
655
 
655
 
656
					}
656
					}
657
				}
657
				}
658
			}
658
			}
659
 
659
 
Line 680... Line 680...
680
 
680
 
681
		CLinkList<SMultiSpkFile> *list = spkfile.GetFileList();
681
		CLinkList<SMultiSpkFile> *list = spkfile.GetFileList();
682
		for ( SMultiSpkFile *ms = list->First(); ms; ms = list->Next() )
682
		for ( SMultiSpkFile *ms = list->First(); ms; ms = list->Next() )
683
		{
683
		{
684
			printf ( "File, %s:\n", ms->sName.c_str() );
684
			printf ( "File, %s:\n", ms->sName.c_str() );
685
			printf ( "\tSize: %s\n", SPK::GetSizeString (ms->lSize).c_str() );
685
			wprintf(L"\tSize: %s\n", SPK::GetSizeString (ms->lSize).c_str() );
686
			if ( (!ms->sScriptName.empty()) && (!ms->sScriptAuthor.empty()) )
686
			if ( (!ms->sScriptName.empty()) && (!ms->sScriptAuthor.empty()) )
687
				printf ( "\tScript: %s %s by %s\n", ms->sScriptName.c_str(), ms->sScriptVersion.c_str(), ms->sScriptAuthor.c_str() );
687
				printf ( "\tScript: %s %s by %s\n", ms->sScriptName.c_str(), ms->sScriptVersion.c_str(), ms->sScriptAuthor.c_str() );
688
			printf ( "\tDefault Install: " );
688
			printf ( "\tDefault Install: " );
689
			if ( ms->bOn )
689
			if ( ms->bOn )
690
				printf ( "Yes\n" );
690
				printf ( "Yes\n" );
Line 855... Line 855...
855
	fclose ( id );
855
	fclose ( id );
856
	remove ( filename.c_str() );
856
	remove ( filename.c_str() );
857
 
857
 
858
	CMultiSpkFile spkfile;
858
	CMultiSpkFile spkfile;
859
 
859
 
860
	CyString sInput;
860
	Utils::WString sInput;
861
	printf ( "Enter Multi-Spk Package Name: " );
861
	printf ( "Enter Multi-Spk Package Name: " );
862
	spkfile.setName(GetInput());
862
	spkfile.setName(GetInput().toString());
863
 
863
 
864
	while ( true )
864
	while ( true )
865
	{
865
	{
866
		printf ( "\nDo you want users to select scripts to install? (Y/N): " );
866
		printf ( "\nDo you want users to select scripts to install? (Y/N): " );
867
		CyString i = GetInput();
867
		Utils::WString i = GetInput();
868
		i = i.ToUpper();
868
		i = i.upper();
869
		if ( i == "Y" )
869
		if ( i == L"Y" )
870
			spkfile.setSelection(true);
870
			spkfile.setSelection(true);
871
		if ( (i == "Y") || (i == "N") )
871
		if ( (i == L"Y") || (i == L"N") )
872
			break;
872
			break;
873
	}
873
	}
874
 
874
 
875
	while ( true )
875
	while ( true )
876
	{
876
	{
Line 878... Line 878...
878
		sInput = GetInput();
878
		sInput = GetInput();
879
		if ( sInput == "0" )
879
		if ( sInput == "0" )
880
			break;
880
			break;
881
 
881
 
882
		// check if file can be opened
882
		// check if file can be opened
883
		FILE *id2 = fopen ( sInput.c_str(), ";rb+" );
883
		FILE *id2 = fopen ( sInput.toString().c_str(), ";rb+");
884
		if ( !id2 )
884
		if ( !id2 )
885
			printf ( "Error: Unable to open SPK file %s\n", sInput.c_str() );
885
			wprintf(L"Error: Unable to open SPK file %s\n", sInput.c_str() );
886
		else
886
		else
887
		{
887
		{
888
			fclose ( id2 );
888
			fclose ( id2 );
889
			if ( !spkfile.addFile(sInput.ToString()))
889
			if ( !spkfile.addFile(sInput.toString()))
890
				printf ( "Error: Unable to add SPK file to package\n" );
890
				printf ( "Error: Unable to add SPK file to package\n" );
891
			else
891
			else
892
				printf ( "File Added to package (%s)\n", sInput.c_str() );
892
				wprintf(L"File Added to package (%s)\n", sInput.c_str() );
893
		}
893
		}
894
	}
894
	}
895
 
895
 
896
	if ( spkfile.numFiles() < 1 )
896
	if ( spkfile.numFiles() < 1 )
897
		printf ( "\nError: You have added no files, you must add at least one file to create a package\n" );
897
		printf ( "\nError: You have added no files, you must add at least one file to create a package\n" );
Line 928... Line 928...
928
	remove ( filename.c_str() );
928
	remove ( filename.c_str() );
929
 
929
 
930
	CSpkFile spkfile;
930
	CSpkFile spkfile;
931
 
931
 
932
	printf ( "Enter Script Name: " );
932
	printf ( "Enter Script Name: " );
933
	spkfile.setName(GetInput());
933
	spkfile.setName(GetInput().toString());
934
 
934
 
935
	printf ( "Enter Script Author: " );
935
	printf ( "Enter Script Author: " );
936
	spkfile.setAuthor(GetInput());
936
	spkfile.setAuthor(GetInput().toString());
937
 
937
 
938
	printf ( "Enter Script Version: " );
938
	printf ( "Enter Script Version: " );
939
	spkfile.setVersion(GetInput());
939
	spkfile.setVersion(GetInput().toString());
940
 
940
 
941
	printf ( "Enter Script Description: " );
941
	printf ( "Enter Script Description: " );
942
	spkfile.setDescription(GetInput());
942
	spkfile.setDescription(GetInput().toString());
943
 
943
 
944
	struct tm   *currDate;
944
	struct tm   *currDate;
945
	char    dateString[100];
945
	char    dateString[100];
946
	time_t now = time(NULL);
946
	time_t now = time(NULL);
947
 
947
 
Line 992... Line 992...
992
		printf ( "(Done)\n" );
992
		printf ( "(Done)\n" );
993
 
993
 
994
		if(game == 0)
994
		if(game == 0)
995
			printf("Extracting all files from archive...\n\n");
995
			printf("Extracting all files from archive...\n\n");
996
		else
996
		else
997
			printf("Extracting %s files from archive...\n\n", packages.GetGameExe()->GetGameNameFromType(game - 1).c_str());
997
			wprintf(L"Extracting %s files from archive...\n\n", packages.GetGameExe()->gameNameFromType(game - 1).c_str());
998
 
998
 
999
		CFileProgress info(&packages, pBaseFile, "Extracting");
999
		CFileProgress info(&packages, pBaseFile, "Extracting");
1000
		if (packages.extractAll(pBaseFile, dir, game, true, &info) )
1000
		if (packages.extractAll(pBaseFile, dir, game, true, &info) )
1001
			printf ( "\n(Done)\nFiles have been extracted successfully\n" );
1001
			printf ( "\n(Done)\nFiles have been extracted successfully\n" );
1002
		else
1002
		else
Line 1222... Line 1222...
1222
	}
1222
	}
1223
 
1223
 
1224
	printf ( "(Done)\n" );
1224
	printf ( "(Done)\n" );
1225
}
1225
}
1226
 
1226
 
1227
Utils::String GetAsk(const Utils::String &command)
1227
Utils::WString GetAsk(const Utils::WString &command)
1228
{
1228
{
1229
	printf("(ASK) Enter the value for, %s: ", command.c_str());
1229
	wprintf(L"(ASK) Enter the value for, %s: ", command.c_str());
1230
	return GetInput();
1230
	return GetInput();
1231
}
1231
}
1232
 
1232
 
1233
void GenerateUpdateList(int argc, char **argv)
1233
void GenerateUpdateList(int argc, char **argv)
1234
{
1234
{
Line 1301... Line 1301...
1301
			printf("unable to find any packages");
1301
			printf("unable to find any packages");
1302
		else
1302
		else
1303
		{
1303
		{
1304
			CPackages packages;
1304
			CPackages packages;
1305
 
1305
 
1306
			Utils::CStringList filedata;
1306
			Utils::WStringList filedata;
1307
			for (auto itr = fileList.begin(); itr != fileList.end(); itr++)
1307
			for (auto itr = fileList.begin(); itr != fileList.end(); itr++)
1308
			{
1308
			{
1309
				wprintf(L"Reading file: %s\n", (*itr)->str.c_str());
1309
				wprintf(L"Reading file: %s\n", (*itr)->str.c_str());
1310
 
1310
 
1311
				int error = 0;
1311
				int error = 0;
Line 1345... Line 1345...
1345
	{
1345
	{
1346
		wprintf(L"Error: The package file, %s, does not exist", spkfile.c_str());
1346
		wprintf(L"Error: The package file, %s, does not exist", spkfile.c_str());
1347
		return;
1347
		return;
1348
	}
1348
	}
1349
 
1349
 
1350
	int check = CSpkFile::CheckFile(spkfile.toString());
1350
	int check = CSpkFile::CheckFile(spkfile);
1351
	if ( check == SPKFILE_MULTI )
1351
	if ( check == SPKFILE_MULTI )
1352
	{
1352
	{
1353
		printf("Error: Multi-Package files currently not supported\n");
1353
		printf("Error: Multi-Package files currently not supported\n");
1354
		return;
1354
		return;
1355
	}
1355
	}
Line 1433... Line 1433...
1433
		printf("Packager script, %s, has been geenrated\n", toFile.c_str());
1433
		printf("Packager script, %s, has been geenrated\n", toFile.c_str());
1434
	else
1434
	else
1435
		printf("Error: unable to write packager script, %s\n", toFile.c_str());
1435
		printf("Error: unable to write packager script, %s\n", toFile.c_str());
1436
 
1436
 
1437
	delete package;
1437
	delete package;
1438
}
1438
}
1439
 
1439
 
1440
/*
1440
/*
1441
	Func:	LoadPackagerScript
1441
	Func:	LoadPackagerScript
1442
	Args:	String filename	-	The filename of the packager script to load
1442
	Args:	String filename	-	The filename of the packager script to load
1443
	Desc:	Loads the packager scripts and creates a spk/xsp file from it
1443
	Desc:	Loads the packager scripts and creates a spk/xsp file from it
1444
*/
1444
*/
1445
void LoadPackagerScript(const Utils::String &filename, bool verify)
1445
void LoadPackagerScript(const Utils::WString &filename, bool verify)
1446
{
1446
{
1447
	if ( !CFileIO::Exists(filename) )
1447
	if ( !CFileIO::Exists(filename) )
1448
	{
1448
	{
1449
		printf("Error: The packager script, %s, does not exist", filename.c_str());
1449
		wprintf(L"Error: The packager script, %s, does not exist", filename.c_str());
1450
		return;
1450
		return;
1451
	}
1451
	}
1452
 
1452
 
1453
	Utils::String myDoc;
1453
	Utils::WString myDoc;
1454
#ifdef _WIN32
1454
#ifdef _WIN32
1455
	TCHAR pszPath[MAX_PATH];
1455
	TCHAR pszPath[MAX_PATH];
1456
	if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, pszPath)))
1456
	if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, pszPath)))
1457
	{
1457
	{
1458
		myDoc = (char *)pszPath;
1458
		myDoc = (char *)pszPath;
1459
	}
1459
	}
1460
#endif
1460
#endif
1461
 
1461
 
1462
	if ( verify )
1462
	if ( verify )
1463
		printf("Verifying Packager Script: %s\n", filename.c_str());
1463
		wprintf(L"Verifying Packager Script: %s\n", filename.c_str());
1464
 
1464
 
1465
	CPackages p;
1465
	CPackages p;
1466
	p.startup(".", ".", myDoc);
1466
	p.startup(L".", L".", myDoc);
1467
	Utils::CStringList malformed, unknown;
1467
	Utils::WStringList malformed, unknown;
1468
 
1468
 
1469
	Utils::String curDir = CFileIO(filename).dir().toString();
1469
	Utils::WString curDir = CFileIO(filename).dir();
1470
	if ( curDir.empty() ) curDir = L"./";
1470
	if ( curDir.empty() ) curDir = L"./";
1471
 
1471
 
1472
	Utils::CStringList variables;
1472
	Utils::WStringList variables;
1473
	variables.pushBack("$PATH", curDir);
1473
	variables.pushBack(L"$PATH", curDir);
1474
 
1474
 
1475
	CFileProgress info(&p, NULL, "Adding File");
1475
	CFileProgress info(&p, NULL, "Adding File");
1476
	CBaseFile *package = p.LoadPackagerScript(filename, -1, (verify) ? NULL : &GetAsk, &malformed, &unknown, &variables, &info);
1476
	CBaseFile *package = p.loadPackagerScript(filename, -1, (verify) ? NULL : &GetAsk, &malformed, &unknown, &variables, &info);
1477
 
1477
 
1478
	printf("\n");
1478
	printf("\n");
1479
 
1479
 
1480
	if ( verify )
1480
	if ( verify )
1481
	{
1481
	{
1482
		if ( !malformed.empty() )
1482
		if ( !malformed.empty() )
1483
		{
1483
		{
1484
			printf("Malformed Lines (%d):\n", malformed.size());
1484
			printf("Malformed Lines (%d):\n", malformed.size());
1485
			for(auto itr = malformed.begin(); itr != malformed.end(); itr++)				
1485
			for(auto itr = malformed.begin(); itr != malformed.end(); itr++)				
1486
				printf("\t(Line %3d) %s\n", (*itr)->data.toInt(), (*itr)->str.c_str());
1486
				wprintf(L"\t(Line %3d) %s\n", (*itr)->data.toInt(), (*itr)->str.c_str());
1487
		}
1487
		}
1488
		if ( !unknown.empty() )
1488
		if ( !unknown.empty() )
1489
		{
1489
		{
1490
			printf("Unknown Commands (%d):\n", unknown.size());
1490
			printf("Unknown Commands (%d):\n", unknown.size());
1491
			for (auto itr = unknown.begin(); itr != unknown.end(); itr++)
1491
			for (auto itr = unknown.begin(); itr != unknown.end(); itr++)
1492
				printf("\t* Command: %s = %s\n", (*itr)->str.c_str(), (*itr)->data.c_str());
1492
				wprintf(L"\t* Command: %s = %s\n", (*itr)->str.c_str(), (*itr)->data.c_str());
1493
		}
1493
		}
1494
	}
1494
	}
1495
 
1495
 
1496
	if ( !package )
1496
	if ( !package )
1497
	{
1497
	{
1498
		if ( verify )
1498
		if ( verify )
1499
			printf("Error: There are errors in the packager script which prevents it from being created\n");
1499
			printf("Error: There are errors in the packager script which prevents it from being created\n");
1500
		else
1500
		else
1501
			printf("Error: Unable to create package, from script: %s\n", filename.c_str());
1501
			wprintf(L"Error: Unable to create package, from script: %s\n", filename.c_str());
1502
	}
1502
	}
1503
	else
1503
	else
1504
	{
1504
	{
1505
		Utils::String saveto = package->filename();
1505
		Utils::WString saveto = package->filename();
1506
		saveto = saveto.findReplace("$DEFAULTDIR", curDir + "/");
1506
		saveto = saveto.findReplace(L"$DEFAULTDIR", curDir + L"/");
1507
		saveto = saveto.findReplace("$PATH", curDir);
1507
		saveto = saveto.findReplace(L"$PATH", curDir);
1508
		saveto = saveto.findReplace("\\", "/");
1508
		saveto = saveto.findReplace(L"\\", L"/");
1509
		saveto = saveto.findReplace("//", "/");
1509
		saveto = saveto.findReplace(L"//", L"/");
1510
		if ( !saveto.right(4).Compare(".spk") && package->GetType() != TYPE_XSP )
1510
		if ( !saveto.right(4).Compare(L".spk") && package->GetType() != TYPE_XSP )
1511
			saveto += ".spk";
1511
			saveto += L".spk";
1512
		else if ( !saveto.right(4).Compare(".xsp") && package->GetType() == TYPE_XSP )
1512
		else if ( !saveto.right(4).Compare(L".xsp") && package->GetType() == TYPE_XSP )
1513
			saveto += ".xsp";
1513
			saveto += L".xsp";
1514
		wprintf(L"Saving file to: %s\n", CFileIO(saveto).fullFilename().c_str());
1514
		wprintf(L"Saving file to: %s\n", CFileIO(saveto).fullFilename().c_str());
1515
		if ( verify )
1515
		if ( verify )
1516
			printf("Package can be created from this script\n");
1516
			printf("Package can be created from this script\n");
1517
		else
1517
		else
1518
		{
1518
		{
1519
			// write script
1519
			// write script
1520
			if ( package->writeFile(saveto) )
1520
			if ( package->writeFile(saveto.toString()) )
1521
			{
1521
			{
1522
				if ( package->AutoGenerateUpdateFile() )
1522
				if ( package->AutoGenerateUpdateFile() )
1523
					package->createUpdateFile(CFileIO(saveto).dir());
1523
					package->createUpdateFile(CFileIO(saveto).dir());
1524
				printf("Package: %s was created\n", saveto.c_str());
1524
				wprintf(L"Package: %s was created\n", saveto.c_str());
1525
			}
1525
			}
1526
			else
1526
			else
1527
				printf("Error! There was a problem writing the package\n");
1527
				printf("Error! There was a problem writing the package\n");
1528
		}
1528
		}
1529
 
1529
 
1530
		saveto = package->exportFilename();
1530
		saveto = package->exportFilename().toWString();
1531
		if ( !saveto.empty() ) {
1531
		if ( !saveto.empty() ) {
1532
			saveto = saveto.findReplace("$DEFAULTDIR", curDir + "/");
1532
			saveto = saveto.findReplace(L"$DEFAULTDIR", curDir + L"/");
1533
			saveto = saveto.findReplace("$PATH", curDir);
1533
			saveto = saveto.findReplace(L"$PATH", curDir);
1534
			saveto = saveto.findReplace("\\", "/");
1534
			saveto = saveto.findReplace(L"\\", L"/");
1535
			saveto = saveto.findReplace("//", "/");
1535
			saveto = saveto.findReplace(L"//", L"/");
1536
			wprintf(L"Exporting file to: %s\n", CFileIO(saveto).fullFilename().c_str());
1536
			wprintf(L"Exporting file to: %s\n", CFileIO(saveto).fullFilename().c_str());
1537
			if ( verify )
1537
			if ( verify )
1538
				printf("Package can be exported from this script\n");
1538
				printf("Package can be exported from this script\n");
1539
			else
1539
			else
1540
			{
1540
			{
1541
				// export
1541
				// export
1542
				if ( package->saveToArchive(saveto, 0, p.GetGameExe()) ) {
1542
				if ( package->saveToArchive(saveto.toString(), 0, p.GetGameExe())) {
1543
					if ( package->IsAnyGameInPackage() ) {
1543
					if ( package->IsAnyGameInPackage() ) {
1544
						for ( int i = 0; i < p.GetGameExe()->GetNumGames(); i++ ) {
1544
						for ( int i = 0; i < p.GetGameExe()->numGames(); i++ ) {
1545
							if ( package->IsGameInPackage(i + 1) ) {								
1545
							if ( package->IsGameInPackage(i + 1) ) {								
1546
								Utils::WString exportFile = CFileIO(saveto).dir() + L"/" + CFileIO(saveto).baseName() + L"_" + CBaseFile::ConvertGameToString(i + 1).toWString() + L"." + CFileIO(saveto).extension();
1546
								Utils::WString exportFile = CFileIO(saveto).dir() + L"/" + CFileIO(saveto).baseName() + L"_" + CBaseFile::ConvertGameToString(i + 1) + L"." + CFileIO(saveto).extension();
1547
								package->saveToArchive(exportFile.toString(), i + 1, p.GetGameExe());
1547
								package->saveToArchive(exportFile.toString(), i + 1, p.GetGameExe());
1548
							}
1548
							}
1549
						}
1549
						}
1550
					}
1550
					}
1551
					printf("Package: %s was exported\n", saveto.c_str());
1551
					wprintf(L"Package: %s was exported\n", saveto.c_str());
1552
				}
1552
				}
1553
				else
1553
				else
1554
					printf("Error! There was a problem exporting the package\n");
1554
					printf("Error! There was a problem exporting the package\n");
1555
			}
1555
			}
1556
		}
1556
		}
Line 1564... Line 1564...
1564
{
1564
{
1565
	// display program header to command prompt
1565
	// display program header to command prompt
1566
	printf ( "\nSPKTool V1.50 (SPK File Version %.2f) 14/02/2021 Created by Cycrow\n\n", (float)FILEVERSION );
1566
	printf ( "\nSPKTool V1.50 (SPK File Version %.2f) 14/02/2021 Created by Cycrow\n\n", (float)FILEVERSION );
1567
 
1567
 
1568
	// parse the cmd name
1568
	// parse the cmd name
1569
	CyString cmd (argv[0]);
1569
	Utils::WString cmd (argv[0]);
1570
	cmd = cmd.FindReplace ( ";\\";, "/" );
1570
	cmd = cmd.findReplace(L";\\";, L"/");
1571
	g_dir = cmd.GetToken ( 0, cmd.NumToken('/') - 1, &apos;/&apos; );
1571
	g_dir = cmd.tokens(L"/", 1, cmd.countToken(L";/&quot;) - 1);
1572
	cmd = cmd.GetToken ( cmd.NumToken('/'), '/&apos; );
1572
	cmd = cmd.token(L"/", cmd.countToken(L"/&quot;));
1573
 
1573
 
1574
	g_read = false;
1574
	g_read = false;
1575
 
1575
 
1576
	// not enough arguments, display the syntax and exit
1576
	// not enough arguments, display the syntax and exit
1577
	if ( argc < 2 )
1577
	if ( argc < 2 )
1578
	{
1578
	{
1579
		PrintSyntax ( cmd );
1579
		PrintSyntax ( cmd.toString() );
1580
		exit ( 1 );
1580
		exit ( 1 );
1581
	}
1581
	}
1582
 
1582
 
1583
	CyString fileTypes;
1583
	Utils::WString fileTypes;
1584
	for ( int i = 0; i < FILETYPE_MAX; i++ )
1584
	for ( int i = 0; i < FILETYPE_MAX; i++ )
1585
	{
1585
	{
1586
		CyString sT = GetFileTypeString(i);
1586
		Utils::WString sT = GetFileTypeString(i);
1587
		if ( !sT.Empty() )
1587
		if ( !sT.empty() )
1588
		{
1588
		{
1589
			if ( fileTypes.Empty() )
1589
			if ( fileTypes.empty() )
1590
				fileTypes = sT;
1590
				fileTypes = sT;
1591
			else
1591
			else
1592
			{
1592
			{
1593
				fileTypes += ", ";
1593
				fileTypes += L", ";
1594
				fileTypes += sT;
1594
				fileTypes += sT;
1595
			}
1595
			}
1596
		}
1596
		}
1597
	}
1597
	}
1598
 
1598
 
1599
	// get the command flag
1599
	// get the command flag
1600
	Utils::String command(argv[1]);
1600
	Utils::WString command(argv[1]);
1601
 
1601
 
1602
	// display the contents of the spk file
1602
	// display the contents of the spk file
1603
	if ( command == "-v" || command == "--view" || command == "--version")
1603
	if ( command == L"-v" || command == L"--view" || command == L"--version")
1604
	{
1604
	{
1605
		if ( argc < 3 )
1605
		if ( argc < 3 )
1606
			printf ( "Syntax: %s -v <spkfile>\n\tWill open and display the contents of the spkfile\n", cmd.c_str() );
1606
			wprintf(L"Syntax: %s -v <spkfile>\n\tWill open and display the contents of the spkfile\n", cmd.c_str() );
1607
		else
1607
		else
1608
			DisplayVersion(argv[2]);
1608
			DisplayVersion(argv[2]);
1609
	}
1609
	}
1610
 
1610
 
1611
	// creates a new spk file
1611
	// creates a new spk file
1612
	else if ( command == "-c" || command == "--create" )
1612
	else if ( command == L"-c" || command == L"--create" )
1613
	{
1613
	{
1614
		if ( argc < 3 )
1614
		if ( argc < 3 )
1615
			printf ( "Syntax:\n\t%s -c <spkfile>\n\t%s --create <spkfile>\n\t\tThis will create a new SPK file and allow you to set some basic settings for the file\n", cmd.c_str(), cmd.c_str() );
1615
			wprintf(L"Syntax:\n\t%s -c <spkfile>\n\t%s --create <spkfile>\n\t\tThis will create a new SPK file and allow you to set some basic settings for the file\n", cmd.c_str(), cmd.c_str() );
1616
		else
1616
		else
1617
			CreateFile ( argv[2] );
1617
			CreateFile ( argv[2] );
1618
	}
1618
	}
1619
 
1619
 
1620
	// appends a file onto the spk archive
1620
	// appends a file onto the spk archive
1621
	else if ( command == "-a" || command == "--append" )
1621
	else if ( command == L"-a" || command == L"--append" )
1622
	{
1622
	{
1623
		if ( argc < 4 )
1623
		if ( argc < 4 )
1624
			printf ( "Syntax:\n\t%s -a <spkfile> <type> <filename>\n\t%s --append <spkfile> <type> <filename>\n\t\tThis will append the file into the archive and compress it according to the files default compression\n\t<type> = %s\n", cmd.c_str(), cmd.c_str(), fileTypes.c_str() );
1624
			wprintf(L"Syntax:\n\t%s -a <spkfile> <type> <filename>\n\t%s --append <spkfile> <type> <filename>\n\t\tThis will append the file into the archive and compress it according to the files default compression\n\t<type> = %s\n", cmd.c_str(), cmd.c_str(), fileTypes.c_str() );
1625
		else
1625
		else
1626
		{
1626
		{
1627
			CyString arg4;
1627
			CyString arg4;
1628
			if ( argc > 4 )
1628
			if ( argc > 4 )
1629
				arg4 = argv[4];
1629
				arg4 = argv[4];
1630
			AppendFile ( argv[2], argv[3], arg4 );
1630
			AppendFile ( argv[2], argv[3], arg4 );
1631
		}
1631
		}
1632
	}
1632
	}
1633
 
1633
 
1634
	// removes a file from the spk archive
1634
	// removes a file from the spk archive
1635
	else if ( command == "-r" || command == "--remove" || command == "--removespk" )
1635
	else if ( command == L"-r" || command == L"--remove" || command == L"--removespk" )
1636
	{
1636
	{
1637
		if ( argc < 4 )
1637
		if ( argc < 4 )
1638
		{
1638
		{
1639
			printf ( "Syntax:\n\t%s -r <spkfile> <type> <filename>\n\t%s --remove <spkfile> <type> <filename\n\t\tThis will remove a file from the archive\n\t<type> = %s\n", cmd.c_str(), cmd.c_str(), fileTypes.c_str() );
1639
			wprintf(L"Syntax:\n\t%s -r <spkfile> <type> <filename>\n\t%s --remove <spkfile> <type> <filename\n\t\tThis will remove a file from the archive\n\t<type> = %s\n", cmd.c_str(), cmd.c_str(), fileTypes.c_str() );
1640
			printf ( "\t%s -r <multispkfile> <filename>\n\t%s --removespk <multispkfile> <filename>\n\t\tThis will remove a spk file from the Multi-SPK package\n", cmd.c_str(), cmd.c_str() );
1640
			wprintf(L"\t%s -r <multispkfile> <filename>\n\t%s --removespk <multispkfile> <filename>\n\t\tThis will remove a spk file from the Multi-SPK package\n", cmd.c_str(), cmd.c_str() );
1641
		}
1641
		}
1642
		else
1642
		else
1643
		{
1643
		{
1644
			CyString arg4;
1644
			CyString arg4;
1645
			if ( argc > 4 )
1645
			if ( argc > 4 )
Line 1647... Line 1647...
1647
			RemoveFile ( argv[2], argv[3], arg4 );
1647
			RemoveFile ( argv[2], argv[3], arg4 );
1648
		}
1648
		}
1649
	}
1649
	}
1650
 
1650
 
1651
	// extracts a file from a spk file
1651
	// extracts a file from a spk file
1652
	else if ( command == "--extractspk" )
1652
	else if ( command == L"--extractspk" )
1653
	{
1653
	{
1654
		if ( argc < 4 )
1654
		if ( argc < 4 )
1655
			printf ( "Syntax:\n\t%s --extractspk <multispkfile> <filename> [destination]\n\tThis will extract a spk file from the Multi-Spk package and save it to the destination path\n", cmd.c_str() );
1655
			wprintf(L"Syntax:\n\t%s --extractspk <multispkfile> <filename> [destination]\n\tThis will extract a spk file from the Multi-Spk package and save it to the destination path\n", cmd.c_str() );
1656
		else
1656
		else
1657
		{
1657
		{
1658
			Utils::String arg4;
1658
			Utils::String arg4;
1659
			if ( argc > 4 )
1659
			if ( argc > 4 )
1660
				arg4 = argv[3];
1660
				arg4 = argv[3];
1661
			ExtractFile(argv[2], argv[3], arg4, Utils::String::Null());
1661
			ExtractFile(argv[2], argv[3], arg4, Utils::String::Null());
1662
		}
1662
		}
1663
	}
1663
	}
1664
	else if ( command == "-x" || command == "--extract")
1664
	else if ( command == L"-x" || command == L"--extract")
1665
	{
1665
	{
1666
		if ( argc < 4 )
1666
		if ( argc < 4 )
1667
		{
1667
		{
1668
			printf ( "Syntax:\n\t%s -x <spkfile> <type> <filename> [destination]\n\tThis will extract a file from the package and save it to the corect path in <directory>\n\t<type> = %s\n", cmd.c_str(), fileTypes.c_str() );
1668
			wprintf(L"Syntax:\n\t%s -x <spkfile> <type> <filename> [destination]\n\tThis will extract a file from the package and save it to the corect path in <directory>\n\t<type> = %s\n", cmd.c_str(), fileTypes.c_str() );
1669
			printf ( "\t%s -x <multispkfile> <filename> [destination]\n\tThis will extract a spk file from the Multi-Spk package and save it to the destination path\n", cmd.c_str() );
1669
			wprintf(L"\t%s -x <multispkfile> <filename> [destination]\n\tThis will extract a spk file from the Multi-Spk package and save it to the destination path\n", cmd.c_str() );
1670
		}
1670
		}
1671
		else
1671
		else
1672
		{
1672
		{
1673
			Utils::String arg5, arg4;
1673
			Utils::String arg5, arg4;
1674
			if ( argc > 5 )
1674
			if ( argc > 5 )
Line 1678... Line 1678...
1678
			ExtractFile(argv[2], argv[3], arg4, arg5);
1678
			ExtractFile(argv[2], argv[3], arg4, arg5);
1679
		}
1679
		}
1680
	}
1680
	}
1681
 
1681
 
1682
	// extracts all the files from an archive
1682
	// extracts all the files from an archive
1683
	else if ( command == "-e" || command == "--extractall" )
1683
	else if ( command == L"-e" || command == L"--extractall" )
1684
	{
1684
	{
1685
		if ( argc < 3 )
1685
		if ( argc < 3 )
1686
			printf ( "Syntax:\n\t%s -e <spkfile> [destination]\n\t--extractall <spkfile> <game> [destination]\n\t\tThis will extract all files of a set game into the destination directory\n\n\t\tGame = 0 will extract all files", cmd.c_str() );
1686
			wprintf(L"Syntax:\n\t%s -e <spkfile> [destination]\n\t--extractall <spkfile> <game> [destination]\n\t\tThis will extract all files of a set game into the destination directory\n\n\t\tGame = 0 will extract all files", cmd.c_str() );
1687
		else
1687
		else
1688
		{
1688
		{
1689
			Utils::String arg4;
1689
			Utils::String arg4;
1690
			if ( argc > 4 )
1690
			if ( argc > 4 )
1691
				arg4 = argv[4];
1691
				arg4 = argv[4];
1692
			ExtractFiles(argv[2], arg4, CBaseFile::GetGameFromString(argv[3]));
1692
			ExtractFiles(argv[2], arg4, CBaseFile::GetGameFromString(argv[3]));
1693
		}
1693
		}
1694
	}
1694
	}
1695
 
1695
 
1696
	// creates a multispk archive
1696
	// creates a multispk archive
1697
	else if ( command == "-n" || command == "--createmulti" )
1697
	else if ( command == L"-n" || command == L"--createmulti" )
1698
	{
1698
	{
1699
		if ( argc < 3 )
1699
		if ( argc < 3 )
1700
			printf ( "Syntax:\n\t%s -n <multispkfile>\n\t%s --createmulti <multispkfile>\n\t\tThis will create a multispk file and allow you to add spk files to it\n", cmd.c_str(), cmd.c_str() );
1700
			wprintf(L"Syntax:\n\t%s -n <multispkfile>\n\t%s --createmulti <multispkfile>\n\t\tThis will create a multispk file and allow you to add spk files to it\n", cmd.c_str(), cmd.c_str() );
1701
		else
1701
		else
1702
			CreateMultiFile ( argv[2] );
1702
			CreateMultiFile ( argv[2] );
1703
	}
1703
	}
1704
 
1704
 
1705
	// merges 2 multi-spk archives together, or appends a single spk file into a multi-spk file
1705
	// merges 2 multi-spk archives together, or appends a single spk file into a multi-spk file
1706
	else if ( command == "-m" || command == "--mergemulti" )
1706
	else if ( command == L"-m" || command == L"--mergemulti" )
1707
	{
1707
	{
1708
		if ( argc < 4 )
1708
		if ( argc < 4 )
1709
			printf ( "Syntax:\n\t%s -m <spkfile1> <spkfile2>\n\t%s --mergemulti <spkfile1> <spkfile2>\n\t\tThis will add spkfile2 into spkfile1, if spkfile1 is a normal SPK file, it will be saved into a Multi-Spk file\nspkfile2 can also be a Multi-Spk file, all files within it will be added\n", cmd.c_str(), cmd.c_str() );
1709
			wprintf(L"Syntax:\n\t%s -m <spkfile1> <spkfile2>\n\t%s --mergemulti <spkfile1> <spkfile2>\n\t\tThis will add spkfile2 into spkfile1, if spkfile1 is a normal SPK file, it will be saved into a Multi-Spk file\nspkfile2 can also be a Multi-Spk file, all files within it will be added\n", cmd.c_str(), cmd.c_str() );
1710
		else
1710
		else
1711
			AppendMultiFile ( argv[2], argv[3] );
1711
			AppendMultiFile ( argv[2], argv[3] );
1712
	}
1712
	}
1713
 
1713
 
1714
	// splits the multi-spk file, exracts all spk files
1714
	// splits the multi-spk file, exracts all spk files
1715
	else if ( command == "-s" || command == "--splitmulti" )
1715
	else if ( command == L"-s" || command == L"--splitmulti" )
1716
	{
1716
	{
1717
		if ( argc < 3 )
1717
		if ( argc < 3 )
1718
			printf ( "Syntax: %s -s <multispkfile> [destination]\n\tSplits the Multi-SPK file and saves each spk file to the destiantion directory\n", cmd.c_str() );
1718
			wprintf(L"Syntax: %s -s <multispkfile> [destination]\n\tSplits the Multi-SPK file and saves each spk file to the destiantion directory\n", cmd.c_str() );
1719
		else
1719
		else
1720
		{
1720
		{
1721
			CyString arg3;
1721
			CyString arg3;
1722
			if ( argc > 3 )
1722
			if ( argc > 3 )
1723
				arg3 = argv[3];
1723
				arg3 = argv[3];
1724
			SplitMulti ( argv[2], arg3 );
1724
			SplitMulti ( argv[2], arg3 );
1725
		}
1725
		}
1726
	}
1726
	}
1727
 
1727
 
1728
	else if ( command == "--set" )
1728
	else if ( command == L"--set" )
1729
	{
1729
	{
1730
		if ( argc < 4 )
1730
		if ( argc < 4 )
1731
			printf ( "Syntax: %s --set <spkfile> <setting> [values]\n\tSets various settings in the package\n", cmd.c_str() );
1731
			wprintf(L"Syntax: %s --set <spkfile> <setting> [values]\n\tSets various settings in the package\n", cmd.c_str() );
1732
		else
1732
		else
1733
			Settings(argv[2], argv[3], argc, argv, cmd);
1733
			Settings(argv[2], argv[3], argc, argv, CyString(cmd.toString()));
1734
	}
1734
	}
1735
	else if ( command == "--setrating" )
1735
	else if ( command == L"--setrating" )
1736
	{
1736
	{
1737
		if ( argc < 6 )
1737
		if ( argc < 6 )
1738
			printf ( "Syntax: %s --setrating <spkfile> <easeofuse> <gamechanging> <recommended>\n\tSets the rating of the spk package\n", cmd.c_str() );
1738
			wprintf(L"Syntax: %s --setrating <spkfile> <easeofuse> <gamechanging> <recommended>\n\tSets the rating of the spk package\n", cmd.c_str() );
1739
		else
1739
		else
1740
			SetRating(argv[2], CyString(argv[3]).ToInt(), CyString(argv[4]).ToInt(), CyString(argv[5]).ToInt());
1740
			SetRating(argv[2], CyString(argv[3]).ToInt(), CyString(argv[4]).ToInt(), CyString(argv[5]).ToInt());
1741
	}
1741
	}
1742
	else if ( command == "--convertxsp" || command == "--convertxspwizard" )
1742
	else if ( command == L"--convertxsp" || command == L"--convertxspwizard" )
1743
	{
1743
	{
1744
		if ( argc < 3 )
1744
		if ( argc < 3 )
1745
			printf ( "Syntax: %s %s <xspfile> [newxspfile]\n\tConverts an old format xsp file to work with the new format\n", cmd.c_str(), command.c_str() );
1745
			wprintf(L"Syntax: %s %s <xspfile> [newxspfile]\n\tConverts an old format xsp file to work with the new format\n", cmd.c_str(), command.c_str() );
1746
		else
1746
		else
1747
		{
1747
		{
1748
			Utils::String arg3;
1748
			Utils::String arg3;
1749
			if ( argc > 3 )
1749
			if ( argc > 3 )
1750
				arg3 = argv[3];
1750
				arg3 = argv[3];
1751
			ConvertXsp(argv[2], arg3, (command == "--convertxspwizard") ? true : false);
1751
			ConvertXsp(argv[2], arg3, (command == L"--convertxspwizard") ? true : false);
1752
		}
1752
		}
1753
	}
1753
	}
1754
	else if ( command == "--createscript" )
1754
	else if ( command == L"--createscript" )
1755
	{
1755
	{
1756
		if ( argc < 3 )
1756
		if ( argc < 3 )
1757
			printf ( "Syntax:\n\t%s --createscript <packagerscript>\n\t\tThis will create a spk/xsp file from a packager script\n", cmd.c_str() );
1757
			wprintf(L"Syntax:\n\t%s --createscript <packagerscript>\n\t\tThis will create a spk/xsp file from a packager script\n", cmd.c_str() );
1758
		else
1758
		else
1759
			LoadPackagerScript ( argv[2], false );
1759
			LoadPackagerScript ( argv[2], false );
1760
	}
1760
	}
1761
	else if ( command == "--generatescript" )
1761
	else if ( command == L"--generatescript" )
1762
	{
1762
	{
1763
		if ( argc < 3 )
1763
		if ( argc < 3 )
1764
			printf ( "Syntax:\n\t%s --generatescript <package> [packagerscript]\n\t\tThis will generate a packager script file from a spk/xsp file.\n", cmd.c_str() );
1764
			wprintf(L"Syntax:\n\t%s --generatescript <package> [packagerscript]\n\t\tThis will generate a packager script file from a spk/xsp file.\n", cmd.c_str() );
1765
		else
1765
		else
1766
		{
1766
		{
1767
			if ( argc < 4 )
1767
			if ( argc < 4 )
1768
				GeneratePackagerScript ( argv[2], "", 0);
1768
				GeneratePackagerScript ( argv[2], "", 0);
1769
			else
1769
			else
1770
				GeneratePackagerScript ( argv[2], argv[3], 0);
1770
				GeneratePackagerScript ( argv[2], argv[3], 0);
1771
		}
1771
		}
1772
	}
1772
	}
1773
	else if ( command == "--verifyscript" )
1773
	else if ( command == L"--verifyscript" )
1774
	{
1774
	{
1775
		if ( argc < 3 )
1775
		if ( argc < 3 )
1776
			printf ( "Syntax:\n\t%s --verifyscript <packagerscript>\n\t\tThis will read a packager script and check its correct without creating the resulting spk/xsp file\n", cmd.c_str() );
1776
			wprintf(L"Syntax:\n\t%s --verifyscript <packagerscript>\n\t\tThis will read a packager script and check its correct without creating the resulting spk/xsp file\n", cmd.c_str() );
1777
		else
1777
		else
1778
			LoadPackagerScript ( argv[2], true );
1778
			LoadPackagerScript ( argv[2], true );
1779
	}
1779
	}
1780
	else if ( command == "--extractship" )
1780
	else if ( command == L"--extractship" )
1781
	{
1781
	{
1782
		if ( argc < 4 )
1782
		if ( argc < 4 )
1783
			printf ( "Syntax:\n\t%s --extractship <modfile> <xspfile> [shipid]\n\t\tThis will create an xsp ship file by extracting from a mod file\n", cmd.c_str() );
1783
			wprintf(L"Syntax:\n\t%s --extractship <modfile> <xspfile> [shipid]\n\t\tThis will create an xsp ship file by extracting from a mod file\n", cmd.c_str() );
1784
		else
1784
		else
1785
		{
1785
		{
1786
			if ( argc < 5 )
1786
			if ( argc < 5 )
1787
				ExtractShip ( argv[2], argv[3], "" );
1787
				ExtractShip ( argv[2], argv[3], L"" );
1788
			else
1788
			else
1789
				ExtractShip ( argv[2], argv[3], argv[4] );
1789
				ExtractShip ( argv[2], argv[3], argv[4] );
1790
		}
1790
		}
1791
	}
1791
	}
1792
	else if (command == "--generateupdatefile")
1792
	else if (command == L"--generateupdatefile")
1793
	{
1793
	{
1794
	if (argc < 3)
1794
		if (argc < 3)
1795
		printf("Syntax:\n\t%s --generateupdatefile <package>\n\t\tThis will generate the update file to allow auto updates for a package\n", cmd.c_str());
1795
			wprintf(L"Syntax:\n\t%s --generateupdatefile <package>\n\t\tThis will generate the update file to allow auto updates for a package\n", cmd.c_str());
1796
	else
1796
		else
1797
		GenerateUpdateFile(argv[2]);
1797
			GenerateUpdateFile(argv[2]);
1798
	}
1798
	}
1799
	else if (command == "--packagelist")
1799
	else if (command == L"--packagelist")
1800
	{
1800
	{
1801
		if (argc < 3)
1801
		if (argc < 3)
1802
			printf("Syntax:\n\t%s --packagelist <filenames>\n\t\tThis will generate the update file to allow downloading packages from a server.\n", cmd.c_str());
1802
			wprintf(L"Syntax:\n\t%s --packagelist <filenames>\n\t\tThis will generate the update file to allow downloading packages from a server.\n", cmd.c_str());
1803
		else
1803
		else
1804
			GenerateUpdateList(argc, argv);
1804
			GenerateUpdateList(argc, argv);
1805
	}
1805
	}
1806
 
1806
 
1807
	// not a valid switch, display syntax
1807
	// not a valid switch, display syntax
1808
	else
1808
	else
1809
		PrintSyntax ( cmd );
1809
		PrintSyntax ( CyString(cmd.toString()) );
1810
 
1810
 
1811
#ifdef _DEBUG
1811
#ifdef _DEBUG
1812
	char pause;
1812
	char pause;
1813
	scanf ( "%s", &pause );
1813
	scanf ( "%s", &pause );
1814
#endif
1814
#endif