Subversion Repositories spk

Rev

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

Rev 125 Rev 126
Line 2253... Line 2253...
2253
 
2253
 
2254
	if ( !version.empty() )	this->AddNeededLibrary("<package>", "<author>", version);
2254
	if ( !version.empty() )	this->AddNeededLibrary("<package>", "<author>", version);
2255
}
2255
}
2256
 
2256
 
2257
 
2257
 
2258
bool CBaseFile::GeneratePackagerScript(bool wildcard, CyStringList *list, bool datafile)
2258
bool CBaseFile::GeneratePackagerScript(bool wildcard, Utils::CStringList *list, int game, bool datafile)
2259
{
2259
{
2260
	list->PushBack("#");
2260
	list->pushBack("#");
2261
	list->PushBack(CyString("# Packager Script"));
2261
	list->pushBack("# Packager Script");
2262
	list->PushBack(CyString(";# -- Generated by SPK Libraries V") + CyString::CreateFromFloat(GetLibraryVersion(), 2) + " --");
2262
	list->pushBack(";# -- Generated by SPK Libraries V" + Utils::String::FromFloat(GetLibraryVersion(), 2) + " --");
2263
	list->PushBack("#");
2263
	list->pushBack("#");
2264
	list->PushBack("");
2264
	list->pushBack("");
2265
	if ( !datafile )
2265
	if ( !datafile )
2266
	{
2266
	{
2267
		list->PushBack("# Variable for your game directory, where to get files from");
2267
		list->pushBack("# Variable for your game directory, where to get files from");
2268
		list->PushBack("# $PATH variable is used to get the current path");
2268
		list->pushBack("# $PATH variable is used to get the current path");
2269
		list->PushBack("Variable: $GAMEDIR $PATH");
2269
		list->pushBack("Variable: $GAMEDIR $PATH");
2270
		list->PushBack("");
2270
		list->pushBack("");
2271
	}
2271
	}
2272
	list->PushBack("# The name of the script");
2272
	list->pushBack("# The name of the script");
2273
	list->PushBack(CyString("Name: ") + this->name());
2273
	list->pushBack("Name: " + this->name());
2274
	list->PushBack("");
2274
	list->pushBack("");
2275
	list->PushBack("# The author of the script, ie, you");
2275
	list->pushBack("# The author of the script, ie, you");
2276
	list->PushBack(CyString("Author: ") + this->author());
2276
	list->pushBack("Author: " + this->author());
2277
	list->PushBack("");
2277
	list->pushBack("");
2278
	list->PushBack("# The creation data, when it was created");
2278
	list->pushBack("# The creation data, when it was created");
2279
	if ( datafile )
2279
	if ( datafile )
2280
		list->PushBack(CyString("Date: ") + this->creationDate());
2280
		list->pushBack("Date: " + this->creationDate());
2281
	else {
2281
	else {
2282
		list->PushBack("# $DATE variable is used to get the current date");
2282
		list->pushBack("# $DATE variable is used to get the current date");
2283
		list->PushBack("Date: $DATE");
2283
		list->pushBack("Date: $DATE");
2284
	}
2284
	}
2285
	list->PushBack("");
2285
	list->pushBack("");
2286
	list->PushBack("# The version of script");
2286
	list->pushBack("# The version of script");
2287
	if ( datafile )
2287
	if ( datafile )
2288
		list->PushBack(CyString("Version: ") + this->version());
2288
		list->pushBack("Version: " + this->version());
2289
	else
2289
	else
2290
	{
2290
	{
2291
		list->PushBack("# $ASK variable is used to get an input when creating");
2291
		list->pushBack("# $ASK variable is used to get an input when creating");
2292
		list->PushBack("Version: $ASK");
2292
		list->pushBack("Version: $ASK");
2293
	}
2293
	}
2294
	list->PushBack("");
2294
	list->pushBack("");
2295
 
2295
 
2296
	if ( !m_lGames.empty() ) {
2296
	if ( !m_lGames.empty() ) {
2297
		list->PushBack("# The game version the script is for <game> <version> (can have multiple games)");
2297
		list->pushBack("# The game version the script is for <game> <version> (can have multiple games)");
2298
		for ( SGameCompat *g = m_lGames.First(); g; g = m_lGames.Next() ) {
2298
		for ( SGameCompat *g = m_lGames.First(); g; g = m_lGames.Next() ) {
-
 
2299
			if (game > 0 && g->iGame != game)
-
 
2300
				continue;
-
 
2301
 
2299
			Utils::String game = CBaseFile::ConvertGameToString(g->iGame);
2302
			Utils::String game = CBaseFile::ConvertGameToString(g->iGame);
2300
 
2303
 
2301
			if ( !g->sVersion.empty() )
2304
			if ( !g->sVersion.empty() )
2302
			{
2305
			{
2303
				game += " ";
2306
				game += " ";
Line 2305... Line 2308...
2305
			}
2308
			}
2306
			else
2309
			else
2307
			{
2310
			{
2308
				game += " ";
2311
				game += " ";
2309
				game += (long)g->iVersion;
2312
				game += (long)g->iVersion;
2310
			}
2313
			}
2311
 
2314
 
2312
			list->PushBack(CyString("Game: ") + game);
2315
			list->pushBack("Game: " + game);
2313
		}
2316
		}
2314
 
2317
 
2315
		list->PushBack("");
2318
		list->pushBack("");
2316
	}
2319
	}
2317
 
2320
 
2318
	if ( !this->description().empty() ) {
2321
	if ( !this->description().empty() ) {
2319
		list->PushBack("# The description of the script, displays when installing");
2322
		list->pushBack("# The description of the script, displays when installing");
2320
		list->PushBack(CyString("Description: ") + this->description());
2323
		list->pushBack("Description: " + this->description());
2321
		list->PushBack("");
2324
		list->pushBack("");
2322
	}
2325
	}
2323
 
2326
 
2324
	if ( !this->webSite().empty() ) {
2327
	if ( !this->webSite().empty() ) {
2325
		list->PushBack("# A link to the website for the script, ie for an online help page");
2328
		list->pushBack("# A link to the website for the script, ie for an online help page");
2326
		list->PushBack(CyString("WebSite: ") + this->webSite());
2329
		list->pushBack("WebSite: " + this->webSite());
2327
		list->PushBack("");
2330
		list->pushBack("");
2328
	}
2331
	}
2329
 
2332
 
2330
	if ( !this->forumLink().empty() ) {
2333
	if ( !this->forumLink().empty() ) {
2331
		list->PushBack("# A direct link to the thread in the egosoft forum");
2334
		list->pushBack("# A direct link to the thread in the egosoft forum");
2332
		list->PushBack(CyString("ForumLink: ") + this->forumLink());
2335
		list->pushBack("ForumLink: " + this->forumLink());
2333
		list->PushBack("");
2336
		list->pushBack("");
2334
	}
2337
	}
2335
 
2338
 
2336
	if ( !this->webAddress().empty() ) {
2339
	if ( !this->webAddress().empty() ) {
2337
		list->PushBack("# A link to the address for the update file");
2340
		list->pushBack("# A link to the address for the update file");
2338
		list->PushBack(CyString("WebAddress: ") + this->webAddress());
2341
		list->pushBack("WebAddress: " + this->webAddress());
2339
		list->PushBack("");
2342
		list->pushBack("");
2340
	}
2343
	}
2341
 
2344
 
2342
	if ( !this->email().empty() ) {
2345
	if ( !this->email().empty() ) {
2343
		list->PushBack("# The email address of the author, to allow users to contract if needed");
2346
		list->pushBack("# The email address of the author, to allow users to contract if needed");
2344
		list->PushBack(CyString("Email: ") + this->email());
2347
		list->pushBack("Email: " + this->email());
2345
		list->PushBack("");
2348
		list->pushBack("");
2346
	}
2349
	}
2347
 
2350
 
2348
	if ( m_lMirrors.Count() )
2351
	if ( m_lMirrors.Count() )
2349
	{
2352
	{
2350
		list->PushBack("# A link to the mirror address for the update file, can have many of these");
2353
		list->pushBack("# A link to the mirror address for the update file, can have many of these");
2351
		for ( SStringList *node = m_lMirrors.Head(); node; node = node->next )
2354
		for ( SStringList *node = m_lMirrors.Head(); node; node = node->next )
2352
			list->PushBack(CyString(";WebMirror: &quot;) + node->str);
2355
			list->pushBack(Utils::String(";WebMirror: &quot;) + node->str.ToString());
2353
		list->PushBack("");
2356
		list->pushBack("");
2354
	}
2357
	}
2355
 
2358
 
2356
	if ( m_bAutoGenerateUpdateFile )
2359
	if ( m_bAutoGenerateUpdateFile )
2357
	{
2360
	{
2358
		list->PushBack("# Auto generate the package update file when created");
2361
		list->pushBack("# Auto generate the package update file when created");
2359
		list->PushBack("GenerateUpdateFile");
2362
		list->pushBack("GenerateUpdateFile");
2360
	}
2363
	}
2361
 
2364
 
2362
	if ( m_lNeededLibrarys.size() )
2365
	if ( m_lNeededLibrarys.size() )
2363
	{
2366
	{
2364
		list->PushBack("# Needed Library dependacies, require these to be installed");
2367
		list->pushBack("# Needed Library dependacies, require these to be installed");
2365
		for ( CListNode<SNeededLibrary> *node = m_lNeededLibrarys.Front(); node; node = node->next() )
2368
		for ( CListNode<SNeededLibrary> *node = m_lNeededLibrarys.Front(); node; node = node->next() )
2366
			list->PushBack(CyString("Depend: ") + node->Data()->sName + "|" + node->Data()->sMinVersion + "|" + node->Data()->sAuthor);
2369
			list->pushBack("Depend: " + node->Data()->sName + "|" + node->Data()->sMinVersion + "|" + node->Data()->sAuthor);
2367
 
2370
 
2368
		list->PushBack("");
2371
		list->pushBack("");
2369
	}
2372
	}
2370
 
2373
 
2371
	if ( !_noRatings() )
2374
	if ( !_noRatings() )
2372
	{
2375
	{
2373
		list->PushBack("# Ratings Values, 0 to 5, <ease> <changing> <recommended>");
2376
		list->pushBack("# Ratings Values, 0 to 5, <ease> <changing> <recommended>");
2374
		list->PushBack(CyString("Ratings: ") + (long)easeOfUse() + " " + (long)gameChanging() + " " + (long)recommended());
2377
		list->pushBack(Utils::String("Ratings: ") + (long)easeOfUse() + " " + (long)gameChanging() + " " + (long)recommended());
2375
		list->PushBack("");
2378
		list->pushBack("");
2376
	}
2379
	}
2377
 
2380
 
2378
	if ( m_lNames.size() )
2381
	if ( m_lNames.size() )
2379
	{
2382
	{
2380
		list->PushBack("# Package names, uses different names for different languages");
2383
		list->pushBack("# Package names, uses different names for different languages");
2381
		for ( CListNode<SNames> *node = m_lNames.Front(); node; node = node->next() )
2384
		for ( CListNode<SNames> *node = m_lNames.Front(); node; node = node->next() )
2382
			list->PushBack(CyString("ScriptName: ") + (long)node->Data()->iLanguage + " " + node->Data()->sName);
2385
			list->pushBack(Utils::String("ScriptName: ") + (long)node->Data()->iLanguage + " " + node->Data()->sName);
2383
		list->PushBack("");
2386
		list->pushBack("");
2384
	}
2387
	}
2385
 
2388
 
2386
	for ( int j = 0; j < 2; j++ ) {
2389
	for ( int j = 0; j < 2; j++ ) {
2387
		Utils::String installText = (j == 0) ? "Install" : "Uninstall";
2390
		Utils::String installText = (j == 0) ? "Install" : "Uninstall";
2388
		const CInstallText *pText = (j == 0) ? this->installText() : this->uninstallText();
2391
		const CInstallText *pText = (j == 0) ? this->installText() : this->uninstallText();
2389
		if ( pText->any() )
2392
		if ( pText->any() )
2390
		{
2393
		{
2391
			list->PushBack(CyString("# " + installText + " Texts, display text before and/or after " + installText + "ing to inform the use of special conditions"));
2394
			list->pushBack("# " + installText + " Texts, display text before and/or after " + installText + "ing to inform the use of special conditions");
2392
			for ( unsigned int i = 0; i < pText->count(); i++ ) {
2395
			for ( unsigned int i = 0; i < pText->count(); i++ ) {
2393
				long iLang = pText->language(i);
2396
				long iLang = pText->language(i);
2394
				if ( !pText->getBefore(iLang).empty() )	list->PushBack(CyString(installText + "Before: ") + iLang + " " + pText->getBefore(iLang));
2397
				if ( !pText->getBefore(iLang).empty() )	list->pushBack(installText + "Before: " + iLang + " " + pText->getBefore(iLang));
2395
				if ( !pText->getAfter(iLang).empty()  )	list->PushBack(CyString(installText + "After: ") + iLang + " " + pText->getAfter(iLang));
2398
				if ( !pText->getAfter(iLang).empty()  )	list->pushBack(installText + "After: " + iLang + " " + pText->getAfter(iLang));
2396
			}
2399
			}
2397
			list->PushBack("");
2400
			list->pushBack("");
2398
		}
2401
		}
2399
	}
2402
	}
2400
 
2403
 
2401
	list->PushBack("# Plugin Type, the type the plugin is, mainly used to show users the type, types include: Normal, Stable, Experimental, Cheat, Mod");
2404
	list->pushBack("# Plugin Type, the type the plugin is, mainly used to show users the type, types include: Normal, Stable, Experimental, Cheat, Mod");
2402
	switch ( this->pluginType() )
2405
	switch ( this->pluginType() )
2403
	{
2406
	{
2404
		case PLUGIN_NORMAL:
2407
		case PLUGIN_NORMAL:
2405
			list->PushBack("PluginType: Normal");
2408
			list->pushBack("PluginType: Normal");
2406
			break;
2409
			break;
2407
		case PLUGIN_STABLE:
2410
		case PLUGIN_STABLE:
2408
			list->PushBack("PluginType: Stable");
2411
			list->pushBack("PluginType: Stable");
2409
			break;
2412
			break;
2410
		case PLUGIN_EXPERIMENTAL:
2413
		case PLUGIN_EXPERIMENTAL:
2411
			list->PushBack("PluginType: Experimental");
2414
			list->pushBack("PluginType: Experimental");
2412
			break;
2415
			break;
2413
		case PLUGIN_CHEAT:
2416
		case PLUGIN_CHEAT:
2414
			list->PushBack("PluginType: Cheat");
2417
			list->pushBack("PluginType: Cheat");
2415
			break;
2418
			break;
2416
		case PLUGIN_MOD:
2419
		case PLUGIN_MOD:
2417
			list->PushBack("PluginType: Mod");
2420
			list->pushBack("PluginType: Mod");
2418
			break;
2421
			break;
2419
	}
2422
	}
2420
	list->PushBack("");
2423
	list->pushBack("");
2421
 
2424
 
2422
	return true;
2425
	return true;
2423
}
2426
}
2424
 
2427
 
2425
bool CBaseFile::GeneratePackagerScriptFile(bool wildcard, CyStringList *list)
2428
bool CBaseFile::GeneratePackagerScriptFile(bool wildcard, Utils::CStringList *list, int game)
2426
{
2429
{
2427
	// now do files and wildcards
2430
	// now do files and wildcards
2428
	CyStringList files;
2431
	Utils::CStringList files;
2429
	for ( CListNode<C_File> *f = m_lFiles.Front(); f; f = f->next() )
2432
	for ( CListNode<C_File> *f = m_lFiles.Front(); f; f = f->next() )
2430
	{
2433
	{
-
 
2434
		if (game && f->Data()->GetGame() != game)
-
 
2435
			continue;
-
 
2436
 
2431
		CyString name = "$GAMEDIR/";
2437
		Utils::String name = "$GAMEDIR/";
2432
 
2438
 
2433
		bool done = false;
2439
		bool done = false;
2434
		if ( wildcard )
2440
		if ( wildcard )
2435
		{
2441
		{
2436
			CyString base = f->Data()->GetBaseName();
2442
			Utils::String base = f->Data()->GetBaseName().ToString();
2437
			if ( f->Data()->GetFileType() == FILETYPE_SCRIPT )
2443
			if ( f->Data()->GetFileType() == FILETYPE_SCRIPT )
2438
			{
2444
			{
2439
				if ( base.GetToken(".", 1, 1).Compare("plugin";) || base.GetToken(";.", 1, 1).Compare("lib") )
2445
				if ( base.token(".", 1).Compare("plugin";) || base.token(";.", 1).Compare("lib") )
2440
				{
2446
				{
2441
					name += f->Data()->GetDirectory(this) + "/" + base.GetToken(".", 1, 2) + ".*";
2447
					name += f->Data()->GetDirectory(this).ToString() + "/" + base.tokens(".", 1, 2) + ".*";
2442
					done = true;
2448
					done = true;
2443
				}
2449
				}
2444
				else if ( base.GetToken(".", 1, 1).Compare("al&quot;) && !base.GetToken(".", 2, 2).Compare("plugin") )
2450
				else if ( base.token(".", 1).Compare("al") &amp;& !base.token(".", 2).Compare("plugin") )
2445
				{
2451
				{
2446
					name += f->Data()->GetDirectory(this) + "/" + base.GetToken(".", 1, 2) + ".*";
2452
					name += f->Data()->GetDirectory(this).ToString() + "/" + base.tokens(".", 1, 2) + ".*";
2447
					done = true;
2453
					done = true;
2448
				}
2454
				}
2449
			}
2455
			}
2450
			else if ( f->Data()->GetFileType() == FILETYPE_TEXT )
2456
			else if ( f->Data()->GetFileType() == FILETYPE_TEXT )
2451
			{
2457
			{
2452
				if ( base.IsIn("-L") )
2458
				if ( base.contains("-L") )
2453
				{
2459
				{
2454
					name += f->Data()->GetDirectory(this) + "/" + base.GetToken(&quot;-L", 1, 1) + "-L*";
2460
					name += f->Data()->GetDirectory(this).ToString() + "/" + base.token(&quot;-L", 1) + "-L*";
2455
					done = true;
2461
					done = true;
2456
				}
2462
				}
2457
				else
2463
				else
2458
				{
2464
				{
2459
					name += f->Data()->GetDirectory(this) + "/*" + base.Right(4) + ".*";
2465
					name += f->Data()->GetDirectory(this).ToString() + "/*" + base.right(4) + ".*";
2460
					done = true;
2466
					done = true;
2461
				}
2467
				}
2462
			}
2468
			}
2463
		}
2469
		}
2464
 
2470
 
2465
		if ( !done )
2471
		if ( !done )
2466
			name += f->Data()->GetNameDirectory(this);
2472
			name += f->Data()->GetNameDirectory(this).ToString();
2467
 
2473
 
2468
		if ( !f->Data()->GetDir().Empty() )
2474
		if ( !f->Data()->GetDir().Empty() )
2469
		{
2475
		{
2470
			name += "|";
2476
			name += "|";
2471
			name += f->Data()->GetDir();
2477
			name += f->Data()->GetDir().ToString();
2472
		}
2478
		}
2473
		files.PushBack(CyString("GAME ") + CBaseFile::ConvertGameToString(f->Data()->GetGame()) + " " + name, f-&gt;Data()->GetFileTypeString(), true);
2479
		Utils::String s = "GAME " + CBaseFile::ConvertGameToString(f-&gt;Data()->GetGame()) + " " + name;
-
 
2480
		if(!files.contains(s))
-
 
2481
			files.pushBack(s, f->Data()->GetFileTypeString().ToString());
2474
	}
2482
	}
2475
 
2483
 
2476
 
2484
 
2477
	if ( !files.Empty() )
2485
	if ( !files.empty() )
2478
	{
2486
	{
2479
		list->PushBack("# Files List, all the files to add, can include wild cards");
2487
		list->pushBack("# Files List, all the files to add, can include wild cards");
2480
		for ( SStringList *node = files.Head(); node; node = node->;next )
2488
		for(auto itr = files.begin(); itr != files.end(); itr++)
2481
			list->PushBack(node->data + ";: " + node->str);
2489
			list->pushBack((*itr)->data + ";: " + (*itr)->str);
2482
		list->PushBack("");
2490
		list->pushBack("");
2483
	}
2491
	}
2484
 
2492
 
2485
	return true;
2493
	return true;
2486
}
2494
}
2487
 
2495
 
Line 2757... Line 2765...
2757
		}
2765
		}
2758
 
2766
 
2759
		C_File *file = this->AppendFile(rest, filetype, addGame, dir);
2767
		C_File *file = this->AppendFile(rest, filetype, addGame, dir);
2760
		if ( file )
2768
		if ( file )
2761
			file->SetShared(shared);
2769
			file->SetShared(shared);
2762
	}
2770
	}
2763
}
2771
}
2764
 
2772
 
2765
 
2773
 
2766
CyString CBaseFile::GetFullFileSizeString() { return SPK::GetSizeString ( this->GetFullFileSize() ); }
2774
CyString CBaseFile::GetFullFileSizeString() { return SPK::GetSizeString ( this->GetFullFileSize() ); }
2767
 
2775
 
2768
// used for a multiple spk file
2776
// used for a multiple spk file
2769
unsigned char *CBaseFile::CreateData(size_t *size, CProgressInfo *progress)
2777
unsigned char *CBaseFile::CreateData(size_t *size, CProgressInfo *progress)
Line 2880... Line 2888...
2880
		if ( match )
2888
		if ( match )
2881
			match->ChangeBaseName(baseName);
2889
			match->ChangeBaseName(baseName);
2882
	}
2890
	}
2883
 
2891
 
2884
	// need to edit the file
2892
	// need to edit the file
2885
	if ( f->GetFileType() == FILETYPE_SCRIPT || f->GetFileType() == FILETYPE_UNINSTALL )
2893
if (f->GetFileType() == FILETYPE_SCRIPT || f->GetFileType() == FILETYPE_UNINSTALL)
2886
		f->RenameScript(baseName);
2894
f->RenameScript(baseName);
2887
 
2895
 
2888
	f->ChangeBaseName(baseName);
2896
f->ChangeBaseName(baseName);
2889
}
2897
}
2890
 
2898
 
2891
CyString CBaseFile::CreateUpdateFile(CyString dir)
2899
CyString CBaseFile::CreateUpdateFile(CyString dir)
2892
{
2900
{
2893
	CyString file = this->GetNameValidFile() + "_" + this->author() + ".dat";
2901
	CyString file = this->GetNameValidFile() + "_" + this->author() + ".dat";
Line 2898... Line 2906...
2898
	write.PushBack(CyString("Author: ") + this->author());
2906
	write.PushBack(CyString("Author: ") + this->author());
2899
	write.PushBack(CyString("Version: ") + this->version());
2907
	write.PushBack(CyString("Version: ") + this->version());
2900
	write.PushBack(CyString("File: ") + CFileIO(this->filename()).filename());
2908
	write.PushBack(CyString("File: ") + CFileIO(this->filename()).filename());
2901
 
2909
 
2902
	CFileIO File(dir + "/" + file);
2910
	CFileIO File(dir + "/" + file);
2903
	if ( File.WriteFile(&write) )
2911
	if (File.WriteFile(&write))
2904
		return File.fullFilename();
2912
		return File.fullFilename();
2905
	return NullString;
2913
	return NullString;
2906
}
2914
}
2907
 
2915
 
2908
CyString CBaseFile::ErrorString(int error, CyString errorStr)
2916
CyString CBaseFile::ErrorString(int error, CyString errorStr)
2909
{
2917
{
2910
	if ( error == SPKERR_NONE ) return NullString;
2918
	if (error == SPKERR_NONE) return NullString;
2911
 
2919
 
2912
	CyString err;
2920
	CyString err;
2913
 
2921
 
2914
	switch(error)
2922
	switch (error)
2915
	{
2923
	{
2916
		case SPKERR_MALLOC:
2924
	case SPKERR_MALLOC:
2917
			err = "Memory Failed";
2925
		err = "Memory Failed";
2918
			break;
2926
		break;
2919
		case SPKERR_FILEOPEN:
2927
	case SPKERR_FILEOPEN:
2920
			err = "Failed to open file";
2928
		err = "Failed to open file";
2921
			break;
2929
		break;
2922
		case SPKERR_FILEREAD:
2930
	case SPKERR_FILEREAD:
2923
			err = "Failed to read file";
2931
		err = "Failed to read file";
2924
			break;
2932
		break;
2925
		case SPKERR_UNCOMPRESS:
2933
	case SPKERR_UNCOMPRESS:
2926
			err = "Failed to Uncompress";
2934
		err = "Failed to Uncompress";
2927
			break;
2935
		break;
2928
		case SPKERR_WRITEFILE:
2936
	case SPKERR_WRITEFILE:
2929
			err = "Failed to write file";
2937
		err = "Failed to write file";
2930
			break;
2938
		break;
2931
		case SPKERR_CREATEDIRECTORY:
2939
	case SPKERR_CREATEDIRECTORY:
2932
			err = "Failed to create directory";
2940
		err = "Failed to create directory";
2933
			break;
2941
		break;
2934
		case SPKERR_FILEMISMATCH:
2942
	case SPKERR_FILEMISMATCH:
2935
			err = "File count mismatch";
2943
		err = "File count mismatch";
2936
			break;
2944
		break;
2937
	}
2945
	}
2938
 
2946
 
2939
	if ( !err.Empty() )
2947
	if (!err.Empty())
2940
	{
2948
	{
2941
		if ( !errorStr.Empty() )
2949
		if (!errorStr.Empty())
2942
		{
2950
		{
2943
			err += " (";
2951
			err += " (";
2944
			err += errorStr + ")";
2952
			err += errorStr + ")";
2945
		}
2953
		}
2946
		return err;
2954
		return err;
2947
	}
2955
	}
2948
 
2956
 
2949
	return CyString((long)error);
2957
	return CyString((long)error);
2950
}
2958
}
2951
 
2959
 
2952
bool CBaseFile::SaveToArchive(CyString filename, int game, CProgressInfo *progress)
2960
bool CBaseFile::SaveToArchive(CyString filename, int game, const CGameExe *exes, CProgressInfo *progress)
2953
{
2961
{
2954
	TCHAR buf[5000];
2962
	TCHAR buf[5000];
2955
	wsprintf(buf, L"%hs", filename.c_str());
2963
	wsprintf(buf, L"%hs", filename.c_str());
2956
 
2964
 
2957
	HZIP hz = CreateZip(buf, 0);
2965
	HZIP hz = CreateZip(buf, 0);
2958
	if ( !hz ) return false;
2966
	if (!hz) return false;
2959
 
2967
 
2960
	// read files and compress
2968
	// read files and compress
2961
	ReadAllFilesToMemory();
2969
	ReadAllFilesToMemory();
2962
	if ( !UncompressAllFiles(progress) )
2970
	if (!UncompressAllFiles(progress))
2963
	{
2971
	{
2964
		CloseZip(hz);
2972
		CloseZip(hz);
2965
		return false;
2973
		return false;
2966
	}
2974
	}
2967
 
2975
 
2968
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
2976
	for (CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next())
2969
	{
2977
	{
2970
		if ( game != -1 ) {
2978
		if (game != -1) {
2971
			if ( game &&amp; node->Data()->GetGame() &;&; node->Data()->GetGame() != game )
2979
			if (game &amp;&; node->Data()->GetGame() &&; node->Data()->GetGame() != game)
2972
				continue;
2980
				continue;
2973
			if ( !game &amp;& node->Data()->GetGame() )
2981
			if (!game &&amp; node->Data()->GetGame())
2974
				continue;
2982
				continue;
2975
		}
2983
		}
2976
		CyString fname = node->Data()->GetNameDirectory(this);
2984
		Utils::String fname = node->Data()->GetNameDirectory(this).ToString();
-
 
2985
 
-
 
2986
		// use the addon directory
-
 
2987
		if (node->Data()->isFileInAddon() && exes)
-
 
2988
		{
-
 
2989
			int whatGame = game;
-
 
2990
			if (game == -1)
-
 
2991
				whatGame = node->Data()->GetGame();
-
 
2992
 
-
 
2993
			SGameExe *e = exes->GetGame(whatGame - 1);
-
 
2994
			if (e)
-
 
2995
			{
-
 
2996
				if (e->iFlags & EXEFLAG_ADDON)
-
 
2997
					fname = e->sAddon + "/" + fname;
-
 
2998
			}
-
 
2999
		}
-
 
3000
 
2977
		// create the directory
3001
		// create the directory
2978
		wsprintf(buf, L"%hs", fname.c_str());
3002
		wsprintf(buf, L"%hs", fname.c_str());
2979
		ZipAdd(hz, buf, node->Data()->GetData(), node->Data()->GetDataSize());
3003
		ZipAdd(hz, buf, node->Data()->GetData(), node->Data()->GetDataSize());
2980
	}
3004
	}
2981
 
3005
 
2982
	// if its a ship, then add any generated files
3006
	// if its a ship, then add any generated files
2983
	this->addGeneratedFiles(hz);
3007
	this->addGeneratedFiles(hz);
2984
 
3008
 
2985
	// add the data file
3009
	// add the data file
2986
	CyStringList list;
3010
	Utils::CStringList list;
2987
	if ( this->GeneratePackagerScript(false, &list, true) )
3011
	if ( this->GeneratePackagerScript(false, &list, game, true) )
2988
	{
3012
	{
2989
		if ( CFileIO("test.tmp").WriteFile(&list) )
3013
		if ( CFileIO("test.tmp").writeFile(&list) )
2990
		{
3014
		{
2991
			ZipAdd(hz, L"pluginmanager.txt", L"test.tmp");
3015
			ZipAdd(hz, L"pluginmanager.txt", L"test.tmp");
2992
			CFileIO::Remove("test.tmp");
3016
			CFileIO::Remove("test.tmp");
2993
		}
3017
		}
2994
	}
3018
	}
2995
 
3019
 
2996
	CloseZip(hz);
3020
	CloseZip(hz);
2997
 
3021
 
2998
	return true;
3022
	return true;
2999
}
3023
}
3000
 
3024
 
3001
int CBaseFile::GetGameFromString(const Utils::String &sGame)
3025
int CBaseFile::GetGameFromString(const Utils::String &sGame)
3002
{
3026
{
3003
	int iGame = GAME_ALL;
3027
	int iGame = GAME_ALL;
3004
	if ( sGame.Compare("ALL") )
3028
	if ( sGame.Compare("ALL") )
Line 3007... Line 3031...
3007
		iGame = GAME_X3;
3031
		iGame = GAME_X3;
3008
	else if ( sGame.Compare("X2") )
3032
	else if ( sGame.Compare("X2") )
3009
		iGame = GAME_X2;
3033
		iGame = GAME_X2;
3010
	else if ( sGame.Compare("X3TC") )
3034
	else if ( sGame.Compare("X3TC") )
3011
		iGame = GAME_X3TC;
3035
		iGame = GAME_X3TC;
3012
	else if ( sGame.Compare("X3AP") )
3036
	else if (sGame.Compare("X3AP"))
3013
		iGame = GAME_X3AP;
3037
		iGame = GAME_X3AP;
-
 
3038
	else if (sGame.Compare("X3FL"))
-
 
3039
		iGame = GAME_X3FL;
3014
	else if ( sGame.Compare("XREBIRTH") )
3040
	else if ( sGame.Compare("XREBIRTH") )
3015
		iGame = GAME_XREBIRTH;
3041
		iGame = GAME_XREBIRTH;
3016
	else if ( sGame.isNumber() )
3042
	else if ( sGame.isNumber() )
3017
		iGame = sGame;
3043
		iGame = sGame;
3018
 
3044
 
Line 3036... Line 3062...
3036
		case GAME_X3TC:
3062
		case GAME_X3TC:
3037
			game = "X3TC";
3063
			game = "X3TC";
3038
			break;
3064
			break;
3039
		case GAME_X3AP:
3065
		case GAME_X3AP:
3040
			game = "X3AP";
3066
			game = "X3AP";
-
 
3067
			break;
-
 
3068
		case GAME_X3FL:
-
 
3069
			game = "X3FL";
3041
			break;
3070
			break;
3042
		case GAME_XREBIRTH:
3071
		case GAME_XREBIRTH:
3043
			game = "XREBIRTH";
3072
			game = "XREBIRTH";
3044
			break;
3073
			break;
3045
		default:
3074
		default: