[Scummvm-git-logs] scummvm master -> ea0a0c7001c191256bf595105325d1fe136559b7

whiterandrek whiterandrek at gmail.com
Mon May 25 20:52:20 UTC 2020


This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
aca3674e1b PETKA: fixed possible crash
08cbf8abb3 PETKA: changes to dialog system
5396b8a3fd PETKA: transfer reaction ownership clearer
ea0a0c7001 PETKA: added QMessageObject::setReaction method


Commit: aca3674e1b0adb3a58a68542f3086791e40e9b26
    https://github.com/scummvm/scummvm/commit/aca3674e1b0adb3a58a68542f3086791e40e9b26
Author: Andrei Prykhodko (whiterandrek at gmail.com)
Date: 2020-05-25T23:50:59+03:00

Commit Message:
PETKA: fixed possible crash

Changed paths:
    engines/petka/objects/text.cpp


diff --git a/engines/petka/objects/text.cpp b/engines/petka/objects/text.cpp
index 168113391b..29e2be2640 100644
--- a/engines/petka/objects/text.cpp
+++ b/engines/petka/objects/text.cpp
@@ -112,8 +112,8 @@ void QTextPhrase::update(int time) {
 			dialog.next(-1);
 		}
 	} else if (_time > _phrase.size() * 30 + 1000 || !g_vm->getQSystem()->_panelInterface->_subtitles) {
-		dialog.next(-1);
 		_time = 0;
+		dialog.next(-1);
 	}
 }
 


Commit: 08cbf8abb3fe9c7b3e3c35a2a1cf36b54d5f73b2
    https://github.com/scummvm/scummvm/commit/08cbf8abb3fe9c7b3e3c35a2a1cf36b54d5f73b2
Author: Andrei Prykhodko (whiterandrek at gmail.com)
Date: 2020-05-25T23:50:59+03:00

Commit Message:
PETKA: changes to dialog system

Changed paths:
    engines/petka/big_dialogue.cpp
    engines/petka/big_dialogue.h
    engines/petka/interfaces/dialog_interface.cpp
    engines/petka/interfaces/dialog_interface.h
    engines/petka/objects/text.cpp


diff --git a/engines/petka/big_dialogue.cpp b/engines/petka/big_dialogue.cpp
index c54dfe0aba..50bdc0194a 100644
--- a/engines/petka/big_dialogue.cpp
+++ b/engines/petka/big_dialogue.cpp
@@ -122,7 +122,8 @@ const Common::U32String *BigDialogue::getSpeechInfo(int *talkerId, const char **
 
 		uint index = _currOp->play.messageIndex;
 		_currOp = menuOp;
-		*soundName = _speeches[index].soundName;
+		if (soundName)
+			*soundName = _speeches[index].soundName;
 		*talkerId = _speeches[index].speakerId;
 		return &_speeches[index].text;
 	}
@@ -138,7 +139,8 @@ const Common::U32String *BigDialogue::getSpeechInfo(int *talkerId, const char **
 	}
 		// fall through
 	case kOperationPlay:
-		*soundName = _speeches[_currOp->play.messageIndex].soundName;
+		if (soundName)
+			*soundName = _speeches[_currOp->play.messageIndex].soundName;
 		*talkerId = _speeches[_currOp->play.messageIndex].speakerId;
 		return &_speeches[_currOp->play.messageIndex].text;
 	default:
@@ -467,4 +469,12 @@ bool BigDialogue::checkMenu(uint menuIndex) {
 	return true;
 }
 
+void BigDialogue::getMenuChoices(Common::Array<Common::U32String> &choices) {
+	uint count = choicesCount();
+	for (uint i = 0; i < count; ++i) {
+		int id;
+		choices.push_back(*getSpeechInfo(&id, nullptr, i));
+	}
+}
+
 } // End of namespace Petka
diff --git a/engines/petka/big_dialogue.h b/engines/petka/big_dialogue.h
index 8b3573540c..272f7b1eb5 100644
--- a/engines/petka/big_dialogue.h
+++ b/engines/petka/big_dialogue.h
@@ -116,6 +116,7 @@ public:
 	void setHandler(uint objId, uint opcode);
 
 	const Common::U32String *getSpeechInfo(int *talkerId, const char **soundName, int unk);
+	void getMenuChoices(Common::Array<Common::U32String> &choices);
 
 	void load(Common::ReadStream *s);
 	void save(Common::WriteStream *s);
diff --git a/engines/petka/interfaces/dialog_interface.cpp b/engines/petka/interfaces/dialog_interface.cpp
index 4b0a91359c..6f1d02b907 100644
--- a/engines/petka/interfaces/dialog_interface.cpp
+++ b/engines/petka/interfaces/dialog_interface.cpp
@@ -36,6 +36,8 @@
 namespace Petka {
 
 DialogInterface::DialogInterface() {
+	_dialog = g_vm->getBigDialogue();
+	_qsys = g_vm->getQSystem();
 	_state = kIdle;
 	_id = -1;
 	_isUserMsg = false;
@@ -43,7 +45,6 @@ DialogInterface::DialogInterface() {
 	_talker = nullptr;
 	_sender = nullptr;
 	_reaction = nullptr;
-	_hasSound = false;
 	_firstTime = true;
 }
 
@@ -53,7 +54,6 @@ DialogInterface::~DialogInterface() {
 
 void DialogInterface::start(uint id, QMessageObject *sender) {
 	_id = id;
-	_hasSound = false;
 	_isUserMsg = false;
 	_afterUserMsg = false;
 	_talker = nullptr;
@@ -66,7 +66,7 @@ void DialogInterface::start(uint id, QMessageObject *sender) {
 }
 
 void DialogInterface::initCursor() {
-	QObjectCursor *cursor = g_vm->getQSystem()->_cursor.get();
+	QObjectCursor *cursor = _qsys->_cursor.get();
 
 	_savedCursorId = cursor->_resourceId;
 	_savedCursorActType = cursor->_actionType;
@@ -80,7 +80,7 @@ void DialogInterface::initCursor() {
 }
 
 void DialogInterface::restoreCursor() {
-	QObjectCursor *cursor = g_vm->getQSystem()->_cursor.get();
+	QObjectCursor *cursor = _qsys->_cursor.get();
 	cursor->_isShown = _wasCursorShown;
 	cursor->_animate = _wasCursorAnim;
 	cursor->_resourceId = _savedCursorId;
@@ -94,80 +94,32 @@ void DialogInterface::next(int choice) {
 	if ((choice == -1 && _state == kMenu) || (choice != -1 && _state == kPlaying))
 		return;
 
-	QSystem *qsys = g_vm->getQSystem();
-	BigDialogue *bigDialog = g_vm->getBigDialogue();
-
-	const char *soundName = nullptr;
 	int prevTalkerId = -1;
-
 	if (choice == -1 && !_afterUserMsg) {
-		bigDialog->getSpeechInfo(&prevTalkerId, &soundName, -1);
+		_dialog->getSpeechInfo(&prevTalkerId, nullptr, -1);
 	}
 	_afterUserMsg = _isUserMsg;
 
-	qsys->_cursor->_isShown = 0;
+	_qsys->_cursor->_isShown = false;
 	if (_isUserMsg)
 		return;
 	if (_firstTime)
 		_firstTime = false;
 	else
-		g_vm->getBigDialogue()->next(choice);
-
-	switch (g_vm->getBigDialogue()->opcode()) {
-	case kOpcodePlay: {
-		int currTalkerId;
-		const Common::U32String *text = bigDialog->getSpeechInfo(&currTalkerId, &soundName, -1);
-		g_vm->soundMgr()->removeSound(_soundName);
-		if (prevTalkerId != currTalkerId) {
-			sendMsg(kSaid);
-		}
-		_talker = qsys->findObject(currTalkerId);
-		_soundName = g_vm->getSpeechPath() + soundName;
-		Sound *s = g_vm->soundMgr()->addSound(_soundName, Audio::Mixer::kSpeechSoundType);
-		if (s) {
-			Common::Rect bounds = g_vm->resMgr()->loadFlic(_talker->_resourceId)->getBounds();
-			s->setBalance(bounds.left + _talker->_x + bounds.width(), 640);
-			s->play(0);
-		}
-		_hasSound = s != nullptr;
-		if (prevTalkerId != currTalkerId) {
-			sendMsg(kSay);
-		}
-		qsys->_mainInterface->setTextPhrase(*text, _talker->_dialogColor, g_system->getScreenFormat().RGBToColor(0x7F, 0, 0));
-		_state = kPlaying;
+		_dialog->next(choice);
+
+	switch (_dialog->opcode()) {
+	case kOpcodePlay:
+		onPlayOpcode(prevTalkerId);
 		break;
-	}
-	case kOpcodeMenu: {
-		g_vm->soundMgr()->removeSound(_soundName);
-		_soundName.clear();
-		if (_talker) {
-			sendMsg(kSaid);
-			_talker = nullptr;
-		}
-		uint count = bigDialog->choicesCount();
-		if (count == 0)
-			break;
-
-		Common::Array<Common::U32String> choices;
-		for (uint i = 0; i < count; ++i) {
-			int id;
-			choices.push_back(*bigDialog->getSpeechInfo(&id, &soundName, i));
-		}
-		qsys->_mainInterface->setTextChoice(choices, 0xFFFF, g_system->getScreenFormat().RGBToColor(0xFF, 0, 0));
-
-		qsys->_cursor->_isShown = 1;
-		_state = kMenu;
+	case kOpcodeMenu:
+		onMenuOpcode();
 		break;
-	}
 	case kOpcodeEnd:
-		end();
+		onEndOpcode();
 		break;
 	case kOpcodeUserMessage:
-		qsys->_mainInterface->setTextPhrase(Common::U32String(""), 0, 0);
-		g_vm->soundMgr()->removeSound(_soundName);
-		_soundName.clear();
-		_talker = nullptr;
-		_state = kPlaying;
+		onUserMsgOpcode();
 		break;
 	default:
 		break;
@@ -180,13 +132,13 @@ void DialogInterface::sendMsg(uint16 opcode) {
 	}
 }
 
-void DialogInterface::end() {
+void DialogInterface::onEndOpcode() {
 	g_vm->soundMgr()->removeSound(_soundName);
 	sendMsg(kSaid);
 	_talker = nullptr;
 	_state = kIdle;
 	_id = -1;
-	g_vm->getQSystem()->_currInterface->removeTexts();
+	_qsys->_currInterface->removeTexts();
 	restoreCursor();
 	if (_reaction)
 		processSavedReaction(&_reaction, _sender);
@@ -202,7 +154,7 @@ void DialogInterface::startUserMsg(uint16 arg) {
 	sendMsg(kSaid);
 	_isUserMsg = true;
 	restoreCursor();
-	g_vm->getQSystem()->addMessage(g_vm->getQSystem()->_chapayev->_id, kUserMsg, arg);
+	_qsys->addMessage(_qsys->_chapayev->_id, kUserMsg, arg);
 }
 
 bool DialogInterface::isActive() {
@@ -214,8 +166,6 @@ void DialogInterface::setSender(QMessageObject *sender) {
 }
 
 Sound *DialogInterface::findSound() {
-	if (!_hasSound)
-		return nullptr;
 	return g_vm->soundMgr()->findSound(_soundName);
 }
 
@@ -230,4 +180,68 @@ void DialogInterface::setReaction(QReaction *reaction, bool deletePrev) {
 	_reaction = reaction;
 }
 
+void DialogInterface::playSound(const Common::String &name) {
+	removeSound();
+	_soundName = name;
+	Sound *s = g_vm->soundMgr()->addSound(name, Audio::Mixer::kSpeechSoundType);
+	if (s) {
+		Common::Rect bounds = g_vm->resMgr()->loadFlic(_talker->_resourceId)->getBounds();
+		s->setBalance(bounds.left + _talker->_x + bounds.width(), 640);
+		s->play(0);
+	}
+}
+
+void DialogInterface::setPhrase(const Common::U32String *text) {
+	uint16 textColor;
+	uint16 outlineColor;
+	if (_talker->_dialogColor == -1) {
+		textColor = g_system->getScreenFormat().RGBToColor(0xA, 0xA, 0xA);
+		outlineColor = 0xFFFF;
+	} else {
+		textColor = _talker->_dialogColor;
+		outlineColor = g_system->getScreenFormat().RGBToColor(0x7F, 0, 0);
+	}
+	_qsys->_mainInterface->setTextPhrase(*text, textColor, outlineColor);
+}
+
+void DialogInterface::onPlayOpcode(int prevTalkerId) {
+	int currTalkerId;
+	const char *soundName = nullptr;
+	const Common::U32String *text = _dialog->getSpeechInfo(&currTalkerId, &soundName, -1);
+
+	if (prevTalkerId != currTalkerId) {
+		sendMsg(kSaid);
+	}
+
+	_talker = _qsys->findObject(currTalkerId);
+	playSound(g_vm->getSpeechPath() + soundName);
+	setPhrase(text);
+
+	if (prevTalkerId != currTalkerId) {
+		sendMsg(kSay);
+	}
+	_state = kPlaying;
+}
+
+void DialogInterface::onMenuOpcode() {
+	removeSound();
+
+	sendMsg(kSaid);
+	_talker = nullptr;
+
+	Common::Array<Common::U32String> choices;
+	_dialog->getMenuChoices(choices);
+	_qsys->_mainInterface->setTextChoice(choices, 0xFFFF, g_system->getScreenFormat().RGBToColor(0xFF, 0, 0));
+
+	_qsys->_cursor->_isShown = true;
+	_state = kMenu;
+}
+
+void DialogInterface::onUserMsgOpcode() {
+	_qsys->_mainInterface->setTextPhrase(Common::U32String(""), 0, 0);
+	removeSound();
+	_talker = nullptr;
+	_state = kPlaying;
+}
+
 } // End of namespace Petka
diff --git a/engines/petka/interfaces/dialog_interface.h b/engines/petka/interfaces/dialog_interface.h
index 9dcd56a607..868065a2fd 100644
--- a/engines/petka/interfaces/dialog_interface.h
+++ b/engines/petka/interfaces/dialog_interface.h
@@ -35,6 +35,8 @@ enum DialogState {
 
 class Sound;
 class QMessageObject;
+class BigDialogue;
+class QSystem;
 struct QReaction;
 
 class DialogInterface {
@@ -44,28 +46,37 @@ public:
 
 	void start(uint id, QMessageObject *sender);
 	void next(int choice);
-	void end();
 
 	void startUserMsg(uint16 arg);
 	void endUserMsg();
 
-	Sound *findSound();
-	void removeSound();
-
 	bool isActive();
 
+	Sound *findSound();
+
 	void setSender(QMessageObject *sender);
 	void setReaction(QReaction *reaction, bool deletePrev = false);
 
 private:
+	void onPlayOpcode(int prevTalkerId);
+	void onMenuOpcode();
+	void onEndOpcode();
+	void onUserMsgOpcode();
+
+	void removeSound();
+
 	void sendMsg(uint16 opcode);
+	void setPhrase(const Common::U32String *text);
+	void playSound(const Common::String &name);
+
 	void initCursor();
 	void restoreCursor();
 
 private:
+	BigDialogue *_dialog;
+	QSystem *_qsys;
 	bool _isUserMsg;
 	bool _afterUserMsg;
-	bool _hasSound;
 	bool _firstTime;
 	int _id;
 	DialogState _state;
diff --git a/engines/petka/objects/text.cpp b/engines/petka/objects/text.cpp
index 29e2be2640..879b178d5b 100644
--- a/engines/petka/objects/text.cpp
+++ b/engines/petka/objects/text.cpp
@@ -119,7 +119,6 @@ void QTextPhrase::update(int time) {
 
 void QTextPhrase::onClick(int x, int y) {
 	DialogInterface &dialog = g_vm->getQSystem()->_mainInterface->_dialog;
-	dialog.removeSound();
 	dialog.next(-1);
 }
 


Commit: 5396b8a3fdbf1e0920337547058d9290180ec576
    https://github.com/scummvm/scummvm/commit/5396b8a3fdbf1e0920337547058d9290180ec576
Author: Andrei Prykhodko (whiterandrek at gmail.com)
Date: 2020-05-25T23:50:59+03:00

Commit Message:
PETKA: transfer reaction ownership clearer

Changed paths:
    engines/petka/interfaces/dialog_interface.cpp
    engines/petka/interfaces/dialog_interface.h
    engines/petka/objects/heroes.cpp
    engines/petka/objects/heroes.h
    engines/petka/objects/object.cpp
    engines/petka/objects/object.h


diff --git a/engines/petka/interfaces/dialog_interface.cpp b/engines/petka/interfaces/dialog_interface.cpp
index 6f1d02b907..69a55db425 100644
--- a/engines/petka/interfaces/dialog_interface.cpp
+++ b/engines/petka/interfaces/dialog_interface.cpp
@@ -140,8 +140,11 @@ void DialogInterface::onEndOpcode() {
 	_id = -1;
 	_qsys->_currInterface->removeTexts();
 	restoreCursor();
-	if (_reaction)
-		processSavedReaction(&_reaction, _sender);
+	if (_reaction) {
+		QReaction *reaction = _reaction;
+		_reaction = nullptr;
+		processSavedReaction(reaction, _sender);
+	}
 	_sender = nullptr;
 }
 
@@ -174,9 +177,8 @@ void DialogInterface::removeSound() {
 	_soundName.clear();
 }
 
-void DialogInterface::setReaction(QReaction *reaction, bool deletePrev) {
-	if (deletePrev)
-		delete _reaction;
+void DialogInterface::setReaction(QReaction *reaction) {
+	delete _reaction;
 	_reaction = reaction;
 }
 
diff --git a/engines/petka/interfaces/dialog_interface.h b/engines/petka/interfaces/dialog_interface.h
index 868065a2fd..a82974042e 100644
--- a/engines/petka/interfaces/dialog_interface.h
+++ b/engines/petka/interfaces/dialog_interface.h
@@ -55,7 +55,7 @@ public:
 	Sound *findSound();
 
 	void setSender(QMessageObject *sender);
-	void setReaction(QReaction *reaction, bool deletePrev = false);
+	void setReaction(QReaction *reaction);
 
 private:
 	void onPlayOpcode(int prevTalkerId);
diff --git a/engines/petka/objects/heroes.cpp b/engines/petka/objects/heroes.cpp
index 40dc2bab8f..2d52c0d11b 100644
--- a/engines/petka/objects/heroes.cpp
+++ b/engines/petka/objects/heroes.cpp
@@ -35,6 +35,7 @@ namespace Petka {
 QObjectPetka::QObjectPetka() {
 	_field7C = 1;
 	_reaction = nullptr;
+	_heroReaction = nullptr;
 	_sender = nullptr;
 	_isPetka = true;
 	_isWalking = false;
@@ -63,7 +64,9 @@ void QObjectPetka::processMessage(const QMessage &arg) {
 	}
 	if (msg.opcode != kWalk) {
 		if (msg.opcode == kWalked && _heroReaction) {
-			processSavedReaction(&_heroReaction, _sender);
+			QReaction *reaction = _heroReaction;
+			_heroReaction = nullptr;
+			processSavedReaction(reaction, _sender);
 		}
 		QMessageObject::processMessage(msg);
 		if (msg.opcode == kSet || msg.opcode == kPlay) {
@@ -221,8 +224,7 @@ void QObjectPetka::updateWalk() {
 	}
 }
 
-void QObjectPetka::setReactionAfterWalk(uint index, QReaction **reaction, QMessageObject *sender, bool deleteReaction) {
-	QReaction *r = *reaction;
+void QObjectPetka::setReactionAfterWalk(uint index, QReaction *reaction, QMessageObject *sender, bool deleteReaction) {
 	_heroReaction = nullptr;
 
 	stopWalk();
@@ -231,19 +233,12 @@ void QObjectPetka::setReactionAfterWalk(uint index, QReaction **reaction, QMessa
 	_heroReaction = new QReaction();
 	_sender = sender;
 
-	for (uint i = index + 1; i < r->messages.size(); ++i) {
-		_heroReaction->messages.push_back(r->messages[i]);
+	for (uint i = index + 1; i < reaction->messages.size(); ++i) {
+		_heroReaction->messages.push_back(reaction->messages[i]);
 	}
 
 	if (deleteReaction) {
-		if (r == *reaction) {
-			if (*reaction) {
-				delete *reaction;
-			}
-			*reaction = nullptr;
-		} else {
-			delete r;
-		}
+		delete reaction;
 	}
 
 }
diff --git a/engines/petka/objects/heroes.h b/engines/petka/objects/heroes.h
index d7d5250b8e..2eedd984c6 100644
--- a/engines/petka/objects/heroes.h
+++ b/engines/petka/objects/heroes.h
@@ -36,7 +36,7 @@ public:
 	void walk(int x, int y);
 	void stopWalk();
 	void updateWalk();
-	void setReactionAfterWalk(uint index, QReaction **reaction, QMessageObject *sender, bool deleteReaction);
+	void setReactionAfterWalk(uint index, QReaction *reaction, QMessageObject *sender, bool deleteReaction);
 
 	void draw() override;
 	void update(int time) override;
diff --git a/engines/petka/objects/object.cpp b/engines/petka/objects/object.cpp
index 22e181bee7..725e06da2b 100644
--- a/engines/petka/objects/object.cpp
+++ b/engines/petka/objects/object.cpp
@@ -70,10 +70,9 @@ QMessageObject::QMessageObject() {
 	_reaction = nullptr;
 }
 
-void processSavedReaction(QReaction **reaction, QMessageObject *sender) {
-	QReaction *r = *reaction;
-	for (uint i = 0; i < r->messages.size(); ++i) {
-		QMessage &msg = r->messages[i];
+void processSavedReaction(QReaction *reaction, QMessageObject *sender) {
+	for (uint i = 0; i < reaction->messages.size(); ++i) {
+		QMessage &msg = reaction->messages[i];
 		if (msg.opcode == kCheck && g_vm->getQSystem()->findObject(msg.objId)->_status != msg.arg1) {
 			break;
 		}
@@ -81,21 +80,22 @@ void processSavedReaction(QReaction **reaction, QMessageObject *sender) {
 		bool processed = true;
 		switch (msg.opcode) {
 		case kDialog: {
-			g_vm->getQSystem()->_mainInterface->_dialog.setReaction(createReaction(r->messages.data() + i + 1, r->messages.end()));
+			g_vm->getQSystem()->_mainInterface->_dialog.setReaction(createReaction(reaction->messages.data() + i + 1, reaction->messages.end()));
 			break;
 		}
 		case kPlay: {
 			QMessageObject *obj = g_vm->getQSystem()->findObject(msg.objId);
-			obj->_reaction = createReaction(r->messages.data() + i + 1, r->messages.end());
+			delete obj->_reaction;
+			obj->_reaction = createReaction(reaction->messages.data() + i + 1, reaction->messages.end());
 			obj->_reactionResId = msg.arg1;
 			break;
 		}
 		case kWalk:
 		case kWalkTo:
-			g_vm->getQSystem()->_petka->setReactionAfterWalk(i, reaction, sender, 1);
+			g_vm->getQSystem()->_petka->setReactionAfterWalk(i, reaction, sender, true);
 			return;
 		case kWalkVich:
-			g_vm->getQSystem()->_chapayev->setReactionAfterWalk(i, reaction, sender, 1);
+			g_vm->getQSystem()->_chapayev->setReactionAfterWalk(i, reaction, sender, true);
 			return;
 		default:
 			processed = false;
@@ -104,12 +104,7 @@ void processSavedReaction(QReaction **reaction, QMessageObject *sender) {
 		if (processed)
 			break;
 	}
-	if (*reaction != r) {
-		delete r;
-	} else if (*reaction) {
-		delete *reaction;
-		*reaction = nullptr;
-	}
+	delete reaction;
 }
 
 void QMessageObject::processMessage(const QMessage &msg) {
@@ -145,7 +140,7 @@ void QMessageObject::processMessage(const QMessage &msg) {
 			bool processed = true;
 			switch (rMsg.opcode) {
 			case kDialog: {
-				g_vm->getQSystem()->_mainInterface->_dialog.setReaction(createReaction(r->messages.data() + j + 1, r->messages.end()), true);
+				g_vm->getQSystem()->_mainInterface->_dialog.setReaction(createReaction(r->messages.data() + j + 1, r->messages.end()));
 				break;
 			}
 			case kPlay: {
@@ -157,10 +152,10 @@ void QMessageObject::processMessage(const QMessage &msg) {
 			}
 			case kWalk:
 			case kWalkTo:
-				g_vm->getQSystem()->_petka->setReactionAfterWalk(j, &r, this, 0);
+				g_vm->getQSystem()->_petka->setReactionAfterWalk(j, r, this, false);
 				break;
 			case kWalkVich:
-				g_vm->getQSystem()->_chapayev->setReactionAfterWalk(j, &r, this, 0);
+				g_vm->getQSystem()->_chapayev->setReactionAfterWalk(j, r, this, false);
 				break;
 			default:
 				processed = false;
@@ -254,7 +249,9 @@ void QMessageObject::processMessage(const QMessage &msg) {
 			break;
 		case kEnd:
 			if (_reaction && _reactionResId == msg.arg1) {
-				processSavedReaction(&_reaction, this);
+				QReaction *reaction = _reaction;
+				_reaction = nullptr;
+				processSavedReaction(reaction, this);
 			}
 			break;
 		case kStatus:
@@ -376,7 +373,7 @@ void QMessageObject::processMessage(const QMessage &msg) {
 				(r.senderId != -1 && r.senderId != msg.sender->_id)) {
 				continue;
 			}
-			g_vm->getQSystem()->_mainInterface->_dialog.setReaction(createReaction(r.messages.data(), r.messages.end()), true);
+			g_vm->getQSystem()->_mainInterface->_dialog.setReaction(createReaction(r.messages.data(), r.messages.end()));
 		}
 		g_vm->getBigDialogue()->setHandler(_id, msg.opcode);
 		g_vm->getQSystem()->_mainInterface->_dialog.start(msg.arg1, this);
diff --git a/engines/petka/objects/object.h b/engines/petka/objects/object.h
index 225d0b4a18..58e28fc290 100644
--- a/engines/petka/objects/object.h
+++ b/engines/petka/objects/object.h
@@ -27,7 +27,7 @@
 
 namespace Petka {
 
-extern void processSavedReaction(QReaction **reaction, QMessageObject *sender);
+extern void processSavedReaction(QReaction *reaction, QMessageObject *sender);
 
 class QVisibleObject {
 public:


Commit: ea0a0c7001c191256bf595105325d1fe136559b7
    https://github.com/scummvm/scummvm/commit/ea0a0c7001c191256bf595105325d1fe136559b7
Author: Andrei Prykhodko (whiterandrek at gmail.com)
Date: 2020-05-25T23:51:00+03:00

Commit Message:
PETKA: added QMessageObject::setReaction method

Changed paths:
    engines/petka/objects/object.cpp
    engines/petka/objects/object.h


diff --git a/engines/petka/objects/object.cpp b/engines/petka/objects/object.cpp
index 725e06da2b..b3b50f1b50 100644
--- a/engines/petka/objects/object.cpp
+++ b/engines/petka/objects/object.cpp
@@ -85,9 +85,7 @@ void processSavedReaction(QReaction *reaction, QMessageObject *sender) {
 		}
 		case kPlay: {
 			QMessageObject *obj = g_vm->getQSystem()->findObject(msg.objId);
-			delete obj->_reaction;
-			obj->_reaction = createReaction(reaction->messages.data() + i + 1, reaction->messages.end());
-			obj->_reactionResId = msg.arg1;
+			obj->setReaction(msg.arg1, createReaction(reaction->messages.data() + i + 1, reaction->messages.end()));
 			break;
 		}
 		case kWalk:
@@ -145,9 +143,7 @@ void QMessageObject::processMessage(const QMessage &msg) {
 			}
 			case kPlay: {
 				QMessageObject *obj = g_vm->getQSystem()->findObject(rMsg.objId);
-				delete obj->_reaction;
-				obj->_reaction = createReaction(r->messages.data() + j + 1, r->messages.end());
-				obj->_reactionResId = rMsg.arg1;
+				obj->setReaction(rMsg.arg1, createReaction(r->messages.data() + j + 1, r->messages.end()));
 				break;
 			}
 			case kWalk:
@@ -248,7 +244,7 @@ void QMessageObject::processMessage(const QMessage &msg) {
 			_animate = msg.arg1;
 			break;
 		case kEnd:
-			if (_reaction && _reactionResId == msg.arg1) {
+			if (_reaction && _reactionId == msg.arg1) {
 				QReaction *reaction = _reaction;
 				_reaction = nullptr;
 				processSavedReaction(reaction, this);
@@ -385,6 +381,12 @@ void QMessageObject::show(bool v) {
 	_isShown = v;
 }
 
+void QMessageObject::setReaction(int16 id, QReaction *reaction) {
+	delete _reaction;
+	_reaction = reaction;
+	_reactionId = id;
+}
+
 QObject::QObject() {
 	_animate = true;
 	_updateZ = true;
diff --git a/engines/petka/objects/object.h b/engines/petka/objects/object.h
index 58e28fc290..1b5bdcb098 100644
--- a/engines/petka/objects/object.h
+++ b/engines/petka/objects/object.h
@@ -55,6 +55,7 @@ public:
 	QMessageObject();
 
 	void show(bool v) override;
+	void setReaction(int16 id, QReaction *reaction);
 	virtual void processMessage(const QMessage &msg);
 
 public:
@@ -80,7 +81,7 @@ public:
 	int32 _dialogColor;
 	Common::Array<QReaction> _reactions;
 	QReaction *_reaction;
-	int16 _reactionResId;
+	int16 _reactionId;
 };
 
 




More information about the Scummvm-git-logs mailing list