Subversion Repositories spk

Rev

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

Rev 112 Rev 118
Line 27... Line 27...
27
typedef struct SComponantEntry {
27
typedef struct SComponantEntry {
28
	CyString		sSection;
28
	CyString		sSection;
29
	CLinkList<SComponantEntry2>	lEntries;
29
	CLinkList<SComponantEntry2>	lEntries;
30
} SComponantEntry;
30
} SComponantEntry;
31
 
31
 
32
CyString CPackages::m_sTempDir;
32
Utils::String CPackages::m_sTempDir;
33
 
33
 
34
CPackages::CPackages() : m_pCurrentGameExe(NULL),
34
CPackages::CPackages() : m_pCurrentGameExe(NULL),
35
	_pOriginalFiles(NULL)
35
	_pOriginalFiles(NULL)
36
{
36
{
37
	m_bRenameText = false;
37
	m_bRenameText = false;
Line 4979... Line 4979...
4979
		if ( !m_lGameWares[i].size() )
4979
		if ( !m_lGameWares[i].size() )
4980
			continue;
4980
			continue;
4981
 
4981
 
4982
		// lets extract the ware file
4982
		// lets extract the ware file
4983
		char wareType = CPackages::ConvertWareTypeBack(i);
4983
		char wareType = CPackages::ConvertWareTypeBack(i);
4984
		CyString wareFile = "TWare";
4984
		Utils::String wareFile = "TWare";
4985
		wareFile += (char)UPPER(wareType);
4985
		wareFile += (char)UPPER(wareType);
4986
 
4986
 
4987
		CyString openFile;
4987
		CyString openFile;
4988
 
4988
 
4989
		int e;
4989
		int e;
4990
		if ( i == WARES_TECH && CFileIO(m_sTempDir + "/TWareT.txt").ExistsOld() )
4990
		if ( i == WARES_TECH && CFileIO::Exists(m_sTempDir + "/TWareT.txt") )
4991
			openFile = m_sTempDir + "/TWareT.txt";
4991
			openFile = m_sTempDir + "/TWareT.txt";
4992
		else {
4992
		else {
4993
			e = ExtractGameFile(CyString("types/") + wareFile + ".pck", m_sTempDir + "/" + wareFile + ".txt");
4993
			e = ExtractGameFile("types/" + wareFile + ".pck", m_sTempDir + "/" + wareFile + ".txt");
4994
			if ( e == 1 )
4994
			if ( e == 1 )
4995
				openFile = m_sTempDir + "/" + wareFile + ".txt";
4995
				openFile = m_sTempDir + "/" + wareFile + ".txt";
4996
			else if ( e == -2 )
4996
			else if ( e == -2 )
4997
				openFile = wareFile + ".txt";
4997
				openFile = wareFile + ".txt";
4998
		}
4998
		}
Line 5882... Line 5882...
5882
	int e = ExtractGameFile("types/Dummies.pck", m_sTempDir + "/Dummies.txt");
5882
	int e = ExtractGameFile("types/Dummies.pck", m_sTempDir + "/Dummies.txt");
5883
	if ( e )
5883
	if ( e )
5884
	{
5884
	{
5885
		// read the dummies
5885
		// read the dummies
5886
		CFileIO File;
5886
		CFileIO File;
5887
		if ( File.Open((e == -1) ? "Dummies.txt" : m_sTempDir + "/Dummies.txt") )
5887
		if ( File.open((e == -1) ? "Dummies.txt" : m_sTempDir + "/Dummies.txt") )
5888
		{
5888
		{
5889
			std::vector<CyString> *lines = File.ReadLines();
5889
			std::vector<CyString> *lines = File.ReadLines();
5890
			if ( lines )
5890
			if ( lines )
5891
			{
5891
			{
5892
				int insection = 0;
5892
				int insection = 0;
Line 6076... Line 6076...
6076
	CyStringList cutList;
6076
	CyStringList cutList;
6077
	int e = ExtractGameFile("types/CutData.pck", m_sTempDir + "/CutData.txt");
6077
	int e = ExtractGameFile("types/CutData.pck", m_sTempDir + "/CutData.txt");
6078
	if ( e )
6078
	if ( e )
6079
	{
6079
	{
6080
		CFileIO File;
6080
		CFileIO File;
6081
		if ( File.Open((e == -1) ? "CutData.txt" : m_sTempDir + "/CutData.txt") )
6081
		if ( File.open((e == -1) ? "CutData.txt" : m_sTempDir + "/CutData.txt") )
6082
		{
6082
		{
6083
			std::vector<CyString> *lines = File.ReadLines();
6083
			std::vector<CyString> *lines = File.ReadLines();
6084
			if ( lines )
6084
			if ( lines )
6085
			{
6085
			{
6086
				int entries = -1;
6086
				int entries = -1;
Line 6171... Line 6171...
6171
	CyStringList aniList;
6171
	CyStringList aniList;
6172
	int e = ExtractGameFile("types/Animations.pck", m_sTempDir + "/Animations.txt");
6172
	int e = ExtractGameFile("types/Animations.pck", m_sTempDir + "/Animations.txt");
6173
	if ( e )
6173
	if ( e )
6174
	{
6174
	{
6175
		CFileIO File;
6175
		CFileIO File;
6176
		if ( File.Open((e == -1) ? "Animations.txt" : m_sTempDir + "/Animations.txt") )
6176
		if ( File.open((e == -1) ? "Animations.txt" : m_sTempDir + "/Animations.txt") )
6177
		{
6177
		{
6178
			std::vector<CyString> *lines = File.ReadLines();
6178
			std::vector<CyString> *lines = File.ReadLines();
6179
			if ( lines )
6179
			if ( lines )
6180
			{
6180
			{
6181
				for ( int j = 0; j < (int)lines->size(); j++ )
6181
				for ( int j = 0; j < (int)lines->size(); j++ )
Line 6324... Line 6324...
6324
	SBodies *currentSection = NULL;
6324
	SBodies *currentSection = NULL;
6325
	int e = ExtractGameFile("types/Bodies.pck", m_sTempDir + "/Bodies.txt");
6325
	int e = ExtractGameFile("types/Bodies.pck", m_sTempDir + "/Bodies.txt");
6326
	if ( e )
6326
	if ( e )
6327
	{
6327
	{
6328
		CFileIO File;
6328
		CFileIO File;
6329
		if ( File.Open((e == -1) ? "Bodies.txt" : m_sTempDir + "/Bodies.txt") )
6329
		if ( File.open((e == -1) ? "Bodies.txt" : m_sTempDir + "/Bodies.txt") )
6330
		{
6330
		{
6331
			std::vector<CyString> *lines = File.ReadLines();
6331
			std::vector<CyString> *lines = File.ReadLines();
6332
			if ( lines )
6332
			if ( lines )
6333
			{
6333
			{
6334
				int entries = 0;
6334
				int entries = 0;
Line 6476... Line 6476...
6476
				type = FILETYPE_MAP;
6476
				type = FILETYPE_MAP;
6477
 
6477
 
6478
			if ( !p->FindFile(str->str + ".xml", type) && !p->FindFile(str->str + ".pck", type) )
6478
			if ( !p->FindFile(str->str + ".xml", type) && !p->FindFile(str->str + ".pck", type) )
6479
			{
6479
			{
6480
				// create a maps files
6480
				// create a maps files
6481
				int e = this->ExtractGameFile(str->data + ".pck", m_sTempDir + "/" + str->data + ".pck");
6481
				int e = this->ExtractGameFile(str->data + ".pck", m_sTempDir + "/" + str->data.ToString() + ".pck");
6482
				if ( e )
6482
				if ( e )
6483
				{
6483
				{
6484
					CFileIO File((e == -1) ? (str->data + ".pck") : (m_sTempDir + "/" + str->data + ".pck"));
6484
					CFileIO File((e == -1) ? (str->data + ".pck") : (m_sTempDir + "/" + str->data.ToString() + ".pck"));
6485
					if ( File.exists() )
6485
					if ( File.exists() )
6486
					{
6486
					{
6487
						File.Rename(m_sCurrentDir + "/" + dir + "/" + str->str + ".pck");
6487
						File.Rename(m_sCurrentDir + "/" + dir + "/" + str->str + ".pck");
6488
						this->AddCreatedFile(dir + "/" + str->str.ToString() + ".pck");
6488
						this->AddCreatedFile(dir + "/" + str->str.ToString() + ".pck");
6489
					}
6489
					}
Line 6516... Line 6516...
6516
	int e = ExtractGameFile("types/Components.pck", m_sTempDir + "/Components.txt");
6516
	int e = ExtractGameFile("types/Components.pck", m_sTempDir + "/Components.txt");
6517
	if ( e )
6517
	if ( e )
6518
	{
6518
	{
6519
		// read the dummies
6519
		// read the dummies
6520
		CFileIO File;
6520
		CFileIO File;
6521
		if ( File.Open((e == -1) ? "Components.txt" : m_sTempDir + "/Components.txt") )
6521
		if ( File.open((e == -1) ? "Components.txt" : m_sTempDir + "/Components.txt") )
6522
		{
6522
		{
6523
			std::vector<CyString> *lines = File.ReadLines();
6523
			std::vector<CyString> *lines = File.ReadLines();
6524
			if ( lines )
6524
			if ( lines )
6525
			{
6525
			{
6526
				int insection = 0;
6526
				int insection = 0;
Line 6831... Line 6831...
6831
bool CPackages::ReadGlobals(CyStringList &globals)
6831
bool CPackages::ReadGlobals(CyStringList &globals)
6832
{
6832
{
6833
	int e = ExtractGameFile("types/Globals.pck", m_sTempDir);
6833
	int e = ExtractGameFile("types/Globals.pck", m_sTempDir);
6834
	if ( e )
6834
	if ( e )
6835
	{
6835
	{
6836
		CFileIO File(((e == -1) ? "." : m_sTempDir) + "/Globals.txt");
6836
		CFileIO File((e == -1) ? "Globals.txt" : m_sTempDir + "/Globals.txt");
6837
		if ( File.exists() )
6837
		if ( File.exists() )
6838
		{
6838
		{
6839
			CyStringList *lines = File.ReadLinesStr();
6839
			CyStringList *lines = File.ReadLinesStr();
6840
			if ( lines )
6840
			if ( lines )
6841
			{
6841
			{
Line 6943... Line 6943...
6943
		int fileType = 51;
6943
		int fileType = 51;
6944
		CyStringList tshipsList;
6944
		CyStringList tshipsList;
6945
 
6945
 
6946
		// if we have no buffer, lets create one
6946
		// if we have no buffer, lets create one
6947
		CFileIO File;
6947
		CFileIO File;
6948
		if ( File.Open((e == -1) ? "TShips.txt" : m_sTempDir + "/TShips.txt") )
6948
		if ( File.open((e == -1) ? "TShips.txt" : m_sTempDir + "/TShips.txt") )
6949
		{
6949
		{
6950
			int shiptext = SHIPSTARTTEXT;
6950
			int shiptext = SHIPSTARTTEXT;
6951
 
6951
 
6952
			std::vector<CyString> *lines = File.ReadLines();
6952
			std::vector<CyString> *lines = File.ReadLines();
6953
			if ( lines )
6953
			if ( lines )
Line 7218... Line 7218...
7218
	int e = ExtractGameFile("types/TCockpits.pck", m_sTempDir + "/TCockpits.txt");
7218
	int e = ExtractGameFile("types/TCockpits.pck", m_sTempDir + "/TCockpits.txt");
7219
	if ( e )
7219
	if ( e )
7220
	{
7220
	{
7221
		// read the dummies
7221
		// read the dummies
7222
		CFileIO File;
7222
		CFileIO File;
7223
		if ( File.Open((e == -1) ? "TCockpits.txt" : m_sTempDir + "/TCockpits.txt") )
7223
		if ( File.open((e == -1) ? "TCockpits.txt" : m_sTempDir + "/TCockpits.txt") )
7224
		{
7224
		{
7225
			CyStringList *lines = File.ReadLinesStr();
7225
			CyStringList *lines = File.ReadLinesStr();
7226
			if ( lines )
7226
			if ( lines )
7227
			{
7227
			{
7228
				int count = -1;
7228
				int count = -1;
Line 7649... Line 7649...
7649
			return false;
7649
			return false;
7650
 
7650
 
7651
		if ( !cat.ExtractFile("types\\TShips.pck", m_sTempDir + "/tships.txt") )
7651
		if ( !cat.ExtractFile("types\\TShips.pck", m_sTempDir + "/tships.txt") )
7652
			return false;
7652
			return false;
7653
 
7653
 
7654
		File.Open(m_sTempDir + "/tships.txt");
7654
		File.open(m_sTempDir + "/tships.txt");
7655
		deleteFile = true;
7655
		deleteFile = true;
7656
	}
7656
	}
7657
	// otherwise its a normal file
7657
	// otherwise its a normal file
7658
	else if ( CFileIO(file).CheckFileExtension("pck") )
7658
	else if ( CFileIO(file).CheckFileExtension("pck") )
7659
	{
7659
	{
Line 7664... Line 7664...
7664
 
7664
 
7665
		f.SetFilename(m_sTempDir + "/tships.txt");
7665
		f.SetFilename(m_sTempDir + "/tships.txt");
7666
		if ( !f.WriteFilePointer() )
7666
		if ( !f.WriteFilePointer() )
7667
			return false;
7667
			return false;
7668
 
7668
 
7669
		File.Open(m_sTempDir + "/tships.txt");
7669
		File.open(m_sTempDir + "/tships.txt");
7670
		deleteFile = true;
7670
		deleteFile = true;
7671
	}
7671
	}
7672
	else
7672
	else
7673
		File.Open(file);
7673
		File.open(file.ToString());
7674
 
7674
 
7675
	if ( !File.exists() )
7675
	if ( !File.exists() )
7676
		return false;
7676
		return false;
7677
 
7677
 
7678
	bool ret = false;
7678
	bool ret = false;
Line 7801... Line 7801...
7801
 
7801
 
7802
		f.SetFilename(m_sTempDir + "/textfile.xml");
7802
		f.SetFilename(m_sTempDir + "/textfile.xml");
7803
		if ( !f.WriteFilePointer() )
7803
		if ( !f.WriteFilePointer() )
7804
			return false;
7804
			return false;
7805
 
7805
 
7806
		File.Open(m_sTempDir + "/textfile.xml");
7806
		File.open(m_sTempDir + "/textfile.xml");
7807
		deleteFile = true;
7807
		deleteFile = true;
7808
	}
7808
	}
7809
	else
7809
	else
7810
		File.Open(file);
7810
		File.open(file.ToString());
7811
 
7811
 
7812
	if ( !File.exists() )
7812
	if ( !File.exists() )
7813
		return false;
7813
		return false;
7814
 
7814
 
7815
	// open and read file
7815
	// open and read file