mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-17 07:07:10 +00:00
CGE: Replace 'no core' checks by asserts
This commit is contained in:
parent
82adc025ea
commit
cf61919648
@ -104,8 +104,7 @@ Bitmap::Bitmap(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
|
||||
if (v == NULL)
|
||||
error("No core");
|
||||
assert(v != NULL);
|
||||
|
||||
*(uint16 *) v = kBmpCPY | dsiz; // data chunk hader
|
||||
memset(v + 2, fill, dsiz); // data bytes
|
||||
@ -143,8 +142,7 @@ Bitmap::Bitmap(const Bitmap &bmp) : _w(bmp._w), _h(bmp._h), _m(NULL), _v(NULL),
|
||||
uint16 vsiz = (uint8 *)(bmp._b) - (uint8 *)(v0);
|
||||
uint16 siz = vsiz + _h * sizeof(HideDesc);
|
||||
uint8 *v1 = (uint8 *) malloc(sizeof(uint8) * siz);
|
||||
if (v1 == NULL)
|
||||
error("No core");
|
||||
assert(v1 != NULL);
|
||||
memcpy(v1, v0, siz);
|
||||
_b = (HideDesc *)((_v = v1) + vsiz);
|
||||
}
|
||||
@ -174,8 +172,7 @@ Bitmap &Bitmap::operator = (const Bitmap &bmp) {
|
||||
uint16 vsiz = (uint8 *)bmp._b - (uint8 *)v0;
|
||||
uint16 siz = vsiz + _h * sizeof(HideDesc);
|
||||
uint8 *v1 = (uint8 *) malloc(sizeof(uint8) * siz);
|
||||
if (v1 == NULL)
|
||||
error("No core");
|
||||
assert(v1 != NULL);
|
||||
memcpy(v1, v0, siz);
|
||||
_b = (HideDesc *)((_v = v1) + vsiz);
|
||||
}
|
||||
@ -252,9 +249,9 @@ BMP_PTR Bitmap::code() {
|
||||
if (! skip) {
|
||||
if (_v)
|
||||
*im = pix;
|
||||
++ im;
|
||||
im++;
|
||||
}
|
||||
++ cnt;
|
||||
cnt++;
|
||||
}
|
||||
|
||||
bm += _w;
|
||||
@ -291,8 +288,7 @@ BMP_PTR Bitmap::code() {
|
||||
|
||||
uint16 sizV = (uint16)(im - 2 - _v);
|
||||
_v = new uint8[sizV + _h * sizeof(*_b)];
|
||||
if (!_v)
|
||||
error("No core");
|
||||
assert(_v != NULL);
|
||||
|
||||
_b = (HideDesc *)(_v + sizV);
|
||||
}
|
||||
|
@ -43,8 +43,7 @@ BtFile::BtFile(const char *name, IOMode mode, CRYPT *crpt)
|
||||
_buff[i]._pgNo = kBtValNone;
|
||||
_buff[i]._indx = -1;
|
||||
_buff[i]._updt = false;
|
||||
if (_buff[i]._page == NULL)
|
||||
error("No core");
|
||||
assert(_buff[i]._page != NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,8 +41,7 @@ IoBuf::IoBuf(IOMode mode, CRYPT *crpt)
|
||||
debugC(1, kCGEDebugFile, "IoBuf::IoBuf(%d, crpt)", mode);
|
||||
|
||||
_buff = (uint8 *) malloc(sizeof(uint8) * kBufferSize);
|
||||
if (_buff == NULL)
|
||||
error("No core for I/O");
|
||||
assert(_buff != NULL);
|
||||
}
|
||||
|
||||
|
||||
@ -54,8 +53,7 @@ IoBuf::IoBuf(const char *name, IOMode mode, CRYPT *crpt)
|
||||
debugC(1, kCGEDebugFile, "IoBuf::IoBuf(%s, %d, crpt)", name, mode);
|
||||
|
||||
_buff = (uint8 *) malloc(sizeof(uint8) * kBufferSize);
|
||||
if (_buff == NULL)
|
||||
error("No core for I/O [%s]", name);
|
||||
assert(_buff != NULL);
|
||||
}
|
||||
|
||||
IoBuf::~IoBuf() {
|
||||
|
@ -353,8 +353,7 @@ void CGEEngine::syncGame(Common::SeekableReadStream *readStream, Common::WriteSt
|
||||
S._prev = S._next = NULL;
|
||||
spr = (scumm_stricmp(S._file + 2, "MUCHA") == 0) ? new Fly(this, NULL)
|
||||
: new Sprite(this, NULL);
|
||||
if (spr == NULL)
|
||||
error("No core");
|
||||
assert(spr != NULL);
|
||||
*spr = S;
|
||||
_vga->_spareQ->append(spr);
|
||||
}
|
||||
@ -1075,7 +1074,7 @@ void CGEEngine::sayDebug() {
|
||||
uint16 n = 0;
|
||||
Sprite *spr;
|
||||
for (spr = _vga->_showQ->first(); spr; spr = spr->_next) {
|
||||
++ n;
|
||||
n++;
|
||||
if (spr == _sprite) {
|
||||
dwtom(n, SP_N, 10, 2);
|
||||
dwtom(_sprite->_x, SP_X, 10, 3);
|
||||
@ -1220,9 +1219,9 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int
|
||||
error("Bad SPR [%s]", line);
|
||||
|
||||
while ((len = sprf.read((uint8 *)line)) != 0) {
|
||||
++ lcnt;
|
||||
lcnt++;
|
||||
if (len && line[len - 1] == '\n')
|
||||
line[-- len] = '\0';
|
||||
line[--len] = '\0';
|
||||
if (len == 0 || *line == '.')
|
||||
continue;
|
||||
|
||||
@ -1238,7 +1237,7 @@ void CGEEngine::loadSprite(const char *fname, int ref, int cav, int col = 0, int
|
||||
error("Bad line %d [%s]", lcnt, fname);
|
||||
break;
|
||||
case 2 : // Phase
|
||||
++ shpcnt;
|
||||
shpcnt++;
|
||||
break;
|
||||
case 3 : // East
|
||||
east = (atoi(strtok(NULL, " \t,;/")) != 0);
|
||||
|
@ -36,8 +36,7 @@ Font::Font(const char *name) {
|
||||
_map = (uint8 *) malloc(sizeof(uint8) * kMapSize);
|
||||
_pos = (uint16 *) malloc(sizeof(uint16) * kPosSize);
|
||||
_wid = (uint8 *) malloc(sizeof(uint8) * kWidSize);
|
||||
if ((_map == NULL) || (_pos == NULL) || (_wid == NULL))
|
||||
error("No core");
|
||||
assert((_map != NULL) && (_pos != NULL) && (_wid != NULL));
|
||||
mergeExt(_path, name, kFontExt);
|
||||
load();
|
||||
}
|
||||
@ -189,8 +188,7 @@ Bitmap *Talk::box(uint16 w, uint16 h) {
|
||||
h = 8;
|
||||
uint16 n = w * h;
|
||||
b = (uint8 *) malloc(sizeof(uint8) * n);
|
||||
if (!b)
|
||||
error("No core");
|
||||
assert(b != NULL);
|
||||
memset(b, kTextColBG, n);
|
||||
|
||||
if (_mode) {
|
||||
|
@ -486,10 +486,9 @@ void Sprite::setName(char *n) {
|
||||
_ext->_name = NULL;
|
||||
}
|
||||
if (n) {
|
||||
if ((_ext->_name = new char[strlen(n) + 1]) != NULL)
|
||||
strcpy(_ext->_name, n);
|
||||
else
|
||||
error("No core [%s]", n);
|
||||
_ext->_name = new char[strlen(n) + 1];
|
||||
assert(_ext->_name != NULL);
|
||||
strcpy(_ext->_name, n);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -499,8 +498,8 @@ Sprite *Sprite::expand() {
|
||||
if (!_ext) {
|
||||
bool enbl = _heart->_enable;
|
||||
_heart->_enable = false;
|
||||
if ((_ext = new SprExt) == NULL)
|
||||
error("No core");
|
||||
_ext = new SprExt;
|
||||
assert(_ext != NULL);
|
||||
if (*_file) {
|
||||
static const char *Comd[] = { "Name", "Phase", "Seq", "Near", "Take", NULL };
|
||||
char line[kLineMax], fname[kPathMax];
|
||||
@ -522,9 +521,9 @@ Sprite *Sprite::expand() {
|
||||
error("Bad SPR [%s]", fname);
|
||||
int len = 0, lcnt = 0;
|
||||
while ((len = sprf.read((uint8 *)line)) != 0) {
|
||||
++lcnt;
|
||||
lcnt++;
|
||||
if (len && line[len - 1] == '\n')
|
||||
line[-- len] = '\0';
|
||||
line[--len] = '\0';
|
||||
if (len == 0 || *line == '.')
|
||||
continue;
|
||||
|
||||
@ -539,8 +538,7 @@ Sprite *Sprite::expand() {
|
||||
}
|
||||
case 2 : { // Seq
|
||||
seq = (Seq *) realloc(seq, (seqcnt + 1) * sizeof(*seq));
|
||||
if (seq == NULL)
|
||||
error("No core [%s]", fname);
|
||||
assert(seq != NULL);
|
||||
Seq *s = &seq[seqcnt++];
|
||||
s->_now = atoi(strtok(NULL, " \t,;/"));
|
||||
if (s->_now > maxnow)
|
||||
@ -564,32 +562,26 @@ Sprite *Sprite::expand() {
|
||||
case 3 : { // Near
|
||||
if (_nearPtr != NO_PTR) {
|
||||
nea = (Snail::Com *) realloc(nea, (neacnt + 1) * sizeof(*nea));
|
||||
if (nea == NULL)
|
||||
error("No core [%s]", fname);
|
||||
else {
|
||||
Snail::Com *c = &nea[neacnt++];
|
||||
if ((c->_com = (SnCom)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0)
|
||||
error("Bad NEAR in %d [%s]", lcnt, fname);
|
||||
c->_ref = atoi(strtok(NULL, " \t,;/"));
|
||||
c->_val = atoi(strtok(NULL, " \t,;/"));
|
||||
c->_ptr = NULL;
|
||||
}
|
||||
assert(nea != NULL);
|
||||
Snail::Com *c = &nea[neacnt++];
|
||||
if ((c->_com = (SnCom)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0)
|
||||
error("Bad NEAR in %d [%s]", lcnt, fname);
|
||||
c->_ref = atoi(strtok(NULL, " \t,;/"));
|
||||
c->_val = atoi(strtok(NULL, " \t,;/"));
|
||||
c->_ptr = NULL;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 4 : { // Take
|
||||
if (_takePtr != NO_PTR) {
|
||||
tak = (Snail::Com *) realloc(tak, (takcnt + 1) * sizeof(*tak));
|
||||
if (tak == NULL)
|
||||
error("No core [%s]", fname);
|
||||
else {
|
||||
Snail::Com *c = &tak[takcnt++];
|
||||
if ((c->_com = (SnCom)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0)
|
||||
error("Bad NEAR in %d [%s]", lcnt, fname);
|
||||
c->_ref = atoi(strtok(NULL, " \t,;/"));
|
||||
c->_val = atoi(strtok(NULL, " \t,;/"));
|
||||
c->_ptr = NULL;
|
||||
}
|
||||
assert(tak != NULL);
|
||||
Snail::Com *c = &tak[takcnt++];
|
||||
if ((c->_com = (SnCom)takeEnum(Snail::_comTxt, strtok(NULL, " \t,;/"))) < 0)
|
||||
error("Bad NEAR in %d [%s]", lcnt, fname);
|
||||
c->_ref = atoi(strtok(NULL, " \t,;/"));
|
||||
c->_val = atoi(strtok(NULL, " \t,;/"));
|
||||
c->_ptr = NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -774,12 +766,11 @@ BMP_PTR Sprite::ghost() {
|
||||
register SprExt *e = _ext;
|
||||
if (e->_b1) {
|
||||
BMP_PTR bmp = new Bitmap(0, 0, (uint8 *)NULL);
|
||||
if (bmp == NULL)
|
||||
error("No core");
|
||||
assert(bmp != NULL);
|
||||
bmp->_w = e->_b1->_w;
|
||||
bmp->_h = e->_b1->_h;
|
||||
if ((bmp->_b = new HideDesc[bmp->_h]) == NULL)
|
||||
error("No Core");
|
||||
bmp->_b = new HideDesc[bmp->_h];
|
||||
assert(bmp->_b != NULL);
|
||||
bmp->_v = (uint8 *) memcpy(bmp->_b, e->_b1->_b, sizeof(HideDesc) * bmp->_h);
|
||||
bmp->_map = (e->_y1 << 16) + e->_x1;
|
||||
return bmp;
|
||||
|
Loading…
Reference in New Issue
Block a user