From 3de8d6459677bb026c7b334dabfa6eb83f9d149e Mon Sep 17 00:00:00 2001
From: Pavel Solodovnikov <pavel.al.solodovnikov@gmail.com>
Date: Thu, 14 Dec 2023 00:27:06 +0300
Subject: [PATCH] Fix `getBaseObjFromId` for features

`player` should be just ignored for features,
always search `apsFeatureLists[0]`.

Signed-off-by: Pavel Solodovnikov <pavel.al.solodovnikov@gmail.com>
---
 src/objmem.cpp | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/src/objmem.cpp b/src/objmem.cpp
index 3f7e2e46ada..1f645bc170c 100644
--- a/src/objmem.cpp
+++ b/src/objmem.cpp
@@ -768,20 +768,17 @@ BASE_OBJECT *getBaseObjFromData(unsigned id, unsigned player, OBJECT_TYPE type)
 		}
 	case OBJ_FEATURE:
 		{
-			if (player == 0)
+			auto pFeat = getBaseObjFromId(apsFeatureLists[0], id);
+			if (pFeat)
 			{
-				auto pFeat = getBaseObjFromId(apsFeatureLists[0], id);
-				if (pFeat)
-				{
-					return pFeat;
-				}
-				pFeat = getBaseObjFromId(mission.apsFeatureLists[0], id);
-				if (pFeat)
-				{
-					return pFeat;
-				}
-				break;
+				return pFeat;
+			}
+			pFeat = getBaseObjFromId(mission.apsFeatureLists[0], id);
+			if (pFeat)
+			{
+				return pFeat;
 			}
+			break;
 		}
 	default:
 		break;
@@ -792,7 +789,8 @@ BASE_OBJECT *getBaseObjFromData(unsigned id, unsigned player, OBJECT_TYPE type)
 // Find a base object from it's id
 BASE_OBJECT *getBaseObjFromId(UDWORD id)
 {
-	for (size_t type = OBJ_DROID; type != OBJ_NUM_TYPES; ++type)
+	// Only cover OBJ_DROID, OBJ_STRUCTURE and OBJ_FEATURE types
+	for (size_t type = OBJ_DROID; type != OBJ_PROJECTILE; ++type)
 	{
 		for (size_t player = 0; player != MAX_PLAYERS; ++player)
 		{