summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2013-01-08 19:00:34 -0800
committerBen Longbons <b.r.longbons@gmail.com>2013-01-08 19:54:26 -0800
commitf2fd4885c2a906414e0f36acf95d252e5a9d5805 (patch)
tree918bff247135e9223a5126f1b85f4ae4fc9ba1aa
parent3e42921c657bc93094f0c7d96855aae9b0be5a7e (diff)
downloadtmwa-f2fd4885c2a906414e0f36acf95d252e5a9d5805.tar.gz
tmwa-f2fd4885c2a906414e0f36acf95d252e5a9d5805.tar.bz2
tmwa-f2fd4885c2a906414e0f36acf95d252e5a9d5805.tar.xz
tmwa-f2fd4885c2a906414e0f36acf95d252e5a9d5805.zip
Improve warning management more
-rw-r--r--.travis.yml11
-rw-r--r--GNUmakefile5
-rw-r--r--make.defs3
-rw-r--r--src/char/char.cpp51
-rw-r--r--src/char/char.hpp4
-rw-r--r--src/char/inter.cpp15
-rw-r--r--src/common/const_array.hpp1
-rw-r--r--src/common/core.cpp2
-rw-r--r--src/common/cxxstdio.hpp59
-rw-r--r--src/common/db.cpp2
-rw-r--r--src/common/sanity.hpp1
-rw-r--r--src/common/socket.cpp2
-rw-r--r--src/common/utils.cpp1
-rw-r--r--src/common/utils2.hpp12
-rw-r--r--src/ladmin/ladmin.cpp20
-rw-r--r--src/login/login.cpp52
-rw-r--r--src/map/atcommand.cpp18
-rw-r--r--src/map/atcommand.hpp3
-rw-r--r--src/map/battle.cpp6
-rw-r--r--src/map/chrif.cpp1
-rw-r--r--src/map/chrif.hpp3
-rw-r--r--src/map/clif.cpp8
-rw-r--r--src/map/intif.cpp1
-rw-r--r--src/map/magic-expr.cpp2
-rw-r--r--src/map/magic-interpreter-base.cpp13
-rw-r--r--src/map/magic-stmt.cpp3
-rw-r--r--src/map/magic.hpp2
-rw-r--r--src/map/map.cpp5
-rw-r--r--src/map/map.hpp6
-rw-r--r--src/map/mob.cpp7
-rw-r--r--src/map/mob.hpp2
-rw-r--r--src/map/npc.cpp2
-rw-r--r--src/map/pc.cpp7
-rw-r--r--src/map/script.cpp12
-rw-r--r--src/map/skill.cpp23
-rw-r--r--src/map/storage.cpp4
-rw-r--r--src/map/trade.cpp2
-rw-r--r--src/tool/eathena-monitor.cpp10
-rw-r--r--src/warnings.hpp89
39 files changed, 315 insertions, 155 deletions
diff --git a/.travis.yml b/.travis.yml
index 379ebaa..c1a9d42 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -19,7 +19,6 @@ notifications:
on_failure: always
## Commands before installing prerequisites
-before_install: export CC=${REAL_CC} CXX=${REAL_CXX}
# before_install: git submodule update --init --recursive
## Install prerequisites
@@ -39,7 +38,7 @@ install:
## Main test script
script:
- - make -k -j2 CC=${REAL_CC} CXX=${REAL_CXX}
+ - make -k -j2 CXX=${REAL_CXX} CPPFLAGS=-DQUIET
## Do something after the main test script
# after_script: ...
@@ -53,8 +52,8 @@ script:
# compiler: clang
## Environment variables to expand the build matrix
-## Needed because compiler: gcc overwrites CC and CXX
+## Needed because 'compiler: gcc' overwrites CXX
env:
- - REAL_CC=gcc-4.6 REAL_CXX=g++-4.6
- - REAL_CC=gcc-4.7 REAL_CXX=g++-4.7
- - REAL_CC=clang REAL_CXX=clang++
+ - REAL_CXX=g++-4.6
+ - REAL_CXX=g++-4.7
+ - REAL_CXX=clang++
diff --git a/GNUmakefile b/GNUmakefile
index d3a0de2..ec52547 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -5,7 +5,7 @@ default: login-server char-server map-server ladmin eathena-monitor
.DELETE_ON_ERROR:
include make.defs
-.PHONY: all clean common
+.PHONY: all clean common most
# With no prerequisites, no target should ever be implicitly deleted.
# With any prerequisites, those targets won't be (no patterns).
.SECONDARY:
@@ -65,6 +65,9 @@ ${BUILD_DIR}/login/login: ${BUILD_DIR}/login/login.o ${BUILD_DIR}/common/core.o
${BUILD_DIR}/map/map: ${BUILD_DIR}/map/map.o ${BUILD_DIR}/map/tmw.o ${BUILD_DIR}/map/magic-interpreter-lexer.o ${BUILD_DIR}/map/magic-interpreter-parser.o ${BUILD_DIR}/map/magic-interpreter-base.o ${BUILD_DIR}/map/magic-expr.o ${BUILD_DIR}/map/magic-stmt.o ${BUILD_DIR}/map/magic.o ${BUILD_DIR}/map/map.o ${BUILD_DIR}/map/chrif.o ${BUILD_DIR}/map/clif.o ${BUILD_DIR}/map/pc.o ${BUILD_DIR}/map/npc.o ${BUILD_DIR}/map/chat.o ${BUILD_DIR}/map/path.o ${BUILD_DIR}/map/itemdb.o ${BUILD_DIR}/map/mob.o ${BUILD_DIR}/map/script.o ${BUILD_DIR}/map/storage.o ${BUILD_DIR}/map/skill.o ${BUILD_DIR}/map/skill-pools.o ${BUILD_DIR}/map/atcommand.o ${BUILD_DIR}/map/battle.o ${BUILD_DIR}/map/intif.o ${BUILD_DIR}/map/trade.o ${BUILD_DIR}/map/party.o ${BUILD_DIR}/common/core.o ${BUILD_DIR}/common/socket.o ${BUILD_DIR}/common/timer.o ${BUILD_DIR}/common/grfio.o ${BUILD_DIR}/common/db.o ${BUILD_DIR}/common/lock.o ${BUILD_DIR}/common/nullpo.o ${BUILD_DIR}/common/mt_rand.o ${BUILD_DIR}/common/md5calc.o ${BUILD_DIR}/common/utils.o
${BUILD_DIR}/tool/eathena-monitor: ${BUILD_DIR}/tool/eathena-monitor.o
+# silence build warnings for code beyond my control
+${BUILD_DIR}/map/magic-interpreter-lexer.o ${BUILD_DIR}/map/magic-interpreter-parser.o : override WARNINGS=
+
# deps.make is *NOT* automatically rebuilt normally
# but the generated source files do need to be done first
deps.make: src/map/magic-interpreter-parser.cpp src/map/magic-interpreter-lexer.cpp
diff --git a/make.defs b/make.defs
index 7b56c97..ec4f801 100644
--- a/make.defs
+++ b/make.defs
@@ -3,7 +3,8 @@ CXX = g++
LEX = flex
BISON = bison
-CXXFLAGS = -pipe -g -O2 -include src/warnings.hpp
+CXXFLAGS = -pipe -g -O2 ${WARNINGS}
+WARNINGS = -include src/warnings.hpp
# works on both x86 and x86_64
override CXX += -m32 -std=c++0x
diff --git a/src/char/char.cpp b/src/char/char.cpp
index 67003b5..05c217d 100644
--- a/src/char/char.cpp
+++ b/src/char/char.cpp
@@ -34,36 +34,64 @@
#include "int_party.hpp"
#include "int_storage.hpp"
+static
struct mmo_map_server server[MAX_MAP_SERVERS];
+static
int server_fd[MAX_MAP_SERVERS];
+static
int server_freezeflag[MAX_MAP_SERVERS]; // Map-server anti-freeze system. Counter. 5 ok, 4...0 freezed
+static
int anti_freeze_enable = 0;
+static
int ANTI_FREEZE_INTERVAL = 6;
// TODO replace all string forms of IP addresses with class instances
+static
int login_fd, char_fd;
+static
char userid[24];
+static
char passwd[24];
+static
char server_name[20];
+static
char wisp_server_name[24] = "Server";
+static
char login_ip_str[16];
+static
int login_ip;
+static
int login_port = 6900;
+static
char char_ip_str[16];
+static
int char_ip;
+static
int char_port = 6121;
+static
int char_maintenance;
+static
int char_new;
+static
int email_creation = 0; // disabled by default
+static
char char_txt[1024];
+static
char unknown_char_name[1024] = "Unknown";
+static
char char_log_filename[1024] = "log/char.log";
//Added for lan support
+static
char lan_map_ip[128];
+static
int subneti[4];
+static
int subnetmaski[4];
+static
int name_ignoring_case = 0; // Allow or not identical name for characters but with a different case by [Yor]
+static
int char_name_option = 0; // Option to know which letters/symbols are authorised in the name of a character (0: all, 1: only those in char_name_letters, 2: all EXCEPT those in char_name_letters) by [Yor]
+static
char char_name_letters[1024] = ""; // list of letters/symbols authorised (or not) in a character name. by [Yor]
struct char_session_data
@@ -76,6 +104,7 @@ struct char_session_data
};
#define AUTH_FIFO_SIZE 256
+static
struct
{
int account_id, char_id, login_id1, login_id2, ip, char_pos, delflag,
@@ -83,36 +112,57 @@ struct
unsigned short packet_tmw_version;
time_t connect_until_time; // # of seconds 1/1/1970 (timestamp): Validity limit of the account (0 = unlimited)
} auth_fifo[AUTH_FIFO_SIZE];
+static
int auth_fifo_pos = 0;
+static
int check_ip_flag = 1; // It's to check IP of a player between char-server and other servers (part of anti-hacking system)
+static
int char_id_count = 150000;
+static
struct mmo_charstatus *char_dat;
+static
int char_num, char_max;
+static
int max_connect_user = 0;
int autosave_interval = DEFAULT_AUTOSAVE_INTERVAL;
+static
int start_zeny = 500;
+static
int start_weapon = 1201;
+static
int start_armor = 1202;
// Initial position (it's possible to set it in conf file)
+static
struct point start_point = { "new_1-1.gat", 53, 111 };
+static
struct gm_account *gm_account = NULL;
+static
int GM_num = 0;
// online players by [Yor]
+static
char online_txt_filename[1024] = "online.txt";
+static
char online_html_filename[1024] = "online.html";
+static
int online_sorting_option = 0; // sorting option to display online players in online files
+static
int online_display_option = 1; // display options: to know which columns must be displayed
+static
int online_refresh_html = 20; // refresh time (in sec) of the html file in the explorer
+static
int online_gm_display_min_level = 20; // minimum GM level to display 'GM' when we want to display it
+static
int *online_chars; // same size of char_dat, and id value of current server (or -1)
+static
time_t update_online; // to update online files when we receiving information from a server (not less than 8 seconds)
+static
pid_t pid = 0; // For forked DB writes
//------------------------------
@@ -2955,6 +3005,7 @@ void parse_char(int fd)
break;
}
}
+ break;
case 0x68: // delete char //Yor's Fix
if (!sd || RFIFOREST(fd) < 46)
diff --git a/src/char/char.hpp b/src/char/char.hpp
index 5c66dd4..3c0c865 100644
--- a/src/char/char.hpp
+++ b/src/char/char.hpp
@@ -29,8 +29,8 @@ int mapif_send(int fd, const uint8_t *buf, unsigned int len);
void char_log(const_string line);
-#define CHAR_LOG(fmt, args...) \
- char_log(static_cast<const std::string&>(STRPRINTF(fmt, ## args)))
+#define CHAR_LOG(fmt, ...) \
+ char_log(static_cast<const std::string&>(STRPRINTF(fmt, ## __VA_ARGS__)))
extern int autosave_interval;
diff --git a/src/char/inter.cpp b/src/char/inter.cpp
index 589a250..5262cca 100644
--- a/src/char/inter.cpp
+++ b/src/char/inter.cpp
@@ -23,6 +23,7 @@
char inter_log_filename[1024] = "log/inter.log";
+static
char accreg_txt[1024] = "save/accreg.txt";
static
struct dbt *accreg_db = NULL;
@@ -35,20 +36,8 @@ struct accreg
int party_share_level = 10;
-// 送信パケット長リスト
-int inter_send_packet_length[] = {
- -1, -1, 27, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- -1, 7, 0, 0, 0, 0, 0, 0, -1, 11, 0, 0, 0, 0, 0, 0,
- 35, -1, 11, 15, 34, 29, 7, -1, 0, 0, 0, 0, 0, 0, 0, 0,
- 10, -1, 15, 0, 79, 19, 7, -1, 0, -1, -1, -1, 14, 67, 186, -1,
- 9, 9, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 11, -1, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-};
-
// 受信パケット長リスト
+static
int inter_recv_packet_length[] = {
-1, -1, 7, -1, -1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
6, -1, 0, 0, 0, 0, 0, 0, 10, -1, 0, 0, 0, 0, 0, 0,
diff --git a/src/common/const_array.hpp b/src/common/const_array.hpp
index 12c5d6f..eb0da58 100644
--- a/src/common/const_array.hpp
+++ b/src/common/const_array.hpp
@@ -29,7 +29,6 @@
#include <vector>
#ifdef ANNOYING_GCC46_WORKAROUNDS
-# warning "like this one"
// constexpr is buggy with templates in this version
# define constexpr /* nothing */
#endif
diff --git a/src/common/core.cpp b/src/common/core.cpp
index a6a170b..ef953f8 100644
--- a/src/common/core.cpp
+++ b/src/common/core.cpp
@@ -46,7 +46,7 @@ void chld_proc(int)
{
wait(NULL);
}
-static
+static __attribute__((noreturn))
void sig_proc(int)
{
for (int i = 1; i < 31; ++i)
diff --git a/src/common/cxxstdio.hpp b/src/common/cxxstdio.hpp
index d7c0634..866947c 100644
--- a/src/common/cxxstdio.hpp
+++ b/src/common/cxxstdio.hpp
@@ -67,6 +67,7 @@ namespace cxxstdio
return vsscanf(in, fmt, ap);
}
#else
+ inline
int do_vscan(const char *, const char *, va_list) = delete;
#endif
@@ -262,39 +263,39 @@ namespace cxxstdio
}
};
-#define FPRINTF(file, fmt, args...) \
- ([&]() -> int \
- { \
- struct format_impl \
- { \
- constexpr static \
- const char *print_format() { return fmt; } \
- }; \
- return cxxstdio::PrintFormatter<format_impl>::print(file, ## args);\
+#define FPRINTF(file, fmt, ...) \
+ ([&]() -> int \
+ { \
+ struct format_impl \
+ { \
+ constexpr static \
+ const char *print_format() { return fmt; } \
+ }; \
+ return cxxstdio::PrintFormatter<format_impl>::print(file, ## __VA_ARGS__); \
}())
-#define FSCANF(file, fmt, args...) \
- ([&]() -> int \
- { \
- struct format_impl \
- { \
- constexpr static \
- const char *scan_format() { return fmt; } \
- }; \
- return cxxstdio::ScanFormatter<format_impl>::scan(file, ## args); \
+#define FSCANF(file, fmt, ...) \
+ ([&]() -> int \
+ { \
+ struct format_impl \
+ { \
+ constexpr static \
+ const char *scan_format() { return fmt; } \
+ }; \
+ return cxxstdio::ScanFormatter<format_impl>::scan(file, ## __VA_ARGS__); \
}())
-#define PRINTF(fmt, args...) FPRINTF(stdout, fmt, ## args)
-#define SPRINTF(str, fmt, args...) FPRINTF(str, fmt, ## args)
-#define SCANF(fmt, args...) FSCANF(stdin, fmt, ## args)
-#define SSCANF(str, fmt, args...) FSCANF(str, fmt, ## args)
-
-#define STRPRINTF(fmt, args...) \
- ([&]() -> std::string \
- { \
- std::string _out_impl; \
- SPRINTF(_out_impl, fmt, ## args); \
- return _out_impl; \
+#define PRINTF(fmt, ...) FPRINTF(stdout, fmt, ## __VA_ARGS__)
+#define SPRINTF(str, fmt, ...) FPRINTF(str, fmt, ## __VA_ARGS__)
+#define SCANF(fmt, ...) FSCANF(stdin, fmt, ## __VA_ARGS__)
+#define SSCANF(str, fmt, ...) FSCANF(str, fmt, ## __VA_ARGS__)
+
+#define STRPRINTF(fmt, ...) \
+ ([&]() -> std::string \
+ { \
+ std::string _out_impl; \
+ SPRINTF(_out_impl, fmt, ## __VA_ARGS__);\
+ return _out_impl; \
}())
} // namespace cxxstdio
diff --git a/src/common/db.cpp b/src/common/db.cpp
index 06f85bc..448bfef 100644
--- a/src/common/db.cpp
+++ b/src/common/db.cpp
@@ -6,8 +6,6 @@
#include "utils.hpp"
-#define ROOT_SIZE 4096
-
static
int strdb_cmp(struct dbt *table, const char *a, const char* b)
{
diff --git a/src/common/sanity.hpp b/src/common/sanity.hpp
index 9bad464..e6f2807 100644
--- a/src/common/sanity.hpp
+++ b/src/common/sanity.hpp
@@ -18,7 +18,6 @@
# error "Please upgrade to at least GCC 4.6"
# endif
# if __GNUC_MINOR__ == 6
-# warning "Working around some annoying bugs in GCC 4.6 ..."
# define ANNOYING_GCC46_WORKAROUNDS
# endif
# endif
diff --git a/src/common/socket.cpp b/src/common/socket.cpp
index d3485d3..023a856 100644
--- a/src/common/socket.cpp
+++ b/src/common/socket.cpp
@@ -18,8 +18,10 @@
#include "mmo.hpp"
#include "utils.hpp"
+static
fd_set readfds;
int fd_max;
+static
int currentuse;
const uint32_t RFIFO_SIZE = 65536;
diff --git a/src/common/utils.cpp b/src/common/utils.cpp
index d8c0c12..d24c0a9 100644
--- a/src/common/utils.cpp
+++ b/src/common/utils.cpp
@@ -59,7 +59,6 @@ int e_mail_check(const char *email)
if (strchr(last_arobas, ch) != NULL)
{
return 0;
- break;
}
}
diff --git a/src/common/utils2.hpp b/src/common/utils2.hpp
index 7b2bc4a..3b652d5 100644
--- a/src/common/utils2.hpp
+++ b/src/common/utils2.hpp
@@ -4,6 +4,12 @@
#include <iterator>
#include <type_traits>
+#ifdef __clang__
+# define FALLTHROUGH [[clang::fallthrough]]
+#else
+# define FALLTHROUGH /* fallthrough */
+#endif
+
template<class T, class E, E max>
struct earray
{
@@ -109,19 +115,19 @@ struct remove_enum<E, true>
inline \
E operator & (E l, E r) \
{ \
- typedef typename underlying_type<E>::type U;\
+ typedef underlying_type<E>::type U; \
return E(U(l) & U(r)); \
} \
inline \
E operator | (E l, E r) \
{ \
- typedef typename underlying_type<E>::type U;\
+ typedef underlying_type<E>::type U; \
return E(U(l) | U(r)); \
} \
inline \
E operator ^ (E l, E r) \
{ \
- typedef typename underlying_type<E>::type U;\
+ typedef underlying_type<E>::type U; \
return E(U(l) ^ U(r)); \
} \
inline \
diff --git a/src/ladmin/ladmin.cpp b/src/ladmin/ladmin.cpp
index 854d1a1..1a57cbb 100644
--- a/src/ladmin/ladmin.cpp
+++ b/src/ladmin/ladmin.cpp
@@ -28,7 +28,8 @@
#include "../common/version.hpp"
-int eathena_interactive_session; // from core.c
+static
+int eathena_interactive_session;
#define Iprintf if (eathena_interactive_session) PRINTF
//-------------------------------INSTRUCTIONS------------------------------
@@ -40,10 +41,15 @@ int eathena_interactive_session; // from core.c
// Be sure that you authorize remote administration in login-server
// (see login_athena.conf, 'admin_state' parameter)
//-------------------------------------------------------------------------
+static
char loginserverip[16] = "127.0.0.1"; // IP of login-server
+static
int loginserverport = 6900; // Port of login-server
+static
char loginserveradminpassword[24] = "admin"; // Administration password
+static
int passenc = 2; // Encoding type of the password
+static
char ladmin_log_filename[1024] = "log/ladmin.log";
//-------------------------------------------------------------------------
// LIST of COMMANDs that you can type at the prompt:
@@ -225,19 +231,25 @@ char ladmin_log_filename[1024] = "log/ladmin.log";
// Displays complete information of an account.
//
//-------------------------------------------------------------------------
+static
int login_fd;
+static
int login_ip;
+static
int bytes_to_read = 0; // flag to know if we waiting bytes from login-server
+static
char parameters[1024]; // needs to be global since it's passed to the parse function
// really should be added to session data
+static
int list_first, list_last, list_type, list_count; // parameter to display a list of accounts
+static
int already_exit_function = 0; // sometimes, the exit function is called twice... so, don't log twice the message
//------------------------------
// Writing function of logs file
//------------------------------
-#define LADMIN_LOG(fmt, args...) \
- ladmin_log(static_cast<const std::string&>(STRPRINTF(fmt, ## args)))
+#define LADMIN_LOG(fmt, ...) \
+ ladmin_log(static_cast<const std::string&>(STRPRINTF(fmt, ## __VA_ARGS__)))
static
void ladmin_log(const_string line)
{
@@ -268,7 +280,6 @@ const char *makeordinal(int number)
{
return "th";
}
- return "";
}
//-----------------------------------------------------------------------------------------
@@ -1683,6 +1694,7 @@ int listaccount(char *param, int type)
case 1:
list_last = 0;
// use tests of the following value
+ FALLTHROUGH;
default:
if (list_first < 0)
list_first = 0;
diff --git a/src/login/login.cpp b/src/login/login.cpp
index b8dc4d0..1d01f72 100644
--- a/src/login/login.cpp
+++ b/src/login/login.cpp
@@ -38,35 +38,60 @@
static_assert(std::is_same<time_t, long>::value, "much code assumes time_t is a long (sorry)");
+static
int account_id_count = START_ACCOUNT_NUM;
+static
int server_num;
+static
int new_account_flag = 0;
+static
int login_port = 6900;
+static
char lan_char_ip[16];
+static
int subneti[4];
+static
int subnetmaski[4];
+static
char update_host[128] = "";
+static
char main_server[20] = "";
+static
char account_filename[1024] = "save/account.txt";
+static
char GM_account_filename[1024] = "conf/GM_account.txt";
+static
char login_log_filename[1024] = "log/login.log";
+static
char login_log_unknown_packets_filename[1024] =
"log/login_unknown_packets.log";
+static
int save_unknown_packets = 0;
+static
long creation_time_GM_account_file;
+static
int gm_account_filename_check_timer = 15; // Timer to check if GM_account file has been changed and reload GM account automaticaly (in seconds; default: 15)
+static
int display_parse_login = 0; // 0: no, 1: yes
+static
int display_parse_admin = 0; // 0: no, 1: yes
+static
int display_parse_fromchar = 0; // 0: no, 1: yes (without packet 0x2714), 2: all packets
+static
struct mmo_char_server server[MAX_SERVERS];
+static
int server_fd[MAX_SERVERS];
+static
int server_freezeflag[MAX_SERVERS]; // Char-server anti-freeze system. Counter. 5 ok, 4...0 freezed
+static
int anti_freeze_enable = 0;
+static
int ANTI_FREEZE_INTERVAL = 15;
+static
int login_fd;
enum
@@ -77,18 +102,29 @@ enum
ACO_STRSIZE = 128,
};
+static
int access_order = ACO_DENY_ALLOW;
+static
int access_allownum = 0;
+static
int access_denynum = 0;
+static
char *access_allow = NULL;
+static
char *access_deny = NULL;
+static
int access_ladmin_allownum = 0;
+static
char *access_ladmin_allow = NULL;
+static
int min_level_to_connect = 0; // minimum level of player/GM (0: player, 1-99: gm) to connect on the server
+static
int add_to_unlimited_account = 0; // Give possibility or not to adjust (ladmin command: timeadd) the time of an unlimited account.
+static
int start_limited_time = -1; // Starting additional sec from now for the limited time at creation of accounts (-1: unlimited time, 0 or more: additional sec from now)
+static
int check_ip_flag = 1; // It's to check IP of a player between login-server and char-server (part of anti-hacking system)
struct login_session_data
@@ -103,8 +139,10 @@ struct
int account_id, login_id1, login_id2;
int ip, sex, delflag;
} auth_fifo[AUTH_FIFO_SIZE];
+static
int auth_fifo_pos = 0;
+static
struct auth_dat
{
int account_id, sex;
@@ -121,16 +159,22 @@ struct auth_dat
struct global_reg account_reg2[ACCOUNT_REG2_NUM];
} *auth_dat;
+static
int auth_num = 0, auth_max = 0;
+static
int admin_state = 0;
+static
char admin_pass[24] = "";
+static
char gm_pass[64] = "";
+static
int level_new_gm = 60;
static
struct dbt *gm_account_db;
+static
pid_t pid = 0; // For forked DB writes
@@ -139,8 +183,8 @@ pid_t pid = 0; // For forked DB writes
//------------------------------
// Writing function of logs file
//------------------------------
-#define LOGIN_LOG(fmt, args...) \
- login_log(static_cast<const std::string&>(STRPRINTF(fmt, ## args)))
+#define LOGIN_LOG(fmt, ...) \
+ login_log(static_cast<const std::string&>(STRPRINTF(fmt, ## __VA_ARGS__)))
static
void login_log(const_string line)
{
@@ -336,7 +380,6 @@ int check_ip(struct in_addr ip)
{
flag = ACF_DENY;
return 0; // At this point, if it's 'deny', we refuse connection.
- break;
}
}
@@ -551,7 +594,6 @@ int mmo_auth_init(void)
if (line.back() == '\r')
{
#ifdef ANNOYING_GCC46_WORKAROUNDS
-# warning " and this one!"
line.resize(line.size() - 1);
#else
line.pop_back();
@@ -925,10 +967,8 @@ int mmo_auth(struct mmo_account *account, int fd)
case 9: // 8 = No MSG (actually, all states after 9 except 99 are No MSG, use only this)
case 100: // 99 = This ID has been totally erased
return auth_dat[i].state - 1;
- break;
default:
return 99; // 99 = ID has been totally erased
- break;
}
}
diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp
index fa3d23d..46c0e9e 100644
--- a/src/map/atcommand.cpp
+++ b/src/map/atcommand.cpp
@@ -5190,7 +5190,6 @@ int atcommand_mapinfo(const int fd, struct map_session_data *sd,
clif_displaymessage(fd,
"Please, enter at least a valid list number (usage: @mapinfo <0-3> [map]).");
return -1;
- break;
}
return 0;
@@ -6424,7 +6423,6 @@ int atcommand_character_item_list(const int fd, struct map_session_data *sd,
{
// replace trailing ", "
#ifdef ANNOYING_GCC46_WORKAROUNDS
-# warning " and "
output.resize(output.size() - 1);
#else
output.pop_back();
@@ -6550,7 +6548,6 @@ int atcommand_character_storage_list(const int fd, struct map_session_data *sd,
{
// replace last ", "
#ifdef ANNOYING_GCC46_WORKAROUNDS
-# warning " all of "
output.resize(output.size() - 1);
#else
output.pop_back();
@@ -6680,7 +6677,6 @@ int atcommand_character_cart_list(const int fd, struct map_session_data *sd,
if (!output.empty())
{
#ifdef ANNOYING_GCC46_WORKAROUNDS
-# warning " these ... "
output.resize(output.size() - 1);
#else
output.pop_back();
@@ -6764,7 +6760,7 @@ int atcommand_charkillable(const int fd, struct map_session_data *,
if (!message || !*message)
return -1;
- if ((pl_sd = map_nick2sd((char *) message)) == NULL)
+ if ((pl_sd = map_nick2sd(message)) == NULL)
return -1;
pl_sd->special_state.killable = !pl_sd->special_state.killable;
@@ -6889,7 +6885,7 @@ int atcommand_chareffect(const int fd, struct map_session_data *,
return -1;
}
- if ((pl_sd = map_nick2sd((char *) target)) == NULL)
+ if ((pl_sd = map_nick2sd(target)) == NULL)
return -1;
clif_specialeffect(&pl_sd->bl, type, 0);
@@ -6935,7 +6931,7 @@ int atcommand_chardropall(const int fd, struct map_session_data *,
if (!message || !*message)
return -1;
- if ((pl_sd = map_nick2sd((char *) message)) == NULL)
+ if ((pl_sd = map_nick2sd(message)) == NULL)
return -1;
for (i = 0; i < MAX_INVENTORY; i++)
{
@@ -7009,7 +7005,7 @@ int atcommand_charstoreall(const int fd, struct map_session_data *sd,
if (!message || !*message)
return -1;
- if ((pl_sd = map_nick2sd((char *) message)) == NULL)
+ if ((pl_sd = map_nick2sd(message)) == NULL)
return -1;
if (storage_storageopen(pl_sd) == 1)
@@ -7297,7 +7293,7 @@ int atcommand_adjgmlvl(const int fd, struct map_session_data *,
return -1;
}
- if ((pl_sd = map_nick2sd((char *) user)) == NULL)
+ if ((pl_sd = map_nick2sd(user)) == NULL)
return -1;
pc_set_gm_level(pl_sd->status.account_id, newlev);
@@ -7321,7 +7317,7 @@ int atcommand_trade(const int, struct map_session_data *sd,
if (!message || !*message)
return -1;
- if ((pl_sd = map_nick2sd((char *) message)) != NULL)
+ if ((pl_sd = map_nick2sd(message)) != NULL)
{
trade_traderequest(sd, pl_sd->bl.id);
return 0;
@@ -7340,7 +7336,7 @@ int atcommand_unmute(const int, struct map_session_data *sd,
if (!message || !*message)
return -1;
- if ((pl_sd = map_nick2sd((char *) message)) != NULL)
+ if ((pl_sd = map_nick2sd(message)) != NULL)
{
if (pl_sd->sc_data[SC_NOCHAT].timer != -1)
{
diff --git a/src/map/atcommand.hpp b/src/map/atcommand.hpp
index ec69cc7..4d3b592 100644
--- a/src/map/atcommand.hpp
+++ b/src/map/atcommand.hpp
@@ -199,4 +199,7 @@ int atcommand_config_read(const char *cfgName);
void log_atcommand(struct map_session_data *sd, const_string cmd);
+// only used by map.cpp
+extern char *gm_logfile_name;
+
#endif // ATCOMMAND_HPP
diff --git a/src/map/battle.cpp b/src/map/battle.cpp
index 3b57d13..7da685f 100644
--- a/src/map/battle.cpp
+++ b/src/map/battle.cpp
@@ -176,7 +176,6 @@ int battle_get_max_hp(struct block_list *bl)
max_hp = 1;
return max_hp;
}
- return 1;
}
/*==========================================
@@ -685,7 +684,6 @@ int battle_get_atk2(struct block_list *bl)
atk2 = 0;
return atk2;
}
- return 0;
}
/*==========================================
@@ -993,8 +991,6 @@ int battle_get_speed(struct block_list *bl)
speed = 1;
return speed;
}
-
- return 1000;
}
/*==========================================
@@ -1075,7 +1071,6 @@ int battle_get_adelay(struct block_list *bl)
adelay = battle_config.monster_max_aspd << 1;
return adelay;
}
- return 4000;
}
int battle_get_amotion(struct block_list *bl)
@@ -1140,7 +1135,6 @@ int battle_get_amotion(struct block_list *bl)
amotion = battle_config.monster_max_aspd;
return amotion;
}
- return 2000;
}
int battle_get_dmotion(struct block_list *bl)
diff --git a/src/map/chrif.cpp b/src/map/chrif.cpp
index 41c1381..6ab786c 100644
--- a/src/map/chrif.cpp
+++ b/src/map/chrif.cpp
@@ -34,7 +34,6 @@ const int packet_len_table[0x20] = {
};
int char_fd;
-int srvinfo;
static
char char_ip_str[16];
static
diff --git a/src/map/chrif.hpp b/src/map/chrif.hpp
index 7c4a431..dce1ae3 100644
--- a/src/map/chrif.hpp
+++ b/src/map/chrif.hpp
@@ -30,4 +30,7 @@ int chrif_send_divorce(int char_id);
int do_init_chrif (void);
+// only used by intif.cpp
+extern int char_fd;
+
#endif // CHRIF_HPP
diff --git a/src/map/clif.cpp b/src/map/clif.cpp
index e306c23..edae508 100644
--- a/src/map/clif.cpp
+++ b/src/map/clif.cpp
@@ -140,7 +140,6 @@ static
struct in_addr map_ip;
static
int map_port = 5121;
-int map_fd;
char talkie_mes[80];
static
@@ -264,7 +263,7 @@ void clif_send_sub(struct block_list *bl, const unsigned char *buf, int len,
clif_emotion_towards(src_bl, bl, EMOTE_IGNORED);
return;
}
- /* fall through... */
+ FALLTHROUGH;
case AREA_WOC:
if ((sd && sd->chatID) || (bl && bl == src_bl))
return;
@@ -414,6 +413,7 @@ int clif_send(const uint8_t *buf, int len, struct block_list *bl, SendWho type)
y0 = bl->y - AREA_SIZE;
x1 = bl->x + AREA_SIZE;
y1 = bl->y + AREA_SIZE;
+ FALLTHROUGH;
case PARTY: // 全パーティーメンバに送信
case PARTY_WOS: // 自分以外の全パーティーメンバに送信
case PARTY_SAMEMAP: // 同じマップの全パーティーメンバに送信
@@ -3719,7 +3719,8 @@ int clif_party_leaved(struct party *p, struct map_session_data *sd,
*/
int clif_party_message(struct party *p, int account_id, const char *mes, int len)
{
- struct map_session_data *sd;
+ // always set, but clang is not smart enough
+ struct map_session_data *sd = nullptr;
int i;
nullpo_ret(p);
@@ -5557,6 +5558,7 @@ typedef struct func_table
int rate;
} func_table;
// *INDENT-OFF*
+static
func_table clif_parse_func_table[0x220] =
{
{ NULL, 0 }, // 0
diff --git a/src/map/intif.cpp b/src/map/intif.cpp
index 44d381b..bb27643 100644
--- a/src/map/intif.cpp
+++ b/src/map/intif.cpp
@@ -40,7 +40,6 @@ const int packet_len_table[] = {
11, -1, 7, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
-extern int char_fd; // inter serverのfdはchar_fdを使う
#define inter_fd char_fd // エイリアス
//-----------------------------------------------------------------
diff --git a/src/map/magic-expr.cpp b/src/map/magic-expr.cpp
index 904d4a4..6712af3 100644
--- a/src/map/magic-expr.cpp
+++ b/src/map/magic-expr.cpp
@@ -1310,7 +1310,7 @@ int functions_are_sorted = 0;
static
int compare_fun(const void *lhs, const void *rhs)
{
- return strcmp(((fun_t *) lhs)->name, ((fun_t *) rhs)->name);
+ return strcmp(((const fun_t *) lhs)->name, ((const fun_t *) rhs)->name);
}
fun_t *magic_get_fun(const char *name, int *index)
diff --git a/src/map/magic-interpreter-base.cpp b/src/map/magic-interpreter-base.cpp
index f0fc6e9..57f6fe6 100644
--- a/src/map/magic-interpreter-base.cpp
+++ b/src/map/magic-interpreter-base.cpp
@@ -10,6 +10,9 @@ void set_int_p(val_t *v, int i, TY t)
v->v.v_int = i;
}
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-macros"
+
#define set_int(v, i) set_int_p(v, i, TY_INT)
#define set_dir(v, i) set_int_p(v, i, TY_DIR)
@@ -46,6 +49,8 @@ void set_spell SETTER(spell_t *, TY_SPELL, v_spell)
#define set_env_invocation(v, x) setenv(set_invocation, v, x)
#define set_env_spell(v, x) setenv(set_spell, v, x)
+#pragma GCC diagnostic pop
+
magic_conf_t magic_conf; /* Global magic conf */
env_t magic_default_env = { &magic_conf, NULL };
@@ -66,8 +71,8 @@ const char *magic_find_invocation(const char *spellname)
static
int spell_compare(const void *lhs, const void *rhs)
{
- return strcmp((*((spell_t **) lhs))->invocation,
- (*((spell_t **) rhs))->invocation);
+ return strcmp((*((const spell_t *const*) lhs))->invocation,
+ (*((const spell_t *const*) rhs))->invocation);
}
spell_t *magic_find_spell(char *invocation)
@@ -103,8 +108,8 @@ spell_t *magic_find_spell(char *invocation)
static
int compare_teleport_anchor(const void *lhs, const void *rhs)
{
- return strcmp((*((teleport_anchor_t **) lhs))->invocation,
- (*((teleport_anchor_t **) rhs))->invocation);
+ return strcmp((*((const teleport_anchor_t *const*) lhs))->invocation,
+ (*((const teleport_anchor_t *const*) rhs))->invocation);
}
const char *magic_find_anchor_invocation(const char *anchor_name)
diff --git a/src/map/magic-stmt.cpp b/src/map/magic-stmt.cpp
index de4a15e..e911f92 100644
--- a/src/map/magic-stmt.cpp
+++ b/src/map/magic-stmt.cpp
@@ -897,7 +897,7 @@ int operation_count;
static
int compare_operations(const void *lhs, const void *rhs)
{
- return strcmp(((op_t *) lhs)->name, ((op_t *) rhs)->name);
+ return strcmp(((const op_t *) lhs)->name, ((const op_t *) rhs)->name);
}
op_t *magic_get_op(char *name, int *index)
@@ -1406,6 +1406,7 @@ int spell_run(invocation_t *invocation, int allow_delete)
case EFFECT_ABORT:
invocation->flags |= INVOCATION_FLAG_ABORTED;
invocation->end_effect = NULL;
+ FALLTHROUGH;
case EFFECT_END:
clear_stack(invocation);
next = NULL;
diff --git a/src/map/magic.hpp b/src/map/magic.hpp
index 4cdce18..848ba46 100644
--- a/src/map/magic.hpp
+++ b/src/map/magic.hpp
@@ -36,7 +36,7 @@ void magic_unshroud(character_t *character);
*
* \param invocation The invocation to notify
* \param bl_id ID of the PC for whom this happened
- * \param type sc_id ID of the status change entry that finished
+ * \param sc_id ID of the status change entry that finished
* \param supplanted Whether the status_change finished normally (0) or was supplanted by a new status_change (1)
*/
void spell_effect_report_termination(int invocation, int bl_id,
diff --git a/src/map/map.cpp b/src/map/map.cpp
index e1b96a8..8732186 100644
--- a/src/map/map.cpp
+++ b/src/map/map.cpp
@@ -65,6 +65,7 @@ int bl_list_count = 0;
struct map_data map[MAX_MAP_PER_SERVER];
int map_num = 0;
+static
int map_port = 0;
int autosave_interval = DEFAULT_AUTOSAVE_INTERVAL;
@@ -1736,11 +1737,11 @@ int map_delmap(const char *mapname)
return 0;
}
-extern char *gm_logfile_name;
-
#define LOGFILE_SECONDS_PER_CHUNK_SHIFT 10
+static
FILE *map_logfile = NULL;
+static
char *map_logfile_name = NULL;
static
long map_logfile_index;
diff --git a/src/map/map.hpp b/src/map/map.hpp
index 3d15bb5..8f534f5 100644
--- a/src/map/map.hpp
+++ b/src/map/map.hpp
@@ -701,10 +701,10 @@ int map_quit(struct map_session_data *);
int map_addnpc(int, struct npc_data *);
void map_log(const_string line);
-#define MAP_LOG(format, args...) \
- map_log(static_cast<const std::string&>(STRPRINTF(format, ##args)));
+#define MAP_LOG(format, ...) \
+ map_log(static_cast<const std::string&>(STRPRINTF(format, ## __VA_ARGS__)))
-#define MAP_LOG_PC(sd, fmt, args...) MAP_LOG("PC%d %d:%d,%d " fmt, sd->status.char_id, sd->bl.m, sd->bl.x, sd->bl.y, ## args)
+#define MAP_LOG_PC(sd, fmt, ...) MAP_LOG("PC%d %d:%d,%d " fmt, sd->status.char_id, sd->bl.m, sd->bl.x, sd->bl.y, ## __VA_ARGS__)
// 床アイテム関連
void map_clearflooritem_timer(timer_id, tick_t, custom_id_t, custom_data_t);
diff --git a/src/map/mob.cpp b/src/map/mob.cpp
index df739a8..06026de 100644
--- a/src/map/mob.cpp
+++ b/src/map/mob.cpp
@@ -21,10 +21,6 @@
#include "pc.hpp"
#include "skill.hpp"
-#ifndef max
-#define max( a, b ) (((a) > (b)) ? (a) : (b) )
-#endif
-
#define MIN_MOBTHINKTIME 100
#define MOB_LAZYMOVEPERC 50 // Move probability in the negligent mode MOB (rate of 1000 minute)
@@ -4606,7 +4602,8 @@ int mob_readskilldb(void)
{
char *sp[20], *p;
int mob_id;
- struct mob_skill *ms;
+ // always initialized, but clang is not smart enough yet
+ struct mob_skill *ms = nullptr;
int j = 0;
if (line[0] == '/' && line[1] == '/')
diff --git a/src/map/mob.hpp b/src/map/mob.hpp
index 70fcf06..6cedb1e 100644
--- a/src/map/mob.hpp
+++ b/src/map/mob.hpp
@@ -21,7 +21,7 @@ struct mob_skill
MSC cond1;
int cond2i;
StatusChange cond2sc() { return StatusChange(cond2i); }
- SkillID cond2sk() { return SkillID(cond2i); };
+ SkillID cond2sk() { return SkillID(cond2i); }
MST target;
int val[5];
short emotion;
diff --git a/src/map/npc.cpp b/src/map/npc.cpp
index 8966d49..0e406c2 100644
--- a/src/map/npc.cpp
+++ b/src/map/npc.cpp
@@ -2054,7 +2054,7 @@ void npc_free(struct npc_data *nd)
static
void ev_release(db_key_t key, db_val_t val)
{
- free((char*)key.s);
+ free(key.ms);
free(val);
}
diff --git a/src/map/pc.cpp b/src/map/pc.cpp
index 5780525..2c8a4e7 100644
--- a/src/map/pc.cpp
+++ b/src/map/pc.cpp
@@ -3106,6 +3106,7 @@ int pc_bonus2(struct map_session_data *sd, SP type, int type2, int val)
sd->random_attack_increase_per += val;
break;
} // end addition
+ break;
default:
if (battle_config.error_log)
PRINTF("pc_bonus2: unknown type %d %d %d!\n",
@@ -4784,7 +4785,8 @@ int pc_checkbaselevelup(struct map_session_data *sd)
//レベルアップしたのでパーティー情報を更新する
//(公平範囲チェック)
party_send_movemap(sd);
- MAP_LOG_XP(sd, "LEVELUP") return 1;
+ MAP_LOG_XP(sd, "LEVELUP");
+ return 1;
}
return 0;
@@ -8496,5 +8498,6 @@ int pc_logout(struct map_session_data *sd) // [fate] Player logs out
#endif
pc_setglobalreg(sd, "MAGIC_CAST_TICK", 0);
- MAP_LOG_STATS(sd, "LOGOUT") return 0;
+ MAP_LOG_STATS(sd, "LOGOUT");
+ return 0;
}
diff --git a/src/map/script.cpp b/src/map/script.cpp
index 25db80b..eca91e6 100644
--- a/src/map/script.cpp
+++ b/src/map/script.cpp
@@ -46,7 +46,9 @@ ScriptCode *script_buf;
static
int script_pos, script_size;
+static
char *str_buf;
+static
int str_pos, str_size;
static
struct str_data_t
@@ -59,7 +61,9 @@ struct str_data_t
int val;
int next;
} *str_data;
+static
int str_num = LABEL_START, str_data_size;
+static
int str_hash[16];
static
@@ -449,7 +453,8 @@ void disp_error_message(const char *mes, const char *pos_)
{
const char *linestart = p;
char *lineend = const_cast<char *>(strchr(p, '\n'));
- char c;
+ // always initialized, but clang is not smart enough
+ char c = '\0';
if (lineend)
{
c = *lineend;
@@ -2374,6 +2379,7 @@ void builtin_strcharinfo(ScriptState *st)
// indexed by the equip_* in db/const.txt
// TODO change to use EQUIP
+static
EPOS equip[10] =
{
EPOS::HAT,
@@ -4128,7 +4134,7 @@ void builtin_message(ScriptState *st)
const char *player = conv_str(st, &(st->stack->stack_data[st->start + 2]));
const char *msg = conv_str(st, &(st->stack->stack_data[st->start + 3]));
- if ((pl_sd = map_nick2sd((char *) player)) == NULL)
+ if ((pl_sd = map_nick2sd(player)) == NULL)
return;
clif_displaymessage(pl_sd->fd, msg);
@@ -4741,7 +4747,7 @@ void run_script_main(const ScriptCode *script, int pos_, int, int,
break;
case ScriptCode::POS:
case ScriptCode::NAME:
- push_val(stack, c, (*(int *)(script + st->pos)) & 0xffffff);
+ push_val(stack, c, (*(const int *)(script + st->pos)) & 0xffffff);
st->pos += 3;
break;
case ScriptCode::ARG:
diff --git a/src/map/skill.cpp b/src/map/skill.cpp
index 68f27fc..98b6f7d 100644
--- a/src/map/skill.cpp
+++ b/src/map/skill.cpp
@@ -2549,7 +2549,9 @@ void skill_timer(timer_id, tick_t tick, custom_id_t id, custom_data_t data)
case RG_INTIMIDATE:
if (sd && !map[src->m].flag.noteleport)
{
- int x, y, i, j, c;
+ // always initialized, but clang is not smart enough
+ int x = 0, y = 0;
+ int i, j, c;
pc_randomwarp(sd, 3);
for (i = 0; i < 16; i++)
{
@@ -2578,7 +2580,9 @@ void skill_timer(timer_id, tick_t tick, custom_id_t id, custom_data_t data)
}
else if (md && !map[src->m].flag.monster_noteleport)
{
- int x, y, i, j, c;
+ // always initialized, but clang isn't smart enough
+ int x = 0, y = 0;
+ int i, j, c;
mob_warp(md, -1, -1, -1, 3);
for (i = 0; i < 16; i++)
{
@@ -7998,6 +8002,8 @@ int skill_use_id(struct map_session_data *sd, int target_id,
sd->skilllv_old = sd->skilllv;
break;
}
+ // TODO: determine if this was supposed to fallthrough instead
+ break;
case BD_ENCORE: /* アンコール */
if (sd->skillid_dance == SkillID::ZERO)
{ //前回使用した踊りがないとだめ
@@ -8896,6 +8902,8 @@ void skill_trap_splash(struct block_list *bl,
sg->skill_lv, tick,
(sg->val2) ? BCT_mid_x05 : BCT_ZERO);
}
+ // TODO: determine if this was supposed to break
+ FALLTHROUGH;
case 0x97: /* フリージングトラップ */
skill_attack(BF_WEAPON, ss, src, bl, sg->skill_id,
sg->skill_lv, tick, (sg->val2) ? BCT_mid_x05 : BCT_ZERO);
@@ -9812,7 +9820,7 @@ int skill_status_effect(struct block_list *bl, StatusChange type,
Opt3 *opt3;
int opt_flag = 0, calc_flag = 0;
int race, mode, elem, undead_flag;
- SP updateflag;
+ SP updateflag = SP::ZERO;
int scdef = 0;
nullpo_ret(bl);
@@ -10044,6 +10052,7 @@ int skill_status_effect(struct block_list *bl, StatusChange type,
calc_flag = 1;
if (tick <= 0)
tick = 1000; /* (オートバーサーク) */
+ break;
case SC_GLORIA: /* グロリア */
calc_flag = 1;
break;
@@ -10245,6 +10254,7 @@ int skill_status_effect(struct block_list *bl, StatusChange type,
case SC_SPEEDPOTION0: /* 増速ポーション */
*opt2 |= Opt2::_speedpotion0;
+ FALLTHROUGH;
case SC_SPEEDPOTION1:
case SC_SPEEDPOTION2:
calc_flag = 1;
@@ -10255,6 +10265,7 @@ int skill_status_effect(struct block_list *bl, StatusChange type,
/* atk & matk potions [Valaris] */
case SC_ATKPOT:
*opt2 |= Opt2::_atkpot;
+ FALLTHROUGH;
case SC_MATKPOT:
calc_flag = 1;
tick = 1000 * tick;
@@ -10528,6 +10539,7 @@ int skill_status_effect(struct block_list *bl, StatusChange type,
break;
case SC_HASTE:
calc_flag = 1;
+ break;
case SC_SPLASHER: /* ベナムスプラッシャー */
case SC_PHYS_SHIELD:
case SC_MBARRIER:
@@ -11273,7 +11285,8 @@ void skill_unit_timer_sub(struct block_list *bl, unsigned int tick)
case 0x99: /* トーキーボックス */
{
struct block_list *src = map_id2bl(group->src_id);
- if (group->unit_id == 0x91 && group->val2);
+ if (group->unit_id == 0x91 && group->val2)
+ ;
else
{
if (src && src->type == BL_PC)
@@ -11286,6 +11299,8 @@ void skill_unit_timer_sub(struct block_list *bl, unsigned int tick)
}
}
}
+ // TODO: determine if this was supposed to be break
+ FALLTHROUGH;
default:
skill_delunit(unit);
}
diff --git a/src/map/storage.cpp b/src/map/storage.cpp
index df228d1..d212c9d 100644
--- a/src/map/storage.cpp
+++ b/src/map/storage.cpp
@@ -28,8 +28,8 @@ struct dbt *storage_db;
static
int storage_comp_item(const void *_i1, const void *_i2)
{
- struct item *i1 = (struct item *) _i1;
- struct item *i2 = (struct item *) _i2;
+ const struct item *i1 = (const struct item *) _i1;
+ const struct item *i2 = (const struct item *) _i2;
if (i1->nameid == i2->nameid)
return 0;
diff --git a/src/map/trade.cpp b/src/map/trade.cpp
index d5be2ad..6b44752 100644
--- a/src/map/trade.cpp
+++ b/src/map/trade.cpp
@@ -310,8 +310,6 @@ void trade_tradecancel(struct map_session_data *sd)
}
}
-#define MAP_LOG_PC(sd, fmt, args...) MAP_LOG("PC%d %d:%d,%d " fmt, sd->status.char_id, sd->bl.m, sd->bl.x, sd->bl.y, ## args)
-
/*==========================================
* 取引許諾(trade押し)
*------------------------------------------
diff --git a/src/tool/eathena-monitor.cpp b/src/tool/eathena-monitor.cpp
index b4c89cf..eb1f425 100644
--- a/src/tool/eathena-monitor.cpp
+++ b/src/tool/eathena-monitor.cpp
@@ -68,15 +68,22 @@ size_t goto_newline(const char* ptr) {
}
// initialiized to $HOME/tmwserver
+static
const char *workdir;
//the rest are relative to workdir
+static
const char *login_server = LOGIN_SERVER;
+static
const char *map_server = MAP_SERVER;
+static
const char *char_server = CHAR_SERVER;
+static
const char *logfile = LOGFILE;
// this variable is hard-coded, but the command-line is checked first
+static
const char *config = CONFIG;
+static
pid_t pid_login, pid_map, pid_char;
static
@@ -156,7 +163,10 @@ pid_t start_process(const char *exec) {
return 0;
}
if (pid == 0) {
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wcast-qual"
execv(exec, (char**)args);
+#pragma GCC diagnostic pop
perror("Failed to exec");
kill(getppid(), SIGABRT);
exit(1);
diff --git a/src/warnings.hpp b/src/warnings.hpp
index 63dd79b..f280014 100644
--- a/src/warnings.hpp
+++ b/src/warnings.hpp
@@ -31,7 +31,7 @@
#ifdef __clang__
# if __clang_major__ < 3
# error "your clang is way too old"
-# elif __clang_major == 3
+# elif __clang_major__ == 3
# if __clang_minor__ < 1
# error "your clang is too old"
# endif // __clang_minor__
@@ -167,7 +167,7 @@
/// Warn about things that will change when compiling
/// with an ABI-compliant compiler
-X(-Wabi)
+I(-Wabi)
/// Warn if a subobject has an abi_tag attribute that
/// the complete object type does not have
@@ -177,7 +177,7 @@ WG48(-Wabi-tag)
E(-Waddress)
/// Warn about returning structures, unions or arrays
-X(-Waggregate-return)
+I(-Waggregate-return)
/// Warn if an array is accessed out of bounds
E(-Warray-bounds)
@@ -198,7 +198,7 @@ E(-Wc++0x-compat)
X(-Wcast-align)
/// Warn about casts which discard qualifiers
-X(-Wcast-qual)
+W(-Wcast-qual)
/// Warn about subscripts whose type is "char"
E(-Wchar-subscripts)
@@ -217,18 +217,21 @@ X(-Wconversion)
/// Warn for converting NULL from/to a non-pointer
/// type
-X(-Wconversion-null)
+E(-Wconversion-null)
/// Warn in case profiles in -fprofile-use do not
/// match
WG(-Wcoverage-mismatch)
+///
+XC(-Wcovered-switch-default)
+
/// Warn when a #warning directive is encountered
-EG(-Wcpp)
+WG(-Wcpp)
/// Warn when all constructors and destructors are
/// private
-X(-Wctor-dtor-privacy)
+E(-Wctor-dtor-privacy)
/// Warn about deleting polymorphic objects with non-
/// virtual destructors
@@ -241,19 +244,25 @@ W(-Wdeprecated)
/// Warn about uses of __attribute__((deprecated))
/// declarations
W(-Wdeprecated-declarations)
+#ifdef QUIET
+I(-Wdeprecated-declarations)
+#endif
/// Warn when an optimization pass is disabled
-X(-Wdisabled-optimization)
+W(-Wdisabled-optimization)
/// Warn about compile-time integer division by zero
E(-Wdiv-by-zero)
+///
+WC(-Wdocumentation)
+
/// Warn about implicit conversions from "float" to
/// "double"
-XG(-Wdouble-promotion)
+IG(-Wdouble-promotion)
/// Warn about violations of Effective C++ style rules
-X(-Weffc++)
+I(-Weffc++)
/// Warn about an empty body in an if or else
/// statement
@@ -265,9 +274,12 @@ E(-Wendif-labels)
/// Warn about comparison of different enum types
E(-Wenum-compare)
+///
+EC(-Wextra-semi)
+
/// Warn if testing floating point numbers for
/// equality
-X(-Wfloat-equal)
+E(-Wfloat-equal)
/// Warn about printf/scanf/strftime/strfmon format
/// string anomalies
@@ -282,13 +294,15 @@ EG(-Wformat-contains-nul)
E(-Wformat-extra-args)
/// Warn about format strings that are not literals
-// Available in clang, but not smart enough to handle constexpr.
EG(-Wformat-nonliteral)
+// Available in clang, but not smart enough to handle constexpr.
+IC(-Wformat-nonliteral)
/// Warn about possible security problems with format
/// functions
-// Same.
EG(-Wformat-security)
+// Same.
+IC(-Wformat-security)
/// Warn about strftime formats yielding 2-digit years
E(-Wformat-y2k)
@@ -304,13 +318,16 @@ EG47(-Wfree-nonheap-object)
/// Warn whenever type qualifiers are ignored.
E(-Wignored-qualifiers)
+///
+EC(-Wimplicit-fallthrough)
+
/// Warn about C++11 inheriting constructors when the
/// base has a variadic constructor
WG48(-Winherited-variadic-ctor)
/// Warn about variables which are initialized to
/// themselves
-X(-Winit-self)
+E(-Winit-self)
/// Warn when an inlined function cannot be inlined
X(-Winline)
@@ -327,7 +344,7 @@ WG47(-Winvalid-memory-model)
E(-Winvalid-offsetof)
/// Warn about PCH files that are found but not used
-X(-Winvalid-pch)
+E(-Winvalid-pch)
/// Warn when a string or character literal is
/// followed by a ud-suffix which does not begin with
@@ -339,7 +356,7 @@ WG48(-Wliteral-suffix)
WG(-Wlogical-op)
/// Do not warn about using "long long" when -pedantic
-X(-Wlong-long)
+I(-Wlong-long)
/// Warn about suspicious declarations of "main"
E(-Wmain)
@@ -364,15 +381,19 @@ IG(-Wmissing-field-initializers)
/// Warn about functions which might be candidates
/// for format attributes
-X(-Wmissing-format-attribute)
+E(-Wmissing-format-attribute)
/// Warn about user-specified include directories
/// that do not exist
-X(-Wmissing-include-dirs)
+E(-Wmissing-include-dirs)
/// Warn about functions which might be candidates
/// for __attribute__((noreturn))
-X(-Wmissing-noreturn)
+W(-Wmissing-noreturn)
+
+///
+// like -Wmissing-declarations but for variables instead of functions
+EC(-Wmissing-variable-declarations)
/// Warn about constructs not instrumented by
/// -fmudflap
@@ -396,12 +417,15 @@ WG(-Wnoexcept)
EG(-Wnon-template-friend)
/// Warn about non-virtual destructors
-X(-Wnon-virtual-dtor)
+E(-Wnon-virtual-dtor)
/// Warn about NULL being passed to argument slots
/// marked as requiring non-NULL
E(-Wnonnull)
+///
+XC(-Wnull-conversion)
+
/// Warn if a C-style cast is used in a program
X(-Wold-style-cast)
@@ -413,11 +437,11 @@ W(-Woverflow)
//X(-Woverlength-strings)
/// Warn about overloaded virtual function names
-X(-Woverloaded-virtual)
+E(-Woverloaded-virtual)
/// Warn when the packed attribute has no effect on
/// struct layout
-X(-Wpacked)
+E(-Wpacked)
/// Warn about packed bit-fields whose offset changed
/// in GCC 4.4
@@ -425,7 +449,7 @@ WG(-Wpacked-bitfield-compat)
/// Warn when padding is required to align structure
/// members
-X(-Wpadded)
+I(-Wpadded)
/// Warn about possibly missing parentheses
E(-Wparentheses)
@@ -433,14 +457,15 @@ E(-Wparentheses)
/// Issue warnings needed for strict compliance to
/// the standard
EG48(-Wpedantic)
-WC(-Wpedantic)
+// a bit too noisy
+XC(-Wpedantic)
/// Warn when converting the type of pointers to
/// member functions
EG(-Wpmf-conversions)
/// Warn about function pointer arithmetic
-X(-Wpointer-arith)
+E(-Wpointer-arith)
/// Warn about misuses of pragmas
EG(-Wpragmas)
@@ -466,7 +491,7 @@ E(-Wreturn-type)
E(-Wsequence-point)
/// Warn when one local variable shadows another
-X(-Wshadow)
+E(-Wshadow)
/// Warn about signed-unsigned comparisons
X(-Wsign-compare)
@@ -522,7 +547,7 @@ E(-Wtype-limits)
/// Warn if an undefined macro is used in an #if
/// directive
-X(-Wundef)
+E(-Wundef)
/// Warn about uninitialized automatic variables
E(-Wuninitialized)
@@ -530,6 +555,10 @@ E(-Wuninitialized)
/// Warn about unrecognized pragmas
E(-Wunknown-pragmas)
+///
+// Not an error because of some remaining enum+default
+WC(-Wunreachable-code)
+
/// Warn if the loop cannot be optimized due to
/// nontrivial assumptions.
XG(-Wunsafe-loop-optimizations)
@@ -553,7 +582,7 @@ EG47(-Wunused-local-typedefs)
/// Warn about macros defined in the main file that
/// are not used
-X(-Wunused-macros)
+W(-Wunused-macros)
/// Warn when a function parameter is unused
E(-Wunused-parameter)
@@ -561,7 +590,7 @@ E(-Wunused-parameter)
/// Warn if a caller of a function, marked with
/// attribute warn_unused_result, does not use its
/// return value
-X(-Wunused-result)
+W(-Wunused-result)
/// Warn when an expression value is unused
E(-Wunused-value)
@@ -577,7 +606,7 @@ XG48(-Wuseless-cast)
EG48(-Wvarargs)
/// Warn about using variadic macros
-X(-Wvariadic-macros)
+W(-Wvariadic-macros)
/// Warn when a vector operation is compiled
/// outside the SIMD