Subversion Repositories spk

Rev

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

Rev 9 Rev 10
Line 72... Line 72...
72
	Return: Boolean - returns true if value exists
72
	Return: Boolean - returns true if value exists
73
	Desc:   Reads the line and assigns the parameters for the file
73
	Desc:   Reads the line and assigns the parameters for the file
74
*/
74
*/
75
bool CSpkFile::ParseValueLine ( CyString line )
75
bool CSpkFile::ParseValueLine ( CyString line )
76
{
76
{
77
	CyString first = line.GetToken ( 1, ' ' );
77
	Utils::String first = line.GetToken ( 1, ' ' ).ToString();
78
	CyString rest  = line.GetToken ( 2, -1, ' ' );
78
	Utils::String rest  = line.GetToken ( 2, -1, ' ' ).ToString();
79
 
79
 
80
	if ( first == "AnotherMod:" )
80
	if ( first == "AnotherMod:" )
81
	{
81
	{
82
		m_sOtherAuthor = rest.GetToken ( 1, '|' );
82
		m_sOtherAuthor = rest.token("|", 1);
83
		m_sOtherName = rest.GetToken ( 2, -1, '|' );
83
		m_sOtherName = rest.tokens("|", 2);
84
	}
84
	}
85
	else if ( line == "CustomStart" )
85
	else if ( line == "CustomStart" )
86
		m_iPackageType = PACKAGETYPE_CUSTOMSTART;
86
		m_iPackageType = PACKAGETYPE_CUSTOMSTART;
87
	else if ( line == "PackageUpdate" )
87
	else if ( line == "PackageUpdate" )
88
		m_iPackageType = PACKAGETYPE_UPDATE;
88
		m_iPackageType = PACKAGETYPE_UPDATE;
Line 93... Line 93...
93
	else if ( line == "Signed" )
93
	else if ( line == "Signed" )
94
		m_bSigned = true;
94
		m_bSigned = true;
95
	else if ( first == "ScriptType:" )
95
	else if ( first == "ScriptType:" )
96
		m_sScriptType = rest;
96
		m_sScriptType = rest;
97
	else if ( first == "ScriptTypeNew:" )
97
	else if ( first == "ScriptTypeNew:" )
98
		m_iScriptType = rest.ToInt();
98
		m_iScriptType = rest;
99
	else if ( first == "PackageType:" )
99
	else if ( first == "PackageType:" )
100
		m_iPackageType = rest.ToInt();
100
		m_iPackageType = rest;
101
	else if ( first == "Ware:" )
101
	else if ( first == "Ware:" )
102
		AddWare ( rest );
102
		AddWare ( rest );
103
	else if ( (first == "WareText:") && (m_pLastWare) )
103
	else if ( (first == "WareText:") && (m_pLastWare) )
104
		AddWareText ( rest );
104
		AddWareText ( rest );
105
	else if ( first == "Setting:" )
105
	else if ( first == "Setting:" )
106
	{
106
	{
107
		SSettingType *t = AddSetting ( rest.GetToken ( 2, '|' ), rest.GetToken ( 1, '|' ).ToInt() );
107
		SSettingType *t = AddSetting ( rest.token("|", 2), rest.token("|", 1) );
108
		ConvertSetting ( t, rest.GetToken ( 3, -1, '|' ) );
108
		ConvertSetting ( t, rest.tokens("|", 3));
109
	}
109
	}
110
	else
110
	else
111
		return CBaseFile::ParseValueLine ( line );
111
		return CBaseFile::ParseValueLine ( line );
112
 
112
 
113
	return true;
113
	return true;
Line 120... Line 120...
120
*/
120
*/
121
CyString CSpkFile::CreateValuesLine ()
121
CyString CSpkFile::CreateValuesLine ()
122
{
122
{
123
	CyString values = CBaseFile::CreateValuesLine ();
123
	CyString values = CBaseFile::CreateValuesLine ();
124
	// combine all values together
124
	// combine all values together
125
	if ( (!m_sOtherAuthor.Empty()) && (!m_sOtherName.Empty()) )
125
	if ( (!m_sOtherAuthor.empty()) && (!m_sOtherName.empty()) )
126
		values += (CyString("AnotherMod: ") + m_sOtherAuthor + "|" + m_sOtherName + "\n");
126
		values += (CyString("AnotherMod: ") + m_sOtherAuthor + "|" + m_sOtherName + "\n");
127
	if ( m_bForceProfile )
127
	if ( m_bForceProfile )
128
		values += "ForceProfile\n";
128
		values += "ForceProfile\n";
129
	if ( !m_sScriptType.Empty() )
129
	if ( !m_sScriptType.empty() )
130
		values += (CyString("ScriptType: ") + m_sScriptType + "\n");
130
		values += (CyString("ScriptType: ") + m_sScriptType + "\n");
131
	values += (CyString("PackageType: ") + (long)m_iPackageType + "\n");
131
	values += (CyString("PackageType: ") + (long)m_iPackageType + "\n");
132
	values += (CyString("ScriptTypeNew: ") + (long)m_iScriptType + "\n");
132
	values += (CyString("ScriptTypeNew: ") + (long)m_iScriptType + "\n");
133
 
133
 
134
	for ( SSettingType *st = m_lSettings.First(); st; st = m_lSettings.Next() )
134
	for ( SSettingType *st = m_lSettings.First(); st; st = m_lSettings.Next() )
Line 145... Line 145...
145
	}
145
	}
146
 
146
 
147
	return values;
147
	return values;
148
}
148
}
149
 
149
 
150
CyString CSpkFile::GetCustomScriptType (int lang)
150
Utils::String CSpkFile::GetCustomScriptType (int lang)
151
{
151
{
152
	if ( !m_sScriptType.Empty() )
152
	if ( !m_sScriptType.empty() )
153
	{
153
	{
154
		int max;
154
		int max;
155
		CyString *split = m_sScriptType.SplitToken("<br>", &max);
155
		Utils::String *split = m_sScriptType.tokenise("<br>", &max);
156
		if ( max && split )
156
		if ( max && split )
157
		{
157
		{
158
			for ( int i = 1; i < max; i++ )
158
			for ( int i = 1; i < max; i++ )
159
			{
159
			{
160
				CyString str = split[i];
160
				Utils::String str = split[i];
161
				int num = str.GetToken(":", 1, 1).ToInt();
161
				int num = str.token(":", 1);
162
				CyString name = str.GetToken(":", 2);
162
				Utils::String name = str.tokens(":", 2);
163
 
163
 
164
				if ( num == lang )
164
				if ( num == lang )
165
				{
165
				{
166
					CLEANSPLIT(split, max)
166
					CLEANSPLIT(split, max)
167
					return name;
167
					return name;
168
				}
168
				}
169
			}
169
			}
170
 
170
 
171
			CyString ret = split[0];
171
			Utils::String ret = split[0];
172
			CLEANSPLIT(split, max)
172
			CLEANSPLIT(split, max)
173
 
173
 
174
			return ret;
174
			return ret;
175
		}
175
		}
176
		CLEANSPLIT(split, max)
176
		CLEANSPLIT(split, max)
Line 184... Line 184...
184
	if ( ferror(id) )
184
	if ( ferror(id) )
185
		return false;
185
		return false;
186
	return true;
186
	return true;
187
}
187
}
188
 
188
 
189
void CSpkFile::AddWareText ( CyString rest )
189
void CSpkFile::AddWareText(const Utils::String &sData)
190
{
190
{
191
	if ( !m_pLastWare )
191
	if ( !m_pLastWare )
192
		return;
192
		return;
193
 
193
 
194
	SWaresText *wt = new SWaresText;
194
	SWaresText *wt = new SWaresText;
195
	wt->iLang = rest.GetToken ( 1, ' &apos; ).ToInt();
195
	wt->iLang = sData.token(&quot; ", 1);
196
	wt->sName = rest.GetToken ( 2, -1, ' &apos; ).GetToken ( 1, &apos;|&apos; );
196
	wt->sName = sData.tokens(&quot; ", 2).token(&quot;|&quot;, 1);
197
	wt->sDesc = rest.GetToken ( 2, -1, ' &apos; ).GetToken ( 2, -1, &apos;|&apos; );
197
	wt->sDesc = sData.tokens(&quot; ", 2).tokens(&quot;|&quot;, 2);
198
	m_pLastWare->lText.push_back ( wt );
198
	m_pLastWare->lText.push_back ( wt );
199
 
199
 
200
	m_bChanged = true;
200
	m_bChanged = true;
201
}
201
}
202
 
202
 
203
void CSpkFile::AddWare ( CyString rest )
203
void CSpkFile::AddWare(const Utils::String &sData)
204
{
204
{
205
	SWares *ware = new SWares;
205
	SWares *ware = new SWares;
206
	ware->iTextID = -1;
206
	ware->iTextID = -1;
207
	ware->iTextPage = 0;
207
	ware->iTextPage = 0;
208
	ware->cType = rest.GetToken ( 1, &apos;:&apos; )[0];
208
	ware->cType = sData.token(&quot;:&quot;, 1)[0];
209
	ware->iPrice = rest.GetToken ( 2, ':&apos; ).ToLong();
209
	ware->iPrice = sData.token(":&quot;, 2);
210
	ware->iSize = rest.GetToken ( 3, ':&apos; ).ToInt();
210
	ware->iSize = sData.token(":&quot;, 3);
211
	ware->iVolumn = rest.GetToken ( 4, ':&apos; ).ToInt();
211
	ware->iVolumn = sData.token(":&quot;, 4);
212
	ware->sID = rest.GetToken ( 5, &apos;:&apos; );
212
	ware->sID = sData.token(&quot;:&quot;, 5);
213
	ware->iNotority = rest.GetToken ( 6, ':&apos; ).ToInt();
213
	ware->iNotority = sData.token(":&quot;, 6);
214
	if ( !rest.GetToken( 7, &apos;:&apos; ).Empty() )
214
	if ( !sData.token(&quot;:&quot;, 7).empty() )
215
	{
215
	{
216
		CyString r = rest.GetToken ( 7, &apos;:&apos; );
216
		Utils::String r = sData.token(&quot;:&quot;, 7);
217
		ware->iTextID = r.GetToken(",", 1, 1).ToInt();
217
		ware->iTextID = r.token(",", 1);
218
		ware->iTextPage = r.GetToken(",", 2, 2).ToInt();
218
		ware->iTextPage = r.token(",", 2);
219
	}
219
	}
220
	m_lWares.push_back ( ware );
220
	m_lWares.push_back ( ware );
221
	m_pLastWare = ware;
221
	m_pLastWare = ware;
222
 
222
 
223
	m_bChanged = true;
223
	m_bChanged = true;
Line 302... Line 302...
302
 
302
 
303
 
303
 
304
 
304
 
305
void CSpkFile::ClearWares()
305
void CSpkFile::ClearWares()
306
{
306
{
307
	for ( CListNode<SWares> *node = m_lWares.Front(); node; node = node->next() )
307
	for ( CListNode<SWares> *node = m_lWares.Front(); node; node = node->next() ) {
308
	{
-
 
309
		node->Data()->lText.clear(true);
308
		node->Data()->lText.clear(true);
310
		node->DeleteData();
309
		node->DeleteData();
311
	}
310
	}
312
	m_bChanged = true;
311
	m_bChanged = true;
313
	m_lWares.clear(true);
312
	m_lWares.clear(true);
314
}
313
}
315
 
314
 
316
SWares *CSpkFile::FindWare ( CyString id )
315
SWares *CSpkFile::FindWare(const Utils::String &id) const
317
{
316
{
318
	for ( SWares *w = m_lWares.First(); w; w = m_lWares.Next() )
317
	for ( CListNode<SWares> *node = m_lWares.Front(); node; node = node->next() ) {
319
	{
318
		SWares *w = node->Data();
320
		if ( w->sID.ToUpper() == id.ToUpper() )
319
		if ( w->sID.Compare(id) ) {
321
			return w;
320
			return w;
-
 
321
		}
322
	}
322
	}
323
	return NULL;
323
	return NULL;
324
}
324
}
325
 
325
 
326
void CSpkFile::RemoveWare ( CyString id )
326
void CSpkFile::RemoveWare(const Utils::String &id )
327
{
327
{
328
	for ( SWares *w = m_lWares.First(); w; w = m_lWares.Next() )
328
	for ( CListNode<SWares> *node = m_lWares.Front(); node; node = node->next() ) {
329
	{
329
		SWares *w = node->Data();
330
		if ( w->sID.ToUpper() == id.ToUpper() )
330
		if ( w->sID.Compare(id) ) {
331
		{
-
 
332
			m_lWares.RemoveCurrent ();
331
			m_lWares.RemoveCurrent ();
333
			delete w;
332
			delete w;
334
			m_bChanged = true;
333
			m_bChanged = true;
335
			return;
334
			return;
336
		}
335
		}
-
 
336
	}
-
 
337
}
-
 
338
 
-
 
339
void CSpkFile::AddWare(SWares *ware)
-
 
340
{
-
 
341
	ware->sID.remove(' ');
-
 
342
 
-
 
343
	SWares *newware = this->FindWare(ware->sID);
-
 
344
	if ( newware ) {
-
 
345
		m_lWares.remove(newware);
337
	}
346
	}
338
}
-
 
339
 
347
 
340
void CSpkFile::AddWare ( SWares *ware )
-
 
341
{
-
 
342
	ware->sID.RemoveChar ( ' ' );
-
 
343
	ware->sID = ware->sID.ToUpper();
-
 
344
 
-
 
345
	SWares *newware = FindWare ( ware->sID );
-
 
346
	if ( newware )
-
 
347
		m_lWares.remove ( newware );
-
 
348
 
-
 
349
	m_lWares.push_back ( ware );
348
	m_lWares.push_back(ware);
350
	m_bChanged = true;
349
	m_bChanged = true;
351
}
350
}
352
 
351
 
353
void CSpkFile::AddWareText ( SWares *w, int lang, CyString name, CyString desc )
352
void CSpkFile::AddWareText(SWares *pWare, int iLang, const Utils::String &sName, const Utils::String &sDesc)
354
{
353
{
355
	SWaresText *wt;
354
	SWaresText *wt;
356
	for ( wt = w->lText.First(); wt; wt = w->lText.Next() )
355
	for ( CListNode<SWaresText> *node = pWare->lText.Front(); node; node = node->next() ) {
357
	{
356
		wt = node->Data();
358
		if ( wt->iLang == lang )
357
		if ( wt->iLang == iLang ) {
359
		{
-
 
360
			wt->sDesc = desc;
358
			wt->sDesc = sDesc;
361
			wt->sName = name;
359
			wt->sName = sName;
362
			return;
360
			return;
363
		}
361
		}
364
	}
362
	}
365
 
363
 
366
	wt = new SWaresText;
364
	wt = new SWaresText;
367
	wt->iLang = lang;
365
	wt->iLang = iLang;
368
	wt->sName = name;
366
	wt->sName = sName;
369
	wt->sDesc = desc;
367
	wt->sDesc = sDesc;
370
 
368
 
371
	w->lText.push_back ( wt );
369
	pWare->lText.push_back(wt);
372
	m_bChanged = true;
370
	m_bChanged = true;
373
}
371
}
374
 
372
 
375
 
373
 
376
void CSpkFile::ClearWareText ( CyString id )
374
void CSpkFile::ClearWareText(const Utils::String &id)
377
{
375
{
378
	SWares *w = FindWare ( id );
376
	SWares *w = FindWare(id);
379
	ClearWareText ( w );
377
	ClearWareText(w);
380
}
378
}
381
 
379
 
382
void CSpkFile::ClearWareText ( SWares *w )
380
void CSpkFile::ClearWareText(SWares *w)
383
{
381
{
384
	if ( !w ) return;
382
	if ( !w ) return;
385
 
383
 
386
	w->lText.clear(true);
384
	w->lText.clear(true);
387
	m_bChanged = true;
385
	m_bChanged = true;
388
}
386
}
389
 
387
 
390
void CSpkFile::RemoveWareText ( CyString wid, int lang )
388
void CSpkFile::RemoveWareText(const Utils::String &wid, int lang)
391
{
389
{
392
	SWares *w = FindWare ( wid );
390
	SWares *w = FindWare(wid);
393
	if ( w )
391
	if ( w )
394
	{
392
	{
395
		for ( SWaresText *wt = w-&gt;lText.First(); wt; wt = w->lText.Next() )
393
		for ( CListNode<SWaresText> *node = w-&gt;lText.Front(); node; node = node->next() ) {
396
		{
394
			SWaresText *wt = node->Data();
397
			if ( wt->iLang == lang )
395
			if ( wt->iLang == lang ) {
398
			{
-
 
399
				w->lText.RemoveCurrent();
396
				w->lText.RemoveCurrent();
400
				m_bChanged = true;
397
				m_bChanged = true;
401
				delete wt;
398
				delete wt;
402
				break;
399
				break;
403
			}
400
			}
Line 405... Line 402...
405
	}
402
	}
406
}
403
}
407
 
404
 
408
int CSpkFile::CheckValidCustomStart ()
405
int CSpkFile::CheckValidCustomStart ()
409
{
406
{
410
 
-
 
411
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
407
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
412
	{
408
	{
413
		C_File *file = node->Data();
409
		C_File *file = node->Data();
414
		if ( file->GetFileType() != FILETYPE_SCRIPT )
410
		if ( file->GetFileType() != FILETYPE_SCRIPT )
415
			continue;
411
			continue;
Line 435... Line 431...
435
	}
431
	}
436
 
432
 
437
	return CBaseFile::UpdateSigned(updateFiles);
433
	return CBaseFile::UpdateSigned(updateFiles);
438
}
434
}
439
 
435
 
440
SSettingType *CSpkFile::AddSetting ( CyString key, int type )
436
SSettingType *CSpkFile::AddSetting(const Utils::String &key, int type )
441
{
437
{
442
	key.RemoveChar ( &apos;|' );
438
	Utils::String sKey = key.removeChar(&apos;|');
-
 
439
 
443
	SSettingType *t;
440
	SSettingType *t;
444
	for ( t = m_lSettings.First(); t; t = m_lSettings.Next() )
441
	for ( t = m_lSettings.First(); t; t = m_lSettings.Next() )
445
	{
442
	{
446
		if ( t->sKey.upper() == key.lower() )
443
		if ( t->sKey.Compare(sKey) )
447
			return NULL;
444
			return NULL;
448
	}
445
	}
449
 
446
 
450
	switch ( type )
447
	switch ( type )
451
	{
448
	{
Line 461... Line 458...
461
	}
458
	}
462
 
459
 
463
	if ( !t )
460
	if ( !t )
464
		return NULL;
461
		return NULL;
465
 
462
 
466
	t->sKey = key;
463
	t->sKey = sKey;
467
	t->iType = type;
464
	t->iType = type;
468
 
465
 
469
	m_lSettings.push_back ( t );
466
	m_lSettings.push_back ( t );
470
	m_bChanged = true;
467
	m_bChanged = true;
471
 
468
 
472
	return t;
469
	return t;
473
}
470
}
474
 
471
 
475
void CSpkFile::ConvertSetting ( SSettingType *t, CyString set )
472
void CSpkFile::ConvertSetting ( SSettingType *t, const Utils::String &set ) const
476
{
473
{
477
	if ( !t )
474
	if ( !t )
478
		return;
475
		return;
479
 
476
 
480
	switch ( t->iType )
477
	switch ( t->iType )
481
	{
478
	{
482
		case SETTING_STRING:
479
		case SETTING_STRING:
483
			((SSettingString *)t)->sValue = set;
480
			((SSettingString *)t)->sValue = set;
484
			break;
481
			break;
485
		case SETTING_INTEGER:
482
		case SETTING_INTEGER:
486
			((SSettingInteger *)t)->iValue = set.ToInt();
483
			((SSettingInteger *)t)->iValue = set;
487
			break;
484
			break;
488
		case SETTING_CHECK:
485
		case SETTING_CHECK:
489
			((SSettingCheck *)t)->bValue = set.ToBool();
486
			((SSettingCheck *)t)->bValue = set;
490
			break;
487
			break;
491
	}
488
	}
492
}
489
}
493
CyString CSpkFile::GetSetting ( SSettingType *t )
490
Utils::String CSpkFile::GetSetting ( SSettingType *t ) const
494
{
491
{
495
	if ( !t )
492
	if ( !t )
496
		return "";
493
		return "";
497
 
494
 
498
	switch ( t->iType )
495
	switch ( t->iType )
499
	{
496
	{
500
		case SETTING_STRING:
497
		case SETTING_STRING:
501
			return ((SSettingString *)t)->sValue;
498
			return ((SSettingString *)t)->sValue;
502
		case SETTING_INTEGER:
499
		case SETTING_INTEGER:
503
			return CyString::Number(((SSettingInteger *)t)->iValue);
500
			return Utils::String::number(((SSettingInteger *)t)->iValue);
504
		case SETTING_CHECK:
501
		case SETTING_CHECK:
505
			return (((SSettingInteger *)t)->iValue) ? "1" : "0";
502
			return (((SSettingInteger *)t)->iValue) ? "1" : "0";
506
	}
503
	}
507
 
504
 
508
	return "";
505
	return "";
Line 513... Line 510...
513
	m_lSettings.clear(true);
510
	m_lSettings.clear(true);
514
	m_bChanged = true;
511
	m_bChanged = true;
515
}
512
}
516
 
513
 
517
 
514
 
518
bool CSpkFile::IsMatchingMod ( CyString mod )
515
bool CSpkFile::IsMatchingMod(const Utils::String &mod)
519
{
516
{
520
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
517
	for ( CListNode<C_File> *node = m_lFiles.Front(); node; node = node->next() )
521
	{
518
	{
522
		C_File *file = node->Data();
519
		C_File *file = node->Data();
523
		if ( file->GetFileType() != FILETYPE_MOD )
520
		if ( file->GetFileType() != FILETYPE_MOD )
524
			continue;
521
			continue;
525
 
522
 
526
		if ( file->IsFakePatch() )
523
		if ( file->IsFakePatch() )
527
			continue;
524
			continue;
528
 
525
 
529
		CyString filename = file->GetBaseName();
526
		Utils::String filename = file->GetBaseName().ToString();
530
		if ( filename.lower() == mod.lower() )
527
		if ( filename.Compare(mod) )
531
			return true;
528
			return true;
532
	}
529
	}
533
	return false;
530
	return false;
534
}
531
}
535
 
532
 
536
CyString CSpkFile::GetScriptTypeString(int lang)
533
Utils::String CSpkFile::GetScriptTypeString(int lang)
537
{
534
{
538
	int iType = m_iScriptType;
535
	int iType = m_iScriptType;
539
 
536
 
540
	if ( this->IsLibrary() )
537
	if ( this->IsLibrary() )
541
		return "Library";
538
		return "Library";
Line 545... Line 542...
545
		return "Custom Start";
542
		return "Custom Start";
546
	else if ( this->IsPatch() )
543
	else if ( this->IsPatch() )
547
		return "Patch";
544
		return "Patch";
548
	else if ( m_iScriptType == SCRIPTTYPE_CUSTOM )
545
	else if ( m_iScriptType == SCRIPTTYPE_CUSTOM )
549
	{
546
	{
550
		CyString type = this->GetCustomScriptType(lang);
547
		Utils::String type = this->GetCustomScriptType(lang);
551
		if ( !type.Empty() )
548
		if ( !type.empty() )
552
			return type;
549
			return type;
553
		iType = -1;
550
		iType = -1;
554
	}
551
	}
555
 
552
 
556
	if (iType == -1)  // no script type
553
	if (iType == -1)  // no script type
557
	{
554
	{
558
		if ( this->IsFakePatch() )
555
		if ( this->IsFakePatch() )
559
			return "Fake Patch";
556
			return "Fake Patch";
560
	}
557
	}
561
 
558
 
562
	CyString sType = CSpkFile::GetScriptTypeStringStatic(m_iScriptType);
559
	Utils::String sType = CSpkFile::GetScriptTypeStringStatic(m_iScriptType);
563
 
560
 
564
	if ( sType.Empty() )
561
	if ( sType.empty() )
565
		return "Other";
562
		return "Other";
566
 
563
 
567
	return sType;	
564
	return sType;	
568
}
565
}
569
 
566
 
570
int CSpkFile::ConvertScriptType(CyString sType)
567
int CSpkFile::ConvertScriptType(const Utils::String &sType)
571
{
568
{
572
	for ( int i = 0; i < SCRIPTTYPE_MAX; i++ )
569
	for ( int i = 0; i < SCRIPTTYPE_MAX; i++ )
573
	{
570
	{
574
		if ( sType.Compare(CSpkFile::GetScriptTypeStringStatic(i)) )
571
		if ( sType.Compare(CSpkFile::GetScriptTypeStringStatic(i)) )
575
			return i;
572
			return i;
576
	}
573
	}
577
 
574
 
578
	return -1;
575
	return -1;
579
}
576
}
580
 
577
 
581
CyString CSpkFile::GetScriptTypeStringStatic(int type)
578
Utils::String CSpkFile::GetScriptTypeStringStatic(int type)
582
{
579
{
583
	switch ( type )
580
	switch ( type )
584
	{
581
	{
585
		case SCRIPTTYPE_CUSTOM:
582
		case SCRIPTTYPE_CUSTOM:
586
			return "Custom";
583
			return "Custom";
Line 623... Line 620...
623
	}
620
	}
624
 
621
 
625
	return "Other";
622
	return "Other";
626
}
623
}
627
 
624
 
628
bool CSpkFile::LoadPackageData(CyString first, CyString rest)
625
bool CSpkFile::LoadPackageData(CyString first, CyString sRest)
629
{
626
{
-
 
627
	Utils::String rest = sRest.ToString();
-
 
628
 
630
	if ( first.Compare("ScriptType") )
629
	if ( first.Compare("ScriptType") )
631
	{
630
	{
632
		if ( rest.Compare("Library") || rest.Compare("Library Script") )
631
		if ( rest.Compare("Library") || rest.Compare("Library Script") )
633
			this->SetLibrary();
632
			this->SetLibrary();
634
		else if ( rest.Compare("Update") || rest.Compare("Package Update") || rest.Compare("Mod Update") )
633
		else if ( rest.Compare("Update") || rest.Compare("Package Update") || rest.Compare("Mod Update") )
Line 637... Line 636...
637
			this->SetCustomStart();
636
			this->SetCustomStart();
638
		else if ( rest.Compare("Patch") || rest.Compare("Patch Mod") )
637
		else if ( rest.Compare("Patch") || rest.Compare("Patch Mod") )
639
			this->SetPatch();
638
			this->SetPatch();
640
		else
639
		else
641
		{
640
		{
642
			int check = rest.ToInt();
641
			int check = rest;
643
			if ( check || rest == "0" )
642
			if ( check || rest == "0" )
644
				m_iScriptType = check;
643
				m_iScriptType = check;
645
			else
644
			else
646
			{
645
			{
647
				m_iScriptType = CSpkFile::ConvertScriptType(rest);
646
				m_iScriptType = CSpkFile::ConvertScriptType(rest);
Line 650... Line 649...
650
			}
649
			}
651
		}
650
		}
652
	}
651
	}
653
	else if ( first.Compare("AnotherMod") )
652
	else if ( first.Compare("AnotherMod") )
654
	{
653
	{
655
		m_sOtherName = rest.GetToken("|", 1, 1);
654
		m_sOtherName = rest.token("|", 1);
656
		m_sOtherAuthor = rest.GetToken("|", 2);
655
		m_sOtherAuthor = rest.tokens("|", 2);
657
	}
656
	}
658
	else if ( first.Compare("WareName") || first.Compare("WareDesc") )
657
	else if ( first.Compare("WareName") || first.Compare("WareDesc") )
659
	{
658
	{
660
		// find the ware to use
659
		// find the ware to use
661
		SWares *useWare = m_pLastWare;
660
		SWares *useWare = m_pLastWare;
662
		CyString id = rest.GetToken(" ", 1, 1);
661
		Utils::String id = rest.token(" ", 1);
663
		for ( CListNode<SWares> *wNode = m_lWares.Front(); wNode; wNode = wNode->next() )
662
		for ( CListNode<SWares> *wNode = m_lWares.Front(); wNode; wNode = wNode->next() )
664
		{
663
		{
665
			if ( wNode->Data()->sID.Compare(id) )
664
			if ( wNode->Data()->sID.Compare(id.c_str()) )
666
			{
665
			{
667
				useWare = wNode->Data();
666
				useWare = wNode->Data();
668
				break;
667
				break;
669
			}
668
			}
670
		}
669
		}
671
 
670
 
672
		// check if we have the id already
671
		// check if we have the id already
673
		if ( useWare )
672
		if ( useWare )
674
		{
673
		{
675
			int lang = rest.GetToken(" ", 2, 2).ToInt();
674
			int lang = rest.token(" ", 2);
676
			SWaresText *wt = NULL;
675
			SWaresText *wt = NULL;
677
			for ( CListNode<SWaresText> *tNode = useWare->lText.Front(); tNode; tNode = tNode->next() )
676
			for ( CListNode<SWaresText> *tNode = useWare->lText.Front(); tNode; tNode = tNode->next() )
678
			{
677
			{
679
				if ( tNode->Data()->iLang == lang )
678
				if ( tNode->Data()->iLang == lang )
680
				{
679
				{
Line 686... Line 685...
686
			if ( !wt )
685
			if ( !wt )
687
			{
686
			{
688
				wt = new SWaresText;
687
				wt = new SWaresText;
689
				wt->iLang = lang;
688
				wt->iLang = lang;
690
				useWare->lText.push_back(wt);
689
				useWare->lText.push_back(wt);
691
			}
690
			}
692
 
691
 
693
			if ( first.Compare("WareName") )
692
			if ( first.Compare("WareName") )
694
				wt->sName = rest.GetToken(" ", 3);
693
				wt->sName = rest.tokens(" ", 3);
695
			else
694
			else
696
				wt->sDesc = rest.GetToken(" ", 3);
695
				wt->sDesc = rest.tokens(" ", 3);
697
		}
696
		}
698
	}
697
	}
699
	else if ( first.Left(4).Compare("Ware") )
698
	else if ( first.Left(4).Compare("Ware") )
700
	{
699
	{
701
		SWares *ware = new SWares;
700
		SWares *ware = new SWares;
702
		ware->iTextID = -1;
701
		ware->iTextID = -1;
703
		ware->iTextPage = 0;
702
		ware->iTextPage = 0;
704
		ware->cType = first[4];
703
		ware->cType = first[4];
705
		ware->iPrice = rest.GetToken ( " ", 2, 2 ).ToLong();
704
		ware->iPrice = rest.token(" ", 2);
706
		ware->iSize = rest.GetToken ( " ", 3, 3 ).ToInt();
705
		ware->iSize = rest.token(" ", 3);
707
		ware->iVolumn = rest.GetToken ( " ", 4, 4 ).ToInt();
706
		ware->iVolumn = rest.token(" ", 4);
708
		ware->sID = rest.GetToken ( " ", 1, 1 );
707
		ware->sID = rest.token(" ", 1);
709
		ware->iNotority = rest.GetToken ( " ", 5, 5 ).ToInt();
708
		ware->iNotority = rest.token(" ", 5);
710
		if ( !rest.GetToken(" ", 6, 6).Empty() )
709
		if ( !rest.token(" ", 6).empty() )
711
		{
710
		{
712
			ware->iTextID = rest.GetToken ( " ", 6, 6 ).GetToken(",", 2, 2).ToInt();
711
			ware->iTextID = rest.token(" ", 6).token(",", 2);
713
			ware->iTextPage = rest.GetToken ( " ", 6, 6 ).GetToken(",", 1, 1).ToInt();
712
			ware->iTextPage = rest.token(" ", 6).token(",", 1);
714
		}
713
		}
715
		m_lWares.push_back ( ware );
714
		m_lWares.push_back ( ware );
716
		m_pLastWare = ware;
715
		m_pLastWare = ware;
717
	}
716
	}
718
 
717
 
719
	else if ( CBaseFile::LoadPackageData(first, rest) )
718
	else if ( CBaseFile::LoadPackageData(first, rest) )
720
		return true;
719
		return true;
721
	else
720
	else
722
		return false;
721
		return false;
723
 
722
 
724
	return true;
723
	return true;
725
}
724
}
726
 
725
 
727
bool CSpkFile::GeneratePackagerScript(bool wildcard, CyStringList *list, bool datafile)
726
bool CSpkFile::GeneratePackagerScript(bool wildcard, CyStringList *list, bool datafile)
728
{
727
{
729
	if ( !CBaseFile::GeneratePackagerScript(wildcard, list, datafile) )
728
	if ( !CBaseFile::GeneratePackagerScript(wildcard, list, datafile) )
730
		return false;
729
		return false;
731
 
730
 
Line 745... Line 744...
745
	if ( this->IsAnotherMod() )
744
	if ( this->IsAnotherMod() )
746
	{
745
	{
747
		list->PushBack("# For another mod/package, this is a child package");
746
		list->PushBack("# For another mod/package, this is a child package");
748
		list->PushBack(CyString("AnotherMod: ") + m_sOtherName + "|" + m_sOtherAuthor);
747
		list->PushBack(CyString("AnotherMod: ") + m_sOtherName + "|" + m_sOtherAuthor);
749
		list->PushBack("");
748
		list->PushBack("");
750
	}
749
	}
751
 
750
 
752
	if ( !m_lWares.empty() )
751
	if ( !m_lWares.empty() )
753
	{
752
	{
754
		list->PushBack("# Custom Wares, Ware<type>: <id> <price> <size> <volumn> <notority>");
753
		list->PushBack("# Custom Wares, Ware<type>: <id> <price> <size> <volumn> <notority>");
755
		for ( CListNode<SWares> *node = m_lWares.Front(); node; node = node->next() )
754
		for ( CListNode<SWares> *node = m_lWares.Front(); node; node = node->next() )
Line 760... Line 759...
760
			else
759
			else
761
				list->PushBack(CyString("Ware") + (char)w->cType + ": " + w->sID + " " + (long)w->iPrice + " " + (long)w->iSize + " " + (long)w->iVolumn + " " + (long)w->iNotority);
760
				list->PushBack(CyString("Ware") + (char)w->cType + ": " + w->sID + " " + (long)w->iPrice + " " + (long)w->iSize + " " + (long)w->iVolumn + " " + (long)w->iNotority);
762
			for ( CListNode<SWaresText> *wNode = w->lText.Front(); wNode; wNode = wNode->next() )
761
			for ( CListNode<SWaresText> *wNode = w->lText.Front(); wNode; wNode = wNode->next() )
763
			{
762
			{
764
				SWaresText *wt = wNode->Data();
763
				SWaresText *wt = wNode->Data();
765
				if ( !wt->sName.Empty() )
764
				if ( !wt->sName.empty() )
766
					list->PushBack(CyString("WareName: ") + w->sID + " " + (long)wt->iLang + " " + wt->sName);
765
					list->PushBack(CyString("WareName: ") + w->sID + " " + (long)wt->iLang + " " + wt->sName);
767
				if ( !wt->sDesc.Empty() )
766
				if ( !wt->sDesc.empty() )
768
					list->PushBack(CyString("WareDesc: ") + w->sID + " " + (long)wt->iLang + " " + wt->sDesc);
767
					list->PushBack(CyString("WareDesc: ") + w->sID + " " + (long)wt->iLang + " " + wt->sDesc);
769
			}
768
			}
770
			list->PushBack("");
769
			list->PushBack("");
771
		}
770
		}
772
	}
771
	}
773
 
772
 
774
	if ( !datafile )
773
	if ( !datafile )
775
	{
774
	{
776
		if ( !CBaseFile::GeneratePackagerScriptFile(wildcard, list) )
775
		if ( !CBaseFile::GeneratePackagerScriptFile(wildcard, list) )
777
			return false;
776
			return false;
778
	}
777
	}
779
 
778
 
780
	return true;
779
	return true;
781
 
780
 
782
}
781
}
783
 
782
 
784
CyString CSpkFile::GetWareText(SWares *w, int lang)
783
Utils::String CSpkFile::GetWareText(SWares *w, int lang)
785
{
784
{
786
	// return the text page if being used
785
	// return the text page if being used
787
	if ( w->iTextID > 0 && w->iTextPage > 0 )
786
	if ( w->iTextID > 0 && w->iTextPage > 0 )
788
		return CyString("{") + (long)w->iTextPage + "," + (long)w->iTextID + "}";
787
		return Utils::String("{") + (long)w->iTextPage + "," + (long)w->iTextID + "}";
789
 
788
 
790
	CyString name;
789
	Utils::String name;
791
	for ( CListNode<SWaresText> *wt = w->lText.Front(); wt; wt = wt->next() )
790
	for ( CListNode<SWaresText> *wt = w->lText.Front(); wt; wt = wt->next() )
792
	{
791
	{
793
		if ( wt->Data()->sName.Empty() )
792
		if ( wt->Data()->sName.empty() )
794
			continue;
793
			continue;
795
		if ( wt->Data()->iLang == lang )
794
		if ( wt->Data()->iLang == lang )
796
			name = wt->Data()->sName;
795
			name = wt->Data()->sName;
797
		else if ( name.Empty() && wt->Data()->iLang == 44 )
796
		else if ( name.empty() && wt->Data()->iLang == 44 )
798
			name = wt->Data()->sName;
797
			name = wt->Data()->sName;
799
		else if ( name.Empty() )
798
		else if ( name.empty() )
800
			name = wt->Data()->sName;
799
			name = wt->Data()->sName;
801
	}
800
	}
802
 
801
 
803
	return name;
802
	return name;
804
}
803
}
805
CyString CSpkFile::GetWareDesc(SWares *w, int lang)
804
Utils::String CSpkFile::GetWareDesc(SWares *w, int lang)
806
{
805
{
807
	// return the text page if being used
806
	// return the text page if being used
808
	if ( w->iTextID > 0 && w->iTextPage > 0 )
807
	if ( w->iTextID > 0 && w->iTextPage > 0 )
809
		return CyString("{") + (long)w->iTextPage + "," + ((long)w->iTextID + 1) + "}";
808
		return Utils::String("{") + (long)w->iTextPage + "," + ((long)w->iTextID + 1) + "}";
810
 
809
 
811
	CyString name;
810
	Utils::String name;
812
	for ( CListNode<SWaresText> *wt = w->lText.Front(); wt; wt = wt->next() )
811
	for ( CListNode<SWaresText> *wt = w->lText.Front(); wt; wt = wt->next() )
813
	{
812
	{
814
		if ( wt->Data()->sDesc.Empty() )
813
		if ( wt->Data()->sDesc.empty() )
815
			continue;
814
			continue;
816
 
815
 
817
		if ( wt->Data()->iLang == lang )
816
		if ( wt->Data()->iLang == lang )
818
			name = wt->Data()->sDesc;
817
			name = wt->Data()->sDesc;
819
		else if ( name.Empty() && wt->Data()->iLang == 44 )
818
		else if ( name.empty() && wt->Data()->iLang == 44 )
820
			name = wt->Data()->sDesc;
819
			name = wt->Data()->sDesc;
821
		else if ( name.Empty() )
820
		else if ( name.empty() )
822
			name = wt->Data()->sDesc;
821
			name = wt->Data()->sDesc;
823
	}
822
	}
824
 
823
 
825
	return name;
824
	return name;
826
}
825
}
827
 
826
 
828
CyString CSpkFile::GetCustomStartName()
827
Utils::String CSpkFile::GetCustomStartName()
829
{
828
{
830
	if ( !this->IsCustomStart() )
829
	if ( !this->IsCustomStart() )
831
		return NullString;
830
		return "";
832
 
831
 
833
	// else find the custom start script
832
	// else find the custom start script
834
	C_File *file = NULL;
833
	C_File *file = NULL;
835
	for ( file = this->GetFirstFile(FILETYPE_SCRIPT); file; file = this->GetNextFile(file) )
834
	for ( file = this->GetFirstFile(FILETYPE_SCRIPT); file; file = this->GetNextFile(file) )
836
	{
835
	{
837
		if ( file->GetFilename().IsIn("initplayership")	&& file->GetFilename().GetToken(".", 1, 1).Compare("galaxy") )
836
		if ( file->GetFilename().IsIn("initplayership")	&& file->GetFilename().GetToken(".", 1, 1).Compare("galaxy") )
838
			break;
837
			break;
839
	}
838
	}
840
 
839
 
841
	if ( !file )
840
	if ( !file )
842
		return NullString;
841
		return "";
843
 
842
 
844
	return file->GetFilename().GetToken(".", 2, 2);
843
	return file->GetFilename().GetToken(".", 2, 2).ToString();
845
}
844
}
846
 
845
 
847
void CSpkFile::MergePackage(CBaseFile *base)
846
void CSpkFile::MergePackage(CBaseFile *base)
848
{
847
{
849
	// update version information
848
	// update version information
Line 870... Line 869...
870
		{
869
		{
871
			for ( CListNode<SSettingType> *node = spk->GetSettingsList()->Front(); node; node = node->next() )
870
			for ( CListNode<SSettingType> *node = spk->GetSettingsList()->Front(); node; node = node->next() )
872
				this->AddSetting(node->Data()->sKey, node->Data()->iType);
871
				this->AddSetting(node->Data()->sKey, node->Data()->iType);
873
		}
872
		}
874
 
873
 
875
		if ( !spk->GetOtherName().Empty() )
874
		if ( !spk->GetOtherName().empty() )
876
		{
875
		{
877
			m_sOtherName = spk->GetOtherName();
876
			m_sOtherName = spk->GetOtherName();
878
			m_sOtherAuthor = spk->GetOtherAuthor();
877
			m_sOtherAuthor = spk->GetOtherAuthor();
879
		}
878
		}
880
	}
879
	}
Line 955... Line 954...
955
unsigned char *CSpkFile::_convert_uncompressFile(const Utils::String &sOldFilename, int *pLen)
954
unsigned char *CSpkFile::_convert_uncompressFile(const Utils::String &sOldFilename, int *pLen)
956
{
955
{
957
	// firstcheck if the file exists
956
	// firstcheck if the file exists
958
	FILE *id = fopen(sOldFilename.c_str(), "rb" );
957
	FILE *id = fopen(sOldFilename.c_str(), "rb" );
959
	if ( !id ) {
958
	if ( !id ) {
960
		CLog::logf("Unable to open file: %s", ((CyString)sOldFilename).c_str());
959
		CLog::logf(CLog::Log_IO, "Unable to open file: %s", sOldFilename.c_str());
961
		return false;
960
		return false;
962
	}
961
	}
963
 
962
 
964
	// read the first 3 charaters to check if its using the original "HiP" compression
963
	// read the first 3 charaters to check if its using the original "HiP" compression
965
	CyString check = (char)fgetc ( id );
964
	CyString check = (char)fgetc ( id );
Line 973... Line 972...
973
	long len = 0, newlen = 0;
972
	long len = 0, newlen = 0;
974
 
973
 
975
	if ( check == "HiP" ) {
974
	if ( check == "HiP" ) {
976
		fclose ( id );
975
		fclose ( id );
977
		bool opened = false;
976
		bool opened = false;
978
		if ( DecompressFile ( (char *)((CyString)sOldFilename).c_str(), "uncompr.tmp" ) ) {
977
		if ( DecompressFile ( (char *)sOldFilename.c_str(), "uncompr.tmp" ) ) {
979
			removeFile = "uncompr.tmp";
978
			removeFile = "uncompr.tmp";
980
			id = fopen ( "uncompr.tmp", "r" );
979
			id = fopen ( "uncompr.tmp", "r" );
981
			if ( id )
980
			if ( id )
982
				opened = true;
981
				opened = true;
983
		}
982
		}
984
 
983
 
985
		if ( !opened ) {
984
		if ( !opened ) {
986
			CLog::log("Unable to uncompress file, exiting...");
985
			CLog::log(CLog::Log_IO, "Unable to uncompress file, exiting...");
987
			return false;
986
			return false;
988
		}
987
		}
989
 
988
 
990
		CLog::log("* Reading file into memory...");
989
		CLog::log(CLog::Log_IO, "* Reading file into memory...");
991
		// get file length
990
		// get file length
992
		fseek ( id, 0, SEEK_END );
991
		fseek ( id, 0, SEEK_END );
993
		len = ftell ( id );
992
		len = ftell ( id );
994
		
993
		
995
		// move back to beginning
994
		// move back to beginning
996
		fseek ( id, 0, SEEK_SET );
995
		fseek ( id, 0, SEEK_SET );
997
 
996
 
998
		// read the data from file into memory
997
		// read the data from file into memory
999
		uncomprData = new unsigned char[len + 1];
998
		uncomprData = new unsigned char[len + 1];
1000
		fread ( uncomprData, sizeof(unsigned char), len, id );
999
		fread ( uncomprData, sizeof(unsigned char), len, id );
1001
 
1000
 
1002
		newlen = len;
1001
		newlen = len;
1003
	}
1002
	}
1004
	else
1003
	else
1005
	{
1004
	{
1006
		CLog::log("* Reading file into memory...");
1005
		CLog::log(CLog::Log_IO, "* Reading file into memory...");
1007
		// get file length
1006
		// get file length
1008
		fseek ( id, 0, SEEK_END );
1007
		fseek ( id, 0, SEEK_END );
1009
		len = ftell ( id );
1008
		len = ftell ( id );
1010
		
1009
		
1011
		// move back to beginning
1010
		// move back to beginning
Line 1014... Line 1013...
1014
		// read the data from file into memory
1013
		// read the data from file into memory
1015
		data = new unsigned char[len + 1];
1014
		data = new unsigned char[len + 1];
1016
		fread ( data, sizeof(unsigned char), len, id );
1015
		fread ( data, sizeof(unsigned char), len, id );
1017
 
1016
 
1018
		// uncompress the file (currently only 7zip compression)
1017
		// uncompress the file (currently only 7zip compression)
1019
		CLog::log("* Uncompressing file...");
1018
		CLog::log(CLog::Log_IO, "* Uncompressing file...");
1020
		newlen = len;
1019
		newlen = len;
1021
	#ifdef _INCLUDE7ZIP
1020
	#ifdef _INCLUDE7ZIP
1022
		uncomprData = LZMADecodeData ( data, len, newlen, progress );
1021
		uncomprData = LZMADecodeData ( data, len, newlen, progress );
1023
	#else
1022
	#else
1024
		uncomprData = LZMADecode_C ( (unsigned char *)data, len, (size_t*)&newlen, NULL );
1023
		uncomprData = LZMADecode_C ( (unsigned char *)data, len, (size_t*)&newlen, NULL );
1025
	#endif
1024
	#endif
1026
	}
1025
	}
1027
 
1026
 
1028
	*pLen = newlen;
1027
	*pLen = newlen;
1029
 
1028
 
1030
	if ( removeFile.Empty() ) {
1029
	if ( !removeFile.Empty() ) {
1031
		CFileIO(removeFile).Remove();
1030
		CFileIO(removeFile).Remove();
1032
	}
1031
	}
1033
 
1032
 
1034
	return uncomprData;
1033
	return uncomprData;
1035
}
1034
}
Line 1069... Line 1068...
1069
		return FILETYPE_SOUND;
1068
		return FILETYPE_SOUND;
1070
 
1069
 
1071
	return FILETYPE_SCRIPT;
1070
	return FILETYPE_SCRIPT;
1072
}
1071
}
1073
 
1072
 
1074
void CSpkFile::_convert_parse(const Utils::String &sCmd, const Utils::String &sRest, bool bVerbose)
1073
void CSpkFile::_convert_parse(const Utils::String &sCmd, const Utils::String &sRest)
1075
{
1074
{
1076
	if ( sCmd == "Name:" )
1075
	if ( sCmd == "Name:" )
1077
	{
1076
	{
1078
		this->SetName ( sRest );
1077
		this->SetName ( sRest );
1079
		if ( bVerbose ) CLog::logf( "\tScript Name: %s", sRest.c_str() );
1078
		CLog::logf(CLog::Log_EditPackage, "\tScript Name: %s", sRest.c_str() );
1080
	}
1079
	}
1081
	else if ( sCmd == "Author:" )
1080
	else if ( sCmd == "Author:" )
1082
	{
1081
	{
1083
		this->SetAuthor ( sRest );
1082
		this->SetAuthor ( sRest );
1084
		if ( bVerbose ) CLog::logf( "\tScript Author: %s", sRest.c_str() );
1083
		CLog::logf(CLog::Log_EditPackage, "\tScript Author: %s", sRest.c_str() );
1085
	}
1084
	}
1086
	else if ( sCmd == "CustomStart" )
1085
	else if ( sCmd == "CustomStart" )
1087
	{
1086
	{
1088
		this->SetCustomStart();
1087
		this->SetCustomStart();
1089
		if ( bVerbose ) CLog::logf( "\tPackage is a custom start!!" );
1088
		CLog::logf(CLog::Log_EditPackage, "\tPackage is a custom start!!" );
1090
	}
1089
	}
1091
	else if ( sCmd == "AnotherMod:" )
1090
	else if ( sCmd == "AnotherMod:" )
1092
	{
1091
	{
1093
		this->SetAnotherMod(sRest.token("|", 1), sRest.tokens("|", 2));
1092
		this->SetAnotherMod(sRest.token("|", 1), sRest.tokens("|", 2));
1094
		if ( bVerbose ) CLog::logf( "\tFor another Mod, Name: %s, Author: %s", this->GetOtherName().c_str(), this->GetOtherAuthor().c_str() );
1093
		CLog::logf(CLog::Log_EditPackage, "\tFor another Mod, Name: %s, Author: %s", this->GetOtherName().c_str(), this->GetOtherAuthor().c_str() );
1095
	}
1094
	}
1096
	else if ( sCmd == "PATCH" )
1095
	else if ( sCmd == "PATCH" )
1097
	{
1096
	{
1098
		this->SetPatch();
1097
		this->SetPatch();
1099
		if ( bVerbose ) CLog::logf("\tPackage is a Patch Mod!!" );
1098
		CLog::logf(CLog::Log_EditPackage, "\tPackage is a Patch Mod!!" );
1100
	}
1099
	}
1101
	else if ( sCmd == "Version:" )
1100
	else if ( sCmd == "Version:" )
1102
	{
1101
	{
1103
		this->SetVersion ( sRest );
1102
		this->SetVersion ( sRest );
1104
		if ( bVerbose ) CLog::logf("\tScript Version: %s", sRest.c_str() );
1103
		CLog::logf(CLog::Log_EditPackage, "\tScript Version: %s", sRest.c_str() );
1105
	}
1104
	}
1106
	else if ( sCmd == "Date:" )
1105
	else if ( sCmd == "Date:" )
1107
	{
1106
	{
1108
		this->SetCreationDate ( sRest );
1107
		this->SetCreationDate ( sRest );
1109
		if ( bVerbose ) CLog::logf("\tScript Creation Date: %s", sRest.c_str() );
1108
		CLog::logf(CLog::Log_EditPackage, "\tScript Creation Date: %s", sRest.c_str() );
1110
	}
1109
	}
1111
	else if ( sCmd == "Desc:" )
1110
	else if ( sCmd == "Desc:" )
1112
	{
1111
	{
1113
		this->SetDescription(sRest.findReplace("<br>", "\n") );
1112
		this->SetDescription(sRest.findReplace("<br>", "\n") );
1114
		if ( bVerbose ) CLog::logf("\tScript Description: %s", this->GetDescription().c_str() );
1113
		CLog::logf(CLog::Log_EditPackage, "\tScript Description: %s", this->GetDescription().c_str() );
1115
	}
1114
	}
1116
	else if ( sCmd == "WebAddress:" )
1115
	else if ( sCmd == "WebAddress:" )
1117
	{
1116
	{
1118
		this->SetWebAddress ( sRest );
1117
		this->SetWebAddress ( sRest );
1119
		if ( bVerbose ) CLog::logf("\tWeb Address: %s", sRest.c_str() );
1118
		CLog::logf(CLog::Log_EditPackage, "\tWeb Address: %s", sRest.c_str() );
1120
	}
1119
	}
1121
	else if ( sCmd == "WebMirror1:" )
1120
	else if ( sCmd == "WebMirror1:" )
1122
	{
1121
	{
1123
		this->AddWebMirror(sRest);
1122
		this->AddWebMirror(sRest);
1124
		if ( bVerbose ) CLog::logf("\tWeb Mirror Address: %s", sRest.c_str() );
1123
		CLog::logf(CLog::Log_EditPackage, "\tWeb Mirror Address: %s", sRest.c_str() );
1125
	}
1124
	}
1126
	else if ( sCmd == "WebMirror2:" )
1125
	else if ( sCmd == "WebMirror2:" )
1127
	{
1126
	{
1128
		this->AddWebMirror(sRest);
1127
		this->AddWebMirror(sRest);
1129
		if ( bVerbose ) CLog::logf("\tWeb Mirror Address: %s", sRest.c_str() );
1128
		CLog::logf(CLog::Log_EditPackage, "\tWeb Mirror Address: %s", sRest.c_str() );
1130
	}
1129
	}
1131
	
1130
	
1132
	else if ( sCmd == "ScriptType:" )
1131
	else if ( sCmd == "ScriptType:" )
1133
		this->SetScriptType ( CyString(sRest) );
1132
		this->SetScriptType (sRest);
1134
	else if ( sCmd == "WebSite:" )
1133
	else if ( sCmd == "WebSite:" )
1135
	{
1134
	{
1136
		this->SetWebSite ( sRest );
1135
		this->SetWebSite ( sRest );
1137
		if ( bVerbose ) CLog::logf("\tWeb Site: %s", sRest.c_str() );
1136
		CLog::logf(CLog::Log_EditPackage, "\tWeb Site: %s", sRest.c_str() );
1138
	}
1137
	}
1139
	else if ( sCmd == "Email:" )
1138
	else if ( sCmd == "Email:" )
1140
	{
1139
	{
1141
		this->SetEmail ( sRest );
1140
		this->SetEmail ( sRest );
1142
		if ( bVerbose ) CLog::logf("\tAuthor Email Address: %s", sRest.c_str() );
1141
		CLog::logf(CLog::Log_EditPackage, "\tAuthor Email Address: %s", sRest.c_str() );
1143
	}
1142
	}
1144
	else if ( sCmd == "GameVersion:" )
1143
	else if ( sCmd == "GameVersion:" )
1145
	{
1144
	{
1146
		//TODO: fix this for new game version
1145
		//TODO: fix this for new game version
1147
		/*
1146
		/*
Line 1150... Line 1149...
1150
			this->SetGameVersion ( 1 );
1149
			this->SetGameVersion ( 1 );
1151
		else if (version == 1 )
1150
		else if (version == 1 )
1152
			this->SetGameVersion ( 0 );
1151
			this->SetGameVersion ( 0 );
1153
		else
1152
		else
1154
			this->SetGameVersion ( version );
1153
			this->SetGameVersion ( version );
1155
		if ( bVerbose ) CLog::logf( "\tGame Version: %d", this->GetGameVersion () );
1154
		CLog::logf(CLog::Log_EditPackage, "\tGame Version: %d", this->GetGameVersion () );
1156
		*/
1155
		*/
1157
	}
1156
	}
1158
	
1157
	
1159
	else if ( sCmd == "Ware:" )
1158
	else if ( sCmd == "Ware:" )
1160
	{
1159
	{
1161
		this->AddWare ( sRest );
1160
		this->AddWare ( sRest );
1162
		if ( bVerbose ) CLog::logf( "\tAdding Custom Ware" );
1161
		CLog::logf(CLog::Log_EditPackage, "\tAdding Custom Ware" );
1163
	}
1162
	}
1164
	else if ( sCmd == "WareText:" )
1163
	else if ( sCmd == "WareText:" )
1165
		this->AddWareText ( sRest );
1164
		this->AddWareText ( sRest );
1166
	else if ( sCmd == "UninstallAfter:" )
1165
	else if ( sCmd == "UninstallAfter:" )
1167
		this->AddUninstallAfterText(sRest.token(" ", 1).toLong(), sRest.tokens(" ", 2));
1166
		this->AddUninstallAfterText(sRest.token(" ", 1).toLong(), sRest.tokens(" ", 2));
Line 1174... Line 1173...
1174
	else if ( sCmd == "ScriptName:" )
1173
	else if ( sCmd == "ScriptName:" )
1175
	{
1174
	{
1176
		Utils::String lang = sRest.token(":", 1);
1175
		Utils::String lang = sRest.token(":", 1);
1177
		Utils::String name = sRest.tokens(":", 2);
1176
		Utils::String name = sRest.tokens(":", 2);
1178
		this->AddLanguageName(lang.toLong(), name);
1177
		this->AddLanguageName(lang.toLong(), name);
1179
		if ( bVerbose ) CLog::logf( "\tScript Name Language (%s) %s", lang.c_str(), name.c_str() );
1178
		CLog::logf(CLog::Log_EditPackage, "\tScript Name Language (%s) %s", lang.c_str(), name.c_str() );
1180
	}
1179
	}
1181
}
1180
}
1182
 
1181
 
1183
Utils::String CSpkFile::_convert_parseFilename(const Utils::String &sRest, float fVersion, Utils::String *pDir)
1182
Utils::String CSpkFile::_convert_parseFilename(const Utils::String &sRest, float fVersion, Utils::String *pDir)
1184
{
1183
{
Line 1203... Line 1202...
1203
	}
1202
	}
1204
 
1203
 
1205
	return sFilename;
1204
	return sFilename;
1206
}
1205
}
1207
 
1206
 
1208
unsigned char *CSpkFile::_convert_parseFile(const Utils::String &sCmd, const Utils::String &sRest, float fVersion, unsigned char *d, bool bVerbose )
1207
unsigned char *CSpkFile::_convert_parseFile(const Utils::String &sCmd, const Utils::String &sRest, float fVersion, unsigned char *d)
1209
{
1208
{
1210
	bool bShared = (sCmd.left(9) == "$$$Shared") ? true : false;
1209
	bool bShared = (sCmd.left(9) == "$$$Shared") ? true : false;
1211
	Utils::String sFile = sCmd.right(-3).left(-1);
1210
	Utils::String sFile = sCmd.right(-3).left(-1);
1212
	Utils::String sEnd = this->_convert_fileEndString(sFile);
1211
	Utils::String sEnd = this->_convert_fileEndString(sFile);
1213
	int iType = this->_convert_fileType(sFile);
1212
	int iType = this->_convert_fileType(sFile);
Line 1222... Line 1221...
1222
	bool binaryRead = (CFileIO(filename).CheckFileExtension("PCK")) ? true : false;
1221
	bool binaryRead = (CFileIO(filename).CheckFileExtension("PCK")) ? true : false;
1223
	if ( sEnd.empty() ) binaryRead = true;
1222
	if ( sEnd.empty() ) binaryRead = true;
1224
	
1223
	
1225
	C_File *file = new C_File ();
1224
	C_File *file = new C_File ();
1226
 
1225
 
1227
	if ( bVerbose )
-
 
1228
	{
-
 
1229
		if ( bShared )
-
 
1230
			CLog::logf( "\tFound %s File (Shared): %s, Reading...", sFile.c_str(), filename.c_str() );
1226
	if ( bShared )	CLog::logf(CLog::Log_File, "\tFound %s File (Shared): %s, Reading...", sFile.c_str(), filename.c_str() );
1231
		else
-
 
1232
			CLog::logf( "\tFound %s File: %s, Reading...", sFile.c_str(), filename.c_str() );
1227
	else			CLog::logf(CLog::Log_File, "\tFound %s File: %s, Reading...", sFile.c_str(), filename.c_str() );
1233
	}
-
 
1234
 
1228
 
1235
	// read the data
1229
	// read the data
1236
	if ( binaryRead )
1230
	if ( binaryRead )
1237
	{
1231
	{
1238
		file->ReadFromData ( (char *)d, size );
1232
		file->ReadFromData ( (char *)d, size );
Line 1253... Line 1247...
1253
	if ( !dir.empty() )
1247
	if ( !dir.empty() )
1254
		file->SetDir ( dir );
1248
		file->SetDir ( dir );
1255
	
1249
	
1256
	this->AddFile ( file );
1250
	this->AddFile ( file );
1257
 
1251
 
1258
	CLog::logf( "Size: %s", file->GetDataSizeString().c_str() );
1252
	CLog::logf(CLog::Log_File, "Size: %s", file->GetDataSizeString().c_str() );
1259
 
1253
 
1260
	return d;
1254
	return d;
1261
}
1255
}
1262
 
1256
 
1263
CSpkFile *CSpkFile::convertFromOld(const Utils::String &sOldFilename)
1257
CSpkFile *CSpkFile::convertFromOld(const Utils::String &sOldFilename)
Line 1289... Line 1283...
1289
	int len;
1283
	int len;
1290
	unsigned char *uncomprData = this->_convert_uncompressFile(sOldFilename, &len);
1284
	unsigned char *uncomprData = this->_convert_uncompressFile(sOldFilename, &len);
1291
 
1285
 
1292
	// uncomressed failed
1286
	// uncomressed failed
1293
	if ( !uncomprData ) {
1287
	if ( !uncomprData ) {
1294
		CLog::log("Error: Unable to uncompress the file");
1288
		CLog::log(CLog::Log_IO, "Error: Unable to uncompress the file");
1295
		return false;
1289
		return false;
1296
	}
1290
	}
1297
 
1291
 
1298
	// now we can read the data
1292
	// now we can read the data
1299
	unsigned char *d = uncomprData;
1293
	unsigned char *d = uncomprData;
Line 1301... Line 1295...
1301
 
1295
 
1302
//	CMultiSpkFile *mspk = NULL;
1296
//	CMultiSpkFile *mspk = NULL;
1303
	//SMultiSpkFile *cur_mspk = NULL;
1297
	//SMultiSpkFile *cur_mspk = NULL;
1304
 
1298
 
1305
	int numscripts = 0, curscript = 0;
1299
	int numscripts = 0, curscript = 0;
1306
	bool bVerbose = true;
-
 
1307
	float fVersion = 1;
1300
	float fVersion = 1;
1308
 
1301
 
1309
	CLog::log("* Reading spk data...");
1302
	CLog::log(CLog::Log_IO, "* Reading spk data...");
1310
	while ( d )
1303
	while ( d )
1311
	{
1304
	{
1312
		// read the next line
1305
		// read the next line
1313
		d = str.readToEndOfLine(d);
1306
		d = str.readToEndOfLine(d);
1314
		if ( !d || d[0] == 0 ) {
1307
		if ( !d || d[0] == 0 ) {
Line 1346... Line 1339...
1346
		}
1339
		}
1347
		*/
1340
		*/
1348
		Utils::String sRest = str.tokens(" ", 2);
1341
		Utils::String sRest = str.tokens(" ", 2);
1349
		if ( sCmd == "Packager:" ) {
1342
		if ( sCmd == "Packager:" ) {
1350
			fVersion = sRest;
1343
			fVersion = sRest;
1351
			if ( bVerbose ) CLog::logf( "\tPackager Version: %.2f", fVersion );
1344
			CLog::logf(CLog::Log_Read, "\tPackager Version: %.2f", fVersion );
1352
		}
1345
		}
1353
		else if ( sCmd == "Icon:" )
1346
		else if ( sCmd == "Icon:" )
1354
		{
1347
		{
1355
			long size = sRest.token(" ", 1);
1348
			long size = sRest.token(" ", 1);
1356
			Utils::String ext = sRest.token(" ", 2);
1349
			Utils::String ext = sRest.token(" ", 2);
Line 1360... Line 1353...
1360
 
1353
 
1361
			d += size;
1354
			d += size;
1362
 
1355
 
1363
			this->SetIcon(file, ext);
1356
			this->SetIcon(file, ext);
1364
 
1357
 
1365
			if ( bVerbose ) CLog::logf( "\tIcon (%s) Size: %s", ext.c_str(), file->GetDataSizeString ().c_str() );
1358
			CLog::logf(CLog::Log_File, "\tIcon (%s) Size: %s", ext.c_str(), file->GetDataSizeString ().c_str() );
1366
		}
1359
		}
1367
		else if ( sCmd.left(3) == "$$$" )
1360
		else if ( sCmd.left(3) == "$$$" )
1368
			d = _convert_parseFile(sCmd, sRest, fVersion, d, bVerbose);
1361
			d = _convert_parseFile(sCmd, sRest, fVersion, d);
1369
		else {
1362
		else {
1370
			this->_convert_parse(sCmd, sRest, bVerbose);
1363
			this->_convert_parse(sCmd, sRest);
1371
		}
1364
		}
1372
	}
1365
	}
1373
 
1366
 
1374
	if ( bVerbose ) CLog::logf( "* Reading spk data..." );
1367
	CLog::logf(CLog::Log_IO, "* Reading spk data..." );
1375
 
1368
 
1376
	return true;
1369
	return true;
1377
}
1370
}