Check for deprecated ammo schemes at startup and delete them
authorunc0rr
Sat, 03 Jan 2009 19:01:50 +0000
changeset 1576 a02353129a41
parent 1575 ec56e8956fcb
child 1577 e3e37c730dc0
Check for deprecated ammo schemes at startup and delete them
QTfrontend/game.cpp
QTfrontend/gamecfgwidget.cpp
QTfrontend/hwconsts.cpp.in
QTfrontend/hwform.cpp
QTfrontend/newnetclient.cpp
QTfrontend/pages.cpp
QTfrontend/selectWeapon.cpp
--- a/QTfrontend/game.cpp	Sat Jan 03 19:01:24 2009 +0000
+++ b/QTfrontend/game.cpp	Sat Jan 03 19:01:50 2009 +0000
@@ -118,8 +118,8 @@
 	HWProto::addStringListToBuffer(teamscfg,
 			team2.TeamGameConfig(100));
 
-	HWProto::addStringToBuffer(teamscfg, *cDefaultAmmoStore);
-	HWProto::addStringToBuffer(teamscfg, *cDefaultAmmoStore);
+	HWProto::addStringToBuffer(teamscfg, "eammstore " + *cDefaultAmmoStore);
+	HWProto::addStringToBuffer(teamscfg, "eammstore " + *cDefaultAmmoStore);
 	RawSendIPC(teamscfg);
 }
 
--- a/QTfrontend/gamecfgwidget.cpp	Sat Jan 03 19:01:24 2009 +0000
+++ b/QTfrontend/gamecfgwidget.cpp	Sat Jan 03 19:01:50 2009 +0000
@@ -182,7 +182,7 @@
 
 void GameCFGWidget::setNetAmmo(const QString& name, const QString& ammo)
 {
-	if (ammo.size() != cDefaultAmmoStore->size() - 10)
+	if (ammo.size() != cDefaultAmmoStore->size())
 		QMessageBox::critical(this, tr("Error"), tr("Illegal ammo scheme"));
 
 	int pos = WeaponsName->findText(name);
--- a/QTfrontend/hwconsts.cpp.in	Sat Jan 03 19:01:24 2009 +0000
+++ b/QTfrontend/hwconsts.cpp.in	Sat Jan 03 19:01:50 2009 +0000
@@ -29,7 +29,7 @@
 QStringList * Themes;
 QStringList * mapList;
 
-QString * cDefaultAmmoStore = new QString("eammstore 93919294221991210322351110012");
+QString * cDefaultAmmoStore = new QString("93919294221991210322351110012");
 
 QColor * color1 = new QColor(221,   0,   0);
 QColor * color2 = new QColor( 67, 118, 233);
--- a/QTfrontend/hwform.cpp	Sat Jan 03 19:01:24 2009 +0000
+++ b/QTfrontend/hwform.cpp	Sat Jan 03 19:01:50 2009 +0000
@@ -397,7 +397,7 @@
 
 void HWForm::SimpleGame()
 {
-	CreateGame(0, 0, cDefaultAmmoStore->mid(10));
+	CreateGame(0, 0, *cDefaultAmmoStore);
 	game->StartQuick();
 }
 
--- a/QTfrontend/newnetclient.cpp	Sat Jan 03 19:01:24 2009 +0000
+++ b/QTfrontend/newnetclient.cpp	Sat Jan 03 19:01:50 2009 +0000
@@ -190,7 +190,7 @@
 
 void HWNewNet::ParseCmd(const QStringList & lst)
 {
-	qDebug() << "Server: " << lst;
+//	qDebug() << "Server: " << lst;
 
 	if(!lst.size())
 	{
--- a/QTfrontend/pages.cpp	Sat Jan 03 19:01:24 2009 +0000
+++ b/QTfrontend/pages.cpp	Sat Jan 03 19:01:50 2009 +0000
@@ -651,7 +651,7 @@
 {
 	QGridLayout * pageLayout = new QGridLayout(this);
 	
-	pWeapons = new SelWeaponWidget(cDefaultAmmoStore->size() - 10, this);
+	pWeapons = new SelWeaponWidget(cDefaultAmmoStore->size(), this);
 	pageLayout->addWidget(pWeapons, 0, 0, 1, 4);
 
 	BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, true);
--- a/QTfrontend/selectWeapon.cpp	Sat Jan 03 19:01:24 2009 +0000
+++ b/QTfrontend/selectWeapon.cpp	Sat Jan 03 19:01:50 2009 +0000
@@ -75,9 +75,16 @@
 {
 	wconf = new QSettings(cfgdir->absolutePath() + "/weapons.ini", QSettings::IniFormat, this);
 
-	wconf->setValue("Default", cDefaultAmmoStore->mid(10));
+	wconf->setValue("Default", *cDefaultAmmoStore);
 
-	QString currentState = cDefaultAmmoStore->mid(10);
+	QStringList keys = wconf->allKeys();
+	for(int i = 0; i < keys.size(); i++)
+	{
+		if (wconf->value(keys[i]).toString().size() != cDefaultAmmoStore->size())
+			wconf->remove(keys[i]);
+	}
+
+	QString currentState = *cDefaultAmmoStore;
 
 	pLayout = new QGridLayout(this);
 	pLayout->setSpacing(1);
@@ -110,7 +117,7 @@
 
 void SelWeaponWidget::setDefault()
 {
-	setWeapons(cDefaultAmmoStore->mid(10));
+	setWeapons(*cDefaultAmmoStore);
 }
 
 void SelWeaponWidget::save()