Skip to content

Commit

Permalink
Remove else after returning branch (#3678)
Browse files Browse the repository at this point in the history
  • Loading branch information
ramon-bernardo authored Sep 25, 2021
1 parent c9a65a8 commit 2e3c682
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 38 deletions.
3 changes: 1 addition & 2 deletions src/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,8 @@ ReturnValue Combat::canTargetCreature(Player* attacker, Creature* target)
if (attacker->hasFlag(PlayerFlag_CannotUseCombat) || !target->isAttackable()) {
if (target->getPlayer()) {
return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER;
} else {
return RETURNVALUE_YOUMAYNOTATTACKTHISCREATURE;
}
return RETURNVALUE_YOUMAYNOTATTACKTHISCREATURE;
}

if (target->getPlayer()) {
Expand Down
3 changes: 1 addition & 2 deletions src/container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,8 @@ ReturnValue Container::queryAdd(int32_t index, const Thing& thing, uint32_t coun
const Cylinder* topParent = getTopParent();
if (topParent != this) {
return topParent->queryAdd(INDEX_WHEREEVER, *item, count, flags | FLAG_CHILDISOWNER, actor);
} else {
return RETURNVALUE_NOERROR;
}
return RETURNVALUE_NOERROR;
}

ReturnValue Container::queryMaxCount(int32_t index, const Thing& thing, uint32_t count,
Expand Down
3 changes: 1 addition & 2 deletions src/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,8 @@ int32_t Creature::getWalkCache(const Position& pos) const
if (std::abs(dy) <= maxWalkCacheHeight) {
if (localMapCache[maxWalkCacheHeight + dy][maxWalkCacheWidth + dx]) {
return 1;
} else {
return 0;
}
return 0;
}
}

Expand Down
18 changes: 8 additions & 10 deletions src/creatureevent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,12 @@ bool CreatureEvents::registerEvent(Event_ptr event, const pugi::xml_node&)
if (!oldEvent->isLoaded() && oldEvent->getEventType() == creatureEvent->getEventType()) {
oldEvent->copyEvent(creatureEvent.get());
}

return false;
} else {
//if not, register it normally
creatureEvents.emplace(creatureEvent->getName(), std::move(*creatureEvent));
return true;
}

// if not, register it normally
creatureEvents.emplace(creatureEvent->getName(), std::move(*creatureEvent));
return true;
}

bool CreatureEvents::registerLuaEvent(CreatureEvent* event)
Expand All @@ -106,13 +105,12 @@ bool CreatureEvents::registerLuaEvent(CreatureEvent* event)
if (!oldEvent->isLoaded() && oldEvent->getEventType() == creatureEvent->getEventType()) {
oldEvent->copyEvent(creatureEvent.get());
}

return false;
} else {
//if not, register it normally
creatureEvents.emplace(creatureEvent->getName(), std::move(*creatureEvent));
return true;
}

// if not, register it normally
creatureEvents.emplace(creatureEvent->getName(), std::move(*creatureEvent));
return true;
}

CreatureEvent* CreatureEvents::getEventByName(const std::string& name, bool forceLoaded /*= true*/)
Expand Down
3 changes: 1 addition & 2 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1684,9 +1684,8 @@ Item* Game::transformItem(Item* item, uint16_t newId, int32_t newCount /*= -1*/)
cylinder->postRemoveNotification(item, cylinder, itemIndex);
ReleaseItem(item);
return newItem;
} else {
return transformItem(item, newItemId);
}
return transformItem(item, newItemId);
}
} else {
cylinder->postRemoveNotification(item, cylinder, itemIndex);
Expand Down
9 changes: 3 additions & 6 deletions src/movement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -953,9 +953,8 @@ uint32_t MoveEvent::fireStepEvent(Creature* creature, Item* item, const Position
{
if (scripted) {
return executeStep(creature, item, pos);
} else {
return stepFunction(creature, item, pos);
}
return stepFunction(creature, item, pos);
}

bool MoveEvent::executeStep(Creature* creature, Item* item, const Position& pos)
Expand Down Expand Up @@ -992,9 +991,8 @@ ReturnValue MoveEvent::fireEquip(Player* player, Item* item, slots_t slot, bool
return RETURNVALUE_CANNOTBEDRESSED;
}
return equipFunction(this, player, item, slot, isCheck);
} else {
return equipFunction(this, player, item, slot, isCheck);
}
return equipFunction(this, player, item, slot, isCheck);
}

bool MoveEvent::executeEquip(Player* player, Item* item, slots_t slot, bool isCheck)
Expand Down Expand Up @@ -1025,9 +1023,8 @@ uint32_t MoveEvent::fireAddRemItem(Item* item, Item* tileItem, const Position& p
{
if (scripted) {
return executeAddRemItem(item, tileItem, pos);
} else {
return moveFunction(item, tileItem, pos);
}
return moveFunction(item, tileItem, pos);
}

bool MoveEvent::executeAddRemItem(Item* item, Item* tileItem, const Position& pos)
Expand Down
9 changes: 3 additions & 6 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -660,9 +660,8 @@ uint16_t Player::getLookCorpse() const
{
if (sex == PLAYERSEX_FEMALE) {
return ITEM_FEMALE_CORPSE;
} else {
return ITEM_MALE_CORPSE;
}
return ITEM_MALE_CORPSE;
}

void Player::addStorageValue(const uint32_t key, const int32_t value, const bool isLogin/* = false*/)
Expand Down Expand Up @@ -2621,9 +2620,8 @@ ReturnValue Player::queryMaxCount(int32_t index, const Thing& thing, uint32_t co

if (maxQueryCount < count) {
return RETURNVALUE_NOTENOUGHROOM;
} else {
return RETURNVALUE_NOERROR;
}
return RETURNVALUE_NOERROR;
}

ReturnValue Player::queryRemove(const Thing& thing, uint32_t count, uint32_t flags, Creature* /*= nullptr*/) const
Expand Down Expand Up @@ -2769,9 +2767,8 @@ Cylinder* Player::queryDestination(int32_t& index, const Thing& thing, Item** de
index = INDEX_WHEREEVER;
*destItem = nullptr;
return subCylinder;
} else {
return this;
}
return this;
}

void Player::addThing(int32_t index, Thing* thing)
Expand Down
3 changes: 1 addition & 2 deletions src/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,8 @@ class Player final : public Creature, public Cylinder
return 0;
} else if (hasFlag(PlayerFlag_HasInfiniteCapacity)) {
return std::numeric_limits<uint32_t>::max();
} else {
return std::max<int32_t>(0, capacity - inventoryWeight);
}
return std::max<int32_t>(0, capacity - inventoryWeight);
}

int32_t getMaxHealth() const override {
Expand Down
3 changes: 1 addition & 2 deletions src/raids.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,8 @@ RaidEvent* Raid::getNextRaidEvent()
{
if (nextEvent < raidEvents.size()) {
return raidEvents[nextEvent];
} else {
return nullptr;
}
return nullptr;
}

bool RaidEvent::configureRaidEvent(const pugi::xml_node& eventNode)
Expand Down
3 changes: 1 addition & 2 deletions src/spells.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1055,9 +1055,8 @@ bool InstantSpell::castSpell(Creature* creature, Creature* target)
var.type = VARIANT_NUMBER;
var.number = target->getID();
return internalCastSpell(creature, var);
} else {
return castSpell(creature);
}
return castSpell(creature);
}

bool InstantSpell::internalCastSpell(Creature* creature, const LuaVariant& var)
Expand Down
3 changes: 1 addition & 2 deletions src/tile.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,8 @@ class Tile : public Cylinder
return ZONE_NOPVP;
} else if (hasFlag(TILESTATE_PVPZONE)) {
return ZONE_PVP;
} else {
return ZONE_NORMAL;
}
return ZONE_NORMAL;
}

bool hasHeight(uint32_t n) const;
Expand Down

0 comments on commit 2e3c682

Please sign in to comment.