[Scummvm-git-logs] scummvm master -> c212217063c3f3c969d3868ab65f15f72b308074
sev-
sev at scummvm.org
Mon Apr 27 16:29:50 UTC 2020
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
16f1ff13bc HDB: Use Common::strlcpy() everywhere
c5868e1611 HDB: Add sanity checks
c212217063 HDB: Remove redundant check
Commit: 16f1ff13bc8a123c691f2ec3c833c0bf696ed100
https://github.com/scummvm/scummvm/commit/16f1ff13bc8a123c691f2ec3c833c0bf696ed100
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-27T18:29:39+02:00
Commit Message:
HDB: Use Common::strlcpy() everywhere
Changed paths:
engines/hdb/ai-cinematic.cpp
engines/hdb/ai-funcs.cpp
engines/hdb/ai-init.cpp
engines/hdb/ai-lists.cpp
engines/hdb/ai-player.cpp
engines/hdb/file-manager.cpp
engines/hdb/gfx.cpp
engines/hdb/hdb.cpp
engines/hdb/lua-script.cpp
engines/hdb/window.cpp
diff --git a/engines/hdb/ai-cinematic.cpp b/engines/hdb/ai-cinematic.cpp
index 0189e2e604..91ad2cf760 100644
--- a/engines/hdb/ai-cinematic.cpp
+++ b/engines/hdb/ai-cinematic.cpp
@@ -101,7 +101,7 @@ void AI::processCines() {
memset(func, 0, 64);
if (_cine[i]->title)
- strcpy(func, _cine[i]->title);
+ Common::strlcpy(func, _cine[i]->title, 64);
cineCleanup();
if (func[0])
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp
index 438f617e97..1feef77134 100644
--- a/engines/hdb/ai-funcs.cpp
+++ b/engines/hdb/ai-funcs.cpp
@@ -61,13 +61,13 @@ AIEntity *AI::spawn(AIType type, AIDir dir, int x, int y, const char *funcInit,
e->animFrame = 0;
if (funcInit)
- strcpy(e->luaFuncInit, funcInit);
+ Common::strlcpy(e->luaFuncInit, funcInit, 32);
if (funcAction)
- strcpy(e->luaFuncAction, funcAction);
+ Common::strlcpy(e->luaFuncAction, funcAction, 32);
if (funcUse)
- strcpy(e->luaFuncUse, funcUse);
+ Common::strlcpy(e->luaFuncUse, funcUse, 32);
if (e->luaFuncInit[0] == '*')
e->luaFuncInit[0] = 0;
@@ -436,10 +436,10 @@ bool AI::cacheEntGfx(AIEntity *e, bool initFlag) {
const char *str1 = g_hdb->_lua->getStringOffStack();
const char *str2 = g_hdb->_lua->getStringOffStack();
if (str1)
- strcpy(e->entityName, str1);
+ Common::strlcpy(e->entityName, str1, 32);
if (str2)
- strcpy(e->printedName, str2);
+ Common::strlcpy(e->printedName, str2, 32);
}
} else if (e->aiInit2)
e->aiInit2(e);
@@ -721,8 +721,8 @@ void AI::initAllEnts() {
(*it)->aiInit((*it));
if ((*it)->luaFuncInit[0]) {
if (g_hdb->_lua->callFunction((*it)->luaFuncInit, 2)) {
- strcpy((*it)->entityName, g_hdb->_lua->getStringOffStack());
- strcpy((*it)->printedName, g_hdb->_lua->getStringOffStack());
+ Common::strlcpy((*it)->entityName, g_hdb->_lua->getStringOffStack(), 32);
+ Common::strlcpy((*it)->printedName, g_hdb->_lua->getStringOffStack(), 32);
} else
warning("'%s' doesn't exists", (*it)->luaFuncInit);
}
diff --git a/engines/hdb/ai-init.cpp b/engines/hdb/ai-init.cpp
index 7e0c3298ef..c77ff4fd11 100644
--- a/engines/hdb/ai-init.cpp
+++ b/engines/hdb/ai-init.cpp
@@ -1211,7 +1211,7 @@ void AI::init() {
_dummyPlayer.type = AI_GUY;
_dummyLaser.type = AI_LASERBEAM;
- strcpy(_dummyPlayer.entityName, "Virtual Player");
+ Common::strlcpy(_dummyPlayer.entityName, "Virtual Player", 32);
_numDeliveries = 0;
_playerRunning = false;
_weaponSelGfx = NULL;
diff --git a/engines/hdb/ai-lists.cpp b/engines/hdb/ai-lists.cpp
index c7637113ee..111c400bb8 100644
--- a/engines/hdb/ai-lists.cpp
+++ b/engines/hdb/ai-lists.cpp
@@ -267,14 +267,14 @@ void AI::addToActionList(int actionIndex, int x, int y, char *luaFuncInit, char
_actions[actionIndex].x1 = x;
_actions[actionIndex].y1 = y;
if (luaFuncInit[0] != '*')
- strcpy(_actions[actionIndex].luaFuncInit, luaFuncInit);
+ Common::strlcpy(_actions[actionIndex].luaFuncInit, luaFuncInit, 32);
if (luaFuncUse[0] != '*')
- strcpy(_actions[actionIndex].luaFuncUse, luaFuncUse);
+ Common::strlcpy(_actions[actionIndex].luaFuncUse, luaFuncUse, 32);
if (_actions[actionIndex].luaFuncInit[0]) {
g_hdb->_lua->callFunction(_actions[actionIndex].luaFuncInit, 2);
- strcpy(_actions[actionIndex].entityName, g_hdb->_lua->getStringOffStack());
- strcpy(_actions[actionIndex].entityName, g_hdb->_lua->getStringOffStack());
+ Common::strlcpy(_actions[actionIndex].entityName, g_hdb->_lua->getStringOffStack(), 32);
+ Common::strlcpy(_actions[actionIndex].entityName, g_hdb->_lua->getStringOffStack(), 32);
}
return;
}
@@ -283,14 +283,14 @@ void AI::addToActionList(int actionIndex, int x, int y, char *luaFuncInit, char
_actions[actionIndex].x2 = x;
_actions[actionIndex].y2 = y;
if (luaFuncInit[0] != '*')
- strcpy(_actions[actionIndex].luaFuncInit, luaFuncInit);
+ Common::strlcpy(_actions[actionIndex].luaFuncInit, luaFuncInit, 32);
if (luaFuncUse[0] != '*')
- strcpy(_actions[actionIndex].luaFuncUse, luaFuncUse);
+ Common::strlcpy(_actions[actionIndex].luaFuncUse, luaFuncUse, 32);
if (_actions[actionIndex].luaFuncInit[0]) {
g_hdb->_lua->callFunction(_actions[actionIndex].luaFuncInit, 2);
- strcpy(_actions[actionIndex].entityName, g_hdb->_lua->getStringOffStack());
- strcpy(_actions[actionIndex].entityName, g_hdb->_lua->getStringOffStack());
+ Common::strlcpy(_actions[actionIndex].entityName, g_hdb->_lua->getStringOffStack(), 32);
+ Common::strlcpy(_actions[actionIndex].entityName, g_hdb->_lua->getStringOffStack(), 32);
}
return;
}
@@ -351,7 +351,7 @@ bool AI::checkActionList(AIEntity *e, int x, int y, bool lookAndGrab) {
void AI::addToHereList(const char *entName, int x, int y) {
HereT *h = new HereT;
- strcpy(h->entName, entName);
+ Common::strlcpy(h->entName, entName, 32);
h->x = x;
h->y = y;
_hereList->push_back(h);
@@ -372,20 +372,20 @@ void AI::addToAutoList(int x, int y, const char *luaFuncInit, const char *luaFun
_autoActions[i].y = y;
_autoActions[i].activated = false;
if (luaFuncInit[0] != '*')
- strcpy(&_autoActions[i].luaFuncInit[0], luaFuncInit);
+ Common::strlcpy(&_autoActions[i].luaFuncInit[0], luaFuncInit, 32);
if (luaFuncUse[0] != '*')
- strcpy(&_autoActions[i].luaFuncUse[0], luaFuncUse);
+ Common::strlcpy(&_autoActions[i].luaFuncUse[0], luaFuncUse, 32);
if (_autoActions[i].luaFuncInit[0]) {
g_hdb->_lua->callFunction(_autoActions[i].luaFuncInit, 2);
const char *get = g_hdb->_lua->getStringOffStack();
if (!get)
return;
- strcpy(&_autoActions[i].entityName[0], get);
+ Common::strlcpy(&_autoActions[i].entityName[0], get, 32);
get = g_hdb->_lua->getStringOffStack();
if (!get)
return;
- strcpy(&_autoActions[i].entityName[0], get);
+ Common::strlcpy(&_autoActions[i].entityName[0], get, 32);
}
return;
}
@@ -565,13 +565,13 @@ void AI::addToLuaList(int x, int y, int value1, int value2, char *luaFuncInit, c
_luaList[i].value1 = value1;
_luaList[i].value2 = value2;
- strcpy(_luaList[i].luaFuncInit, luaFuncInit);
+ Common::strlcpy(_luaList[i].luaFuncInit, luaFuncInit, 32);
if (luaFuncInit[0] == '*')
_luaList[i].luaFuncInit[0] = 0;
- strcpy(_luaList[i].luaFuncAction, luaFuncAction);
+ Common::strlcpy(_luaList[i].luaFuncAction, luaFuncAction, 32);
if (luaFuncAction[0] == '*')
_luaList[i].luaFuncAction[0] = 0;
- strcpy(_luaList[i].luaFuncUse, luaFuncUse);
+ Common::strlcpy(_luaList[i].luaFuncUse, luaFuncUse, 32);
if (luaFuncUse[0] == '*')
_luaList[i].luaFuncUse[0] = 0;
@@ -624,7 +624,7 @@ void AI::addToTeleportList(int teleIndex, int x, int y, int dir, int level, int
_teleporters[teleIndex].level1 = level;
_teleporters[teleIndex].anim1 = anim;
_teleporters[teleIndex].usable1 = usable;
- strcpy(_teleporters[teleIndex].luaFuncUse1, luaFuncUse);
+ Common::strlcpy(_teleporters[teleIndex].luaFuncUse1, luaFuncUse, 32);
if (_teleporters[teleIndex].luaFuncUse1[0] == '*')
_teleporters[teleIndex].luaFuncUse1[0] = 0;
_numTeleporters++;
@@ -637,7 +637,7 @@ void AI::addToTeleportList(int teleIndex, int x, int y, int dir, int level, int
_teleporters[teleIndex].level2 = level;
_teleporters[teleIndex].anim2 = anim;
_teleporters[teleIndex].usable2 = usable;
- strcpy(_teleporters[teleIndex].luaFuncUse2, luaFuncUse);
+ Common::strlcpy(_teleporters[teleIndex].luaFuncUse2, luaFuncUse, 32);
if (_teleporters[teleIndex].luaFuncUse2[0] == '*')
_teleporters[teleIndex].luaFuncUse2[0] = 0;
_numTeleporters++;
@@ -809,15 +809,15 @@ void AI::addToTriggerList(char *luaFuncInit, char *luaFuncUse, int x, int y, int
_triggerList->push_back(t);
- strcpy(t->id, id);
+ Common::strlcpy(t->id, id, 32);
t->x = x;
t->y = y;
t->value1 = value1;
t->value2 = value2;
if (luaFuncInit[0] != '*')
- strcpy(t->luaFuncInit, luaFuncInit);
+ Common::strlcpy(t->luaFuncInit, luaFuncInit, 32);
if (luaFuncUse[0] != '*')
- strcpy(t->luaFuncUse, luaFuncUse);
+ Common::strlcpy(t->luaFuncUse, luaFuncUse, 32);
if (!t->luaFuncUse[0])
g_hdb->_window->openMessageBar("Trigger without USE!", 10);
diff --git a/engines/hdb/ai-player.cpp b/engines/hdb/ai-player.cpp
index 02089e2413..e8afe42cea 100644
--- a/engines/hdb/ai-player.cpp
+++ b/engines/hdb/ai-player.cpp
@@ -60,7 +60,7 @@ void aiPlayerInit(AIEntity *e) {
}
e->moveSpeed = kPlayerMoveSpeed;
- strcpy(e->entityName, "player");
+ Common::strlcpy(e->entityName, "player", 32);
g_hdb->_ai->assignPlayer(e);
}
@@ -1175,7 +1175,7 @@ void aiRoboStunnerAction(AIEntity *e) {
void aiRoboStunnerInit(AIEntity *e) {
e->aiAction = aiRoboStunnerAction;
- strcpy(e->printedName, "Robostunner");
+ Common::strlcpy(e->printedName, "Robostunner", 32);
}
void aiRoboStunnerInit2(AIEntity *e) {
@@ -1183,7 +1183,7 @@ void aiRoboStunnerInit2(AIEntity *e) {
}
void aiClubInit(AIEntity *e) {
- strcpy(e->printedName, "Creature Clubber");
+ Common::strlcpy(e->printedName, "Creature Clubber", 32);
e->aiAction = aiGetItemAction;
}
@@ -1192,7 +1192,7 @@ void aiClubInit2(AIEntity *e) {
}
void aiSlugSlingerInit(AIEntity *e) {
- strcpy(e->printedName, "Slugslinger");
+ Common::strlcpy(e->printedName, "Slugslinger", 32);
e->aiAction = aiGetItemAction;
}
@@ -1201,7 +1201,7 @@ void aiSlugSlingerInit2(AIEntity *e) {
}
void aiEnvelopeGreenInit(AIEntity *e) {
- strcpy(e->printedName, "Green envelope");
+ Common::strlcpy(e->printedName, "Green envelope", 32);
e->aiAction = aiGetItemAction;
}
@@ -1234,7 +1234,7 @@ void aiGemGreenInit2(AIEntity *e) {
}
void aiTeaCupInit(AIEntity *e) {
- strcpy(e->printedName, "a Teacup");
+ Common::strlcpy(e->printedName, "a Teacup", 32);
e->aiAction = aiGetItemAction;
}
@@ -1243,7 +1243,7 @@ void aiTeaCupInit2(AIEntity *e) {
}
void aiCookieInit(AIEntity *e) {
- strcpy(e->printedName, "a Cookie");
+ Common::strlcpy(e->printedName, "a Cookie", 32);
e->aiAction = aiGetItemAction;
}
@@ -1252,7 +1252,7 @@ void aiCookieInit2(AIEntity *e) {
}
void aiBurgerInit(AIEntity *e) {
- strcpy(e->printedName, "a Burger");
+ Common::strlcpy(e->printedName, "a Burger", 32);
e->aiAction = aiGetItemAction;
}
@@ -1261,7 +1261,7 @@ void aiBurgerInit2(AIEntity *e) {
}
void aiBookInit(AIEntity *e) {
- strcpy(e->printedName, "a Book");
+ Common::strlcpy(e->printedName, "a Book", 32);
e->aiAction = aiGetItemAction;
}
@@ -1270,7 +1270,7 @@ void aiBookInit2(AIEntity *e) {
}
void aiClipboardInit(AIEntity *e) {
- strcpy(e->printedName, "a Clipboard");
+ Common::strlcpy(e->printedName, "a Clipboard", 32);
e->aiAction = aiGetItemAction;
}
@@ -1279,7 +1279,7 @@ void aiClipboardInit2(AIEntity *e) {
}
void aiNoteInit(AIEntity *e) {
- strcpy(e->printedName, "a Note");
+ Common::strlcpy(e->printedName, "a Note", 32);
e->aiAction = aiGetItemAction;
}
@@ -1288,7 +1288,7 @@ void aiNoteInit2(AIEntity *e) {
}
void aiKeycardWhiteInit(AIEntity *e) {
- strcpy(e->printedName, "a White keycard");
+ Common::strlcpy(e->printedName, "a White keycard", 32);
e->aiAction = aiGetItemAction;
}
@@ -1297,7 +1297,7 @@ void aiKeycardWhiteInit2(AIEntity *e) {
}
void aiKeycardBlueInit(AIEntity *e) {
- strcpy(e->printedName, "a Blue keycard");
+ Common::strlcpy(e->printedName, "a Blue keycard", 32);
e->aiAction = aiGetItemAction;
}
@@ -1306,7 +1306,7 @@ void aiKeycardBlueInit2(AIEntity *e) {
}
void aiKeycardRedInit(AIEntity *e) {
- strcpy(e->printedName, "a Red keycard");
+ Common::strlcpy(e->printedName, "a Red keycard", 32);
e->aiAction = aiGetItemAction;
}
@@ -1315,7 +1315,7 @@ void aiKeycardRedInit2(AIEntity *e) {
}
void aiKeycardGreenInit(AIEntity *e) {
- strcpy(e->printedName, "a Green keycard");
+ Common::strlcpy(e->printedName, "a Green keycard", 32);
e->aiAction = aiGetItemAction;
}
@@ -1324,7 +1324,7 @@ void aiKeycardGreenInit2(AIEntity *e) {
}
void aiKeycardPurpleInit(AIEntity *e) {
- strcpy(e->printedName, "a Purple keycard");
+ Common::strlcpy(e->printedName, "a Purple keycard", 32);
e->aiAction = aiGetItemAction;
}
@@ -1333,7 +1333,7 @@ void aiKeycardPurpleInit2(AIEntity *e) {
}
void aiKeycardBlackInit(AIEntity *e) {
- strcpy(e->printedName, "a Black keycard");
+ Common::strlcpy(e->printedName, "a Black keycard", 32);
e->aiAction = aiGetItemAction;
}
@@ -1342,7 +1342,7 @@ void aiKeycardBlackInit2(AIEntity *e) {
}
void aiSeedInit(AIEntity *e) {
- strcpy(e->printedName, "some Henscratch");
+ Common::strlcpy(e->printedName, "some Henscratch", 32);
e->aiAction = aiGetItemAction;
}
@@ -1351,7 +1351,7 @@ void aiSeedInit2(AIEntity *e) {
}
void aiSodaInit(AIEntity *e) {
- strcpy(e->printedName, "a Dr. Frostee");
+ Common::strlcpy(e->printedName, "a Dr. Frostee", 32);
e->aiAction = aiGetItemAction;
}
@@ -1360,7 +1360,7 @@ void aiSodaInit2(AIEntity *e) {
}
void aiDollyTool1Init(AIEntity *e) {
- strcpy(e->printedName, "Dolly's Wrench");
+ Common::strlcpy(e->printedName, "Dolly's Wrench", 32);
e->aiAction = aiGetItemAction;
}
@@ -1369,7 +1369,7 @@ void aiDollyTool1Init2(AIEntity *e) {
}
void aiDollyTool2Init(AIEntity *e) {
- strcpy(e->printedName, "Dolly's Torch");
+ Common::strlcpy(e->printedName, "Dolly's Torch", 32);
e->aiAction = aiGetItemAction;
}
@@ -1378,7 +1378,7 @@ void aiDollyTool2Init2(AIEntity *e) {
}
void aiDollyTool3Init(AIEntity *e) {
- strcpy(e->printedName, "Dolly's EMF Resonator");
+ Common::strlcpy(e->printedName, "Dolly's EMF Resonator", 32);
e->aiAction = aiGetItemAction;
}
@@ -1387,7 +1387,7 @@ void aiDollyTool3Init2(AIEntity *e) {
}
void aiDollyTool4Init(AIEntity *e) {
- strcpy(e->printedName, "Dolly's Toolbox");
+ Common::strlcpy(e->printedName, "Dolly's Toolbox", 32);
e->aiAction = aiGetItemAction;
}
@@ -1396,7 +1396,7 @@ void aiDollyTool4Init2(AIEntity *e) {
}
void aiRouterInit(AIEntity *e) {
- strcpy(e->printedName, "a Computer Router");
+ Common::strlcpy(e->printedName, "a Computer Router", 32);
e->aiAction = aiGetItemAction;
}
@@ -1405,7 +1405,7 @@ void aiRouterInit2(AIEntity *e) {
}
void aiSlicerInit(AIEntity *e) {
- strcpy(e->printedName, "a Pizza Slicer");
+ Common::strlcpy(e->printedName, "a Pizza Slicer", 32);
e->aiAction = aiGetItemAction;
}
@@ -1414,7 +1414,7 @@ void aiSlicerInit2(AIEntity *e) {
}
void aiPackageInit(AIEntity *e) {
- strcpy(e->printedName, "a Package");
+ Common::strlcpy(e->printedName, "a Package", 32);
e->aiAction = aiGetItemAction;
}
@@ -1501,7 +1501,7 @@ void aiIceBlockInit2(AIEntity *e) {
}
void aiCabKeyInit(AIEntity *e) {
- strcpy(e->printedName, "a Cabinet key");
+ Common::strlcpy(e->printedName, "a Cabinet key", 32);
}
void aiCabKeyInit2(AIEntity *e) {
@@ -1509,7 +1509,7 @@ void aiCabKeyInit2(AIEntity *e) {
}
void aiItemChickenInit(AIEntity *e) {
- strcpy(e->printedName, "Cooper's chicken");
+ Common::strlcpy(e->printedName, "Cooper's chicken", 32);
}
void aiItemChickenInit2(AIEntity *e) {
@@ -1517,7 +1517,7 @@ void aiItemChickenInit2(AIEntity *e) {
}
void aiPdaInit(AIEntity *e) {
- strcpy(e->printedName, "a P.D.A.");
+ Common::strlcpy(e->printedName, "a P.D.A.", 32);
e->aiAction = aiGetItemAction;
}
@@ -1536,12 +1536,12 @@ void aiCellInit2(AIEntity *e) {
}
void aiCellInit(AIEntity *e) {
- strcpy(e->printedName, "Energy Cell");
+ Common::strlcpy(e->printedName, "Energy Cell", 32);
e->aiAction = aiGetItemAction;
}
void aiEnvelopeWhiteInit(AIEntity *e) {
- strcpy(e->printedName, "White envelope");
+ Common::strlcpy(e->printedName, "White envelope", 32);
e->aiAction = aiGetItemAction;
}
@@ -1550,7 +1550,7 @@ void aiEnvelopeWhiteInit2(AIEntity *e) {
}
void aiEnvelopeBlueInit(AIEntity *e) {
- strcpy(e->printedName, "Blue envelope");
+ Common::strlcpy(e->printedName, "Blue envelope", 32);
e->aiAction = aiGetItemAction;
}
@@ -1559,7 +1559,7 @@ void aiEnvelopeBlueInit2(AIEntity *e) {
}
void aiEnvelopeRedInit(AIEntity *e) {
- strcpy(e->printedName, "Red envelope");
+ Common::strlcpy(e->printedName, "Red envelope", 32);
e->aiAction = aiGetItemAction;
}
@@ -1569,7 +1569,7 @@ void aiEnvelopeRedInit2(AIEntity *e) {
void aiTransceiverInit(AIEntity *e) {
e->aiAction = aiTransceiverAction;
- strcpy(e->printedName, "Transceiver");
+ Common::strlcpy(e->printedName, "Transceiver", 32);
}
void aiTransceiverInit2(AIEntity *e) {
diff --git a/engines/hdb/file-manager.cpp b/engines/hdb/file-manager.cpp
index 31acc2dab8..c92acd3829 100644
--- a/engines/hdb/file-manager.cpp
+++ b/engines/hdb/file-manager.cpp
@@ -96,7 +96,7 @@ Common::SeekableReadStream *FileMan::findFirstData(const char *string, DataType
MPCEntry *file = NULL;
char fname[128];
- strcpy(fname, string);
+ Common::strlcpy(fname, string, 128);
char *pDest = strrchr(fname, '.');
if (pDest)
*pDest = '_';
@@ -143,7 +143,7 @@ int32 FileMan::getLength(const char *string, DataType type) {
MPCEntry *file = NULL;
char fname[128];
- strcpy(fname, string);
+ Common::strlcpy(fname, string, 128);
char *pDest = strrchr(fname, '.');
if (pDest)
*pDest = '_';
diff --git a/engines/hdb/gfx.cpp b/engines/hdb/gfx.cpp
index 4816ec9aa6..f8ca14b099 100644
--- a/engines/hdb/gfx.cpp
+++ b/engines/hdb/gfx.cpp
@@ -234,7 +234,7 @@ void Gfx::init() {
// Add Animating Tile Info
int found = -1;
char search[32];
- strcpy(search, "anim_");
+ Common::strlcpy(search, "anim_", 32);
for (index = 0; index < _numTiles; index++) {
// IF we have not found a start, look for it
// ELSE IF we have found a start and are in the middle of an anim group
@@ -247,7 +247,7 @@ void Gfx::init() {
_tLookupArray[index - 1].animIndex = index;
else if (strncmp(_tLookupArray[index].filename, search, strlen(search)) && found >= 0) {
_tLookupArray[index - 1].animIndex = found;
- strcpy(search, "anim_");
+ Common::strlcpy(search, "anim_", 32);
found = -1;
if (!strncmp(_tLookupArray[index].filename, search, strlen(search)))
index--;
@@ -739,7 +739,7 @@ Tile *Gfx::getTileGfx(const char *name, int32 size) {
}
GfxCache *gc = new GfxCache;
- strcpy(gc->name, name);
+ Common::strlcpy(gc->name, name, 32);
gc->tileGfx = loadTile(name);
gc->status = false;
if (size == -1)
@@ -773,7 +773,7 @@ Picture *Gfx::getPicGfx(const char *name, int32 size) {
}
GfxCache *gc = new GfxCache;
- strcpy(gc->name, name);
+ Common::strlcpy(gc->name, name, 32);
gc->picGfx = loadPic(name);
gc->status = true;
if (size == -1)
diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp
index dd20951728..f4c697192f 100644
--- a/engines/hdb/hdb.cpp
+++ b/engines/hdb/hdb.cpp
@@ -256,7 +256,7 @@ bool HDBGame::restartMap() {
_lua->saveGlobalNumber("map12_complete", 1);
- strcpy(_lastMapname, "MAP12");
+ Common::strlcpy(_lastMapname, "MAP12", 64);
}
if (!strcmp(_currentLuaName, "MAP06.LUA")) {
@@ -888,13 +888,13 @@ void HDBGame::setInMapName(const char *name) {
for (uint i = 0; i < ARRAYSIZE(mapNames); i++) {
if (!scumm_stricmp(name, mapNames[i].fName)) {
memset(&_inMapName, 0, 32);
- strcpy(_inMapName, mapNames[i].printName);
+ Common::strlcpy(_inMapName, mapNames[i].printName, 32);
return;
}
}
memset(&_inMapName, 0, 32);
- strcpy(_inMapName, name);
+ Common::strlcpy(_inMapName, name, 32);
}
Common::Error HDBGame::run() {
diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp
index 054bde9104..548140397a 100644
--- a/engines/hdb/lua-script.cpp
+++ b/engines/hdb/lua-script.cpp
@@ -168,7 +168,7 @@ void LuaScript::saveGlobalNumber(const char *global, double value) {
}
Global *g = new Global;
- strcpy(g->global, global);
+ Common::strlcpy(g->global, global, 32);
g->valueOrString = 0;
g->value = value;
@@ -183,15 +183,15 @@ void LuaScript::saveGlobalString(const char *global, const char *string) {
for (uint i = 0; i < _globals.size(); i++) {
if (!scumm_stricmp(global, _globals[i]->global)) {
_globals[i]->valueOrString = 1;
- strcpy(_globals[i]->string, string);
+ Common::strlcpy(_globals[i]->string, string, 32);
return;
}
}
Global *g = new Global;
- strcpy(g->global, global);
+ Common::strlcpy(g->global, global, 32);
g->valueOrString = 1;
- strcpy(g->string, string);
+ Common::strlcpy(g->string, string, 32);
_globals.push_back(g);
}
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index af3c816008..72f83ed74f 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -626,13 +626,13 @@ void Window::openDialog(const char *title, int tileIndex, const char *string, in
_dialogInfo.luaMore[0] = 0;
_dialogInfo.tileIndex = tileIndex;
- strcpy(_dialogInfo.title, title);
+ Common::strlcpy(_dialogInfo.title, title, 128);
_dialogInfo.active = true;
if (strlen(string) > sizeof(_dialogInfo.string))
- strncpy(_dialogInfo.string, string, sizeof(_dialogInfo.string) - 1);
+ Common::strlcpy(_dialogInfo.string, string, 128);
else
- strcpy(_dialogInfo.string, string);
+ Common::strlcpy(_dialogInfo.string, string, 128);
int e1, e2, e3, e4;
g_hdb->_gfx->getTextEdges(&e1, &e2, &e3, &e4);
@@ -662,7 +662,7 @@ void Window::openDialog(const char *title, int tileIndex, const char *string, in
_dialogInfo.more = more;
if (luaMore)
- strcpy(_dialogInfo.luaMore, luaMore);
+ Common::strlcpy(_dialogInfo.luaMore, luaMore, 64);
g_hdb->_sound->playSound(SND_MOVE_SELECTION);
}
@@ -849,13 +849,13 @@ void Window::openDialogChoice(const char *title, const char *text, const char *f
for (int i = 0; i < 10; i++)
_dialogChoiceInfo.choices[i][0] = 0;
- strcpy(_dialogChoiceInfo.title, title);
- strcpy(_dialogChoiceInfo.text, text);
- strcpy(_dialogChoiceInfo.func, func);
+ Common::strlcpy(_dialogChoiceInfo.title, title, 64);
+ Common::strlcpy(_dialogChoiceInfo.text, text, 160);
+ Common::strlcpy(_dialogChoiceInfo.func, func, 64);
_dialogChoiceInfo.numChoices = numChoices;
for (int i = 0; i < numChoices; i++)
- strcpy(_dialogChoiceInfo.choices[i], choices[i]);
+ Common::strlcpy(_dialogChoiceInfo.choices[i], choices[i], 64);
_dialogChoiceInfo.active = true;
g_hdb->_gfx->getTextEdges(&e1, &e2, &e3, &e4);
@@ -989,7 +989,7 @@ void Window::openMessageBar(const char *title, int time) {
for (i = 0; i < _numMsgQueue; i++)
if (!scumm_stricmp(_msgQueueStr[i], title))
return;
- strcpy(_msgQueueStr[_numMsgQueue], title);
+ Common::strlcpy(_msgQueueStr[_numMsgQueue], title, 128);
_msgQueueWait[_numMsgQueue] = time;
_numMsgQueue++;
}
@@ -998,7 +998,7 @@ void Window::openMessageBar(const char *title, int time) {
_msgInfo.y = 0;
_msgInfo.timer = (time * kGameFPS);
- strcpy(_msgInfo.title, title);
+ Common::strlcpy(_msgInfo.title, title, 128);
int e1, e2, e3, e4;
g_hdb->_gfx->getTextEdges(&e1, &e2, &e3, &e4);
@@ -1058,7 +1058,7 @@ void Window::nextMsgQueued() {
return;
}
- strcpy(_msgInfo.title, _msgQueueStr[0]);
+ Common::strlcpy(_msgInfo.title, _msgQueueStr[0], 128);
_msgInfo.timer = (_msgQueueWait[0] * kGameFPS);
int e1, e2, e3, e4;
@@ -1075,7 +1075,7 @@ void Window::nextMsgQueued() {
_msgInfo.y = (g_hdb->_screenHeight >> 2) - (_msgInfo.height >> 1);
for (int xx = 0; xx < _numMsgQueue - 1; xx++) {
- strcpy(_msgQueueStr[xx], _msgQueueStr[xx + 1]);
+ Common::strlcpy(_msgQueueStr[xx], _msgQueueStr[xx + 1], 128);
_msgQueueWait[xx] = _msgQueueWait[xx + 1];
}
@@ -1890,7 +1890,7 @@ void Window::textOut(const char *text, int x, int y, int timer) {
t->x = x;
t->y = y;
- strcpy(t->text, text);
+ Common::strlcpy(t->text, text, 128);
t->timer = g_system->getMillis() + (uint32)(timer << 4);
if (x < 0) {
Commit: c5868e16112d5373ef393e05d5e2ad607c2e233f
https://github.com/scummvm/scummvm/commit/c5868e16112d5373ef393e05d5e2ad607c2e233f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-27T18:29:39+02:00
Commit Message:
HDB: Add sanity checks
Changed paths:
engines/hdb/ai-bots.cpp
engines/hdb/window.cpp
diff --git a/engines/hdb/ai-bots.cpp b/engines/hdb/ai-bots.cpp
index 5f7e28ddb9..56db4642cd 100644
--- a/engines/hdb/ai-bots.cpp
+++ b/engines/hdb/ai-bots.cpp
@@ -743,6 +743,10 @@ void aiRailRiderAction(AIEntity *e) {
e->aiAction = aiRailRiderOnAction;
e->aiUse = aiRailRiderOnUse;
arrowPath = g_hdb->_ai->findArrowPath(e->tileX, e->tileY);
+
+ if (arrowPath == nullptr)
+ return;
+
e->dir = arrowPath->dir;
e->value1 = 0; // Not in a tunnel
}
diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp
index 72f83ed74f..cebe2345d3 100644
--- a/engines/hdb/window.cpp
+++ b/engines/hdb/window.cpp
@@ -582,6 +582,9 @@ void Window::chooseWeapon(AIType wType) {
static AIType lastWeaponSelected = AI_NONE;
int slot = g_hdb->_ai->queryInventoryTypeSlot(wType);
+ if (slot == -1)
+ return;
+
g_hdb->_sound->playSound(SND_MENU_SLIDER);
if (!g_hdb->getActionMode())
Commit: c212217063c3f3c969d3868ab65f15f72b308074
https://github.com/scummvm/scummvm/commit/c212217063c3f3c969d3868ab65f15f72b308074
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2020-04-27T18:29:39+02:00
Commit Message:
HDB: Remove redundant check
Changed paths:
engines/hdb/sound.cpp
diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp
index 33c3540d61..2cd0839582 100644
--- a/engines/hdb/sound.cpp
+++ b/engines/hdb/sound.cpp
@@ -1441,8 +1441,6 @@ void Sound::init() {
}
debug(9, "Registering sound: sName: %s, \tsLuaName: %s, \tExtension: %s", soundList[index].name, soundList[index].luaName, _soundCache[index].ext == SNDTYPE_MP3 ? "MP3" : "WAV");
index++;
- if (index >= kMaxSounds)
- error("Reached MAX_SOUNDS in Sound::Init() !");
}
_numSounds = index;
@@ -1757,7 +1755,7 @@ void Sound::beginMusic(SoundType song, bool fadeIn, int ramp) {
if (_song2.isPlaying()) {
_song2.fadeOut(ramp);
}
-
+
_song1.playSong(song, fadeIn, ramp);
}
else if (!_song2.isPlaying()) {
More information about the Scummvm-git-logs
mailing list