aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2011-07-11 20:56:32 +1000
committerPaul Gilbert2011-07-11 20:56:32 +1000
commit9ba5e2b304e6ba7ca9d0b782ad8e5dfd98317b02 (patch)
tree8420a4b7938cf52ff4a696a618bf977bd0434dc0
parent18077762d738178795c99d38010052b95cb1cef5 (diff)
downloadscummvm-rg350-9ba5e2b304e6ba7ca9d0b782ad8e5dfd98317b02.tar.gz
scummvm-rg350-9ba5e2b304e6ba7ca9d0b782ad8e5dfd98317b02.tar.bz2
scummvm-rg350-9ba5e2b304e6ba7ca9d0b782ad8e5dfd98317b02.zip
CGE: Reverted last commit due to extra memory leaks
-rw-r--r--engines/cge/cge_main.cpp5
-rw-r--r--engines/cge/events.cpp14
-rw-r--r--engines/cge/talk.cpp7
-rw-r--r--engines/cge/vga13h.cpp29
-rw-r--r--engines/cge/vga13h.h2
5 files changed, 15 insertions, 42 deletions
diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp
index 76d1b7dbcd..4c20f31cac 100644
--- a/engines/cge/cge_main.cpp
+++ b/engines/cge/cge_main.cpp
@@ -1587,10 +1587,7 @@ void CGEEngine::runGame() {
{ 1, 6, 0, 0, 4 },
{ 0, 1, 0, 0, 16 },
};
- Seq *seq = (Seq *)malloc(7 * sizeof(Seq));
- Common::copy(&pocSeq[0], &pocSeq[7], seq);
- _pocLight->setSeq(seq);
-
+ _pocLight->setSeq(pocSeq);
_pocLight->_flags._tran = true;
_pocLight->_time = 1;
_pocLight->_z = 120;
diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp
index 0bf5191530..433f7c6db9 100644
--- a/engines/cge/events.cpp
+++ b/engines/cge/events.cpp
@@ -142,6 +142,11 @@ void Keyboard::newKeyboard(Common::Event &event) {
/*----------------- MOUSE interface -----------------*/
Mouse::Mouse(CGEEngine *vm) : Sprite(vm, NULL), _busy(NULL), _hold(NULL), _hx(0), _vm(vm) {
+ static Seq ms[] = {
+ { 0, 0, 0, 0, 1 },
+ { 1, 1, 0, 0, 1 }
+ };
+
_hold = NULL;
_hx = 0;
_hy = 0;
@@ -150,14 +155,7 @@ Mouse::Mouse(CGEEngine *vm) : Sprite(vm, NULL), _busy(NULL), _hold(NULL), _hx(0)
_busy = NULL;
_active = false;
_flags._kill = false;
-
- static Seq ms[] = {
- { 0, 0, 0, 0, 1 },
- { 1, 1, 0, 0, 1 }
- };
- Seq *seq = (Seq *)malloc(2 * sizeof(Seq));
- Common::copy(&ms[0], &ms[2], seq);
- setSeq(seq);
+ setSeq(ms);
BMP_PTR *MC = new BMP_PTR[3];
MC[0] = new Bitmap("MOUSE", true);
diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp
index 152f4a7123..146c720667 100644
--- a/engines/cge/talk.cpp
+++ b/engines/cge/talk.cpp
@@ -310,12 +310,7 @@ void InfoLine::update(const char *tx) {
// clear whole rectangle
memset(v + 2, TEXT_BG, dsiz); // data bytes
-
- for (byte *pDest = v + lsiz; pDest < (v + psiz); pDest += lsiz)
- *pDest = 0;
-// Common::set_to(pDest, pDest + lsiz, 0);
- //Common::copy(v, v + lsiz, pDest);
-
+ memmove(v + lsiz, v, psiz - lsiz);
*(uint16 *)(v + psiz - 2) = EOI; // plane trailer uint16
memmove(v + psiz, v, 3 * psiz);
diff --git a/engines/cge/vga13h.cpp b/engines/cge/vga13h.cpp
index ff21f5cce8..d92b9e97f0 100644
--- a/engines/cge/vga13h.cpp
+++ b/engines/cge/vga13h.cpp
@@ -60,6 +60,8 @@ static VgaRegBlk VideoMode[] = {
};
bool SpeedTest = false;
+Seq _seq1[] = { { 0, 0, 0, 0, 0 } };
+Seq _seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } };
extern "C" void SNDMIDIPlay();
@@ -381,23 +383,6 @@ BMP_PTR Sprite::shp() {
return NULL;
}
-Seq *Sprite::getConstantSeq(bool seqFlag) {
- Seq seq1[] = { { 0, 0, 0, 0, 0 } };
- Seq seq2[] = { { 0, 1, 0, 0, 0 }, { 1, 0, 0, 0, 0 } };
-
- // Make a copy of the given seq list and return it
- Seq *seq;
- if (seqFlag) {
- seq = (Seq *)malloc(sizeof(Seq));
- seq[0] = seq1[0];
- } else {
- seq = (Seq *)malloc(2 * sizeof(Seq));
- seq[0] = seq2[0];
- seq[1] = seq2[1];
- }
-
- return seq;
-}
BMP_PTR *Sprite::setShapeList(BMP_PTR *shpP) {
BMP_PTR *r = (_ext) ? _ext->_shpList : NULL;
@@ -420,7 +405,7 @@ BMP_PTR *Sprite::setShapeList(BMP_PTR *shpP) {
_ext->_shpList = shpP;
_flags._bDel = true;
if (!_ext->_seq)
- setSeq(getConstantSeq(_shpCnt < 2));
+ setSeq((_shpCnt < 2) ? _seq1 : _seq2);
}
return r;
}
@@ -605,7 +590,7 @@ Sprite *Sprite::expand() {
error("Bad JUMP in SEQ [%s]", fname);
setSeq(seq);
} else
- setSeq(getConstantSeq(_shpCnt == 1));
+ setSeq((_shpCnt == 1) ? _seq1 : _seq2);
//disable(); // disable interupt
setShapeList(shplist);
@@ -636,8 +621,8 @@ Sprite *Sprite::contract() {
delete e->_shpList[i];
delete[] e->_shpList;
}
- free(e->_seq);
-
+ if (memType(e->_seq) == NEAR_MEM)
+ free(e->_seq);
if (e->_near)
free(e->_near);
if (e->_take)
@@ -1399,7 +1384,7 @@ CavLight::CavLight(CGEEngine *vm): Sprite(vm, NULL) {
Spike::Spike(CGEEngine *vm): Sprite(vm, NULL) {
// Set the sprite list
- BMP_PTR *SP = new BMP_PTR[3];
+ BMP_PTR *SP = new BMP_PTR[2];
SP[0] = new Bitmap("SPK_L", true);
SP[1] = new Bitmap("SPK_R", true);
SP[2] = NULL;
diff --git a/engines/cge/vga13h.h b/engines/cge/vga13h.h
index 177165689e..003be7c800 100644
--- a/engines/cge/vga13h.h
+++ b/engines/cge/vga13h.h
@@ -166,8 +166,6 @@ public:
class Sprite {
-private:
- Seq *getConstantSeq(bool seqFlag);
protected:
SprExt *_ext;
public: