mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-28 07:58:08 +01:00
sanity check: make sure tiles are within range.
This commit is contained in:
parent
9f22b11f81
commit
6d98631640
1 changed files with 7 additions and 5 deletions
|
@ -705,13 +705,15 @@ checkSanity( DictionaryCtxt* dict, const XP_U32 numEdges )
|
||||||
{
|
{
|
||||||
XP_U32 ii;
|
XP_U32 ii;
|
||||||
XP_Bool passed = XP_TRUE;
|
XP_Bool passed = XP_TRUE;
|
||||||
|
XP_U16 nFaces = dict_numTileFaces( dict );
|
||||||
|
|
||||||
array_edge* edge = dict->base;
|
array_edge* edge = dict->base;
|
||||||
Tile prevTile = 0;
|
Tile prevTile = 0;
|
||||||
for ( ii = 0; ii < numEdges && passed; ++ii ) {
|
for ( ii = 0; ii < numEdges && passed; ++ii ) {
|
||||||
Tile tile = EDGETILE( dict, edge );
|
Tile tile = EDGETILE( dict, edge );
|
||||||
if ( tile < prevTile ) {
|
if ( tile < prevTile || tile >= nFaces ) {
|
||||||
XP_LOGF( "%s: node %ld of %ld has out-of-order tile", __func__,
|
XP_LOGF( "%s: node %ld (out of %ld) has too-large or "
|
||||||
ii, numEdges );
|
"out-of-order tile", __func__, ii, numEdges );
|
||||||
passed = XP_FALSE;
|
passed = XP_FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -719,8 +721,8 @@ checkSanity( DictionaryCtxt* dict, const XP_U32 numEdges )
|
||||||
|
|
||||||
unsigned long index = dict_index_from( dict, edge );
|
unsigned long index = dict_index_from( dict, edge );
|
||||||
if ( index >= numEdges ) {
|
if ( index >= numEdges ) {
|
||||||
XP_LOGF( "%s: node %ld of %ld has too-high index", __func__,
|
XP_LOGF( "%s: node %ld (out of %ld) has too-high index %ld", __func__,
|
||||||
ii, numEdges );
|
ii, numEdges, index );
|
||||||
passed = XP_FALSE;
|
passed = XP_FALSE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue