Subversion Repositories spk

Rev

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

Rev 102 Rev 121
Line 34... Line 34...
34
 *
34
 *
35
 * Argument:	exe,	String - name of the exe file to find
35
 * Argument:	exe,	String - name of the exe file to find
36
 */
36
 */
37
int CGameExe::_findExe(const Utils::String &exe) const
37
int CGameExe::_findExe(const Utils::String &exe) const
38
{
38
{
-
 
39
	CFileIO File(exe);
-
 
40
	Utils::String e = File.filename();
-
 
41
 
39
	int count = 0;
42
	int count = 0;
40
	for ( CListNode<SGameExe> *node = m_lExe.Front(); node; node = node->next() )
43
	for ( CListNode<SGameExe> *node = m_lExe.Front(); node; node = node->next() )
41
	{
44
	{
42
		if ( node->Data()->sExe.Compare(exe) )
45
		if ( node->Data()->sExe.Compare(e) )
43
			return count;
46
			return count;
44
		++count;
47
		++count;
45
	}
48
	}
46
 
49
 
47
	return -1;
50
	return -1;
48
}
51
}
49
 
52
 
50
SGameExe *CGameExe::gameExe(const Utils::String &exe)
53
SGameExe *CGameExe::gameExe(const Utils::String &exe) const
51
{
54
{
52
	int e = this->_findExe(exe);
55
	int e = this->_findExe(exe);
53
	if ( e < 0 ) return NULL;
56
	if ( e < 0 ) return NULL;
54
	return m_lExe[e];
57
	return m_lExe.Get(e);
55
}
58
}
56
 
59
 
57
int CGameExe::_findVersion(int exe, int size, Utils::String *fVersion)
60
int CGameExe::_findVersion(int exe, int size, Utils::String *fVersion) const
58
{
61
{
59
	if ( fVersion ) *fVersion = -1.0;
62
	if ( fVersion ) *fVersion = -1.0;
60
	if ( exe < 0 ) return -1;
63
	if ( exe < 0 ) return -1;
61
 
64
 
62
	SGameExe *gameExe = m_lExe[exe];
65
	SGameExe *gameExe = m_lExe[exe];
Line 90... Line 93...
90
 
93
 
91
	return -1;
94
	return -1;
92
}
95
}
93
 
96
 
94
Utils::String CGameExe::GetModKey(int game)
97
Utils::String CGameExe::GetModKey(int game)
95
{
98
{
96
	if ( game < 0 )	return "";
99
	if ( game < 0 )	return "";
97
	SGameExe *sExe = m_lExe[game];
100
	SGameExe *sExe = m_lExe[game];
98
	if ( !sExe ) return "";
101
	if ( !sExe ) return "";
99
 
102
 
100
	return sExe->sModKey;
103
	return sExe->sModKey;
Line 195... Line 198...
195
			f |= EXEFLAG_ADDON;
198
			f |= EXEFLAG_ADDON;
196
		else if ( str.Compare("MYDOCLOG") )
199
		else if ( str.Compare("MYDOCLOG") )
197
			f |= EXEFLAG_MYDOCLOG;
200
			f |= EXEFLAG_MYDOCLOG;
198
		else if ( str.Compare("NOSAVESUBDIR") )
201
		else if ( str.Compare("NOSAVESUBDIR") )
199
			f |= EXEFLAG_NOSAVESUBDIR;
202
			f |= EXEFLAG_NOSAVESUBDIR;
200
		else {
203
		else {
201
			if ( str.isNumber() )
204
			if ( str.isNumber() )
202
				f |= (long)str;
205
				f |= (long)str;
203
		}
206
		}
204
	}
207
	}
205
 
208
 
Line 253... Line 256...
253
	}
256
	}
254
	File.close();
257
	File.close();
255
	return true;
258
	return true;
256
}
259
}
257
 
260
 
258
Utils::String CGameExe::GetGameRunExe(const Utils::String &dir)
261
Utils::String CGameExe::GetGameRunExe(const Utils::String &dir) const
259
{
262
{
260
	CDirIO Dir(dir);
263
	CDirIO Dir(dir);
261
	int count = 0;
264
	int count = 0;
262
	for ( CListNode<SGameExe> *node = m_lExe.Front(); node; node = node->next() )
265
	for ( CListNode<SGameExe> *node = m_lExe.Front(); node; node = node->next() )
263
	{
266
	{
264
		SGameExe *exe = node->Data();
267
		SGameExe *exe = node->Data();
265
		if ( Dir.Exists(exe->sExe) )
268
		if ( Dir.exists(exe->sExe) )
266
			return dir + "/" + exe->sExe;
269
			return dir + "/" + exe->sExe;
267
		if ( !exe->sAddon.empty() ) {
270
		if ( !exe->sAddon.empty() ) {
268
			if ( Dir.TopDir().Compare(CyString(exe->sAddon)) )
271
			if ( Dir.topDir().Compare(exe->sAddon) )
269
				return this->GetGameDir(dir) + "/" + exe->sExe;
272
				return this->GetGameDir(dir) + "/" + exe->sExe;
270
		}
273
		}
271
		++count;
274
		++count;
272
	}
275
	}
273
 
276
 
274
	return "";
277
	return "";
275
}
278
}
276
 
279
 
277
Utils::String CGameExe::GetGameName(const Utils::String &gameExe)
280
Utils::String CGameExe::GetGameName(const Utils::String &gameExe) const
278
{
281
{
279
	int gameType = this->GetGameType(gameExe);
282
	int gameType = this->GetGameType(gameExe);
-
 
283
	Utils::String gameDir = this->GetProperDir(gameExe);
280
	Utils::String gameName = ExtractGameName(gameExe);
284
	Utils::String gameName = this->ExtractGameName(gameDir);
281
	if ( gameName.empty() )	gameName = this->GetGameNameFromType(gameType);
285
	if ( gameName.empty() )	gameName = this->GetGameNameFromType(gameType);
282
	if ( gameName.empty() )	return "";
286
	if ( gameName.empty() )	return "";
283
 
287
 
284
	// no version
288
	// no version
285
	Utils::String fVersion;
289
	Utils::String fVersion;
Line 301... Line 305...
301
			return gameName;
305
			return gameName;
302
	}
306
	}
303
 
307
 
304
	// return the name and the version
308
	// return the name and the version
305
	return gameName + " " + sGameVersion;
309
	return gameName + " " + sGameVersion;
306
}
310
}
307
 
311
 
308
 
312
 
309
int CGameExe::GetGameAddons(const Utils::String &dir, CyStringList &exes)
313
int CGameExe::GetGameAddons(const Utils::String &dir, Utils::CStringList &exes)
310
{
314
{
311
	int count = 0;
315
	int count = 0;
312
 
316
 
313
	CDirIO Dir(dir);
317
	CDirIO Dir(dir);
314
 
318
 
315
	for ( CListNode<SGameExe> *node = m_lExe.Front(); node; node = node->next() )
319
	for ( CListNode<SGameExe> *node = m_lExe.Front(); node; node = node->next() )
316
	{
320
	{
317
		SGameExe *exe = node->Data();
321
		SGameExe *exe = node->Data();
318
		if ( !(exe->iFlags & EXEFLAG_ADDON) )
322
		if ( !(exe->iFlags & EXEFLAG_ADDON) )
319
			continue;
323
			continue;
320
		if ( Dir.Exists(exe->sExe) ) {
324
		if ( Dir.exists(exe->sExe) ) {
321
			if ( Dir.Exists(exe->sAddon) ) {			
325
			if ( Dir.exists(exe->sAddon) ) {			
322
				exes.PushBack(CyString(exe->sExe), CyString(exe->sAddon));
326
				exes.pushBack(exe->sExe, exe->sAddon);
323
				++count;
327
				++count;
324
			}
328
			}
325
		}
329
		}
326
	}
330
	}
327
 
331
 
328
	return count;
332
	return count;
329
}
333
}
330
 
334
 
331
Utils::String CGameExe::GetAddonDir(const Utils::String &dir)
335
Utils::String CGameExe::GetAddonDir(const Utils::String &dir) const
332
{
336
{
333
	int gameType = this->GetGameType(dir);
337
	int gameType = this->GetGameType(dir);
334
	if ( gameType != -1 ) {
338
	if ( gameType != -1 ) {
335
		return m_lExe[gameType]->sAddon;
339
		return m_lExe[gameType]->sAddon;
336
	}
340
	}
337
 
341
 
338
	return "";
342
	return "";
339
}
343
}
-
 
344
 
-
 
345
bool CGameExe::isAddon(const Utils::String &exe) const
-
 
346
{
-
 
347
	SGameExe *e = gameExe(exe);
-
 
348
	if (e && (e->iFlags & EXEFLAG_ADDON))
-
 
349
		return true;
-
 
350
 
-
 
351
	return false;
-
 
352
}
-
 
353
 
-
 
354
int CGameExe::getTextID(const Utils::String &dir) const
-
 
355
{
-
 
356
	SGameExe *e = gameExe(dir);
-
 
357
	if (e)
-
 
358
		return e->iTextNum;
-
 
359
 
-
 
360
	e = gameExe(this->GetGameRunExe(dir));
-
 
361
	if (e)
-
 
362
		return e->iTextNum;
-
 
363
 
-
 
364
	return 0;
-
 
365
}
340
 
366
 
341
Utils::String CGameExe::GetProperDir(const Utils::String &dir)
367
Utils::String CGameExe::GetProperDir(const Utils::String &dir) const
342
{
368
{
343
	CDirIO Dir(dir);
369
	CDirIO Dir(dir);
-
 
370
 
344
	int gameType = this->GetGameType(dir);
371
	int gameType = this->GetGameType(dir);
345
	if ( gameType != -1 ) {
372
	if ( gameType != -1 ) {
346
		if ( !m_lExe[gameType]->sAddon.empty() ) {
373
		if ( !m_lExe[gameType]->sAddon.empty() ) {
347
			if ( CDirIO(dir).IsFile() ) return CFileIO(dir).dir() + "/" + m_lExe[gameType]->sAddon;
374
			if ( CDirIO(dir).IsFile() ) return this->GetGameDir(dir) + "/" + m_lExe[gameType]->sAddon;
348
			return Dir.Dir(m_lExe[gameType]->sAddon).ToString();
375
			return CDirIO(this->GetGameDir(dir)).dir(m_lExe[gameType]->sAddon);
349
		}
376
		}
350
	}
377
	}
351
 
378
 
352
	return CDirIO(dir).IsFile() ? CFileIO(dir).dir() : dir;
379
	return CDirIO(dir).IsFile() ? CFileIO(dir).dir() : dir;
353
}
380
}
354
 
381
 
355
int CGameExe::GetGameFlags(int game)
382
int CGameExe::GetGameFlags(int game)
356
{
383
{
357
	if ( game == -1 )
384
	if ( game == -1 )
358
		return 0;
385
		return 0;
359
 
386
 
360
	SGameExe *exe = m_lExe[game];
387
	SGameExe *exe = m_lExe[game];
361
	if ( !exe )
388
	if ( !exe )
362
		return 0;
389
		return 0;
Line 365... Line 392...
365
}
392
}
366
 
393
 
367
int CGameExe::GetMaxPatch(int game)
394
int CGameExe::GetMaxPatch(int game)
368
{
395
{
369
	if ( game == -1 )
396
	if ( game == -1 )
370
		return 0;
397
		return 0;
371
 
398
 
372
	SGameExe *exe = m_lExe[game];
399
	SGameExe *exe = m_lExe[game];
373
	if ( !exe )
400
	if ( !exe )
374
		return 0;
401
		return 0;
375
 
402
 
376
	return exe->iMaxPatch;
403
	return exe->iMaxPatch;
377
}
404
}
378
 
405
 
379
Utils::String CGameExe::GetGameNameFromType(int type)
406
Utils::String CGameExe::GetGameNameFromType(int type) const
380
{
407
{
381
	if ( type == -1 ) return "";
408
	if ( type == -1 ) return "";
382
 
409
 
383
	SGameExe *exe = m_lExe[type];
410
	SGameExe *exe = m_lExe.Get(type);
384
	if ( !exe ) return "";
411
	if ( !exe ) return "";
385
 
412
 
386
	return exe->sName;
413
	return exe->sName;
387
}
414
}
388
 
415
 
389
Utils::String CGameExe::GetGameVersionFromType(int game, int gameVersion, const Utils::String &fGameVersion)
416
Utils::String CGameExe::GetGameVersionFromType(int game, int gameVersion, const Utils::String &fGameVersion) const
390
{
417
{
391
	SGameExe *exe = m_lExe[game];
418
	SGameExe *exe = m_lExe[game];
392
	if ( !exe ) return "";
419
	if ( !exe ) return "";
393
 
420
 
394
	SGameExeVersion *version = exe->lVersions[gameVersion];
421
	SGameExeVersion *version = exe->lVersions[gameVersion];
Line 399... Line 426...
399
	}
426
	}
400
 
427
 
401
	return version->sName;
428
	return version->sName;
402
}
429
}
403
 
430
 
404
Utils::String CGameExe::GetGameDir(const Utils::String &dir) 
431
Utils::String CGameExe::GetGameDir(const Utils::String &dir) const
405
{
432
{
406
	CDirIO Dir(dir);
433
	CDirIO Dir(dir);
407
 
434
 
408
	for ( CListNode<SGameExe> *node = m_lExe.Front(); node; node = node->next() )
435
	for ( CListNode<SGameExe> *node = m_lExe.Front(); node; node = node->next() )
409
	{
436
	{
Line 411... Line 438...
411
		if ( CDirIO(dir).IsFile() ) {
438
		if ( CDirIO(dir).IsFile() ) {
412
			if ( CFileIO(dir).filename().Compare(exe->sExe) )
439
			if ( CFileIO(dir).filename().Compare(exe->sExe) )
413
				return CFileIO(dir).dir();
440
				return CFileIO(dir).dir();
414
		}
441
		}
415
		else {
442
		else {
416
			if ( Dir.Exists(exe->sExe) ) return dir;
443
			if ( Dir.exists(exe->sExe) ) return dir;
417
			// check for addon dir
444
			// check for addon dir
418
			if ( !exe->sAddon.empty() ) {
445
			if ( !exe->sAddon.empty() ) {
419
				if ( exe->sAddon.Compare(Dir.TopDir().ToString()) )
446
				if ( exe->sAddon.Compare(Dir.topDir()) )
420
					return Dir.Back().ToString();
447
					return Dir.Back().ToString();
421
			}
448
			}
422
		}
449
		}
423
	}
450
	}
424
 
451
 
425
	return dir;
452
	return dir;
426
}
453
}
427
int CGameExe::GetGameType(const Utils::String &gameExe)
454
int CGameExe::GetGameType(const Utils::String &gameExe) const
428
{
455
{
429
	CDirIO Dir (gameExe);
456
	CDirIO Dir (gameExe);
430
	int count = 0;
457
	int count = 0;
431
 
458
 
432
	for ( CListNode<SGameExe> *node = m_lExe.Front(); node; node = node->next() )
459
	for ( CListNode<SGameExe> *node = m_lExe.Front(); node; node = node->next() )
Line 435... Line 462...
435
		if ( CDirIO(gameExe).IsFile() ) {
462
		if ( CDirIO(gameExe).IsFile() ) {
436
			if ( CFileIO(gameExe).filename().Compare(exe->sExe) )
463
			if ( CFileIO(gameExe).filename().Compare(exe->sExe) )
437
				return count;
464
				return count;
438
		}
465
		}
439
		else {
466
		else {
440
			if ( Dir.Exists(exe->sExe) )
467
			if ( Dir.exists(exe->sExe) )
441
				return count;
468
				return count;
442
			// check for addon dir
469
			// check for addon dir
443
			if ( !exe->sAddon.empty() ) {
470
			if ( !exe->sAddon.empty() ) {
444
				if ( exe->sAddon.Compare(Dir.TopDir().ToString()) )
471
				if ( exe->sAddon.Compare(Dir.topDir()) )
445
					return count;
472
					return count;
446
			}
473
			}
447
		}
474
		}
448
		++count;
475
		++count;
449
	}
476
	}
450
 
477
 
451
	return -1;
478
	return -1;
452
}
479
}
453
 
480
 
454
Utils::String CGameExe::ExtractGameName(const Utils::String &gameDir)
481
Utils::String CGameExe::ExtractGameName(const Utils::String &gameDir) const
455
{
482
{
-
 
483
	Utils::String dir = this->GetProperDir(gameDir);
456
	CDirIO Dir(gameDir);
484
	CDirIO Dir(dir);
457
 
485
 
458
	Utils::String sText = this->_extractTextData(this->_readTextFile(gameDir), 1910, 1216);
486
	Utils::String sText = this->_extractTextData(this->_readTextFile(dir), 1910, 1216, this->getTextID(gameDir));
459
	if ( sText.empty() ) return "";
487
	if ( sText.empty() ) return "";
460
	int end = sText.findPos("\\n");
488
	int end = sText.findPos("\\n");
461
	if ( end >= 0 ) return sText.left(end);
489
	if ( end >= 0 ) return sText.left(end);
462
 
490
 
463
	return "";
491
	return "";
464
}
492
}
465
 
493
 
466
Utils::String CGameExe::_textFileName(const Utils::String &sGameDir)
494
Utils::String CGameExe::_textFileName(const Utils::String &sGameDir) const
467
{
495
{
-
 
496
	int lang = 44;
-
 
497
 
468
	CDirIO Dir(sGameDir);
498
	CDirIO Dir(sGameDir);
-
 
499
	if (Dir.exists("t"))
-
 
500
	{
469
	if ( Dir.Exists("t") && Dir.Exists("t/0002.pck") ) return "t/0002.pck";
501
		if (Dir.exists("t/0002.pck")) return "t/0002.pck";
470
	else if ( Dir.Exists("t") && Dir.Exists(";t/440002.pck") ) return "t/440002.pck";
502
		else if (Dir.exists(";t/0002.xml")) return "t/0002.xml";
-
 
503
		else if (Dir.exists(Utils::String::Format("t/%d0002.pck", lang))) return Utils::String::Format("t/%d0002.pck", lang);
-
 
504
		else if (Dir.exists(Utils::String::Format("t/%d0002.xml", lang))) return Utils::String::Format("t/%d0002.xml", lang);
471
	else if ( Dir.Exists("t") && Dir.Exists("t/0002-L044.pck";) ) return "t/0002-L044.pck";
505
		else if (Dir.exists(Utils::String::Format("t/0002-L%03d.pck";, lang))) return Utils::String::Format("t/0002-L%03d.pck", lang);
-
 
506
		else if (Dir.exists(Utils::String::Format("t/0002-L%03d.xml", lang))) return Utils::String::Format("t/0002-L%03d.xml", lang);
-
 
507
	}
472
	return "";
508
	return "";
473
}
509
}
474
 
510
 
475
Utils::String CGameExe::_readTextFile(const Utils::String &sGameDir)
511
Utils::String CGameExe::_readTextFile(const Utils::String &sGameDir) const
476
{
512
{
477
	Utils::String textFileName = _textFileName(sGameDir);;
513
	Utils::String textFileName = _textFileName(sGameDir);
478
	if ( !textFileName.empty() ) {
514
	if ( !textFileName.empty() )
-
 
515
	{
479
		Utils::String sVersion;
516
		Utils::String sVersion;
480
 
517
 
481
		CDirIO Dir(sGameDir);
518
		CDirIO Dir(sGameDir);
482
		CFileIO File(Dir.File(textFileName));
519
		CFileIO File(Dir.File(textFileName));
483
		size_t fileSize;
520
		size_t fileSize;
484
		unsigned char *fileData = File.readAll(&fileSize);
521
		unsigned char *fileData = File.readAll(&fileSize);
485
		if ( fileData && fileSize) {
522
		if ( fileData && fileSize) 
-
 
523
		{
-
 
524
			if (CFileIO(textFileName).isFileExtension("pck"))
-
 
525
			{
486
			size_t newFileSize;
526
				size_t newFileSize;
487
			unsigned char *pckData = UnPCKData((unsigned char *)fileData, fileSize, &newFileSize);
527
				unsigned char *pckData = UnPCKData((unsigned char *)fileData, fileSize, &newFileSize);
488
			delete fileData;
528
				delete fileData;
489
			pckData[newFileSize -1] = '\0';
529
				pckData[newFileSize - 1] = '\0';
490
			Utils::String Data((char *)pckData);
530
				Utils::String Data((char *)pckData);
491
			delete pckData;
531
				delete pckData;
-
 
532
				return Data;
-
 
533
			}
-
 
534
			else if (CFileIO(textFileName).isFileExtension("xml"))
-
 
535
			{
-
 
536
				Utils::String Data((char *)fileData);
-
 
537
				delete fileData;
492
			return Data;
538
				return Data;
-
 
539
			}
493
		}
540
		}
494
	}
541
	}
495
 
542
 
496
	return "";
543
	return "";
497
}
544
}
498
 
545
 
499
Utils::String CGameExe::_extractTextData(const Utils::String &sData, long iPage, long iID)
546
Utils::String CGameExe::_extractTextData(const Utils::String &sData, long iPage, long iID, int iGameID) const
500
{
547
{
501
	Utils::String sPage = Utils::String("<page id=\"") + iPage + "\"";
-
 
502
	Utils::String sID = Utils::String("<t id=\"") + iID + "\">";
548
	Utils::String sID = Utils::String("<t id=\"") + iID + "\">";
503
 
549
 
-
 
550
	if (iGameID > 0)
-
 
551
	{
-
 
552
		Utils::String sPage = Utils::String("<page id=\"") + Utils::String::Number(iGameID) + iPage + "\"";
-
 
553
 
504
	int startpage = sData.findPos(sPage);
554
		int startpage = sData.findPos(sPage);
-
 
555
		if (startpage >= 0) {
-
 
556
			int start = sData.findPos(sID, startpage);
-
 
557
			if (start >= 0) {
-
 
558
				start += sID.length();
-
 
559
				int end = sData.findPos("</t>", start);
-
 
560
				return sData.mid(start, end);
-
 
561
			}
-
 
562
		}
-
 
563
	}
-
 
564
 
-
 
565
	{
-
 
566
		Utils::String sPage = Utils::String("<page id=\"") + iPage + "\"";
-
 
567
 
-
 
568
		int startpage = sData.findPos(sPage);
505
	if ( startpage >= 0 ) {
569
		if (startpage >= 0) {
506
		int start = sData.findPos(sID, startpage);
570
			int start = sData.findPos(sID, startpage);
507
		if ( start >= 0 ) {
571
			if (start >= 0) {
508
			start += sID.length();
572
				start += sID.length();
509
			int end = sData.findPos("</t>", start);
573
				int end = sData.findPos("</t>", start);
510
			return sData.mid(start, end);
574
				return sData.mid(start, end);
-
 
575
			}
511
		}
576
		}
512
	}
577
	}
513
 
578
 
514
	return "";
579
	return "";
515
}
580
}
516
 
581
 
517
bool CGameExe::GetGameVersionName(const Utils::String &sGameExe, Utils::String *versionName)
582
bool CGameExe::GetGameVersionName(const Utils::String &sGameExe, Utils::String *versionName) const
518
{
583
{
519
	int gameType = this->GetGameType(sGameExe);
584
	int gameType = this->GetGameType(sGameExe);
520
 
585
 
521
	if ( gameType == -1 )
586
	if ( gameType == -1 )
522
		return false;
587
		return false;
523
 
588
 
524
	Utils::String gameDir = sGameExe;
-
 
525
	Utils::String gameExe = this->GetGameDir(sGameExe) + "/" + m_lExe[gameType]->sExe;
589
	Utils::String gameExe = this->GetGameDir(sGameExe) + "/" + m_lExe[gameType]->sExe;
-
 
590
	Utils::String gameDir = this->GetProperDir(gameExe);
526
	int size = (int)CFileIO(gameExe).GetFilesize();
591
	int size = (int)CFileIO(gameExe).GetFilesize();
527
 
592
 
528
	Utils::String fVersion;
593
	Utils::String fVersion;
529
	int version = this->_findVersion(gameType, size, &fVersion);
594
	int version = this->_findVersion(gameType, size, &fVersion);
530
	// not matched version
595
	// not matched version
Line 533... Line 598...
533
	if ( version != -1 ) {
598
	if ( version != -1 ) {
534
		(*versionName) = this->GetGameVersionFromType(gameType, version, fVersion);
599
		(*versionName) = this->GetGameVersionFromType(gameType, version, fVersion);
535
		return true;
600
		return true;
536
	}
601
	}
537
 
602
 
538
	Utils::String sText = this->_extractTextData(this->_readTextFile(gameDir), 1910, 1216);
603
	Utils::String sText = this->_extractTextData(this->_readTextFile(gameDir), 1910, 1216, this->getTextID(gameExe));
539
	Utils::String sVersion = sText.between("Version ", ", ");
604
	Utils::String sVersion = sText.between("Version ", ", ");
540
	if ( sVersion.empty() ) sVersion = sText.between("ver=", "&amp");
605
	if ( sVersion.empty() ) sVersion = sText.between("ver=", "&amp");
541
 
606
 
542
	if ( !sVersion.empty() ) {
607
	if ( !sVersion.empty() ) {
543
		// lets match the version
608
		// lets match the version
Line 563... Line 628...
563
	}
628
	}
564
 
629
 
565
	return true;
630
	return true;
566
}
631
}
567
 
632
 
568
int CGameExe::GetGameVersion(const Utils::String &sGameExe, Utils::String *a_fVersion)
633
int CGameExe::GetGameVersion(const Utils::String &sGameExe, Utils::String *a_fVersion) const
569
{
634
{
570
	Utils::String gameExe = sGameExe;
635
	Utils::String gameExe = sGameExe;
571
 
636
 
572
	int gameType = this->GetGameType(gameExe);
637
	int gameType = this->GetGameType(gameExe);
573
 
638
 
Line 581... Line 646...
581
		gameExe = gameExe + "/" + m_lExe[gameType]->sExe;
646
		gameExe = gameExe + "/" + m_lExe[gameType]->sExe;
582
	int size = (int)CFileIO(gameExe).GetFilesize();
647
	int size = (int)CFileIO(gameExe).GetFilesize();
583
 
648
 
584
	int version = this->_findVersion(gameType, size, a_fVersion);
649
	int version = this->_findVersion(gameType, size, a_fVersion);
585
 
650
 
586
	Utils::String sText = this->_extractTextData(this->_readTextFile(gameDir), 1910, 10000);
651
	Utils::String sText = this->_extractTextData(this->_readTextFile(gameDir), 1910, 10000, this->getTextID(gameExe));
587
	Utils::String sVersion = sText.between("ver=", "&amp");
652
	Utils::String sVersion = sText.between("ver=", "&amp");
588
 
653
 
589
	if ( !sVersion.empty() )
654
	if ( !sVersion.empty() )
590
	{
655
	{
591
		// lets match the version
656
		// lets match the version