]> granicus.if.org Git - nethack/commitdiff
Fix some crashes in unused tile editor.
authorwarwick <warwick>
Tue, 22 Jan 2002 08:44:37 +0000 (08:44 +0000)
committerwarwick <warwick>
Tue, 22 Jan 2002 08:44:37 +0000 (08:44 +0000)
tileedit is the program I use to edit tile files (directly).

win/Qt/tileedit.cpp

index a594d3a7b1f21959dbf5395de5439a9391f5ddcc..16e2002c197113256441d721e18766050d1061d9 100644 (file)
@@ -180,9 +180,10 @@ void TrivialTileEditor::setColor( QRgb rgb )
 {
     pen = rgb;
     for (penpixel = 0;
-           penpixel<img.numColors()-1 && img.color(penpixel)!=pen.rgb();
+           penpixel<img.numColors()-1 && (img.color(penpixel)&0xffffff)!=(pen.rgb()&0xffffff);
            penpixel++)
        continue;
+qDebug("penpixel=%d, pen=%x",penpixel,pen.rgb());
 }
 
 void TrivialTileEditor::setImage( const QImage& i )
@@ -217,6 +218,8 @@ void TrivialTileEditor::paintPoint(QPainter& painter, QPoint p)
 void TrivialTileEditor::mousePressEvent(QMouseEvent* e)
 {
     QPoint p = imagePoint(e->pos());
+    if ( !img.rect().contains(p) )
+       return;
     uchar& pixel = img.scanLine(p.y())[p.x()];
     if ( e->button() == LeftButton ) {
        pixel = penpixel;
@@ -226,7 +229,8 @@ void TrivialTileEditor::mousePressEvent(QMouseEvent* e)
        emit pick( img.color(pixel) );
     } else if ( e->button() == MidButton ) {
        QPainter painter(this);
-       fill(painter,p,pixel);
+       if ( pixel != penpixel )
+           fill(painter,p,pixel);
     }
 }
 
@@ -253,6 +257,8 @@ void TrivialTileEditor::mouseReleaseEvent(QMouseEvent* e)
 void TrivialTileEditor::mouseMoveEvent(QMouseEvent* e)
 {
     QPoint p = imagePoint(e->pos());
+    if ( !img.rect().contains(p) )
+       return;
     uchar& pixel = img.scanLine(p.y())[p.x()];
     pixel = penpixel;
     QPainter painter(this);