[Scummvm-git-logs] scummvm master -> c737b1d3e2020dc15581f2fdb86fbcbc41ac6e50
mgerhardy
martin.gerhardy at gmail.com
Wed Mar 24 05:52:36 UTC 2021
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:
c737b1d3e2 TWINE: added missing files
Commit: c737b1d3e2020dc15581f2fdb86fbcbc41ac6e50
https://github.com/scummvm/scummvm/commit/c737b1d3e2020dc15581f2fdb86fbcbc41ac6e50
Author: Martin Gerhardy (martin.gerhardy at gmail.com)
Date: 2021-03-24T06:51:53+01:00
Commit Message:
TWINE: added missing files
Changed paths:
A engines/twine/parser/holomap.cpp
A engines/twine/parser/holomap.h
diff --git a/engines/twine/parser/holomap.cpp b/engines/twine/parser/holomap.cpp
new file mode 100644
index 0000000000..3d7cb6e336
--- /dev/null
+++ b/engines/twine/parser/holomap.cpp
@@ -0,0 +1,51 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "twine/parser/holomap.h"
+#include "common/debug.h"
+#include "common/stream.h"
+
+namespace TwinE {
+
+bool TrajectoryData::loadFromStream(Common::SeekableReadStream &stream) {
+ _trajectories.clear();
+ _trajectories.reserve(100); // this is the lba1 amount of trajectories
+ while (stream.pos() < stream.size()) {
+ Trajectory data;
+ data.locationIdx = stream.readSint16LE();
+ data.trajLocationIdx = stream.readSint16LE();
+ data.vehicleIdx = stream.readSint16LE();
+ data.pos.x = stream.readSint16LE();
+ data.pos.y = stream.readSint16LE();
+ data.pos.z = stream.readSint16LE();
+ data.numAnimFrames = stream.readSint16LE();
+ assert(data.numAnimFrames < ARRAYSIZE(data.positions));
+ for (int32 i = 0; i < data.numAnimFrames; ++i) {
+ data.positions[i].x = stream.readSint16LE();
+ data.positions[i].y = stream.readSint16LE();
+ }
+ _trajectories.push_back(data);
+ }
+ return !stream.err();
+}
+
+} // End of namespace TwinE
diff --git a/engines/twine/parser/holomap.h b/engines/twine/parser/holomap.h
new file mode 100644
index 0000000000..255d7a6fc4
--- /dev/null
+++ b/engines/twine/parser/holomap.h
@@ -0,0 +1,91 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TWINE_PARSER_HOLOMAP_H
+#define TWINE_PARSER_HOLOMAP_H
+
+#include "common/memstream.h"
+#include "twine/parser/parser.h"
+
+namespace TwinE {
+
+enum HolomapVehicle {
+ FerryBoat = 31,
+ Motorbike = 33,
+ Car = 35,
+ FishingBoat = 37,
+ Catamaran = 39,
+ Hovercraft = 41,
+ Dino = 43,
+ ArmyBoat = 45,
+ HamalayiTransporter = 47
+};
+
+struct TrajectoryPos {
+ int16 x = 0;
+ int16 y = 0;
+};
+
+struct Trajectory {
+ int16 locationIdx = -1;
+ int16 trajLocationIdx = -1;
+ int16 vehicleIdx = -1;
+ IVec3 pos;
+ int16 numAnimFrames = 0;
+ TrajectoryPos positions[512];
+
+ bool isValid() const {
+ return locationIdx != -1;
+ }
+
+ /**
+ * The HQR index of the vehicle model for the holomap
+ * @note Multiplied by 2 because the model index is always followed by the corresponding animation index for that model
+ */
+ int32 getModel() const {
+ return 2 * vehicleIdx + HolomapVehicle::FerryBoat;
+ }
+
+ int32 getAnimation() const {
+ return getModel() + 1;
+ }
+};
+
+class TrajectoryData : public Parser {
+private:
+ Common::Array<Trajectory> _trajectories;
+
+public:
+ bool loadFromStream(Common::SeekableReadStream &stream) override;
+
+ const Trajectory *getTrajectory(int index) const {
+ return &_trajectories[index];
+ }
+
+ const Common::Array<Trajectory> &getTrajectories() const {
+ return _trajectories;
+ }
+};
+
+} // End of namespace TwinE
+
+#endif
More information about the Scummvm-git-logs
mailing list