Skip to content

Commit

Permalink
Fix getBaseObjFromId for features
Browse files Browse the repository at this point in the history
`player` should be just ignored for features,
always search `apsFeatureLists[0]`.

Signed-off-by: Pavel Solodovnikov <[email protected]>
  • Loading branch information
ManManson committed Dec 13, 2023
1 parent 5722d9d commit 3de8d64
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/objmem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
{
Expand Down

0 comments on commit 3de8d64

Please sign in to comment.