Skip to content

Commit

Permalink
Fix compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
sfan5 committed Feb 24, 2024
1 parent 6952bab commit 492aab2
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/client/imagefilters.cpp
Expand Up @@ -71,14 +71,14 @@ static void imageCleanTransparentWithInlining(video::IImage *src, u32 threshold)
void *const src_data = src->getData();
const core::dimension2d<u32> dim = src->getDimension();

auto get_pixel = [src, src_data, dim](u32 x, u32 y) -> video::SColor {
auto get_pixel = [=](u32 x, u32 y) -> video::SColor {
if constexpr (IS_A8R8G8B8) {
return reinterpret_cast<u32 *>(src_data)[y*dim.Width + x];
} else {
return src->getPixel(x, y);
}
};
auto set_pixel = [src, src_data, dim](u32 x, u32 y, video::SColor color) {
auto set_pixel = [=](u32 x, u32 y, video::SColor color) {
if constexpr (IS_A8R8G8B8) {
u32 *dest = &reinterpret_cast<u32 *>(src_data)[y*dim.Width + x];
*dest = color.color;
Expand Down
16 changes: 8 additions & 8 deletions src/network/connection.h
Expand Up @@ -615,7 +615,7 @@ class Peer {
u64 m_last_timeout_check;
};

class UDPPeer : public Peer
class UDPPeer final : public Peer
{
public:

Expand All @@ -628,15 +628,15 @@ class UDPPeer : public Peer
virtual ~UDPPeer() = default;

void PutReliableSendCommand(ConnectionCommandPtr &c,
unsigned int max_packet_size);
unsigned int max_packet_size) override;

bool getAddress(MTProtocols type, Address& toset);
bool getAddress(MTProtocols type, Address& toset) override;

u16 getNextSplitSequenceNumber(u8 channel);
void setNextSplitSequenceNumber(u8 channel, u16 seqnum);
u16 getNextSplitSequenceNumber(u8 channel) override;
void setNextSplitSequenceNumber(u8 channel, u16 seqnum) override;

SharedBuffer<u8> addSplitPacket(u8 channel, BufferedPacketPtr &toadd,
bool reliable);
bool reliable) override;

bool isTimedOut(float timeout, std::string &reason) override;

Expand All @@ -645,7 +645,7 @@ class UDPPeer : public Peer
Calculates avg_rtt and resend_timeout.
rtt=-1 only recalculates resend_timeout
*/
void reportRTT(float rtt);
void reportRTT(float rtt) override;

void RunCommandQueues(
unsigned int max_packet_size,
Expand All @@ -657,7 +657,7 @@ class UDPPeer : public Peer
void setResendTimeout(float timeout)
{ MutexAutoLock lock(m_exclusive_access_mutex); resend_timeout = timeout; }

bool Ping(float dtime,SharedBuffer<u8>& data);
bool Ping(float dtime, SharedBuffer<u8>& data) override;

Channel channels[CHANNEL_COUNT];
bool m_pending_disconnect = false;
Expand Down
2 changes: 1 addition & 1 deletion src/script/common/c_packer.cpp
Expand Up @@ -630,7 +630,7 @@ void script_dump_packed(const PackedValue *val)
printf("table(%d, %d)", i.uidata1, i.uidata2);
break;
case LUA_TFUNCTION:
printf("function(%lu byte)", i.sdata.size());
printf("function(%d bytes)", (int)i.sdata.size());
break;
case LUA_TUSERDATA:
printf("userdata %s %p", i.sdata.c_str(), i.ptrdata);
Expand Down
6 changes: 0 additions & 6 deletions src/script/lua_api/l_minimap.cpp
Expand Up @@ -132,9 +132,6 @@ int LuaMinimap::l_show(lua_State *L)
if (!g_settings->getBool("enable_minimap"))
return 1;

Client *client = getClient(L);
assert(client);

LuaMinimap *ref = checkObject<LuaMinimap>(L, 1);
Minimap *m = getobject(ref);

Expand All @@ -149,9 +146,6 @@ int LuaMinimap::l_show(lua_State *L)

int LuaMinimap::l_hide(lua_State *L)
{
Client *client = getClient(L);
assert(client);

LuaMinimap *ref = checkObject<LuaMinimap>(L, 1);
Minimap *m = getobject(ref);

Expand Down
2 changes: 1 addition & 1 deletion src/unittest/test_datastructures.cpp
Expand Up @@ -104,7 +104,7 @@ void TestDataStructures::testMap1()
UASSERT(t0.deleted);
UASSERT(!t1.copied);
UASSERT(!t1.deleted);
if (once |= 1)
if ((once |= 1))
break;
}
UASSERT(once);
Expand Down
16 changes: 11 additions & 5 deletions src/util/string.h
Expand Up @@ -43,13 +43,19 @@ class Translations;
( (unsigned int)(x) <= 0x7e))

// Checks whether a value is in a Unicode private use area
#define IS_PRIVATE_USE_CHAR(x) \
(((wchar_t)(x) >= 0xE000 && \
(wchar_t)(x) <= 0xF8FF) || \
((wchar_t)(x) >= 0xF0000 && \
#define IS_PRIVATE_USE_CHAR16(x) \
((wchar_t)(x) >= 0xE000 && \
(wchar_t)(x) <= 0xF8FF)
#define IS_PRIVATE_USE_CHAR32(x) \
(((wchar_t)(x) >= 0xF0000 && \
(wchar_t)(x) <= 0xFFFFD) || \
((wchar_t)(x) >= 0x100000 && \
(wchar_t)(x) <= 0x10FFFD)) \
(wchar_t)(x) <= 0x10FFFD))
#if WCHAR_MAX > 0xFFFF
#define IS_PRIVATE_USE_CHAR(x) (IS_PRIVATE_USE_CHAR16(x) || IS_PRIVATE_USE_CHAR32(x))
#else
#define IS_PRIVATE_USE_CHAR(x) IS_PRIVATE_USE_CHAR16(x)
#endif

// Checks whether a byte is an inner byte for an utf-8 multibyte sequence
#define IS_UTF8_MULTB_INNER(x) \
Expand Down

0 comments on commit 492aab2

Please sign in to comment.