fixed segfault
This commit is contained in:
parent
aa9b459ef7
commit
081131c5c3
@ -16,6 +16,7 @@ QString RPGCharacter::toString()
|
||||
str.append(QString::number(x)).append(" ");
|
||||
str.append(QString::number(y)).append(" ");
|
||||
str.append(QString::number(gold)).append(" ");
|
||||
str.append(weapon).append(" ");
|
||||
str.append(QString::number(inventory.size()));
|
||||
for(QString &item : inventory)
|
||||
str.append(" ").append(item);
|
||||
@ -78,9 +79,9 @@ void RPGModule::initVillages()
|
||||
bool RPGCharacter::fromString(QString str)
|
||||
{
|
||||
QStringList list = str.split(QChar(' '));
|
||||
bool ok;
|
||||
if(list.size() == 6) // retrocompatibilitry
|
||||
{
|
||||
bool ok;
|
||||
pseudo = list[0];
|
||||
password = list[1];
|
||||
level = list[2].toInt(&ok);
|
||||
@ -99,7 +100,6 @@ bool RPGCharacter::fromString(QString str)
|
||||
}
|
||||
else if(list.size() > 7)
|
||||
{
|
||||
bool ok;
|
||||
pseudo = list[0];
|
||||
password = list[1];
|
||||
level = list[2].toInt(&ok);
|
||||
@ -121,8 +121,8 @@ bool RPGCharacter::fromString(QString str)
|
||||
int nbItems = list[8].toInt(&ok);
|
||||
if(!ok)
|
||||
return false;
|
||||
/*for(int i=0; i<nbItems && i+9 < list.size(); ++i)
|
||||
inventory.push_back(list[9+i]);*/
|
||||
for(int i=0; i<nbItems && i+9 < list.size(); ++i)
|
||||
inventory.push_back(list[9+i]);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user