Skip to content

Commit

Permalink
component.cpp: Additional connectors sanity checks
Browse files Browse the repository at this point in the history
  • Loading branch information
past-due committed Nov 17, 2023
1 parent 88ef893 commit 957c0d8
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,12 @@ static void sharedStructureButton(STRUCTURE_STATS *Stats, iIMDBaseShape *strBase
//draw Weapon/ECM/Sensor for structure
if (weaponImd[0] != nullptr)
{
for (int i = 0; i < MAX(1, Stats->numWeaps); i++)
for (uint32_t i = 0; i < MAX(1, Stats->numWeaps); i++)
{
if (i >= strImd->connectors.size())
{
break;
}
glm::mat4 localMatrix = glm::translate(glm::vec3(strImd->connectors[i].xzy()));
if (mountImd[i] != nullptr)
{
Expand Down Expand Up @@ -602,15 +606,15 @@ static bool displayCompObj(DROID *psDroid, bool bButton, const glm::mat4& modelM
float localHeightAboveTerrain = psDroid->heightAboveMap;

//to skip number of VTOL_CONNECTOR_START ground unit connectors
if (iConnector < VTOL_CONNECTOR_START)
size_t bodyConnectorIndex = (iConnector < VTOL_CONNECTOR_START) ? i : iConnector + i;
if (bodyConnectorIndex < psShapeBody->connectors.size())
{
localModelMatrix *= glm::translate(glm::vec3(psShapeBody->connectors[i].xzy()));
localHeightAboveTerrain += psShapeBody->connectors[i].z;
localModelMatrix *= glm::translate(glm::vec3(psShapeBody->connectors[bodyConnectorIndex].xzy()));
localHeightAboveTerrain += psShapeBody->connectors[bodyConnectorIndex].z;
}
else
{
localModelMatrix *= glm::translate(glm::vec3(psShapeBody->connectors[iConnector + i].xzy()));
localHeightAboveTerrain += (psShapeBody->connectors[iConnector + i]).z;
debug(LOG_INFO, "Model lacks sufficient connectors?: %s", psShapeBody->modelName.toUtf8().c_str());
}
localModelMatrix *= glm::rotate(UNDEG(-rot.direction), glm::vec3(0.f, 1.f, 0.f));

Expand Down

0 comments on commit 957c0d8

Please sign in to comment.