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

joostp noreply at scummvm.org
Fri Aug 5 11:56:34 UTC 2022


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:
fea4f8bcfa ICB: ELDORADO: support loading newer El Dorado version of .set files


Commit: fea4f8bcfa19e0cd0c3d04744bcf5836d5101053
    https://github.com/scummvm/scummvm/commit/fea4f8bcfa19e0cd0c3d04744bcf5836d5101053
Author: Joost Peters (joostp at 7fc1.org)
Date: 2022-08-05T13:55:07+02:00

Commit Message:
ICB: ELDORADO: support loading newer El Dorado version of .set files

Changed paths:
    engines/icb/common/pc_props.h
    engines/icb/set_pc.cpp
    engines/icb/set_pc.h


diff --git a/engines/icb/common/pc_props.h b/engines/icb/common/pc_props.h
index f25b953a388..c04e3fa9276 100644
--- a/engines/icb/common/pc_props.h
+++ b/engines/icb/common/pc_props.h
@@ -34,7 +34,12 @@ namespace ICB {
 
 #define PCPROP_SCHEMA 3
 #define PCPROP_ID MKTAG('p', 'o', 'r', 'P')
-#define PCSETFILE_ID MKTAG('t', 'n', 'i', 'm')
+
+#define PCINTERACTIBLE_SCHEMA 2
+#define PCINTERACTIBLE_ID MKTAG('k', 'c', 'a', 'T')
+
+#define PCSETFILE_ID_ICB MKTAG('t', 'n', 'i', 'm')
+#define PCSETFILE_ID_ELDORADO MKTAG('t', 'n', 'i', 'p')
 
 typedef struct _pcSetHeader {
 	uint32 id;
@@ -43,8 +48,96 @@ typedef struct _pcSetHeader {
 	uint32 propOffset;
 	uint32 layerOffset;
 	uint32 backgroundOffset;
+	uint32 interactiblesOffset;
 } _pcSetHeader;
 
+class pcInteractible {
+private:
+	char name[32];
+	int32 width;
+	int32 height;
+	int32 x;
+	int32 y;
+	uint8 *mask;
+
+public:
+	pcInteractible(uint8 *interactiblePtr) {
+		uint8 *ptr = interactiblePtr;
+
+		memcpy(name, ptr, 32);
+		ptr += 32;
+
+		width = (int32)READ_LE_U32(ptr);
+		ptr += 4;
+
+		height = (int32)READ_LE_U32(ptr);
+		ptr += 4;
+
+		x = (int32)READ_LE_U32(ptr);
+		ptr += 4;
+
+		y = (int32)READ_LE_U32(ptr);
+		ptr += 4;
+
+		mask = ptr;
+	}
+};
+
+class pcInteractibleFile {
+private:
+	uint32 id;
+	uint32 schema;
+	uint32 mapping;
+	uint32 quantity;
+	pcInteractible **interactibles;
+
+public:
+	pcInteractibleFile() : id(PCINTERACTIBLE_ID), schema(PCINTERACTIBLE_SCHEMA), mapping(0), quantity(0), interactibles(nullptr) {}
+
+	pcInteractibleFile(uint8 *interactibleData) {
+		uint8 *ptr = interactibleData;
+
+		id = READ_LE_U32(ptr);
+		ptr += 4;
+
+		schema = READ_LE_U32(ptr);
+		ptr += 4;
+
+		mapping = READ_LE_U32(ptr);
+		ptr += 4;
+
+		quantity = READ_LE_U32(ptr);
+		ptr += 4;
+
+		interactibles = new pcInteractible *[quantity];
+		for (uint32 i = 0; i < quantity; i++) {
+			interactibles[i] = new pcInteractible(interactibleData + READ_LE_U32(ptr));
+			ptr += 4;
+		}
+	}
+
+	~pcInteractibleFile() {
+		for (uint32 i = 0; i < quantity; i++) {
+			delete interactibles[i];
+		}
+		delete[] interactibles;
+		interactibles = 0;
+	}
+
+	uint32 GetID() { return id; }
+	void SetId(uint32 i) { id = i; }
+	uint32 GetQty() { return quantity; }
+	void SetQty(uint32 q) { quantity = q; }
+	pcInteractible *GetInt(uint32 i) { return interactibles[i]; }
+	void SetSchema(uint32 s) { schema = s; }
+	uint32 GetSchema() const {
+		if (id != PCINTERACTIBLE_ID)
+			return 0;
+		else
+			return schema;
+	}
+};
+
 class pcPropRGBState {
 private:
 	uint16 *zPtrs[TILE_COUNT];
diff --git a/engines/icb/set_pc.cpp b/engines/icb/set_pc.cpp
index 76605216488..130b61370c9 100644
--- a/engines/icb/set_pc.cpp
+++ b/engines/icb/set_pc.cpp
@@ -613,8 +613,8 @@ bool8 _set::Init(const char *camera_name, const char *clustered_camera_name) {
 
 	// Load this camera
 	m_currentCamera = (_pcSetHeader *)rs_bg->Res_open(p_rcvf, p_rcvf_hash, set_cluster, set_cluster_hash);
-	if (FROM_LE_32(m_currentCamera->id) != PCSETFILE_ID)
-		Fatal_error("Unsupported set files. Set id is %d.  should be %d", FROM_LE_32(m_currentCamera->id), PCSETFILE_ID);
+	if (FROM_LE_32(m_currentCamera->id) != PCSETFILE_ID_ICB && FROM_LE_32(m_currentCamera->id) != PCSETFILE_ID_ELDORADO)
+		Fatal_error("Unsupported set files. Set id is %d.", FROM_LE_32(m_currentCamera->id));
 
 	// Hack the camera into the format we want.
 	HackMakeCamera();
@@ -1695,10 +1695,10 @@ void _set::DrawWeather() {
 
 void _set::HackMakeCamera() {
 	float *oldCameraData;
-	if (FROM_LE_32(m_currentCamera->id) == PCSETFILE_ID)
-		oldCameraData = (float *)(((uint8 *)m_currentCamera) + FROM_LE_32(m_currentCamera->cameraOffset));
-	else
-		oldCameraData = (float *)rs_bg->Res_open(rvcam_file_name, rvcam_file_hash, set_cluster, set_cluster_hash, 0);
+	if (FROM_LE_32(m_currentCamera->id) != PCSETFILE_ID_ICB && FROM_LE_32(m_currentCamera->id) != PCSETFILE_ID_ELDORADO)
+		Fatal_error("Illegal camera file.  SetID == %d", FROM_LE_32(m_currentCamera->id));
+
+	oldCameraData = (float *)(((uint8 *)m_currentCamera) + FROM_LE_32(m_currentCamera->cameraOffset));
 	/*   Old Camera Format
 	    -------------------
 
diff --git a/engines/icb/set_pc.h b/engines/icb/set_pc.h
index 2c751d2f2df..b01111eb7fc 100644
--- a/engines/icb/set_pc.h
+++ b/engines/icb/set_pc.h
@@ -78,6 +78,7 @@ public:
 	inline rlp_API *GetPRig();
 	inline pcStaticLayers *GetStaticLayers();
 	inline pcPropFile *GetProps();
+	inline pcInteractibleFile *GetInteractibles();
 	inline uint8 *GetBackground();
 	inline uint32 GetPropQty();
 	inline const char *GetPropName(uint32 n);
@@ -156,6 +157,18 @@ inline rlp_API *_set::GetPRig() { return (rlp_API *)(((uint8 *)m_currentCamera)
 
 inline pcStaticLayers *_set::GetStaticLayers() { return (pcStaticLayers *)(((uint8 *)m_currentCamera) + FROM_LE_32(m_currentCamera->layerOffset)); }
 
+inline pcInteractibleFile *_set::GetInteractibles() {
+	if (m_currentCamera->id == PCSETFILE_ID_ICB) {
+		static pcInteractibleFile temp;
+		temp.SetQty(0);
+		temp.SetSchema(PCINTERACTIBLE_SCHEMA);
+		temp.SetId(PCINTERACTIBLE_ID);
+		return &temp;
+	}
+	else
+		return (pcInteractibleFile *)(((uint8 *)m_currentCamera) + FROM_LE_32(m_currentCamera->interactiblesOffset));
+}
+
 inline pcPropFile *_set::GetProps() { return m_props; }
 
 inline uint8 *_set::GetBackground() { return (uint8 *)(((uint8 *)m_currentCamera) + FROM_LE_32(m_currentCamera->backgroundOffset)); }




More information about the Scummvm-git-logs mailing list