Commit 3681e2c4 authored by Gaël de Chalendar's avatar Gaël de Chalendar

Solves bug #238902

svn path=/trunk/KDE/kdegames/ksirk/; revision=1154939
parent f9eb43d4
* Make Jabber error messages user visible
* When conquering a country, it should be invaded with at least the number of armies used to attack
* [DONE] Use kwallet to store password(s)
* When last armies is placed, should display 0 instead of 1 armies left
* When starting a new game, should reinitialize the save file name
Before KDE4.3:
* Correct Arena bugs
......
......@@ -25,7 +25,8 @@
namespace Ksirk
{
AnimSpritesGroup::AnimSpritesGroup(QObject* target, const char* slot):
AnimSpritesGroup::AnimSpritesGroup(QObject* target, const char* slot, QObject* parent):
QObject(parent), AnimSpritesList<AnimSprite>(),
m_numberArrived(0), m_target(target), m_slot(slot)
{
kDebug();
......
......@@ -33,7 +33,7 @@ class AnimSpritesGroup : public QObject, public AnimSpritesList<AnimSprite>
{
Q_OBJECT
public:
AnimSpritesGroup(QObject* target, const char* slot);
AnimSpritesGroup(QObject* target, const char* slot, QObject* parent = 0);
virtual ~AnimSpritesGroup();
......
......@@ -101,16 +101,12 @@ template < typename SpriteType >
template < typename SpriteType >
void AnimSpritesList< SpriteType >::hideAndRemoveAll()
{ // cache tous les sprites du tableau, puis les enleve et les
// detruit si le tableau n'etait pas en auto delete
// kDebug();
{
// kDebug();
while (!QList< SpriteType* >::empty())
{
SpriteType* sprite = QList< SpriteType* >::front();
sprite-> hide();
QList< SpriteType* >::pop_front();
delete sprite;
hideAndRemoveFirst();
}
}
......@@ -118,9 +114,9 @@ template < typename SpriteType >
void AnimSpritesList< SpriteType >::hideAndRemoveFirst()
{
SpriteType* sprite = QList< SpriteType* >::front();
sprite-> hide();
QList< SpriteType* >::pop_front();
delete sprite;
sprite-> hide();
sprite->deleteLater();
}
template < typename SpriteType >
......@@ -150,12 +146,11 @@ void AnimSpritesList< SpriteType >::moveAll()
if (((sp->x()) == (destinationPoint.x())) && ((sp-> y()) == (destinationPoint.y())))
{
typename AnimSpritesList< SpriteType >::iterator itToRemove = it;
sp-> getDestination()-> incrNbArmies((*it)-> nbArmies());
sp-> hide();
it++;
QList< SpriteType* >::remove(itToRemove);
it = QList< SpriteType* >::erase(it);
sp-> getDestination()-> incrNbArmies((*it)-> nbArmies());
sp-> getDestination()-> createArmiesSprites();
sp->deleteLater();
}
else it++;
}
......@@ -178,11 +173,9 @@ void AnimSpritesList< SpriteType >::moveAllToDestinationNow(bool clear)
if (clear)
{
typename AnimSpritesList< SpriteType >::iterator itToRemove = it;
sp-> getDestination()-> incrNbArmies(((ArmySprite*)(*it))-> nbArmies());
sp-> hide();
it++;
QList< SpriteType* >::erase(itToRemove);
it = QList< SpriteType* >::erase(it);
sp-> getDestination()-> incrNbArmies(((ArmySprite*)(*it))-> nbArmies());
sp-> getDestination()-> createArmiesSprites();
}
else
......@@ -195,14 +188,9 @@ void AnimSpritesList< SpriteType >::moveAllToDestinationNow(bool clear)
template < typename SpriteType >
void AnimSpritesList< SpriteType >::saveXmlAll(QTextStream& xmlStream)
{
typename AnimSpritesList< SpriteType >::iterator it, it_end;
it = QList< SpriteType* >::begin();
it_end = QList< SpriteType* >::end();
while (it != it_end)
foreach (SpriteType* sp, *this)
{
SpriteType* sp = (*it);
sp->saveXml(xmlStream);
it++;
}
}
......
......@@ -535,6 +535,14 @@ void KGameWindow::newSkin(const QString& onuFileName)
kDebug() << onuFileName;
clear();
m_animFighters->clear();
foreach(AnimSpritesGroup* sprites, m_animSpritesGroups)
{
sprites->clear();
delete sprites;
}
m_animSpritesGroups.clear();
if (m_centralWidget != 0)
{
m_centralWidget->setCurrentIndex(-1);
......
......@@ -1189,6 +1189,15 @@ void KGameWindow::slotStartNewGame()
kDebug() << m_newGameSetup->nbPlayers() << m_newGameSetup->nbPlayers() << m_newGameSetup->players().size();
m_automaton->setGameStatus(KGame::End);
m_reinitializingGame = true;
// delete remainings animations from previous game
m_animFighters->clear();
foreach(AnimSpritesGroup* sprites, m_animSpritesGroups)
{
sprites->clear();
delete sprites;
}
m_animSpritesGroups.clear();
// for network games, remote players are already created, should not remove them
// TODO the players will not be in the orderd showed in the interface.
......@@ -1218,6 +1227,7 @@ void KGameWindow::slotStartNewGame()
{
showMap();
m_frame->setFocus();
m_newGameSummaryWidget->finishButton->setEnabled(true);
}
else
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment