aboutsummaryrefslogtreecommitdiff
path: root/engines/griffon/engine.cpp
diff options
context:
space:
mode:
authorStrangerke2019-09-01 20:04:27 +0200
committerEugene Sandulenko2019-11-13 22:07:08 +0100
commite313bc167d13e05f027d7e7832d97ccaacbb7d88 (patch)
tree3d9b6777cb5815aad50a666c38d5aa72701a5072 /engines/griffon/engine.cpp
parentdaa06c0c7d59690ae3e74aa73848265049c00c77 (diff)
downloadscummvm-rg350-e313bc167d13e05f027d7e7832d97ccaacbb7d88.tar.gz
scummvm-rg350-e313bc167d13e05f027d7e7832d97ccaacbb7d88.tar.bz2
scummvm-rg350-e313bc167d13e05f027d7e7832d97ccaacbb7d88.zip
GRIFFON: Add a check after calls to file.open
Diffstat (limited to 'engines/griffon/engine.cpp')
-rw-r--r--engines/griffon/engine.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/engines/griffon/engine.cpp b/engines/griffon/engine.cpp
index 01021e02ac..7d418e2707 100644
--- a/engines/griffon/engine.cpp
+++ b/engines/griffon/engine.cpp
@@ -155,9 +155,8 @@ DataChunk *Mix_LoadWAV(const char *name) {
DataChunk *res = new DataChunk;
file.open(name);
- if (!file.isOpen()) {
+ if (!file.isOpen())
error("Cannot open file %s", name);
- }
res->size = file.size();
res->data = (byte *)malloc(res->size);
@@ -3681,18 +3680,20 @@ void GriffonEngine::game_loadmap(int mapnum) {
Common::File file;
file.open(name);
+
+ if (!file.isOpen())
+ error("Cannot open file %s", name);
+
int tempmap[320][200];
for (int x = 0; x <= 319; x++) {
- for (int y = 0; y <= 199; y++) {
+ for (int y = 0; y <= 199; y++)
INPUT("%i", &tempmap[x][y]);
- }
}
file.close();
for (int x = 0; x <= 319; x++) {
- for (int y = 0; y <= 239; y++) {
+ for (int y = 0; y <= 239; y++)
_triggerloc[x][y] = -1;
- }
}
// read *.trg file
@@ -3700,6 +3701,9 @@ void GriffonEngine::game_loadmap(int mapnum) {
debug(1, "Reading %s", name);
file.open(name);
+ if (!file.isOpen())
+ error("Cannot open file %s", name);
+
INPUT("%i", &_ntriggers);
for (int i = 0; i < _ntriggers; i++) {
@@ -3945,6 +3949,9 @@ void GriffonEngine::game_loadmap(int mapnum) {
debug(1, "Reading %s", name);
file.open(name);
+ if (!file.isOpen())
+ error("Cannot open file %s", name);
+
for (int i = 0; i < kMaxNPC; i++) {
INPUT("%i", &_npcinfo[i].spriteset);
INPUT("%i", &_npcinfo[i].x1);
@@ -8007,10 +8014,12 @@ void GriffonEngine::sys_LoadTriggers() {
Common::File file;
file.open("data/triggers.dat");
+ if (!file.isOpen())
+ error("Cannot open file data/Triggers.dat");
+
for (int i = 0; i <= 9999; i++) {
- for (int a = 0; a <= 8; a++) {
+ for (int a = 0; a <= 8; a++)
INPUT("%i", &_triggers[i][a]);
- }
}
file.close();
@@ -8020,6 +8029,8 @@ void GriffonEngine::sys_LoadObjectDB() {
Common::File file;
file.open("objectdb.dat");
+ if (!file.isOpen())
+ error("Cannot open file objectdb.dat");
for (int a = 0; a <= 32; a++) {
for (int b = 0; b <= 5; b++) {