Skip to content

Commit

Permalink
Merge pull request #520 from Wargus/clean_up
Browse files Browse the repository at this point in the history
Remove trailing space.
  • Loading branch information
Jarod42 authored Sep 30, 2023
2 parents a5c2e61 + 5262e09 commit 5555720
Show file tree
Hide file tree
Showing 74 changed files with 510 additions and 528 deletions.
2 changes: 1 addition & 1 deletion doc/lua/generate_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def extract_docstring(filename, c_func):


PLUGIN_PREAMBLE = r"""
-- Start copy from spec/lua.lua
-- Start copy from spec/lua.lua
local unpack = table.unpack or unpack
local funcdef = "([A-Za-z_][A-Za-z0-9_%.%:]*)%s*"
local decindent = {
Expand Down
2 changes: 1 addition & 1 deletion gameheaders/stratagus-game-launcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ static void ExtractData(char* extractor_tool, const char *const extractor_args[]

#ifndef WIN32
if (!fs::exists(sourcepath)) {
// deployment time path might be same as extractor
// deployment time path might be same as extractor
strcpy(sourcepath, fs::path(extractor_tool).parent_path().string().c_str());
}
#endif
Expand Down
24 changes: 12 additions & 12 deletions src/action/action_attack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ PixelPos COrder_Attack::Show(const CViewport &vp,
bool isAttackMove = IsAutoTargeting();

targetPos = this->HasGoal() ? vp.MapToScreenPixelPos(this->GetGoal()->GetMapPixelPosCenter())
: IsMovingToAttackPos() ? vp.TilePosToScreen_Center(this->attackMovePos)
: IsMovingToAttackPos() ? vp.TilePosToScreen_Center(this->attackMovePos)
: vp.TilePosToScreen_Center(this->goalPos);

orderedPos = isAttackMove ? vp.TilePosToScreen_Center(this->attackMovePos)
Expand Down Expand Up @@ -340,7 +340,7 @@ CUnit *COrder_Attack::BestTarget(const CUnit &unit, CUnit *const target1, CUnit
Assert(target1 != nullptr);
Assert(target2 != nullptr);

return (GameSettings.SimplifiedAutoTargeting
return (GameSettings.SimplifiedAutoTargeting
? ((TargetPriorityCalculate(&unit, target1) > TargetPriorityCalculate(&unit, target2)) ? target1 : target2)
: ((ThreatCalculate(unit, *target1) < ThreatCalculate(unit, *target2)) ? target1 : target2));
}
Expand All @@ -356,7 +356,7 @@ void COrder_Attack::OfferNewTarget(const CUnit &unit, CUnit *const target)
{
Assert(target != nullptr);
Assert(this->IsAutoTargeting() || unit.Player->AiEnabled);

/// if attacker cant't move (stand_ground, building, in a bunker or transport)
const bool immobile = this->Action == UnitAction::StandGround || unit.Removed || !unit.CanMove();
if (immobile && !InAttackRange(unit, *target)) {
Expand Down Expand Up @@ -636,7 +636,7 @@ bool COrder_Attack::CheckForTargetInRange(CUnit &unit)

/**
** Check if current target is closer to unit more than MinAttackRange
**
**
** @param unit Unit that is attacking and moving
*/
bool COrder_Attack::IsTargetTooClose(const CUnit &unit) const
Expand All @@ -654,7 +654,7 @@ bool COrder_Attack::IsTargetTooClose(const CUnit &unit) const

/**
** Controls moving a unit to position if its target is closer than MinAttackRange when attacking
**
**
** @param unit Unit that is attacking and moving
** @param pfReturn Current path finder status. Using to find new attack pos if current is unreachable.
*/
Expand All @@ -665,10 +665,10 @@ void COrder_Attack::MoveToAttackPos(CUnit &unit, const int pfReturn)
if (CheckForTargetInRange(unit)) {
return;
}
CUnit *goal = this->GetGoal();
CUnit *goal = this->GetGoal();
/// When attack ground and moving to attack position, the target tile pos is stored in attackMovePos
const bool inAttackRange = goal ? InAttackRange(unit, *goal)
: InAttackRange(unit, this->attackMovePos);
const bool inAttackRange =
goal ? InAttackRange(unit, *goal) : InAttackRange(unit, this->attackMovePos);
if (!IsTargetTooClose(unit)) {
/// We have to restore original goalPos value
if (goal) {
Expand All @@ -690,7 +690,7 @@ void COrder_Attack::MoveToAttackPos(CUnit &unit, const int pfReturn)

/**
** Controls moving a unit to its target when attacking
**
**
** @param unit Unit that is attacking and moving
*/
void COrder_Attack::MoveToTarget(CUnit &unit)
Expand All @@ -710,7 +710,7 @@ void COrder_Attack::MoveToTarget(CUnit &unit)

if (needToSearchBetterPos) {
MoveToBetterPos(unit);
return;
return;
}
/// Order may be set as finished by outside code while playing animation.
/// In this case we must not execute code of MoveToTarget
Expand Down Expand Up @@ -857,7 +857,7 @@ void COrder_Attack::AttackTarget(CUnit &unit)
return;
}
// Can we already attack ?
if ((this->HasGoal() && InAttackRange(unit, *this->GetGoal()))
if ((this->HasGoal() && InAttackRange(unit, *this->GetGoal()))
|| (IsAttackGroundOrWall() && InAttackRange(unit, this->goalPos))) {

TurnToTarget(unit, this->GetGoal());
Expand All @@ -867,7 +867,7 @@ void COrder_Attack::AttackTarget(CUnit &unit)
}
this->State |= MOVE_TO_TARGET;
// FIXME: should use a reachable place to reduce pathfinder time.

// FALL THROUGH
case MOVE_TO_TARGET:
case MOVE_TO_TARGET + AUTO_TARGETING:
Expand Down
14 changes: 7 additions & 7 deletions src/action/action_build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,9 +292,9 @@ CUnit *COrder_Build::CheckCanBuild(CUnit &unit)
CUnit *building = AlreadyBuildingFinder(unit, type).Find(Map.Field(pos));
if (building != nullptr) {
if (unit.CurrentOrder() == this) {
DebugPrint("%d: Worker [%d] is helping build: %s [%d]\n",
unit.Player->Index, unit.Slot,
building->Type->Name.c_str(),
DebugPrint("%d: Worker [%d] is helping build: %s [%d]\n",
unit.Player->Index, unit.Slot,
building->Type->Name.c_str(),
building->Slot);

delete this; // Bad
Expand Down Expand Up @@ -350,10 +350,10 @@ bool COrder_Build::StartBuilding(CUnit &unit, CUnit &ontop)
ontop.Release();
}
}
if (type.BoolFlag[MAINFACILITY_INDEX].value
&& CPlayer::IsRevelationEnabled() && unit.Player->LostMainFacilityTimer != 0 ) {

if (type.BoolFlag[MAINFACILITY_INDEX].value && CPlayer::IsRevelationEnabled()
&& unit.Player->LostMainFacilityTimer != 0) {

unit.Player->LostMainFacilityTimer = 0;
unit.Player->SetRevealed(false);
for (int j = 0; j < NumPlayers; ++j) {
Expand Down
6 changes: 3 additions & 3 deletions src/action/action_move.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,11 @@ void COrder_Move::Execute(CUnit &unit) /* override */
case PF_REACHED:
this->Finished = true;
break;
case PF_WAIT:

case PF_WAIT:
{
const CUnit *blocker = UnitOnMapTile(this->goalPos, unit.Type->UnitType);
if (blocker) {
if (blocker) {
const int distToBlocker = MapDistanceBetweenTypes(*(unit.Type), unit.tilePos, *(blocker->Type), blocker->tilePos);
if (distToBlocker == 1 && (unit.IsEnemy(*blocker) || blocker->Moving == 0)) {
unit.Wait = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/action/actions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ static inline void IncreaseVariable(CUnit &unit, int index)
{
unit.Variable[index].Value += unit.Variable[index].Increase;
clamp(&unit.Variable[index].Value, 0, unit.Variable[index].Max);

//if variable is HP and increase is negative, unit dies if HP reached 0
if (index == HP_INDEX && unit.Variable[HP_INDEX].Value <= 0) {
LetUnitDie(unit);
Expand Down
7 changes: 4 additions & 3 deletions src/action/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,8 +924,9 @@ void CommandSharedVision(int playerIndex, bool state, int opponentIndex)
CPlayer *player = &Players[playerIndex];
CPlayer *opponent = &Players[opponentIndex];

if (state == player->HasSharedVisionWith(*opponent) || opponent->Type == PlayerTypes::PlayerNobody
|| player->Type == PlayerTypes::PlayerNobody) {
if (state == player->HasSharedVisionWith(*opponent)
|| opponent->Type == PlayerTypes::PlayerNobody
|| player->Type == PlayerTypes::PlayerNobody) {
return;
}

Expand All @@ -935,7 +936,7 @@ void CommandSharedVision(int playerIndex, bool state, int opponentIndex)
MapUnmarkUnitSight(*unit);
}
}

if (state == false) {
player->UnshareVisionWith(*opponent);

Expand Down
35 changes: 19 additions & 16 deletions src/ai/ai_force.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -867,24 +867,27 @@ static void AiGroupAttackerForTransport(AiForce &aiForce)
&& static_cast<COrder_Board *>(unit.CurrentOrder())->GetGoal() == &transporter) {
CommandFollow(transporter, unit, 0);
}
if (CanTransport(transporter, unit) && (unit.IsIdle()
|| (unit.CurrentAction() == UnitAction::Board && !unit.Moving
&& static_cast<COrder_Board *>(unit.CurrentOrder())->GetGoal() != &transporter)) && unit.Container == nullptr) {
CommandBoard(unit, transporter, FlushCommands);
CommandFollow(transporter, unit, 0);
if (--nbToTransport == 0) { // full : next transporter.
for (++transporterIndex; transporterIndex < aiForce.Size(); ++transporterIndex) {
const CUnit &nextTransporter = *aiForce.Units[transporterIndex];

if (nextTransporter.Type->CanTransport()) {
nbToTransport = nextTransporter.Type->MaxOnBoard - nextTransporter.BoardCount;
break ;
}
}
if (transporterIndex == aiForce.Size()) { // No more transporter.
break ;
if (CanTransport(transporter, unit)
&& (unit.IsIdle()
|| (unit.CurrentAction() == UnitAction::Board && !unit.Moving
&& static_cast<COrder_Board *>(unit.CurrentOrder())->GetGoal() != &transporter))
&& unit.Container == nullptr) {
CommandBoard(unit, transporter, FlushCommands);
CommandFollow(transporter, unit, 0);
if (--nbToTransport == 0) { // full : next transporter.
for (++transporterIndex; transporterIndex < aiForce.Size(); ++transporterIndex) {
const CUnit &nextTransporter = *aiForce.Units[transporterIndex];

if (nextTransporter.Type->CanTransport()) {
nbToTransport =
nextTransporter.Type->MaxOnBoard - nextTransporter.BoardCount;
break;
}
}
if (transporterIndex == aiForce.Size()) { // No more transporter.
break;
}
}
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/ai/ai_magic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ void AiCheckMagic()
CPlayer &player = *AiPlayer->Player;

for (CUnit *unit : player.GetUnits()) {


if (!unit->Type->CanCastSpell.empty()) {
// Check only idle magic units
for (const auto *order : unit->Orders) {
Expand Down
1 change: 0 additions & 1 deletion src/animation/animation_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ void CAnimation_Frame::Action(CUnit &unit, int &/*move*/, int /*scale*/) const /
} else {
unit.Frame = ParseAnimInt(&unit);
}

UnitUpdateHeading(unit);
}

Expand Down
2 changes: 1 addition & 1 deletion src/animation/animation_rotate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void UnitRotate(CUnit &unit, int rotate)
target = order->GetGoal();
if (target->Destroyed) {
order->ClearGoal();
return;
return;
}
} else if (unit.CurrentOrder()->Action == UnitAction::Build) {
target = static_cast<const COrder_Build *>(order)->GetBuildingUnit();
Expand Down
Loading

0 comments on commit 5555720

Please sign in to comment.