summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2013-02-07 19:38:32 -0800
committerBen Longbons <b.r.longbons@gmail.com>2013-02-07 22:41:23 -0800
commit83b2e0b3ceda907b7186acfcc56c214fc04d9c13 (patch)
treef4dcc8d8b59fd9a633bc2604cc92f0523cc76ee4 /src/common
parentc67c2b7435a13d7ce17b2075e22dc5c6036f702a (diff)
downloadtmwa-83b2e0b3ceda907b7186acfcc56c214fc04d9c13.tar.gz
tmwa-83b2e0b3ceda907b7186acfcc56c214fc04d9c13.tar.bz2
tmwa-83b2e0b3ceda907b7186acfcc56c214fc04d9c13.tar.xz
tmwa-83b2e0b3ceda907b7186acfcc56c214fc04d9c13.zip
Remove some macros
Diffstat (limited to 'src/common')
-rw-r--r--src/common/db.hpp2
-rw-r--r--src/common/grfio.hpp10
-rw-r--r--src/common/mmo.hpp46
-rw-r--r--src/common/socket.hpp4
-rw-r--r--src/common/utils.hpp2
5 files changed, 26 insertions, 38 deletions
diff --git a/src/common/db.hpp b/src/common/db.hpp
index d04f318..7d07b1d 100644
--- a/src/common/db.hpp
+++ b/src/common/db.hpp
@@ -9,7 +9,7 @@
/// Number of tree roots
// Somewhat arbitrary - larger wastes more space but is faster for large trees
// num % HASH_SIZE minimize collisions even for similar num
-# define HASH_SIZE (256+27)
+constexpr int HASH_SIZE = 256 + 27;
typedef enum dbn_color
{
diff --git a/src/common/grfio.hpp b/src/common/grfio.hpp
index 58afb07..7707b2b 100644
--- a/src/common/grfio.hpp
+++ b/src/common/grfio.hpp
@@ -8,11 +8,17 @@
// Note that there currently is a 1-1 correlation between them,
// but it is possible for a single .wlk to have multiple .gats reference it
-/// Load file into memory
-# define grfio_read(resourcename) grfio_reads(resourcename, NULL)
/// Load file into memory and possibly record length
// For some reason, this allocates an extra 1024 bytes at the end
void *grfio_reads(const char *resourcename, size_t *size);
+
+/// Load file into memory
+inline
+void *grfio_read(const char *resourcename)
+{
+ return grfio_reads(resourcename, NULL);
+}
+
/// Get size of file
// This is only called once, and that is to check the existence of a file.
size_t grfio_size(const char *resourcename) __attribute__((deprecated));
diff --git a/src/common/mmo.hpp b/src/common/mmo.hpp
index db150ba..1bbb28a 100644
--- a/src/common/mmo.hpp
+++ b/src/common/mmo.hpp
@@ -6,33 +6,27 @@
# include "utils.hpp"
-# define FIFOSIZE_SERVERLINK 256*1024
+constexpr int FIFOSIZE_SERVERLINK = 256 * 1024;
-// set to 0 to not check IP of player between each server.
-// set to another value if you want to check (1)
-# define CMP_AUTHFIFO_IP 1
+constexpr int MAX_MAP_PER_SERVER = 512;
+constexpr int MAX_INVENTORY = 100;
+constexpr int MAX_AMOUNT = 30000;
+constexpr int MAX_ZENY = 1000000000; // 1G zeny
+constexpr int MAX_CART = 100;
-# define CMP_AUTHFIFO_LOGIN2 1
-
-# define MAX_MAP_PER_SERVER 512
-# define MAX_INVENTORY 100
-# define MAX_AMOUNT 30000
-# define MAX_ZENY 1000000000 // 1G zeny
-# define MAX_CART 100
enum class SkillID : uint16_t;
constexpr SkillID MAX_SKILL = SkillID(474); // not 450
constexpr SkillID get_enum_min_value(SkillID) { return SkillID(); }
constexpr SkillID get_enum_max_value(SkillID) { return MAX_SKILL; }
-
-# define GLOBAL_REG_NUM 96
-# define ACCOUNT_REG_NUM 16
-# define ACCOUNT_REG2_NUM 16
-# define DEFAULT_WALK_SPEED 150
-# define MIN_WALK_SPEED 0
-# define MAX_WALK_SPEED 1000
-# define MAX_STORAGE 300
-# define MAX_PARTY 12
+constexpr int GLOBAL_REG_NUM = 96;
+constexpr int ACCOUNT_REG_NUM = 16;
+constexpr int ACCOUNT_REG2_NUM = 16;
+constexpr int DEFAULT_WALK_SPEED = 150;
+constexpr int MIN_WALK_SPEED = 0;
+constexpr int MAX_WALK_SPEED = 1000;
+constexpr int MAX_STORAGE = 300;
+constexpr int MAX_PARTY = 12;
# define MIN_HAIR_STYLE battle_config.min_hair_style
# define MAX_HAIR_STYLE battle_config.max_hair_style
@@ -41,18 +35,6 @@ constexpr SkillID get_enum_max_value(SkillID) { return MAX_SKILL; }
# define MIN_CLOTH_COLOR battle_config.min_cloth_color
# define MAX_CLOTH_COLOR battle_config.max_cloth_color
-// for produce
-# define MIN_ATTRIBUTE 0
-# define MAX_ATTRIBUTE 4
-# define ATTRIBUTE_NORMAL 0
-# define MIN_STAR 0
-# define MAX_STAR 3
-
-# define MIN_PORTAL_MEMO 0
-# define MAX_PORTAL_MEMO 2
-
-# define MAX_STATUS_TYPE 5
-
# define CHAR_CONF_NAME "conf/char_athena.conf"
namespace e
diff --git a/src/common/socket.hpp b/src/common/socket.hpp
index b9b80b3..48caee5 100644
--- a/src/common/socket.hpp
+++ b/src/common/socket.hpp
@@ -46,10 +46,10 @@ struct socket_data
};
// save file descriptors for important stuff
-# define SOFT_LIMIT (FD_SETSIZE - 50)
+constexpr int SOFT_LIMIT = FD_SETSIZE - 50;
// socket timeout to establish a full connection in seconds
-# define CONNECT_TIMEOUT 15
+constexpr int CONNECT_TIMEOUT = 15;
/// Everyone who has connected
// note: call delete_session(i) to null out an element
diff --git a/src/common/utils.hpp b/src/common/utils.hpp
index 553d34f..7ebd978 100644
--- a/src/common/utils.hpp
+++ b/src/common/utils.hpp
@@ -22,7 +22,7 @@ future calls should either use this or depend on the coming segfault.
if (!((result) = (type *) calloc((number), sizeof(type)))) \
{ perror("SYSERR: malloc failure"); abort(); } else (void)0
-# define RECREATE(result,type,number) \
+# define RECREATE(result, type, number) \
if (!((result) = (type *) realloc((result), sizeof(type) * (number))))\
{ perror("SYSERR: realloc failure"); abort(); } else (void)0