Skip to content

Commit

Permalink
Fix some msvc warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarod42 committed Mar 7, 2024
1 parent 79271bc commit 597d11d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 26 deletions.
10 changes: 7 additions & 3 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,7 @@ end
disablewarnings {
"4100", -- '%var': unreferenced formal parameter
"4013", -- '$func' undefined, assuming extern return int
"4456", -- declaration of '$var' hides previous local declaration
"4457", -- declaration of '$var' hides function parameter
"4458", -- declaration of '$var' hides class member
"4459", -- declaration of '$var' hides global declaration
"4701", -- potentially uninitialized local variable '$var' used
"4703", -- potentially uninitialized local pointer variable '$var' used
"4996", -- '$func': The POSIX name of this item is deprecated. Instead, use the ISO C and C++ conformant name: $func2. See online help for details.
Expand Down Expand Up @@ -124,6 +121,7 @@ project "resinstaller"
filter { "toolset:msc*" }
disablewarnings {
"4244", -- '=': conversion from '$type1' to '$type2', possible loss of data
"4456", -- declaration of '$var' hides previous local declaration
}
filter "action:not vs*"
if vorbis_headerPath then
Expand Down Expand Up @@ -198,6 +196,12 @@ project "tests"
links { "maxr_lib" }
linksToCrashRpt()

filter { "toolset:msc*" }
disablewarnings {
"4459", -- declaration of '$var' hides global declaration
}
filter {}

project "maxr_lib"
kind "StaticLib"

Expand Down
6 changes: 3 additions & 3 deletions src/lib/game/logic/action/actionfinishbuild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,13 @@ void cActionFinishBuild::finishAVehicle (cModel& model, cBuilding& building) con

if (!building.isBuildListEmpty())
{
cBuildListItem& buildingListItem = building.getBuildListItem (0);
cBuildListItem& nextBuildingListItem = building.getBuildListItem (0);
if (buildingListItem.getRemainingMetal() == -1)
{
std::array<int, 3> turboBuildRounds;
std::array<int, 3> turboBuildCosts;
building.calcTurboBuild (turboBuildRounds, turboBuildCosts, player->getLastUnitData (buildingListItem.getType())->getBuildCost());
buildingListItem.setRemainingMetal (turboBuildCosts[building.getBuildSpeed()]);
building.calcTurboBuild (turboBuildRounds, turboBuildCosts, player->getLastUnitData (nextBuildingListItem.getType())->getBuildCost());
nextBuildingListItem.setRemainingMetal (turboBuildCosts[building.getBuildSpeed()]);
}
building.startWork();
}
Expand Down
12 changes: 6 additions & 6 deletions src/lib/game/logic/surveyorai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,13 @@ float cSurveyorAi::calcFactor (const cPosition& position, const std::forward_lis
{
for (int y = miny; y <= maxy; ++y)
{
const cPosition position (x, y);
if (positionHasBeenSurveyedByPath (position, path)) continue;
const cPosition aroundPosition (x, y);
if (positionHasBeenSurveyedByPath (aroundPosition, path)) continue;

if (!owner.hasResourceExplored (position)) //&& !map.isBlocked (position))
if (!owner.hasResourceExplored (aroundPosition)) //&& !map.isBlocked (aroundPosition))
{
nrSurvFields++;
if (hasAdjacentResources (position, map))
if (hasAdjacentResources (aroundPosition, map))
{
// spots with adjacent revealed resources have a high probability
// for more resources
Expand Down Expand Up @@ -345,9 +345,9 @@ bool cSurveyorAi::hasAdjacentResources (const cPosition& position, const cMap& m
{
for (int y = miny; y <= maxy; ++y)
{
const cPosition position (x, y);
const cPosition aroundPosition (x, y);

if (owner.hasResourceExplored (position) && map.getResource (position).typ != eResourceType::None)
if (owner.hasResourceExplored (aroundPosition) && map.getResource (aroundPosition).typ != eResourceType::None)
{
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/graphical/game/control/rightmousebuttonscroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ bool cRightMouseButtonScrollerWidget::isScrolling() const
}

//------------------------------------------------------------------------------
bool cRightMouseButtonScrollerWidget::handleMouseMoved (cApplication& application, cMouse& mouse, const cPosition& offset)
bool cRightMouseButtonScrollerWidget::handleMouseMoved (cApplication& application, cMouse& mouse, const cPosition&)
{
if (hasStartedScrolling)
{
Expand Down
26 changes: 13 additions & 13 deletions src/ui/graphical/game/gamegui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,19 +753,6 @@ void cGameGui::updateSelectedUnitIdleSound()
{
stopSelectedUnitSound();
}
else if (const auto* building = dynamic_cast<const cBuilding*> (selectedUnit))
{
auto& uiData = UnitsUiData.getBuildingUI (*building);

if (building->isUnitWorking())
{
startSelectedUnitSound (*building, uiData.Running);
}
else
{
startSelectedUnitSound (*building, uiData.Wait);
}
}
else if (const auto* vehicle = dynamic_cast<const cVehicle*> (selectedUnit))
{
auto* uiData = UnitsUiData.getVehicleUI (vehicle->getStaticUnitData().ID);
Expand All @@ -791,6 +778,19 @@ void cGameGui::updateSelectedUnitIdleSound()
startSelectedUnitSound (*vehicle, uiData->Wait);
}
}
else if (const auto* building = dynamic_cast<const cBuilding*> (selectedUnit))
{
auto& uiData = UnitsUiData.getBuildingUI (*building);

if (building->isUnitWorking())
{
startSelectedUnitSound (*building, uiData.Running);
}
else
{
startSelectedUnitSound (*building, uiData.Wait);
}
}
}

//------------------------------------------------------------------------------
Expand Down

0 comments on commit 597d11d

Please sign in to comment.