Subversion Repositories spk

Rev

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

Rev 160 Rev 161
Line 8997... Line 8997...
8997
	ret = ret.addToken("::", package->sDesc);
8997
	ret = ret.addToken("::", package->sDesc);
8998
 
8998
 
8999
	return ret;
8999
	return ret;
9000
}
9000
}
9001
 
9001
 
9002
void CPackages::ParseAvailablePackage(CyString sStr, CyString webaddress)
9002
void CPackages::parseAvailablePackage(const Utils::String &str, const Utils::String &webaddress)
9003
{
9003
{
9004
	// first check game
9004
	// first check game
9005
	Utils::String str = sStr.ToString();
-
 
9006
 
-
 
9007
	int num = 0;
9005
	int num = 0;
9008
	Utils::String *tok = str.tokenise("::", &num);
9006
	Utils::String *tok = str.tokenise("::", &num);
9009
	if ( !num || !tok ) return;
9007
	if ( !num || !tok ) return;
9010
	// invalid number of entries?
9008
	// invalid number of entries?
9011
	if ( num < 7 ) { CLEANSPLIT(tok, num); return; }
9009
	if ( num < 7 ) { CLEANSPLIT(tok, num); return; }
9012
 
9010
 
9013
	SAvailablePackage *p = new SAvailablePackage;
9011
	SAvailablePackage *p = new SAvailablePackage;
9014
	p->iType = tok[0].toLong();
9012
	p->iType = tok[0].toLong();
9015
	p->bSigned = false;
9013
	p->bSigned = false;
9016
 
9014
 
9017
	// theres multiple games, so we need to split it
9015
	// theres multiple games, so we need to split it
9018
	if ( m_iGame ) {
9016
	if ( m_iGame ) {
9019
		Utils::String sGame = tok[1];
9017
		Utils::String sGame = tok[1];
9020
		if ( sGame.isin("!") ) {
9018
		if ( sGame.isin("!") ) {
9021
			for(int i = 1; i <= sGame.countToken("!"); i++) {
9019
			for(int i = 1; i <= sGame.countToken("!"); i++) {
9022
				SGameCompat *gc = new SGameCompat;
9020
				SGameCompat *gc = new SGameCompat;
9023
				gc->iVersion = 0;
9021
				gc->iVersion = 0;
9024
				gc->iGame = sGame.token("!", i).toLong();
9022
				gc->iGame = sGame.token("!", i).toLong();
9025
				p->lGames.push_back(gc);
9023
				p->lGames.push_back(gc);
9026
			}
9024
			}
9027
		}
9025
		}
9028
		else {
9026
		else {
9029
			SGameCompat *gc = new SGameCompat;
9027
			SGameCompat *gc = new SGameCompat;
9030
			gc->iVersion = 0;
9028
			gc->iVersion = 0;
9031
			gc->iGame = sGame.toLong();
9029
			gc->iGame = sGame.toLong();
9032
			p->lGames.push_back(gc);
9030
			p->lGames.push_back(gc);
Line 9037... Line 9035...
9037
	p->sAuthor = tok[3];
9035
	p->sAuthor = tok[3];
9038
	p->sVersion = tok[4];
9036
	p->sVersion = tok[4];
9039
	p->sUpdated = tok[5];
9037
	p->sUpdated = tok[5];
9040
	p->sFilename = tok[6];
9038
	p->sFilename = tok[6];
9041
 
9039
 
9042
	if ( !webaddress.Empty() )
9040
	if ( !webaddress.empty() )
9043
		p->sFilename = webaddress.ToString() + "/" + p->sFilename;
9041
		p->sFilename = webaddress + "/" + p->sFilename;
9044
 
9042
 
9045
	p->iChanging = p->iEase = p->iPluginType = p->iRec = p->iScriptType = -1;
9043
	p->iChanging = p->iEase = p->iPluginType = p->iRec = p->iScriptType = -1;
9046
 
9044
 
9047
	// check if we have the extra values
9045
	// check if we have the extra values
9048
	if ( num >= 12 )
9046
	if ( num >= 12 )
Line 9057... Line 9055...
9057
				p->sDesc = tok[13];
9055
				p->sDesc = tok[13];
9058
				p->bSigned = tok[12].toBool();
9056
				p->bSigned = tok[12].toBool();
9059
			}
9057
			}
9060
			else
9058
			else
9061
				p->sDesc = tok[12];
9059
				p->sDesc = tok[12];
9062
		}
9060
		}
9063
	}
9061
	}
9064
	else if ( num > 7 )
9062
	else if ( num > 7 )
9065
		p->sDesc = tok[8];
9063
		p->sDesc = tok[8];
9066
 
9064
 
9067
	if ( !p->sDesc.empty() )
9065
	if ( !p->sDesc.empty() )
9068
		p->sDesc = p->sDesc.findReplace("::newline::", "\\n");
9066
		p->sDesc = p->sDesc.findReplace("::newline::", "\\n");
9069
 
9067
 
9070
	AddAvailablePackage(p);
9068
	addAvailablePackage(p);
9071
 
9069
 
9072
	CLEANSPLIT(tok, num);
9070
	CLEANSPLIT(tok, num);
9073
}
9071
}
9074
 
9072
 
9075
SAvailablePackage *CPackages::FindAvailablePackage(const Utils::String &filename)
9073
const SAvailablePackage* CPackages::findAvailablePackage(const Utils::String& filename) const
-
 
9074
{
-
 
9075
	for (CListNode<SAvailablePackage>* node = m_lAvailablePackages.Front(); node; node = node->next())
-
 
9076
	{
-
 
9077
		if (node->Data()->sFilename.Compare(filename))
-
 
9078
			return node->Data();
-
 
9079
	}
-
 
9080
	return NULL;
-
 
9081
}
-
 
9082
const SAvailablePackage* CPackages::findAvailablePackage(const Utils::String& name, const Utils::String& author) const
9076
{
9083
{
9077
	for ( CListNode<SAvailablePackage> *node = m_lAvailablePackages.Front(); node; node = node->next() )
9084
	for (CListNode<SAvailablePackage>* node = m_lAvailablePackages.Front(); node; node = node->next())
9078
	{
9085
	{
9079
		if ( node->;Data()->sFilename.Compare(filename) )
9086
		if (node->Data()->sName.Compare(name) && node->;Data()->sAuthor.Compare(author))
9080
			return node->Data();
9087
			return node->Data();
9081
	}
9088
	}
9082
	return NULL;
9089
	return NULL;
9083
}
9090
}
9084
 
9091
 
9085
bool CPackages::AddAvailablePackage(SAvailablePackage *package)	
9092
bool CPackages::addAvailablePackage(SAvailablePackage *package)	
9086
{ 
9093
{ 
9087
	if ( !package->lGames.empty() ) {
9094
	if ( !package->lGames.empty() ) {
9088
		bool found = false;
9095
		bool found = false;
9089
		for ( CListNode<SGameCompat> *node = package->lGames.Front(); node; node = node->next() ) {
9096
		for ( CListNode<SGameCompat> *node = package->lGames.Front(); node; node = node->next() ) {
9090
			if ( !node->Data()->iGame || node->Data()->iGame == m_iGame ) {
9097
			if ( !node->Data()->iGame || node->Data()->iGame == m_iGame ) {
Line 9095... Line 9102...
9095
 
9102
 
9096
		if ( !found )
9103
		if ( !found )
9097
			return false;
9104
			return false;
9098
	}
9105
	}
9099
 
9106
 
9100
	SAvailablePackage *p = FindAvailablePackage(package->sFilename);
9107
	const SAvailablePackage *p = findAvailablePackage(package->sFilename);
-
 
9108
	if(p)
-
 
9109
	{
-
 
9110
		if (p->sVersion.compareVersion(package->sVersion) <= 0)
-
 
9111
			return true;
-
 
9112
		m_lAvailablePackages.remove(p);
-
 
9113
	}
-
 
9114
 
-
 
9115
	p = findAvailablePackage(package->sName, package->sAuthor);
9101
	if ( p )
9116
	if (p)
-
 
9117
	{
-
 
9118
		if (p->sVersion.compareVersion(package->sVersion) <= 0)
-
 
9119
			return true;
9102
		m_lAvailablePackages.remove(p);
9120
		m_lAvailablePackages.remove(p);
-
 
9121
	}
-
 
9122
 
9103
	m_lAvailablePackages.push_back(package); 
9123
	m_lAvailablePackages.push_back(package); 
9104
 
9124
 
9105
	return true;
9125
	return true;
9106
}
9126
}
9107
 
9127