summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/HPMDataCheck.h9
-rw-r--r--src/common/Makefile.in2
-rw-r--r--src/common/cbasetypes.h3
-rw-r--r--src/common/console.h8
-rw-r--r--src/common/memmgr.c2
-rw-r--r--src/common/mmo.h6
-rw-r--r--src/common/socket.c39
7 files changed, 47 insertions, 22 deletions
diff --git a/src/common/HPMDataCheck.h b/src/common/HPMDataCheck.h
index c60bec4c8..00ac57cd5 100644
--- a/src/common/HPMDataCheck.h
+++ b/src/common/HPMDataCheck.h
@@ -446,14 +446,19 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = {
#endif // MAP_MOB_H
#ifdef MAP_NPC_H
{ "event_data", sizeof(struct event_data), SERVER_TYPE_MAP },
+ { "npc_chat_interface", sizeof(struct npc_chat_interface), SERVER_TYPE_MAP },
{ "npc_data", sizeof(struct npc_data), SERVER_TYPE_MAP },
{ "npc_interface", sizeof(struct npc_interface), SERVER_TYPE_MAP },
{ "npc_item_list", sizeof(struct npc_item_list), SERVER_TYPE_MAP },
{ "npc_label_list", sizeof(struct npc_label_list), SERVER_TYPE_MAP },
+ { "npc_parse", sizeof(struct npc_parse), SERVER_TYPE_MAP },
{ "npc_path_data", sizeof(struct npc_path_data), SERVER_TYPE_MAP },
{ "npc_shop_data", sizeof(struct npc_shop_data), SERVER_TYPE_MAP },
{ "npc_src_list", sizeof(struct npc_src_list), SERVER_TYPE_MAP },
{ "npc_timerevent_list", sizeof(struct npc_timerevent_list), SERVER_TYPE_MAP },
+ { "pcre_interface", sizeof(struct pcre_interface), SERVER_TYPE_MAP },
+ { "pcrematch_entry", sizeof(struct pcrematch_entry), SERVER_TYPE_MAP },
+ { "pcrematch_set", sizeof(struct pcrematch_set), SERVER_TYPE_MAP },
#else
#define MAP_NPC_H
#endif // MAP_NPC_H
@@ -589,8 +594,6 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = {
#ifdef MAP_SCRIPT_H
{ "Script_Config", sizeof(struct Script_Config), SERVER_TYPE_MAP },
{ "casecheck_data", sizeof(struct casecheck_data), SERVER_TYPE_MAP },
- { "hQueue", sizeof(struct hQueue), SERVER_TYPE_MAP },
- { "hQueueIterator", sizeof(struct hQueueIterator), SERVER_TYPE_MAP },
{ "reg_db", sizeof(struct reg_db), SERVER_TYPE_MAP },
{ "script_array", sizeof(struct script_array), SERVER_TYPE_MAP },
{ "script_code", sizeof(struct script_code), SERVER_TYPE_MAP },
@@ -598,6 +601,8 @@ HPExport const struct s_HPMDataCheck HPMDataCheck[] = {
{ "script_function", sizeof(struct script_function), SERVER_TYPE_MAP },
{ "script_interface", sizeof(struct script_interface), SERVER_TYPE_MAP },
{ "script_label_entry", sizeof(struct script_label_entry), SERVER_TYPE_MAP },
+ { "script_queue", sizeof(struct script_queue), SERVER_TYPE_MAP },
+ { "script_queue_iterator", sizeof(struct script_queue_iterator), SERVER_TYPE_MAP },
{ "script_retinfo", sizeof(struct script_retinfo), SERVER_TYPE_MAP },
{ "script_stack", sizeof(struct script_stack), SERVER_TYPE_MAP },
{ "script_state", sizeof(struct script_state), SERVER_TYPE_MAP },
diff --git a/src/common/Makefile.in b/src/common/Makefile.in
index 88e991651..f9917ef0d 100644
--- a/src/common/Makefile.in
+++ b/src/common/Makefile.in
@@ -119,7 +119,7 @@ obj_all/sysinfo.o: sysinfo.c $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_
obj_all/%.o: %.c $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | $(SYSINFO_INC) obj_all
@echo " CC $<"
- @$(CC) @CFLAGS@ @DEFS@ $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
+ @$(CC) @CFLAGS@ @DEFS@ $(COMMON_INCLUDE) $(THIRDPARTY_INCLUDE) @PCRE_CFLAGS@ @CPPFLAGS@ -c $(OUTPUT_OPTION) $<
obj_all/mini%.o: %.c $(COMMON_H) $(CONFIG_H) $(MT19937AR_H) $(LIBCONFIG_H) | $(SYSINFO_INC) obj_all
@echo " CC $<"
diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h
index 64f21f7e0..5fc08b770 100644
--- a/src/common/cbasetypes.h
+++ b/src/common/cbasetypes.h
@@ -428,4 +428,7 @@ typedef char bool;
#define ZEROED_BLOCK_POS(x) (&(x)->HERC__zeroed_block_BEGIN)
#define ZEROED_BLOCK_SIZE(x) ((char*)&((x)->HERC__zeroed_block_END) - (char*)&((x)->HERC__zeroed_block_BEGIN) + sizeof((x)->HERC__zeroed_block_END))
+/** Support macros for marking structs as unavailable */
+#define UNAVAILABLE_STRUCT int8 HERC__unavailable_struct
+
#endif /* COMMON_CBASETYPES_H */
diff --git a/src/common/console.h b/src/common/console.h
index ef6db0cb4..102a1beaf 100644
--- a/src/common/console.h
+++ b/src/common/console.h
@@ -50,8 +50,8 @@ struct CParseEntry {
} u;
};
-#ifdef CONSOLE_INPUT
struct console_input_interface {
+#ifdef CONSOLE_INPUT
/* vars */
SPIN_LOCK ptlock;/* parse thread lock */
rAthread *pthread;/* parse thread */
@@ -75,10 +75,10 @@ struct console_input_interface {
void (*parse_list_subs) (struct CParseEntry *cmd, unsigned char depth);
void (*addCommand) (char *name, CParseFunc func);
void (*setSQL) (Sql *SQL_handle);
-};
-#else
-struct console_input_interface;
+#else // not CONSOLE_INPUT
+ UNAVAILABLE_STRUCT;
#endif
+};
struct console_interface {
void (*init) (void);
diff --git a/src/common/memmgr.c b/src/common/memmgr.c
index 0d9305b06..f7177338c 100644
--- a/src/common/memmgr.c
+++ b/src/common/memmgr.c
@@ -140,7 +140,7 @@ void* aReallocz_(void *p, size_t size, const char *file, int line, const char *f
#else
size_t newSize;
if (p) {
- size_t oldSize = malloc_usable_size(p);
+ size_t oldSize = BUFFER_SIZE(p);
ret = REALLOC(p, size, file, line, func);
newSize = BUFFER_SIZE(ret);
if (ret && newSize > oldSize)
diff --git a/src/common/mmo.h b/src/common/mmo.h
index 73d4510a1..095b96341 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -462,13 +462,15 @@ struct s_friend {
char name[NAME_LENGTH];
};
-#ifdef HOTKEY_SAVING
struct hotkey {
+#ifdef HOTKEY_SAVING
unsigned int id;
unsigned short lv;
unsigned char type; // 0: item, 1: skill
-};
+#else // not HOTKEY_SAVING
+ UNAVAILABLE_STRUCT;
#endif
+};
struct mmo_charstatus {
int char_id;
diff --git a/src/common/socket.c b/src/common/socket.c
index b418a468f..362fe78db 100644
--- a/src/common/socket.c
+++ b/src/common/socket.c
@@ -303,18 +303,31 @@ void set_nonblocking(int fd, unsigned long yes)
ShowError("set_nonblocking: Failed to set socket #%d to non-blocking mode (%s) - Please report this!!!\n", fd, error_msg());
}
-void setsocketopts(int fd, struct hSockOpt *opt) {
- int yes = 1; // reuse fix
- struct linger lopt;
+/**
+ * Sets the options for a socket.
+ *
+ * @param fd The socket descriptor
+ * @param opt Optional, additional options to set (Can be NULL).
+ */
+void setsocketopts(int fd, struct hSockOpt *opt)
+{
+#if defined(WIN32)
+ BOOL yes = TRUE;
+#else // not WIN32
+ int yes = 1;
+#endif // WIN32
+ struct linger lopt = { 0 };
+ // Note: We cast the fourth argument to (char *) because, while in UNIX
+ // it takes a const void *, in Windows it takes a const char *.
#if !defined(WIN32)
// set SO_REAUSEADDR to true, unix only. on windows this option causes
// the previous owner of the socket to give up, which is not desirable
// in most cases, neither compatible with unix.
- if (sSetsockopt(fd,SOL_SOCKET,SO_REUSEADDR,(char *)&yes,sizeof(yes)))
+ if (sSetsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&yes, sizeof(yes)))
ShowWarning("setsocketopts: Unable to set SO_REUSEADDR mode for connection #%d!\n", fd);
#ifdef SO_REUSEPORT
- if (sSetsockopt(fd,SOL_SOCKET,SO_REUSEPORT,(char *)&yes,sizeof(yes)))
+ if (sSetsockopt(fd, SOL_SOCKET, SO_REUSEPORT, (char *)&yes, sizeof(yes)))
ShowWarning("setsocketopts: Unable to set SO_REUSEPORT mode for connection #%d!\n", fd);
#endif // SO_REUSEPORT
#endif // WIN32
@@ -324,15 +337,17 @@ void setsocketopts(int fd, struct hSockOpt *opt) {
if (sSetsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char *)&yes, sizeof(yes)))
ShowWarning("setsocketopts: Unable to set TCP_NODELAY mode for connection #%d!\n", fd);
- if( opt && opt->setTimeo ) {
- struct timeval timeout;
-
+ if (opt && opt->setTimeo) {
+#if defined(WIN32)
+ DWORD timeout = 5000; // https://msdn.microsoft.com/en-us/library/windows/desktop/ms740476(v=vs.85).aspx
+#else // not WIN32
+ struct timeval timeout = { 0 };
timeout.tv_sec = 5;
- timeout.tv_usec = 0;
+#endif // WIN32
- if (sSetsockopt(fd,SOL_SOCKET,SO_RCVTIMEO,(char *)&timeout,sizeof(timeout)))
+ if (sSetsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof(timeout)))
ShowWarning("setsocketopts: Unable to set SO_RCVTIMEO for connection #%d!\n", fd);
- if (sSetsockopt(fd,SOL_SOCKET,SO_SNDTIMEO,(char *)&timeout,sizeof(timeout)))
+ if (sSetsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout, sizeof(timeout)))
ShowWarning("setsocketopts: Unable to set SO_SNDTIMEO for connection #%d!\n", fd);
}
@@ -340,7 +355,7 @@ void setsocketopts(int fd, struct hSockOpt *opt) {
//(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/closesocket_2.asp)
lopt.l_onoff = 0; // SO_DONTLINGER
lopt.l_linger = 0; // Do not care
- if( sSetsockopt(fd, SOL_SOCKET, SO_LINGER, (char*)&lopt, sizeof(lopt)) )
+ if (sSetsockopt(fd, SOL_SOCKET, SO_LINGER, (char *)&lopt, sizeof(lopt)))
ShowWarning("setsocketopts: Unable to set SO_LINGER mode for connection #%d!\n", fd);
#ifdef TCP_THIN_LINEAR_TIMEOUTS