Skip to content

Commit

Permalink
STRUCTURE: change structureIsBlueprint() free function into `isBlue…
Browse files Browse the repository at this point in the history
…print()` member function

Signed-off-by: Pavel Solodovnikov <[email protected]>
  • Loading branch information
ManManson committed Jan 16, 2024
1 parent 9e346a3 commit 656a775
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2125,7 +2125,7 @@ static void dealWithLMBDClick()
{
/* We clicked on structure */
psStructure = (STRUCTURE *) psClickedOn;
if (psStructure->player == selectedPlayer && !structureIsBlueprint(psStructure))
if (psStructure->player == selectedPlayer && !psStructure->isBlueprint())
{
if (psStructure->isFactory())
{
Expand Down Expand Up @@ -2277,7 +2277,7 @@ static void dealWithRMB()
triggerEventSelected();
jsDebugSelected(psStructure);
}
else if (!structureIsBlueprint(psStructure))
else if (!psStructure->isBlueprint())
{
clearSelection();

Expand Down
12 changes: 6 additions & 6 deletions src/display3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ static PIELIGHT structureBrightness(STRUCTURE *psStructure)
{
PIELIGHT buildingBrightness;

if (structureIsBlueprint(psStructure))
if (psStructure->isBlueprint())
{
buildingBrightness = getBlueprintColour(psStructure->status);
}
Expand Down Expand Up @@ -2663,7 +2663,7 @@ static void renderStructureTurrets(STRUCTURE *psStructure, iIMDShape *strImd, PI
}

// flags for drawing weapons
if (structureIsBlueprint(psStructure))
if (psStructure->isBlueprint())
{
pieFlag = pie_TRANSLUCENT;
pieFlagData = BLUEPRINT_OPACITY;
Expand Down Expand Up @@ -2874,7 +2874,7 @@ void renderStructure(STRUCTURE *psStructure, const glm::mat4 &viewMatrix, const
/* Draw the building's base first */
if (psStructure->pStructureType->pBaseIMD != nullptr)
{
if (structureIsBlueprint(psStructure))
if (psStructure->isBlueprint())
{
pieFlagData = BLUEPRINT_OPACITY;
}
Expand Down Expand Up @@ -2920,7 +2920,7 @@ void renderStructure(STRUCTURE *psStructure, const glm::mat4 &viewMatrix, const
return;
}

if (structureIsBlueprint(psStructure))
if (psStructure->isBlueprint())
{
pieFlag = pie_TRANSLUCENT;
pieFlagData = BLUEPRINT_OPACITY;
Expand All @@ -2941,7 +2941,7 @@ void renderStructure(STRUCTURE *psStructure, const glm::mat4 &viewMatrix, const
while (strImd)
{
float stretch = 0.f;
if (defensive && !structureIsBlueprint(psStructure) && !(strImd->flags & iV_IMD_NOSTRETCH))
if (defensive && !psStructure->isBlueprint() && !(strImd->flags & iV_IMD_NOSTRETCH))
{
stretch = psStructure->pos.z - psStructure->foundationDepth;
}
Expand Down Expand Up @@ -3049,7 +3049,7 @@ static bool renderWallSection(STRUCTURE *psStructure, const glm::mat4 &viewMatri
}
else
{
if (structureIsBlueprint(psStructure))
if (psStructure->isBlueprint())
{
pieFlag = pie_TRANSLUCENT;
pieFlagData = BLUEPRINT_OPACITY;
Expand Down
12 changes: 6 additions & 6 deletions src/structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,17 +226,17 @@ static int numStructureModules(STRUCTURE const *psStruct)
return psStruct->capacity;
}

bool structureIsBlueprint(const STRUCTURE *psStructure)
bool STRUCTURE::isBlueprint() const
{
return (psStructure->status == SS_BLUEPRINT_VALID ||
psStructure->status == SS_BLUEPRINT_INVALID ||
psStructure->status == SS_BLUEPRINT_PLANNED ||
psStructure->status == SS_BLUEPRINT_PLANNED_BY_ALLY);
return (status == SS_BLUEPRINT_VALID ||
status == SS_BLUEPRINT_INVALID ||
status == SS_BLUEPRINT_PLANNED ||
status == SS_BLUEPRINT_PLANNED_BY_ALLY);
}

bool isBlueprint(const BASE_OBJECT *psObject)
{
return psObject != nullptr && psObject->type == OBJ_STRUCTURE && structureIsBlueprint((const STRUCTURE *)psObject);
return psObject != nullptr && psObject->type == OBJ_STRUCTURE && ((const STRUCTURE*)psObject)->isBlueprint();
}

void initStructLimits()
Expand Down
1 change: 0 additions & 1 deletion src/structure.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ void changeProductionPlayer(UBYTE player);
bool IsStatExpansionModule(const STRUCTURE_STATS *psStats);

/// is this a blueprint and not a real structure?
bool structureIsBlueprint(const STRUCTURE *psStructure);
bool isBlueprint(const BASE_OBJECT *psObject);

/*returns the power cost to build this structure, or to add its next module */
Expand Down
2 changes: 2 additions & 0 deletions src/structuredef.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ struct STRUCTURE : public BASE_OBJECT
uint32_t structureBody() const;
// Just returns true if the structure's present body points aren't as high as the original
bool isDamaged() const;
// is this a blueprint and not a real structure?
bool isBlueprint() const;

STRUCTURE_STATS *pStructureType; /* pointer to the structure stats for this type of building */
STRUCT_STATES status; /* defines whether the structure is being built, doing nothing or performing a function */
Expand Down

0 comments on commit 656a775

Please sign in to comment.