PETKA: implemented handling dialog opcode 0x2 when engine needs speech info

This commit is contained in:
Andrei Prykhodko 2019-07-25 08:40:23 +03:00 committed by Eugene Sandulenko
parent a366e65aad
commit 464718e896
3 changed files with 32 additions and 7 deletions

View File

@ -100,14 +100,39 @@ void BigDialogue::loadSpeechesInfo() {
delete[] str;
}
const SpeechInfo *BigDialogue::getSpeechInfo() {
const SpeechInfo *BigDialogue::getSpeechInfo(int unk) {
if (!_ip)
return nullptr;
int *oldIp = _ip;
int op = *_ip;
byte opcode = (byte)(*_ip >> 24);
switch (opcode) {
case 2:
// not implemented
break;
case 2: {
int unk1 = 1;
byte arg = (byte)*_ip;
if (arg <= unk || unk >= 0) {
break;
}
while (true) {
_ip += 1;
if (unk == 0 && (unk1 & ((op >> 8) & 0xFFFF)))
break;
if ((*_ip >> 24) == 0x1) {
if (unk1 & ((op >> 8) & 0xFFFF))
unk--;
unk1 *= 2;
}
}
if ((*_ip >> 24) != 0x7)
sub40B670(-1);
if ((*_ip >> 24) != 0x7) {
_ip = oldIp;
break;
}
uint index = (uint16)*_ip;
_ip = oldIp;
return &_speeches[index];
}
case 8:
_ip += 1;
for (uint i = 0; i < ((*_ip >> 16) & 0xFF); ++i) {

View File

@ -69,7 +69,7 @@ public:
const Dialog *findDialog(uint objId, uint opcode, bool *res) const;
void setDialog(uint objId, uint opcode, int index);
const SpeechInfo *getSpeechInfo();
const SpeechInfo *getSpeechInfo(int unk);
private:
void loadSpeechesInfo();

View File

@ -81,7 +81,7 @@ void DialogInterface::sub_4155D0(int a) {
return;
int talkerId = -1;
if (a == -1 && !_field8) {
talkerId = g_vm->getBigDialogue()->getSpeechInfo()->speakerId;
talkerId = g_vm->getBigDialogue()->getSpeechInfo(-1)->speakerId;
}
_field8 = _field4;
g_vm->getQSystem()->_cursor.get()->_isShown = 0;
@ -93,7 +93,7 @@ void DialogInterface::sub_4155D0(int a) {
g_vm->getBigDialogue()->sub40B670(a);
switch (g_vm->getBigDialogue()->opcode()) {
case 1: {
const SpeechInfo *info = g_vm->getBigDialogue()->getSpeechInfo();
const SpeechInfo *info = g_vm->getBigDialogue()->getSpeechInfo(-1);
g_vm->soundMgr()->removeSound(_soundName);
if (talkerId != info->speakerId) {
sendMsg(kSaid);