Skip to content

Commit

Permalink
Replace dynamic_cast to static_cast
Browse files Browse the repository at this point in the history
  • Loading branch information
LordBombardir committed Jan 1, 2025
1 parent a661829 commit e2702e3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/mod/commands/RemoveRankCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void RemoveRankCommand::execute(
) {
std::string localeCode = origin.getEntity() == nullptr || !origin.getEntity()->isType(ActorType::Player)
? manager::ConfigManager::getConfig().defaultLocaleCode
: dynamic_cast<ServerPlayer&>(*origin.getEntity()).getLocaleCode();
: static_cast<ServerPlayer&>(*origin.getEntity()).getLocaleCode();

std::optional<object::Rank*> rank = manager::RanksManager::getRank(parameter.rankName);
if (!rank.has_value() || rank.value() == nullptr) {
Expand Down
4 changes: 2 additions & 2 deletions src/mod/commands/SetRankCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void SetRankCommand::execute(
) {
// clang-format off
bool isOriginServer = origin.getEntity() == nullptr || !origin.getEntity()->isType(ActorType::Player);
std::string localeCode = isOriginServer ? manager::ConfigManager::getConfig().defaultLocaleCode : dynamic_cast<ServerPlayer&>(*origin.getEntity()).getLocaleCode();
std::string localeCode = isOriginServer ? manager::ConfigManager::getConfig().defaultLocaleCode : static_cast<ServerPlayer&>(*origin.getEntity()).getLocaleCode();

CommandSelectorResults<Player> players = parameter.player.results(origin);
if (players.empty()) {
Expand Down Expand Up @@ -115,7 +115,7 @@ void SetRankCommand::executeWithoutParameter(const CommandOrigin& origin, Comman
return;
}

forms::SetRankForm::init(dynamic_cast<ServerPlayer&>(*origin.getEntity()));
forms::SetRankForm::init(static_cast<ServerPlayer&>(*origin.getEntity()));
}

} // namespace power_ranks::commands
4 changes: 2 additions & 2 deletions src/mod/hooks/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ LL_TYPE_INSTANCE_HOOK(
return origin(commandOrigin, flags, permissionLevel);
}

auto& player = dynamic_cast<ServerPlayer&>(*commandOrigin.getEntity());
auto& player = static_cast<ServerPlayer&>(*commandOrigin.getEntity());

const object::Rank& rank = manager::MainManager::getPlayerRankOrSetDefault(player);
std::optional<std::string> lastWrittedCommand =
Expand Down Expand Up @@ -88,7 +88,7 @@ LL_TYPE_INSTANCE_HOOK(
return origin(commandOrigin, output);
}

auto& player = dynamic_cast<ServerPlayer&>(*commandOrigin.getEntity());
auto& player = static_cast<ServerPlayer&>(*commandOrigin.getEntity());
manager::CommandManager::setLastWrittedCommand(player.getRealName(), getCommandName());

origin(commandOrigin, output);
Expand Down

0 comments on commit e2702e3

Please sign in to comment.