Hello community, here is the log from the commit of package kblocks for openSUSE:Factory checked in at 2016-08-31 00:06:52 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/kblocks (Old) and /work/SRC/openSUSE:Factory/.kblocks.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "kblocks" Changes: -------- --- /work/SRC/openSUSE:Factory/kblocks/kblocks.changes 2016-07-24 19:45:14.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.kblocks.new/kblocks.changes 2016-08-31 00:06:53.000000000 +0200 @@ -1,0 +2,16 @@ +Fri Aug 12 10:10:35 UTC 2016 - tittiatc...@gmail.com + +- Update to KDE Applications 16.08.0 + * KDE Applications 16.08.0 + * https://www.kde.org/announcements/announce-applications-16.08.0.php + + +------------------------------------------------------------------- +Mon Aug 8 14:48:10 UTC 2016 - tittiatc...@gmail.com + +- Update to KDE Applications 16.07.90 + * KDE Applications 16.07.90 (16.08-RC) + * https://www.kde.org/announcements/announce-applications-16.07.90.php + + +------------------------------------------------------------------- Old: ---- kblocks-16.04.3.tar.xz New: ---- kblocks-16.08.0.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ kblocks.spec ++++++ --- /var/tmp/diff_new_pack.iKe1rc/_old 2016-08-31 00:06:54.000000000 +0200 +++ /var/tmp/diff_new_pack.iKe1rc/_new 2016-08-31 00:06:54.000000000 +0200 @@ -42,7 +42,7 @@ License: LGPL-2.1+ Group: Amusements/Games/Strategy/Real Time Url: http://www.kde.org -Version: 16.04.3 +Version: 16.08.0 Release: 0 Source0: kblocks-%{version}.tar.xz Obsoletes: %{name}5 < %{version} @@ -77,8 +77,8 @@ %dir %{_kf5_configkcfgdir} %{_kf5_configkcfgdir}/kblocks.kcfg %{_kf5_configdir}/kblocks.knsrc -%dir %_datadir/appdata -%_datadir/appdata/org.kde.kblocks.appdata.xml -%_datadir/kxmlgui5/kblocks/ +%dir %{_kf5_appstreamdir} +%{_kf5_appstreamdir}/org.kde.kblocks.appdata.xml +%{_kf5_kxmlguidir}/kblocks/ %changelog ++++++ kblocks-16.04.3.tar.xz -> kblocks-16.08.0.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/.gitignore new/kblocks-16.08.0/.gitignore --- old/kblocks-16.04.3/.gitignore 1970-01-01 01:00:00.000000000 +0100 +++ new/kblocks-16.08.0/.gitignore 2016-06-12 09:35:45.000000000 +0200 @@ -0,0 +1,3 @@ +.kdev4/ +build/ +*.kdev4 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/AI/EvaluationInterface.h new/kblocks-16.08.0/AI/EvaluationInterface.h --- old/kblocks-16.04.3/AI/EvaluationInterface.h 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/AI/EvaluationInterface.h 2016-06-12 09:35:45.000000000 +0200 @@ -1,11 +1,11 @@ /*************************************************************************** -* KBlocks, a falling blocks game for KDE * -* Copyright (C) 2010 University Freiburg * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * +* KBlocks, a falling blocks game for KDE * +* Copyright (C) 2010 University Freiburg <squall.leonhart....@gmail.com> * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * ***************************************************************************/ #ifndef EVALUATIONINTERFACE_H #define EVALUATIONINTERFACE_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/AI/KBlocksAIEvaluation.cpp new/kblocks-16.08.0/AI/KBlocksAIEvaluation.cpp --- old/kblocks-16.04.3/AI/KBlocksAIEvaluation.cpp 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/AI/KBlocksAIEvaluation.cpp 2016-06-12 09:35:45.000000000 +0200 @@ -1,11 +1,11 @@ /*************************************************************************** -* KBlocks, a falling blocks game for KDE * -* Copyright (C) 2010 University Freiburg * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * +* KBlocks, a falling blocks game for KDE * +* Copyright (C) 2010 University Freiburg <squall.leonhart....@gmail.com> * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * ***************************************************************************/ #include "KBlocksAIEvaluation.h" #include "KBlocksAIFeature.h" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/AI/KBlocksAIEvaluation.h new/kblocks-16.08.0/AI/KBlocksAIEvaluation.h --- old/kblocks-16.04.3/AI/KBlocksAIEvaluation.h 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/AI/KBlocksAIEvaluation.h 2016-06-12 09:35:45.000000000 +0200 @@ -1,11 +1,11 @@ /*************************************************************************** -* KBlocks, a falling blocks game for KDE * -* Copyright (C) 2010 University Freiburg * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * +* KBlocks, a falling blocks game for KDE * +* Copyright (C) 2010 University Freiburg <squall.leonhart....@gmail.com> * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * ***************************************************************************/ #ifndef KBLOCKSAIEVALUATION_H #define KBLOCKSAIEVALUATION_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/AI/KBlocksAIFeature.cpp new/kblocks-16.08.0/AI/KBlocksAIFeature.cpp --- old/kblocks-16.04.3/AI/KBlocksAIFeature.cpp 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/AI/KBlocksAIFeature.cpp 2016-06-12 09:35:45.000000000 +0200 @@ -1,11 +1,11 @@ /*************************************************************************** -* KBlocks, a falling blocks game for KDE * -* Copyright (C) 2010 University Freiburg * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * +* KBlocks, a falling blocks game for KDE * +* Copyright (C) 2010 University Freiburg <squall.leonhart....@gmail.com> * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * ***************************************************************************/ #include "KBlocksAIFeature.h" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/AI/KBlocksAIFeature.h new/kblocks-16.08.0/AI/KBlocksAIFeature.h --- old/kblocks-16.04.3/AI/KBlocksAIFeature.h 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/AI/KBlocksAIFeature.h 2016-06-12 09:35:45.000000000 +0200 @@ -1,11 +1,11 @@ /*************************************************************************** -* KBlocks, a falling blocks game for KDE * -* Copyright (C) 2010 University Freiburg * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * +* KBlocks, a falling blocks game for KDE * +* Copyright (C) 2010 University Freiburg <squall.leonhart....@gmail.com> * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * ***************************************************************************/ #ifndef KBLOCKSAIFEATURE_H #define KBLOCKSAIFEATURE_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/AI/KBlocksAILog.cpp new/kblocks-16.08.0/AI/KBlocksAILog.cpp --- old/kblocks-16.04.3/AI/KBlocksAILog.cpp 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/AI/KBlocksAILog.cpp 2016-06-12 09:35:45.000000000 +0200 @@ -1,11 +1,11 @@ /*************************************************************************** -* KBlocks, a falling blocks game for KDE * -* Copyright (C) 2010 University Freiburg * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * +* KBlocks, a falling blocks game for KDE * +* Copyright (C) 2010 University Freiburg <squall.leonhart....@gmail.com> * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * ***************************************************************************/ #include "KBlocksAILog.h" #include <string.h> @@ -73,7 +73,6 @@ void gotoXY(int x, int y) { #ifdef DEBUG - y++; char essq[100]; char xstr[100]; char ystr[100]; @@ -207,19 +206,19 @@ { if (full) { if (x != -1) { - gotoXY(x, y++); + gotoXY(x, ++y); } println(piece); if (x != -1) { - gotoXY(x, y++); + gotoXY(x, ++y); } println("STATE"); if (x != -1) { - gotoXY(x, y++); + gotoXY(x, ++y); } print("Rotation Id :"); println(piece->getRotation()); if (x != -1) { - gotoXY(x, y++); + gotoXY(x, ++y); } print("pos: ("); print(piece->getPosX()); @@ -229,7 +228,7 @@ println("Cells: "); for (int i = 0; i < KBlocksPiece_CellCount; ++i) { if (x != -1) { - gotoXY(x, y++); + gotoXY(x, ++y); } print("["); print(piece->getCellPosX(i)); @@ -251,7 +250,7 @@ int h = field->getHeight(); for (int j = 0; j < h; ++j) { if (x != -1) { - gotoXY(x, y + j); + gotoXY(x, y + j + 1); } print("|"); for (int i = 0; i < w; ++i) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/AI/KBlocksAILog.h new/kblocks-16.08.0/AI/KBlocksAILog.h --- old/kblocks-16.04.3/AI/KBlocksAILog.h 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/AI/KBlocksAILog.h 2016-06-12 09:35:45.000000000 +0200 @@ -1,11 +1,11 @@ /*************************************************************************** -* KBlocks, a falling blocks game for KDE * -* Copyright (C) 2010 University Freiburg * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * +* KBlocks, a falling blocks game for KDE * +* Copyright (C) 2010 University Freiburg <squall.leonhart....@gmail.com> * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * ***************************************************************************/ #ifndef KBLOCKSAILOG_H #define KBLOCKSAILOG_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/AI/KBlocksAIPlanner.cpp new/kblocks-16.08.0/AI/KBlocksAIPlanner.cpp --- old/kblocks-16.04.3/AI/KBlocksAIPlanner.cpp 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/AI/KBlocksAIPlanner.cpp 2016-06-12 09:35:45.000000000 +0200 @@ -1,11 +1,11 @@ /*************************************************************************** -* KBlocks, a falling blocks game for KDE * -* Copyright (C) 2010 University Freiburg * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * +* KBlocks, a falling blocks game for KDE * +* Copyright (C) 2010 University Freiburg <squall.leonhart....@gmail.com> * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * ***************************************************************************/ #include "KBlocksAIPlanner.h" #include "KBlocksAILog.h" @@ -14,9 +14,8 @@ ##### Definition ######################################### ############################################################ */ struct Span { - Span() + Span() : Span(0,0) { - Span(0, 0); } Span(int mn, int mx) { @@ -90,7 +89,7 @@ for (int i = 0; i < KBlocksPiece_CellCount; i++) { int cx = piece.getCellPosX(i); int cy = piece.getCellPosY(i); - if (mpField->getCell(cx, cy)) { + if (cx < 0 || cx >= w || mpField->getCell(cx, cy)) { invalidPos = true; break; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/AI/KBlocksAIPlanner.h new/kblocks-16.08.0/AI/KBlocksAIPlanner.h --- old/kblocks-16.04.3/AI/KBlocksAIPlanner.h 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/AI/KBlocksAIPlanner.h 2016-06-12 09:35:45.000000000 +0200 @@ -1,11 +1,11 @@ /*************************************************************************** -* KBlocks, a falling blocks game for KDE * -* Copyright (C) 2010 University Freiburg * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * +* KBlocks, a falling blocks game for KDE * +* Copyright (C) 2010 University Freiburg <squall.leonhart....@gmail.com> * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * ***************************************************************************/ #ifndef KBLOCKSAIPLANNER_H #define KBLOCKSAIPLANNER_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/AI/KBlocksAIPlannerExtend.cpp new/kblocks-16.08.0/AI/KBlocksAIPlannerExtend.cpp --- old/kblocks-16.04.3/AI/KBlocksAIPlannerExtend.cpp 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/AI/KBlocksAIPlannerExtend.cpp 2016-06-12 09:35:45.000000000 +0200 @@ -1,11 +1,11 @@ /*************************************************************************** -* KBlocks, a falling blocks game for KDE * -* Copyright (C) 2010 University Freiburg * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * +* KBlocks, a falling blocks game for KDE * +* Copyright (C) 2010 University Freiburg <squall.leonhart....@gmail.com> * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * ***************************************************************************/ #include "KBlocksAIPlannerExtend.h" #include "KBlocksAILog.h" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/AI/KBlocksAIPlannerExtend.h new/kblocks-16.08.0/AI/KBlocksAIPlannerExtend.h --- old/kblocks-16.04.3/AI/KBlocksAIPlannerExtend.h 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/AI/KBlocksAIPlannerExtend.h 2016-06-12 09:35:45.000000000 +0200 @@ -1,11 +1,11 @@ /*************************************************************************** -* KBlocks, a falling blocks game for KDE * -* Copyright (C) 2010 University Freiburg * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * +* KBlocks, a falling blocks game for KDE * +* Copyright (C) 2010 University Freiburg <squall.leonhart....@gmail.com> * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * ***************************************************************************/ #ifndef KBLOCKSAIPLANNEREXTEND_H #define KBLOCKSAIPLANNEREXTEND_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/AI/KBlocksAIPlayer.cpp new/kblocks-16.08.0/AI/KBlocksAIPlayer.cpp --- old/kblocks-16.04.3/AI/KBlocksAIPlayer.cpp 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/AI/KBlocksAIPlayer.cpp 2016-06-12 09:35:45.000000000 +0200 @@ -1,11 +1,11 @@ /*************************************************************************** -* KBlocks, a falling blocks game for KDE * -* Copyright (C) 2010 University Freiburg * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * +* KBlocks, a falling blocks game for KDE * +* Copyright (C) 2010 University Freiburg <squall.leonhart....@gmail.com> * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * ***************************************************************************/ #include "KBlocksAIPlayer.h" @@ -13,6 +13,9 @@ #include "KBlocksAIFeature.h" #include "KBlocksAIPlannerExtend.h" #include "KBlocksAILog.h" +#include "KBlocksAITypeDefine.h" + +#include "KBlocks_debug.h" #include <utility> #include <vector> @@ -48,7 +51,6 @@ mAIStarted = false; mAIPaused = false; - mpGame = 0; mpAIField = 0; mpCurPiece = 0; mpNextPiece = 0; @@ -175,11 +177,18 @@ /* Phase II - Planning ----------------------------------*/ void KBlocksAIPlayer::planning() { + if (!mpPlanner) { + qCWarning(KBlocksAI) << "No planner set for AI evaluation!"; + return; + } #ifdef TWO_PIECE_PLANNER AIPlanner_PieceValue_Sequence mPieceSequence = AIPlanner_PieceValue_Sequence(0); mPieceSequence.push_back(KBlocks_PieceType_Detail(mpCurPiece->toValue())); mPieceSequence.push_back(KBlocks_PieceType_Detail(mpNextPiece->toValue())); - mNextCount = (dynamic_cast<KBlocksAIPlannerExtend *>(mpPlanner))->process(mPieceSequence); + KBlocksAIPlannerExtend *extendedPlanner = dynamic_cast<KBlocksAIPlannerExtend *>(mpPlanner); + if (extendedPlanner != nullptr) { + mNextCount = extendedPlanner->process(mPieceSequence); + } #else KBlocks_PieceType_Detail type = KBlocks_PieceType_Detail(mpCurPiece->toValue()); mNextCount = mpPlanner->process(type); @@ -289,7 +298,7 @@ value = evaluator->evaluate(field); #endif #endif - result.push_back(Result(piece, value)); + result.push_back(Result(KBlocksPiece(piece), value)); #ifdef MAX_UTILITY bool better = (best_value < value); #else diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/AI/KBlocksAIPlayer.h new/kblocks-16.08.0/AI/KBlocksAIPlayer.h --- old/kblocks-16.04.3/AI/KBlocksAIPlayer.h 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/AI/KBlocksAIPlayer.h 2016-06-12 09:35:45.000000000 +0200 @@ -1,11 +1,11 @@ /*************************************************************************** -* KBlocks, a falling blocks game for KDE * -* Copyright (C) 2010 University Freiburg * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * +* KBlocks, a falling blocks game for KDE * +* Copyright (C) 2010 University Freiburg <squall.leonhart....@gmail.com> * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * ***************************************************************************/ #ifndef KBLOCKSAIPLAYER_H #define KBLOCKSAIPLAYER_H @@ -48,7 +48,6 @@ bool mAIPaused; // Phase I - State Update - SingleGameInterface *mpGame; KBlocksField *mpAIField; KBlocksPiece *mpCurPiece; KBlocksPiece *mpNextPiece; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/AI/KBlocksAITypeDefine.h new/kblocks-16.08.0/AI/KBlocksAITypeDefine.h --- old/kblocks-16.04.3/AI/KBlocksAITypeDefine.h 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/AI/KBlocksAITypeDefine.h 2016-06-12 09:35:45.000000000 +0200 @@ -1,18 +1,17 @@ /*************************************************************************** -* KBlocks, a falling blocks game for KDE * -* Copyright (C) 2010 University Freiburg * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * +* KBlocks, a falling blocks game for KDE * +* Copyright (C) 2010 University Freiburg <squall.leonhart....@gmail.com> * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * ***************************************************************************/ #ifndef KBLOCKSAITYPEDEFINE_H #define KBLOCKSAITYPEDEFINE_H #include <utility> #include <stdlib.h> -#include <time.h> #define KSIRTET diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/AI/PlannerInterface.h new/kblocks-16.08.0/AI/PlannerInterface.h --- old/kblocks-16.04.3/AI/PlannerInterface.h 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/AI/PlannerInterface.h 2016-06-12 09:35:45.000000000 +0200 @@ -1,11 +1,11 @@ /*************************************************************************** -* KBlocks, a falling blocks game for KDE * -* Copyright (C) 2010 University Freiburg * -* * -* This program is free software; you can redistribute it and/or modify * -* it under the terms of the GNU General Public License as published by * -* the Free Software Foundation; either version 2 of the License, or * -* (at your option) any later version. * +* KBlocks, a falling blocks game for KDE * +* Copyright (C) 2010 University Freiburg <squall.leonhart....@gmail.com> * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * ***************************************************************************/ #ifndef PLANNERINTERFACE_H #define PLANNERINTERFACE_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/CMakeLists.txt new/kblocks-16.08.0/CMakeLists.txt --- old/kblocks-16.04.3/CMakeLists.txt 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/CMakeLists.txt 2016-06-12 09:35:45.000000000 +0200 @@ -25,7 +25,7 @@ include(FeatureSummary) include(ECMInstallIcons) include(KDEInstallDirs) -include(KDECompilerSettings) +include(KDECompilerSettings NO_POLICY_SCOPE) include(KDECMakeSettings) include(ECMAddAppIcon) @@ -41,6 +41,7 @@ set(kblocks_SRCS main.cpp + KBlocks_debug.cpp KBlocksDefine.cpp KBlocksNetServer.cpp KBlocksNetClient.cpp diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/FieldInterface.h new/kblocks-16.08.0/FieldInterface.h --- old/kblocks-16.04.3/FieldInterface.h 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/FieldInterface.h 2016-06-12 09:35:45.000000000 +0200 @@ -12,8 +12,10 @@ class FieldInterface { +protected: + FieldInterface() : maBoard(nullptr), mHeight(0), mWidth(0) {}; + public: - FieldInterface() {}; virtual ~FieldInterface() {}; public: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/GameLogicInterface.h new/kblocks-16.08.0/GameLogicInterface.h --- old/kblocks-16.04.3/GameLogicInterface.h 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/GameLogicInterface.h 2016-06-12 09:35:45.000000000 +0200 @@ -15,7 +15,7 @@ class GameLogicInterface { public: - GameLogicInterface() {}; + GameLogicInterface() : maGameList(nullptr) {}; virtual ~GameLogicInterface() {}; public: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/GamePlayerInterface.h new/kblocks-16.08.0/GamePlayerInterface.h --- old/kblocks-16.04.3/GamePlayerInterface.h 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/GamePlayerInterface.h 2016-06-12 09:35:45.000000000 +0200 @@ -31,7 +31,7 @@ class GamePlayerInterface { public: - GamePlayerInterface() {}; + GamePlayerInterface() : mpGame(nullptr) {}; virtual ~GamePlayerInterface() {}; public: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/KBlocksDisplay.h new/kblocks-16.08.0/KBlocksDisplay.h --- old/kblocks-16.04.3/KBlocksDisplay.h 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/KBlocksDisplay.h 2016-06-12 09:35:45.000000000 +0200 @@ -49,7 +49,7 @@ private: int mGameCount; - int mGamesPerWidth; + //int mGamesPerWidth; int mUpdateInterval; QTimer mUpdateTimer; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/KBlocksDummyAI.cpp new/kblocks-16.08.0/KBlocksDummyAI.cpp --- old/kblocks-16.04.3/KBlocksDummyAI.cpp 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/KBlocksDummyAI.cpp 2016-06-12 09:35:45.000000000 +0200 @@ -9,11 +9,10 @@ ***************************************************************************/ #include "KBlocksDummyAI.h" -#include <stdlib.h> +#include <QtGlobal> KBlocksDummyAI::KBlocksDummyAI() { - mpGame = 0; mPauseFlag = false; mFieldWidth = 0; @@ -49,8 +48,8 @@ return; } - int rotation = rand() % (mRotateCount + 1) - mRotateCount / 2; - int motionx = rand() % (mFieldWidth + 1) - mFieldWidth / 2; + int rotation = qrand() % (mRotateCount + 1) - mRotateCount / 2; + int motionx = qrand() % (mFieldWidth + 1) - mFieldWidth / 2; if (rotation > 0) { for (int i = 0; i < rotation; i++) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/KBlocksDummyAI.h new/kblocks-16.08.0/KBlocksDummyAI.h --- old/kblocks-16.04.3/KBlocksDummyAI.h 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/KBlocksDummyAI.h 2016-06-12 09:35:45.000000000 +0200 @@ -27,7 +27,6 @@ void think(GamePlayer_ActionList *actionList); protected: - SingleGameInterface *mpGame; bool mPauseFlag; int mFieldWidth; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/KBlocksGameLogic.cpp new/kblocks-16.08.0/KBlocksGameLogic.cpp --- old/kblocks-16.04.3/KBlocksGameLogic.cpp 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/KBlocksGameLogic.cpp 2016-06-12 09:35:45.000000000 +0200 @@ -9,6 +9,8 @@ ***************************************************************************/ #include "KBlocksGameLogic.h" +#include <QtGlobal> + KBlocksGameLogic::KBlocksGameLogic(int capacity, bool record) { mGameCount = 0; @@ -20,6 +22,9 @@ mStandbyMode = false; mGameInterval = 0; + mInitialInterval = 0; + mLevelUpInterval = 0; + maGameList = new KBlocksSingleGame*[capacity]; if (record) { @@ -41,6 +46,9 @@ mStandbyMode = false; mGameInterval = 0; + mInitialInterval = 0; + mLevelUpInterval = 0; + maGameList = new KBlocksSingleGame*[mGameMax]; mpGameRecorder = 0; @@ -170,7 +178,7 @@ lineList[i] = tmpTotal; if ((mPunishFlag) && (tmpPunishCount > 0)) { - int punishSeed = rand() % 256; + int punishSeed = qrand() % 256; for (int j = 0; j < i; j++) { maGameList[j]->punishGame(tmpPunishCount, punishSeed); } @@ -276,9 +284,9 @@ int *seedList = new int[mGameCount]; if (mGameSeed < 0) { mGameSeed = -mGameSeed; - srand(mGameSeed); + qsrand(mGameSeed); for (int i = 0; i < mGameCount; i++) { - seedList[i] = rand() % 256; + seedList[i] = qrand() % 256; } } else { for (int i = 0; i < mGameCount; i++) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/KBlocksGameReplayer.cpp new/kblocks-16.08.0/KBlocksGameReplayer.cpp --- old/kblocks-16.04.3/KBlocksGameReplayer.cpp 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/KBlocksGameReplayer.cpp 2016-06-12 09:35:45.000000000 +0200 @@ -9,24 +9,51 @@ ***************************************************************************/ #include "KBlocksGameReplayer.h" +#include <sstream> +#include <string> + +#include "KBlocksDefine.h" +#include "KBlocks_debug.h" + KBlocksGameReplayer::KBlocksGameReplayer(const char *fileName, bool isBinaryMode) { + // Map data types to strings for reading text file for (int i = 0; i < RecordDataType_Max_Count; ++i) { mRTMap[ KBlocksRecordText[i] ] = i; } mRTMap[string("MaxCount")] = -1; - FILE *pFile = fopen(fileName, "r"); + // Set default variables in case loading the file fails + mGameCount = 0; + mGameSeed = 0; + mSameSeed = false; + mStepLength = 1; + + // Open replay file + std::ifstream replayFile; + if (isBinaryMode) { + replayFile.open(fileName, std::ios::binary); + } else { + replayFile.open(fileName); + } - if (!pFile) { - mGameCount = 0; + // Check that replay file was opened successfully + if (!replayFile.is_open()) { + qCWarning(KBReplay) << "Unable to open file " << fileName; return; } if (isBinaryMode) { - loadBinary(pFile); + loadBinary(replayFile); } else { - loadText(pFile); + loadText(replayFile); + } + + // Check that more than two Replay steps have been loaded + // The two first steps set the required variables. + if (mReplayList.size() < 2) { + qCWarning(KBReplay) << "Problem loading replay file" << fileName; + return; } mGameCount = mReplayList.front().value; @@ -35,9 +62,7 @@ mSameSeed = (mReplayList.front().index == 1); mReplayList.pop_front(); - mStepLength = 1; - - fclose(pFile); + replayFile.close(); } KBlocksGameReplayer::~KBlocksGameReplayer() @@ -93,48 +118,54 @@ return true; } -void KBlocksGameReplayer::loadText(FILE *pFile) +void KBlocksGameReplayer::loadText(std::ifstream &replayFile) { - int count = 0; - char tmpString[256]; + std::string line; + std::istringstream inStream; + std::string tmpString; KBlocksReplayData tmpData; mReplayList.clear(); - while (1) { - count = fscanf(pFile, "%d %s %d %d", &(tmpData.time), tmpString, &(tmpData.index), &(tmpData.value)); - tmpData.type = mRTMap[string(tmpString)]; - if ((tmpData.type == -1) || (count != 4)) { + do { + std::getline(replayFile, line); + inStream.str(line); + inStream >> tmpData.time >> tmpString >> tmpData.index >> tmpData.value; + tmpData.type = mRTMap[tmpString]; + if ((tmpData.type == -1) || inStream.fail()) { break; } mReplayList.push_back(tmpData); - } + inStream.clear(); + } while (!replayFile.eof()); } -void KBlocksGameReplayer::loadBinary(FILE *pFile) +void KBlocksGameReplayer::loadBinary(std::ifstream &replayFile) { KBlocksReplayData tmpData; mReplayList.clear(); - tmpData.time = fgetc(pFile); - tmpData.type = fgetc(pFile); - tmpData.index = fgetc(pFile); - tmpData.value = fgetc(pFile); - while (tmpData.time != EOF) { + + tmpData.time = replayFile.get(); + tmpData.type = replayFile.get(); + tmpData.index = replayFile.get(); + tmpData.value = replayFile.get(); + + do { if (tmpData.type == RecordDataType_Skipped) { int tmpTime = tmpData.time; while (tmpData.type == RecordDataType_Skipped) { - tmpData.time = fgetc(pFile); - tmpData.type = fgetc(pFile); - tmpData.index = fgetc(pFile); - tmpData.value = fgetc(pFile); + tmpData.time = replayFile.get(); + tmpData.type = replayFile.get(); + tmpData.index = replayFile.get(); + tmpData.value = replayFile.get(); tmpTime += tmpData.time; } tmpData.time = tmpTime; } mReplayList.push_back(tmpData); - tmpData.time = fgetc(pFile); - tmpData.type = fgetc(pFile); - tmpData.index = fgetc(pFile); - tmpData.value = fgetc(pFile); - } + tmpData.time = replayFile.get(); + tmpData.type = replayFile.get(); + tmpData.index = replayFile.get(); + tmpData.value = replayFile.get(); + } while (!replayFile.eof()); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/KBlocksGameReplayer.h new/kblocks-16.08.0/KBlocksGameReplayer.h --- old/kblocks-16.04.3/KBlocksGameReplayer.h 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/KBlocksGameReplayer.h 2016-06-12 09:35:45.000000000 +0200 @@ -12,7 +12,7 @@ #include "KBlocksDefine.h" -#include <stdio.h> +#include <fstream> #include <string> #include <vector> #include <list> @@ -46,8 +46,8 @@ bool getNextRecords(vector<KBlocksReplayData> *data); private: - void loadText(FILE *pFile); - void loadBinary(FILE *pFile); + void loadText(std::ifstream &pFile); + void loadBinary(std::ifstream &pFile); private: int mGameCount; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/KBlocksGraphics.cpp new/kblocks-16.08.0/KBlocksGraphics.cpp --- old/kblocks-16.04.3/KBlocksGraphics.cpp 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/KBlocksGraphics.cpp 2016-06-12 09:35:45.000000000 +0200 @@ -9,7 +9,7 @@ * (at your option) any later version. * ***************************************************************************/ #include "KBlocksGraphics.h" -#include <QDebug> +#include "KBlocks_debug.h" #include <QPixmapCache> #include <QPainter> @@ -18,7 +18,8 @@ { m_theme = new KGameTheme(); if (!m_theme->load(themeFile)) { - qWarning() << "Error loading KBlocks .desktop theme" << themeFile << endl; + qCWarning(KBGraphics) << "Error loading KBlocks .desktop theme" + << themeFile << endl; m_theme->loadDefault(); } m_renderer = new QSvgRenderer(m_theme->graphics()); @@ -34,11 +35,13 @@ bool KBlocksGraphics::loadTheme(const QString &themeFile) { if (!m_theme->load(themeFile)) { - qWarning() << "Error loading KBlocks .desktop theme" << themeFile << endl; + qCWarning(KBGraphics) << "Error loading KBlocks .desktop theme" + << themeFile << endl; return false; } if (!m_renderer->load(m_theme->graphics())) { - qWarning() << "Error loading SVG theme" << m_theme->graphics() << endl; + qCWarning(KBGraphics) << "Error loading SVG theme" + << m_theme->graphics() << endl; return false; } //clear the cache or pixmaps from the old theme will be returned @@ -69,7 +72,7 @@ } else { aspectratio = nh/origh; } - //qWarning() << aspectratio; + //qCDebug(KBGraphics) << aspectratio; m_Block_Size = (int) (aspectratio*(qreal)m_Block_Size); m_View_Size_Width = (int) (aspectratio*(double)m_View_Size_Width); m_View_Size_Height = (int) (aspectratio*(double)m_View_Size_Height); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/KBlocksNetPlayer.cpp new/kblocks-16.08.0/KBlocksNetPlayer.cpp --- old/kblocks-16.04.3/KBlocksNetPlayer.cpp 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/KBlocksNetPlayer.cpp 2016-06-12 09:35:45.000000000 +0200 @@ -16,7 +16,9 @@ mpNetClient = new KBlocksNetClient(serverIP.c_str(), localPort); mpPlayer = player; + mpGame = nullptr; + mSendLength = 0; mActionList.clear(); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/KBlocksNetServer.cpp new/kblocks-16.08.0/KBlocksNetServer.cpp --- old/kblocks-16.04.3/KBlocksNetServer.cpp 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/KBlocksNetServer.cpp 2016-06-12 09:35:45.000000000 +0200 @@ -20,14 +20,19 @@ KBlocksNetServer::KBlocksNetServer(KBlocksGameLogic *p, const QString &localIP) { mpGameLogic = p; + maGameScoreList = nullptr; mGameCount = 0; mGameStarted = false; mWaitForAll = false; + mTopGameLevel = -1; mInitSendLength = 0; mLvUpSendLength = 0; parseIPString(localIP, &mLocalAddress, &mLocalPort); + // mRemoteAddress and mRemotePort are only used in recvRemoteData + // and will be set there. + mRemotePort = 0; mpServerSocket = new QUdpSocket(this); mpServerSocket->bind(mLocalAddress, mLocalPort); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/KBlocksNetServer.h new/kblocks-16.08.0/KBlocksNetServer.h --- old/kblocks-16.04.3/KBlocksNetServer.h 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/KBlocksNetServer.h 2016-06-12 09:35:45.000000000 +0200 @@ -62,8 +62,8 @@ KBlocksScore **maGameScoreList; bool mWaitForAll; - bool mSpeedMode; - int mTimeOut; + //bool mSpeedMode; + //int mTimeOut; int mTopGameLevel; int mInitSendLength; int mLvUpSendLength; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/KBlocksPiece.cpp new/kblocks-16.08.0/KBlocksPiece.cpp --- old/kblocks-16.04.3/KBlocksPiece.cpp 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/KBlocksPiece.cpp 2016-06-12 09:35:45.000000000 +0200 @@ -127,10 +127,6 @@ KBlocksPiece::KBlocksPiece() { - mType = 0; - mPosX = 0; - mPosY = 0; - mRotation = 0; } KBlocksPiece::KBlocksPiece(PieceInterface *p) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/KBlocksPiece.h new/kblocks-16.08.0/KBlocksPiece.h --- old/kblocks-16.04.3/KBlocksPiece.h 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/KBlocksPiece.h 2016-06-12 09:35:45.000000000 +0200 @@ -84,7 +84,7 @@ { public: KBlocksPiece(); - KBlocksPiece(PieceInterface *p); + explicit KBlocksPiece(PieceInterface *p); ~KBlocksPiece(); public: @@ -117,12 +117,6 @@ void encodeData(unsigned char *data); void decodeData(unsigned char *data); - -protected: - int mType; - int mPosX; - int mPosY; - int mRotation; }; #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/KBlocksPieceGenerator.cpp new/kblocks-16.08.0/KBlocksPieceGenerator.cpp --- old/kblocks-16.04.3/KBlocksPieceGenerator.cpp 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/KBlocksPieceGenerator.cpp 2016-06-12 09:35:45.000000000 +0200 @@ -9,7 +9,7 @@ ***************************************************************************/ #include "KBlocksPieceGenerator.h" -#include <stdlib.h> +#include <QtGlobal> #include <stdio.h> #include "KBlocksPiece.h" @@ -28,10 +28,10 @@ void KBlocksPieceGenerator::genList(int seed) { - srand(seed); + qsrand(seed); for (int i = 0; i < maxCapacity; i++) { - maPieceList[i] = rand() % PieceType_Detail_Max_Count; + maPieceList[i] = qrand() % PieceType_Detail_Max_Count; } pieceIndex = 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/KBlocksPlayNetwork.cpp new/kblocks-16.08.0/KBlocksPlayNetwork.cpp --- old/kblocks-16.04.3/KBlocksPlayNetwork.cpp 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/KBlocksPlayNetwork.cpp 2016-06-12 09:35:45.000000000 +0200 @@ -20,6 +20,8 @@ mServerIP = serverIP; mLocalPort = localPort; + mRunning = false; + mPlayerCount = 0; mMaxCapacity = capacity; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/KBlocksRepWin.cpp new/kblocks-16.08.0/KBlocksRepWin.cpp --- old/kblocks-16.04.3/KBlocksRepWin.cpp 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/KBlocksRepWin.cpp 2016-06-12 09:35:45.000000000 +0200 @@ -15,15 +15,22 @@ #include <qdatetime.h> +#include "KBlocks_debug.h" + KBlocksRepWin::KBlocksRepWin(const char *replayFile, bool binaryMode) : KMainWindow() { //Use up to 3MB for global application pixmap cache QPixmapCache::setCacheLimit(3 * 1024); + mUpdateInterval = 1000; + mpGameReplayer = new KBlocksGameReplayer(replayFile, binaryMode); mGameCount = mpGameReplayer->getGameCount(); if (mGameCount == 0) { + mpGameScene = nullptr; + mpGameView = nullptr; + mpGameLogic = nullptr; return; } @@ -44,7 +51,6 @@ mpGameView->show(); setCentralWidget(mpGameView); - mUpdateInterval = 1000; mUpdateTimer.setInterval(mUpdateInterval); connect(&mUpdateTimer, &QTimer::timeout, this, &KBlocksRepWin::replayOneStep); mUpdateTimer.stop(); @@ -63,14 +69,18 @@ void KBlocksRepWin::setGamesPerLine(int count) { - mpGameScene->setGamesPerLine(count); + if (mpGameScene) { + mpGameScene->setGamesPerLine(count); + } } void KBlocksRepWin::setUpdateInterval(int interval) { - mUpdateInterval = interval; - mUpdateTimer.setInterval(mUpdateInterval); - mpGameScene->setUpdateInterval(interval); + if (mpGameScene) { + mUpdateInterval = interval; + mUpdateTimer.setInterval(mUpdateInterval); + mpGameScene->setUpdateInterval(interval); + } } void KBlocksRepWin::setReplayStepLength(int stepLen) @@ -95,10 +105,14 @@ void KBlocksRepWin::startReplay() { - mpGameLogic->startGame(mGameCount); + if (mpGameLogic) { + mpGameLogic->startGame(mGameCount); + } - mpGameScene->createGameItemGroups(mGameCount); - mpGameScene->startGame(); + if (mpGameScene) { + mpGameScene->createGameItemGroups(mGameCount); + mpGameScene->startGame(); + } mUpdateTimer.start(); } @@ -107,10 +121,14 @@ { mUpdateTimer.stop(); - mpGameScene->stopGame(); - mpGameScene->deleteGameItemGroups(); + if (mpGameScene) { + mpGameScene->stopGame(); + mpGameScene->deleteGameItemGroups(); + } - mpGameLogic->stopGame(); + if (mpGameLogic) { + mpGameLogic->stopGame(); + } } QString KBlocksRepWin::getTimeString() @@ -144,7 +162,7 @@ { int tmpPieceChanged = 0; if (!mpGameLogic->playRecordOneStep(&tmpPieceChanged)) { - printf("Finished Replay!\n"); + qCDebug(KBReplay) << "Finished Replay!"; mUpdateTimer.stop(); } if (tmpPieceChanged != 0) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/KBlocksRepWin.h new/kblocks-16.08.0/KBlocksRepWin.h --- old/kblocks-16.04.3/KBlocksRepWin.h 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/KBlocksRepWin.h 2016-06-12 09:35:45.000000000 +0200 @@ -54,7 +54,7 @@ private: int mGameCount; - int mGamesPerWidth; + //int mGamesPerWidth; int mUpdateInterval; QTimer mUpdateTimer; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/KBlocksScene.cpp new/kblocks-16.08.0/KBlocksScene.cpp --- old/kblocks-16.04.3/KBlocksScene.cpp 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/KBlocksScene.cpp 2016-06-12 09:35:45.000000000 +0200 @@ -47,6 +47,8 @@ mUpdateTimer.setInterval(mUpdateInterval); connect(&mUpdateTimer, &QTimer::timeout, this, &KBlocksScene::updateGame); mUpdateTimer.stop(); + + mMessageBox = nullptr; } KBlocksScene::~KBlocksScene() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/KBlocksSingleGame.cpp new/kblocks-16.08.0/KBlocksSingleGame.cpp --- old/kblocks-16.04.3/KBlocksSingleGame.cpp 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/KBlocksSingleGame.cpp 2016-06-12 09:35:45.000000000 +0200 @@ -11,7 +11,7 @@ #include "KBlocksField.h" #include "KBlocksPiece.h" -#include <stdlib.h> +#include <QtGlobal> KBlocksSingleGame::KBlocksSingleGame(int gameIndex, int fieldWidth, int fieldHeight, int showPieceCount, int messagePoolSize) { @@ -125,11 +125,11 @@ mpGameRecorder->append(mGameIndex, RecordDataType_PunishLineSeed, punishSeed); } - srand(punishSeed); + qsrand(punishSeed); int punishIndex = 0; for (int i = 0; i < lineCount; i++) { setCurrentPiece(0, -1, 0); - punishIndex = rand() % width; + punishIndex = qrand() % width; mpField->addPunishLine(lineCount, punishIndex); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/KBlocksSound.cpp new/kblocks-16.08.0/KBlocksSound.cpp --- old/kblocks-16.04.3/KBlocksSound.cpp 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/KBlocksSound.cpp 2016-06-12 09:35:45.000000000 +0200 @@ -11,21 +11,22 @@ //Uses routines from Kapman sound manager (game.cpp) #include "KBlocksSound.h" -#include "settings.h" #include <kgsound.h> -#include <QDebug> #include <QStandardPaths> +#include "KBlocks_debug.h" +#include "settings.h" + KBlocksSound::KBlocksSound() { m_blockFallSound = new KgSound(QStandardPaths::locate( - QStandardPaths::DataLocation, "sounds/block-fall.ogg")); + QStandardPaths::AppDataLocation, "sounds/block-fall.ogg")); m_blockMoveSound = new KgSound(QStandardPaths::locate( - QStandardPaths::DataLocation, "sounds/block-move.ogg")); + QStandardPaths::AppDataLocation, "sounds/block-move.ogg")); m_blockRemoveSound = new KgSound(QStandardPaths::locate( - QStandardPaths::DataLocation, "sounds/block-remove.ogg")); + QStandardPaths::AppDataLocation, "sounds/block-remove.ogg")); setSoundsEnabled(Settings::sounds()); } @@ -55,7 +56,7 @@ m_blockRemoveSound->start(); break; default: - qDebug() << "Unknown Sound requested for playback."; + qCWarning(KBSound) << "Unknown Sound requested for playback."; break; } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/KBlocksWin.cpp new/kblocks-16.08.0/KBlocksWin.cpp --- old/kblocks-16.04.3/KBlocksWin.cpp 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/KBlocksWin.cpp 2016-06-12 09:35:45.000000000 +0200 @@ -11,7 +11,6 @@ #include "KBlocksWin.h" #include <limits.h> -#include <stdlib.h> #include <KConfigDialog> #include <kstandardgameaction.h> @@ -24,6 +23,7 @@ #include <QStatusBar> #include <KgDifficulty> +#include <QtGlobal> #include <QPixmapCache> #include <QPointer> #include <QLabel> @@ -103,8 +103,8 @@ void KBlocksWin::startGame() { - srand(time(0)); - mpGameLogic->setGameSeed(rand()); + qsrand(time(0)); + mpGameLogic->setGameSeed(qrand()); if (mpGameLogic->startGame(mGameCount)) { mpPlayManager->startGame(); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/KBlocks_debug.cpp new/kblocks-16.08.0/KBlocks_debug.cpp --- old/kblocks-16.04.3/KBlocks_debug.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/kblocks-16.08.0/KBlocks_debug.cpp 2016-06-12 09:35:45.000000000 +0200 @@ -0,0 +1,16 @@ +/*************************************************************************** +* KBlocks, a falling blocks game for KDE * +* Copyright (C) 2016 Julian Helfferich <julian.helffer...@gmail.com> * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +***************************************************************************/ +#include "KBlocks_debug.h" + +Q_LOGGING_CATEGORY(KBlocksAI,"KBlocks.AI") +Q_LOGGING_CATEGORY(KBGeneral, "KBlocks.General") +Q_LOGGING_CATEGORY(KBGraphics, "KBlocks.Graphics") +Q_LOGGING_CATEGORY(KBReplay, "KBlocks.Replay") +Q_LOGGING_CATEGORY(KBSound, "KBlocks.Sound") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/KBlocks_debug.h new/kblocks-16.08.0/KBlocks_debug.h --- old/kblocks-16.04.3/KBlocks_debug.h 1970-01-01 01:00:00.000000000 +0100 +++ new/kblocks-16.08.0/KBlocks_debug.h 2016-06-12 09:35:45.000000000 +0200 @@ -0,0 +1,21 @@ +/*************************************************************************** +* KBlocks, a falling blocks game for KDE * +* Copyright (C) 2016 Julian Helfferich <julian.helffer...@gmail.com> * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +***************************************************************************/ + +#ifndef KBLOCKS_DEBUG_H +#define KBLOCKS_DEBUG_H + +#include <QLoggingCategory> +Q_DECLARE_LOGGING_CATEGORY(KBlocksAI) +Q_DECLARE_LOGGING_CATEGORY(KBGeneral) +Q_DECLARE_LOGGING_CATEGORY(KBGraphics) +Q_DECLARE_LOGGING_CATEGORY(KBReplay) +Q_DECLARE_LOGGING_CATEGORY(KBSound) + +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/PieceInterface.h new/kblocks-16.08.0/PieceInterface.h --- old/kblocks-16.04.3/PieceInterface.h 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/PieceInterface.h 2016-06-12 09:35:45.000000000 +0200 @@ -13,7 +13,7 @@ class PieceInterface { public: - PieceInterface() {}; + PieceInterface() : mType(0), mPosX(0), mPosY(0), mRotation(0) {}; virtual ~PieceInterface() {}; public: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/SingleGameInterface.h new/kblocks-16.08.0/SingleGameInterface.h --- old/kblocks-16.04.3/SingleGameInterface.h 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/SingleGameInterface.h 2016-06-12 09:35:45.000000000 +0200 @@ -18,7 +18,8 @@ class SingleGameInterface { public: - SingleGameInterface() {}; + SingleGameInterface() + : mpField(nullptr), mPieceCount(0), mpPieceList(nullptr) {}; virtual ~SingleGameInterface() {}; public: Files old/kblocks-16.04.3/doc/gameboard.png and new/kblocks-16.08.0/doc/gameboard.png differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/doc/index.docbook new/kblocks-16.08.0/doc/index.docbook --- old/kblocks-16.04.3/doc/index.docbook 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/doc/index.docbook 2016-06-12 09:35:45.000000000 +0200 @@ -1,7 +1,5 @@ <?xml version="1.0" ?> <!DOCTYPE book PUBLIC "-//KDE//DTD DocBook XML V4.5-Based Variant V1.1//EN" "dtd/kdedbx45.dtd" [ - <!ENTITY kappname "&kblocks;"> - <!ENTITY package "kdegames"> <!ENTITY % addindex "IGNORE"> <!ENTITY % English "INCLUDE" > <!-- change language only here --> ]> @@ -29,8 +27,8 @@ <legalnotice>&FDLNotice;</legalnotice> -<date>2013-05-05</date> -<releaseinfo>0.3 (&kde; 4.11)</releaseinfo> +<date>2016-05-09</date> +<releaseinfo>0.4 (Applications 16.04)</releaseinfo> <abstract><para>&kblocks; is the &kde; version of the classic falling blocks game.</para></abstract> @@ -55,6 +53,18 @@ <chapter id="how-to-play"> <title>How to Play</title> + +<screenshot> +<mediaobject> +<imageobject> +<imagedata fileref="gameboard.png" format="PNG"/> +</imageobject> +<textobject> +<phrase>&kblocks; gameboard</phrase> +</textobject> +</mediaobject> +</screenshot> + <note><title>Objective:</title><para>Rotate the falling blocks, and fit them together to complete lines and clear the playfield.</para></note><!--Describe the objective of the game.--> <para> @@ -141,17 +151,7 @@ <guimenuitem>Quit</guimenuitem> </menuchoice></term> <listitem><para><action>Quits</action> &kblocks;</para></listitem> </varlistentry> -<!--FIXME when is sound played ? see https://bugs.kde.org/show_bug.cgi?id=319372 -<varlistentry> -<term><menuchoice> -<shortcut> -<keycombo action="simul">&Ctrl;<keycap>Q</keycap></keycombo> -</shortcut> -<guimenu>Settings</guimenu> -<guimenuitem>Play sound</guimenuitem> </menuchoice></term> -<listitem><para>???</para></listitem> -</varlistentry> ---> + <varlistentry> <term><menuchoice> <guimenu>Settings</guimenu> @@ -196,6 +196,7 @@ <row><entry><keycap>Down arrow</keycap></entry><entry>Move the block down</entry></row> <row><entry><keycap>Z</keycap></entry><entry>Rotate the block clockwise</entry></row> <row><entry><keycap>Up arrow</keycap></entry><entry>Rotate the block counter clockwise</entry></row> +<row><entry><keysym>Space</keysym></entry><entry>Drop the block</entry></row> </tbody> </tgroup> @@ -271,24 +272,6 @@ </chapter> -<appendix id="installation"> -<title>Installation</title> - -<sect1 id="getting-kblocks"> -<title>How to obtain &kblocks;</title> - -&install.intro.documentation; - -</sect1> - -<sect1 id="compilation"> -<title>Compilation and Installation</title> - -&install.compile.documentation; - -</sect1> -</appendix> - </book> <!-- Local Variables: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/main.cpp new/kblocks-16.08.0/main.cpp --- old/kblocks-16.04.3/main.cpp 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/main.cpp 2016-06-12 09:35:45.000000000 +0200 @@ -8,7 +8,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * ***************************************************************************/ -#include <time.h> +#include <ctime> #include <string> #include <vector> @@ -66,7 +66,7 @@ { // Desktop User Mode mpKBlocksGameLogic = new KBlocksGameLogic(2); - mpKBlocksGameLogic->setGameSeed(time(0)); + mpKBlocksGameLogic->setGameSeed(std::time(nullptr)); mpKBlocksGameLogic->setGamePunish(true); mpKBlocksGameLogic->setGameStandbyMode(true); mpKBlocksGameLogic->setInitInterval(500); @@ -118,7 +118,7 @@ printf("\tHas Human = %s\n", hasHuman ? "true" : "false"); printf("\tSpeed Limit = %s\n", sendLimit ? "true" : "false"); mpKBlocksGameLogic = new KBlocksGameLogic(gameCount, true); - mpKBlocksGameLogic->setGameSeed(sameSeq ? time(0) : -time(0)); + mpKBlocksGameLogic->setGameSeed(sameSeq ? std::time(nullptr) : -std::time(nullptr)); mpKBlocksGameLogic->setGamePunish(hasAttack); mpKBlocksGameLogic->setGameStandbyMode(standbyMode); mpKBlocksGameLogic->setInitInterval(hasHuman ? 500 : 0); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kblocks-16.04.3/org.kde.kblocks.appdata.xml new/kblocks-16.08.0/org.kde.kblocks.appdata.xml --- old/kblocks-16.04.3/org.kde.kblocks.appdata.xml 2016-03-28 14:16:41.000000000 +0200 +++ new/kblocks-16.08.0/org.kde.kblocks.appdata.xml 2016-06-12 09:35:45.000000000 +0200 @@ -11,6 +11,7 @@ <name xml:lang="cs">KBlocks</name> <name xml:lang="da">KBlocks</name> <name xml:lang="de">KBlocks</name> + <name xml:lang="el">KBlocks</name> <name xml:lang="en-GB">KBlocks</name> <name xml:lang="es">KBlock</name> <name xml:lang="fi">KBlocks</name> @@ -43,6 +44,7 @@ <summary xml:lang="ca-valencia">Joc de blocs que cauen</summary> <summary xml:lang="cs">Hra s padajícími bloky</summary> <summary xml:lang="de">„Tetris“-Spiel</summary> + <summary xml:lang="el">Παιχνίδι πτώσης τούβλων</summary> <summary xml:lang="en-GB">Falling Blocks Game</summary> <summary xml:lang="es">Juego de caída de bloques</summary> <summary xml:lang="fi">Putoavien kappaleiden peli</summary> @@ -78,6 +80,7 @@ <p xml:lang="ca">El KBlocks és el joc clàssic de blocs que cauen. La idea és apilar els blocs que cauen per crear línies horitzontals sense cap forat. Quan s'ha completat una línia, aquesta s'elimina i queda més espai disponible a l'àrea de joc. Quan no hi ha espai suficient per als blocs que cauen el joc finalitza.</p> <p xml:lang="ca-valencia">El KBlocks és el joc clàssic de blocs que cauen. La idea és apilar els blocs que cauen per crear línies horitzontals sense cap forat. Quan s'ha completat una línia, esta s'elimina i queda més espai disponible a l'àrea de joc. Quan no hi ha espai suficient per als blocs que cauen el joc finalitza.</p> <p xml:lang="de">KBlocks ist ein klassisches Tetris-Spiel. Die herunterfallenden Blöcke müssen so gestapelt werden, dass sie waagerechte Zeilen ohne Lücken bilden. Eine solche Zeile verschwindet dann, und im Spielfeld ist wieder mehr Platz. Wenn es keinen Platz mehr für herunterfallende Blöcke gibt, ist das Spiel zu Ende.</p> + <p xml:lang="el">Το KBlocks είναι το κλασικό παιχνίδι πτώσης τούβλων. Η ιδέα είναι να δημιουργηθούν με τα τούβλα οριζόντιες γραμμές χωρίς κενά. Όταν μια γραμμή συμπληρωθεί, αφαιρείται και περισσότερος χώρος γίνεται διαθέσιμος στην περιοχή του παιχνιδιού. Όταν δεν υπάρχει αρκετός χώρος για να πέσουν τα τούβλα, το ταιχνίδι τελειώνει.να δημιουργήσουν</p> <p xml:lang="en-GB">KBlocks is the classic falling blocks game. The idea is to stack the falling blocks to create horizontal lines without any gaps. When a line is completed it is removed, and more space is available in the play area. When there is not enough space for blocks to fall, the game is over.</p> <p xml:lang="es">KBlocks es un juego clásico de caída de bloques. La idea es apilar los bloques que van cayendo para crear líneas horizontaes sin huecos. Cuando se completa una línea se elimina, y hay más espacio disponible en la zona de juego. Cuando no queda más sitio para que los bloques caigan, se termina el juego.</p> <p xml:lang="fi">KBlock on perinteinen putoavien kappaleiden peli. Tavoitteena on kasata putoavat kappaleet aukottomiksi vaakariveiksi. Kun rivi on valmis, se poistetaan ja pelialue kasvaa. Kun kappaleilla ei ole enää tilaa pudota, peli on lopussa.</p> @@ -110,4 +113,7 @@ </screenshot> </screenshots> <project_group>KDE</project_group> + <provides> + <binary>kblocks</binary> + </provides> </component>