Skip to content

Commit

Permalink
Chore: Address new clang-18 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
zach2good committed Dec 29, 2024
1 parent 36ce6ef commit 23b7d9a
Show file tree
Hide file tree
Showing 32 changed files with 61 additions and 61 deletions.
2 changes: 1 addition & 1 deletion modules/renamer/cpp/renamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class RenamerModule : public CPPModule
}

std::string dataString;
for (auto [key, value] : zoneTable)
for (const auto& [key, value] : zoneTable)
{
auto entryTable = value.as<sol::table>();

Expand Down
4 changes: 2 additions & 2 deletions src/common/lua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void lua_init()
/**
* @brief
*/
std::string lua_to_string_depth(sol::object const& obj, std::size_t depth)
std::string lua_to_string_depth(const sol::object& obj, std::size_t depth)
{
switch (obj.get_type())
{
Expand Down Expand Up @@ -203,7 +203,7 @@ void lua_print(sol::variadic_args va)
ShowLua(lua_to_string(va).c_str());
}

std::string lua_fmt(std::string fmtStr, sol::variadic_args va)
std::string lua_fmt(const std::string& fmtStr, sol::variadic_args va)
{
fmt::dynamic_format_arg_store<fmt::format_context> store;
for (auto const& arg : va)
Expand Down
4 changes: 2 additions & 2 deletions src/common/lua.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
extern sol::state lua;

void lua_init();
auto lua_to_string_depth(sol::object const& obj, std::size_t depth) -> std::string;
auto lua_to_string_depth(const sol::object& obj, std::size_t depth) -> std::string;
auto lua_to_string(sol::variadic_args va) -> std::string;
void lua_print(sol::variadic_args va);
auto lua_fmt(std::string fmtStr, sol::variadic_args va) -> std::string;
auto lua_fmt(const std::string& fmtStr, sol::variadic_args va) -> std::string;

#endif // _LUA_H
12 changes: 6 additions & 6 deletions src/common/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ namespace settings
}

// Scrape defaults into cpp's settingsMap
for (auto [outerKeyObj, outerValObj] : lua["xi"]["settings"].get<sol::table>())
for (const auto& [outerKeyObj, outerValObj] : lua["xi"]["settings"].get<sol::table>())
{
auto outerKey = outerKeyObj.as<std::string>();

for (auto [innerKeyObj, innerValObj] : outerValObj.as<sol::table>())
for (const auto& [innerKeyObj, innerValObj] : outerValObj.as<sol::table>())
{
auto innerKey = innerKeyObj.as<std::string>();
auto key = to_upper(fmt::format("{}.{}", outerKey, innerKey));
Expand Down Expand Up @@ -161,11 +161,11 @@ namespace settings
// Scrape user settings into cpp's settingsMap
// This will overwrite the defaults, if user settings exist. Otherwise the
// defaults will be left intact.
for (auto [outerKeyObj, outerValObj] : lua["xi"]["settings"].get<sol::table>())
for (const auto& [outerKeyObj, outerValObj] : lua["xi"]["settings"].get<sol::table>())
{
auto outerKey = outerKeyObj.as<std::string>();

for (auto [innerKeyObj, innerValObj] : outerValObj.as<sol::table>())
for (const auto& [innerKeyObj, innerValObj] : outerValObj.as<sol::table>())
{
auto innerKey = innerKeyObj.as<std::string>();
auto key = to_upper(fmt::format("{}.{}", outerKey, innerKey));
Expand Down Expand Up @@ -210,7 +210,7 @@ namespace settings
}

// Push the consolidated defaults + user settings back up into xi.settings
for (auto [key, value] : settingsMap)
for (const auto& [key, value] : settingsMap)
{
auto parts = split(key, ".");
auto outer = to_lower(parts[0]);
Expand All @@ -226,7 +226,7 @@ namespace settings
// lua.safe_script("require('settings/main'); require('settings/default/main'); print(xi.settings)");
}

void visit(std::function<void(std::string, SettingsVariant_t)> visitor)
void visit(const std::function<void(std::string, SettingsVariant_t)>& visitor)
{
for (auto& [key, value] : settingsMap)
{
Expand Down
2 changes: 1 addition & 1 deletion src/common/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ namespace settings
settingsMap[key] = SettingsVariant_t(value);
}

void visit(std::function<void(std::string, SettingsVariant_t)> visitor);
void visit(const std::function<void(std::string, SettingsVariant_t)>& visitor);
} // namespace settings

#endif // _SETTINGS_H
2 changes: 1 addition & 1 deletion src/common/socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ using AccessControl = struct _access_control
uint32 mask;
};

enum _aco
enum _aco : uint8
{
ACO_DENY_ALLOW,
ACO_ALLOW_DENY,
Expand Down
1 change: 1 addition & 0 deletions src/common/sql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ SqlConnection::SqlConnection(const char* user, const char* passwd, const char* h
// these members will be set up in SetupKeepalive(), they need to be init'd here to appease clang-tidy
m_PingInterval = 0;
m_LastPing = 0;

SetupKeepalive();
}

Expand Down
1 change: 0 additions & 1 deletion src/common/sql.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,6 @@ class SqlConnection

uint32 m_PingInterval;
uint32 m_LastPing;
bool m_LatencyWarning;

std::thread::id m_ThreadId;
};
Expand Down
2 changes: 1 addition & 1 deletion src/login/handler_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void handler_session::do_read()
}
else
{
DebugSockets(fmt::format("async_read_some error in from IP {} ({}: {})", ipAddress, ec.value(), ec.message()));
DebugSockets(fmt::format("async_read_some error in handler_session from IP {} ({}: {})", ipAddress, ec.value(), ec.message()));
handle_error(ec, self);
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/login/view_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ void view_session::read_func()

// Sanitize name & check for invalid characters
std::string nameStr = db::escapeString(CharName);
for (auto letters : nameStr)
for (const auto& letters : nameStr)
{
if (!std::isalpha(letters))
{
Expand Down
2 changes: 1 addition & 1 deletion src/map/ability.h
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ class CAbility
std::string m_name;
uint16 m_mobskillId;
ACTIONTYPE m_actionType{};
EFFECT m_cleanupEffect;
EFFECT m_cleanupEffect{};
};

/************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion src/map/ai/controllers/mob_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class CMobController : public CController
time_point m_NeutralTime;
time_point m_WaitTime;
time_point m_mobHealTime;
FollowType m_followType;
FollowType m_followType = FollowType::None;

bool m_firstSpell{ true };
time_point m_LastRoamScript{ time_point::min() };
Expand Down
2 changes: 1 addition & 1 deletion src/map/ai/controllers/trust_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

namespace
{
enum TRUST_MOVEMENT_TYPE
enum TRUST_MOVEMENT_TYPE : int8
{
// NOTE: If you need to add special movement types, add descending into the minus values.
// : All of the positive values are taken for the ranged movement range.
Expand Down
1 change: 1 addition & 0 deletions src/map/ai/helpers/targetfind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ CTargetFind::CTargetFind(CBattleEntity* PBattleEntity)
, m_zone(0)
, m_findType{}
, m_findFlags(0)
, m_targetFlags(0)
, m_conal(false)
, m_scalar(0.0f)
, m_APoint(nullptr)
Expand Down
4 changes: 2 additions & 2 deletions src/map/entities/baseentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void CBaseEntity::ResetLocalVars()
m_localVars.clear();
}

uint32 CBaseEntity::GetLocalVar(std::string var)
uint32 CBaseEntity::GetLocalVar(const std::string& var)
{
return m_localVars[var];
}
Expand All @@ -212,7 +212,7 @@ std::map<std::string, uint32>& CBaseEntity::GetLocalVars()
return m_localVars;
}

void CBaseEntity::SetLocalVar(std::string var, uint32 val)
void CBaseEntity::SetLocalVar(const std::string& var, uint32 val)
{
m_localVars[var] = val;
}
Expand Down
4 changes: 2 additions & 2 deletions src/map/entities/baseentity.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,8 @@ class CBaseEntity
void SendZoneUpdate();

void ResetLocalVars();
uint32 GetLocalVar(std::string var);
void SetLocalVar(std::string var, uint32 val);
uint32 GetLocalVar(const std::string& var);
void SetLocalVar(const std::string& var, uint32 val);
auto GetLocalVars() -> std::map<std::string, uint32>&;

// pre-tick update
Expand Down
2 changes: 1 addition & 1 deletion src/map/entities/charentity.h
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ class CCharEntity : public CBattleEntity
bool isSettingBazaarPrices; // Is setting bazaar prices (temporarily hide bazaar)
bool isLinkDead; // Player is d/cing

SAVE_CONF playerConfig; // Various settings such as chat filter, display head flag, new adventurer, autotarget, etc.
SAVE_CONF playerConfig{}; // Various settings such as chat filter, display head flag, new adventurer, autotarget, etc.

uint32 lastOnline{ 0 }; // UTC Unix Timestamp of the last time char zoned or logged out
bool isNewPlayer() const; // Checks if new player bit is unset.
Expand Down
3 changes: 1 addition & 2 deletions src/map/guild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ void CGuild::updateGuildPointsPattern(uint8 pattern)
{
while (_sql->NextRow() == SQL_SUCCESS)
{
m_GPItems[i].emplace_back(
GPItem_t(itemutils::GetItemPointer(_sql->GetUIntData(0)), _sql->GetUIntData(2), _sql->GetUIntData(1)));
m_GPItems[i].emplace_back(itemutils::GetItemPointer(_sql->GetUIntData(0)), _sql->GetUIntData(2), _sql->GetUIntData(1));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/map/job_points.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ namespace jobpointutils
break;
}

currentGifts->emplace_back(CModifier(static_cast<Mod>(gift.modId), gift.value));
currentGifts->emplace_back(static_cast<Mod>(gift.modId), gift.value);
}

PChar->addModifiers(currentGifts);
Expand Down
6 changes: 3 additions & 3 deletions src/map/lua/lua_baseentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6774,7 +6774,7 @@ void CLuaBaseEntity::setMonstrosityData(sol::table table)
// NOTE: This will populate m_PMonstrosity if it doesn't exist
monstrosity::ReadMonstrosityData(PChar);

luautils::SetMonstrosityLuaTable(PChar, table);
luautils::SetMonstrosityLuaTable(PChar, std::move(table));

monstrosity::WriteMonstrosityData(PChar);

Expand Down Expand Up @@ -7992,11 +7992,11 @@ void CLuaBaseEntity::triggerRoeEvent(uint8 eventNum, sol::object const& reqTable
{
if (kv.second.get_type() == sol::type::number)
{
roeEventData.emplace_back(RoeDatagram(kv.first.as<std::string>(), kv.second.as<uint32>()));
roeEventData.emplace_back(kv.first.as<std::string>(), kv.second.as<uint32>());
}
else if (kv.second.get_type() == sol::type::string)
{
roeEventData.emplace_back(RoeDatagram(kv.first.as<std::string>(), kv.second.as<std::string>()));
roeEventData.emplace_back(kv.first.as<std::string>(), kv.second.as<std::string>());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/map/lua/luautils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5451,7 +5451,7 @@ namespace luautils
customMenuContext.erase(PChar->id);
}

SendToDBoxReturnCode SendItemToDeliveryBox(std::string const& playerName, uint16 itemId, uint32 quantity, std::string senderText)
SendToDBoxReturnCode SendItemToDeliveryBox(const std::string& playerName, uint16 itemId, uint32 quantity, const std::string& senderText)
{
uint32 playerID = GetPlayerIDByName(playerName);
if (playerID == 0)
Expand Down
2 changes: 1 addition & 1 deletion src/map/lua/luautils.h
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ namespace luautils

// Retrive the first itemId that matches a name
uint16 GetItemIDByName(std::string const& name);
auto SendItemToDeliveryBox(std::string const& playerName, uint16 itemId, uint32 quantity, std::string senderText) -> SendToDBoxReturnCode;
auto SendItemToDeliveryBox(const std::string& playerName, uint16 itemId, uint32 quantity, const std::string& senderText) -> SendToDBoxReturnCode;

std::optional<CLuaBaseEntity> GenerateDynamicEntity(CZone* PZone, CInstance* PInstance, sol::table table);

Expand Down
26 changes: 13 additions & 13 deletions src/map/monstrosity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,27 +50,27 @@

struct MonstrositySpeciesRow
{
uint8 monstrosityId;
uint16 monstrositySpeciesCode;
std::string name;
JOBTYPE mjob;
JOBTYPE sjob;
uint8 size;
uint16 look;
uint8 monstrosityId{};
uint16 monstrositySpeciesCode{};
std::string name{};
JOBTYPE mjob{};
JOBTYPE sjob{};
uint8 size{};
uint16 look{};
};

struct MonstrosityInstinctRow
{
uint16 monstrosityInstinctId;
uint8 cost;
std::string name;
std::vector<CModifier> mods;
uint16 monstrosityInstinctId{};
uint8 cost{};
std::string name{};
std::vector<CModifier> mods{};
};

namespace
{
std::unordered_map<uint16, MonstrositySpeciesRow> gMonstrositySpeciesMap;
std::unordered_map<uint16, MonstrosityInstinctRow> gMonstrosityInstinctMap;
std::unordered_map<uint16, MonstrositySpeciesRow> gMonstrositySpeciesMap{};
std::unordered_map<uint16, MonstrosityInstinctRow> gMonstrosityInstinctMap{};
} // namespace

monstrosity::MonstrosityData_t::MonstrosityData_t()
Expand Down
2 changes: 1 addition & 1 deletion src/map/packet_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2393,7 +2393,7 @@ void SmallPacket0x04B(map_session_data_t* const PSession, CCharEntity* const PCh
}
else
{
entries.push_back(FishingContestEntry()); // Safety if there is no pointer but we need to fill the vector
entries.emplace_back(FishingContestEntry{}); // Safety if there is no pointer but we need to fill the vector
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/map/packets/zone_in.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct GP_SERV_POS_HEAD
};

// PS2: SAVE_LOGIN_STATE
enum class SAVE_LOGIN_STATE : uint32_t
enum class SAVE_LOGIN_STATE : uint8 // Originally uint32_t, but changed to uint8 to appease Clang
{
SAVE_LOGIN_STATE_NONE = 0,
SAVE_LOGIN_STATE_MYROOM = 1,
Expand Down
4 changes: 2 additions & 2 deletions src/map/spell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -684,8 +684,8 @@ namespace spell
return false;
}

bool usable = false;
uint8 requirements;
bool usable = false;
uint8 requirements = 0;

switch (PCaster->objtype)
{
Expand Down
2 changes: 1 addition & 1 deletion src/map/utils/blueutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ namespace blueutils
if (add)
{
// Check all the eligible Blue Traits for conflicts
std::size_t j;
std::size_t j = 0;
for (j = 0; j < traitsToAdd.size(); ++j)
{
auto iter = traitsToAdd.at(j);
Expand Down
4 changes: 2 additions & 2 deletions src/map/utils/charutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ namespace charutils
PChar->profile.mhflag = rset->get<uint16>("mhflag");
PChar->profile.title = rset->get<uint16>("title");

std::array<uint8, 512> bazaarMessageArray;
std::array<uint8, 512> bazaarMessageArray{};
db::extractFromBlob(rset, "bazaar_message", bazaarMessageArray);
const char* bazaarMessageStr = reinterpret_cast<const char*>(bazaarMessageArray.data());
if (bazaarMessageStr != nullptr)
Expand Down Expand Up @@ -7164,7 +7164,7 @@ namespace charutils
return 0;
}

void forceSynthCritFail(std::string sourceFunction, CCharEntity* PChar)
void forceSynthCritFail(const std::string& sourceFunction, CCharEntity* PChar)
{
// NOTE:
// Supposed non-losable items are reportedly lost if this condition is met:
Expand Down
2 changes: 1 addition & 1 deletion src/map/utils/charutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ namespace charutils

uint32 getCharIdFromName(std::string const& name);

void forceSynthCritFail(std::string sourceFunction, CCharEntity* PChar);
void forceSynthCritFail(const std::string& sourceFunction, CCharEntity* PChar);

void removeCharFromZone(CCharEntity* PChar);
}; // namespace charutils
Expand Down
2 changes: 1 addition & 1 deletion src/map/utils/instanceutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ namespace instanceutils

void LoadInstance(uint16 instanceid, CCharEntity* PRequester)
{
LoadQueue.push({ PRequester->id, instanceid });
LoadQueue.emplace(PRequester->id, instanceid);
}

InstanceData_t GetInstanceData(uint16 instanceid)
Expand Down
Loading

0 comments on commit 23b7d9a

Please sign in to comment.