Subversion Repositories spk

Rev

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

Rev 10 Rev 36
Line 238... Line 238...
238
	{
238
	{
239
		printf ( "Error: Mod File, %s, does not exist\n", catfile.c_str() );
239
		printf ( "Error: Mod File, %s, does not exist\n", catfile.c_str() );
240
		return;
240
		return;
241
	}
241
	}
242
 
242
 
243
	CCatFile cat;
243
	CVirtualFileSystem *pVfs = new CVirtualFileSystem();
244
	if ( cat.Open(catfile, "", CATREAD_CATDECRYPT, false) != CATERR_NONE )
244
	if ( !pVfs->LoadMod(catfile.ToString()) ) {
245
	{
-
 
246
		printf("Error: Unable to read mod file, %s\n", catfile.c_str());
245
		printf("Error: Unable to read mod file, %s\n", catfile.c_str());
-
 
246
		delete pVfs;
247
		return;
247
		return;
248
	}
248
	}
249
 
249
 
250
	CyStringList *ships = cat.GetTShipsEntries();
250
	CyStringList *ships = pVfs->GetTShipsEntries();
251
	if ( !ships )
251
	if ( !ships )
252
	{
252
	{
253
		printf("Error: Failed to read %s::types\\TShips.pck\n", catfile.c_str());
253
		printf("Error: Failed to read %s::types\\TShips.pck\n", catfile.c_str());
-
 
254
		delete pVfs;
254
		return;
255
		return;
255
	}
256
	}
256
 
257
 
257
	// now get the ship line to extract
258
	// now get the ship line to extract
258
	SStringList *tshipsLine = NULL;
259
	SStringList *tshipsLine = NULL;
Line 288... Line 289...
288
		ships->FindData(shipid.upper());
289
		ships->FindData(shipid.upper());
289
 
290
 
290
	if ( !tshipsLine )
291
	if ( !tshipsLine )
291
	{
292
	{
292
		printf("Error, %s is not a valid ship id to use\n", shipid.c_str());
293
		printf("Error, %s is not a valid ship id to use\n", shipid.c_str());
-
 
294
		delete pVfs;
293
		return;
295
		return;
294
	}
296
	}
295
 
297
 
296
	// now we have the tships to use, lets start to extract the ship
298
	// now we have the tships to use, lets start to extract the ship
297
	printf("Extracting ship from %s, Ship=%s\n", catfile.c_str(), tshipsLine->data.c_str());
299
	printf("Extracting ship from %s, Ship=%s\n", catfile.c_str(), tshipsLine->data.c_str());
298
 
300
 
299
	CXspFile ship;
301
	CXspFile ship;
300
	if ( ship.ExtractShip(&cat, tshipsLine->data, 0) )
302
	if ( ship.extractShip(pVfs, tshipsLine->data.ToString(), 0) )
301
	{
303
	{
302
		printf ( "Ship has been successfully extracted\n" );
304
		printf ( "Ship has been successfully extracted\n" );
303
 
305
 
304
		printf("\t- Models:\t %d\n", ship.CountFiles(FILETYPE_SHIPMODEL));
306
		printf("\t- Models:\t %d\n", ship.CountFiles(FILETYPE_SHIPMODEL));
305
		printf("\t- Textures:\t %d\n", ship.CountFiles(FILETYPE_SHIPOTHER));
307
		printf("\t- Textures:\t %d\n", ship.CountFiles(FILETYPE_SHIPOTHER));
Line 331... Line 333...
331
		else
333
		else
332
			printf("Error: Unable to write ship file, %s\n", to.c_str());
334
			printf("Error: Unable to write ship file, %s\n", to.c_str());
333
	}
335
	}
334
	else
336
	else
335
		printf("Error: Unable to extract the ship\n");
337
		printf("Error: Unable to extract the ship\n");
-
 
338
 
-
 
339
	delete pVfs;
336
}
340
}
337
 
341
 
338
CyString GetGameName(int game)
342
CyString GetGameName(int game)
339
{
343
{
340
	switch(game)
344
	switch(game)