Commit 553e0eb2 authored by Gaël de Chalendar's avatar Gaël de Chalendar

Corrects bug #243623 and better error handling when saved game cannot be loaded

svn path=/trunk/KDE/kdegames/ksirk/; revision=1151222
parent 9321263e
......@@ -201,8 +201,6 @@ void InvasionSlider::slideClose()
stream << quint32(m_currentSlideValue);
m_game->automaton()->sendMessage(buffer,Invade);
// m_wSlide->close();
QByteArray buffer2;
m_game->automaton()->sendMessage(buffer2,InvasionFinished);
m_game->automaton()->currentPlayerPlayed(true);
......
......@@ -55,6 +55,7 @@
#include <errno.h>
#include <sys/types.h>
#include <signal.h>
#include <qcache.h>
namespace Ksirk{
namespace GameLogic {
......@@ -1884,6 +1885,7 @@ void GameAutomaton::movingArmyArrived(Country* country, unsigned int number)
kDebug() << number << endl;
country->incrNbArmies(number);
country->createArmiesSprites();
checkGoal(country->owner());
}
void GameAutomaton::firingFinished()
......@@ -2624,7 +2626,7 @@ void GameAutomaton::actionNextPlayer()
QDataStream stream(&buffer, QIODevice::WriteOnly);
stream << currentPlayer()->name();
stream << (quint32)NEWARMIES;
kDebug() << "sending NextPlayerNormal" << currentPlayer()->name() << NEWARMIES;
kDebug() << "(state " << stateName() << ") sending NextPlayerNormal" << currentPlayer()->name() << NEWARMIES;
sendMessage(buffer,NextPlayerNormal);
m_game-> cancelAction();
}
......@@ -2644,7 +2646,7 @@ void GameAutomaton::newGameNext()
m_startingGame = true;
state(INIT);
kDebug() << "Changing skin" << endl;
kDebug() << "Changing skin";
m_skin = m_game->newGameSetup()->skin();
if (m_game->newGameSetup()->networkGameType() == Socket)
{
......@@ -2653,6 +2655,19 @@ void GameAutomaton::newGameNext()
m_game->finishSetupPlayers();
}
void GameAutomaton::checkGoal(Player* player)
{
QByteArray buffer;
QDataStream stream(&buffer, QIODevice::WriteOnly);
if (player == 0)
stream << currentPlayer()->id();
else
stream << player->id();
kDebug() << "sending CheckGoal";
sendMessage(buffer,CheckGoal);
}
} // closing namespace GameLogic
} // closing namespace Ksirk
......
......@@ -407,6 +407,8 @@ public:
bool connectToServ();
void checkGoal(Player* player = 0);
Q_SIGNALS:
void newJabberGame(const QString&, int, const QString&);
......
......@@ -79,6 +79,7 @@ Goal::~Goal()
bool Goal::checkFor(const GameLogic::Player* player) const
{
kDebug() << message(GoalAdvance);
switch (type())
{
case Goal::GoalPlayer :
......@@ -98,7 +99,7 @@ bool Goal::checkFor(const GameLogic::Player* player) const
bool Goal::checkCountriesFor(const GameLogic::Player* player) const
{
kDebug() << "Goal::checkCountriesFor " << player->name() << endl;
kDebug() << player->name();
if (player->getNbCountries() >= m_nbCountries)
{
uint nbCountriesOk = 0;
......
......@@ -154,7 +154,7 @@ public:
/**
* Builds this goal's description.
* @param displayType the manner to display this goal: final goal or advance.
* @param displayType the manner to display this goal: final goal (default) or advance.
* @return a string containing this goal's description.
*/
QString message(int displayType = GoalDesc) const;
......
......@@ -562,6 +562,10 @@ void KGameWindow::newSkin(const QString& onuFileName)
{
onuDefinitionFileName = m_dirs-> findResource("appdata", m_automaton->skin() + "/Data/world.desktop");
}
else if (!QFile::exists(onuDefinitionFileName))
{
onuDefinitionFileName.clear();
}
if (onuDefinitionFileName.isEmpty())
{
KMessageBox::error(0,
......@@ -841,18 +845,12 @@ bool KGameWindow::attackEnd()
}
else if (m_automaton->isAdmin())
{
QByteArray buffer;
QDataStream stream(&buffer, QIODevice::WriteOnly);
stream << currentPlayer()->id();
m_automaton->sendMessage(buffer,CheckGoal);
m_automaton->checkGoal();
}
}
else if (m_automaton->isAdmin())
{
QByteArray buffer;
QDataStream stream(&buffer, QIODevice::WriteOnly);
stream << currentPlayer()->id();
m_automaton->sendMessage(buffer,CheckGoal);
m_automaton->checkGoal();
}
}
if (backGnd()->bgIsArena())
......@@ -2121,11 +2119,7 @@ bool KGameWindow::playerPutsArmy(const QPointF& point, bool removable)
if (m_automaton->isAdmin())
{
QByteArray buffer;
QDataStream stream(&buffer, QIODevice::WriteOnly);
stream << currentPlayer()->id();
m_automaton->sendMessage(buffer,CheckGoal);
m_automaton->checkGoal();
}
}
}
......@@ -3222,7 +3216,6 @@ void KGameWindow::showNewGameSummary()
m_centralWidget->setCurrentIndex(NEWGAMESUMMARY_INDEX);
}
} // closing namespace Ksirk
#include "kgamewin.moc"
......@@ -646,7 +646,7 @@ public:
void updateNewGameSummary();
void showNewGameSummary();
protected:
/**
......@@ -698,7 +698,6 @@ protected:
void reduceChat();
void unreduceChat();
Q_SIGNALS:
void newJabberGame(const QString&, int, const QString&);
......@@ -910,7 +909,7 @@ private: // Private methods
QPixmap buildDice(const QString& id);
void setupPopupMessage();
QString defenseLabel();
private: // Private members
QDockWidget * m_rightDock;
......
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