Fix logging macros

macros should be fully wrapped in do { ... } while(false) to prevent
any accidental coding issues (like else being eaten!!!)
This commit is contained in:
Michael Cook (mackal) 2014-09-05 13:26:44 -04:00
parent c953f1dee1
commit da121137e5

View File

@ -92,8 +92,8 @@ extern void log_raw_packet(LogType type, uint16 seq, const BasePacket *p);
class Mob;
extern void log_message_mob(LogType type, Mob *who, const char *fmt, ...);
#define mlog( type, format, ...) \
if(IsLoggingEnabled()) \
do { \
if(IsLoggingEnabled()) \
if(log_type_info[ type ].enabled) { \
log_message_mob(type, this, format, ##__VA_ARGS__); \
} \
@ -150,16 +150,16 @@ extern void log_raw_packet(LogType type, uint16 seq, const BasePacket *p);
class Mob;
extern void log_hex_mob(LogType type, Mob *who, const char *data, uint32 length);
#define mhex( type, data, len) \
if(IsLoggingEnabled()) \
do { \
if(IsLoggingEnabled()) \
if(log_type_info[ type ].enabled) { \
log_hex_mob(type, this, data, len); \
} \
} while(false)
extern void log_packet_mob(LogType type, Mob *who, const BasePacket *p);
#define mpkt( type, packet) \
if(IsLoggingEnabled()) \
do { \
if(IsLoggingEnabled()) \
if(log_type_info[ type ].enabled) { \
log_packet_mob(type, this, packet); \
} \