Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
KShisen
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Games
KShisen
Commits
faf285e7
Commit
faf285e7
authored
May 10, 2016
by
Frederik Schwarzer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename logging category.
parent
d62ddb85
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
40 deletions
+40
-40
src/app.cpp
src/app.cpp
+1
-1
src/board.cpp
src/board.cpp
+31
-31
src/debug.h
src/debug.h
+1
-1
src/main.cpp
src/main.cpp
+1
-1
src/possiblemove.cpp
src/possiblemove.cpp
+6
-6
No files found.
src/app.cpp
View file @
faf285e7
...
...
@@ -296,7 +296,7 @@ void App::updateTimeDisplay()
if
(
m_board
->
isStuck
()
||
m_board
->
isOver
())
{
return
;
}
//qCDebug(KSHISEN_
LOG
) << "Time: " << m_board->currentTime();
//qCDebug(KSHISEN_
General
) << "Time: " << m_board->currentTime();
int
const
currentTime
=
m_board
->
currentTime
();
QString
const
message
=
i18n
(
"Your time: %1:%2:%3 %4"
,
QString
().
sprintf
(
"%02d"
,
currentTime
/
3600
),
...
...
src/board.cpp
View file @
faf285e7
...
...
@@ -98,12 +98,12 @@ Board::Board(QWidget * parent)
void
Board
::
loadSettings
()
{
if
(
!
loadTileset
(
Prefs
::
tileSet
()))
{
qCDebug
(
KSHISEN_
LOG
)
<<
"An error occurred when loading the tileset"
<<
Prefs
::
tileSet
()
<<
"KShisen will continue with the default tileset."
;
qCDebug
(
KSHISEN_
General
)
<<
"An error occurred when loading the tileset"
<<
Prefs
::
tileSet
()
<<
"KShisen will continue with the default tileset."
;
}
// Load background
if
(
!
loadBackground
(
Prefs
::
background
()))
{
qCDebug
(
KSHISEN_
LOG
)
<<
"An error occurred when loading the background"
<<
Prefs
::
background
()
<<
"KShisen will continue with the default background."
;
qCDebug
(
KSHISEN_
General
)
<<
"An error occurred when loading the background"
<<
Prefs
::
background
()
<<
"KShisen will continue with the default background."
;
}
// There are tile sets, that have only one tile for e.g. the flowers group.
...
...
@@ -405,9 +405,9 @@ void Board::setSize(int x, int y)
void
Board
::
resizeEvent
(
QResizeEvent
*
e
)
{
qCDebug
(
KSHISEN_
LOG
)
<<
"[resizeEvent]"
;
qCDebug
(
KSHISEN_
General
)
<<
"[resizeEvent]"
;
if
(
e
->
spontaneous
())
{
qCDebug
(
KSHISEN_
LOG
)
<<
"[resizeEvent] spontaneous"
;
qCDebug
(
KSHISEN_
General
)
<<
"[resizeEvent] spontaneous"
;
}
resizeBoard
();
emit
resized
();
...
...
@@ -547,7 +547,7 @@ void Board::newGame()
}
// debug, tell if make solvable failed
if
(
maxAttempts
==
0
)
{
qCDebug
(
KSHISEN_
LOG
)
<<
"NewGame make solvable failed"
;
qCDebug
(
KSHISEN_
General
)
<<
"NewGame make solvable failed"
;
}
...
...
@@ -864,7 +864,7 @@ void Board::performMove(PossibleMove & possibleMoves)
// DEBUG undo, compare to saved board state
for
(
int
i
=
0
;
i
<
xTiles
()
*
yTiles
();
++
i
)
{
if
(
saved1
.
at
(
i
)
!=
m_field
.
at
(
i
))
{
qCDebug
(
KSHISEN_
LOG
)
<<
"[DEBUG Undo 1], tile ("
<<
i
<<
") was"
<<
saved1
.
at
(
i
)
<<
"before move, it is"
<<
m_field
.
at
(
i
)
<<
"after undo."
;
qCDebug
(
KSHISEN_
General
)
<<
"[DEBUG Undo 1], tile ("
<<
i
<<
") was"
<<
saved1
.
at
(
i
)
<<
"before move, it is"
<<
m_field
.
at
(
i
)
<<
"after undo."
;
errorFound
=
true
;
}
}
...
...
@@ -877,7 +877,7 @@ void Board::performMove(PossibleMove & possibleMoves)
// DEBUG undo, compare to saved board2 state
for
(
int
i
=
0
;
i
<
xTiles
()
*
yTiles
();
++
i
)
{
if
(
saved2
.
at
(
i
)
!=
m_field
.
at
(
i
))
{
qCDebug
(
KSHISEN_
LOG
)
<<
"[DEBUG Undo 2], tile ("
<<
i
<<
") was"
<<
saved2
.
at
(
i
)
<<
"after move, it is"
<<
m_field
.
at
(
i
)
<<
"after redo."
;
qCDebug
(
KSHISEN_
General
)
<<
"[DEBUG Undo 2], tile ("
<<
i
<<
") was"
<<
saved2
.
at
(
i
)
<<
"after move, it is"
<<
m_field
.
at
(
i
)
<<
"after redo."
;
errorFound
=
true
;
}
}
...
...
@@ -887,13 +887,13 @@ void Board::performMove(PossibleMove & possibleMoves)
}
// dumpBoard on error
if
(
errorFound
)
{
qCDebug
(
KSHISEN_
LOG
)
<<
"[DEBUG] Before move"
;
qCDebug
(
KSHISEN_
General
)
<<
"[DEBUG] Before move"
;
dumpBoard
(
saved1
);
qCDebug
(
KSHISEN_
LOG
)
<<
"[DEBUG] After move"
;
qCDebug
(
KSHISEN_
General
)
<<
"[DEBUG] After move"
;
dumpBoard
(
saved2
);
qCDebug
(
KSHISEN_
LOG
)
<<
"[DEBUG] Undo"
;
qCDebug
(
KSHISEN_
General
)
<<
"[DEBUG] Undo"
;
dumpBoard
(
saved3
);
qCDebug
(
KSHISEN_
LOG
)
<<
"[DEBUG] Redo"
;
qCDebug
(
KSHISEN_
General
)
<<
"[DEBUG] Redo"
;
dumpBoard
(
saved4
);
}
...
...
@@ -1459,7 +1459,7 @@ void Board::undo()
// if there is no slide, keep previous implementation: move both column up
if
(
!
move
->
hasSlide
())
{
#ifdef DEBUGGING
qCDebug
(
KSHISEN_
LOG
)
<<
"[undo] gravity from a no slide move"
;
qCDebug
(
KSHISEN_
General
)
<<
"[undo] gravity from a no slide move"
;
#endif
// move tiles from the first column up
for
(
int
y
=
0
;
y
<
move
->
y1
();
++
y
)
{
...
...
@@ -1474,7 +1474,7 @@ void Board::undo()
}
}
else
{
// else check all tiles from the slide that may have fallen down
#ifdef DEBUGGING
qCDebug
(
KSHISEN_
LOG
)
<<
"[undo] gravity from slide s1("
<<
move
->
slideX1
()
<<
","
<<
move
->
slideY1
()
<<
")=>s2("
<<
move
->
slideX2
()
<<
","
<<
move
->
slideY2
()
<<
") matching ("
<<
move
->
x1
()
<<
","
<<
move
->
y1
()
<<
")=>("
<<
move
->
x2
()
<<
","
<<
move
->
y2
()
<<
")"
;
qCDebug
(
KSHISEN_
General
)
<<
"[undo] gravity from slide s1("
<<
move
->
slideX1
()
<<
","
<<
move
->
slideY1
()
<<
")=>s2("
<<
move
->
slideX2
()
<<
","
<<
move
->
slideY2
()
<<
") matching ("
<<
move
->
x1
()
<<
","
<<
move
->
y1
()
<<
")=>("
<<
move
->
x2
()
<<
","
<<
move
->
y2
()
<<
")"
;
#endif
// horizontal slide
// because tiles that slides horizontaly may fall down
...
...
@@ -1482,7 +1482,7 @@ void Board::undo()
// we need to take them back up then undo the slide
if
(
move
->
slideY1
()
==
move
->
slideY2
())
{
#ifdef DEBUGGING
qCDebug
(
KSHISEN_
LOG
)
<<
"[undo] gravity from horizontal slide"
;
qCDebug
(
KSHISEN_
General
)
<<
"[undo] gravity from horizontal slide"
;
#endif
// last slide tile went from slide_x1 -> slide_x2
// the number of slided tiles is n = abs(x1 - slide_x1)
...
...
@@ -1496,14 +1496,14 @@ void Board::undo()
dx
=
-
dx
;
}
#ifdef DEBUGGING
qCDebug
(
KSHISEN_
LOG
)
<<
"[undo] n ="
<<
n
;
qCDebug
(
KSHISEN_
General
)
<<
"[undo] n ="
<<
n
;
#endif
// slided tiles may fall down after the slide
// so any tiles on top of the columns between
// slide_x2 -> slide_x2 +/- n (excluded) should go up to slide_y1
if
(
move
->
slideX2
()
>
move
->
slideX1
())
{
// slide to the right
#ifdef DEBUGGING
qCDebug
(
KSHISEN_
LOG
)
<<
"[undo] slide right"
;
qCDebug
(
KSHISEN_
General
)
<<
"[undo] slide right"
;
#endif
for
(
int
i
=
move
->
slideX2
();
i
>
move
->
slideX2
()
-
n
;
--
i
)
{
// find top tile
...
...
@@ -1519,7 +1519,7 @@ void Board::undo()
continue
;
}
#ifdef DEBUGGING
qCDebug
(
KSHISEN_
LOG
)
<<
"[undo] moving ("
<<
i
<<
","
<<
j
<<
") up to ("
<<
i
<<
","
<<
move
->
slideY1
()
<<
")"
;
qCDebug
(
KSHISEN_
General
)
<<
"[undo] moving ("
<<
i
<<
","
<<
j
<<
") up to ("
<<
i
<<
","
<<
move
->
slideY1
()
<<
")"
;
#endif
// put it back up
setField
(
TilePos
(
i
,
move
->
slideY1
()),
field
(
TilePos
(
i
,
j
)));
...
...
@@ -1529,7 +1529,7 @@ void Board::undo()
}
}
else
{
// slide to the left
#ifdef DEBUGGING
qCDebug
(
KSHISEN_
LOG
)
<<
"[undo] slide left"
;
qCDebug
(
KSHISEN_
General
)
<<
"[undo] slide left"
;
#endif
for
(
int
i
=
move
->
slideX2
();
i
<
move
->
slideX2
()
+
n
;
++
i
)
{
// find top tile
...
...
@@ -1545,7 +1545,7 @@ void Board::undo()
continue
;
}
#ifdef DEBUGGING
qCDebug
(
KSHISEN_
LOG
)
<<
"[undo] moving ("
<<
i
<<
","
<<
j
<<
") up to ("
<<
i
<<
","
<<
move
->
slideY1
()
<<
")"
;
qCDebug
(
KSHISEN_
General
)
<<
"[undo] moving ("
<<
i
<<
","
<<
j
<<
") up to ("
<<
i
<<
","
<<
move
->
slideY1
()
<<
")"
;
#endif
// put it back up
setField
(
TilePos
(
i
,
move
->
slideY1
()),
field
(
TilePos
(
i
,
j
)));
...
...
@@ -1555,12 +1555,12 @@ void Board::undo()
}
}
#ifdef DEBUGGING
qCDebug
(
KSHISEN_
LOG
)
<<
"[undo] moving up column x2"
<<
move
->
x2
();
qCDebug
(
KSHISEN_
General
)
<<
"[undo] moving up column x2"
<<
move
->
x2
();
#endif
// move tiles from the second column up
for
(
int
y
=
0
;
y
<=
move
->
y2
();
++
y
)
{
#ifdef DEBUGGING
qCDebug
(
KSHISEN_
LOG
)
<<
"[undo] moving up tile"
<<
y
+
1
;
qCDebug
(
KSHISEN_
General
)
<<
"[undo] moving up tile"
<<
y
+
1
;
#endif
setField
(
TilePos
(
move
->
x2
(),
y
),
field
(
TilePos
(
move
->
x2
(),
y
+
1
)));
updateField
(
TilePos
(
move
->
x2
(),
y
));
...
...
@@ -1574,17 +1574,17 @@ void Board::undo()
if
(
move
->
slideY1
()
>
0
)
{
for
(
int
i
=
move
->
x1
()
+
dx
;
i
>=
move
->
x1
();
--
i
)
{
#ifdef DEBUGGING
qCDebug
(
KSHISEN_
LOG
)
<<
"[undo] moving up column"
<<
i
<<
"until"
<<
move
->
slideY1
();
qCDebug
(
KSHISEN_
General
)
<<
"[undo] moving up column"
<<
i
<<
"until"
<<
move
->
slideY1
();
#endif
for
(
int
j
=
0
;
j
<
move
->
slideY1
();
++
j
)
{
#ifdef DEBUGGING
qCDebug
(
KSHISEN_
LOG
)
<<
"[undo] moving up tile"
<<
j
+
1
;
qCDebug
(
KSHISEN_
General
)
<<
"[undo] moving up tile"
<<
j
+
1
;
#endif
setField
(
TilePos
(
i
,
j
),
field
(
TilePos
(
i
,
j
+
1
)));
updateField
(
TilePos
(
i
,
j
));
}
#ifdef DEBUGGING
qCDebug
(
KSHISEN_
LOG
)
<<
"[undo] clearing last tile"
<<
move
->
slideY1
();
qCDebug
(
KSHISEN_
General
)
<<
"[undo] clearing last tile"
<<
move
->
slideY1
();
#endif
setField
(
TilePos
(
i
,
move
->
slideY1
()),
EMPTY
);
updateField
(
TilePos
(
i
,
move
->
slideY1
()));
...
...
@@ -1594,17 +1594,17 @@ void Board::undo()
if
(
move
->
slideY1
()
>
0
)
{
for
(
int
i
=
move
->
x1
()
-
dx
;
i
<=
move
->
x1
();
++
i
)
{
#ifdef DEBUGGING
qCDebug
(
KSHISEN_
LOG
)
<<
"[undo] moving up column"
<<
i
<<
"until"
<<
move
->
slideY1
();
qCDebug
(
KSHISEN_
General
)
<<
"[undo] moving up column"
<<
i
<<
"until"
<<
move
->
slideY1
();
#endif
for
(
int
j
=
0
;
j
<
move
->
slideY1
();
++
j
)
{
#ifdef DEBUGGING
qCDebug
(
KSHISEN_
LOG
)
<<
"[undo] moving up tile"
<<
j
+
1
;
qCDebug
(
KSHISEN_
General
)
<<
"[undo] moving up tile"
<<
j
+
1
;
#endif
setField
(
TilePos
(
i
,
j
),
field
(
TilePos
(
i
,
j
+
1
)));
updateField
(
TilePos
(
i
,
j
));
}
#ifdef DEBUGGING
qCDebug
(
KSHISEN_
LOG
)
<<
"[undo] clearing last tile"
<<
move
->
slideY1
();
qCDebug
(
KSHISEN_
General
)
<<
"[undo] clearing last tile"
<<
move
->
slideY1
();
#endif
setField
(
TilePos
(
i
,
move
->
slideY1
()),
EMPTY
);
updateField
(
TilePos
(
i
,
move
->
slideY1
()));
...
...
@@ -1613,14 +1613,14 @@ void Board::undo()
}
#ifdef DEBUGGING
qCDebug
(
KSHISEN_
LOG
)
<<
"[undo] reversing slide"
;
qCDebug
(
KSHISEN_
General
)
<<
"[undo] reversing slide"
;
#endif
// then undo the slide to put the tiles back to their original location
reverseSlide
(
TilePos
(
move
->
x1
(),
move
->
y1
()),
move
->
slideX1
(),
move
->
slideY1
(),
move
->
slideX2
(),
move
->
slideY2
());
}
else
{
#ifdef DEBUGGING
qCDebug
(
KSHISEN_
LOG
)
<<
"[undo] gravity from vertical slide"
;
qCDebug
(
KSHISEN_
General
)
<<
"[undo] gravity from vertical slide"
;
#endif
// vertical slide, in fact nothing special is necessary
// the default implementation works because it only affects
...
...
@@ -1712,7 +1712,7 @@ void Board::dumpBoard() const
void
Board
::
dumpBoard
(
const
std
::
vector
<
int
>
&
board
)
const
{
qCDebug
(
KSHISEN_
LOG
)
<<
"Board contents:"
;
qCDebug
(
KSHISEN_
General
)
<<
"Board contents:"
;
for
(
int
y
=
0
;
y
<
yTiles
();
++
y
)
{
QString
row
;
for
(
int
x
=
0
;
x
<
xTiles
();
++
x
)
{
...
...
@@ -1723,7 +1723,7 @@ void Board::dumpBoard(const std::vector<int> & board) const
row
+=
QString
(
QLatin1String
(
"%1"
)).
arg
(
tile
,
3
);
}
}
qCDebug
(
KSHISEN_
LOG
)
<<
row
;
qCDebug
(
KSHISEN_
General
)
<<
row
;
}
}
#endif
...
...
src/debug.h
View file @
faf285e7
...
...
@@ -24,7 +24,7 @@
namespace
KShisen
{
Q_DECLARE_LOGGING_CATEGORY
(
KSHISEN_
LOG
)
Q_DECLARE_LOGGING_CATEGORY
(
KSHISEN_
General
)
// Use for debugging game mode.
//#define DEBUGGING
...
...
src/main.cpp
View file @
faf285e7
...
...
@@ -34,7 +34,7 @@
#include "debug.h"
namespace
KShisen
{
Q_LOGGING_CATEGORY
(
KSHISEN_
LOG
,
"log_kshisen
"
)
Q_LOGGING_CATEGORY
(
KSHISEN_
General
,
"kshisen_general
"
)
}
static
const
char
description
[]
=
I18N_NOOP
(
"A KDE game similar to Mahjongg"
);
...
...
src/possiblemove.cpp
View file @
faf285e7
...
...
@@ -43,7 +43,7 @@ bool PossibleMove::isInPath(TilePos const & tilePos) const
if
(
tilePos
.
x
()
==
m_path
.
back
().
x
()
&&
tilePos
.
y
()
==
m_path
.
back
().
y
())
{
return
false
;
}
qCDebug
(
KSHISEN_
LOG
)
<<
"isInPath:"
<<
tilePos
.
x
()
<<
","
<<
tilePos
.
y
();
qCDebug
(
KSHISEN_
General
)
<<
"isInPath:"
<<
tilePos
.
x
()
<<
","
<<
tilePos
.
y
();
Debug
();
// a path has at least 2 positions
...
...
@@ -57,7 +57,7 @@ bool PossibleMove::isInPath(TilePos const & tilePos) const
||
(
tilePos
.
y
()
<
pathY
&&
tilePos
.
y
()
>=
iter
->
y
())))
||
(
tilePos
.
y
()
==
iter
->
y
()
&&
((
tilePos
.
x
()
>
pathX
&&
tilePos
.
x
()
<=
iter
->
x
())
||
(
tilePos
.
x
()
<
pathX
&&
tilePos
.
x
()
>=
iter
->
x
()))))
{
qCDebug
(
KSHISEN_
LOG
)
<<
"isInPath:"
<<
tilePos
.
x
()
<<
","
<<
tilePos
.
y
()
<<
"found in path"
<<
pathX
<<
","
<<
pathY
<<
" => "
<<
iter
->
x
()
<<
","
<<
iter
->
y
();
qCDebug
(
KSHISEN_
General
)
<<
"isInPath:"
<<
tilePos
.
x
()
<<
","
<<
tilePos
.
y
()
<<
"found in path"
<<
pathX
<<
","
<<
pathY
<<
" => "
<<
iter
->
x
()
<<
","
<<
iter
->
y
();
return
true
;
}
pathX
=
iter
->
x
();
...
...
@@ -68,16 +68,16 @@ bool PossibleMove::isInPath(TilePos const & tilePos) const
void
PossibleMove
::
Debug
()
const
{
qCDebug
(
KSHISEN_
LOG
)
<<
"PossibleMove"
;
qCDebug
(
KSHISEN_
General
)
<<
"PossibleMove"
;
foreach
(
auto
iter
,
m_path
)
{
qCDebug
(
KSHISEN_
LOG
)
<<
" Path:"
<<
iter
.
x
()
<<
","
<<
iter
.
y
();
qCDebug
(
KSHISEN_
General
)
<<
" Path:"
<<
iter
.
x
()
<<
","
<<
iter
.
y
();
}
if
(
m_hasSlide
)
{
qCDebug
(
KSHISEN_
LOG
)
<<
" hasSlide"
;
qCDebug
(
KSHISEN_
General
)
<<
" hasSlide"
;
foreach
(
auto
iter
,
m_slide
)
{
qCDebug
(
KSHISEN_
LOG
)
<<
" Slide:"
<<
iter
.
x
()
<<
","
<<
iter
.
y
();
qCDebug
(
KSHISEN_
General
)
<<
" Slide:"
<<
iter
.
x
()
<<
","
<<
iter
.
y
();
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment