QTfrontend/team.cpp
changeset 245 4f6b53b7a567
parent 239 f9adf3c73bed
child 247 07605d2a2024
equal deleted inserted replaced
244:b37ca2295b73 245:4f6b53b7a567
    28 
    28 
    29 HWTeam::HWTeam(const QString & teamname) :
    29 HWTeam::HWTeam(const QString & teamname) :
    30   difficulty(0)
    30   difficulty(0)
    31 {
    31 {
    32 	TeamName = teamname;
    32 	TeamName = teamname;
       
    33 	OldTeamName = TeamName;
    33 	for (int i = 0; i < 8; i++) HHName[i].sprintf("hedgehog %d", i);
    34 	for (int i = 0; i < 8; i++) HHName[i].sprintf("hedgehog %d", i);
    34 	Grave = "Simple";
    35 	Grave = "Simple";
    35 	Fort = "Barrelhouse";
    36 	Fort = "Barrelhouse";
    36 	for(int i = 0; i < BINDS_NUMBER; i++)
    37 	for(int i = 0; i < BINDS_NUMBER; i++)
    37 	{
    38 	{
    74 
    75 
    75 	while (!stream.atEnd())
    76 	while (!stream.atEnd())
    76 	{
    77 	{
    77 		str = stream.readLine();
    78 		str = stream.readLine();
    78 		if (str.startsWith(";")) continue;
    79 		if (str.startsWith(";")) continue;
    79 		if (str.startsWith("name team "))
    80 		/*if (str.startsWith("name team "))
    80 		{
    81 		{
    81 			str.remove(0, 10);
    82 			str.remove(0, 10);
    82 			TeamName = str;
    83 			TeamName = str;
    83 		} else
    84 		} else*/
    84 		if (str.startsWith("name hh"))
    85 		if (str.startsWith("name hh"))
    85 		{
    86 		{
    86 			str.remove(0, 7);
    87 			str.remove(0, 7);
    87 			long i = str.left(1).toLong();
    88 			long i = str.left(1).toLong();
    88 			if ((i < 0) || (i > 7)) continue;
    89 			if ((i < 0) || (i > 7)) continue;
   123 	return true;
   124 	return true;
   124 }
   125 }
   125 
   126 
   126 bool HWTeam::SaveToFile()
   127 bool HWTeam::SaveToFile()
   127 {
   128 {
       
   129 	if (OldTeamName != TeamName)
       
   130 	{
       
   131 		QFile cfgfile(cfgdir->absolutePath() + "/" + OldTeamName + ".cfg");
       
   132 		cfgfile.remove();
       
   133 		OldTeamName = TeamName;
       
   134 	}
   128 	QFile cfgfile(cfgdir->absolutePath() + "/" + TeamName + ".cfg");
   135 	QFile cfgfile(cfgdir->absolutePath() + "/" + TeamName + ".cfg");
   129 	if (!cfgfile.open(QIODevice::WriteOnly)) return false;
   136 	if (!cfgfile.open(QIODevice::WriteOnly)) return false;
   130 	QTextStream stream(&cfgfile);
   137 	QTextStream stream(&cfgfile);
   131 	stream.setCodec("UTF-8");
   138 	stream.setCodec("UTF-8");
   132 	stream << "; Generated by Hedgewars, do not modify" << endl;
   139 	stream << "; Generated by Hedgewars, do not modify" << endl;