aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorStrangerke2014-08-03 01:49:59 +0200
committerStrangerke2014-08-03 01:51:33 +0200
commit9dc06870e79edd637280ef9a81391adca1eafabc (patch)
treeb4d5286a18214b5dc67a27721f235812a7c63819 /engines
parentd44ff5491281fb9bcd4cc8f4534988b0b2bcb052 (diff)
downloadscummvm-rg350-9dc06870e79edd637280ef9a81391adca1eafabc.tar.gz
scummvm-rg350-9dc06870e79edd637280ef9a81391adca1eafabc.tar.bz2
scummvm-rg350-9dc06870e79edd637280ef9a81391adca1eafabc.zip
CGE2: Start removing the checks on the return value of new
Diffstat (limited to 'engines')
-rw-r--r--engines/cge2/bitmap.cpp12
-rw-r--r--engines/cge2/cge2_main.cpp9
-rw-r--r--engines/cge2/events.cpp3
-rw-r--r--engines/cge2/hero.cpp17
-rw-r--r--engines/cge2/vga13h.cpp19
5 files changed, 15 insertions, 45 deletions
diff --git a/engines/cge2/bitmap.cpp b/engines/cge2/bitmap.cpp
index 60e7a80945..289e156ee8 100644
--- a/engines/cge2/bitmap.cpp
+++ b/engines/cge2/bitmap.cpp
@@ -84,7 +84,6 @@ Bitmap::Bitmap(CGE2Engine *vm, uint16 w, uint16 h, uint8 fill)
uint16 psiz = _h * lsiz; // - last gape, but + plane trailer
uint8 *v = new uint8[4 * psiz + _h * sizeof(*_b)];// the same for 4 planes
// + room for wash table
- assert(v != nullptr);
WRITE_LE_UINT16(v, (kBmpCPY | dsiz)); // data chunk hader
memset(v + 2, fill, dsiz); // data bytes
@@ -122,7 +121,6 @@ Bitmap::Bitmap(CGE2Engine *vm, const Bitmap &bmp) : _w(bmp._w), _h(bmp._h), _v(n
uint16 vsiz = (uint8 *)(bmp._b) - (uint8 *)(v0);
uint16 siz = vsiz + _h * sizeof(HideDesc);
uint8 *v1 = new uint8[siz];
- assert(v1 != nullptr);
memcpy(v1, v0, siz);
_b = (HideDesc *)((_v = v1) + vsiz);
}
@@ -149,13 +147,10 @@ Bitmap &Bitmap::operator=(const Bitmap &bmp) {
delete[] _v;
_v = nullptr;
- if (v0 == nullptr) {
- _v = nullptr;
- } else {
+ if (v0) {
uint16 vsiz = (uint8 *)bmp._b - (uint8 *)v0;
uint16 siz = vsiz + _h * sizeof(HideDesc);
uint8 *v1 = new uint8[siz];
- assert(v1 != nullptr);
memcpy(v1, v0, siz);
_b = (HideDesc *)((_v = v1) + vsiz);
}
@@ -265,8 +260,6 @@ BitmapPtr Bitmap::code(uint8 *map) {
uint16 sizV = (uint16)(im - 2 - _v);
_v = new uint8[sizV + _h * sizeof(*_b)];
- assert(_v != nullptr);
-
_b = (HideDesc *)(_v + sizV);
}
cnt = 0;
@@ -383,8 +376,7 @@ bool Bitmap::loadVBM(EncryptedStream *f) {
f->seek(f->pos() + kPalSize);
}
}
- if ((_v = new uint8[n]) == nullptr)
- return false;
+ _v = new uint8[n];
if (!f->err())
f->read(_v, n);
diff --git a/engines/cge2/cge2_main.cpp b/engines/cge2/cge2_main.cpp
index 6a6066e10d..e945fbfdec 100644
--- a/engines/cge2/cge2_main.cpp
+++ b/engines/cge2/cge2_main.cpp
@@ -277,14 +277,11 @@ Sprite *CGE2Engine::loadSprite(const char *fname, int ref, int scene, V3D &pos)
char c = *fname | 0x20;
if (c >= 'a' && c <= 'z' && fname[1] == '0' && fname[2] == '\0') {
h = new Hero(this);
- if (h) {
- h->gotoxyz(pos);
- sprite = h;
- }
+ h->gotoxyz(pos);
+ sprite = h;
} else {
sprite = new Sprite(this);
- if (sprite)
- sprite->gotoxyz(pos);
+ sprite->gotoxyz(pos);
}
if (sprite) {
diff --git a/engines/cge2/events.cpp b/engines/cge2/events.cpp
index ccddc25505..cf6d3b0b61 100644
--- a/engines/cge2/events.cpp
+++ b/engines/cge2/events.cpp
@@ -166,9 +166,8 @@ void Mouse::on() {
void Mouse::off() {
if (_seqPtr == 0) {
- if (_exist) {
+ if (_exist)
_active = false;
- }
step(1);
if (_busy)
diff --git a/engines/cge2/hero.cpp b/engines/cge2/hero.cpp
index 3bb7c82713..91f6354ce3 100644
--- a/engines/cge2/hero.cpp
+++ b/engines/cge2/hero.cpp
@@ -53,9 +53,8 @@ Sprite *Hero::expand() {
if (_ext != nullptr)
delete _ext;
+
_ext = new SprExt(_vm);
- if (_ext == nullptr)
- error("No core %s", fname);
if (!*_file)
return this;
@@ -79,21 +78,15 @@ Sprite *Hero::expand() {
for (int i = 0; i < kActions; i++) {
byte n = _actionCtrl[i]._cnt;
- if (n) {
+ if (n)
_ext->_actions[i] = new CommandHandler::Command[n];
- if (_ext->_actions[i] == nullptr)
- error("No core %s", fname);
- } else
+ else
_ext->_actions[i] = nullptr;
}
- Seq *curSeq;
- if (_seqCnt) {
+ Seq *curSeq = nullptr;
+ if (_seqCnt)
curSeq = new Seq[_seqCnt];
- if (curSeq == nullptr)
- error("No core %s", fname);
- } else
- curSeq = nullptr;
if (_vm->_resman->exist(fname)) { // sprite description file exist
EncryptedStream sprf(_vm, fname);
diff --git a/engines/cge2/vga13h.cpp b/engines/cge2/vga13h.cpp
index 33d5ba1335..03e6b3fe93 100644
--- a/engines/cge2/vga13h.cpp
+++ b/engines/cge2/vga13h.cpp
@@ -224,7 +224,6 @@ void Sprite::setName(char *newName) {
}
if (newName) {
_ext->_name = new char[strlen(newName) + 1];
- assert(_ext->_name != nullptr);
strcpy(_ext->_name, newName);
}
}
@@ -308,8 +307,6 @@ Sprite *Sprite::expand() {
if (_ext != nullptr)
delete _ext;
_ext = new SprExt(_vm);
- if (_ext == nullptr)
- error("No core %s", fname);
if (!*_file)
return this;
@@ -327,21 +324,15 @@ Sprite *Sprite::expand() {
for (int i = 0; i < kActions; i++){
byte n = _actionCtrl[i]._cnt;
- if (n) {
+ if (n)
_ext->_actions[i] = new CommandHandler::Command[n];
- if (_ext->_actions[i] == nullptr)
- error("No core %s", fname);
- } else
+ else
_ext->_actions[i] = nullptr;
}
- Seq *curSeq;
- if (_seqCnt) {
+ Seq *curSeq = nullptr;
+ if (_seqCnt)
curSeq = new Seq[_seqCnt];
- if (curSeq == nullptr)
- error("No core %s", fname);
- } else
- curSeq = nullptr;
if (_vm->_resman->exist(fname)) { // sprite description file exist
EncryptedStream sprf(_vm, fname);
@@ -698,11 +689,9 @@ BitmapPtr Sprite::ghost() {
return nullptr;
BitmapPtr bmp = new Bitmap(_vm, 0, 0, (uint8 *)nullptr);
- assert(bmp != nullptr);
bmp->_w = e->_b1->_w;
bmp->_h = e->_b1->_h;
bmp->_b = new HideDesc[bmp->_h];
- assert(bmp->_b != nullptr);
memcpy(bmp->_b, e->_b1->_b, sizeof(HideDesc)* bmp->_h);
uint8 *v = new uint8;
*v = (e->_p1.y << 16) + e->_p1.x;