Subversion Repositories spk

Rev

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

Rev 116 Rev 118
Line 2134... Line 2134...
2134
		}
2134
		}
2135
		fileStream.close();
2135
		fileStream.close();
2136
	}
2136
	}
2137
	*/
2137
	*/
2138
 
2138
 
2139
	FILE *fid = fopen(file.c_str(), "r");
2139
	CFileIO F(file);
2140
	if ( fid )
2140
	if ( F.exists() && F.startRead() ) {
2141
	{
-
 
2142
		bool ret = this->AddTextFromFile(fid, textId);
2141
		bool ret = this->_addTextFromFile(F, textId);
2143
		fclose(fid);
2142
		F.close();
2144
 
2143
 
2145
		if ( remove ) CFileIO::Remove(file);
2144
		if ( remove ) CFileIO::Remove(file);
2146
		_changed();
2145
		_changed();
2147
		return ret;
2146
		return ret;
2148
	}
2147
	}
2149
 
2148
 
2150
	return false;
2149
	return false;
2151
}
2150
}
2152
 
2151
 
2153
bool CXspFile::ImportBodies(CyStringList *sceneModels, const Utils::String &filename)
2152
bool CXspFile::ImportBodies(CyStringList *sceneModels, const Utils::String &filename)
2154
{
2153
{
2155
	CFileIO File(filename);
2154
	CFileIO File(filename);
2156
	if ( File.exists() )
2155
	if ( File.exists() )
2157
	{
2156
	{
2158
		Utils::String sSection;
2157
		Utils::String sSection;
2159
		int section = 0;
2158
		int section = 0;
2160
		CyStringList *lines = File.ReadLinesStr();
2159
		CyStringList *lines = File.ReadLinesStr();
2161
		for ( SStringList *node = lines->Head(); node; node = node->next )
2160
		for ( SStringList *node = lines->Head(); node; node = node->next )
2162
		{
2161
		{
2163
			node->str.RemoveChar(9);
2162
			node->str.RemoveChar(9);
2164
			node->str.RemoveChar('\r');
2163
			node->str.RemoveChar('\r');
2165
			node->str.RemoveFirstSpace();
2164
			node->str.RemoveFirstSpace();
2166
			if ( node->str.Empty() )
2165
			if ( node->str.Empty() )
2167
				continue;
2166
				continue;
2168
			if ( node->str[0] == '/' )
2167
			if ( node->str[0] == '/' )
Line 2218... Line 2217...
2218
				node->remove = true;
2217
				node->remove = true;
2219
			else if ( !entries )
2218
			else if ( !entries )
2220
			{
2219
			{
2221
				entries = node->str.GetToken(";", 2, 2).ToInt();
2220
				entries = node->str.GetToken(";", 2, 2).ToInt();
2222
				node->remove = true;
2221
				node->remove = true;
2223
			}
2222
			}
2224
		}
2223
		}
2225
		lines->RemoveMarked();
2224
		lines->RemoveMarked();
2226
 
2225
 
2227
		// now get all the entries from TShips
2226
		// now get all the entries from TShips
2228
		for ( int i = 0; i < 6; i++ )
2227
		for ( int i = 0; i < 6; i++ )
Line 2270... Line 2269...
2270
	}
2269
	}
2271
 
2270
 
2272
	return false;
2271
	return false;
2273
}
2272
}
2274
 
2273
 
2275
bool CXspFile::AddTextFromFile(FILE *id, int textId)
2274
bool CXspFile::_addTextFromFile(CFileIO &F, int textId)
2276
{
2275
{
2277
	if ( textId == -1 && !m_sData.empty() )
2276
	if ( textId == -1 && !m_sData.empty() )
2278
		textId = m_sData.token(";", 7);
2277
		textId = m_sData.token(";", 7);
2279
 
2278
 
2280
	if ( textId <= 0 )
2279
	if ( textId <= 0 )
2281
		return false;
2280
		return false;
2282
 
2281
 
2283
	Utils::String line;
-
 
2284
	if ( !id )
2282
	if ( !F.isOpened() )
2285
		return false;
2283
		return false;
2286
 
2284
 
2287
	bool added = false;
2285
	bool added = false;
2288
 
2286
 
2289
	Utils::String shipName;
2287
	Utils::String shipName;
2290
	Utils::String shipDesc;
2288
	Utils::String shipDesc;
2291
 
2289
 
2292
	int lastAddedGameID = 0;
2290
	int lastAddedGameID = 0;
2293
	int currentGameID = 0;
2291
	int currentGameID = 0;
2294
	int lang = 0;
2292
	int lang = 0;
2295
	bool inpage = false;
2293
	bool inpage = false;
-
 
2294
 
2296
	while ( !feof(id) )
2295
	while(!F.atEnd()) {
2297
	{
-
 
2298
		if ( !shipName.empty() && !shipDesc.empty() )
2296
		if ( !shipName.empty() && !shipDesc.empty() )
2299
		{
2297
		{
2300
			added = true;
2298
			added = true;
2301
			break;
2299
			break;
2302
		}
2300
		}
2303
 
2301
 
2304
		line.readToEndOfLine(id, 0, false);
2302
		Utils::String line = F.readEndOfLine();
2305
		line.removeChar(9);
2303
		line.removeChar(9);
2306
		line.removeChar('\r');
2304
		line.removeChar('\r');
2307
		line.removeFirstSpace();
2305
		line.removeFirstSpace();
2308
 
2306
	
2309
		if ( inpage )
2307
		if ( inpage )
2310
		{
2308
		{
2311
			if ( line.left(6).Compare("</page") ) {
2309
			if ( line.left(6).Compare("</page") ) {
2312
				inpage = false;
2310
				inpage = false;
2313
				continue;
2311
				continue;