diff options
author | Slávek Banko <[email protected]> | 2020-09-01 12:36:09 +0200 |
---|---|---|
committer | Slávek Banko <[email protected]> | 2020-09-01 12:36:09 +0200 |
commit | 40420b140dae57640a553643766112af9902b7b0 (patch) | |
tree | 77b8670df921d1c9c2bc22a5f713bb5fac2cf28f | |
parent | 7e43acd8185cad93e5aeb91b199a89bd8b3eb069 (diff) | |
download | tdepacman-40420b140dae57640a553643766112af9902b7b0.tar.gz tdepacman-40420b140dae57640a553643766112af9902b7b0.zip |
Added controlled conversions to char* instead of automatic
ascii conversions. Removed unnecessary conversions to char*.
The definition of -UTQT_NO_ASCII_CAST is no longer needed.
Signed-off-by: Slávek Banko <[email protected]>
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | kpacman/bitfont.cpp | 2 | ||||
-rw-r--r-- | kpacman/board.cpp | 6 | ||||
-rw-r--r-- | kpacman/keys.cpp | 16 | ||||
-rw-r--r-- | kpacman/kpacmanview.cpp | 2 | ||||
-rw-r--r-- | kpacman/painter.cpp | 24 | ||||
-rw-r--r-- | kpacman/referee.cpp | 18 | ||||
-rw-r--r-- | kpacman/score.cpp | 10 | ||||
-rw-r--r-- | kpacman/status.cpp | 11 |
9 files changed, 45 insertions, 46 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 833e868..afd371c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,7 +59,7 @@ include( ConfigureChecks.cmake ) ###### global compiler settings -add_definitions( -DHAVE_CONFIG_H -UTQT_NO_ASCII_CAST ) +add_definitions( -DHAVE_CONFIG_H ) set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TQT_CXX_FLAGS}" ) set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined" ) diff --git a/kpacman/bitfont.cpp b/kpacman/bitfont.cpp index 1f4d3d9..28a265e 100644 --- a/kpacman/bitfont.cpp +++ b/kpacman/bitfont.cpp @@ -26,7 +26,7 @@ TQPixmap Bitfont::text(TQString str, TQColor fg, TQColor bg) TQPixmap FG(str.length()*fontWidth, fontHeight); TQBitmap MASK(str.length()*fontWidth, fontHeight, TRUE); - const uchar *s = (const uchar *) str.local8Bit().data(); + const uchar *s = str.latin1(); for (uint i = 0; i < str.length(); i++) { if (font.width() == font.height()) bitBlt(&MASK, i*fontWidth, 0, &font, diff --git a/kpacman/board.cpp b/kpacman/board.cpp index 95ad5f2..8a07310 100644 --- a/kpacman/board.cpp +++ b/kpacman/board.cpp @@ -58,7 +58,7 @@ void Board::init(Image image, TQString levelName) "or could not be opened for reading."); msg.replace(TQRegExp("@LEVELNAME@"), levelName); // TQMessageBox::information(0, i18n("Initialization Error"), msg); - printf("%s\n", msg.local8Bit()); + printf("%s\n", msg.local8Bit().data()); } else { map.fill(' ', BoardHeight*BoardWidth); int height = 0; @@ -75,7 +75,7 @@ void Board::init(Image image, TQString levelName) map.replace(height*BoardWidth, (line.length() > BoardWidth) ? BoardWidth : line.length(), - line.local8Bit()); + line.latin1()); height++; } @@ -93,7 +93,7 @@ void Board::init(Image image, TQString levelName) break; case Level : setup(demo_bits); break; - case File : setup((uchar *) map.local8Bit().data()); + case File : setup(map.latin1()); break; default : break; } diff --git a/kpacman/keys.cpp b/kpacman/keys.cpp index d26c263..df8f980 100644 --- a/kpacman/keys.cpp +++ b/kpacman/keys.cpp @@ -162,28 +162,28 @@ void PKeys::defaults() void PKeys::init() { TQString up("Up"); - up = kapp->config()->readEntry("upKey", (const char*) up); + up = kapp->config()->readEntry("upKey", up); labels[0]->setText(up); TQString down("Down"); - down = kapp->config()->readEntry("downKey", (const char*) down); + down = kapp->config()->readEntry("downKey", down); labels[1]->setText(down); TQString left("Left"); - left = kapp->config()->readEntry("leftKey", (const char*) left); + left = kapp->config()->readEntry("leftKey", left); labels[2]->setText(left); TQString right("Right"); - right = kapp->config()->readEntry("rightKey", (const char*) right); + right = kapp->config()->readEntry("rightKey", right); labels[3]->setText(right); } void PKeys::ok() { - kapp->config()->writeEntry("upKey", (const char*) labels[0]->text() ); - kapp->config()->writeEntry("downKey", (const char*) labels[1]->text() ); - kapp->config()->writeEntry("leftKey", (const char*) labels[2]->text() ); - kapp->config()->writeEntry("rightKey",(const char*) labels[3]->text() ); + kapp->config()->writeEntry("upKey", labels[0]->text() ); + kapp->config()->writeEntry("downKey", labels[1]->text() ); + kapp->config()->writeEntry("leftKey", labels[2]->text() ); + kapp->config()->writeEntry("rightKey", labels[3]->text() ); kapp->config()->sync(); accept(); diff --git a/kpacman/kpacmanview.cpp b/kpacman/kpacmanview.cpp index eeb396f..40d23e1 100644 --- a/kpacman/kpacmanview.cpp +++ b/kpacman/kpacmanview.cpp @@ -120,7 +120,7 @@ void KpacmanView::confScheme() "or is of an unknown format."); msg.replace(TQRegExp("@FONTNAME@"), fontName); // TQMessageBox::critical(this, i18n("Initialization Error"), msg); - printf("%s\n", msg.local8Bit()); + printf("%s\n", msg.local8Bit().data()); } } diff --git a/kpacman/painter.cpp b/kpacman/painter.cpp index 16c0083..4c897c8 100644 --- a/kpacman/painter.cpp +++ b/kpacman/painter.cpp @@ -70,7 +70,7 @@ TQPtrList<TQPixmap> *Painter::loadPixmap(TQWidget *parent, TQString pixmapName, "or is of an unknown format."); msg.replace(TQRegExp("@PIXMAPNAME@"), pixmapName); // TQMessageBox::critical(parent, i18n("Initialization Error"), msg); - printf("%s\n", msg.local8Bit()); + printf("%s\n", msg.local8Bit().data()); return 0; } @@ -389,8 +389,8 @@ void Painter::initPixmaps() } if (lastFruitScorePixmapName != fruitScorePixmapName.at(level) || - (const char *) *fruitScorePixmapName.at(level) == '\0') { - if ((const char *) *fruitScorePixmapName.at(level) == '\0') { + *fruitScorePixmapName.at(level) == '\0') { + if (*fruitScorePixmapName.at(level) == '\0') { fruitScorePix = textPixmap(fruitScoreString, fruitScorePix, PINK); } else { fruitScorePix = loadPixmap(w, fruitScorePixmapName.at(level), @@ -400,8 +400,8 @@ void Painter::initPixmaps() } if (lastMonsterScorePixmapName != monsterScorePixmapName.at(level) || - (const char *) *monsterScorePixmapName.at(level) == '\0') { - if ((const char *) *monsterScorePixmapName.at(level) == '\0') { + *monsterScorePixmapName.at(level) == '\0') { + if (*monsterScorePixmapName.at(level) == '\0') { monsterScorePix = textPixmap(monsterScoreString, monsterScorePix, CYAN); } else { monsterScorePix = loadPixmap(w, monsterScorePixmapName.at(level), @@ -654,7 +654,7 @@ TQString Painter::decodeHexOctString(TQString s) c = '\0'; len = 0; value = s.mid(pos+leadin, 3); - ptr = (const char *) value; + ptr = value.latin1(); while (*ptr != '\0' && (v = valids.find(*ptr++, 0, FALSE)) != -1) { c = (c * valids.length()) + v; @@ -692,7 +692,7 @@ void Painter::fillScoreString(TQStrList &list, TQMemArray<int> &values) s.insert(0, char (values[i] / 1000 + 0x10)); } - list.append(s.local8Bit()); + list.append(s.latin1()); } } @@ -739,7 +739,7 @@ void Painter::fillStrList(TQStrList &list, TQString values, int max) } if (!value.isEmpty()) last = decodeHexOctString(value); - list.append(last); + list.append(last.latin1()); } } @@ -763,8 +763,8 @@ void Painter::fillPixmapName(TQStrList &pixmapName) fileInfo.setFile(pixmap); if (!fileInfo.isReadable() || !fileInfo.isFile()) pixmap = ""; - - pixmapName.append(pixmap); + + pixmapName.append(pixmap.utf8()); } } @@ -897,9 +897,9 @@ void Painter::confScheme() confScoring(FALSE); } - if ((const char *) *fruitScoreString.at(0) == '\0') + if (*fruitScoreString.at(0) == '\0') fillScoreString(fruitScoreString, fruitScore); - if ((const char *) *monsterScoreString.at(0) == '\0') + if (*monsterScoreString.at(0) == '\0') fillScoreString(monsterScoreString, monsterScore); fillPixmapName(pointPixmapName); diff --git a/kpacman/referee.cpp b/kpacman/referee.cpp index dc1a53e..af5c566 100644 --- a/kpacman/referee.cpp +++ b/kpacman/referee.cpp @@ -408,19 +408,19 @@ void Referee::repaintFigures() void Referee::initKeys() { TQString up("Up"); - up = kapp->config()->readEntry("upKey", (const char*) up); + up = kapp->config()->readEntry("upKey", up); UpKey = TDEAccel::stringToKey(up); TQString down("Down"); - down = kapp->config()->readEntry("downKey", (const char*) down); + down = kapp->config()->readEntry("downKey", down); DownKey = TDEAccel::stringToKey(down); TQString left("Left"); - left = kapp->config()->readEntry("leftKey", (const char*) left); + left = kapp->config()->readEntry("leftKey", left); LeftKey = TDEAccel::stringToKey(left); TQString right("Right"); - right = kapp->config()->readEntry("rightKey", (const char*) right); + right = kapp->config()->readEntry("rightKey", right); RightKey = TDEAccel::stringToKey(right); } @@ -471,7 +471,7 @@ void Referee::fillStrList(TQStrList &list, TQString values, int max) if (!value.isEmpty()) last = value; - list.append(last); + list.append(last.latin1()); } } @@ -495,8 +495,8 @@ void Referee::fillMapName() fileInfo.setFile(map); if (!fileInfo.isReadable()) map = ""; - - mapName.append(map); + + mapName.append(map.utf8()); } } @@ -901,10 +901,10 @@ void Referee::introPaint(int t) case 12 : repaint(pix->draw(38, 28, RoomPix, i18n("\"CLYDE\""), ORANGE, TQColor(), AlignLeft), FALSE); break; case 13 : pts.sprintf("%d", pointScore); - repaint(pix->draw(28, 44, RoomPix, pts.local8Bit(), WHITE, TQColor(), AlignRight), FALSE); + repaint(pix->draw(28, 44, RoomPix, pts, WHITE, TQColor(), AlignRight), FALSE); repaint(pix->draw(31, 44, RoomPix, "\x1C\x1D\x1E", WHITE, TQColor(), AlignLeft), FALSE); pts.sprintf("%d", energizerScore); - repaint(pix->draw(28, 48, RoomPix, pts.local8Bit(), WHITE, TQColor(), AlignRight), FALSE); + repaint(pix->draw(28, 48, RoomPix, pts, WHITE, TQColor(), AlignRight), FALSE); repaint(pix->draw(31, 48, RoomPix, "\x1C\x1D\x1E", WHITE, TQColor(), AlignLeft), FALSE); break; case 14 : // "@ 1980 MIDWAY MFG.CO." diff --git a/kpacman/score.cpp b/kpacman/score.cpp index 68a5682..fa52583 100644 --- a/kpacman/score.cpp +++ b/kpacman/score.cpp @@ -128,7 +128,7 @@ void Score::paintEvent( TQPaintEvent *e) for (int i = 0; i < 10; i++) { s.sprintf("%2d%9d %-3.3s %-8.8s", i+1, hallOfFame[i].points, hallOfFame[i].name.utf8().data(), - formatDate(hallOfFame[i].moment.date()).utf8()); + formatDate(hallOfFame[i].moment.date()).utf8().data()); if (rect(1, (11+i)*1.25, s).intersects(e->rect())) { TQPixmap pix = bitfont->text(s, (i == lastScore) ? YELLOW : WHITE, BLACK); bitBlt(this, x(1), y((11+i)*1.25), &pix); @@ -250,19 +250,19 @@ void Score::keyPressEvent(TQKeyEvent *k) void Score::initKeys() { TQString up("Up"); - up = kapp->config()->readEntry("upKey", (const char*) up); + up = kapp->config()->readEntry("upKey", up); UpKey = TDEAccel::stringToKey(up); TQString down("Down"); - down = kapp->config()->readEntry("downKey", (const char*) down); + down = kapp->config()->readEntry("downKey", down); DownKey = TDEAccel::stringToKey(down); TQString left("Left"); - left = kapp->config()->readEntry("leftKey", (const char*) left); + left = kapp->config()->readEntry("leftKey", left); LeftKey = TDEAccel::stringToKey(left); TQString right("Right"); - right = kapp->config()->readEntry("rightKey", (const char*) right); + right = kapp->config()->readEntry("rightKey", right); RightKey = TDEAccel::stringToKey(right); } diff --git a/kpacman/status.cpp b/kpacman/status.cpp index b89e49d..12f01b7 100644 --- a/kpacman/status.cpp +++ b/kpacman/status.cpp @@ -42,8 +42,7 @@ TQPtrList<TQPixmap> *Status::loadPixmap(TQWidget *parent, TQString pixmapName, "The file '@PIXMAPNAME@' does not exist,\n" "or is of an unknown format."); msg.replace(TQRegExp("@PIXMAPNAME@"), pixmapName); - TQMessageBox::information(parent, i18n("Initialization Error"), - (const char *) msg); + TQMessageBox::information(parent, i18n("Initialization Error"), msg); return 0; } @@ -122,7 +121,7 @@ TQString Status::decodeHexOctString(TQString s) c = '\0'; len = 0; value = s.mid(pos+leadin, 3); - ptr = (const char *) value; + ptr = value.latin1(); while (*ptr != '\0' && (v = valids.find(*ptr++, 0, FALSE)) != -1) { c = (c * valids.length()) + v; @@ -179,7 +178,7 @@ void Status::fillStrList(TQStrList &list, TQString values, int max) } if (!value.isEmpty()) last = decodeHexOctString(value); - list.append(last); + list.append(last.latin1()); } } @@ -203,8 +202,8 @@ void Status::fillPixmapName(TQStrList &pixmapName) fileInfo.setFile(pixmap); if (!fileInfo.isReadable() || !fileInfo.isFile()) pixmap = ""; - - pixmapName.append(pixmap); + + pixmapName.append(pixmap.utf8()); } } |