[Scummvm-git-logs] scummvm master -> f97d040591080ee2d30b054cfc3ed1ecfb126d31
whiterandrek
whiterandrek at gmail.com
Thu May 28 23:19:30 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
f97d040591 PETKA: created methods for loading objects data
Commit: f97d040591080ee2d30b054cfc3ed1ecfb126d31
https://github.com/scummvm/scummvm/commit/f97d040591080ee2d30b054cfc3ed1ecfb126d31
Author: Andrei Prykhodko (whiterandrek at gmail.com)
Date: 2020-05-29T02:19:12+03:00
Commit Message:
PETKA: created methods for loading objects data
Changed paths:
engines/petka/objects/object.cpp
engines/petka/objects/object.h
engines/petka/objects/object_bg.cpp
engines/petka/objects/object_bg.h
engines/petka/petka.cpp
engines/petka/q_system.cpp
diff --git a/engines/petka/objects/object.cpp b/engines/petka/objects/object.cpp
index c397cf12f4..069aab4e00 100644
--- a/engines/petka/objects/object.cpp
+++ b/engines/petka/objects/object.cpp
@@ -367,6 +367,47 @@ void QMessageObject::removeSound() {
_sound = nullptr;
}
+static Common::String readString(Common::ReadStream &readStream) {
+ uint32 stringSize = readStream.readUint32LE();
+ byte *data = (byte *)malloc(stringSize + 1);
+ readStream.read(data, stringSize);
+ data[stringSize] = '\0';
+ Common::String str((char *)data);
+ return str;
+}
+
+void QMessageObject::readScriptData(Common::SeekableReadStream &stream) {
+ _id = stream.readUint16LE();
+ _name = readString(stream);
+ _reactions.resize(stream.readUint32LE());
+
+ for (uint i = 0; i < _reactions.size(); ++i) {
+ QReaction *reaction = &_reactions[i];
+ reaction->opcode = stream.readUint16LE();
+ reaction->status = stream.readByte();
+ reaction->senderId = stream.readUint16LE();
+ reaction->messages.resize(stream.readUint32LE());
+ for (uint j = 0; j < reaction->messages.size(); ++j) {
+ QMessage *msg = &reaction->messages[j];
+ msg->objId = stream.readUint16LE();
+ msg->opcode = stream.readUint16LE();
+ msg->arg1 = stream.readUint16LE();
+ msg->arg2 = stream.readUint16LE();
+ msg->arg3 = stream.readUint16LE();
+ }
+ }
+}
+
+void QMessageObject::readInisData(Common::INIFile &names, Common::INIFile &cast, Common::INIFile *bgs) {
+ names.getKey(_name, "all", _nameOnScreen);
+ Common::String rgbString;
+ if (cast.getKey(_name, "all", rgbString)) {
+ int r, g, b;
+ sscanf(rgbString.c_str(), "%d %d %d", &r, &g, &b);
+ _dialogColor = g_vm->_system->getScreenFormat().RGBToColor((byte)r, (byte)g, (byte)b);
+ }
+}
+
QObject::QObject() {
_animate = true;
_updateZ = true;
diff --git a/engines/petka/objects/object.h b/engines/petka/objects/object.h
index 246c9d871d..6c726211f7 100644
--- a/engines/petka/objects/object.h
+++ b/engines/petka/objects/object.h
@@ -25,6 +25,11 @@
#include "petka/base.h"
+namespace Common {
+class INIFile;
+class SeekableReadStream;
+}
+
namespace Petka {
class QVisibleObject {
@@ -62,6 +67,9 @@ public:
void loadSound();
void removeSound();
+ void readScriptData(Common::SeekableReadStream &stream);
+ virtual void readInisData(Common::INIFile &names, Common::INIFile &cast, Common::INIFile *bgs);
+
public:
int32 _x;
int32 _y;
diff --git a/engines/petka/objects/object_bg.cpp b/engines/petka/objects/object_bg.cpp
index 3f18f6e676..6f25b63834 100644
--- a/engines/petka/objects/object_bg.cpp
+++ b/engines/petka/objects/object_bg.cpp
@@ -141,4 +141,18 @@ void QObjectBG::setEntrance(const Common::String &name) {
g_vm->videoSystem()->makeAllDirty();
}
+void QObjectBG::readInisData(Common::INIFile &names, Common::INIFile &cast, Common::INIFile *bgs) {
+ if (bgs) {
+ Common::String perspective;
+ bgs->getKey(_name, "Settings", perspective);
+ if (!perspective.empty()) {
+ // todo store this structure in bg object
+ UnkStruct unk;
+ sscanf(perspective.c_str(), "%lf %lf %d %d %lf", &unk.f1, &unk.f2, &unk.f3, &unk.f4, &unk.f5);
+ g_vm->getQSystem()->_unkMap.setVal(_name, unk);
+ }
+ }
+ QMessageObject::readInisData(names, cast, bgs);
+}
+
}
diff --git a/engines/petka/objects/object_bg.h b/engines/petka/objects/object_bg.h
index 90f182a0dd..41e3082cf9 100644
--- a/engines/petka/objects/object_bg.h
+++ b/engines/petka/objects/object_bg.h
@@ -36,6 +36,8 @@ public:
void setEntrance(const Common::String &name);
void play(int id, int type) override {}
+ void readInisData(Common::INIFile &names, Common::INIFile &cast, Common::INIFile *bgs) override;
+
public:
int _showMap;
int _fxId;
diff --git a/engines/petka/petka.cpp b/engines/petka/petka.cpp
index 04a5717b01..01043bdf05 100644
--- a/engines/petka/petka.cpp
+++ b/engines/petka/petka.cpp
@@ -294,14 +294,7 @@ void PetkaEngine::loadChapter(byte chapter) {
for (uint i = 0; i < _qsystem->_allObjects.size(); ++i) {
QMessageObject *obj = _qsystem->_allObjects[i];
- namesIni.getKey(obj->_name, "all", obj->_nameOnScreen);
-
- Common::String rgbString;
- if (castIni.getKey(obj->_name, "all", rgbString)) {
- int r, g, b;
- sscanf(rgbString.c_str(), "%d %d %d", &r, &g, &b);
- obj->_dialogColor = g_vm->_system->getScreenFormat().RGBToColor((byte)r, (byte)g, (byte)b);
- }
+ obj->readInisData(namesIni, castIni, nullptr);
}
_chapter = chapter;
}
diff --git a/engines/petka/q_system.cpp b/engines/petka/q_system.cpp
index bc0c4bf2cf..f1844e0317 100644
--- a/engines/petka/q_system.cpp
+++ b/engines/petka/q_system.cpp
@@ -125,34 +125,23 @@ bool QSystem::init() {
_bgs.resize(bgsCount);
_petka.reset(new QObjectPetka());
- readObject(*_petka, *stream, namesIni, castIni);
+ _petka->readScriptData(*stream);
+ _petka->readInisData(namesIni, castIni, nullptr);
_allObjects.push_back(_petka.get());
_chapayev.reset(new QObjectChapayev());
- readObject(*_chapayev, *stream, namesIni, castIni);
+ _chapayev->readScriptData(*stream);
+ _chapayev->readInisData(namesIni, castIni, nullptr);
_allObjects.push_back(_chapayev.get());
for (uint i = 0; i < objsCount; ++i) {
- readObject(_objs[i], *stream, namesIni, castIni);
+ _objs[i].readScriptData(*stream);
+ _objs[i].readInisData(namesIni, castIni, nullptr);
_allObjects.push_back(&_objs[i]);
}
for (uint i = 0; i < bgsCount; ++i) {
- readObject(_bgs[i], *stream, namesIni, castIni);
-
-
- Common::String val;
- bgsIni.getKey(_bgs[i]._name, "Settings", val);
-
- if (!val.empty()) {
- UnkStruct unk;
-
- sscanf(val.c_str(), "%lf %lf %d %d %lf", &unk.f1, &unk.f2, &unk.f3, &unk.f4, &unk.f5);
-
- _unkMap.setVal(_bgs[i]._name, unk);
- }
-
-
-
+ _bgs[i].readScriptData(*stream);
+ _bgs[i].readInisData(namesIni, castIni, &bgsIni);
_allObjects.push_back(&_bgs[i]);
}
More information about the Scummvm-git-logs
mailing list