aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2019-05-27 02:26:04 +0300
committerFilippos Karapetis2019-05-27 14:53:37 +0300
commite412bf5ee44c7c1fb2be634e9db6aaa2322818e3 (patch)
tree2907b98807d0d906dfef5aac4fca3f7a78982fda
parent9bf2b5d03e8a15d86ccb6b7dd156b91ae99c2311 (diff)
downloadscummvm-rg350-e412bf5ee44c7c1fb2be634e9db6aaa2322818e3.tar.gz
scummvm-rg350-e412bf5ee44c7c1fb2be634e9db6aaa2322818e3.tar.bz2
scummvm-rg350-e412bf5ee44c7c1fb2be634e9db6aaa2322818e3.zip
ADL: Fix MSVC warnings
- Change APPLECHAR to APPLEBYTE, when its output is used as a byte - Replace uses of strncpy with Common::strlcpy - Merge redundant switch and if statements - Remove redundant semicolons
-rw-r--r--engines/adl/adl.cpp42
-rw-r--r--engines/adl/display.cpp11
-rw-r--r--engines/adl/display.h1
-rw-r--r--engines/adl/hires1.cpp2
-rw-r--r--engines/adl/hires6.cpp2
5 files changed, 28 insertions, 30 deletions
diff --git a/engines/adl/adl.cpp b/engines/adl/adl.cpp
index 17fdd28892..d866af6a31 100644
--- a/engines/adl/adl.cpp
+++ b/engines/adl/adl.cpp
@@ -119,7 +119,7 @@ Common::String AdlEngine::readString(Common::ReadStream &stream, byte until) con
break;
str += b;
- };
+ }
return str;
}
@@ -209,21 +209,13 @@ Common::String AdlEngine::inputString(byte prompt) const {
return s;
}
- if (b < 0xa0) {
- switch (b) {
- case Common::KEYCODE_BACKSPACE | 0x80:
- if (!s.empty()) {
- _display->moveCursorBackward();
- _display->setCharAtCursor(APPLECHAR(' '));
- s.deleteLastChar();
- }
- break;
- };
- } else {
- if (s.size() < 255) {
- s += b;
- _display->printString(Common::String(b));
- }
+ if (b < 0xa0 && b == (Common::KEYCODE_BACKSPACE | 0x80) && !s.empty()) {
+ _display->moveCursorBackward();
+ _display->setCharAtCursor(APPLEBYTE(' '));
+ s.deleteLastChar();
+ } else if (s.size() < 255) {
+ s += b;
+ _display->printString(Common::String(b));
}
}
}
@@ -233,7 +225,7 @@ byte AdlEngine::inputKey(bool showCursor) const {
// If debug script is active, we fake a return press for the text overflow handling
if (_inputScript && !_scriptPaused)
- return APPLECHAR('\r');
+ return APPLEBYTE('\r');
if (showCursor)
_display->showCursor(true);
@@ -252,12 +244,12 @@ byte AdlEngine::inputKey(bool showCursor) const {
default:
if (event.kbd.ascii >= 0x20 && event.kbd.ascii < 0x80)
key = convertKey(event.kbd.ascii);
- };
+ }
}
// If debug script was activated in the meantime, abort input
if (_inputScript && !_scriptPaused)
- return APPLECHAR('\r');
+ return APPLEBYTE('\r');
_display->updateTextScreen();
g_system->delayMillis(16);
@@ -917,11 +909,11 @@ Common::Error AdlEngine::saveGameState(int slot, const Common::String &desc) {
char name[SAVEGAME_NAME_LEN] = { };
if (!desc.empty())
- strncpy(name, desc.c_str(), sizeof(name) - 1);
+ Common::strlcpy(name, desc.c_str(), sizeof(name) - 1);
else {
Common::String defaultName("Save ");
defaultName += 'A' + slot;
- strncpy(name, defaultName.c_str(), sizeof(name) - 1);
+ Common::strlcpy(name, defaultName.c_str(), sizeof(name) - 1);
}
outFile->write(name, sizeof(name));
@@ -992,7 +984,7 @@ byte AdlEngine::convertKey(uint16 ascii) const {
Common::String AdlEngine::getLine() {
while (1) {
- Common::String line = inputString(APPLECHAR('?'));
+ Common::String line = inputString(APPLEBYTE('?'));
if (shouldQuit() || _isRestoring)
return Common::String();
@@ -1028,8 +1020,10 @@ Common::String AdlEngine::getWord(const Common::String &line, uint &index) const
// Copy up to 8 characters
while (1) {
- if (copied < 8)
- str.setChar(line[index], copied++);
+ if (copied < 8) {
+ str.setChar(line[index], copied);
+ copied++;
+ }
index++;
diff --git a/engines/adl/display.cpp b/engines/adl/display.cpp
index 52fb1b44d7..a1a1f6fea7 100644
--- a/engines/adl/display.cpp
+++ b/engines/adl/display.cpp
@@ -383,6 +383,9 @@ static byte processColorBits(uint16 &bits, bool &odd, bool secondPal) {
break;
case 0x5: // 101 (color)
color = 2 + !odd;
+ break;
+ default:
+ break;
}
if (secondPal)
@@ -477,9 +480,9 @@ static void renderPixelRowMono(byte *dst, byte *src) {
static void copyEvenSurfaceRows(Graphics::Surface &surf) {
byte *src = (byte *)surf.getPixels();
- for (uint y = 0; y < surf.h / 2; ++y) {
+ for (uint16 y = 0; y < surf.h / 2; ++y) {
byte *dst = src + surf.pitch;
- for (uint x = 0; x < surf.w; ++x)
+ for (uint16 x = 0; x < surf.w; ++x)
dst[x] = ALTCOL(src[x]);
src += surf.pitch * 2;
}
@@ -553,8 +556,8 @@ void Display::createFont() {
byte *buf = (byte *)_font->getPixels();
byte *bufInv = buf + (_font->h / 2) * _font->pitch;
- for (uint row = 0; row < _font->h / 2; row += 2) {
- for (uint col = 0; col < _font->w; ++col)
+ for (uint16 row = 0; row < _font->h / 2; row += 2) {
+ for (uint16 col = 0; col < _font->w; ++col)
bufInv[col] = (buf[col] ? 0 : 1);
buf += _font->pitch * 2;
diff --git a/engines/adl/display.h b/engines/adl/display.h
index c1c0f410fe..08e6f4c2f3 100644
--- a/engines/adl/display.h
+++ b/engines/adl/display.h
@@ -52,6 +52,7 @@ enum DisplayMode {
};
#define APPLECHAR(C) ((char)((C) | 0x80))
+#define APPLEBYTE(C) ((byte)((C) | 0x80))
class Display {
public:
diff --git a/engines/adl/hires1.cpp b/engines/adl/hires1.cpp
index 2cf2931896..39aec9367f 100644
--- a/engines/adl/hires1.cpp
+++ b/engines/adl/hires1.cpp
@@ -398,7 +398,7 @@ void HiRes1Engine::printString(const Common::String &str) {
Common::String HiRes1Engine::loadMessage(uint idx) const {
StreamPtr stream(_messages[idx]->createReadStream());
- return readString(*stream, APPLECHAR('\r')) + APPLECHAR('\r');
+ return readString(*stream, APPLEBYTE('\r')) + APPLEBYTE('\r');
}
void HiRes1Engine::printMessage(uint idx) {
diff --git a/engines/adl/hires6.cpp b/engines/adl/hires6.cpp
index 5cbca1caa2..3093b146d7 100644
--- a/engines/adl/hires6.cpp
+++ b/engines/adl/hires6.cpp
@@ -214,7 +214,7 @@ void HiRes6Engine::runIntro() {
error("Failed to open disk volume 0");
stream.reset(files->createReadStream("\010\010\010\010\010\010"));
- Common::String copyright(readStringAt(*stream, 0x103, APPLECHAR('\r')));
+ Common::String copyright(readStringAt(*stream, 0x103, APPLEBYTE('\r')));
delete files;