summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2013-12-06 14:15:43 -0800
committerBen Longbons <b.r.longbons@gmail.com>2013-12-06 14:15:49 -0800
commit3eea219548e84efdbc3148ce378fcba865f97a01 (patch)
tree6ece594f60ddff038cf9c1d94b99d8d66a00bc20
parent1458563f00deebbbcf3e8049dc90157fb825fae3 (diff)
downloadtmwa-3eea219548e84efdbc3148ce378fcba865f97a01.tar.gz
tmwa-3eea219548e84efdbc3148ce378fcba865f97a01.tar.bz2
tmwa-3eea219548e84efdbc3148ce378fcba865f97a01.tar.xz
tmwa-3eea219548e84efdbc3148ce378fcba865f97a01.zip
Add basic source formatting tools
-rw-r--r--.travis.yml2
-rw-r--r--real.make26
-rw-r--r--src/char/char.hpp14
-rw-r--r--src/char/int_party.hpp2
-rw-r--r--src/char/int_storage.hpp2
-rw-r--r--src/char/inter.hpp4
-rw-r--r--src/common/const_array.hpp22
-rw-r--r--src/common/core.hpp4
-rw-r--r--src/common/dumb_ptr.hpp18
-rw-r--r--src/common/extract.hpp12
-rw-r--r--src/common/human_time_diff.hpp6
-rw-r--r--src/common/intern-pool.hpp12
-rw-r--r--src/common/ip.hpp8
-rw-r--r--src/common/md5calc.cpp2
-rw-r--r--src/common/md5calc.hpp22
-rw-r--r--src/common/mmo.hpp10
-rw-r--r--src/common/nullpo.hpp2
-rw-r--r--src/common/socket.cpp4
-rw-r--r--src/common/utils.hpp26
-rw-r--r--src/common/utils2.hpp98
-rw-r--r--src/conf/version.hpp16
-rw-r--r--src/io/cxxstdio.hpp100
-rw-r--r--src/io/fwd.hpp2
-rw-r--r--src/io/lock.hpp4
-rw-r--r--src/io/read.hpp4
-rw-r--r--src/io/write.hpp6
-rw-r--r--src/map/atcommand.hpp6
-rw-r--r--src/map/battle.hpp12
-rw-r--r--src/map/battle.t.hpp2
-rw-r--r--src/map/chrif.hpp10
-rw-r--r--src/map/clif.hpp20
-rw-r--r--src/map/clif.t.hpp2
-rw-r--r--src/map/grfio.hpp6
-rw-r--r--src/map/intif.hpp6
-rw-r--r--src/map/itemdb.hpp6
-rw-r--r--src/map/magic-expr-eval.hpp58
-rw-r--r--src/map/magic-expr.cpp30
-rw-r--r--src/map/magic-expr.hpp8
-rw-r--r--src/map/magic-interpreter-aux.hpp2
-rw-r--r--src/map/magic-interpreter-lexer.lpp2
-rw-r--r--src/map/magic-interpreter-parser.ypp2
-rw-r--r--src/map/magic-interpreter.hpp38
-rw-r--r--src/map/magic-interpreter.t.hpp2
-rw-r--r--src/map/magic.hpp10
-rw-r--r--src/map/map.hpp40
-rw-r--r--src/map/map.t.hpp186
-rw-r--r--src/map/mob.hpp20
-rw-r--r--src/map/mob.t.hpp2
-rw-r--r--src/map/npc.hpp10
-rw-r--r--src/map/party.hpp6
-rw-r--r--src/map/path.hpp2
-rw-r--r--src/map/pc.cpp26
-rw-r--r--src/map/pc.hpp8
-rw-r--r--src/map/pc.t.hpp2
-rw-r--r--src/map/script.hpp18
-rw-r--r--src/map/skill.hpp10
-rw-r--r--src/map/skill.t.hpp4
-rw-r--r--src/map/storage.hpp2
-rw-r--r--src/map/tmw.hpp8
-rw-r--r--src/map/trade.hpp2
-rw-r--r--src/poison.hpp104
-rw-r--r--src/strings/all.hpp16
-rw-r--r--src/strings/base.hpp8
-rw-r--r--src/strings/fstring.hpp12
-rw-r--r--src/strings/fwd.hpp2
-rw-r--r--src/strings/mstring.hpp4
-rw-r--r--src/strings/pair.hpp6
-rw-r--r--src/strings/sstring.hpp6
-rw-r--r--src/strings/tstring.hpp6
-rw-r--r--src/strings/vstring.hpp4
-rw-r--r--src/strings/xstring.hpp4
-rw-r--r--src/strings/zstring.hpp6
-rwxr-xr-xtools/apply-filter10
-rwxr-xr-xtools/bs-align45
-rwxr-xr-xtools/maybe-mv8
-rwxr-xr-xtools/maybe-replace3
-rwxr-xr-xtools/pp-indent54
77 files changed, 705 insertions, 589 deletions
diff --git a/.travis.yml b/.travis.yml
index d3f0c34..963b088 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -48,6 +48,8 @@ script:
- cd build
- ../configure --dev CPPFLAGS=-DQUIET
- make -k -j2
+ - make format
+ - git diff --exit-code
## Do something after the main test script
after_script:
diff --git a/real.make b/real.make
index 72957ce..3ae013b 100644
--- a/real.make
+++ b/real.make
@@ -106,6 +106,8 @@ endif
include Makefile # for variables - this is handled VERY carefully
+export PATH:=$(realpath ${SRC_DIR}/tools):${PATH}
+
# bash is needed for 'set -o pipefail' below - I have had real bugs there!
# It's just not worth the bother to see if another shell works when it
# needs to *and* fails when it needs to. Just use bash.
@@ -245,7 +247,7 @@ obj/%.d: src/%.cpp
set -o pipefail; \
${CXX} ${CPPFLAGS} -DGENERATING_DEPENDENCIES ${CXXFLAGS} -MG -MP -MM $< \
-MT '$(patsubst %.d,%.ii,$@) $(patsubst %.d,%.ll,$@) $(patsubst %.d,%.bc,$@) $(patsubst %.d,%.s,$@) $(patsubst %.d,%.o,$@) $@' \
- | sed -e ':again; s:/[^/ ]*/\.\./:/:; t again' \
+ | sed -e ':again; s:/[^/. ]*/\.\./:/:; t again' \
-e 's: ${SRC_DIR}/: :g' \
> $@
endif
@@ -348,27 +350,15 @@ include ${SRC_DIR}/version.make
# This is complicated and still isn't optimal.
conf-raw/int-%.h: FORCE
$(MKDIR_FIRST)
- @grep -s -q '^$(value $*)$$' $@ \
- || { \
- echo "#define $* \\"; \
- echo '$(value $*)'; \
- } > $@
+ echo '#define $* $(value $*)' | maybe-replace $@
bool_yes := true
bool_no := false
conf-raw/bool-%.h: FORCE
$(MKDIR_FIRST)
- @grep -s -q '^$(bool_$(value $*))$$' $@ \
- || { \
- echo "#define $* \\"; \
- echo '$(bool_$(value $*))'; \
- } > $@
+ echo '#define $* $(bool_$(value $*))' | maybe-replace $@
conf-raw/str-%.h: FORCE
$(MKDIR_FIRST)
- @grep -s -q '^"$(value $*)"$$' $@ \
- || { \
- echo "#define $* \\"; \
- echo '"$(value $*)"'; \
- } > $@
+ echo '#define $* "$(value $*)"' | maybe-replace $@
FORCE: ;
override CPPFLAGS += -I .
@@ -393,3 +383,7 @@ dist/%-bundled.tar: dist/%-src.tar dist/%-attoconf-only.tar
dist: dist/tmwa-${VERSION_FULL}-src.tar dist/tmwa-${VERSION_FULL}-bundled.tar
.PHONY: dist
+
+format:
+ cd ${SRC_DIR} && apply-filter 'pp-indent | bs-align' ${REAL_SOURCES} ${REAL_HEADERS} ${LEXERS} ${PARSERS}
+.PHONY: format
diff --git a/src/char/char.hpp b/src/char/char.hpp
index 78c68cb..f24acbc 100644
--- a/src/char/char.hpp
+++ b/src/char/char.hpp
@@ -1,17 +1,17 @@
#ifndef CHAR_HPP
#define CHAR_HPP
-#include "../strings/fwd.hpp"
+# include "../strings/fwd.hpp"
-#include "../common/const_array.hpp"
-#include "../common/ip.hpp"
-#include "../common/mmo.hpp"
+# include "../common/const_array.hpp"
+# include "../common/ip.hpp"
+# include "../common/mmo.hpp"
constexpr int MAX_MAP_SERVERS = 30;
-#define CHAR_CONF_NAME "conf/char_athena.conf"
+# define CHAR_CONF_NAME "conf/char_athena.conf"
-#define LOGIN_LAN_CONF_NAME "conf/lan_support.conf"
+# define LOGIN_LAN_CONF_NAME "conf/lan_support.conf"
struct mmo_map_server
{
@@ -29,7 +29,7 @@ int mapif_send(int fd, const uint8_t *buf, unsigned int len);
void char_log(XString line);
-#define CHAR_LOG(fmt, ...) \
+# define CHAR_LOG(fmt, ...) \
char_log(STRPRINTF(fmt, ## __VA_ARGS__))
#endif // CHAR_HPP
diff --git a/src/char/int_party.hpp b/src/char/int_party.hpp
index 2793257..e5a3ab9 100644
--- a/src/char/int_party.hpp
+++ b/src/char/int_party.hpp
@@ -1,7 +1,7 @@
#ifndef INT_PARTY_HPP
#define INT_PARTY_HPP
-#include "../strings/fwd.hpp"
+# include "../strings/fwd.hpp"
int inter_party_init(void);
int inter_party_save(void);
diff --git a/src/char/int_storage.hpp b/src/char/int_storage.hpp
index 2585d63..6c13923 100644
--- a/src/char/int_storage.hpp
+++ b/src/char/int_storage.hpp
@@ -1,7 +1,7 @@
#ifndef INT_STORAGE_HPP
#define INT_STORAGE_HPP
-#include "../strings/fwd.hpp"
+# include "../strings/fwd.hpp"
int inter_storage_init(void);
int inter_storage_save(void);
diff --git a/src/char/inter.hpp b/src/char/inter.hpp
index 5216d57..ece340a 100644
--- a/src/char/inter.hpp
+++ b/src/char/inter.hpp
@@ -1,7 +1,7 @@
#ifndef INTER_HPP
#define INTER_HPP
-#include "../strings/fwd.hpp"
+# include "../strings/fwd.hpp"
void inter_init(ZString file);
void inter_save(void);
@@ -9,7 +9,7 @@ int inter_parse_frommap(int fd);
int inter_check_length(int fd, int length);
-#define inter_cfgName "conf/inter_athena.conf"
+# define inter_cfgName "conf/inter_athena.conf"
extern int party_share_level;
diff --git a/src/common/const_array.hpp b/src/common/const_array.hpp
index 383a4e2..fe15728 100644
--- a/src/common/const_array.hpp
+++ b/src/common/const_array.hpp
@@ -19,19 +19,19 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include "../sanity.hpp"
+# include "../sanity.hpp"
-#include <cstring>
+# include <cstring>
-#include <iterator>
-#include <ostream>
-#include <vector>
+# include <iterator>
+# include <ostream>
+# include <vector>
-#ifdef WORKAROUND_GCC46_COMPILER
+# ifdef WORKAROUND_GCC46_COMPILER
// constexpr is buggy with templates in this version
// Is this still needed now that const_string is removed?
-# define constexpr /* nothing */
-#endif
+# define constexpr /* nothing */
+# endif
// TODO see if I ever actually use this, and not the subclass
template<class T>
@@ -125,8 +125,8 @@ public:
}
};
-#ifdef WORKAROUND_GCC46_COMPILER
-# undef constexpr
-#endif
+# ifdef WORKAROUND_GCC46_COMPILER
+# undef constexpr
+# endif
#endif // CONST_ARRAY_HPP
diff --git a/src/common/core.hpp b/src/common/core.hpp
index 11b04fd..f93f5a1 100644
--- a/src/common/core.hpp
+++ b/src/common/core.hpp
@@ -1,9 +1,9 @@
#ifndef CORE_HPP
#define CORE_HPP
-#include "../sanity.hpp"
+# include "../sanity.hpp"
-#include "../strings/fwd.hpp"
+# include "../strings/fwd.hpp"
/// core.c contains a server-independent main() function
/// and then runs a do_sendrecv loop
diff --git a/src/common/dumb_ptr.hpp b/src/common/dumb_ptr.hpp
index 1dba39d..1ac237a 100644
--- a/src/common/dumb_ptr.hpp
+++ b/src/common/dumb_ptr.hpp
@@ -19,17 +19,17 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include "../sanity.hpp"
+# include "../sanity.hpp"
-#include <cstring>
+# include <cstring>
-#include <algorithm>
+# include <algorithm>
-#include "../strings/fstring.hpp"
-#include "../strings/zstring.hpp"
-#include "../strings/xstring.hpp"
+# include "../strings/fstring.hpp"
+# include "../strings/zstring.hpp"
+# include "../strings/xstring.hpp"
-#include "const_array.hpp"
+# include "const_array.hpp"
// unmanaged new/delete-able pointer
// should be replaced by std::unique_ptr<T>
@@ -210,9 +210,9 @@ struct dumb_string
return dumb_string::copy(&*s.begin(), &*s.end());
}
static
-#ifndef __clang__
+# ifndef __clang__
__attribute__((warning("shouldn't use this - slice instead")))
-#endif
+# endif
dumb_string copyn(const char *sn, size_t n)
{
return dumb_string::copy(sn, sn + strnlen(sn, n));
diff --git a/src/common/extract.hpp b/src/common/extract.hpp
index 4f90be4..e798204 100644
--- a/src/common/extract.hpp
+++ b/src/common/extract.hpp
@@ -19,15 +19,15 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include "../sanity.hpp"
+# include "../sanity.hpp"
-#include <algorithm>
+# include <algorithm>
-#include "../strings/xstring.hpp"
+# include "../strings/xstring.hpp"
-#include "const_array.hpp"
-#include "mmo.hpp"
-#include "utils.hpp"
+# include "const_array.hpp"
+# include "mmo.hpp"
+# include "utils.hpp"
template<class T, typename=typename std::enable_if<std::is_integral<T>::value && !std::is_same<T, char>::value && !std::is_same<T, bool>::value>::type>
bool extract(XString str, T *iv)
diff --git a/src/common/human_time_diff.hpp b/src/common/human_time_diff.hpp
index b8754b2..b8040b8 100644
--- a/src/common/human_time_diff.hpp
+++ b/src/common/human_time_diff.hpp
@@ -19,11 +19,11 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include "../sanity.hpp"
+# include "../sanity.hpp"
-#include "../strings/xstring.hpp"
+# include "../strings/xstring.hpp"
-#include "extract.hpp"
+# include "extract.hpp"
struct HumanTimeDiff
{
diff --git a/src/common/intern-pool.hpp b/src/common/intern-pool.hpp
index 204b659..163e5cc 100644
--- a/src/common/intern-pool.hpp
+++ b/src/common/intern-pool.hpp
@@ -1,14 +1,14 @@
#ifndef INTERN_POOL_HPP
#define INTERN_POOL_HPP
-#include <cassert>
+# include <cassert>
-#include <map>
-#include <vector>
+# include <map>
+# include <vector>
-#include "../strings/fstring.hpp"
-#include "../strings/zstring.hpp"
-#include "../strings/xstring.hpp"
+# include "../strings/fstring.hpp"
+# include "../strings/zstring.hpp"
+# include "../strings/xstring.hpp"
class InternPool
{
diff --git a/src/common/ip.hpp b/src/common/ip.hpp
index 7e645bb..d6e6f04 100644
--- a/src/common/ip.hpp
+++ b/src/common/ip.hpp
@@ -19,13 +19,13 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include "../sanity.hpp"
+# include "../sanity.hpp"
-#include <netinet/in.h>
+# include <netinet/in.h>
-#include "../strings/fwd.hpp"
+# include "../strings/fwd.hpp"
-#include "extract.hpp"
+# include "extract.hpp"
// TODO - in the long run ports belong here also
// and of course, IPv6 stuff.
diff --git a/src/common/md5calc.cpp b/src/common/md5calc.cpp
index 8d650fa..d23f8e3 100644
--- a/src/common/md5calc.cpp
+++ b/src/common/md5calc.cpp
@@ -16,7 +16,7 @@
// auxilary data
/*
sin() constant table
-# Reformatted output of:
+#Reformatted output of:
echo 'scale=40; obase=16; for (i=1;i<=64;i++) print 2^32 * sin(i), "\n"' |
bc | sed 's/^-//;s/^/0x/;s/\..*$/,/'
*/
diff --git a/src/common/md5calc.hpp b/src/common/md5calc.hpp
index 479c1a9..45bec84 100644
--- a/src/common/md5calc.hpp
+++ b/src/common/md5calc.hpp
@@ -1,23 +1,23 @@
#ifndef MD5CALC_HPP
#define MD5CALC_HPP
-#include "../sanity.hpp"
+# include "../sanity.hpp"
-#include <netinet/in.h>
+# include <netinet/in.h>
-#include <cstdint>
-#include <cstddef>
-#include <cstdio>
+# include <cstdint>
+# include <cstddef>
+# include <cstdio>
-#include <array>
+# include <array>
-#include "../strings/fwd.hpp"
-#include "../strings/vstring.hpp"
+# include "../strings/fwd.hpp"
+# include "../strings/vstring.hpp"
-#include "../io/fwd.hpp"
+# include "../io/fwd.hpp"
-#include "ip.hpp"
-#include "mmo.hpp"
+# include "ip.hpp"
+# include "mmo.hpp"
/// The digest state - becomes the output
struct MD5_state
diff --git a/src/common/mmo.hpp b/src/common/mmo.hpp
index 0f89c81..178bb08 100644
--- a/src/common/mmo.hpp
+++ b/src/common/mmo.hpp
@@ -57,7 +57,7 @@ T stringish(VString<sizeof(T) - 1> iv)
static_cast<VString<sizeof(T) - 1>&>(rv) = iv;
return rv;
}
-#define DEFAULT_EMAIL stringish<AccountEmail>("a@a.com")
+# define DEFAULT_EMAIL stringish<AccountEmail>("a@a.com")
// It is decreed: a mapname shall not contain an extension
class MapName : public strings::_crtp_string<MapName, MapName, strings::ZPair>
@@ -111,12 +111,12 @@ public:
}
VString<23> to__canonical() const
{
-#if NAME_IGNORING_CASE == 0
+# if NAME_IGNORING_CASE == 0
return to__actual();
-#endif
-#if NAME_IGNORING_CASE == 1
+# endif
+# if NAME_IGNORING_CASE == 1
return to__lower();
-#endif
+# endif
}
friend bool operator == (const CharName& l, const CharName& r)
diff --git a/src/common/nullpo.hpp b/src/common/nullpo.hpp
index 26aab20..0eaa1b2 100644
--- a/src/common/nullpo.hpp
+++ b/src/common/nullpo.hpp
@@ -11,7 +11,7 @@
/// nullpo_retr(rv, cond) - return given value instead
# ifndef BUG_FREE
-# define nullpo_retr(ret, t) \
+# define nullpo_retr(ret, t) \
if (nullpo_chk(__FILE__, __LINE__, __PRETTY_FUNCTION__, t)) \
return ret;
# else // BUG_FREE
diff --git a/src/common/socket.cpp b/src/common/socket.cpp
index b507cd8..61552c7 100644
--- a/src/common/socket.cpp
+++ b/src/common/socket.cpp
@@ -208,7 +208,7 @@ int make_listen_port(uint16_t port)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wold-style-cast"
#if __GNUC__ > 4 || __GNUC_MINOR__ >= 8
-#pragma GCC diagnostic ignored "-Wuseless-cast"
+# pragma GCC diagnostic ignored "-Wuseless-cast"
#endif
server_address.sin_addr.s_addr = htonl(INADDR_ANY);
server_address.sin_port = htons(port);
@@ -268,7 +268,7 @@ int make_connection(IP4Address ip, uint16_t port)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wold-style-cast"
#if __GNUC__ > 4 || __GNUC_MINOR__ >= 8
-#pragma GCC diagnostic ignored "-Wuseless-cast"
+# pragma GCC diagnostic ignored "-Wuseless-cast"
#endif
server_address.sin_port = htons(port);
#pragma GCC diagnostic pop
diff --git a/src/common/utils.hpp b/src/common/utils.hpp
index 2d2e2d5..f975e34 100644
--- a/src/common/utils.hpp
+++ b/src/common/utils.hpp
@@ -1,21 +1,21 @@
#ifndef UTILS_HPP
#define UTILS_HPP
-#include "../sanity.hpp"
+# include "../sanity.hpp"
-#include <cstdio>
-#include <cstring>
+# include <cstdio>
+# include <cstring>
-#include <type_traits>
+# include <type_traits>
-#include "../strings/fwd.hpp"
-#include "../strings/vstring.hpp"
+# include "../strings/fwd.hpp"
+# include "../strings/vstring.hpp"
-#include "../io/fwd.hpp"
+# include "../io/fwd.hpp"
-#include "const_array.hpp"
-#include "operators.hpp"
-#include "utils2.hpp"
+# include "const_array.hpp"
+# include "operators.hpp"
+# include "utils2.hpp"
template<class T>
struct is_trivially_copyable
@@ -122,16 +122,16 @@ void stamp_time(timestamp_milliseconds_buffer&);
void log_with_timestamp(io::WriteFile& out, XString line);
// TODO VString?
-#define TIMESTAMP_DUMMY "YYYY-MM-DD HH:MM:SS"
+# define TIMESTAMP_DUMMY "YYYY-MM-DD HH:MM:SS"
static_assert(sizeof(TIMESTAMP_DUMMY) == sizeof(timestamp_seconds_buffer),
"timestamp size");
-#define WITH_TIMESTAMP(str) str TIMESTAMP_DUMMY
+# define WITH_TIMESTAMP(str) str TIMESTAMP_DUMMY
// str: prefix: YYYY-MM-DD HH:MM:SS
// sizeof: 01234567890123456789012345678
// str + sizeof: ^
// -1: ^
// there's probably a better way to do this now
-#define REPLACE_TIMESTAMP(str, t) \
+# define REPLACE_TIMESTAMP(str, t) \
stamp_time( \
reinterpret_cast<timestamp_seconds_buffer *>( \
str + sizeof(str) \
diff --git a/src/common/utils2.hpp b/src/common/utils2.hpp
index 7dbd741..0f72aff 100644
--- a/src/common/utils2.hpp
+++ b/src/common/utils2.hpp
@@ -1,19 +1,19 @@
#ifndef UTILS2_HPP
#define UTILS2_HPP
-#include "../sanity.hpp"
+# include "../sanity.hpp"
-#include <algorithm>
-#include <functional>
-#include <iterator>
-#include <memory>
-#include <type_traits>
+# include <algorithm>
+# include <functional>
+# include <iterator>
+# include <memory>
+# include <type_traits>
-#ifdef __clang__
-# define FALLTHROUGH [[clang::fallthrough]]
-#else
-# define FALLTHROUGH /* fallthrough */
-#endif
+# ifdef __clang__
+# define FALLTHROUGH [[clang::fallthrough]]
+# else
+# define FALLTHROUGH /* fallthrough */
+# endif
template<class T, class E, E max>
struct earray
@@ -136,44 +136,44 @@ struct remove_enum<E, true>
};
-#define ENUM_BITWISE_OPERATORS(E) \
-inline \
-E operator & (E l, E r) \
-{ \
- typedef underlying_type<E>::type U; \
- return E(U(l) & U(r)); \
-} \
-inline \
-E operator | (E l, E r) \
-{ \
- typedef underlying_type<E>::type U; \
- return E(U(l) | U(r)); \
-} \
-inline \
-E operator ^ (E l, E r) \
-{ \
- typedef underlying_type<E>::type U; \
- return E(U(l) ^ U(r)); \
-} \
-inline \
-E& operator &= (E& l, E r) \
-{ \
- return l = l & r; \
-} \
-inline \
-E& operator |= (E& l, E r) \
-{ \
- return l = l | r; \
-} \
-inline \
-E& operator ^= (E& l, E r) \
-{ \
- return l = l ^ r; \
-} \
-inline \
-E operator ~ (E r) \
-{ \
- return E(-1) ^ r; \
+# define ENUM_BITWISE_OPERATORS(E) \
+inline \
+E operator & (E l, E r) \
+{ \
+ typedef underlying_type<E>::type U; \
+ return E(U(l) & U(r)); \
+} \
+inline \
+E operator | (E l, E r) \
+{ \
+ typedef underlying_type<E>::type U; \
+ return E(U(l) | U(r)); \
+} \
+inline \
+E operator ^ (E l, E r) \
+{ \
+ typedef underlying_type<E>::type U; \
+ return E(U(l) ^ U(r)); \
+} \
+inline \
+E& operator &= (E& l, E r) \
+{ \
+ return l = l & r; \
+} \
+inline \
+E& operator |= (E& l, E r) \
+{ \
+ return l = l | r; \
+} \
+inline \
+E& operator ^= (E& l, E r) \
+{ \
+ return l = l ^ r; \
+} \
+inline \
+E operator ~ (E r) \
+{ \
+ return E(-1) ^ r; \
}
template<class E>
diff --git a/src/conf/version.hpp b/src/conf/version.hpp
index 1da6088..a4ee931 100644
--- a/src/conf/version.hpp
+++ b/src/conf/version.hpp
@@ -1,15 +1,15 @@
#ifndef CONF_VERSION_HPP
#define CONF_VERSION_HPP
-#include "conf-raw/str-VERSION_FULL.h"
-#include "conf-raw/str-VERSION_HASH.h"
+# include "conf-raw/str-VERSION_FULL.h"
+# include "conf-raw/str-VERSION_HASH.h"
-#include "conf-raw/int-VERSION_MAJOR.h"
-#include "conf-raw/int-VERSION_MINOR.h"
-#include "conf-raw/int-VERSION_PATCH.h"
-#include "conf-raw/int-VERSION_DEVEL.h"
+# include "conf-raw/int-VERSION_MAJOR.h"
+# include "conf-raw/int-VERSION_MINOR.h"
+# include "conf-raw/int-VERSION_PATCH.h"
+# include "conf-raw/int-VERSION_DEVEL.h"
-#include "conf-raw/str-VENDOR.h"
-#include "conf-raw/int-VENDOR_VERSION.h"
+# include "conf-raw/str-VENDOR.h"
+# include "conf-raw/int-VENDOR_VERSION.h"
#endif
diff --git a/src/io/cxxstdio.hpp b/src/io/cxxstdio.hpp
index 0d0bdba..b4b4c79 100644
--- a/src/io/cxxstdio.hpp
+++ b/src/io/cxxstdio.hpp
@@ -19,16 +19,16 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include "../sanity.hpp"
+# include "../sanity.hpp"
-#include <cstdarg>
-#include <cstdio>
+# include <cstdarg>
+# include <cstdio>
// TODO get rid of these header order violations
-#include "../common/const_array.hpp"
-#include "../common/utils2.hpp"
+# include "../common/const_array.hpp"
+# include "../common/utils2.hpp"
-#include "fwd.hpp"
+# include "fwd.hpp"
namespace cxxstdio
@@ -46,16 +46,16 @@ namespace cxxstdio
return vfscanf(in, fmt, ap);
}
-#if 0
+# if 0
inline __attribute__((format(scanf, 2, 0)))
int do_vscan(const char *in, const char *fmt, va_list ap)
{
return vsscanf(in, fmt, ap);
}
-#else
+# else
inline
int do_vscan(const char *, const char *, va_list) = delete;
-#endif
+# endif
template<class T>
inline __attribute__((format(printf, 2, 3)))
@@ -101,7 +101,7 @@ namespace cxxstdio
return v;
}
-#if 0
+# if 0
template<class E>
constexpr
E get_enum_min_value(decltype(E::min_value))
@@ -127,7 +127,7 @@ namespace cxxstdio
{
return def;
}
-#else
+# else
template<class E>
constexpr
E get_enum_min_value(E)
@@ -140,24 +140,24 @@ namespace cxxstdio
{
return E::max_value;
}
-#endif
+# endif
template<class E>
class EnumConverter
{
E& out;
typedef typename underlying_type<E>::type U;
-#if 0
+# if 0
constexpr static
U min_value = U(get_enum_min_value<E>(E(std::numeric_limits<U>::min())));
constexpr static
U max_value = U(get_enum_max_value<E>(E(std::numeric_limits<U>::max())));
-#else
+# else
constexpr static
U min_value = U(get_enum_min_value(E()));
constexpr static
U max_value = U(get_enum_max_value(E()));
-#endif
+# endif
U mid;
public:
EnumConverter(E& e)
@@ -165,10 +165,10 @@ namespace cxxstdio
{}
~EnumConverter()
{
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wtype-limits"
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wtype-limits"
if (min_value <= mid && mid <= max_value)
-#pragma GCC diagnostic pop
+# pragma GCC diagnostic pop
out = E(mid);
}
U *operator &()
@@ -213,49 +213,49 @@ namespace cxxstdio
}
};
-#define XPRINTF(out, fmt, ...) \
- (/*[&]() -> int*/ \
- { \
- struct format_impl \
- { \
- constexpr static \
- const char *print_format() { return fmt; } \
- }; \
+# define XPRINTF(out, fmt, ...) \
+ (/*[&]() -> int*/ \
+ { \
+ struct format_impl \
+ { \
+ constexpr static \
+ const char *print_format() { return fmt; } \
+ }; \
/*return*/ cxxstdio::PrintFormatter<format_impl>::print(out, ## __VA_ARGS__); \
}/*()*/)
-#define XSCANF(out, fmt, ...) \
- (/*[&]() -> int*/ \
- { \
- struct format_impl \
- { \
- constexpr static \
- const char *scan_format() { return fmt; } \
- }; \
- /*return*/ cxxstdio::ScanFormatter<format_impl>::scan(out, ## __VA_ARGS__); \
+# define XSCANF(out, fmt, ...) \
+ (/*[&]() -> int*/ \
+ { \
+ struct format_impl \
+ { \
+ constexpr static \
+ const char *scan_format() { return fmt; } \
+ }; \
+ /*return*/ cxxstdio::ScanFormatter<format_impl>::scan(out, ## __VA_ARGS__); \
}/*()*/)
-#define FPRINTF(file, fmt, ...) XPRINTF(/*no_cast<FILE *>*/(file), fmt, ## __VA_ARGS__)
-#define FSCANF(file, fmt, ...) XSCANF(no_cast<FILE *>(file), fmt, ## __VA_ARGS__)
-#define PRINTF(fmt, ...) FPRINTF(stdout, fmt, ## __VA_ARGS__)
-#define SPRINTF(str, fmt, ...) XPRINTF(base_cast<FString&>(str), fmt, ## __VA_ARGS__)
-#define SNPRINTF(str, n, fmt, ...) XPRINTF(base_cast<VString<n-1>&>(str), fmt, ## __VA_ARGS__)
-#define SCANF(fmt, ...) FSCANF(stdin, fmt, ## __VA_ARGS__)
-#define SSCANF(str, fmt, ...) XSCANF(/*ZString or compatible*/str, fmt, ## __VA_ARGS__)
+# define FPRINTF(file, fmt, ...) XPRINTF(/*no_cast<FILE *>*/(file), fmt, ## __VA_ARGS__)
+# define FSCANF(file, fmt, ...) XSCANF(no_cast<FILE *>(file), fmt, ## __VA_ARGS__)
+# define PRINTF(fmt, ...) FPRINTF(stdout, fmt, ## __VA_ARGS__)
+# define SPRINTF(str, fmt, ...) XPRINTF(base_cast<FString&>(str), fmt, ## __VA_ARGS__)
+# define SNPRINTF(str, n, fmt, ...) XPRINTF(base_cast<VString<n-1>&>(str), fmt, ## __VA_ARGS__)
+# define SCANF(fmt, ...) FSCANF(stdin, fmt, ## __VA_ARGS__)
+# define SSCANF(str, fmt, ...) XSCANF(/*ZString or compatible*/str, fmt, ## __VA_ARGS__)
-#define STRPRINTF(fmt, ...) \
+# define STRPRINTF(fmt, ...) \
(/*[&]() -> FString*/ \
- { \
- FString _out_impl; \
- SPRINTF(_out_impl, fmt, ## __VA_ARGS__);\
+ { \
+ FString _out_impl; \
+ SPRINTF(_out_impl, fmt, ## __VA_ARGS__); \
/*return*/ _out_impl; \
}/*()*/)
-#define STRNPRINTF(n, fmt, ...) \
+# define STRNPRINTF(n, fmt, ...) \
(/*[&]() -> VString<n - 1>*/ \
- { \
- VString<n - 1> _out_impl; \
- SNPRINTF(_out_impl, n, fmt, ## __VA_ARGS__);\
+ { \
+ VString<n - 1> _out_impl; \
+ SNPRINTF(_out_impl, n, fmt, ## __VA_ARGS__); \
/*return*/ _out_impl; \
}/*()*/)
diff --git a/src/io/fwd.hpp b/src/io/fwd.hpp
index 9a980c5..52e6d6d 100644
--- a/src/io/fwd.hpp
+++ b/src/io/fwd.hpp
@@ -19,7 +19,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include "../sanity.hpp"
+# include "../sanity.hpp"
namespace io
diff --git a/src/io/lock.hpp b/src/io/lock.hpp
index 49576a5..a19acdb 100644
--- a/src/io/lock.hpp
+++ b/src/io/lock.hpp
@@ -19,9 +19,9 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include "write.hpp"
+# include "write.hpp"
-#include "../strings/fstring.hpp"
+# include "../strings/fstring.hpp"
namespace io
diff --git a/src/io/read.hpp b/src/io/read.hpp
index 47fc055..8b910b6 100644
--- a/src/io/read.hpp
+++ b/src/io/read.hpp
@@ -19,9 +19,9 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include "../sanity.hpp"
+# include "../sanity.hpp"
-#include "../strings/fwd.hpp"
+# include "../strings/fwd.hpp"
namespace io
diff --git a/src/io/write.hpp b/src/io/write.hpp
index 18e8209..7134015 100644
--- a/src/io/write.hpp
+++ b/src/io/write.hpp
@@ -19,11 +19,11 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include "../sanity.hpp"
+# include "../sanity.hpp"
-#include <cstdarg>
+# include <cstdarg>
-#include "../strings/fwd.hpp"
+# include "../strings/fwd.hpp"
namespace io
{
diff --git a/src/map/atcommand.hpp b/src/map/atcommand.hpp
index aca49e7..31f1432 100644
--- a/src/map/atcommand.hpp
+++ b/src/map/atcommand.hpp
@@ -1,11 +1,11 @@
#ifndef ATCOMMAND_HPP
#define ATCOMMAND_HPP
-#include "../strings/fwd.hpp"
+# include "../strings/fwd.hpp"
-#include "../common/const_array.hpp"
+# include "../common/const_array.hpp"
-#include "map.hpp"
+# include "map.hpp"
bool is_atcommand(const int fd, dumb_ptr<map_session_data> sd,
ZString message, int gmlvl);
diff --git a/src/map/battle.hpp b/src/map/battle.hpp
index 2d9cd7f..02a32ad 100644
--- a/src/map/battle.hpp
+++ b/src/map/battle.hpp
@@ -1,15 +1,15 @@
#ifndef BATTLE_HPP
#define BATTLE_HPP
-#include "battle.t.hpp"
+# include "battle.t.hpp"
-#include "../strings/fwd.hpp"
+# include "../strings/fwd.hpp"
-#include "../common/timer.t.hpp"
+# include "../common/timer.t.hpp"
-#include "magic-interpreter.t.hpp"
-#include "map.t.hpp"
-#include "skill.t.hpp"
+# include "magic-interpreter.t.hpp"
+# include "map.t.hpp"
+# include "skill.t.hpp"
// ダメージ
struct Damage
diff --git a/src/map/battle.t.hpp b/src/map/battle.t.hpp
index f730cc5..1242c85 100644
--- a/src/map/battle.t.hpp
+++ b/src/map/battle.t.hpp
@@ -1,7 +1,7 @@
#ifndef BATTLE_T_HPP
#define BATTLE_T_HPP
-#include "../common/utils2.hpp"
+# include "../common/utils2.hpp"
namespace e
{
diff --git a/src/map/chrif.hpp b/src/map/chrif.hpp
index db7ad0e..51c6d20 100644
--- a/src/map/chrif.hpp
+++ b/src/map/chrif.hpp
@@ -1,13 +1,13 @@
#ifndef CHRIF_HPP
#define CHRIF_HPP
-#include "../strings/fwd.hpp"
+# include "../strings/fwd.hpp"
-#include "../common/dumb_ptr.hpp"
-#include "../common/human_time_diff.hpp"
-#include "../common/ip.hpp"
+# include "../common/dumb_ptr.hpp"
+# include "../common/human_time_diff.hpp"
+# include "../common/ip.hpp"
-#include "map.hpp"
+# include "map.hpp"
void chrif_setuserid(AccountName);
void chrif_setpasswd(AccountPass);
diff --git a/src/map/clif.hpp b/src/map/clif.hpp
index a605e73..bf7393c 100644
--- a/src/map/clif.hpp
+++ b/src/map/clif.hpp
@@ -1,20 +1,20 @@
#ifndef CLIF_HPP
#define CLIF_HPP
-#include "clif.t.hpp"
+# include "clif.t.hpp"
-#include <functional>
+# include <functional>
-#include "../strings/fwd.hpp"
+# include "../strings/fwd.hpp"
-#include "../common/const_array.hpp"
-#include "../common/ip.hpp"
-#include "../common/timer.t.hpp"
+# include "../common/const_array.hpp"
+# include "../common/ip.hpp"
+# include "../common/timer.t.hpp"
-#include "battle.t.hpp"
-#include "map.hpp"
-#include "pc.t.hpp"
-#include "skill.t.hpp"
+# include "battle.t.hpp"
+# include "map.hpp"
+# include "pc.t.hpp"
+# include "skill.t.hpp"
void clif_setip(IP4Address);
void clif_setport(int);
diff --git a/src/map/clif.t.hpp b/src/map/clif.t.hpp
index 38394e9..96b8a9c 100644
--- a/src/map/clif.t.hpp
+++ b/src/map/clif.t.hpp
@@ -1,7 +1,7 @@
#ifndef CLIF_T_HPP
#define CLIF_T_HPP
-#include <cstdint>
+# include <cstdint>
enum class BeingRemoveWhy : uint8_t
{
diff --git a/src/map/grfio.hpp b/src/map/grfio.hpp
index 599064d..17acfb6 100644
--- a/src/map/grfio.hpp
+++ b/src/map/grfio.hpp
@@ -1,11 +1,11 @@
#ifndef GRFIO_HPP
#define GRFIO_HPP
-#include <cstdint>
+# include <cstdint>
-#include <vector>
+# include <vector>
-#include "../common/mmo.hpp"
+# include "../common/mmo.hpp"
/// Load a resource into memory, subject to data/resnametable.txt.
/// Normally, resourcename is xxx-y.gat and the file is xxx-y.wlk.
diff --git a/src/map/intif.hpp b/src/map/intif.hpp
index a3e1d17..244c230 100644
--- a/src/map/intif.hpp
+++ b/src/map/intif.hpp
@@ -1,11 +1,11 @@
#ifndef INTIF_HPP
#define INTIF_HPP
-#include "../strings/fwd.hpp"
+# include "../strings/fwd.hpp"
-#include "../common/const_array.hpp"
+# include "../common/const_array.hpp"
-#include "map.hpp"
+# include "map.hpp"
int intif_parse(int fd);
diff --git a/src/map/itemdb.hpp b/src/map/itemdb.hpp
index a08777e..e41be41 100644
--- a/src/map/itemdb.hpp
+++ b/src/map/itemdb.hpp
@@ -1,10 +1,10 @@
#ifndef ITEMDB_HPP
#define ITEMDB_HPP
-#include "../common/mmo.hpp"
+# include "../common/mmo.hpp"
-#include "map.t.hpp"
-#include "script.hpp"
+# include "map.t.hpp"
+# include "script.hpp"
struct item_data
{
diff --git a/src/map/magic-expr-eval.hpp b/src/map/magic-expr-eval.hpp
index a4a71f8..1569be8 100644
--- a/src/map/magic-expr-eval.hpp
+++ b/src/map/magic-expr-eval.hpp
@@ -1,11 +1,11 @@
#ifndef MAGIC_EXPR_EVAL_HPP
#define MAGIC_EXPR_EVAL_HPP
-#include "../strings/zstring.hpp"
+# include "../strings/zstring.hpp"
-#include "../common/utils2.hpp"
+# include "../common/utils2.hpp"
-#include "magic-interpreter.hpp"
+# include "magic-interpreter.hpp"
/* Helper definitions for dealing with functions and operations */
@@ -15,31 +15,31 @@ int magic_signature_check(ZString opname, ZString funname, ZString signature,
void magic_area_rect(map_local **m, int *x, int *y, int *width, int *height,
area_t& area);
-#define ARGINT(x) args[x].v.v_int
-#define ARGDIR(x) args[x].v.v_dir
-#define ARGSTR(x) ZString(args[x].v.v_string)
-#define ARGENTITY(x) args[x].v.v_entity
-#define ARGLOCATION(x) args[x].v.v_location
-#define ARGAREA(x) args[x].v.v_area
-#define ARGSPELL(x) args[x].v.v_spell
-#define ARGINVOCATION(x) args[x].v.v_invocation
-
-#define RESULTINT result->v.v_int
-#define RESULTDIR result->v.v_dir
-#define RESULTSTR result->v.v_string
-#define RESULTENTITY result->v.v_entity
-#define RESULTLOCATION result->v.v_location
-#define RESULTAREA result->v.v_area
-#define RESULTSPELL result->v.v_spell
-#define RESULTINVOCATION result->v.v_invocation
-
-#define ARG_TYPE(x) args[x].ty
-#define ENTITY_TYPE(x) ARGENTITY(x)->bl_type
-
-#define ARGPC(x) (ARGENTITY(x)->is_player())
-#define ARGNPC(x) (ARGENTITY(x)->is_npc())
-#define ARGMOB(x) (ARGENTITY(x)->is_mob())
-
-#define ARG_MAY_BE_AREA(x) (ARG_TYPE(x) == TYPE::AREA || ARG_TYPE(x) == TYPE::LOCATION)
+# define ARGINT(x) args[x].v.v_int
+# define ARGDIR(x) args[x].v.v_dir
+# define ARGSTR(x) ZString(args[x].v.v_string)
+# define ARGENTITY(x) args[x].v.v_entity
+# define ARGLOCATION(x) args[x].v.v_location
+# define ARGAREA(x) args[x].v.v_area
+# define ARGSPELL(x) args[x].v.v_spell
+# define ARGINVOCATION(x) args[x].v.v_invocation
+
+# define RESULTINT result->v.v_int
+# define RESULTDIR result->v.v_dir
+# define RESULTSTR result->v.v_string
+# define RESULTENTITY result->v.v_entity
+# define RESULTLOCATION result->v.v_location
+# define RESULTAREA result->v.v_area
+# define RESULTSPELL result->v.v_spell
+# define RESULTINVOCATION result->v.v_invocation
+
+# define ARG_TYPE(x) args[x].ty
+# define ENTITY_TYPE(x) ARGENTITY(x)->bl_type
+
+# define ARGPC(x) (ARGENTITY(x)->is_player())
+# define ARGNPC(x) (ARGENTITY(x)->is_npc())
+# define ARGMOB(x) (ARGENTITY(x)->is_mob())
+
+# define ARG_MAY_BE_AREA(x) (ARG_TYPE(x) == TYPE::AREA || ARG_TYPE(x) == TYPE::LOCATION)
#endif // MAGIC_EXPR_EVAL_HPP
diff --git a/src/map/magic-expr.cpp b/src/map/magic-expr.cpp
index acdefc2..655da1b 100644
--- a/src/map/magic-expr.cpp
+++ b/src/map/magic-expr.cpp
@@ -613,12 +613,12 @@ int fun_his_shroud(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
return 0;
}
-#define BATTLE_GETTER(name) \
-static \
-int fun_get_##name(dumb_ptr<env_t>, val_t *result, const_array<val_t> args) \
-{ \
- RESULTINT = battle_get_##name(ARGENTITY(0)); \
- return 0; \
+#define BATTLE_GETTER(name) \
+static \
+int fun_get_##name(dumb_ptr<env_t>, val_t *result, const_array<val_t> args) \
+{ \
+ RESULTINT = battle_get_##name(ARGENTITY(0)); \
+ return 0; \
}
BATTLE_GETTER(str)
@@ -639,15 +639,15 @@ int fun_get_dir(dumb_ptr<env_t>, val_t *result, const_array<val_t> args)
return 0;
}
-#define MMO_GETTER(name) \
-static \
-int fun_get_##name(dumb_ptr<env_t>, val_t *result, const_array<val_t> args) \
-{ \
- if (ENTITY_TYPE(0) == BL::PC) \
- RESULTINT = ARGPC(0)->status.name; \
- else \
- RESULTINT = 0; \
- return 0; \
+#define MMO_GETTER(name) \
+static \
+int fun_get_##name(dumb_ptr<env_t>, val_t *result, const_array<val_t> args) \
+{ \
+ if (ENTITY_TYPE(0) == BL::PC) \
+ RESULTINT = ARGPC(0)->status.name; \
+ else \
+ RESULTINT = 0; \
+ return 0; \
}
MMO_GETTER(sp)
diff --git a/src/map/magic-expr.hpp b/src/map/magic-expr.hpp
index 0d1bd4f..7601bef 100644
--- a/src/map/magic-expr.hpp
+++ b/src/map/magic-expr.hpp
@@ -1,10 +1,10 @@
#ifndef MAGIC_EXPR_HPP
#define MAGIC_EXPR_HPP
-#include "magic-interpreter.hpp"
+# include "magic-interpreter.hpp"
-#include "../strings/fwd.hpp"
-#include "../strings/zstring.hpp"
+# include "../strings/fwd.hpp"
+# include "../strings/zstring.hpp"
/*
* Argument types:
@@ -74,7 +74,7 @@ void magic_random_location(location_t *dest, dumb_ptr<area_t> area);
// ret -1: not a string, ret 1: no such item, ret 0: OK
int magic_find_item(const_array<val_t> args, int index, struct item *item, int *stackable);
-#define GET_ARG_ITEM(index, dest, stackable) \
+# define GET_ARG_ITEM(index, dest, stackable) \
switch (magic_find_item(args, index, &dest, &stackable)) \
{ \
case -1: return 1; \
diff --git a/src/map/magic-interpreter-aux.hpp b/src/map/magic-interpreter-aux.hpp
index 2ff597f..070c771 100644
--- a/src/map/magic-interpreter-aux.hpp
+++ b/src/map/magic-interpreter-aux.hpp
@@ -1,7 +1,7 @@
#ifndef MAGIC_INTERPRETER_AUX_HPP
#define MAGIC_INTERPRETER_AUX_HPP
-#include "magic-interpreter.t.hpp"
+# include "magic-interpreter.t.hpp"
template<class T>
bool CHECK_TYPE(T *v, TYPE t)
diff --git a/src/map/magic-interpreter-lexer.lpp b/src/map/magic-interpreter-lexer.lpp
index 2b68acf..3625ee3 100644
--- a/src/map/magic-interpreter-lexer.lpp
+++ b/src/map/magic-interpreter-lexer.lpp
@@ -1,6 +1,6 @@
%{
#include "magic-interpreter-lexer.hpp"
-#
+
#include "magic-interpreter-parser.hpp"
#include "../io/cxxstdio.hpp"
diff --git a/src/map/magic-interpreter-parser.ypp b/src/map/magic-interpreter-parser.ypp
index 0657ade..f067a8b 100644
--- a/src/map/magic-interpreter-parser.ypp
+++ b/src/map/magic-interpreter-parser.ypp
@@ -28,7 +28,7 @@
#pragma GCC diagnostic warning "-Wextra"
#pragma GCC diagnostic warning "-Wformat"
#ifndef __clang__
-#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
+# pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#endif
static
diff --git a/src/map/magic-interpreter.hpp b/src/map/magic-interpreter.hpp
index a0abe7a..8afb8af 100644
--- a/src/map/magic-interpreter.hpp
+++ b/src/map/magic-interpreter.hpp
@@ -1,17 +1,17 @@
#ifndef MAGIC_INTERPRETER_HPP
#define MAGIC_INTERPRETER_HPP
-#include "magic-interpreter.t.hpp"
+# include "magic-interpreter.t.hpp"
-#include <cassert>
+# include <cassert>
-#include "../strings/fwd.hpp"
-#include "../strings/fstring.hpp"
+# include "../strings/fwd.hpp"
+# include "../strings/fstring.hpp"
-#include "magic.hpp"
-#include "map.hpp"
-#include "script.hpp"
-#include "skill.t.hpp"
+# include "magic.hpp"
+# include "map.hpp"
+# include "script.hpp"
+# include "skill.t.hpp"
struct fun_t;
struct op_t;
@@ -82,7 +82,7 @@ struct val_t
/* Expressions */
/* ----------- */
-#define MAX_ARGS 7 /* Max. # of args used in builtin primitive functions */
+# define MAX_ARGS 7 /* Max. # of args used in builtin primitive functions */
struct e_location_t
{
@@ -288,15 +288,15 @@ struct magic_conf_t
/* Execution environment */
// these are not an enum they're a nasty intern hack
-#define VAR_MIN_CASTTIME 0
-#define VAR_OBSCURE_CHANCE 1
-#define VAR_CASTER 2
-#define VAR_SPELLPOWER 3
-#define VAR_SPELL 4
-#define VAR_INVOCATION 5
-#define VAR_TARGET 6
-#define VAR_SCRIPTTARGET 7
-#define VAR_LOCATION 8
+# define VAR_MIN_CASTTIME 0
+# define VAR_OBSCURE_CHANCE 1
+# define VAR_CASTER 2
+# define VAR_SPELLPOWER 3
+# define VAR_SPELL 4
+# define VAR_INVOCATION 5
+# define VAR_TARGET 6
+# define VAR_SCRIPTTARGET 7
+# define VAR_LOCATION 8
struct magic_config;
@@ -316,7 +316,7 @@ struct env_t
};
-#define MAX_STACK_SIZE 32
+# define MAX_STACK_SIZE 32
struct cont_activation_record_t
{
diff --git a/src/map/magic-interpreter.t.hpp b/src/map/magic-interpreter.t.hpp
index d5aa5e5..fb7bb6d 100644
--- a/src/map/magic-interpreter.t.hpp
+++ b/src/map/magic-interpreter.t.hpp
@@ -1,7 +1,7 @@
#ifndef MAGIC_INTERPRETER_T_HPP
#define MAGIC_INTERPRETER_T_HPP
-#include "../common/utils2.hpp"
+# include "../common/utils2.hpp"
enum class SPELLARG : uint8_t
{
diff --git a/src/map/magic.hpp b/src/map/magic.hpp
index 84e3387..79e2a84 100644
--- a/src/map/magic.hpp
+++ b/src/map/magic.hpp
@@ -1,14 +1,14 @@
#ifndef MAGIC_HPP
#define MAGIC_HPP
-#include "../strings/fwd.hpp"
+# include "../strings/fwd.hpp"
-#include "../common/dumb_ptr.hpp"
+# include "../common/dumb_ptr.hpp"
-#include "map.hpp"
-#include "skill.t.hpp"
+# include "map.hpp"
+# include "skill.t.hpp"
-#define MAGIC_CONFIG_FILE "conf/magic.conf"
+# define MAGIC_CONFIG_FILE "conf/magic.conf"
struct invocation; /* Spell invocation */
diff --git a/src/map/map.hpp b/src/map/map.hpp
index 7eeaa8c..882fde6 100644
--- a/src/map/map.hpp
+++ b/src/map/map.hpp
@@ -1,33 +1,33 @@
#ifndef MAP_HPP
#define MAP_HPP
-#include "map.t.hpp"
+# include "map.t.hpp"
-#include <netinet/in.h>
+# include <netinet/in.h>
-#include <functional>
-#include <list>
+# include <functional>
+# include <list>
-#include "../strings/fwd.hpp"
-#include "../strings/fstring.hpp"
-#include "../strings/vstring.hpp"
+# include "../strings/fwd.hpp"
+# include "../strings/fstring.hpp"
+# include "../strings/vstring.hpp"
-#include "../io/cxxstdio.hpp"
+# include "../io/cxxstdio.hpp"
-#include "../common/db.hpp"
-#include "../common/matrix.hpp"
-#include "../common/socket.hpp"
-#include "../common/timer.t.hpp"
+# include "../common/db.hpp"
+# include "../common/matrix.hpp"
+# include "../common/socket.hpp"
+# include "../common/timer.t.hpp"
-#include "battle.t.hpp"
-#include "magic-interpreter.t.hpp"
-#include "mob.t.hpp"
-#include "script.hpp" // change to script.t.hpp
-#include "skill.t.hpp"
+# include "battle.t.hpp"
+# include "magic-interpreter.t.hpp"
+# include "mob.t.hpp"
+# include "script.hpp" // change to script.t.hpp
+# include "skill.t.hpp"
constexpr int MAX_NPC_PER_MAP = 512;
constexpr int BLOCK_SIZE = 8;
-#define AREA_SIZE battle_config.area_size
+# define AREA_SIZE battle_config.area_size
constexpr std::chrono::seconds LIFETIME_FLOORITEM = std::chrono::minutes(1);
constexpr int MAX_SKILL_LEVEL = 100;
constexpr int MAX_EVENTTIMER = 32;
@@ -625,10 +625,10 @@ void map_quit(dumb_ptr<map_session_data>);
int map_addnpc(map_local *, dumb_ptr<npc_data>);
void map_log(XString line);
-#define MAP_LOG(format, ...) \
+# define MAP_LOG(format, ...) \
map_log(STRPRINTF(format, ## __VA_ARGS__))
-#define MAP_LOG_PC(sd, fmt, ...) \
+# define MAP_LOG_PC(sd, fmt, ...) \
MAP_LOG("PC%d %s:%d,%d " fmt, \
sd->status.char_id, (sd->bl_m ? sd->bl_m->name_ : stringish<MapName>("undefined.gat")), sd->bl_x, sd->bl_y, ## __VA_ARGS__)
diff --git a/src/map/map.t.hpp b/src/map/map.t.hpp
index 2255f60..f4d916a 100644
--- a/src/map/map.t.hpp
+++ b/src/map/map.t.hpp
@@ -1,10 +1,10 @@
#ifndef MAP_T_HPP
#define MAP_T_HPP
-#include "../strings/vstring.hpp"
+# include "../strings/vstring.hpp"
-#include "../common/mmo.hpp"
-#include "../common/utils2.hpp"
+# include "../common/mmo.hpp"
+# include "../common/utils2.hpp"
namespace e
{
@@ -137,9 +137,9 @@ enum class SP : uint16_t
BASEEXP = 1,
// sent to client
JOBEXP = 2,
-#if 0
+# if 0
KARMA = 3,
-#endif
+# endif
// sent to client
HP = 5,
@@ -224,12 +224,12 @@ enum class SP : uint16_t
// sent to client
JOBLEVEL = 55,
-#if 0
+# if 0
PARTNER = 57,
CART = 58,
FAME = 59,
UNBREAKABLE = 60,
-#endif
+# endif
DEAF = 70,
@@ -238,154 +238,154 @@ enum class SP : uint16_t
// sent to client
ATTACKRANGE = 1000,
-#if 0
+# if 0
ATKELE = 1001,
-#endif
-#if 0
+# endif
+# if 0
DEFELE = 1002,
-#endif
-#if 0
+# endif
+# if 0
CASTRATE = 1003,
-#endif
+# endif
MAXHPRATE = 1004,
-#if 0
+# if 0
MAXSPRATE = 1005,
-#endif
-#if 0
+# endif
+# if 0
SPRATE = 1006,
-#endif
+# endif
-#if 0
+# if 0
ADDEFF = 1012,
-#endif
-#if 0
+# endif
+# if 0
RESEFF = 1013,
-#endif
+# endif
BASE_ATK = 1014,
ASPD_RATE = 1015,
HP_RECOV_RATE = 1016,
-#if 0
+# if 0
SP_RECOV_RATE = 1017,
-#endif
-#if 0
+# endif
+# if 0
SPEED_RATE = 1018,
-#endif
+# endif
CRITICAL_DEF = 1019,
-#if 0
+# if 0
NEAR_ATK_DEF = 1020,
-#endif
-#if 0
+# endif
+# if 0
LONG_ATK_DEF = 1021,
-#endif
-#if 0
+# endif
+# if 0
DOUBLE_RATE = 1022,
-#endif
+# endif
DOUBLE_ADD_RATE = 1023,
-#if 0
+# if 0
MATK = 1024,
-#endif
-#if 0
+# endif
+# if 0
MATK_RATE = 1025,
-#endif
-#if 0
+# endif
+# if 0
IGNORE_DEF_ELE = 1026,
-#endif
-#if 0
+# endif
+# if 0
IGNORE_DEF_RACE = 1027,
-#endif
-#if 0
+# endif
+# if 0
ATK_RATE = 1028,
-#endif
+# endif
SPEED_ADDRATE = 1029,
-#if 0
+# if 0
ASPD_ADDRATE = 1030,
-#endif
-#if 0
+# endif
+# if 0
MAGIC_ATK_DEF = 1031,
-#endif
-#if 0
+# endif
+# if 0
MISC_ATK_DEF = 1032,
-#endif
-#if 0
+# endif
+# if 0
IGNORE_MDEF_ELE = 1033,
-#endif
-#if 0
+# endif
+# if 0
IGNORE_MDEF_RACE = 1034,
-#endif
+# endif
-#if 0
+# if 0
PERFECT_HIT_RATE = 1038,
-#endif
-#if 0
+# endif
+# if 0
PERFECT_HIT_ADD_RATE = 1039,
-#endif
-#if 0
+# endif
+# if 0
CRITICAL_RATE = 1040,
-#endif
-#if 0
+# endif
+# if 0
GET_ZENY_NUM = 1041,
-#endif
-#if 0
+# endif
+# if 0
ADD_GET_ZENY_NUM = 1042,
-#endif
+# endif
-#if 0
+# if 0
ADD_MONSTER_DROP_ITEM = 1047,
-#endif
-#if 0
+# endif
+# if 0
DEF_RATIO_ATK_ELE = 1048,
-#endif
-#if 0
+# endif
+# if 0
DEF_RATIO_ATK_RACE = 1049,
-#endif
-#if 0
+# endif
+# if 0
ADD_SPEED = 1050,
-#endif
-#if 0
+# endif
+# if 0
HIT_RATE = 1051,
-#endif
-#if 0
+# endif
+# if 0
FLEE_RATE = 1052,
-#endif
-#if 0
+# endif
+# if 0
FLEE2_RATE = 1053,
-#endif
+# endif
DEF_RATE = 1054,
DEF2_RATE = 1055,
-#if 0
+# if 0
MDEF_RATE = 1056,
-#endif
-#if 0
+# endif
+# if 0
MDEF2_RATE = 1057,
-#endif
-#if 0
+# endif
+# if 0
SPLASH_RANGE = 1058,
-#endif
-#if 0
+# endif
+# if 0
SPLASH_ADD_RANGE = 1059,
-#endif
+# endif
HP_DRAIN_RATE = 1061,
-#if 0
+# if 0
SP_DRAIN_RATE = 1062,
-#endif
-#if 0
+# endif
+# if 0
SHORT_WEAPON_DAMAGE_RETURN = 1063,
-#endif
-#if 0
+# endif
+# if 0
LONG_WEAPON_DAMAGE_RETURN = 1064,
-#endif
+# endif
-#if 0
+# if 0
ADDEFF2 = 1067,
-#endif
+# endif
BREAK_WEAPON_RATE = 1068,
BREAK_ARMOR_RATE = 1069,
ADD_STEAL_RATE = 1070,
MAGIC_DAMAGE_RETURN = 1071,
-#if 0
+# if 0
RANDOM_ATTACK_INCREASE = 1072,
-#endif
+# endif
};
constexpr
diff --git a/src/map/mob.hpp b/src/map/mob.hpp
index 2ed4018..b0445de 100644
--- a/src/map/mob.hpp
+++ b/src/map/mob.hpp
@@ -1,19 +1,19 @@
#ifndef MOB_HPP
#define MOB_HPP
-#include "mob.t.hpp"
+# include "mob.t.hpp"
-#include "../common/mmo.hpp"
-#include "../common/timer.t.hpp"
-#include "../common/random.t.hpp"
+# include "../common/mmo.hpp"
+# include "../common/timer.t.hpp"
+# include "../common/random.t.hpp"
-#include "clif.t.hpp"
-#include "map.hpp"
-#include "skill.t.hpp"
+# include "clif.t.hpp"
+# include "map.hpp"
+# include "skill.t.hpp"
-#define ENGLISH_NAME stringish<MobName>("--en--")
-#define JAPANESE_NAME stringish<MobName>("--ja--")
-#define MOB_THIS_MAP stringish<MapName>("this")
+# define ENGLISH_NAME stringish<MobName>("--en--")
+# define JAPANESE_NAME stringish<MobName>("--ja--")
+# define MOB_THIS_MAP stringish<MapName>("this")
struct mob_skill
{
diff --git a/src/map/mob.t.hpp b/src/map/mob.t.hpp
index b112c69..54c326d 100644
--- a/src/map/mob.t.hpp
+++ b/src/map/mob.t.hpp
@@ -1,7 +1,7 @@
#ifndef MOB_T_HPP
#define MOB_T_HPP
-#include <cstdint>
+# include <cstdint>
enum class MobSkillTarget
{
diff --git a/src/map/npc.hpp b/src/map/npc.hpp
index ee9ed91..0bc00ed 100644
--- a/src/map/npc.hpp
+++ b/src/map/npc.hpp
@@ -1,14 +1,14 @@
#ifndef NPC_HPP
#define NPC_HPP
-#include <cstddef>
-#include <cstdint>
+# include <cstddef>
+# include <cstdint>
-#include "../strings/fwd.hpp"
+# include "../strings/fwd.hpp"
-#include "../common/timer.t.hpp"
+# include "../common/timer.t.hpp"
-#include "map.hpp"
+# include "map.hpp"
constexpr int START_NPC_NUM = 110000000;
diff --git a/src/map/party.hpp b/src/map/party.hpp
index 5ad6c03..91dab1b 100644
--- a/src/map/party.hpp
+++ b/src/map/party.hpp
@@ -1,11 +1,11 @@
#ifndef PARTY_HPP
#define PARTY_HPP
-#include <functional>
+# include <functional>
-#include "../strings/fwd.hpp"
+# include "../strings/fwd.hpp"
-#include "map.hpp"
+# include "map.hpp"
struct party;
struct map_session_data;
diff --git a/src/map/path.hpp b/src/map/path.hpp
index 8dace6f..4b5b3d8 100644
--- a/src/map/path.hpp
+++ b/src/map/path.hpp
@@ -1,7 +1,7 @@
#ifndef PATH_HPP
#define PATH_HPP
-#include "map.hpp"
+# include "map.hpp"
int path_search(struct walkpath_data *, map_local *, int, int, int, int, int);
diff --git a/src/map/pc.cpp b/src/map/pc.cpp
index 0b648d1..4cfa107 100644
--- a/src/map/pc.cpp
+++ b/src/map/pc.cpp
@@ -46,7 +46,7 @@ constexpr std::chrono::milliseconds PVP_CALCRANK_INTERVAL =
constexpr int MAGIC_SKILL_THRESHOLD = 200;
#endif
-#define MAP_LOG_STATS(sd, suffix) \
+#define MAP_LOG_STATS(sd, suffix) \
MAP_LOG_PC(sd, "STAT %d %d %d %d %d %d " suffix, \
sd->status.attrs[ATTR::STR], \
sd->status.attrs[ATTR::AGI], \
@@ -55,20 +55,20 @@ constexpr int MAGIC_SKILL_THRESHOLD = 200;
sd->status.attrs[ATTR::DEX], \
sd->status.attrs[ATTR::LUK])
-#define MAP_LOG_XP(sd, suffix) \
- MAP_LOG_PC(sd, "XP %d %d JOB %d %d %d ZENY %d + %d " suffix, \
- sd->status.base_level, sd->status.base_exp, \
- sd->status.job_level, sd->status.job_exp, sd->status.skill_point, \
+#define MAP_LOG_XP(sd, suffix) \
+ MAP_LOG_PC(sd, "XP %d %d JOB %d %d %d ZENY %d + %d " suffix, \
+ sd->status.base_level, sd->status.base_exp, \
+ sd->status.job_level, sd->status.job_exp, sd->status.skill_point, \
sd->status.zeny, pc_readaccountreg(sd, stringish<VarName>("BankAccount")))
-#define MAP_LOG_MAGIC(sd, suffix) \
- MAP_LOG_PC(sd, "MAGIC %d %d %d %d %d %d EXP %d %d " suffix, \
- sd->status.skill[SkillID::TMW_MAGIC].lv, \
- sd->status.skill[SkillID::TMW_MAGIC_LIFE].lv, \
- sd->status.skill[SkillID::TMW_MAGIC_WAR].lv, \
- sd->status.skill[SkillID::TMW_MAGIC_TRANSMUTE].lv, \
- sd->status.skill[SkillID::TMW_MAGIC_NATURE].lv, \
- sd->status.skill[SkillID::TMW_MAGIC_ETHER].lv, \
+#define MAP_LOG_MAGIC(sd, suffix) \
+ MAP_LOG_PC(sd, "MAGIC %d %d %d %d %d %d EXP %d %d " suffix, \
+ sd->status.skill[SkillID::TMW_MAGIC].lv, \
+ sd->status.skill[SkillID::TMW_MAGIC_LIFE].lv, \
+ sd->status.skill[SkillID::TMW_MAGIC_WAR].lv, \
+ sd->status.skill[SkillID::TMW_MAGIC_TRANSMUTE].lv, \
+ sd->status.skill[SkillID::TMW_MAGIC_NATURE].lv, \
+ sd->status.skill[SkillID::TMW_MAGIC_ETHER].lv, \
pc_readglobalreg(sd, stringish<VarName>("MAGIC_EXPERIENCE")) & 0xffff, \
(pc_readglobalreg(sd, stringish<VarName>("MAGIC_EXPERIENCE")) >> 24) & 0xff)
diff --git a/src/map/pc.hpp b/src/map/pc.hpp
index fbd161e..40d0e76 100644
--- a/src/map/pc.hpp
+++ b/src/map/pc.hpp
@@ -1,12 +1,12 @@
#ifndef PC_HPP
#define PC_HPP
-#include "pc.t.hpp"
+# include "pc.t.hpp"
-#include "../strings/fwd.hpp"
+# include "../strings/fwd.hpp"
-#include "clif.t.hpp"
-#include "map.hpp"
+# include "clif.t.hpp"
+# include "map.hpp"
inline
void pc_setsit(dumb_ptr<map_session_data> sd)
diff --git a/src/map/pc.t.hpp b/src/map/pc.t.hpp
index feffd89..95a76a7 100644
--- a/src/map/pc.t.hpp
+++ b/src/map/pc.t.hpp
@@ -1,7 +1,7 @@
#ifndef PC_T_HPP
#define PC_T_HPP
-#include <cstdint>
+# include <cstdint>
enum class PC_GAINEXP_REASON
{
diff --git a/src/map/script.hpp b/src/map/script.hpp
index e593cfa..da1d3ce 100644
--- a/src/map/script.hpp
+++ b/src/map/script.hpp
@@ -1,19 +1,19 @@
#ifndef SCRIPT_HPP
#define SCRIPT_HPP
-#include <cstdint>
-#include <cstring> // for inlined get_str - TODO remove
+# include <cstdint>
+# include <cstring> // for inlined get_str - TODO remove
-#include <vector>
+# include <vector>
-#include "../strings/fstring.hpp"
-#include "../strings/zstring.hpp"
+# include "../strings/fstring.hpp"
+# include "../strings/zstring.hpp"
-#include "../common/db.hpp"
-#include "../common/dumb_ptr.hpp"
-#include "../common/utils.hpp"
+# include "../common/db.hpp"
+# include "../common/dumb_ptr.hpp"
+# include "../common/utils.hpp"
-#include "map.t.hpp"
+# include "map.t.hpp"
enum class ByteCode : uint8_t;
struct str_data_t;
diff --git a/src/map/skill.hpp b/src/map/skill.hpp
index d816161..14ff1b5 100644
--- a/src/map/skill.hpp
+++ b/src/map/skill.hpp
@@ -1,13 +1,13 @@
#ifndef SKILL_HPP
#define SKILL_HPP
-#include "skill.t.hpp"
-#include "skill-pools.hpp"
+# include "skill.t.hpp"
+# include "skill-pools.hpp"
-#include "../strings/fwd.hpp"
-#include "../strings/fstring.hpp"
+# include "../strings/fwd.hpp"
+# include "../strings/fstring.hpp"
-#include "map.hpp"
+# include "map.hpp"
constexpr int MAX_SKILL_PRODUCE_DB = 150;
constexpr int MAX_SKILL_ARROW_DB = 150;
diff --git a/src/map/skill.t.hpp b/src/map/skill.t.hpp
index 3214062..bfa0e2f 100644
--- a/src/map/skill.t.hpp
+++ b/src/map/skill.t.hpp
@@ -1,9 +1,9 @@
#ifndef SKILL_T_HPP
#define SKILL_T_HPP
-#include <cstdint>
+# include <cstdint>
-#include "../common/utils2.hpp"
+# include "../common/utils2.hpp"
// TODO remove most of these as their corresponding SkillIDs get deleted.
enum class StatusChange : uint16_t
diff --git a/src/map/storage.hpp b/src/map/storage.hpp
index 8f31517..f923ebe 100644
--- a/src/map/storage.hpp
+++ b/src/map/storage.hpp
@@ -4,7 +4,7 @@
#ifndef STORAGE_HPP
#define STORAGE_HPP
-#include "map.hpp"
+# include "map.hpp"
int storage_storageopen(dumb_ptr<map_session_data> sd);
int storage_storageadd(dumb_ptr<map_session_data> sd, int index, int amount);
diff --git a/src/map/tmw.hpp b/src/map/tmw.hpp
index d9147c9..e90143d 100644
--- a/src/map/tmw.hpp
+++ b/src/map/tmw.hpp
@@ -1,12 +1,12 @@
#ifndef TMW_HPP
#define TMW_HPP
-#include "../strings/fwd.hpp"
+# include "../strings/fwd.hpp"
-#include "../common/const_array.hpp"
-#include "../common/dumb_ptr.hpp"
+# include "../common/const_array.hpp"
+# include "../common/dumb_ptr.hpp"
-#include "map.hpp"
+# include "map.hpp"
int tmw_CheckChatSpam(dumb_ptr<map_session_data> sd, XString message);
void tmw_GmHackMsg(ZString line);
diff --git a/src/map/trade.hpp b/src/map/trade.hpp
index 708e578..e50d608 100644
--- a/src/map/trade.hpp
+++ b/src/map/trade.hpp
@@ -1,7 +1,7 @@
#ifndef TRADE_HPP
#define TRADE_HPP
-#include "map.hpp"
+# include "map.hpp"
void trade_traderequest(dumb_ptr<map_session_data> sd, int target_id);
void trade_tradeack(dumb_ptr<map_session_data> sd, int type);
diff --git a/src/poison.hpp b/src/poison.hpp
index d4a6cd0..51bf6ef 100644
--- a/src/poison.hpp
+++ b/src/poison.hpp
@@ -2,21 +2,21 @@
// impossible(*) to use safely
// removed in C11
-#pragma GCC poison gets
+# pragma GCC poison gets
// TODO fill in as they are removed from source code:
// double (use a fixed class)
-#pragma GCC poison float
+# pragma GCC poison float
-#pragma GCC poison dynamic_cast
+# pragma GCC poison dynamic_cast
// Local time is forbidden.
-#pragma GCC poison timelocal // timegm
-#pragma GCC poison mktime // timegm
-#pragma GCC poison localtime // gmtime
-#pragma GCC poison localtime_r // gmtime_r
+# pragma GCC poison timelocal // timegm
+# pragma GCC poison mktime // timegm
+# pragma GCC poison localtime // gmtime
+# pragma GCC poison localtime_r // gmtime_r
-#pragma GCC poison time // TimeT::now() or gettick()
+# pragma GCC poison time // TimeT::now() or gettick()
// Avoid manual allocations.
// Use some sort of managed container, or at least dumb_ptr
@@ -25,36 +25,36 @@
// No it isn't. It doesn't matter if it's a little more verbose; it's cleaner.
//#define really_new1 new
// delete is needed for unique_ptr's deleter.
-#define really_delete1 delete
+# define really_delete1 delete
-#pragma GCC poison new
-#pragma GCC poison delete
+# pragma GCC poison new
+# pragma GCC poison delete
-#pragma GCC poison malloc
-#pragma GCC poison calloc
-#pragma GCC poison realloc
-#pragma GCC poison free
+# pragma GCC poison malloc
+# pragma GCC poison calloc
+# pragma GCC poison realloc
+# pragma GCC poison free
-#pragma GCC poison strdup
-#pragma GCC poison strndup
+# pragma GCC poison strdup
+# pragma GCC poison strndup
// complete list of glibc whose results may need to be free()d
// not believed to be used
-#pragma GCC poison posix_memalign
-#pragma GCC poison aligned_alloc
-#pragma GCC poison memalign
-#pragma GCC poison valloc
-#pragma GCC poison pvalloc
+# pragma GCC poison posix_memalign
+# pragma GCC poison aligned_alloc
+# pragma GCC poison memalign
+# pragma GCC poison valloc
+# pragma GCC poison pvalloc
-#pragma GCC poison asprintf
-#pragma GCC poison vasprintf
+# pragma GCC poison asprintf
+# pragma GCC poison vasprintf
-#pragma GCC poison canonicalize_file_name
+# pragma GCC poison canonicalize_file_name
-#pragma GCC poison cfree
+# pragma GCC poison cfree
-#pragma GCC poison open_memstream
-#pragma GCC poison open_wmemstream
+# pragma GCC poison open_memstream
+# pragma GCC poison open_wmemstream
// *scanf %ms is done very carefully.
//#pragma GCC poison scanf
@@ -64,38 +64,38 @@
//#pragma GCC poison vsscanf
//#pragma GCC poison vfscanf
-#pragma GCC poison getcwd
-#pragma GCC poison get_current_dir_name
+# pragma GCC poison getcwd
+# pragma GCC poison get_current_dir_name
-#pragma GCC poison malloc_get_state
+# pragma GCC poison malloc_get_state
-#pragma GCC poison realpath
+# pragma GCC poison realpath
-#pragma GCC poison tempnam
+# pragma GCC poison tempnam
-#pragma GCC poison wcsdup
+# pragma GCC poison wcsdup
-#pragma GCC poison memcpy
-#pragma GCC poison memmove
-#pragma GCC poison memset
-#pragma GCC poison memcmp
-#pragma GCC poison strncpy // in favor of strzcpy
+# pragma GCC poison memcpy
+# pragma GCC poison memmove
+# pragma GCC poison memset
+# pragma GCC poison memcmp
+# pragma GCC poison strncpy // in favor of strzcpy
-#pragma GCC poison string // in favor of FString, MString, etc.
-#pragma GCC poison strcasecmp
-#pragma GCC poison toupper
-#pragma GCC poison tolower
-#pragma GCC poison isupper
-#pragma GCC poison islower
+# pragma GCC poison string // in favor of FString, MString, etc.
+# pragma GCC poison strcasecmp
+# pragma GCC poison toupper
+# pragma GCC poison tolower
+# pragma GCC poison isupper
+# pragma GCC poison islower
// in favor of io::ReadFile and io::WriteFile
// note that stdout and stderr are NOT poisoned (yet)
-#pragma GCC poison FILE
-#pragma GCC poison istream
-#pragma GCC poison ostream
-#pragma GCC poison iostream
-#pragma GCC poison ifstream
-#pragma GCC poison ofstream
-#pragma GCC poison fstream
+# pragma GCC poison FILE
+# pragma GCC poison istream
+# pragma GCC poison ostream
+# pragma GCC poison iostream
+# pragma GCC poison ifstream
+# pragma GCC poison ofstream
+# pragma GCC poison fstream
#endif // GENERATING_DEPENDENCIES
diff --git a/src/strings/all.hpp b/src/strings/all.hpp
index 333cb4b..7fd543f 100644
--- a/src/strings/all.hpp
+++ b/src/strings/all.hpp
@@ -19,13 +19,13 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include "base.hpp"
-#include "mstring.hpp"
-#include "fstring.hpp"
-#include "tstring.hpp"
-#include "sstring.hpp"
-#include "zstring.hpp"
-#include "xstring.hpp"
-#include "vstring.hpp"
+# include "base.hpp"
+# include "mstring.hpp"
+# include "fstring.hpp"
+# include "tstring.hpp"
+# include "sstring.hpp"
+# include "zstring.hpp"
+# include "xstring.hpp"
+# include "vstring.hpp"
#endif // TMWA_STRINGS_ALL_HPP
diff --git a/src/strings/base.hpp b/src/strings/base.hpp
index 8c0e924..7461872 100644
--- a/src/strings/base.hpp
+++ b/src/strings/base.hpp
@@ -19,10 +19,10 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include "fwd.hpp"
-#include "pair.hpp"
+# include "fwd.hpp"
+# include "pair.hpp"
-#include <iterator>
+# include <iterator>
// It is a common mistake to assume that one string class for everything.
// Because C++ and TMWA have a C legacy, there are a few more here
@@ -192,6 +192,6 @@ namespace strings
auto operator >= (const L& l, const R& r) -> decltype((pair_compare(l, r), true));
} // namespace strings
-#include "base.tcc"
+# include "base.tcc"
#endif // TMWA_STRINGS_BASE_HPP
diff --git a/src/strings/fstring.hpp b/src/strings/fstring.hpp
index 8538b70..b025d74 100644
--- a/src/strings/fstring.hpp
+++ b/src/strings/fstring.hpp
@@ -19,13 +19,13 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include <cstdarg>
-#include <cstring>
+# include <cstdarg>
+# include <cstring>
-#include <memory>
-#include <vector>
+# include <memory>
+# include <vector>
-#include "base.hpp"
+# include "base.hpp"
namespace strings
{
@@ -89,6 +89,6 @@ namespace strings
StringConverter convert_for_scanf(FString& s);
} // namespace strings
-#include "fstring.tcc"
+# include "fstring.tcc"
#endif // TMWA_STRINGS_FSTRING_HPP
diff --git a/src/strings/fwd.hpp b/src/strings/fwd.hpp
index 9d71b5f..a865fc4 100644
--- a/src/strings/fwd.hpp
+++ b/src/strings/fwd.hpp
@@ -19,7 +19,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include "../sanity.hpp"
+# include "../sanity.hpp"
// It is a common mistake to assume that one string class for everything.
// Because C++ and TMWA have a C legacy, there are a few more here
diff --git a/src/strings/mstring.hpp b/src/strings/mstring.hpp
index 9658601..6f257ed 100644
--- a/src/strings/mstring.hpp
+++ b/src/strings/mstring.hpp
@@ -19,9 +19,9 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include <deque>
+# include <deque>
-#include "base.hpp"
+# include "base.hpp"
namespace strings
{
diff --git a/src/strings/pair.hpp b/src/strings/pair.hpp
index 2c0061a..a519ddb 100644
--- a/src/strings/pair.hpp
+++ b/src/strings/pair.hpp
@@ -19,11 +19,11 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include "../sanity.hpp"
+# include "../sanity.hpp"
-#include <cstring>
+# include <cstring>
-#include "fwd.hpp"
+# include "fwd.hpp"
namespace strings
{
diff --git a/src/strings/sstring.hpp b/src/strings/sstring.hpp
index a9558c9..12fb96d 100644
--- a/src/strings/sstring.hpp
+++ b/src/strings/sstring.hpp
@@ -19,8 +19,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include "base.hpp"
-#include "fstring.hpp"
+# include "base.hpp"
+# include "fstring.hpp"
namespace strings
{
@@ -54,6 +54,6 @@ namespace strings
};
} // namespace strings
-#include "sstring.tcc"
+# include "sstring.tcc"
#endif // TMWA_STRINGS_SSTRING_HPP
diff --git a/src/strings/tstring.hpp b/src/strings/tstring.hpp
index 5d283fa..49ec4ab 100644
--- a/src/strings/tstring.hpp
+++ b/src/strings/tstring.hpp
@@ -19,8 +19,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include "base.hpp"
-#include "fstring.hpp"
+# include "base.hpp"
+# include "fstring.hpp"
namespace strings
{
@@ -61,6 +61,6 @@ namespace strings
const char *decay_for_printf(const TString& ts);
} // namespace strings
-#include "tstring.tcc"
+# include "tstring.tcc"
#endif // TMWA_STRINGS_TSTRING_HPP
diff --git a/src/strings/vstring.hpp b/src/strings/vstring.hpp
index 7864b7d..c07c32a 100644
--- a/src/strings/vstring.hpp
+++ b/src/strings/vstring.hpp
@@ -19,7 +19,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include "base.hpp"
+# include "base.hpp"
namespace strings
{
@@ -64,6 +64,6 @@ namespace strings
int do_vprint(VString<len>& out, const char *fmt, va_list ap);
} // namespace strings
-#include "vstring.tcc"
+# include "vstring.tcc"
#endif // TMWA_STRINGS_VSTRING_HPP
diff --git a/src/strings/xstring.hpp b/src/strings/xstring.hpp
index 72cae1e..e96ef8a 100644
--- a/src/strings/xstring.hpp
+++ b/src/strings/xstring.hpp
@@ -19,7 +19,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include "base.hpp"
+# include "base.hpp"
namespace strings
{
@@ -56,6 +56,6 @@ namespace strings
};
} // namespace strings
-#include "xstring.tcc"
+# include "xstring.tcc"
#endif // TMWA_STRINGS_XSTRING_HPP
diff --git a/src/strings/zstring.hpp b/src/strings/zstring.hpp
index 358e3bc..72a227c 100644
--- a/src/strings/zstring.hpp
+++ b/src/strings/zstring.hpp
@@ -19,9 +19,9 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
-#include <cstring>
+# include <cstring>
-#include "base.hpp"
+# include "base.hpp"
namespace strings
{
@@ -66,6 +66,6 @@ namespace strings
int do_vscan(ZString in, const char *fmt, va_list ap);
} // namespace strings
-#include "zstring.tcc"
+# include "zstring.tcc"
#endif // TMWA_STRINGS_ZSTRING_HPP
diff --git a/tools/apply-filter b/tools/apply-filter
new file mode 100755
index 0000000..6d36be4
--- /dev/null
+++ b/tools/apply-filter
@@ -0,0 +1,10 @@
+#!/bin/bash -eu
+# Apply a filter command to a set of files
+
+filter=$1; shift
+for arg
+do
+ echo apply-filter "$filter" "$arg"
+ bash -c "$filter" < "$arg" > "$arg.tmp"
+ maybe-mv "$arg.tmp" "$arg"
+done
diff --git a/tools/bs-align b/tools/bs-align
new file mode 100755
index 0000000..6582298
--- /dev/null
+++ b/tools/bs-align
@@ -0,0 +1,45 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8
+## bs-align.py - Filter to align trailing line continuations
+##
+## Copyright ©2013 Ben Longbons <b.r.longbons@gmail.com>
+##
+## This file is part of The Mana World (Athena server)
+##
+## This program is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Settings.
+pad = 1
+align = 4
+min_col = 8
+
+import sys
+
+lines = []
+
+for line in sys.stdin:
+ if line.endswith('\\\n'):
+ lines.append(line[:-2].rstrip())
+ continue
+ if lines:
+ # TODO: correctly handle tabs and multibyte characters
+ tlen = max(len(l) for l in lines) + pad
+ if tlen < min_col:
+ tlen = min_col
+ elif tlen % align:
+ tlen += align - tlen % align
+ for l in lines:
+ sys.stdout.writelines([l, ' ' * (tlen - len(l)), '\\\n'])
+ del lines[:]
+ sys.stdout.write(line)
diff --git a/tools/maybe-mv b/tools/maybe-mv
new file mode 100755
index 0000000..725b86b
--- /dev/null
+++ b/tools/maybe-mv
@@ -0,0 +1,8 @@
+#!/bin/bash -eu
+# Replace one file with another, but maybe don't update the timestamp
+if cmp -s "$1" "$2"
+then
+ rm "$1"
+else
+ mv "$1" "$2"
+fi
diff --git a/tools/maybe-replace b/tools/maybe-replace
new file mode 100755
index 0000000..97bd19c
--- /dev/null
+++ b/tools/maybe-replace
@@ -0,0 +1,3 @@
+#!/bin/bash -eu
+cat > "$1.tmp"
+maybe-mv "$1.tmp" "$1"
diff --git a/tools/pp-indent b/tools/pp-indent
new file mode 100755
index 0000000..9be9a03
--- /dev/null
+++ b/tools/pp-indent
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8
+## pp-indent - Filter to apply indentation to preprocessor statements
+##
+## Copyright ©2013 Ben Longbons <b.r.longbons@gmail.com>
+##
+## This file is part of The Mana World (Athena server)
+##
+## This program is free software: you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation, either version 3 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Settings.
+
+pre_indent = ''
+post_indent = ' '
+rules = {
+ 'if': (0, 1),
+ 'ifdef': (0, 1),
+ 'ifndef': (0, 1),
+ 'else': (-1, 1),
+ 'elif': (-1, 1),
+ 'endif': (-1, 0),
+ 'define_h': (-1, 1),
+}
+
+import sys
+
+depth = 0
+for line in sys.stdin:
+ sline = line.lstrip()
+ if not sline.startswith('#'):
+ sys.stdout.write(line)
+ continue
+ line = sline[1:].lstrip()
+ if not line:
+ sys.stdout.write('\n')
+ continue
+ word = line.split(None, 1)[0]
+ if word == 'define' and line.endswith('_HPP\n'):
+ word = 'define_h'
+ pre, post = rules.get(word, (0, 0))
+ depth += pre
+ sys.stdout.writelines([depth * pre_indent, '#', depth * post_indent, line])
+ depth += post