aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/prince/graphics.cpp2
-rw-r--r--engines/prince/prince.cpp26
-rw-r--r--engines/prince/prince.h2
-rw-r--r--engines/prince/script.cpp8
-rw-r--r--engines/prince/script.h2
-rw-r--r--engines/prince/variatxt.cpp4
-rw-r--r--engines/prince/variatxt.h2
7 files changed, 29 insertions, 17 deletions
diff --git a/engines/prince/graphics.cpp b/engines/prince/graphics.cpp
index b86628009f..c993cc8905 100644
--- a/engines/prince/graphics.cpp
+++ b/engines/prince/graphics.cpp
@@ -46,6 +46,8 @@ GraphicsMan::GraphicsMan(PrinceEngine *vm)
GraphicsMan::~GraphicsMan() {
_frontScreen->free();
delete _frontScreen;
+ _screenForInventory->free();
+ delete _screenForInventory;
delete[] _shadowTable70;
delete[] _shadowTable50;
}
diff --git a/engines/prince/prince.cpp b/engines/prince/prince.cpp
index 83a471a6ed..0df1f778c6 100644
--- a/engines/prince/prince.cpp
+++ b/engines/prince/prince.cpp
@@ -140,6 +140,8 @@ PrinceEngine::~PrinceEngine() {
}
_maskList.clear();
+ freeDrawNodes();
+
clearBackAnimList();
for (uint i = 0; i < _allInvList.size(); i++) {
@@ -404,6 +406,8 @@ bool PrinceEngine::loadLocation(uint16 locationNr) {
_mobList[i]._visible = _script->getMobVisible(i);
}
+ freeDrawNodes();
+
clearBackAnimList();
_script->installBackAnims(_backAnimList, _room->_backAnim);
@@ -855,8 +859,10 @@ int PrinceEngine::checkMob(Graphics::Surface *screen, Common::Array<Mob> &mobLis
int phase = backAnim._showFrame;
int phaseFrameIndex = backAnim._animData->getPhaseFrameIndex(phase);
Graphics::Surface *backAnimSurface = backAnim._animData->getFrame(phaseFrameIndex);
- byte *pixel = (byte *)backAnimSurface->getBasePtr(mousePosCamera.x - backAnim._currX, mousePosCamera.y - backAnim._currY);
- if (*pixel != 255) {
+ byte pixel = *(byte *)backAnimSurface->getBasePtr(mousePosCamera.x - backAnim._currX, mousePosCamera.y - backAnim._currY);
+ backAnimSurface->free();
+ delete backAnimSurface;
+ if (pixel != 255) {
break;
}
}
@@ -923,13 +929,11 @@ int PrinceEngine::checkMob(Graphics::Surface *screen, Common::Array<Mob> &mobLis
return -1;
}
-void PrinceEngine::printAt(uint32 slot, uint8 color, const char *s, uint16 x, uint16 y) {
+void PrinceEngine::printAt(uint32 slot, uint8 color, char *s, uint16 x, uint16 y) {
debugC(1, DebugChannel::kEngine, "PrinceEngine::printAt slot %d, color %d, x %02d, y %02d, str %s", slot, color, x, y, s);
- char *destStr = (char *)malloc(strlen(s));
- strcpy(destStr, s);
- char *strPointer = destStr;
+ char *strPointer = s;
if (getLanguage() == Common::DE_DEU) {
while (*strPointer) {
@@ -961,7 +965,7 @@ void PrinceEngine::printAt(uint32 slot, uint8 color, const char *s, uint16 x, ui
}
Text &text = _textSlots[slot];
- text._str = destStr;
+ text._str = s;
text._x = x;
text._y = y;
text._color = color;
@@ -1140,6 +1144,9 @@ void PrinceEngine::showSprite(Graphics::Surface *spriteSurface, int destX, int d
newDrawNode.freeSurfaceSMemory = freeSurfaceMemory;
newDrawNode.drawFunction = &_graph->drawTransparentDrawNode;
_drawNodeList.push_back(newDrawNode);
+ } else if (freeSurfaceMemory) {
+ spriteSurface->free();
+ delete spriteSurface;
}
}
@@ -1159,6 +1166,9 @@ void PrinceEngine::showSpriteShadow(Graphics::Surface *shadowSurface, int destX,
newDrawNode.freeSurfaceSMemory = freeSurfaceMemory;
newDrawNode.drawFunction = &_graph->drawAsShadowDrawNode;
_drawNodeList.push_back(newDrawNode);
+ } else if (freeSurfaceMemory) {
+ shadowSurface->free();
+ delete shadowSurface;
}
}
@@ -1906,7 +1916,7 @@ void PrinceEngine::inventoryLeftMouseButton() {
int invObjExamEvent = _script->scanMobEvents(_invMobList[_selectedMob]._mask, _script->_scriptInfo.invObjExam);
if (invObjExamEvent == -1) {
// do_standard
- printAt(0, 216, _invMobList[_selectedMob]._examText.c_str(), kNormalWidth / 2, _invExamY);
+ printAt(0, 216, (char *)_invMobList[_selectedMob]._examText.c_str(), kNormalWidth / 2, _invExamY);
_interpreter->setCurrentString(_invMobList[_selectedMob]._mask + 70000);
setVoice(0, 28, 1);
playSample(28, 0);
diff --git a/engines/prince/prince.h b/engines/prince/prince.h
index e1da3ba41b..0d3bae26f6 100644
--- a/engines/prince/prince.h
+++ b/engines/prince/prince.h
@@ -250,7 +250,7 @@ public:
virtual GUI::Debugger *getDebugger();
void changeCursor(uint16 curId);
- void printAt(uint32 slot, uint8 color, const char *s, uint16 x, uint16 y);
+ void printAt(uint32 slot, uint8 color, char *s, uint16 x, uint16 y);
int calcText(const char *s);
static const uint8 MAXTEXTS = 32;
diff --git a/engines/prince/script.cpp b/engines/prince/script.cpp
index 910c861706..d5284034e2 100644
--- a/engines/prince/script.cpp
+++ b/engines/prince/script.cpp
@@ -462,7 +462,7 @@ void Interpreter::debugInterpreter(const char *s, ...) {
Common::String str = Common::String::format("@0x%08X: ", _lastInstruction);
str += Common::String::format("op %04d: ", _lastOpcode);
//debugC(10, DebugChannel::kScript, "PrinceEngine::Script %s %s", str.c_str(), buf);
- if (_mode == "fg") {
+ if (!strcmp(_mode, "fg")) {
debug(10, "PrinceEngine::Script %s %s", str.c_str(), buf);
}
//debug("Prince::Script frame %08ld mode %s %s %s", _vm->_frameNr, _mode, str.c_str(), buf);
@@ -834,7 +834,7 @@ void Interpreter::O_SETSTRING() {
_currentString = offset;
if (offset >= 80000) {
- _string = (const byte *)_vm->_variaTxt->getString(offset - 80000);
+ _string = (byte *)_vm->_variaTxt->getString(offset - 80000);
debugInterpreter("GetVaria %s", _string);
}
else if (offset < 2000) {
@@ -911,7 +911,7 @@ void Interpreter::O_XORFLAG() {
void Interpreter::O_GETMOBTEXT() {
uint16 mob = readScriptFlagValue();
_currentString = _vm->_locationNr * 100 + mob + 60001;
- _string = (const byte *)_vm->_mobList[mob]._examText.c_str();
+ _string = (byte *)_vm->_mobList[mob]._examText.c_str();
debugInterpreter("O_GETMOBTEXT mob %d", mob);
}
@@ -1239,7 +1239,7 @@ void Interpreter::O_PRINTAT() {
uint8 color = _flags->getFlagValue(Flags::KOLOR);
- _vm->printAt(slot, color, (const char *)_string, fr1, fr2);
+ _vm->printAt(slot, color, (char *)_string, fr1, fr2);
increaseString();
}
diff --git a/engines/prince/script.h b/engines/prince/script.h
index 36fff1ceb9..d550ebc9bf 100644
--- a/engines/prince/script.h
+++ b/engines/prince/script.h
@@ -209,7 +209,7 @@ private:
//uint8 _savedStacktop;
uint32 _waitFlag;
- const byte *_string;
+ byte *_string;
uint32 _currentString;
const char *_mode;
diff --git a/engines/prince/variatxt.cpp b/engines/prince/variatxt.cpp
index fdca8c2c77..56fbd2911a 100644
--- a/engines/prince/variatxt.cpp
+++ b/engines/prince/variatxt.cpp
@@ -42,12 +42,12 @@ bool VariaTxt::loadFromStream(Common::SeekableReadStream &stream) {
return true;
}
-const char *VariaTxt::getString(uint32 stringId) {
+char *VariaTxt::getString(uint32 stringId) {
uint32 stringOffset = READ_LE_UINT32(_data + stringId * 4);
if (stringOffset > _dataSize) {
assert(false);
}
- return (const char *)_data + stringOffset;
+ return (char *)_data + stringOffset;
}
}
diff --git a/engines/prince/variatxt.h b/engines/prince/variatxt.h
index 2a7a5fda9c..b7fc7e3ac5 100644
--- a/engines/prince/variatxt.h
+++ b/engines/prince/variatxt.h
@@ -32,7 +32,7 @@ public:
bool loadFromStream(Common::SeekableReadStream &stream);
- const char *getString(uint32 stringId);
+ char *getString(uint32 stringId);
private:
uint32 _dataSize;