diff --git a/src/component.cpp b/src/component.cpp index ef4a8e79153..e198a3639f7 100644 --- a/src/component.cpp +++ b/src/component.cpp @@ -167,12 +167,11 @@ UDWORD getStructureStatHeight(STRUCTURE_STATS *psStat) static void draw_player_3d_shape(uint32_t player_index, iIMDShape *shape, const glm::mat4 &modelMatrix) { - for (iIMDShape *imd = shape; imd != nullptr; imd = imd->next) + for (iIMDShape *imd = getFactionIMD(getPlayerFaction(player_index), shape); imd != nullptr; imd = imd->next) { - auto faction_shape = getFactionIMD(getPlayerFaction(player_index), imd); int team = getPlayerColour(player_index); const PIELIGHT teamcolour = pal_GetTeamColour(team); - pie_Draw3DButton(faction_shape, teamcolour, modelMatrix, glm::mat4(1.f)); + pie_Draw3DButton(imd, teamcolour, modelMatrix, glm::mat4(1.f)); } } diff --git a/src/display3d.cpp b/src/display3d.cpp index 929bfd68c5b..6a30564001b 100644 --- a/src/display3d.cpp +++ b/src/display3d.cpp @@ -2670,9 +2670,9 @@ void renderStructure(STRUCTURE *psStructure, const glm::mat4 &viewMatrix, const const Vector3i dv = Vector3i(psStructure->pos.x, psStructure->pos.z, -(psStructure->pos.y)); bool bHitByElectronic = false; bool defensive = false; - iIMDShape *strImd = psStructure->sDisplay.imd; - MAPTILE *psTile = worldTile(psStructure->pos.x, psStructure->pos.y); const FACTION *faction = getPlayerFaction(psStructure->player); + iIMDShape *strImd = getFactionIMD(faction, psStructure->sDisplay.imd); + MAPTILE *psTile = worldTile(psStructure->pos.x, psStructure->pos.y); glm::mat4 modelMatrix = glm::translate(glm::vec3(dv)) * glm::rotate(UNDEG(-psStructure->rot.direction), glm::vec3(0.f, 1.f, 0.f)); @@ -2766,7 +2766,7 @@ void renderStructure(STRUCTURE *psStructure, const glm::mat4 &viewMatrix, const } if (strImd) { - pie_Draw3DShape(getFactionIMD(faction, strImd), 0, colour, buildingBrightness, pie_HEIGHT_SCALED | pie_SHADOW, static_cast(structHeightScale(psStructure) * pie_RAISE_SCALE), modelMatrix, viewMatrix); + pie_Draw3DShape(strImd, 0, colour, buildingBrightness, pie_HEIGHT_SCALED | pie_SHADOW, static_cast(structHeightScale(psStructure) * pie_RAISE_SCALE), modelMatrix, viewMatrix); } setScreenDispWithPerspective(&psStructure->sDisplay, perspectiveViewMatrix * modelMatrix); return; @@ -2797,10 +2797,10 @@ void renderStructure(STRUCTURE *psStructure, const glm::mat4 &viewMatrix, const { stretch = psStructure->pos.z - psStructure->foundationDepth; } - drawShape(psStructure, getFactionIMD(faction, strImd), colour, buildingBrightness, pieFlag, pieFlagData, modelMatrix, viewMatrix, stretch); - if (psStructure->sDisplay.imd->nconnectors > 0) + drawShape(psStructure, strImd, colour, buildingBrightness, pieFlag, pieFlagData, modelMatrix, viewMatrix, stretch); + if (strImd->nconnectors > 0) { - renderStructureTurrets(psStructure, getFactionIMD(faction, strImd), buildingBrightness, pieFlag, pieFlagData, ecmFlag, modelMatrix, viewMatrix); + renderStructureTurrets(psStructure, strImd, buildingBrightness, pieFlag, pieFlagData, ecmFlag, modelMatrix, viewMatrix); } strImd = strImd->next; } diff --git a/src/faction.cpp b/src/faction.cpp index 08f23825416..6a4814c5c8a 100644 --- a/src/faction.cpp +++ b/src/faction.cpp @@ -217,17 +217,3 @@ const char* to_localized_string(FactionID faction) } return ""; // silence warning - switch above should be complete } - -void addFactionModelNameMapping(FACTION *faction, const WzString& normalFactionName, const WzString& mappedName) -{ - auto result = faction->replaceIMD.insert(FACTION::ReplaceIMDMap::value_type(normalFactionName, mappedName)); - if (!result.second) - { - debug(LOG_INFO, "Already inserted this mapping (%s: %s -> %s)", faction->name.toUtf8().c_str(), normalFactionName.toUtf8().c_str(), mappedName.toUtf8().c_str()); - } -} - -void addFactionModelNameMapping(FactionID faction, const WzString& normalFactionName, const WzString& mappedName) -{ - addFactionModelNameMapping(&(factions[(uint8_t)faction]), normalFactionName, mappedName); -} diff --git a/src/faction.h b/src/faction.h index 05f70b1002f..43f1f52d3f8 100644 --- a/src/faction.h +++ b/src/faction.h @@ -54,7 +54,4 @@ std::unordered_set getEnabledFactions(bool ignoreNormalFaction = fals const char* to_string(FactionID faction); const char* to_localized_string(FactionID faction); -void addFactionModelNameMapping(FACTION *faction, const WzString& normalFactionName, const WzString& mappedName); -void addFactionModelNameMapping(FactionID faction, const WzString& normalFactionName, const WzString& mappedName); - #endif diff --git a/src/levels.cpp b/src/levels.cpp index 9348e9d7d13..406c730a5de 100644 --- a/src/levels.cpp +++ b/src/levels.cpp @@ -987,15 +987,6 @@ bool levLoadData(char const *name, Sha256 const *hash, char *pSaveName, GAME_TYP iIMDShape *retval = modelGet(factionModel.value()); ASSERT(retval != nullptr, "Cannot find the faction PIE model %s (for normal model: %s)", factionModel.value().toUtf8().c_str(), modelName.c_str()); - for (const iIMDShape *pIMD = retval, *pNormalIMD = &s; pIMD != nullptr && pNormalIMD != nullptr; pIMD = pIMD->next, pNormalIMD = pNormalIMD->next) - { - if (pIMD->modelLevel <= 0) - { - continue; - } - // Must add mapping to faction IMD lookup table for all additional level modelNames (these have _ appended) - addFactionModelNameMapping(faction, pNormalIMD->modelName, pIMD->modelName); - } } } });