Mercurial > hg > forks > yadex
changeset 60:1dfcb729ef3d
Add in more extensive error reporting.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 26 Sep 2011 07:03:47 +0300 |
parents | 55bd29745535 |
children | 0cb3078fff55 |
files | src/textures.cc |
diffstat | 1 files changed, 17 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/textures.cc Mon Sep 26 07:03:29 2011 +0300 +++ b/src/textures.cc Mon Sep 26 07:03:47 2011 +0300 @@ -135,6 +135,7 @@ } if (WAD_TEX_NAME < 7) nf_bug("WAD_TEX_NAME too small"); // Sanity + if (!y_strnicmp(c->name, "TEX", 3) && isdigit(c->name[3]) && isdigit(c->name[4]) @@ -508,6 +509,9 @@ { dir->wadfile->seek(dir->dir.start); dir->wadfile->read_i32(&numtex); + if (dir->wadfile->error()) + warn("Could not seek or read the textures directory (1).\n"); + // Read in the offsets for texture1 names and info offsets = (i32 *) GetMemory((long) numtex * 4); dir->wadfile->read_i32(offsets, numtex); @@ -515,6 +519,11 @@ { dir->wadfile->seek(dir->dir.start + offsets[n]); dir->wadfile->read_bytes(&tname, WAD_TEX_NAME); + if (dir->wadfile->error()) + { + warn("Error in reading texture #%d/%d (1).\n", n, numtex); + break; + } if (!y_strnicmp(tname, texname, WAD_TEX_NAME)) texofs = dir->dir.start + offsets[n]; } @@ -529,6 +538,9 @@ { dir->wadfile->seek(dir->dir.start); dir->wadfile->read_i32(&numtex); + if (dir->wadfile->error()) + warn("Could not seek or read the textures directory (2).\n"); + // Read in the offsets for texture2 names offsets = (i32 *) GetMemory((long) numtex * 4); dir->wadfile->read_i32(offsets, numtex); @@ -536,6 +548,11 @@ { dir->wadfile->seek(dir->dir.start + offsets[n]); dir->wadfile->read_bytes(&tname, WAD_TEX_NAME); + if (dir->wadfile->error()) + { + warn("Error in reading texture #%d/%d (2).\n", n, numtex); + break; + } if (!y_strnicmp(tname, texname, WAD_TEX_NAME)) texofs = dir->dir.start + offsets[n]; }