From ec1bc50b01aa4f34f151b3b3800011abdce31919 Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 24 Jun 2018 04:06:39 +0200 Subject: When the memmgr is enabled, don't define the non-memmgr functions needlessly Signed-off-by: Haru --- src/common/memmgr.c | 45 +++++++++++++++++++-------------------------- 1 file changed, 19 insertions(+), 26 deletions(-) diff --git a/src/common/memmgr.c b/src/common/memmgr.c index bdaf61db3..3c9cca6a6 100644 --- a/src/common/memmgr.c +++ b/src/common/memmgr.c @@ -113,8 +113,6 @@ struct malloc_interface *iMalloc; #error Unsupported OS #endif -#endif - void* aMalloc_(size_t size, const char *file, int line, const char *func) { void *ret = MALLOC(size, file, line, func); @@ -151,9 +149,6 @@ void* aReallocz_(void *p, size_t size, const char *file, int line, const char *f { unsigned char *ret = NULL; // ShowMessage("%s:%d: in func %s: aReallocz %p %ld\n",file,line,func,p,size); -#ifdef USE_MEMMGR - ret = REALLOC(p, size, file, line, func); -#else if (p != NULL) { size_t newSize; size_t oldSize = BUFFER_SIZE(p); @@ -166,7 +161,6 @@ void* aReallocz_(void *p, size_t size, const char *file, int line, const char *f if (ret != NULL) memset(ret, 0, BUFFER_SIZE(ret)); } -#endif if (ret == NULL) { ShowFatalError("%s:%d: in func %s: aRealloc error out of memory!\n",file,line,func); exit(EXIT_FAILURE); @@ -222,8 +216,7 @@ void aFree_(void *p, const char *file, int line, const char *func) //p = NULL; } - -#ifdef USE_MEMMGR +#else // USE_MEMMGR #if defined(DEBUG) #define DEBUG_MEMMGR @@ -232,21 +225,21 @@ void aFree_(void *p, const char *file, int line, const char *func) /* USE_MEMMGR */ /* -* Memory manager -* able to handle malloc and free efficiently -* Since the complex processing, I might be slightly heavier. -* -* (I'm sorry for the poor description ^ ^;) such as data structures -* Divided into "blocks" of a plurality of memory, "unit" of a plurality of blocks further -* I have to divide. Size of the unit, a plurality of distribution equal to the capacity of one block -* That's what you have. For example, if one unit of 32KB, one block 1 Yu 32Byte -* Knit, or are able to gather 1024, gathered 512 units 64Byte -* I can be or have. (Excluding padding, the unit_head) -* -* Lead-linked list (block_prev, block_next) in each other is the same size block -* Linked list (hash_prev, hash_nect) even among such one in the block with the figure -* I like to have. Thus, reuse of memory no longer needed can be performed efficiently. -*/ + * Memory manager + * able to handle malloc and free efficiently + * Since the complex processing, I might be slightly heavier. + * + * (I'm sorry for the poor description ^ ^;) such as data structures + * Divided into "blocks" of a plurality of memory, "unit" of a plurality of blocks further + * I have to divide. Size of the unit, a plurality of distribution equal to the capacity of one block + * That's what you have. For example, if one unit of 32KB, one block 1 Yu 32Byte + * Knit, or are able to gather 1024, gathered 512 units 64Byte + * I can be or have. (Excluding padding, the unit_head) + * + * Lead-linked list (block_prev, block_next) in each other is the same size block + * Linked list (hash_prev, hash_nect) even among such one in the block with the figure + * I like to have. Thus, reuse of memory no longer needed can be performed efficiently. + */ /* Alignment of the block */ #define BLOCK_ALIGNMENT1 16 @@ -919,9 +912,9 @@ static void memmgr_init_messages(void) /*====================================== -* Initialize -*-------------------------------------- -*/ + * Initialize + *-------------------------------------- + */ /// Tests the memory for errors and memory leaks. -- cgit v1.2.3-70-g09d2 From 8dd7aec896efc0220d6234bcfb190767c30dbb29 Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 24 Jun 2018 00:13:59 +0200 Subject: Change functions to static where possible (Part 1 - common) This fixes issues with plugins defining symbols with the same names Signed-off-by: Haru --- src/common/HPM.c | 95 ++++++++++++++++++------------------ src/common/conf.c | 44 ++++++++--------- src/common/console.c | 50 +++++++++---------- src/common/core.c | 26 +++++----- src/common/db.c | 58 +++++++++++----------- src/common/des.c | 6 +-- src/common/ers.c | 2 +- src/common/grfio.c | 32 ++++++------ src/common/mapindex.c | 20 ++++---- src/common/md5calc.c | 6 +-- src/common/memmgr.c | 82 ++++++++++++++++++------------- src/common/mutex.c | 22 ++++----- src/common/nullpo.c | 8 +-- src/common/random.c | 18 +++---- src/common/showmsg.c | 72 ++++++++++++++------------- src/common/socket.c | 133 +++++++++++++++++++++++++++----------------------- src/common/sql.c | 88 ++++++++++++++++----------------- src/common/strlib.c | 101 +++++++++++++++++++++++--------------- src/common/sysinfo.c | 54 ++++++++++---------- src/common/thread.c | 29 +++++------ src/common/timer.c | 79 ++++++++++++++++++------------ src/common/utils.c | 30 ++++++------ 22 files changed, 562 insertions(+), 493 deletions(-) diff --git a/src/common/HPM.c b/src/common/HPM.c index c84b447e8..300edf60a 100644 --- a/src/common/HPM.c +++ b/src/common/HPM.c @@ -48,25 +48,25 @@ # include #endif -struct malloc_interface iMalloc_HPM; -struct malloc_interface *HPMiMalloc; -struct HPM_interface HPM_s; +static struct malloc_interface iMalloc_HPM; +static struct malloc_interface *HPMiMalloc; +static struct HPM_interface HPM_s; struct HPM_interface *HPM; -struct HPMHooking_core_interface HPMHooking_core_s; +static struct HPMHooking_core_interface HPMHooking_core_s; /** * (char*) data name -> (unsigned int) HPMDataCheck[] index **/ -struct DBMap *datacheck_db; -int datacheck_version; -const struct s_HPMDataCheck *datacheck_data; +static struct DBMap *datacheck_db; +static int datacheck_version; +static const struct s_HPMDataCheck *datacheck_data; /** * Executes an event on all loaded plugins. * * @param type The event type to trigger. */ -void hplugin_trigger_event(enum hp_event_types type) +static void hplugin_trigger_event(enum hp_event_types type) { int i; for (i = 0; i < VECTOR_LENGTH(HPM->plugins); i++) { @@ -82,7 +82,7 @@ void hplugin_trigger_event(enum hp_event_types type) * @param value The symbol value. * @param name The symbol name. */ -void hplugin_export_symbol(void *value, const char *name) +static void hplugin_export_symbol(void *value, const char *name) { struct hpm_symbol *symbol = NULL; CREATE(symbol ,struct hpm_symbol, 1); @@ -100,7 +100,7 @@ void hplugin_export_symbol(void *value, const char *name) * @return The symbol value. * @retval NULL if the symbol wasn't found. */ -void *hplugin_import_symbol(char *name, unsigned int pID) +static void *hplugin_import_symbol(char *name, unsigned int pID) { int i; nullpo_retr(NULL, name); @@ -113,7 +113,8 @@ void *hplugin_import_symbol(char *name, unsigned int pID) return NULL; } -bool hplugin_iscompatible(char* version) { +static bool hplugin_iscompatible(char *version) +{ unsigned int req_major = 0, req_minor = 0; if( version == NULL ) @@ -131,7 +132,7 @@ bool hplugin_iscompatible(char* version) { * @retval true if the plugin exists and is currently loaded. * @retval false otherwise. */ -bool hplugin_exists(const char *filename) +static bool hplugin_exists(const char *filename) { int i; nullpo_retr(false, filename); @@ -147,7 +148,7 @@ bool hplugin_exists(const char *filename) * * @return A (retained) pointer to the initialized data. */ -struct hplugin *hplugin_create(void) +static struct hplugin *hplugin_create(void) { struct hplugin *plugin = NULL; CREATE(plugin, struct hplugin, 1); @@ -158,7 +159,7 @@ struct hplugin *hplugin_create(void) return plugin; } -bool hplugins_addpacket(unsigned short cmd, unsigned short length, void (*receive) (int fd), unsigned int point, unsigned int pluginID) +static bool hplugins_addpacket(unsigned short cmd, unsigned short length, void (*receive) (int fd), unsigned int point, unsigned int pluginID) { struct HPluginPacket *packet; int i; @@ -204,7 +205,7 @@ bool hplugins_addpacket(unsigned short cmd, unsigned short length, void (*receiv * initialized through \c HPM->data_store_create() and ownership is passed * to the caller. */ -bool hplugin_data_store_validate(enum HPluginDataTypes type, struct hplugin_data_store **storeptr, bool initialize) +static bool hplugin_data_store_validate(enum HPluginDataTypes type, struct hplugin_data_store **storeptr, bool initialize) { struct hplugin_data_store *store; nullpo_retr(false, storeptr); @@ -248,7 +249,7 @@ bool hplugin_data_store_validate(enum HPluginDataTypes type, struct hplugin_data * @param classid[in] The entry class identifier. * @param autofree[in] Whether the entry should be automatically freed when removed. */ -void hplugins_addToHPData(enum HPluginDataTypes type, uint32 pluginID, struct hplugin_data_store **storeptr, void *data, uint32 classid, bool autofree) +static void hplugins_addToHPData(enum HPluginDataTypes type, uint32 pluginID, struct hplugin_data_store **storeptr, void *data, uint32 classid, bool autofree) { struct hplugin_data_store *store; struct hplugin_data_entry *entry; @@ -293,7 +294,7 @@ void hplugins_addToHPData(enum HPluginDataTypes type, uint32 pluginID, struct hp * * @return The retrieved entry, or NULL. */ -void *hplugins_getFromHPData(enum HPluginDataTypes type, uint32 pluginID, struct hplugin_data_store *store, uint32 classid) +static void *hplugins_getFromHPData(enum HPluginDataTypes type, uint32 pluginID, struct hplugin_data_store *store, uint32 classid) { int i; @@ -320,7 +321,7 @@ void *hplugins_getFromHPData(enum HPluginDataTypes type, uint32 pluginID, struct * @param store[in] The store. * @param classid[in] The entry class identifier. */ -void hplugins_removeFromHPData(enum HPluginDataTypes type, uint32 pluginID, struct hplugin_data_store *store, uint32 classid) +static void hplugins_removeFromHPData(enum HPluginDataTypes type, uint32 pluginID, struct hplugin_data_store *store, uint32 classid) { struct hplugin_data_entry *entry; int i; @@ -344,7 +345,7 @@ void hplugins_removeFromHPData(enum HPluginDataTypes type, uint32 pluginID, stru } /* TODO: add ability for tracking using pID for the upcoming runtime load/unload support. */ -bool HPM_AddHook(enum HPluginHookType type, const char *target, void *hook, unsigned int pID) +static bool HPM_AddHook(enum HPluginHookType type, const char *target, void *hook, unsigned int pID) { if (!HPM->hooking->enabled) { ShowError("HPM:AddHook Fail! '%s' tried to hook to '%s' but HPMHooking is disabled!\n",HPM->pid2name(pID),target); @@ -360,13 +361,13 @@ bool HPM_AddHook(enum HPluginHookType type, const char *target, void *hook, unsi return false; } -void HPM_HookStop(const char *func, unsigned int pID) +static void HPM_HookStop(const char *func, unsigned int pID) { /* track? */ HPM->hooking->force_return = true; } -bool HPM_HookStopped(void) +static bool HPM_HookStopped(void) { return HPM->hooking->force_return; } @@ -381,7 +382,7 @@ bool HPM_HookStopped(void) * @param help the help string to be displayed by '--help', if any. * @return the success status. */ -bool hpm_add_arg(unsigned int pluginID, char *name, bool has_param, CmdlineExecFunc func, const char *help) +static bool hpm_add_arg(unsigned int pluginID, char *name, bool has_param, CmdlineExecFunc func, const char *help) { int i; @@ -410,7 +411,7 @@ bool hpm_add_arg(unsigned int pluginID, char *name, bool has_param, CmdlineExecF * @retval true if the listener was added successfully. * @retval false in case of error. */ -bool hplugins_addconf(unsigned int pluginID, enum HPluginConfType type, char *name, void (*parse_func) (const char *key, const char *val), int (*return_func) (const char *key), bool required) +static bool hplugins_addconf(unsigned int pluginID, enum HPluginConfType type, char *name, void (*parse_func) (const char *key, const char *val), int (*return_func) (const char *key), bool required) { struct HPConfListenStorage *conf; int i; @@ -450,7 +451,7 @@ bool hplugins_addconf(unsigned int pluginID, enum HPluginConfType type, char *na return true; } -struct hplugin *hplugin_load(const char* filename) +static struct hplugin *hplugin_load(const char *filename) { struct hplugin *plugin; struct hplugin_info *info; @@ -598,7 +599,7 @@ struct hplugin *hplugin_load(const char* filename) * * @param plugin The plugin data. */ -void hplugin_unload(struct hplugin* plugin) +static void hplugin_unload(struct hplugin *plugin) { int i; nullpo_retv(plugin); @@ -628,7 +629,7 @@ CMDLINEARG(loadplugin) /** * Reads the plugin configuration and loads the plugins as necessary. */ -void hplugins_config_read(void) +static void hplugins_config_read(void) { struct config_t plugins_conf; struct config_setting_t *plist = NULL; @@ -707,7 +708,7 @@ void hplugins_config_read(void) * * @see CPCMD() */ -CPCMD(plugins) +static CPCMD(plugins) { int i; @@ -733,7 +734,7 @@ CPCMD(plugins) * @retval 1 OK * @retval 2 incomplete packet */ -unsigned char hplugins_parse_packets(int fd, int packet_id, enum HPluginPacketHookingPoints point) +static unsigned char hplugins_parse_packets(int fd, int packet_id, enum HPluginPacketHookingPoints point) { struct HPluginPacket *packet = NULL; int i; @@ -765,7 +766,7 @@ unsigned char hplugins_parse_packets(int fd, int packet_id, enum HPluginPacketHo * @retval "core" if the plugin ID belongs to the Hercules core. * @retval "UnknownPlugin" if the plugin wasn't found. */ -char *hplugins_id2name(unsigned int pid) +static char *hplugins_id2name(unsigned int pid) { int i; @@ -791,7 +792,7 @@ char *hplugins_id2name(unsigned int pid) * @param file The string/filename to retain * @return A retained copy of the source string. */ -const char *HPM_file2ptr(const char *file) +static const char *HPM_file2ptr(const char *file) { int i; @@ -810,27 +811,27 @@ const char *HPM_file2ptr(const char *file) return HPM->filenames.data[i].name; } -void* HPM_mmalloc(size_t size, const char *file, int line, const char *func) +static void *HPM_mmalloc(size_t size, const char *file, int line, const char *func) { return iMalloc->malloc(size,HPM_file2ptr(file),line,func); } -void* HPM_calloc(size_t num, size_t size, const char *file, int line, const char *func) +static void *HPM_calloc(size_t num, size_t size, const char *file, int line, const char *func) { return iMalloc->calloc(num,size,HPM_file2ptr(file),line,func); } -void* HPM_realloc(void *p, size_t size, const char *file, int line, const char *func) +static void *HPM_realloc(void *p, size_t size, const char *file, int line, const char *func) { return iMalloc->realloc(p,size,HPM_file2ptr(file),line,func); } -void* HPM_reallocz(void *p, size_t size, const char *file, int line, const char *func) +static void *HPM_reallocz(void *p, size_t size, const char *file, int line, const char *func) { return iMalloc->reallocz(p,size,HPM_file2ptr(file),line,func); } -char* HPM_astrdup(const char *p, const char *file, int line, const char *func) +static char *HPM_astrdup(const char *p, const char *file, int line, const char *func) { return iMalloc->astrdup(p,HPM_file2ptr(file),line,func); } @@ -844,7 +845,7 @@ char* HPM_astrdup(const char *p, const char *file, int line, const char *func) * @retval true if a registered plugin was found to handle the entry. * @retval false if no registered plugins could be found. */ -bool hplugins_parse_conf_entry(const char *w1, const char *w2, enum HPluginConfType point) +static bool hplugins_parse_conf_entry(const char *w1, const char *w2, enum HPluginConfType point) { int i; ARR_FIND(0, VECTOR_LENGTH(HPM->config_listeners[point]), i, strcmpi(w1, VECTOR_INDEX(HPM->config_listeners[point], i).key) == 0); @@ -863,7 +864,7 @@ bool hplugins_parse_conf_entry(const char *w1, const char *w2, enum HPluginConfT * @retval true in case of data found * @retval false in case of no data found */ -bool hplugins_get_battle_conf(const char *w1, int *value) +static bool hplugins_get_battle_conf(const char *w1, int *value) { int i; @@ -887,7 +888,7 @@ bool hplugins_get_battle_conf(const char *w1, int *value) * @param imported Whether the current config is imported from another file. * @retval false in case of error. */ -bool hplugins_parse_conf(const struct config_t *config, const char *filename, enum HPluginConfType point, bool imported) +static bool hplugins_parse_conf(const struct config_t *config, const char *filename, enum HPluginConfType point, bool imported) { const struct config_setting_t *setting = NULL; int i, val, type; @@ -940,7 +941,7 @@ bool hplugins_parse_conf(const struct config_t *config, const char *filename, en * @param imported whether the current config is imported from another file. * @retval false in case of error. */ -bool hplugins_parse_battle_conf(const struct config_t *config, const char *filename, bool imported) +static bool hplugins_parse_battle_conf(const struct config_t *config, const char *filename, bool imported) { const struct config_setting_t *setting = NULL; int i, val, type; @@ -985,7 +986,7 @@ bool hplugins_parse_battle_conf(const struct config_t *config, const char *filen * * @param storeptr[in,out] A pointer to the plugin data store. */ -void hplugin_data_store_destroy(struct hplugin_data_store **storeptr) +static void hplugin_data_store_destroy(struct hplugin_data_store **storeptr) { struct hplugin_data_store *store; nullpo_retv(storeptr); @@ -1014,7 +1015,7 @@ void hplugin_data_store_destroy(struct hplugin_data_store **storeptr) * @param storeptr[in,out] A pointer to the data store to initialize. * @param type[in] The store type. */ -void hplugin_data_store_create(struct hplugin_data_store **storeptr, enum HPluginDataTypes type) +static void hplugin_data_store_create(struct hplugin_data_store **storeptr, enum HPluginDataTypes type) { struct hplugin_data_store *store; nullpo_retv(storeptr); @@ -1031,7 +1032,7 @@ void hplugin_data_store_create(struct hplugin_data_store **storeptr, enum HPlugi /** * Called by HPM->DataCheck on a plugins incoming data, ensures data structs in use are matching! **/ -bool HPM_DataCheck(struct s_HPMDataCheck *src, unsigned int size, int version, char *name) +static bool HPM_DataCheck(struct s_HPMDataCheck *src, unsigned int size, int version, char *name) { unsigned int i, j; @@ -1060,7 +1061,7 @@ bool HPM_DataCheck(struct s_HPMDataCheck *src, unsigned int size, int version, c return true; } -void HPM_datacheck_init(const struct s_HPMDataCheck *src, unsigned int length, int version) +static void HPM_datacheck_init(const struct s_HPMDataCheck *src, unsigned int length, int version) { unsigned int i; @@ -1077,12 +1078,12 @@ void HPM_datacheck_init(const struct s_HPMDataCheck *src, unsigned int length, i } } -void HPM_datacheck_final(void) +static void HPM_datacheck_final(void) { db_destroy(datacheck_db); } -void hpm_init(void) +static void hpm_init(void) { int i; datacheck_db = NULL; @@ -1126,7 +1127,7 @@ void hpm_init(void) /** * Releases the retained filenames cache. */ -void hpm_memdown(void) +static void hpm_memdown(void) { /* this memory is handled outside of the server's memory manager and * thus cleared after memory manager goes down */ @@ -1141,7 +1142,7 @@ void hpm_memdown(void) } } -void hpm_final(void) +static void hpm_final(void) { int i; diff --git a/src/common/conf.c b/src/common/conf.c index 841288959..0ad350057 100644 --- a/src/common/conf.c +++ b/src/common/conf.c @@ -29,7 +29,7 @@ #include /* interface source */ -struct libconfig_interface libconfig_s; +static struct libconfig_interface libconfig_s; struct libconfig_interface *libconfig; /** @@ -44,7 +44,7 @@ struct libconfig_interface *libconfig; * @retval CONFIG_TRUE in case of success. * @retval CONFIG_FALSE in case of failure. */ -int config_load_file(struct config_t *config, const char *config_filename) +static int config_load_file(struct config_t *config, const char *config_filename) { libconfig->init(config); if (!exists(config_filename)) { @@ -63,7 +63,7 @@ int config_load_file(struct config_t *config, const char *config_filename) // // Functions to copy settings from libconfig/contrib // -void config_setting_copy_simple(struct config_setting_t *parent, const struct config_setting_t *src) +static void config_setting_copy_simple(struct config_setting_t *parent, const struct config_setting_t *src) { if (config_setting_is_aggregate(src)) { libconfig->setting_copy_aggregate(parent, src); @@ -92,7 +92,7 @@ void config_setting_copy_simple(struct config_setting_t *parent, const struct co } } -void config_setting_copy_elem(struct config_setting_t *parent, const struct config_setting_t *src) +static void config_setting_copy_elem(struct config_setting_t *parent, const struct config_setting_t *src) { struct config_setting_t *set = NULL; @@ -113,7 +113,7 @@ void config_setting_copy_elem(struct config_setting_t *parent, const struct conf } } -void config_setting_copy_aggregate(struct config_setting_t *parent, const struct config_setting_t *src) +static void config_setting_copy_aggregate(struct config_setting_t *parent, const struct config_setting_t *src) { struct config_setting_t *newAgg; int i, n; @@ -137,7 +137,7 @@ void config_setting_copy_aggregate(struct config_setting_t *parent, const struct } } -int config_setting_copy(struct config_setting_t *parent, const struct config_setting_t *src) +static int config_setting_copy(struct config_setting_t *parent, const struct config_setting_t *src) { if (!config_setting_is_group(parent) && !config_setting_is_list(parent)) return CONFIG_FALSE; @@ -158,7 +158,7 @@ int config_setting_copy(struct config_setting_t *parent, const struct config_set * @return The converted value. * @retval false in case of failure. */ -bool config_setting_get_bool_real(const struct config_setting_t *setting) +static bool config_setting_get_bool_real(const struct config_setting_t *setting) { if (setting == NULL || setting->type != CONFIG_TYPE_BOOL) return false; @@ -176,7 +176,7 @@ bool config_setting_get_bool_real(const struct config_setting_t *setting) * @retval CONFIG_TRUE in case of success. * @retval CONFIG_FALSE in case of failure. */ -int config_setting_lookup_bool_real(const struct config_setting_t *setting, const char *name, bool *value) +static int config_setting_lookup_bool_real(const struct config_setting_t *setting, const char *name, bool *value) { struct config_setting_t *member = config_setting_get_member(setting, name); @@ -199,7 +199,7 @@ int config_setting_lookup_bool_real(const struct config_setting_t *setting, cons * @return The converted value. * @retval 0 in case of failure. */ -uint32 config_setting_get_uint32(const struct config_setting_t *setting) +static uint32 config_setting_get_uint32(const struct config_setting_t *setting) { if (setting == NULL || setting->type != CONFIG_TYPE_INT) return 0; @@ -220,7 +220,7 @@ uint32 config_setting_get_uint32(const struct config_setting_t *setting) * @retval CONFIG_TRUE in case of success. * @retval CONFIG_FALSE in case of failure. */ -int config_setting_lookup_uint32(const struct config_setting_t *setting, const char *name, uint32 *value) +static int config_setting_lookup_uint32(const struct config_setting_t *setting, const char *name, uint32 *value) { struct config_setting_t *member = config_setting_get_member(setting, name); @@ -243,7 +243,7 @@ int config_setting_lookup_uint32(const struct config_setting_t *setting, const c * @return The converted value. * @retval 0 in case of failure. */ -uint16 config_setting_get_uint16(const struct config_setting_t *setting) +static uint16 config_setting_get_uint16(const struct config_setting_t *setting) { if (setting == NULL || setting->type != CONFIG_TYPE_INT) return 0; @@ -266,7 +266,7 @@ uint16 config_setting_get_uint16(const struct config_setting_t *setting) * @retval CONFIG_TRUE in case of success. * @retval CONFIG_FALSE in case of failure. */ -int config_setting_lookup_uint16(const struct config_setting_t *setting, const char *name, uint16 *value) +static int config_setting_lookup_uint16(const struct config_setting_t *setting, const char *name, uint16 *value) { struct config_setting_t *member = config_setting_get_member(setting, name); @@ -289,7 +289,7 @@ int config_setting_lookup_uint16(const struct config_setting_t *setting, const c * @return The converted value. * @retval 0 in case of failure. */ -int16 config_setting_get_int16(const struct config_setting_t *setting) +static int16 config_setting_get_int16(const struct config_setting_t *setting) { if (setting == NULL || setting->type != CONFIG_TYPE_INT) return 0; @@ -312,7 +312,7 @@ int16 config_setting_get_int16(const struct config_setting_t *setting) * @retval CONFIG_TRUE in case of success. * @retval CONFIG_FALSE in case of failure. */ -int config_setting_lookup_int16(const struct config_setting_t *setting, const char *name, int16 *value) +static int config_setting_lookup_int16(const struct config_setting_t *setting, const char *name, int16 *value) { struct config_setting_t *member = config_setting_get_member(setting, name); @@ -338,7 +338,7 @@ int config_setting_lookup_int16(const struct config_setting_t *setting, const ch * @retval CONFIG_TRUE in case of success. * @retval CONFIG_FALSE in case of failure. */ -int config_setting_lookup_mutable_string(const struct config_setting_t *setting, const char *name, char *out, size_t out_size) +static int config_setting_lookup_mutable_string(const struct config_setting_t *setting, const char *name, char *out, size_t out_size) { const char *str = NULL; @@ -361,7 +361,7 @@ int config_setting_lookup_mutable_string(const struct config_setting_t *setting, * @retval CONFIG_TRUE in case of success. * @retval CONFIG_FALSE in case of failure. */ -int config_lookup_mutable_string(const struct config_t *config, const char *name, char *out, size_t out_size) +static int config_lookup_mutable_string(const struct config_t *config, const char *name, char *out, size_t out_size) { const char *str = NULL; @@ -378,7 +378,7 @@ int config_lookup_mutable_string(const struct config_t *config, const char *name * * @see config_setting_get_int64_real() */ -int64 config_setting_get_int64_real(const struct config_setting_t *setting) +static int64 config_setting_get_int64_real(const struct config_setting_t *setting) { return (int64)config_setting_get_int64(setting); } @@ -388,7 +388,7 @@ int64 config_setting_get_int64_real(const struct config_setting_t *setting) * * @see config_setting_lookup_int64() */ -int config_setting_lookup_int64_real(const struct config_setting_t *setting, const char *name, int64 *value) +static int config_setting_lookup_int64_real(const struct config_setting_t *setting, const char *name, int64 *value) { long long int lli = 0; @@ -405,7 +405,7 @@ int config_setting_lookup_int64_real(const struct config_setting_t *setting, con * * @see config_setting_set_int64() */ -int config_setting_set_int64_real(struct config_setting_t *setting, int64 value) +static int config_setting_set_int64_real(struct config_setting_t *setting, int64 value) { return config_setting_set_int64(setting, (long long int)value); } @@ -415,7 +415,7 @@ int config_setting_set_int64_real(struct config_setting_t *setting, int64 value) * * @see config_setting_get_int64_elem() */ -int64 config_setting_get_int64_elem_real(const struct config_setting_t *setting, int idx) +static int64 config_setting_get_int64_elem_real(const struct config_setting_t *setting, int idx) { return (int64)config_setting_get_int64_elem(setting, idx); } @@ -425,7 +425,7 @@ int64 config_setting_get_int64_elem_real(const struct config_setting_t *setting, * * @see config_setting_set_int64_elem() */ -struct config_setting_t *config_setting_set_int64_elem_real(struct config_setting_t *setting, int idx, int64 value) +static struct config_setting_t *config_setting_set_int64_elem_real(struct config_setting_t *setting, int idx, int64 value) { return config_setting_set_int64_elem(setting, idx, (long long int)value); } @@ -435,7 +435,7 @@ struct config_setting_t *config_setting_set_int64_elem_real(struct config_settin * * @see config_lookup_int64() */ -int config_lookup_int64_real(const struct config_t *config, const char *filepath, int64 *value) +static int config_lookup_int64_real(const struct config_t *config, const char *filepath, int64 *value) { long long int lli = 0; diff --git a/src/common/console.c b/src/common/console.c index e7edd7e1e..55a9815f5 100644 --- a/src/common/console.c +++ b/src/common/console.c @@ -53,13 +53,13 @@ # endif #endif -struct console_interface console_s; +static struct console_interface console_s; struct console_interface *console; #ifdef CONSOLE_INPUT -struct console_input_interface console_input_s; -struct spin_lock console_ptlock_s; +static struct console_input_interface console_input_s; +static struct spin_lock console_ptlock_s; -struct { +static struct { char queue[CONSOLE_PARSE_SIZE][MAX_CONSOLE_INPUT]; unsigned short count; } cinput; @@ -68,7 +68,7 @@ struct { /*====================================== * CORE : Display title *--------------------------------------*/ -void display_title(void) +static void display_title(void) { const char *vcstype = sysinfo->vcstype(); @@ -98,14 +98,14 @@ void display_title(void) /** * Shows a license notice as per GNU GPL recommendation. */ -void display_gplnotice(void) +static void display_gplnotice(void) { ShowInfo("Hercules, Copyright (C) 2012-2018, Hercules Dev Team and others.\n"); ShowInfo("Licensed under the GNU General Public License, version 3 or later.\n"); } #ifdef CONSOLE_INPUT -int console_parse_key_pressed(void) +static int console_parse_key_pressed(void) { #ifdef WIN32 return _kbhit(); @@ -131,7 +131,7 @@ int console_parse_key_pressed(void) /** * Stops server **/ -CPCMD_C(exit, server) +static CPCMD_C(exit, server) { if (core->shutdown_callback != NULL) core->shutdown_callback(); @@ -142,7 +142,7 @@ CPCMD_C(exit, server) /** * Displays ERS-related statistics (Entry Reusage System) **/ -CPCMD_C(ers_report, server) +static CPCMD_C(ers_report, server) { ers_report(); } @@ -150,7 +150,7 @@ CPCMD_C(ers_report, server) /** * Displays memory usage **/ -CPCMD_C(mem_report, server) +static CPCMD_C(mem_report, server) { #ifdef USE_MEMMGR memmgr_report(line?atoi(line):0); @@ -160,7 +160,7 @@ CPCMD_C(mem_report, server) /** * Displays command list **/ -CPCMD(help) +static CPCMD(help) { int i; for (i = 0; i < VECTOR_LENGTH(console->input->command_list); i++) { @@ -178,7 +178,7 @@ CPCMD(help) * [Ind/Hercules] * Displays current malloc usage */ -CPCMD_C(malloc_usage, server) +static CPCMD_C(malloc_usage, server) { unsigned int val = (unsigned int)iMalloc->usage(); ShowInfo("malloc_usage: %.2f MB\n",(double)(val)/1024); @@ -188,7 +188,7 @@ CPCMD_C(malloc_usage, server) * Skips an sql update * Usage: sql update skip UPDATE-FILE.sql **/ -CPCMD_C(skip, update) +static CPCMD_C(skip, update) { if( !line ) { ShowDebug("usage example: sql update skip 2013-02-14--16-15.sql\n"); @@ -200,7 +200,7 @@ CPCMD_C(skip, update) /** * Loads console commands list **/ -void console_load_defaults(void) +static void console_load_defaults(void) { /** * Defines a main category. @@ -313,7 +313,7 @@ void console_load_defaults(void) * @param name The command name. * @param func The command callback. */ -void console_parse_create(char *name, CParseFunc func) +static void console_parse_create(char *name, CParseFunc func) { int i; char *tok; @@ -370,7 +370,7 @@ void console_parse_create(char *name, CParseFunc func) * @param cmd The command entry. * @param depth The current tree depth (for display purposes). */ -void console_parse_list_subs(struct CParseEntry *cmd, unsigned char depth) +static void console_parse_list_subs(struct CParseEntry *cmd, unsigned char depth) { int i; char msg[CP_CMD_LENGTH * 2]; @@ -394,7 +394,7 @@ void console_parse_list_subs(struct CParseEntry *cmd, unsigned char depth) * * @param line The input line. */ -void console_parse_sub(char *line) +static void console_parse_sub(char *line) { struct CParseEntry *cmd; char bline[200]; @@ -457,7 +457,7 @@ void console_parse_sub(char *line) ShowError("Is only a category, type '"CL_WHITE"%s help"CL_RESET"' to list its subcommands\n",sublist); } -void console_parse(char *line) +static void console_parse(char *line) { int c, i = 0, len = MAX_CONSOLE_INPUT - 1;/* we leave room for the \0 :P */ @@ -474,7 +474,7 @@ void console_parse(char *line) line[i++] = '\0'; } -void *cThread_main(void *x) +static void *cThread_main(void *x) { while( console->input->ptstate ) {/* loopx */ if( console->input->key_pressed() ) { @@ -501,7 +501,7 @@ void *cThread_main(void *x) return NULL; } -int console_parse_timer(int tid, int64 tick, int id, intptr_t data) +static int console_parse_timer(int tid, int64 tick, int id, intptr_t data) { int i; EnterSpinLock(console->input->ptlock); @@ -514,7 +514,7 @@ int console_parse_timer(int tid, int64 tick, int id, intptr_t data) return 0; } -void console_parse_final(void) +static void console_parse_final(void) { if( console->input->ptstate ) { InterlockedDecrement(&console->input->ptstate); @@ -528,7 +528,7 @@ void console_parse_final(void) } } -void console_parse_init(void) +static void console_parse_init(void) { cinput.count = 0; @@ -548,13 +548,13 @@ void console_parse_init(void) timer->add_interval(timer->gettick() + 1000, console->input->parse_timer, 0, 0, 500);/* start listening in 1s; re-try every 0.5s */ } -void console_setSQL(struct Sql *SQL_handle) +static void console_setSQL(struct Sql *SQL_handle) { console->input->SQL = SQL_handle; } #endif /* CONSOLE_INPUT */ -void console_init(void) +static void console_init(void) { #ifdef CONSOLE_INPUT VECTOR_INIT(console->input->command_list); @@ -564,7 +564,7 @@ void console_init(void) #endif } -void console_final(void) +static void console_final(void) { #ifdef CONSOLE_INPUT console->input->parse_final(); diff --git a/src/common/core.c b/src/common/core.c index 406bb7629..9fd33c4e0 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -80,7 +80,7 @@ // And don't complain to us if the XYZ plugin you installed wiped your hard disk, or worse. // Note: This feature is deprecated, and should not be used. -struct core_interface core_s; +static struct core_interface core_s; struct core_interface *core = &core_s; #ifndef MINICORE // minimalist Core @@ -97,7 +97,7 @@ struct core_interface *core = &core_s; #ifndef POSIX #define compat_signal(signo, func) signal((signo), (func)) #else -sigfunc *compat_signal(int signo, sigfunc *func) +static sigfunc *compat_signal(int signo, sigfunc *func) { struct sigaction sact, oact; @@ -180,7 +180,7 @@ static void sig_proc(int sn) } } -void signals_init (void) +static void signals_init(void) { compat_signal(SIGTERM, sig_proc); compat_signal(SIGINT, sig_proc); @@ -203,7 +203,7 @@ void signals_init (void) * * @retval false if the check didn't pass and the program should be terminated. */ -bool usercheck(void) +static bool usercheck(void) { #ifndef _WIN32 if (sysinfo->is_superuser()) { @@ -247,7 +247,7 @@ bool usercheck(void) return true; } -void core_defaults(void) +static void core_defaults(void) { nullpo_defaults(); #ifndef MINICORE @@ -278,7 +278,7 @@ void core_defaults(void) /** * Returns the source (core or plugin name) for the given command-line argument */ -const char *cmdline_arg_source(struct CmdlineArgData *arg) +static const char *cmdline_arg_source(struct CmdlineArgData *arg) { #ifdef MINICORE return "core"; @@ -299,7 +299,7 @@ const char *cmdline_arg_source(struct CmdlineArgData *arg) * @param options options associated to the command-line argument. @see enum cmdline_options. * @return the success status. */ -bool cmdline_arg_add(unsigned int pluginID, const char *name, char shortname, CmdlineExecFunc func, const char *help, unsigned int options) +static bool cmdline_arg_add(unsigned int pluginID, const char *name, char shortname, CmdlineExecFunc func, const char *help, unsigned int options) { struct CmdlineArgData *data = NULL; @@ -363,7 +363,7 @@ static CMDLINEARG(version) * @param argc the program's argc. * @return true if a value for the current argument is available on the command line. */ -bool cmdline_arg_next_value(const char *name, int current_arg, int argc) +static bool cmdline_arg_next_value(const char *name, int current_arg, int argc) { if (current_arg >= argc-1) { ShowError("Missing value for option '%s'.\n", name); @@ -391,7 +391,7 @@ bool cmdline_arg_next_value(const char *name, int current_arg, int argc) * line arguments or handler's failure cause the program to abort. * @return the amount of command line handlers successfully executed. */ -int cmdline_exec(int argc, char **argv, unsigned int options) +static int cmdline_exec(int argc, char **argv, unsigned int options) { int count = 0, i; @@ -444,7 +444,7 @@ int cmdline_exec(int argc, char **argv, unsigned int options) /** * Defines the global command-line arguments. */ -void cmdline_init(void) +static void cmdline_init(void) { #ifdef MINICORE // Minicore has no HPM. This value isn't used, but the arg_add function requires it, so we're (re)defining it here @@ -458,7 +458,7 @@ void cmdline_init(void) cmdline_args_init_local(); } -void cmdline_final(void) +static void cmdline_final(void) { while (VECTOR_LENGTH(cmdline->args_data) > 0) { struct CmdlineArgData *data = &VECTOR_POP(cmdline->args_data); @@ -468,7 +468,7 @@ void cmdline_final(void) VECTOR_CLEAR(cmdline->args_data); } -struct cmdline_interface cmdline_s; +static struct cmdline_interface cmdline_s; struct cmdline_interface *cmdline; void cmdline_defaults(void) @@ -488,7 +488,7 @@ void cmdline_defaults(void) /*====================================== * CORE : MAINROUTINE *--------------------------------------*/ -int main (int argc, char **argv) +int main(int argc, char **argv) { int retval = EXIT_SUCCESS; {// initialize program arguments diff --git a/src/common/db.c b/src/common/db.c index 1ad715f25..c28ad1f7c 100644 --- a/src/common/db.c +++ b/src/common/db.c @@ -100,7 +100,7 @@ #include #include -struct db_interface DB_s; +static struct db_interface DB_s; struct db_interface *DB; /***************************************************************************** @@ -358,8 +358,8 @@ static struct db_stats { #endif /* !defined(DB_ENABLE_STATS) */ /* [Ind/Hercules] */ -struct eri *db_iterator_ers; -struct eri *db_alloc_ers; +static struct eri *db_iterator_ers; +static struct eri *db_alloc_ers; /*****************************************************************************\ * (2) Section of private functions used by the database system. * @@ -1250,7 +1250,7 @@ static void db_release_both(union DBKey key, struct DBData data, enum DBReleaseO * @protected * @see struct DBIterator#first() */ -struct DBData *dbit_obj_first(struct DBIterator *self, union DBKey *out_key) +static struct DBData *dbit_obj_first(struct DBIterator *self, union DBKey *out_key) { struct DBIterator_impl *it = (struct DBIterator_impl *)self; @@ -1272,7 +1272,7 @@ struct DBData *dbit_obj_first(struct DBIterator *self, union DBKey *out_key) * @protected * @see struct DBIterator#last() */ -struct DBData *dbit_obj_last(struct DBIterator *self, union DBKey *out_key) +static struct DBData *dbit_obj_last(struct DBIterator *self, union DBKey *out_key) { struct DBIterator_impl *it = (struct DBIterator_impl *)self; @@ -1294,7 +1294,7 @@ struct DBData *dbit_obj_last(struct DBIterator *self, union DBKey *out_key) * @protected * @see struct DBIterator#next() */ -struct DBData *dbit_obj_next(struct DBIterator *self, union DBKey *out_key) +static struct DBData *dbit_obj_next(struct DBIterator *self, union DBKey *out_key) { struct DBIterator_impl *it = (struct DBIterator_impl *)self; struct DBNode *node; @@ -1370,7 +1370,7 @@ struct DBData *dbit_obj_next(struct DBIterator *self, union DBKey *out_key) * @protected * @see struct DBIterator#prev() */ -struct DBData *dbit_obj_prev(struct DBIterator *self, union DBKey *out_key) +static struct DBData *dbit_obj_prev(struct DBIterator *self, union DBKey *out_key) { struct DBIterator_impl *it = (struct DBIterator_impl *)self; struct DBNode *node; @@ -1445,7 +1445,7 @@ struct DBData *dbit_obj_prev(struct DBIterator *self, union DBKey *out_key) * @protected * @see struct DBIterator#exists() */ -bool dbit_obj_exists(struct DBIterator *self) +static bool dbit_obj_exists(struct DBIterator *self) { struct DBIterator_impl *it = (struct DBIterator_impl *)self; @@ -1467,7 +1467,7 @@ bool dbit_obj_exists(struct DBIterator *self) * @see struct DBMap#remove() * @see struct DBIterator#remove() */ -int dbit_obj_remove(struct DBIterator *self, struct DBData *out_data) +static int dbit_obj_remove(struct DBIterator *self, struct DBData *out_data) { struct DBIterator_impl *it = (struct DBIterator_impl *)self; struct DBNode *node; @@ -1494,7 +1494,7 @@ int dbit_obj_remove(struct DBIterator *self, struct DBData *out_data) * @param self Iterator * @protected */ -void dbit_obj_destroy(struct DBIterator *self) +static void dbit_obj_destroy(struct DBIterator *self) { struct DBIterator_impl *it = (struct DBIterator_impl *)self; @@ -2407,7 +2407,7 @@ static enum DBOptions db_obj_options(struct DBMap *self) * @see #db_default_release() * @see #db_alloc() */ -enum DBOptions db_fix_options(enum DBType type, enum DBOptions options) +static enum DBOptions db_fix_options(enum DBType type, enum DBOptions options) { DB_COUNTSTAT(db_fix_options); switch (type) { @@ -2438,7 +2438,7 @@ enum DBOptions db_fix_options(enum DBType type, enum DBOptions options) * @see #db_int64_cmp() * @see #db_uint64_cmp() */ -DBComparator db_default_cmp(enum DBType type) +static DBComparator db_default_cmp(enum DBType type) { DB_COUNTSTAT(db_default_cmp); switch (type) { @@ -2466,7 +2466,7 @@ DBComparator db_default_cmp(enum DBType type) * @see #db_int64_hash() * @see #db_uint64_hash() */ -DBHasher db_default_hash(enum DBType type) +static DBHasher db_default_hash(enum DBType type) { DB_COUNTSTAT(db_default_hash); switch (type) { @@ -2499,7 +2499,7 @@ DBHasher db_default_hash(enum DBType type) * @see #db_release_both() * @see #db_custom_release() */ -DBReleaser db_default_release(enum DBType type, enum DBOptions options) +static DBReleaser db_default_release(enum DBType type, enum DBOptions options) { DB_COUNTSTAT(db_default_release); options = DB->fix_options(type, options); @@ -2524,7 +2524,7 @@ DBReleaser db_default_release(enum DBType type, enum DBOptions options) * @see #db_release_both() * @see #db_default_release() */ -DBReleaser db_custom_release(enum DBReleaseOption which) +static DBReleaser db_custom_release(enum DBReleaseOption which) { DB_COUNTSTAT(db_custom_release); switch (which) { @@ -2555,7 +2555,7 @@ DBReleaser db_custom_release(enum DBReleaseOption which) * @see struct DBMap_impl * @see #db_fix_options() */ -struct DBMap *db_alloc(const char *file, const char *func, int line, enum DBType type, enum DBOptions options, unsigned short maxlen) +static struct DBMap *db_alloc(const char *file, const char *func, int line, enum DBType type, enum DBOptions options, unsigned short maxlen) { struct DBMap_impl *db; unsigned int i; @@ -2629,7 +2629,7 @@ struct DBMap *db_alloc(const char *file, const char *func, int line, enum DBType * @return The key as a DBKey union * @public */ -union DBKey db_i2key(int key) +static union DBKey db_i2key(int key) { union DBKey ret; @@ -2644,7 +2644,7 @@ union DBKey db_i2key(int key) * @return The key as a DBKey union * @public */ -union DBKey db_ui2key(unsigned int key) +static union DBKey db_ui2key(unsigned int key) { union DBKey ret; @@ -2659,7 +2659,7 @@ union DBKey db_ui2key(unsigned int key) * @return The key as a DBKey union * @public */ -union DBKey db_str2key(const char *key) +static union DBKey db_str2key(const char *key) { union DBKey ret; @@ -2674,7 +2674,7 @@ union DBKey db_str2key(const char *key) * @return The key as a DBKey union * @public */ -union DBKey db_i642key(int64 key) +static union DBKey db_i642key(int64 key) { union DBKey ret; @@ -2689,7 +2689,7 @@ union DBKey db_i642key(int64 key) * @return The key as a DBKey union * @public */ -union DBKey db_ui642key(uint64 key) +static union DBKey db_ui642key(uint64 key) { union DBKey ret; @@ -2704,7 +2704,7 @@ union DBKey db_ui642key(uint64 key) * @return The data as a DBData struct * @public */ -struct DBData db_i2data(int data) +static struct DBData db_i2data(int data) { struct DBData ret; @@ -2720,7 +2720,7 @@ struct DBData db_i2data(int data) * @return The data as a DBData struct * @public */ -struct DBData db_ui2data(unsigned int data) +static struct DBData db_ui2data(unsigned int data) { struct DBData ret; @@ -2736,7 +2736,7 @@ struct DBData db_ui2data(unsigned int data) * @return The data as a DBData struct * @public */ -struct DBData db_ptr2data(void *data) +static struct DBData db_ptr2data(void *data) { struct DBData ret; @@ -2753,7 +2753,7 @@ struct DBData db_ptr2data(void *data) * @return Integer value of the data. * @public */ -int db_data2i(struct DBData *data) +static int db_data2i(struct DBData *data) { DB_COUNTSTAT(db_data2i); if (data && DB_DATA_INT == data->type) @@ -2768,7 +2768,7 @@ int db_data2i(struct DBData *data) * @return Unsigned int value of the data. * @public */ -unsigned int db_data2ui(struct DBData *data) +static unsigned int db_data2ui(struct DBData *data) { DB_COUNTSTAT(db_data2ui); if (data && DB_DATA_UINT == data->type) @@ -2783,7 +2783,7 @@ unsigned int db_data2ui(struct DBData *data) * @return Void* value of the data. * @public */ -void *db_data2ptr(struct DBData *data) +static void *db_data2ptr(struct DBData *data) { DB_COUNTSTAT(db_data2ptr); if (data && DB_DATA_PTR == data->type) @@ -2796,7 +2796,7 @@ void *db_data2ptr(struct DBData *data) * @public * @see #db_final(void) */ -void db_init(void) +static void db_init(void) { db_iterator_ers = ers_new(sizeof(struct DBIterator_impl),"db.c::db_iterator_ers",ERS_OPT_CLEAN|ERS_OPT_FLEX_CHUNK); db_alloc_ers = ers_new(sizeof(struct DBMap_impl),"db.c::db_alloc_ers",ERS_OPT_CLEAN|ERS_OPT_FLEX_CHUNK); @@ -2810,7 +2810,7 @@ void db_init(void) * @public * @see #db_init(void) */ -void db_final(void) +static void db_final(void) { #ifdef DB_ENABLE_STATS DB_COUNTSTAT(db_final); diff --git a/src/common/des.c b/src/common/des.c index 2223f4744..fbd158265 100644 --- a/src/common/des.c +++ b/src/common/des.c @@ -29,7 +29,7 @@ * Implementation of the des interface. */ -struct des_interface des_s; +static struct des_interface des_s; struct des_interface *des; /// Bitmask for accessing individual bits of a byte. @@ -228,7 +228,7 @@ static void des_RoundFunction(struct des_bit64 *src) } /// @copydoc des_interface::decrypt_block() -void des_decrypt_block(struct des_bit64 *block) +static void des_decrypt_block(struct des_bit64 *block) { des_IP(block); des_RoundFunction(block); @@ -236,7 +236,7 @@ void des_decrypt_block(struct des_bit64 *block) } /// @copydoc des_interface::decrypt() -void des_decrypt(unsigned char *data, size_t size) +static void des_decrypt(unsigned char *data, size_t size) { struct des_bit64 *p = (struct des_bit64 *)data; size_t i; diff --git a/src/common/ers.c b/src/common/ers.c index da793db99..e421c47c9 100644 --- a/src/common/ers.c +++ b/src/common/ers.c @@ -309,7 +309,7 @@ static void ers_obj_destroy(ERS *self) aFree(instance); } -void ers_cache_size(ERS *self, unsigned int new_size) +static void ers_cache_size(ERS *self, unsigned int new_size) { struct ers_instance_t *instance = (struct ers_instance_t *)self; diff --git a/src/common/grfio.c b/src/common/grfio.c index ba8a1d161..79154d191 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -68,19 +68,19 @@ enum grf_filelist_type { //#define GRFIO_LOCAL // stores info about every loaded file -struct grf_filelist *filelist = NULL; -int filelist_entrys = 0; -int filelist_maxentry = 0; +static struct grf_filelist *filelist = NULL; +static int filelist_entrys = 0; +static int filelist_maxentry = 0; // stores grf file names -char** gentry_table = NULL; -int gentry_entrys = 0; -int gentry_maxentry = 0; +static char** gentry_table = NULL; +static int gentry_entrys = 0; +static int gentry_maxentry = 0; // the path to the data directory -char data_dir[1024] = ""; +static char data_dir[1024] = ""; -struct grfio_interface grfio_s; +static struct grfio_interface grfio_s; struct grfio_interface *grfio; // little endian char array to uint conversion @@ -273,19 +273,19 @@ static void grf_decode(unsigned char *buf, size_t len, char entry_type, int entr /* Zlib Subroutines */ /// @copydoc grfio_interface::crc32() -unsigned long grfio_crc32(const unsigned char *buf, unsigned int len) +static unsigned long grfio_crc32(const unsigned char *buf, unsigned int len) { return crc32(crc32(0L, Z_NULL, 0), buf, len); } /// @copydoc grfio_interface::decode_zip -int grfio_decode_zip(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len) +static int grfio_decode_zip(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len) { return uncompress(dest, dest_len, source, source_len); } /// @copydoc grfio_interface::encode_zip -int grfio_encode_zip(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len) +static int grfio_encode_zip(void *dest, unsigned long *dest_len, const void *source, unsigned long source_len) { if (*dest_len == 0) /* [Ind/Hercules] */ *dest_len = compressBound(source_len); @@ -299,7 +299,7 @@ int grfio_encode_zip(void *dest, unsigned long *dest_len, const void *source, un /* File List Subroutines */ /// File list hash table -int filelist_hash[256]; +static int filelist_hash[256]; /** * Initializes the table that holds the first elements of all hash chains @@ -351,7 +351,7 @@ static struct grf_filelist *grfio_filelist_find(const char *fname) } /// @copydoc grfio_interface::find_file() -const char *grfio_find_file(const char *fname) +static const char *grfio_find_file(const char *fname) { struct grf_filelist *flist = grfio_filelist_find(fname); if (flist == NULL) @@ -458,7 +458,7 @@ static void grfio_localpath_create(char *buffer, size_t size, const char *filena } /// @copydoc grfio_interface::reads() -void *grfio_reads(const char *fname, int *size) +static void *grfio_reads(const char *fname, int *size) { struct grf_filelist *entry = grfio_filelist_find(fname); if (entry == NULL || entry->gentry <= 0) { @@ -885,7 +885,7 @@ static int grfio_add(const char *fname) } /// @copydoc grfio_interface::final() -void grfio_final(void) +static void grfio_final(void) { if (filelist != NULL) { int i; @@ -911,7 +911,7 @@ void grfio_final(void) } /// @copydoc grfio_interface::init() -void grfio_init(const char *fname) +static void grfio_init(const char *fname) { FILE *data_conf; int grf_num = 0; diff --git a/src/common/mapindex.c b/src/common/mapindex.c index e79054f72..d5cda5c22 100644 --- a/src/common/mapindex.c +++ b/src/common/mapindex.c @@ -33,12 +33,12 @@ #include /* mapindex.c interface source */ -struct mapindex_interface mapindex_s; +static struct mapindex_interface mapindex_s; struct mapindex_interface *mapindex; /// Retrieves the map name from 'string' (removing .gat extension if present). /// Result gets placed either into 'buf' or in a static local buffer. -const char* mapindex_getmapname(const char* string, char* output) +static const char *mapindex_getmapname(const char *string, char *output) { static char buf[MAP_NAME_LENGTH]; char* dest = (output != NULL) ? output : buf; @@ -62,7 +62,7 @@ const char* mapindex_getmapname(const char* string, char* output) /// Retrieves the map name from 'string' (adding .gat extension if not already present). /// Result gets placed either into 'buf' or in a static local buffer. -const char* mapindex_getmapname_ext(const char* string, char* output) +static const char *mapindex_getmapname_ext(const char *string, char *output) { static char buf[MAP_NAME_LENGTH_EXT]; char* dest = (output != NULL) ? output : buf; @@ -94,7 +94,7 @@ const char* mapindex_getmapname_ext(const char* string, char* output) /// Adds a map to the specified index /// Returns 1 if successful, 0 otherwise -int mapindex_addmap(int index, const char* name) +static int mapindex_addmap(int index, const char *name) { char map_name[MAP_NAME_LENGTH]; @@ -136,7 +136,7 @@ int mapindex_addmap(int index, const char* name) return index; } -unsigned short mapindex_name2id(const char* name) +static unsigned short mapindex_name2id(const char *name) { int i; char map_name[MAP_NAME_LENGTH]; @@ -150,7 +150,7 @@ unsigned short mapindex_name2id(const char* name) return 0; } -const char *mapindex_id2name_sub(uint16 id, const char *file, int line, const char *func) +static const char *mapindex_id2name_sub(uint16 id, const char *file, int line, const char *func) { if (id >= MAX_MAPINDEX || !mapindex_exists(id)) { ShowDebug("mapindex_id2name: Requested name for non-existant map index [%d] in cache. %s:%s:%d\n", id,file,func,line); @@ -159,7 +159,7 @@ const char *mapindex_id2name_sub(uint16 id, const char *file, int line, const ch return mapindex->list[id].name; } -int mapindex_init(void) +static int mapindex_init(void) { FILE *fp; char line[1024]; @@ -198,7 +198,7 @@ int mapindex_init(void) return total; } -bool mapindex_check_default(void) +static bool mapindex_check_default(void) { if (!strdb_iget(mapindex->db, mapindex->default_map)) { ShowError("mapindex_init: MAP_DEFAULT '%s' not found in cache! update mapindex.h MAP_DEFAULT var!!!\n", mapindex->default_map); @@ -207,14 +207,14 @@ bool mapindex_check_default(void) return true; } -void mapindex_removemap(int index) +static void mapindex_removemap(int index) { Assert_retv(index < MAX_MAPINDEX); strdb_remove(mapindex->db, mapindex->list[index].name); mapindex->list[index].name[0] = '\0'; } -void mapindex_final(void) +static void mapindex_final(void) { db_destroy(mapindex->db); } diff --git a/src/common/md5calc.c b/src/common/md5calc.c index 9784bd7b8..3f9ccdc41 100644 --- a/src/common/md5calc.c +++ b/src/common/md5calc.c @@ -34,7 +34,7 @@ * Implementation of the md5 interface. */ -struct md5_interface md5_s; +static struct md5_interface md5_s; struct md5_interface *md5; /// Global variable @@ -233,7 +233,7 @@ static void md5_buf2binary(const uint8 *buf, const int buf_size, uint8 *output) } /// @copydoc md5_interface::string() -void md5_string(const char *string, char *output) +static void md5_string(const char *string, char *output) { uint8 digest[16]; @@ -249,7 +249,7 @@ void md5_string(const char *string, char *output) } /// @copydoc md5_interface::salt(); -void md5_salt(int len, char *output) +static void md5_salt(int len, char *output) { int i; Assert_retv(len > 0); diff --git a/src/common/memmgr.c b/src/common/memmgr.c index 3c9cca6a6..3c645e7fa 100644 --- a/src/common/memmgr.c +++ b/src/common/memmgr.c @@ -31,7 +31,7 @@ #include #include -struct malloc_interface iMalloc_s; +static struct malloc_interface iMalloc_s; struct malloc_interface *iMalloc; ////////////// Memory Libraries ////////////////// @@ -113,7 +113,7 @@ struct malloc_interface *iMalloc; #error Unsupported OS #endif -void* aMalloc_(size_t size, const char *file, int line, const char *func) +static void *aMalloc_(size_t size, const char *file, int line, const char *func) { void *ret = MALLOC(size, file, line, func); // ShowMessage("%s:%d: in func %s: aMalloc %d\n",file,line,func,size); @@ -124,7 +124,7 @@ void* aMalloc_(size_t size, const char *file, int line, const char *func) return ret; } -void* aCalloc_(size_t num, size_t size, const char *file, int line, const char *func) +static void *aCalloc_(size_t num, size_t size, const char *file, int line, const char *func) { void *ret = CALLOC(num, size, file, line, func); // ShowMessage("%s:%d: in func %s: aCalloc %d %d\n",file,line,func,num,size); @@ -134,7 +134,7 @@ void* aCalloc_(size_t num, size_t size, const char *file, int line, const char * } return ret; } -void* aRealloc_(void *p, size_t size, const char *file, int line, const char *func) +static void *aRealloc_(void *p, size_t size, const char *file, int line, const char *func) { void *ret = REALLOC(p, size, file, line, func); // ShowMessage("%s:%d: in func %s: aRealloc %p %d\n",file,line,func,p,size); @@ -145,7 +145,7 @@ void* aRealloc_(void *p, size_t size, const char *file, int line, const char *fu return ret; } -void* aReallocz_(void *p, size_t size, const char *file, int line, const char *func) +static void *aReallocz_(void *p, size_t size, const char *file, int line, const char *func) { unsigned char *ret = NULL; // ShowMessage("%s:%d: in func %s: aReallocz %p %ld\n",file,line,func,p,size); @@ -168,7 +168,7 @@ void* aReallocz_(void *p, size_t size, const char *file, int line, const char *f return ret; } -char* aStrdup_(const char *p, const char *file, int line, const char *func) +static char *aStrdup_(const char *p, const char *file, int line, const char *func) { char *ret = STRDUP(p, file, line, func); // ShowMessage("%s:%d: in func %s: aStrdup %p\n",file,line,func,p); @@ -195,7 +195,7 @@ char* aStrdup_(const char *p, const char *file, int line, const char *func) * @param func @see ALC_MARK. * @return the copied string. */ -char *aStrndup_(const char *p, size_t size, const char *file, int line, const char *func) +static char *aStrndup_(const char *p, size_t size, const char *file, int line, const char *func) { size_t len = strnlen(p, size); char *ret = MALLOC(len + 1, file, line, func); @@ -208,7 +208,7 @@ char *aStrndup_(const char *p, size_t size, const char *file, int line, const ch return ret; } -void aFree_(void *p, const char *file, int line, const char *func) +static void aFree_(void *p, const char *file, int line, const char *func) { // ShowMessage("%s:%d: in func %s: aFree %p\n",file,line,func,p); if (p) @@ -279,8 +279,8 @@ struct unit_head { long checksum; }; -static struct block* hash_unfill[BLOCK_DATA_COUNT1 + BLOCK_DATA_COUNT2 + 1]; -static struct block* block_first, *block_last, block_head; +static struct block *hash_unfill[BLOCK_DATA_COUNT1 + BLOCK_DATA_COUNT2 + 1]; +static struct block *block_first, *block_last, block_head; /* Data for areas that do not use the memory be turned */ struct unit_head_large { @@ -292,8 +292,8 @@ struct unit_head_large { static struct unit_head_large *unit_head_large_first = NULL; -static struct block* block_malloc(unsigned short hash); -static void block_free(struct block* p); +static struct block *block_malloc(unsigned short hash); +static void block_free(struct block *p); static size_t memmgr_usage_bytes; static size_t memmgr_usage_bytes_t; @@ -301,7 +301,7 @@ static size_t memmgr_usage_bytes_t; #define block2unit(p, n) ((struct unit_head*)(&(p)->data[ p->unit_size * (n) ])) #define memmgr_assert(v) do { if(!(v)) { ShowError("Memory manager: assertion '" #v "' failed!\n"); } } while(0) -static unsigned short size2hash( size_t size ) +static unsigned short size2hash(size_t size) { if( size <= BLOCK_DATA_SIZE1 ) { return (unsigned short)(size + BLOCK_ALIGNMENT1 - 1) / BLOCK_ALIGNMENT1; @@ -313,7 +313,7 @@ static unsigned short size2hash( size_t size ) } } -static size_t hash2size( unsigned short hash ) +static size_t hash2size(unsigned short hash) { if( hash <= BLOCK_DATA_COUNT1) { return hash * BLOCK_ALIGNMENT1; @@ -322,7 +322,8 @@ static size_t hash2size( unsigned short hash ) } } -void *mmalloc_(size_t size, const char *file, int line, const char *func) { +static void *mmalloc_(size_t size, const char *file, int line, const char *func) +{ struct block *block; short size_hash = size2hash( size ); struct unit_head *head; @@ -428,14 +429,16 @@ void *mmalloc_(size_t size, const char *file, int line, const char *func) { return (char *)head + sizeof(struct unit_head) - sizeof(long); } -void *mcalloc_(size_t num, size_t size, const char *file, int line, const char *func) { +static void *mcalloc_(size_t num, size_t size, const char *file, int line, const char *func) +{ void *p = iMalloc->malloc(num * size,file,line,func); if (p) memset(p, 0, num * size); return p; } -void *mrealloc_(void *memblock, size_t size, const char *file, int line, const char *func) { +static void *mrealloc_(void *memblock, size_t size, const char *file, int line, const char *func) +{ size_t old_size; if(memblock == NULL) { return iMalloc->malloc(size,file,line,func); @@ -460,7 +463,8 @@ void *mrealloc_(void *memblock, size_t size, const char *file, int line, const c } /* a mrealloc_ clone with the difference it 'z'eroes the newly created memory */ -void *mreallocz_(void *memblock, size_t size, const char *file, int line, const char *func) { +static void *mreallocz_(void *memblock, size_t size, const char *file, int line, const char *func) +{ size_t old_size; void *p = NULL; @@ -490,7 +494,8 @@ void *mreallocz_(void *memblock, size_t size, const char *file, int line, const } -char *mstrdup_(const char *p, const char *file, int line, const char *func) { +static char *mstrdup_(const char *p, const char *file, int line, const char *func) +{ if(p == NULL) { return NULL; } else { @@ -518,7 +523,7 @@ char *mstrdup_(const char *p, const char *file, int line, const char *func) { * @return the copied string. * @retval NULL if the source string is NULL or in case of error. */ -char *mstrndup_(const char *p, size_t size, const char *file, int line, const char *func) +static char *mstrndup_(const char *p, size_t size, const char *file, int line, const char *func) { if (p == NULL) { return NULL; @@ -532,7 +537,8 @@ char *mstrndup_(const char *p, size_t size, const char *file, int line, const ch } -void mfree_(void *ptr, const char *file, int line, const char *func) { +static void mfree_(void *ptr, const char *file, int line, const char *func) +{ struct unit_head *head; if (ptr == NULL) @@ -604,7 +610,7 @@ void mfree_(void *ptr, const char *file, int line, const char *func) { } /* Allocating blocks */ -static struct block* block_malloc(unsigned short hash) +static struct block *block_malloc(unsigned short hash) { struct block *p; if(hash_unfill[0] != NULL) { @@ -661,7 +667,7 @@ static struct block* block_malloc(unsigned short hash) return p; } -static void block_free(struct block* p) +static void block_free(struct block *p) { if( p->unfill_prev ) { if( p->unfill_prev == &block_head) { @@ -679,7 +685,7 @@ static void block_free(struct block* p) hash_unfill[0] = p; } -size_t memmgr_usage (void) +static size_t memmgr_usage(void) { return memmgr_usage_bytes / 1024; } @@ -688,7 +694,8 @@ size_t memmgr_usage (void) static char memmer_logfile[128]; static FILE *log_fp; -static void memmgr_log(char *buf, char *vcsinfo) { +static void memmgr_log(char *buf, char *vcsinfo) +{ if( !log_fp ) { time_t raw; struct tm* t; @@ -711,7 +718,7 @@ static void memmgr_log(char *buf, char *vcsinfo) { /// /// @param ptr Pointer to the memory /// @return true if the memory is active -bool memmgr_verify(void* ptr) +static bool memmgr_verify(void *ptr) { struct block* block = block_first; struct unit_head_large* large = unit_head_large_first; @@ -752,7 +759,7 @@ bool memmgr_verify(void* ptr) return false; } -static void memmgr_final (void) +static void memmgr_final(void) { struct block *block = block_first; struct unit_head_large *large = unit_head_large_first; @@ -808,7 +815,8 @@ static void memmgr_final (void) #endif /* LOG_MEMMGR */ } /* [Ind/Hercules] */ -void memmgr_report (int extra) { +void memmgr_report(int extra) +{ struct block *block = block_first; struct unit_head_large *large = unit_head_large_first; unsigned int count = 0, size = 0; @@ -918,7 +926,7 @@ static void memmgr_init_messages(void) /// Tests the memory for errors and memory leaks. -void malloc_memory_check(void) +static void malloc_memory_check(void) { MEMORY_CHECK(); } @@ -926,7 +934,8 @@ void malloc_memory_check(void) /// Returns true if a pointer is valid. /// The check is best-effort, false positives are possible. -bool malloc_verify_ptr(void* ptr) { +static bool malloc_verify_ptr(void *ptr) +{ #ifdef USE_MEMMGR return memmgr_verify(ptr) && MEMORY_VERIFY(ptr); #else @@ -935,7 +944,8 @@ bool malloc_verify_ptr(void* ptr) { } -size_t malloc_usage (void) { +static size_t malloc_usage(void) +{ #ifdef USE_MEMMGR return memmgr_usage (); #else @@ -943,7 +953,8 @@ size_t malloc_usage (void) { #endif } -void malloc_final (void) { +static void malloc_final(void) +{ #ifdef USE_MEMMGR memmgr_final (); #endif @@ -959,14 +970,14 @@ void malloc_final (void) { * chance to other modules to initialize, in case they want to silence any * status messages, but at the same time require malloc. */ -void malloc_init_messages(void) +static void malloc_init_messages(void) { #ifdef USE_MEMMGR memmgr_init_messages(); #endif } -void malloc_init(void) +static void malloc_init(void) { #ifdef USE_MEMMGR memmgr_usage_bytes_t = 0; @@ -986,7 +997,8 @@ void malloc_init(void) #endif } -void malloc_defaults(void) { +void malloc_defaults(void) +{ iMalloc = &iMalloc_s; iMalloc->init = malloc_init; iMalloc->final = malloc_final; diff --git a/src/common/mutex.c b/src/common/mutex.c index fab1c45c0..dd63d2adc 100644 --- a/src/common/mutex.c +++ b/src/common/mutex.c @@ -39,7 +39,7 @@ * Implementation of the mutex interface. */ -struct mutex_interface mutex_s; +static struct mutex_interface mutex_s; struct mutex_interface *mutex; struct mutex_data { @@ -65,7 +65,7 @@ struct cond_data { /* Mutex */ /// @copydoc mutex_interface::create() -struct mutex_data *mutex_create(void) +static struct mutex_data *mutex_create(void) { struct mutex_data *m = aMalloc(sizeof(struct mutex_data)); if (m == NULL) { @@ -83,7 +83,7 @@ struct mutex_data *mutex_create(void) } /// @copydoc mutex_interface::destroy() -void mutex_destroy(struct mutex_data *m) +static void mutex_destroy(struct mutex_data *m) { nullpo_retv(m); #ifdef WIN32 @@ -96,7 +96,7 @@ void mutex_destroy(struct mutex_data *m) } /// @copydoc mutex_interface::lock() -void mutex_lock(struct mutex_data *m) +static void mutex_lock(struct mutex_data *m) { nullpo_retv(m); #ifdef WIN32 @@ -107,7 +107,7 @@ void mutex_lock(struct mutex_data *m) } /// @copydoc mutex_interface::trylock() -bool mutex_trylock(struct mutex_data *m) +static bool mutex_trylock(struct mutex_data *m) { nullpo_retr(false, m); #ifdef WIN32 @@ -121,7 +121,7 @@ bool mutex_trylock(struct mutex_data *m) } /// @copydoc mutex_interface::unlock() -void mutex_unlock(struct mutex_data *m) +static void mutex_unlock(struct mutex_data *m) { nullpo_retv(m); #ifdef WIN32 @@ -134,7 +134,7 @@ void mutex_unlock(struct mutex_data *m) /* Conditional variable */ /// @copydoc mutex_interface::cond_create() -struct cond_data *cond_create(void) +static struct cond_data *cond_create(void) { struct cond_data *c = aMalloc(sizeof(struct cond_data)); if (c == NULL) { @@ -155,7 +155,7 @@ struct cond_data *cond_create(void) } /// @copydoc mutex_interface::cond_destroy() -void cond_destroy(struct cond_data *c) +static void cond_destroy(struct cond_data *c) { nullpo_retv(c); #ifdef WIN32 @@ -170,7 +170,7 @@ void cond_destroy(struct cond_data *c) } /// @copydoc mutex_interface::cond_wait() -void cond_wait(struct cond_data *c, struct mutex_data *m, sysint timeout_ticks) +static void cond_wait(struct cond_data *c, struct mutex_data *m, sysint timeout_ticks) { #ifdef WIN32 register DWORD ms; @@ -224,7 +224,7 @@ void cond_wait(struct cond_data *c, struct mutex_data *m, sysint timeout_ticks) } /// @copydoc mutex_interface::cond_signal() -void cond_signal(struct cond_data *c) +static void cond_signal(struct cond_data *c) { #ifdef WIN32 # if 0 @@ -245,7 +245,7 @@ void cond_signal(struct cond_data *c) } /// @copydoc mutex_interface::cond_broadcast() -void cond_broadcast(struct cond_data *c) +static void cond_broadcast(struct cond_data *c) { #ifdef WIN32 # if 0 diff --git a/src/common/nullpo.c b/src/common/nullpo.c index 1441ff853..e19f7f846 100644 --- a/src/common/nullpo.c +++ b/src/common/nullpo.c @@ -32,7 +32,7 @@ #include #endif // HAVE_EXECINFO -struct nullpo_interface nullpo_s; +static struct nullpo_interface nullpo_s; struct nullpo_interface *nullpo; /** @@ -44,7 +44,8 @@ struct nullpo_interface *nullpo; * @param targetname Name of the checked symbol * @param title Message title to display (i.e. failed assertion or nullpo info) */ -void assert_report(const char *file, int line, const char *func, const char *targetname, const char *title) { +static void assert_report(const char *file, int line, const char *func, const char *targetname, const char *title) +{ #ifdef HAVE_EXECINFO void *array[10]; int size; @@ -72,7 +73,8 @@ void assert_report(const char *file, int line, const char *func, const char *tar /** * **/ -void nullpo_defaults(void) { +void nullpo_defaults(void) +{ nullpo = &nullpo_s; nullpo->assert_report = assert_report; } diff --git a/src/common/random.c b/src/common/random.c index 6fbaba91c..9bbe4f86c 100644 --- a/src/common/random.c +++ b/src/common/random.c @@ -40,11 +40,11 @@ * Implementation of the random number generator interface. */ -struct rnd_interface rnd_s; +static struct rnd_interface rnd_s; struct rnd_interface *rnd; /// @copydoc rnd_interface::init() -void rnd_init(void) +static void rnd_init(void) { unsigned long seed = (unsigned long)timer->gettick(); seed += (unsigned long)time(NULL); @@ -66,30 +66,30 @@ void rnd_init(void) } /// @copydoc rnd_interface::final() -void rnd_final(void) +static void rnd_final(void) { } /// @copydoc rnd_interface::seed() -void rnd_seed(uint32 seed) +static void rnd_seed(uint32 seed) { init_genrand(seed); } /// @copydoc rnd_interface::random() -int32 rnd_random(void) +static int32 rnd_random(void) { return (int32)genrand_int31(); } /// @copydoc rnd_interface::roll() -uint32 rnd_roll(uint32 dice_faces) +static uint32 rnd_roll(uint32 dice_faces) { return (uint32)(rnd->uniform()*dice_faces); } /// @copydoc rnd_interface::value() -int32 rnd_value(int32 min, int32 max) +static int32 rnd_value(int32 min, int32 max) { if (min >= max) return min; @@ -97,13 +97,13 @@ int32 rnd_value(int32 min, int32 max) } /// @copydoc rnd_interface::uniform() -double rnd_uniform(void) +static double rnd_uniform(void) { return ((uint32)genrand_int32())*(1.0/4294967296.0);// divided by 2^32 } /// @copydoc rnd_interface::uniform53() -double rnd_uniform53(void) +static double rnd_uniform53(void) { return genrand_res53(); } diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 8bcd1b4c7..91f84e9d3 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -45,7 +45,7 @@ #define DEBUGLOGPATH "log"PATHSEP_STR"login-server.log" #endif -struct showmsg_interface showmsg_s; +static struct showmsg_interface showmsg_s; struct showmsg_interface *showmsg; /////////////////////////////////////////////////////////////////////////////// @@ -186,7 +186,7 @@ Escape sequences for Select Character Set #define is_console(handle) (FILE_TYPE_CHAR==GetFileType(handle)) /////////////////////////////////////////////////////////////////////////////// -int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) +static int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) { ///////////////////////////////////////////////////////////////// /* XXX Two streams are being used. Disabled to avoid inconsistency [flaviojs] @@ -467,8 +467,9 @@ int VFPRINTF(HANDLE handle, const char *fmt, va_list argptr) return 0; } -int FPRINTF(HANDLE handle, const char *fmt, ...) __attribute__((format(printf, 2, 3))); -int FPRINTF(HANDLE handle, const char *fmt, ...) { +static int FPRINTF(HANDLE handle, const char *fmt, ...) __attribute__((format(printf, 2, 3))); +static int FPRINTF(HANDLE handle, const char *fmt, ...) +{ int ret; va_list argptr; va_start(argptr, fmt); @@ -488,7 +489,7 @@ int FPRINTF(HANDLE handle, const char *fmt, ...) { #define is_console(file) (0!=isatty(fileno(file))) //vprintf_without_ansiformats -int VFPRINTF(FILE *file, const char *fmt, va_list argptr) +static int VFPRINTF(FILE *file, const char *fmt, va_list argptr) { char *p, *q; NEWBUF(tempbuf); // temporary buffer @@ -584,8 +585,9 @@ int VFPRINTF(FILE *file, const char *fmt, va_list argptr) FREEBUF(tempbuf); return 0; } -int FPRINTF(FILE *file, const char *fmt, ...) __attribute__((format(printf, 2, 3))); -int FPRINTF(FILE *file, const char *fmt, ...) { +static int FPRINTF(FILE *file, const char *fmt, ...) __attribute__((format(printf, 2, 3))); +static int FPRINTF(FILE *file, const char *fmt, ...) +{ int ret; va_list argptr; va_start(argptr, fmt); @@ -601,7 +603,7 @@ int FPRINTF(FILE *file, const char *fmt, ...) { #endif// not _WIN32 -int vShowMessage_(enum msg_type flag, const char *string, va_list ap) +static int vShowMessage_(enum msg_type flag, const char *string, va_list ap) { va_list apcopy; char prefix[100]; @@ -720,7 +722,7 @@ int vShowMessage_(enum msg_type flag, const char *string, va_list ap) return 0; } -int showmsg_vShowMessage(const char *string, va_list ap) +static int showmsg_vShowMessage(const char *string, va_list ap) { int ret; va_list apcopy; @@ -730,14 +732,16 @@ int showmsg_vShowMessage(const char *string, va_list ap) return ret; } -void showmsg_clearScreen(void) +static void showmsg_clearScreen(void) { #ifndef _WIN32 ShowMessage(CL_CLS); // to prevent empty string passed messages #endif } -int ShowMessage_(enum msg_type flag, const char *string, ...) __attribute__((format(printf, 2, 3))); -int ShowMessage_(enum msg_type flag, const char *string, ...) { + +static int ShowMessage_(enum msg_type flag, const char *string, ...) __attribute__((format(printf, 2, 3))); +static int ShowMessage_(enum msg_type flag, const char *string, ...) +{ int ret; va_list ap; va_start(ap, string); @@ -747,56 +751,56 @@ int ShowMessage_(enum msg_type flag, const char *string, ...) { } // direct printf replacement -void showmsg_showMessage(const char *string, ...) __attribute__((format(printf, 1, 2))); -void showmsg_showMessage(const char *string, ...) +static void showmsg_showMessage(const char *string, ...) __attribute__((format(printf, 1, 2))); +static void showmsg_showMessage(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_NONE, string, ap); va_end(ap); } -void showmsg_showStatus(const char *string, ...) __attribute__((format(printf, 1, 2))); -void showmsg_showStatus(const char *string, ...) +static void showmsg_showStatus(const char *string, ...) __attribute__((format(printf, 1, 2))); +static void showmsg_showStatus(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_STATUS, string, ap); va_end(ap); } -void showmsg_showSQL(const char *string, ...) __attribute__((format(printf, 1, 2))); -void showmsg_showSQL(const char *string, ...) +static void showmsg_showSQL(const char *string, ...) __attribute__((format(printf, 1, 2))); +static void showmsg_showSQL(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_SQL, string, ap); va_end(ap); } -void showmsg_showInfo(const char *string, ...) __attribute__((format(printf, 1, 2))); -void showmsg_showInfo(const char *string, ...) +static void showmsg_showInfo(const char *string, ...) __attribute__((format(printf, 1, 2))); +static void showmsg_showInfo(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_INFORMATION, string, ap); va_end(ap); } -void showmsg_showNotice(const char *string, ...) __attribute__((format(printf, 1, 2))); -void showmsg_showNotice(const char *string, ...) +static void showmsg_showNotice(const char *string, ...) __attribute__((format(printf, 1, 2))); +static void showmsg_showNotice(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_NOTICE, string, ap); va_end(ap); } -void showmsg_showWarning(const char *string, ...) __attribute__((format(printf, 1, 2))); -void showmsg_showWarning(const char *string, ...) +static void showmsg_showWarning(const char *string, ...) __attribute__((format(printf, 1, 2))); +static void showmsg_showWarning(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_WARNING, string, ap); va_end(ap); } -void showmsg_showConfigWarning(struct config_setting_t *config, const char *string, ...) __attribute__((format(printf, 2, 3))); -void showmsg_showConfigWarning(struct config_setting_t *config, const char *string, ...) +static void showmsg_showConfigWarning(struct config_setting_t *config, const char *string, ...) __attribute__((format(printf, 2, 3))); +static void showmsg_showConfigWarning(struct config_setting_t *config, const char *string, ...) { StringBuf buf; va_list ap; @@ -812,24 +816,24 @@ void showmsg_showConfigWarning(struct config_setting_t *config, const char *stri va_end(ap); StrBuf->Destroy(&buf); } -void showmsg_showDebug(const char *string, ...) __attribute__((format(printf, 1, 2))); -void showmsg_showDebug(const char *string, ...) +static void showmsg_showDebug(const char *string, ...) __attribute__((format(printf, 1, 2))); +static void showmsg_showDebug(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_DEBUG, string, ap); va_end(ap); } -void showmsg_showError(const char *string, ...) __attribute__((format(printf, 1, 2))); -void showmsg_showError(const char *string, ...) +static void showmsg_showError(const char *string, ...) __attribute__((format(printf, 1, 2))); +static void showmsg_showError(const char *string, ...) { va_list ap; va_start(ap, string); vShowMessage_(MSG_ERROR, string, ap); va_end(ap); } -void showmsg_showFatalError(const char *string, ...) __attribute__((format(printf, 1, 2))); -void showmsg_showFatalError(const char *string, ...) +static void showmsg_showFatalError(const char *string, ...) __attribute__((format(printf, 1, 2))); +static void showmsg_showFatalError(const char *string, ...) { va_list ap; va_start(ap, string); @@ -837,11 +841,11 @@ void showmsg_showFatalError(const char *string, ...) va_end(ap); } -void showmsg_init(void) +static void showmsg_init(void) { } -void showmsg_final(void) +static void showmsg_final(void) { } diff --git a/src/common/socket.c b/src/common/socket.c index cec366765..6119a5341 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -75,19 +75,19 @@ /** * Socket Interface Source **/ -struct socket_interface sockt_s; +static struct socket_interface sockt_s; struct socket_interface *sockt; -struct socket_data **session; +static struct socket_data **session; -const char *SOCKET_CONF_FILENAME = "conf/common/socket.conf"; +static const char *SOCKET_CONF_FILENAME = "conf/common/socket.conf"; #ifdef SEND_SHORTLIST // Add a fd to the shortlist so that it'll be recognized as a fd that needs // sending done on it. -void send_shortlist_add_fd(int fd); +static void send_shortlist_add_fd(int fd); // Do pending network sends (and eof handling) from the shortlist. -void send_shortlist_do_sends(void); +static void send_shortlist_do_sends(void); #endif // SEND_SHORTLIST ///////////////////////////////////////////////////////////////////// @@ -123,7 +123,7 @@ static int sock_arr_len = 0; /// /// @param s Socket /// @return Fd or -1 -int sock2fd(SOCKET s) +static int sock2fd(SOCKET s) { int fd; @@ -144,7 +144,7 @@ int sock2fd(SOCKET s) /// /// @param s Socket /// @return New fd or -1 -int sock2newfd(SOCKET s) +static int sock2newfd(SOCKET s) { int fd; @@ -164,7 +164,7 @@ int sock2newfd(SOCKET s) return fd; } -int sAccept(int fd, struct sockaddr* addr, int* addrlen) +static int sAccept(int fd, struct sockaddr *addr, int *addrlen) { SOCKET s; @@ -175,14 +175,14 @@ int sAccept(int fd, struct sockaddr* addr, int* addrlen) return sock2newfd(s); } -int sClose(int fd) +static int sClose(int fd) { int ret = closesocket(fd2sock(fd)); fd2sock(fd) = INVALID_SOCKET; return ret; } -int sSocket(int af, int type, int protocol) +static int sSocket(int af, int type, int protocol) { SOCKET s; @@ -193,7 +193,7 @@ int sSocket(int af, int type, int protocol) return sock2newfd(s); } -char* sErr(int code) +static char *sErr(int code) { static char sbuf[512]; // strerror does not handle socket codes @@ -259,7 +259,7 @@ char* sErr(int code) #ifndef SOCKET_EPOLL // Select based Event Dispatcher: -fd_set readfds; +static fd_set readfds; #else // SOCKET_EPOLL // Epoll based Event Dispatcher: @@ -296,19 +296,19 @@ static time_t socket_data_last_tick = 0; #define WFIFO_MAX (1*1024*1024) #ifdef SEND_SHORTLIST -int send_shortlist_array[FD_SETSIZE];// we only support FD_SETSIZE sockets, limit the array to that -int send_shortlist_count = 0;// how many fd's are in the shortlist -uint32 send_shortlist_set[(FD_SETSIZE+31)/32];// to know if specific fd's are already in the shortlist +static int send_shortlist_array[FD_SETSIZE];// we only support FD_SETSIZE sockets, limit the array to that +static int send_shortlist_count = 0;// how many fd's are in the shortlist +static uint32 send_shortlist_set[(FD_SETSIZE+31)/32];// to know if specific fd's are already in the shortlist #endif // SEND_SHORTLIST static int create_session(int fd, RecvFunc func_recv, SendFunc func_send, ParseFunc func_parse); #ifndef MINICORE - int ip_rules = 1; + static int ip_rules = 1; static int connect_check(uint32 ip); #endif // MINICORE -const char* error_msg(void) +static const char *error_msg(void) { static char buf[512]; int code = sErrno; @@ -319,13 +319,24 @@ const char* error_msg(void) /*====================================== * CORE : Default processing functions *--------------------------------------*/ -int null_recv(int fd) { return 0; } -int null_send(int fd) { return 0; } -int null_parse(int fd) { return 0; } +static int null_recv(int fd) +{ + return 0; +} + +static int null_send(int fd) +{ + return 0; +} + +static int null_parse(int fd) +{ + return 0; +} -ParseFunc default_func_parse = null_parse; +static ParseFunc default_func_parse = null_parse; -void set_defaultparse(ParseFunc defaultparse) +static void set_defaultparse(ParseFunc defaultparse) { default_func_parse = defaultparse; } @@ -333,7 +344,7 @@ void set_defaultparse(ParseFunc defaultparse) /*====================================== * CORE : Socket options *--------------------------------------*/ -void set_nonblocking(int fd, unsigned long yes) +static void set_nonblocking(int fd, unsigned long yes) { // FIONBIO Use with a nonzero argp parameter to enable the nonblocking mode of socket s. // The argp parameter is zero if nonblocking is to be disabled. @@ -347,7 +358,7 @@ void set_nonblocking(int fd, unsigned long yes) * @param fd The socket descriptor * @param opt Optional, additional options to set (Can be NULL). */ -void setsocketopts(int fd, struct hSockOpt *opt) +static void setsocketopts(int fd, struct hSockOpt *opt) { #if defined(WIN32) BOOL yes = TRUE; @@ -409,7 +420,7 @@ void setsocketopts(int fd, struct hSockOpt *opt) /*====================================== * CORE : Socket Sub Function *--------------------------------------*/ -void set_eof(int fd) +static void set_eof(int fd) { if (sockt->session_is_active(fd)) { #ifdef SEND_SHORTLIST @@ -420,7 +431,7 @@ void set_eof(int fd) } } -int recv_to_fifo(int fd) +static int recv_to_fifo(int fd) { ssize_t len; @@ -457,7 +468,7 @@ int recv_to_fifo(int fd) return 0; } -int send_from_fifo(int fd) +static int send_from_fifo(int fd) { ssize_t len; @@ -504,13 +515,13 @@ int send_from_fifo(int fd) } /// Best effort - there's no warranty that the data will be sent. -void flush_fifo(int fd) +static void flush_fifo(int fd) { if(sockt->session[fd] != NULL) sockt->session[fd]->func_send(fd); } -void flush_fifos(void) +static void flush_fifos(void) { int i; for(i = 1; i < sockt->fd_max; i++) @@ -520,7 +531,7 @@ void flush_fifos(void) /*====================================== * CORE : Connection functions *--------------------------------------*/ -int connect_client(int listen_fd) +static int connect_client(int listen_fd) { int fd; struct sockaddr_in client_address; @@ -579,7 +590,7 @@ int connect_client(int listen_fd) return fd; } -int make_listen_bind(uint32 ip, uint16 port) +static int make_listen_bind(uint32 ip, uint16 port) { struct sockaddr_in server_address = { 0 }; int fd; @@ -648,7 +659,7 @@ int make_listen_bind(uint32 ip, uint16 port) return fd; } -int make_connection(uint32 ip, uint16 port, struct hSockOpt *opt) +static int make_connection(uint32 ip, uint16 port, struct hSockOpt *opt) { struct sockaddr_in remote_address = { 0 }; int fd; @@ -749,7 +760,7 @@ static void delete_session(int fd) } } -int realloc_fifo(int fd, unsigned int rfifo_size, unsigned int wfifo_size) +static int realloc_fifo(int fd, unsigned int rfifo_size, unsigned int wfifo_size) { if (!sockt->session_is_valid(fd)) return 0; @@ -766,7 +777,7 @@ int realloc_fifo(int fd, unsigned int rfifo_size, unsigned int wfifo_size) return 0; } -int realloc_writefifo(int fd, size_t addition) +static int realloc_writefifo(int fd, size_t addition) { size_t newsize; @@ -794,7 +805,7 @@ int realloc_writefifo(int fd, size_t addition) } /// advance the RFIFO cursor (marking 'len' bytes as processed) -int rfifoskip(int fd, size_t len) +static int rfifoskip(int fd, size_t len) { struct socket_data *s; @@ -816,7 +827,7 @@ int rfifoskip(int fd, size_t len) } /// advance the WFIFO cursor (marking 'len' bytes for sending) -int wfifoset(int fd, size_t len) +static int wfifoset(int fd, size_t len) { size_t newreserve; struct socket_data* s; @@ -884,7 +895,7 @@ int wfifoset(int fd, size_t len) return 0; } -int do_sockets(int next) +static int do_sockets(int next) { #ifndef SOCKET_EPOLL fd_set rfd; @@ -1088,7 +1099,7 @@ static int access_debug = 0; static int ddos_count = 10; static int ddos_interval = 3*1000; static int ddos_autoreset = 10*60*1000; -struct DBMap *connect_history = NULL; +static struct DBMap *connect_history = NULL; static int connect_check_(uint32 ip); @@ -1232,7 +1243,7 @@ static int connect_check_clear(int tid, int64 tick, int id, intptr_t data) /// Parses the ip address and mask and puts it into acc. /// Returns 1 is successful, 0 otherwise. -int access_ipmask(const char *str, struct access_control *acc) +static int access_ipmask(const char *str, struct access_control *acc) { uint32 ip; uint32 mask; @@ -1288,7 +1299,7 @@ int access_ipmask(const char *str, struct access_control *acc) * * @retval false in case of failure */ -bool access_list_add(struct config_setting_t *setting, const char *list_name, struct access_control_list *access_list) +static bool access_list_add(struct config_setting_t *setting, const char *list_name, struct access_control_list *access_list) { const char *temp = NULL; int i, setting_length; @@ -1330,7 +1341,7 @@ bool access_list_add(struct config_setting_t *setting, const char *list_name, st * * @retval false in case of error. */ -bool socket_config_read_iprules(const char *filename, struct config_t *config, bool imported) +static bool socket_config_read_iprules(const char *filename, struct config_t *config, bool imported) { #ifndef MINICORE struct config_setting_t *setting = NULL; @@ -1389,7 +1400,7 @@ bool socket_config_read_iprules(const char *filename, struct config_t *config, b * * @retval false in case of error. */ -bool socket_config_read_ddos(const char *filename, struct config_t *config, bool imported) +static bool socket_config_read_ddos(const char *filename, struct config_t *config, bool imported) { #ifndef MINICORE struct config_setting_t *setting = NULL; @@ -1420,7 +1431,7 @@ bool socket_config_read_ddos(const char *filename, struct config_t *config, bool * * @retval false in case of error. */ -bool socket_config_read(const char *filename, bool imported) +static bool socket_config_read(const char *filename, bool imported) { struct config_t config; struct config_setting_t *setting = NULL; @@ -1484,7 +1495,7 @@ bool socket_config_read(const char *filename, bool imported) return retval; } -void socket_final(void) +static void socket_final(void) { int i; #ifndef MINICORE @@ -1523,7 +1534,7 @@ void socket_final(void) } /// Closes a socket. -void socket_close(int fd) +static void socket_close(int fd) { if( fd <= 0 ||fd >= FD_SETSIZE ) return;// invalid @@ -1547,7 +1558,7 @@ void socket_close(int fd) /// Retrieve local ips in host byte order. /// Uses loopback is no address is found. -int socket_getips(uint32* ips, int max) +static int socket_getips(uint32 *ips, int max) { int num = 0; @@ -1628,7 +1639,7 @@ int socket_getips(uint32* ips, int max) return num; } -void socket_init(void) +static void socket_init(void) { uint64 rlim_cur = FD_SETSIZE; @@ -1730,18 +1741,18 @@ void socket_init(void) ShowInfo("Server supports up to '"CL_WHITE"%"PRIu64""CL_RESET"' concurrent connections.\n", rlim_cur); } -bool session_is_valid(int fd) +static bool session_is_valid(int fd) { return ( fd > 0 && fd < FD_SETSIZE && sockt->session[fd] != NULL ); } -bool session_is_active(int fd) +static bool session_is_active(int fd) { return ( sockt->session_is_valid(fd) && !sockt->session[fd]->flag.eof ); } // Resolves hostname into a numeric ip. -uint32 host2ip(const char *hostname) +static uint32 host2ip(const char *hostname) { struct hostent* h; nullpo_ret(hostname); @@ -1757,7 +1768,7 @@ uint32 host2ip(const char *hostname) * * @return A pointer to the output string. */ -const char *ip2str(uint32 ip, char *ip_str) +static const char *ip2str(uint32 ip, char *ip_str) { struct in_addr addr; addr.s_addr = htonl(ip); @@ -1765,20 +1776,20 @@ const char *ip2str(uint32 ip, char *ip_str) } // Converts a dot-formatted ip string into a numeric ip. -uint32 str2ip(const char* ip_str) +static uint32 str2ip(const char *ip_str) { return ntohl(inet_addr(ip_str)); } // Reorders bytes from network to little endian (Windows). // Necessary for sending port numbers to the RO client until Gravity notices that they forgot ntohs() calls. -uint16 ntows(uint16 netshort) +static uint16 ntows(uint16 netshort) { return ((netshort & 0xFF) << 8) | ((netshort & 0xFF00) >> 8); } /* [Ind/Hercules] - socket_datasync */ -void socket_datasync(int fd, bool send) +static void socket_datasync(int fd, bool send) { struct { unsigned int length;/* short is not enough for some */ @@ -1845,7 +1856,7 @@ void socket_datasync(int fd, bool send) #ifdef SEND_SHORTLIST // Add a fd to the shortlist so that it'll be recognized as a fd that needs // sending or eof handling. -void send_shortlist_add_fd(int fd) +static void send_shortlist_add_fd(int fd) { int i; int bit; @@ -1872,7 +1883,7 @@ void send_shortlist_add_fd(int fd) } // Do pending network sends and eof handling from the shortlist. -void send_shortlist_do_sends(void) +static void send_shortlist_do_sends(void) { int i; @@ -1928,7 +1939,7 @@ void send_shortlist_do_sends(void) * @retval 0 if it is a WAN IP. * @return the appropriate LAN server address to send, if it is a LAN IP. */ -uint32 socket_lan_subnet_check(uint32 ip, struct s_subnet *info) +static uint32 socket_lan_subnet_check(uint32 ip, struct s_subnet *info) { int i; ARR_FIND(0, VECTOR_LENGTH(sockt->lan_subnets), i, SUBNET_MATCH(ip, VECTOR_INDEX(sockt->lan_subnets, i).ip, VECTOR_INDEX(sockt->lan_subnets, i).mask)); @@ -1952,7 +1963,7 @@ uint32 socket_lan_subnet_check(uint32 ip, struct s_subnet *info) * @retval true if we allow server connections from the given IP. * @retval false otherwise. */ -bool socket_allowed_ip_check(uint32 ip) +static bool socket_allowed_ip_check(uint32 ip) { int i; ARR_FIND(0, VECTOR_LENGTH(sockt->allowed_ips), i, SUBNET_MATCH(ip, VECTOR_INDEX(sockt->allowed_ips, i).ip, VECTOR_INDEX(sockt->allowed_ips, i).mask)); @@ -1968,7 +1979,7 @@ bool socket_allowed_ip_check(uint32 ip) * @retval true if we trust the given IP. * @retval false otherwise. */ -bool socket_trusted_ip_check(uint32 ip) +static bool socket_trusted_ip_check(uint32 ip) { int i; ARR_FIND(0, VECTOR_LENGTH(sockt->trusted_ips), i, SUBNET_MATCH(ip, VECTOR_INDEX(sockt->trusted_ips, i).ip, VECTOR_INDEX(sockt->trusted_ips, i).mask)); @@ -1988,7 +1999,7 @@ bool socket_trusted_ip_check(uint32 ip) * @param[in] groupname Current group name, for output/logging reasons. * @return The amount of entries read, zero in case of errors. */ -int socket_net_config_read_sub(struct config_setting_t *t, struct s_subnet_vector *list, const char *filename, const char *groupname) +static int socket_net_config_read_sub(struct config_setting_t *t, struct s_subnet_vector *list, const char *filename, const char *groupname) { int i, len; char ipbuf[64], maskbuf[64]; @@ -2022,7 +2033,7 @@ int socket_net_config_read_sub(struct config_setting_t *t, struct s_subnet_vecto * * @param filename The filename to read from. */ -void socket_net_config_read(const char *filename) +static void socket_net_config_read(const char *filename) { struct config_t network_config; int i; diff --git a/src/common/sql.c b/src/common/sql.c index 6e0e9ba33..0b5b7fa07 100644 --- a/src/common/sql.c +++ b/src/common/sql.c @@ -37,12 +37,12 @@ #include #include // strtoul -void hercules_mysql_error_handler(unsigned int ecode); +static void hercules_mysql_error_handler(unsigned int ecode); -int mysql_reconnect_type = 2; -int mysql_reconnect_count = 1; +static int mysql_reconnect_type = 2; +static int mysql_reconnect_count = 1; -struct sql_interface sql_s; +static struct sql_interface sql_s; struct sql_interface *SQL; /// Sql handle @@ -81,7 +81,7 @@ struct SqlStmt { /////////////////////////////////////////////////////////////////////////////// /// Allocates and initializes a new Sql handle. -struct Sql *Sql_Malloc(void) +static struct Sql *Sql_Malloc(void) { struct Sql *self; @@ -101,7 +101,7 @@ struct Sql *Sql_Malloc(void) static int Sql_P_Keepalive(struct Sql *self); /// Establishes a connection. -int Sql_Connect(struct Sql *self, const char *user, const char *passwd, const char *host, uint16 port, const char *db) +static int Sql_Connect(struct Sql *self, const char *user, const char *passwd, const char *host, uint16 port, const char *db) { if( self == NULL ) return SQL_ERROR; @@ -124,7 +124,7 @@ int Sql_Connect(struct Sql *self, const char *user, const char *passwd, const ch } /// Retrieves the timeout of the connection. -int Sql_GetTimeout(struct Sql *self, uint32 *out_timeout) +static int Sql_GetTimeout(struct Sql *self, uint32 *out_timeout) { if( self && out_timeout && SQL_SUCCESS == SQL->Query(self, "SHOW VARIABLES LIKE 'wait_timeout'") ) { char* data; @@ -141,7 +141,7 @@ int Sql_GetTimeout(struct Sql *self, uint32 *out_timeout) } /// Retrieves the name of the columns of a table into out_buf, with the separator after each name. -int Sql_GetColumnNames(struct Sql *self, const char *table, char *out_buf, size_t buf_len, char sep) +static int Sql_GetColumnNames(struct Sql *self, const char *table, char *out_buf, size_t buf_len, char sep) { char* data; size_t len; @@ -170,7 +170,7 @@ int Sql_GetColumnNames(struct Sql *self, const char *table, char *out_buf, size_ } /// Changes the encoding of the connection. -int Sql_SetEncoding(struct Sql *self, const char *encoding) +static int Sql_SetEncoding(struct Sql *self, const char *encoding) { if( self && mysql_set_character_set(&self->handle, encoding) == 0 ) return SQL_SUCCESS; @@ -178,7 +178,7 @@ int Sql_SetEncoding(struct Sql *self, const char *encoding) } /// Pings the connection. -int Sql_Ping(struct Sql *self) +static int Sql_Ping(struct Sql *self) { if( self && mysql_ping(&self->handle) == 0 ) return SQL_SUCCESS; @@ -220,7 +220,7 @@ static int Sql_P_Keepalive(struct Sql *self) } /// Escapes a string. -size_t Sql_EscapeString(struct Sql *self, char *out_to, const char *from) +static size_t Sql_EscapeString(struct Sql *self, char *out_to, const char *from) { if (self != NULL) return (size_t)mysql_real_escape_string(&self->handle, out_to, from, (unsigned long)strlen(from)); @@ -229,7 +229,7 @@ size_t Sql_EscapeString(struct Sql *self, char *out_to, const char *from) } /// Escapes a string. -size_t Sql_EscapeStringLen(struct Sql *self, char *out_to, const char *from, size_t from_len) +static size_t Sql_EscapeStringLen(struct Sql *self, char *out_to, const char *from, size_t from_len) { if (self != NULL) return (size_t)mysql_real_escape_string(&self->handle, out_to, from, (unsigned long)from_len); @@ -238,8 +238,8 @@ size_t Sql_EscapeStringLen(struct Sql *self, char *out_to, const char *from, siz } /// Executes a query. -int Sql_Query(struct Sql *self, const char *query, ...) __attribute__((format(printf, 2, 3))); -int Sql_Query(struct Sql *self, const char *query, ...) +static int Sql_Query(struct Sql *self, const char *query, ...) __attribute__((format(printf, 2, 3))); +static int Sql_Query(struct Sql *self, const char *query, ...) { int res; va_list args; @@ -252,7 +252,7 @@ int Sql_Query(struct Sql *self, const char *query, ...) } /// Executes a query. -int Sql_QueryV(struct Sql *self, const char *query, va_list args) +static int Sql_QueryV(struct Sql *self, const char *query, va_list args) { if( self == NULL ) return SQL_ERROR; @@ -277,7 +277,7 @@ int Sql_QueryV(struct Sql *self, const char *query, va_list args) } /// Executes a query. -int Sql_QueryStr(struct Sql *self, const char *query) +static int Sql_QueryStr(struct Sql *self, const char *query) { if( self == NULL ) return SQL_ERROR; @@ -302,7 +302,7 @@ int Sql_QueryStr(struct Sql *self, const char *query) } /// Returns the number of the AUTO_INCREMENT column of the last INSERT/UPDATE query. -uint64 Sql_LastInsertId(struct Sql *self) +static uint64 Sql_LastInsertId(struct Sql *self) { if (self != NULL) return (uint64)mysql_insert_id(&self->handle); @@ -311,7 +311,7 @@ uint64 Sql_LastInsertId(struct Sql *self) } /// Returns the number of columns in each row of the result. -uint32 Sql_NumColumns(struct Sql *self) +static uint32 Sql_NumColumns(struct Sql *self) { if (self != NULL && self->result != NULL) return (uint32)mysql_num_fields(self->result); @@ -319,7 +319,7 @@ uint32 Sql_NumColumns(struct Sql *self) } /// Returns the number of rows in the result. -uint64 Sql_NumRows(struct Sql *self) +static uint64 Sql_NumRows(struct Sql *self) { if (self != NULL && self->result != NULL) return (uint64)mysql_num_rows(self->result); @@ -327,7 +327,7 @@ uint64 Sql_NumRows(struct Sql *self) } /// Fetches the next row. -int Sql_NextRow(struct Sql *self) +static int Sql_NextRow(struct Sql *self) { if (self != NULL && self->result != NULL) { self->row = mysql_fetch_row(self->result); @@ -343,7 +343,7 @@ int Sql_NextRow(struct Sql *self) } /// Gets the data of a column. -int Sql_GetData(struct Sql *self, size_t col, char **out_buf, size_t *out_len) +static int Sql_GetData(struct Sql *self, size_t col, char **out_buf, size_t *out_len) { if( self && self->row ) { if( col < SQL->NumColumns(self) ) { @@ -359,7 +359,7 @@ int Sql_GetData(struct Sql *self, size_t col, char **out_buf, size_t *out_len) } /// Frees the result of the query. -void Sql_FreeResult(struct Sql *self) +static void Sql_FreeResult(struct Sql *self) { if( self && self->result ) { mysql_free_result(self->result); @@ -370,7 +370,7 @@ void Sql_FreeResult(struct Sql *self) } /// Shows debug information (last query). -void Sql_ShowDebug_(struct Sql *self, const char *debug_file, const unsigned long debug_line) +static void Sql_ShowDebug_(struct Sql *self, const char *debug_file, const unsigned long debug_line) { if( self == NULL ) ShowDebug("at %s:%lu - self is NULL\n", debug_file, debug_line); @@ -381,7 +381,7 @@ void Sql_ShowDebug_(struct Sql *self, const char *debug_file, const unsigned lon } /// Frees a Sql handle returned by Sql_Malloc. -void Sql_Free(struct Sql *self) +static void Sql_Free(struct Sql *self) { if( self ) { @@ -417,7 +417,7 @@ static enum enum_field_types Sql_P_SizeToMysqlIntType(int sz) /// Binds a parameter/result. /// /// @private -static int Sql_P_BindSqlDataType(MYSQL_BIND* bind, enum SqlDataType buffer_type, void* buffer, size_t buffer_len, unsigned long* out_length, int8* out_is_null) +static int Sql_P_BindSqlDataType(MYSQL_BIND *bind, enum SqlDataType buffer_type, void *buffer, size_t buffer_len, unsigned long *out_length, int8 *out_is_null) { nullpo_retr(SQL_ERROR, bind); memset(bind, 0, sizeof(MYSQL_BIND)); @@ -531,7 +531,7 @@ static int Sql_P_BindSqlDataType(MYSQL_BIND* bind, enum SqlDataType buffer_type, /// Prints debug information about a field (type and length). /// /// @private -static void Sql_P_ShowDebugMysqlFieldInfo(const char* prefix, enum enum_field_types type, int is_unsigned, unsigned long length, const char* length_postfix) +static void Sql_P_ShowDebugMysqlFieldInfo(const char *prefix, enum enum_field_types type, int is_unsigned, unsigned long length, const char *length_postfix) { const char *sign = (is_unsigned ? "UNSIGNED " : ""); const char *type_string = NULL; @@ -588,7 +588,7 @@ static void SqlStmt_P_ShowDebugTruncatedColumn(struct SqlStmt *self, size_t i) } /// Allocates and initializes a new SqlStmt handle. -struct SqlStmt *SqlStmt_Malloc(struct Sql *sql) +static struct SqlStmt *SqlStmt_Malloc(struct Sql *sql) { struct SqlStmt *self; MYSQL_STMT* stmt; @@ -616,8 +616,8 @@ struct SqlStmt *SqlStmt_Malloc(struct Sql *sql) } /// Prepares the statement. -int SqlStmt_Prepare(struct SqlStmt *self, const char *query, ...) __attribute__((format(printf, 2, 3))); -int SqlStmt_Prepare(struct SqlStmt *self, const char *query, ...) +static int SqlStmt_Prepare(struct SqlStmt *self, const char *query, ...) __attribute__((format(printf, 2, 3))); +static int SqlStmt_Prepare(struct SqlStmt *self, const char *query, ...) { int res; va_list args; @@ -630,7 +630,7 @@ int SqlStmt_Prepare(struct SqlStmt *self, const char *query, ...) } /// Prepares the statement. -int SqlStmt_PrepareV(struct SqlStmt *self, const char *query, va_list args) +static int SqlStmt_PrepareV(struct SqlStmt *self, const char *query, va_list args) { if( self == NULL ) return SQL_ERROR; @@ -650,7 +650,7 @@ int SqlStmt_PrepareV(struct SqlStmt *self, const char *query, va_list args) } /// Prepares the statement. -int SqlStmt_PrepareStr(struct SqlStmt *self, const char *query) +static int SqlStmt_PrepareStr(struct SqlStmt *self, const char *query) { if( self == NULL ) return SQL_ERROR; @@ -670,7 +670,7 @@ int SqlStmt_PrepareStr(struct SqlStmt *self, const char *query) } /// Returns the number of parameters in the prepared statement. -size_t SqlStmt_NumParams(struct SqlStmt *self) +static size_t SqlStmt_NumParams(struct SqlStmt *self) { if( self ) return (size_t)mysql_stmt_param_count(self->stmt); @@ -679,7 +679,7 @@ size_t SqlStmt_NumParams(struct SqlStmt *self) } /// Binds a parameter to a buffer. -int SqlStmt_BindParam(struct SqlStmt *self, size_t idx, enum SqlDataType buffer_type, const void *buffer, size_t buffer_len) +static int SqlStmt_BindParam(struct SqlStmt *self, size_t idx, enum SqlDataType buffer_type, const void *buffer, size_t buffer_len) { if( self == NULL ) return SQL_ERROR; @@ -716,7 +716,7 @@ PRAGMA_GCC46(GCC diagnostic pop) } /// Executes the prepared statement. -int SqlStmt_Execute(struct SqlStmt *self) +static int SqlStmt_Execute(struct SqlStmt *self) { if( self == NULL ) return SQL_ERROR; @@ -741,7 +741,7 @@ int SqlStmt_Execute(struct SqlStmt *self) } /// Returns the number of the AUTO_INCREMENT column of the last INSERT/UPDATE statement. -uint64 SqlStmt_LastInsertId(struct SqlStmt *self) +static uint64 SqlStmt_LastInsertId(struct SqlStmt *self) { if( self ) return (uint64)mysql_stmt_insert_id(self->stmt); @@ -750,7 +750,7 @@ uint64 SqlStmt_LastInsertId(struct SqlStmt *self) } /// Returns the number of columns in each row of the result. -size_t SqlStmt_NumColumns(struct SqlStmt *self) +static size_t SqlStmt_NumColumns(struct SqlStmt *self) { if( self ) return (size_t)mysql_stmt_field_count(self->stmt); @@ -759,7 +759,7 @@ size_t SqlStmt_NumColumns(struct SqlStmt *self) } /// Binds the result of a column to a buffer. -int SqlStmt_BindColumn(struct SqlStmt *self, size_t idx, enum SqlDataType buffer_type, void *buffer, size_t buffer_len, uint32 *out_length, int8 *out_is_null) +static int SqlStmt_BindColumn(struct SqlStmt *self, size_t idx, enum SqlDataType buffer_type, void *buffer, size_t buffer_len, uint32 *out_length, int8 *out_is_null) { if (self == NULL) return SQL_ERROR; @@ -801,7 +801,7 @@ int SqlStmt_BindColumn(struct SqlStmt *self, size_t idx, enum SqlDataType buffer } /// Returns the number of rows in the result. -uint64 SqlStmt_NumRows(struct SqlStmt *self) +static uint64 SqlStmt_NumRows(struct SqlStmt *self) { if (self != NULL) return (uint64)mysql_stmt_num_rows(self->stmt); @@ -810,7 +810,7 @@ uint64 SqlStmt_NumRows(struct SqlStmt *self) } /// Fetches the next row. -int SqlStmt_NextRow(struct SqlStmt *self) +static int SqlStmt_NextRow(struct SqlStmt *self) { int err; size_t i; @@ -878,14 +878,14 @@ int SqlStmt_NextRow(struct SqlStmt *self) } /// Frees the result of the statement execution. -void SqlStmt_FreeResult(struct SqlStmt *self) +static void SqlStmt_FreeResult(struct SqlStmt *self) { if( self ) mysql_stmt_free_result(self->stmt); } /// Shows debug information (with statement). -void SqlStmt_ShowDebug_(struct SqlStmt *self, const char *debug_file, const unsigned long debug_line) +static void SqlStmt_ShowDebug_(struct SqlStmt *self, const char *debug_file, const unsigned long debug_line) { if( self == NULL ) ShowDebug("at %s:%lu - self is NULL\n", debug_file, debug_line); @@ -896,7 +896,7 @@ void SqlStmt_ShowDebug_(struct SqlStmt *self, const char *debug_file, const unsi } /// Frees a SqlStmt returned by SqlStmt_Malloc. -void SqlStmt_Free(struct SqlStmt *self) +static void SqlStmt_Free(struct SqlStmt *self) { if( self ) { @@ -915,7 +915,7 @@ void SqlStmt_Free(struct SqlStmt *self) } /* receives mysql error codes during runtime (not on first-time-connects) */ -void hercules_mysql_error_handler(unsigned int ecode) +static void hercules_mysql_error_handler(unsigned int ecode) { switch( ecode ) { case 2003:/* Can't connect to MySQL (this error only happens here when failing to reconnect) */ @@ -938,7 +938,7 @@ void hercules_mysql_error_handler(unsigned int ecode) * * @retval false in case of error. */ -bool Sql_inter_server_read(const char *filename, bool imported) +static bool Sql_inter_server_read(const char *filename, bool imported) { struct config_t config; const struct config_setting_t *setting = NULL; diff --git a/src/common/strlib.c b/src/common/strlib.c index f0357e4a0..c9448177b 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -32,16 +32,17 @@ #define J_MAX_MALLOC_SIZE 65535 -struct strlib_interface strlib_s; -struct stringbuf_interface stringbuf_s; -struct sv_interface sv_s; +static struct strlib_interface strlib_s; +static struct stringbuf_interface stringbuf_s; +static struct sv_interface sv_s; struct strlib_interface *strlib; struct stringbuf_interface *StrBuf; struct sv_interface *sv; // escapes a string in-place (' -> \' , \ -> \\ , % -> _) -char* jstrescape (char* pt) { +static char *jstrescape(char *pt) +{ //copy from here char *ptr; int i = 0, j = 0; @@ -73,7 +74,7 @@ char* jstrescape (char* pt) { } // escapes a string into a provided buffer -char* jstrescapecpy (char* pt, const char* spt) +static char *jstrescapecpy(char *pt, const char *spt) { //copy from here //WARNING: Target string pt should be able to hold strlen(spt)*2, as each time @@ -108,7 +109,7 @@ char* jstrescapecpy (char* pt, const char* spt) } // escapes exactly 'size' bytes of a string into a provided buffer -int jmemescapecpy (char* pt, const char* spt, int size) +static int jmemescapecpy(char *pt, const char *spt, int size) { //copy from here int i =0, j=0; @@ -135,7 +136,7 @@ int jmemescapecpy (char* pt, const char* spt, int size) } // Function to suppress control characters in a string. -int strlib_remove_control_chars(char *str) +static int strlib_remove_control_chars(char *str) { int i; int change = 0; @@ -152,7 +153,7 @@ int strlib_remove_control_chars(char *str) // Removes characters identified by ISSPACE from the start and end of the string // NOTE: make sure the string is not const!! -char *strlib_trim(char *str) +static char *strlib_trim(char *str) { size_t start; size_t end; @@ -180,7 +181,7 @@ char *strlib_trim(char *str) // Converts one or more consecutive occurrences of the delimiters into a single space // and removes such occurrences from the beginning and end of string // NOTE: make sure the string is not const!! -char *strlib_normalize_name(char *str, const char *delims) +static char *strlib_normalize_name(char *str, const char *delims) { char* in = str; char* out = str; @@ -218,7 +219,7 @@ char *strlib_normalize_name(char *str, const char *delims) //stristr: Case insensitive version of strstr, code taken from //http://www.daniweb.com/code/snippet313.html, Dave Sinkula // -const char *strlib_stristr(const char *haystack, const char *needle) +static const char *strlib_stristr(const char *haystack, const char *needle) { if ( !*needle ) { @@ -246,7 +247,7 @@ const char *strlib_stristr(const char *haystack, const char *needle) return 0; } -char* strlib_strtok_r(char *s1, const char *s2, char **lasts) +static char* strlib_strtok_r(char *s1, const char *s2, char **lasts) { #ifdef __WIN32 char *ret; @@ -269,7 +270,7 @@ char* strlib_strtok_r(char *s1, const char *s2, char **lasts) #endif } -size_t strlib_strnlen(const char *string, size_t maxlen) +static size_t strlib_strnlen(const char *string, size_t maxlen) { // TODO: Verify whether this implementation is still necessary for NetBSD 5.x // and possibly some Solaris versions. @@ -287,7 +288,7 @@ size_t strlib_strnlen(const char *string, size_t maxlen) //---------------------------------------------------- // E-mail check: return 0 (not correct) or 1 (valid). //---------------------------------------------------- -int strlib_e_mail_check(char *email) +static int strlib_e_mail_check(char *email) { char ch; char* last_arobas; @@ -324,7 +325,8 @@ int strlib_e_mail_check(char *email) // Return numerical value of a switch configuration // on/off, yes/no, true/false, number //-------------------------------------------------- -int strlib_config_switch(const char *str) { +static int strlib_config_switch(const char *str) +{ size_t len = strlen(str); if ((len == 2 && strcmpi(str, "on") == 0) || (len == 3 && strcmpi(str, "yes") == 0) @@ -345,7 +347,7 @@ int strlib_config_switch(const char *str) { /// strncpy that always null-terminates the string /// @remark this function will read at most `n` - 1 bytes from `src` (from 0 to `n` - 2) -char *strlib_safestrncpy(char *dst, const char *src, size_t n) +static char *strlib_safestrncpy(char *dst, const char *src, size_t n) { if( n > 0 ) { @@ -366,7 +368,7 @@ char *strlib_safestrncpy(char *dst, const char *src, size_t n) } /// doesn't crash on null pointer -size_t strlib_safestrnlen(const char *string, size_t maxlen) +static size_t strlib_safestrnlen(const char *string, size_t maxlen) { return ( string != NULL ) ? strnlen(string, maxlen) : 0; } @@ -380,8 +382,8 @@ size_t strlib_safestrnlen(const char *string, size_t maxlen) /// @param fmt Format string /// @param ... Format arguments /// @return The size of the string or -1 if the buffer is too small -int strlib_safesnprintf(char *buf, size_t sz, const char *fmt, ...) __attribute__((format(printf, 3, 4))); -int strlib_safesnprintf(char *buf, size_t sz, const char *fmt, ...) +static int strlib_safesnprintf(char *buf, size_t sz, const char *fmt, ...) __attribute__((format(printf, 3, 4))); +static int strlib_safesnprintf(char *buf, size_t sz, const char *fmt, ...) { va_list ap; int ret; @@ -398,7 +400,7 @@ int strlib_safesnprintf(char *buf, size_t sz, const char *fmt, ...) /// Returns the line of the target position in the string. /// Lines start at 1. -int strlib_strline(const char *str, size_t pos) +static int strlib_strline(const char *str, size_t pos) { const char* target; int line; @@ -424,7 +426,7 @@ int strlib_strline(const char *str, size_t pos) /// @param output Output string /// @param input Binary input buffer /// @param count Number of bytes to convert -bool strlib_bin2hex(char *output, const unsigned char *input, size_t count) +static bool strlib_bin2hex(char *output, const unsigned char *input, size_t count) { char toHex[] = "0123456789abcdef"; size_t i; @@ -444,7 +446,7 @@ bool strlib_bin2hex(char *output, const unsigned char *input, size_t count) /// /// @param svstate Parse state /// @return 1 if a field was parsed, 0 if already done, -1 on error. -int sv_parse_next(struct s_svstate* svstate) +static int sv_parse_next(struct s_svstate *svstate) { enum { START_OF_FIELD, @@ -615,7 +617,8 @@ int sv_parse_next(struct s_svstate* svstate) /// @param npos Size of the pos array /// @param opt Options that determine the parsing behavior /// @return Number of fields found in the string or -1 if an error occurred -int sv_parse(const char* str, int len, int startoff, char delim, int* out_pos, int npos, enum e_svopt opt) { +static int sv_parse(const char *str, int len, int startoff, char delim, int *out_pos, int npos, enum e_svopt opt) +{ struct s_svstate svstate; int count; @@ -665,7 +668,8 @@ int sv_parse(const char* str, int len, int startoff, char delim, int* out_pos, i /// @param nfields Size of the field array /// @param opt Options that determine the parsing behavior /// @return Number of fields found in the string or -1 if an error occurred -int sv_split(char* str, int len, int startoff, char delim, char** out_fields, int nfields, enum e_svopt opt) { +static int sv_split(char *str, int len, int startoff, char delim, char **out_fields, int nfields, enum e_svopt opt) +{ int pos[1024]; int i; int done; @@ -731,7 +735,8 @@ int sv_split(char* str, int len, int startoff, char delim, char** out_fields, in /// @param len Length of the source string /// @param escapes Extra characters to be escaped /// @return Length of the escaped string -size_t sv_escape_c(char* out_dest, const char* src, size_t len, const char* escapes) { +static size_t sv_escape_c(char *out_dest, const char *src, size_t len, const char *escapes) +{ size_t i; size_t j; @@ -799,7 +804,8 @@ size_t sv_escape_c(char* out_dest, const char* src, size_t len, const char* esca /// @param src Source string /// @param len Length of the source string /// @return Length of the escaped string -size_t sv_unescape_c(char* out_dest, const char* src, size_t len) { +static size_t sv_unescape_c(char *out_dest, const char *src, size_t len) +{ static unsigned char low2hex[256] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,// 0x0? 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,// 0x1? @@ -880,7 +886,8 @@ size_t sv_unescape_c(char* out_dest, const char* src, size_t len) { } /// Skips a C escape sequence (starting with '\\'). -const char* skip_escaped_c(const char* p) { +static const char *skip_escaped_c(const char *p) +{ if( p && *p == '\\' ) { ++p; switch( *p ) { @@ -918,7 +925,8 @@ const char* skip_escaped_c(const char* p) { /// @param maxcols Maximum number of columns of a valid row /// @param parseproc User-supplied row processing function /// @return true on success, false if file could not be opened -bool sv_readdb(const char* directory, const char* filename, char delim, int mincols, int maxcols, int maxrows, bool (*parseproc)(char* fields[], int columns, int current)) { +static bool sv_readdb(const char *directory, const char *filename, char delim, int mincols, int maxcols, int maxrows, bool (*parseproc)(char *fields[], int columns, int current)) +{ FILE* fp; int lines = 0; int entries = 0; @@ -990,7 +998,8 @@ bool sv_readdb(const char* directory, const char* filename, char delim, int minc // @author MouseJstr (original) /// Allocates a StringBuf -StringBuf* StringBuf_Malloc(void) { +static StringBuf *StringBuf_Malloc(void) +{ StringBuf* self; CREATE(self, StringBuf, 1); StrBuf->Init(self); @@ -998,14 +1007,16 @@ StringBuf* StringBuf_Malloc(void) { } /// Initializes a previously allocated StringBuf -void StringBuf_Init(StringBuf* self) { +static void StringBuf_Init(StringBuf *self) +{ self->max_ = 1024; self->ptr_ = self->buf_ = (char*)aMalloc(self->max_ + 1); } /// Appends the result of printf to the StringBuf -int StringBuf_Printf(StringBuf *self, const char *fmt, ...) __attribute__((format(printf, 2, 3))); -int StringBuf_Printf(StringBuf *self, const char *fmt, ...) { +static int StringBuf_Printf(StringBuf *self, const char *fmt, ...) __attribute__((format(printf, 2, 3))); +static int StringBuf_Printf(StringBuf *self, const char *fmt, ...) +{ int len; va_list ap; @@ -1017,7 +1028,8 @@ int StringBuf_Printf(StringBuf *self, const char *fmt, ...) { } /// Appends the result of vprintf to the StringBuf -int StringBuf_Vprintf(StringBuf* self, const char* fmt, va_list ap) { +static int StringBuf_Vprintf(StringBuf *self, const char *fmt, va_list ap) +{ for(;;) { va_list apcopy; int n, off; @@ -1040,7 +1052,8 @@ int StringBuf_Vprintf(StringBuf* self, const char* fmt, va_list ap) { } /// Appends the contents of another StringBuf to the StringBuf -int StringBuf_Append(StringBuf* self, const StringBuf* sbuf) { +static int StringBuf_Append(StringBuf *self, const StringBuf *sbuf) +{ size_t available = self->max_ - (self->ptr_ - self->buf_); size_t needed = sbuf->ptr_ - sbuf->buf_; @@ -1057,7 +1070,8 @@ int StringBuf_Append(StringBuf* self, const StringBuf* sbuf) { } // Appends str to the StringBuf -int StringBuf_AppendStr(StringBuf* self, const char* str) { +static int StringBuf_AppendStr(StringBuf *self, const char *str) +{ size_t available = self->max_ - (self->ptr_ - self->buf_); size_t needed = strlen(str); @@ -1075,34 +1089,41 @@ int StringBuf_AppendStr(StringBuf* self, const char* str) { } // Returns the length of the data in the Stringbuf -int StringBuf_Length(StringBuf* self) { +static int StringBuf_Length(StringBuf *self) +{ return (int)(self->ptr_ - self->buf_); } /// Returns the data in the StringBuf -char* StringBuf_Value(StringBuf* self) { +static char *StringBuf_Value(StringBuf *self) +{ *self->ptr_ = '\0'; return self->buf_; } /// Clears the contents of the StringBuf -void StringBuf_Clear(StringBuf* self) { +static void StringBuf_Clear(StringBuf *self) +{ self->ptr_ = self->buf_; } /// Destroys the StringBuf -void StringBuf_Destroy(StringBuf* self) { +static void StringBuf_Destroy(StringBuf *self) +{ aFree(self->buf_); self->ptr_ = self->buf_ = 0; self->max_ = 0; } // Frees a StringBuf returned by StringBuf_Malloc -void StringBuf_Free(StringBuf* self) { +static void StringBuf_Free(StringBuf *self) +{ StrBuf->Destroy(self); aFree(self); } -void strlib_defaults(void) { + +void strlib_defaults(void) +{ /* connect */ strlib = &strlib_s; StrBuf = &stringbuf_s; diff --git a/src/common/sysinfo.c b/src/common/sysinfo.c index 0056aee1e..b8cb2a90a 100644 --- a/src/common/sysinfo.c +++ b/src/common/sysinfo.c @@ -59,8 +59,8 @@ struct sysinfo_private { }; /// sysinfo.c interface source -struct sysinfo_interface sysinfo_s; -struct sysinfo_private sysinfo_p; +static struct sysinfo_interface sysinfo_s; +static struct sysinfo_private sysinfo_p; struct sysinfo_interface *sysinfo; @@ -238,7 +238,7 @@ enum windows_ver_suite { * @retval true if a revision was correctly detected. * @retval false if no revision was detected. out is set to NULL in this case. */ -bool sysinfo_svn_get_revision(char **out) +static bool sysinfo_svn_get_revision(char **out) { // Only include SVN support if detected it, or we're on MSVC #if !defined(SYSINFO_VCSTYPE) || SYSINFO_VCSTYPE == VCSTYPE_SVN || SYSINFO_VCSTYPE == VCSTYPE_UNKNOWN @@ -310,7 +310,7 @@ bool sysinfo_svn_get_revision(char **out) * @retval true if a revision was correctly detected. * @retval false if no revision was detected. out is set to NULL in this case. */ -bool sysinfo_git_get_revision(char **out) +static bool sysinfo_git_get_revision(char **out) { // Only include Git support if we detected it, or we're on MSVC #if !defined(SYSINFO_VCSTYPE) || SYSINFO_VCSTYPE == VCSTYPE_GIT || SYSINFO_VCSTYPE == VCSTYPE_UNKNOWN @@ -359,7 +359,7 @@ typedef BOOL (WINAPI *PGPI)(DWORD, DWORD, DWORD, DWORD, PDWORD); * * Once retrieved, the version string is stored into sysinfo->p->osversion. */ -void sysinfo_osversion_retrieve(void) +static void sysinfo_osversion_retrieve(void) { OSVERSIONINFOEX osvi; StringBuf buf; @@ -611,7 +611,7 @@ typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO); * System info is not stored anywhere after retrieval * @see http://msdn.microsoft.com/en-us/library/windows/desktop/ms724958(v=vs.85).aspx **/ -void sysinfo_systeminfo_retrieve(LPSYSTEM_INFO info) +static void sysinfo_systeminfo_retrieve(LPSYSTEM_INFO info) { PGNSI pGNSI; @@ -629,7 +629,7 @@ void sysinfo_systeminfo_retrieve(LPSYSTEM_INFO info) * Returns number of bytes in a memory page * Only needed when compiling with MSVC **/ -long sysinfo_getpagesize(void) +static long sysinfo_getpagesize(void) { SYSTEM_INFO si; ZeroMemory(&si, sizeof(SYSTEM_INFO)); @@ -644,7 +644,7 @@ long sysinfo_getpagesize(void) * Once retrieved, the name is stored into sysinfo->p->cpu and the * number of cores in sysinfo->p->cpucores. */ -void sysinfo_cpu_retrieve(void) +static void sysinfo_cpu_retrieve(void) { StringBuf buf; SYSTEM_INFO si; @@ -681,7 +681,7 @@ void sysinfo_cpu_retrieve(void) * * Once retrieved, the name is stored into sysinfo->p->arch. */ -void sysinfo_arch_retrieve(void) +static void sysinfo_arch_retrieve(void) { SYSTEM_INFO si; ZeroMemory(&si, sizeof(SYSTEM_INFO)); @@ -710,7 +710,7 @@ void sysinfo_arch_retrieve(void) * * Once retrieved, the value is stored in sysinfo->p->vcsrevision_src. */ -void sysinfo_vcsrevision_src_retrieve(void) +static void sysinfo_vcsrevision_src_retrieve(void) { if (sysinfo->p->vcsrevision_src != NULL) { aFree(sysinfo->p->vcsrevision_src); @@ -735,7 +735,7 @@ void sysinfo_vcsrevision_src_retrieve(void) * * Once retrieved, the value is stored in sysinfo->p->vcstype_name. */ -void sysinfo_vcstype_name_retrieve(void) +static void sysinfo_vcstype_name_retrieve(void) { if (sysinfo->p->vcstype_name != NULL) { aFree(sysinfo->p->vcstype_name); @@ -765,7 +765,7 @@ void sysinfo_vcstype_name_retrieve(void) * * Output example: "Linux", "Darwin", "Windows", etc. */ -const char *sysinfo_platform(void) +static const char *sysinfo_platform(void) { return sysinfo->p->platform; } @@ -784,7 +784,7 @@ const char *sysinfo_platform(void) * Output example: "Windows 2008 Small Business Server", "OS X 10.8 Mountain Lion", * "Gentoo Base System Release 2.2", "Debian GNU/Linux 6.0.6 (squeeze)", etc. */ -const char *sysinfo_osversion(void) +static const char *sysinfo_osversion(void) { return sysinfo->p->osversion; } @@ -804,7 +804,7 @@ const char *sysinfo_osversion(void) * "Intel(R) Xeon(R) CPU E5-1650 0 @ 3.20GHz", "Intel Core i7", * "x86 CPU, Family 6, Model 54, Stepping 1", etc. */ -const char *sysinfo_cpu(void) +static const char *sysinfo_cpu(void) { return sysinfo->p->cpu; } @@ -818,7 +818,7 @@ const char *sysinfo_cpu(void) * * @return the number of CPU cores. */ -int sysinfo_cpucores(void) +static int sysinfo_cpucores(void) { return sysinfo->p->cpucores; } @@ -836,7 +836,7 @@ int sysinfo_cpucores(void) * * Output example: "x86", "x86_64", "IA-64", "ARM", etc. */ -const char *sysinfo_arch(void) +static const char *sysinfo_arch(void) { return sysinfo->p->arch; } @@ -847,7 +847,7 @@ const char *sysinfo_arch(void) * @retval true if this is a 64 bit build. * @retval false if this isn't a 64 bit build (i.e. it is a 32 bit build). */ -bool sysinfo_is64bit(void) +static bool sysinfo_is64bit(void) { #ifdef _LP64 return true; @@ -866,7 +866,7 @@ bool sysinfo_is64bit(void) * Output example: "Microsoft Visual C++ 2012 (v170050727)", * "Clang v5.0.0", "MinGW32 v3.20", "GCC v4.7.3", etc. */ -const char *sysinfo_compiler(void) +static const char *sysinfo_compiler(void) { return sysinfo->p->compiler; } @@ -882,7 +882,7 @@ const char *sysinfo_compiler(void) * * Output example: "-ggdb -O2 -flto -pipe -ffast-math ..." */ -const char *sysinfo_cflags(void) +static const char *sysinfo_cflags(void) { return sysinfo->p->cflags; } @@ -898,7 +898,7 @@ const char *sysinfo_cflags(void) * * @see VCSTYPE_NONE, VCSTYPE_GIT, VCSTYPE_SVN, VCSTYPE_UNKNOWN */ -int sysinfo_vcstypeid(void) +static int sysinfo_vcstypeid(void) { return sysinfo->p->vcstype; } @@ -916,7 +916,7 @@ int sysinfo_vcstypeid(void) * * Output example: "Git", "SVN", "Exported" */ -const char *sysinfo_vcstype(void) +static const char *sysinfo_vcstype(void) { return sysinfo->p->vcstype_name; } @@ -935,7 +935,7 @@ const char *sysinfo_vcstype(void) * * Output example: Git: "9128feccf3bddda94a7f8a170305565416815b40", SVN: "17546" */ -const char *sysinfo_vcsrevision_src(void) +static const char *sysinfo_vcsrevision_src(void) { return sysinfo->p->vcsrevision_src; } @@ -952,7 +952,7 @@ const char *sysinfo_vcsrevision_src(void) * * Output example: Git: "9128feccf3bddda94a7f8a170305565416815b40", SVN: "17546" */ -const char *sysinfo_vcsrevision_scripts(void) +static const char *sysinfo_vcsrevision_scripts(void) { return sysinfo->p->vcsrevision_scripts; } @@ -961,7 +961,7 @@ const char *sysinfo_vcsrevision_scripts(void) * Reloads the run-time (scripts) VCS revision information. To be used during * script reloads to refresh the cached version. */ -void sysinfo_vcsrevision_reload(void) +static void sysinfo_vcsrevision_reload(void) { if (sysinfo->p->vcsrevision_scripts != NULL) { aFree(sysinfo->p->vcsrevision_scripts); @@ -984,7 +984,7 @@ void sysinfo_vcsrevision_reload(void) * @retval false if the current process is running as regular user, or * in any case under Windows. */ -bool sysinfo_is_superuser(void) +static bool sysinfo_is_superuser(void) { #ifndef _WIN32 if (geteuid() == 0) @@ -996,7 +996,7 @@ bool sysinfo_is_superuser(void) /** * Interface runtime initialization. */ -void sysinfo_init(void) +static void sysinfo_init(void) { sysinfo->p->compiler = SYSINFO_COMPILER; #ifdef WIN32 @@ -1023,7 +1023,7 @@ void sysinfo_init(void) /** * Interface shutdown cleanup. */ -void sysinfo_final(void) +static void sysinfo_final(void) { #ifdef WIN32 // Only need to be free'd in win32, they're #defined elsewhere diff --git a/src/common/thread.c b/src/common/thread.c index 2dc7d2682..605153011 100644 --- a/src/common/thread.c +++ b/src/common/thread.c @@ -49,7 +49,7 @@ * @author Florian Wilkemeyer */ -struct thread_interface thread_s; +static struct thread_interface thread_s; struct thread_interface *thread; /// The maximum amount of threads. @@ -70,7 +70,7 @@ struct thread_handle { }; #ifdef HAS_TLS -__thread int g_rathread_ID = -1; +static __thread int g_rathread_ID = -1; #endif // Subystem Code @@ -78,7 +78,7 @@ __thread int g_rathread_ID = -1; static struct thread_handle l_threads[THREADS_MAX]; /// @copydoc thread_interface::init() -void thread_init(void) +static void thread_init(void) { register int i; memset(&l_threads, 0x00, THREADS_MAX * sizeof(struct thread_handle)); @@ -97,7 +97,7 @@ void thread_init(void) } /// @copydoc thread_interface::final() -void thread_final(void) +static void thread_final(void) { register int i; @@ -125,7 +125,7 @@ static void thread_terminated(struct thread_handle *handle) } #ifdef WIN32 -DWORD WINAPI thread_main_redirector(LPVOID p) +static DWORD WINAPI thread_main_redirector(LPVOID p) { #else static void *thread_main_redirector(void *p) @@ -170,13 +170,13 @@ static void *thread_main_redirector(void *p) // API Level /// @copydoc thread_interface::create() -struct thread_handle *thread_create(threadFunc entry_point, void *param) +static struct thread_handle *thread_create(threadFunc entry_point, void *param) { return thread->create_opt(entry_point, param, (1<<23) /*8MB*/, THREADPRIO_NORMAL); } /// @copydoc thread_interface::create_opt() -struct thread_handle *thread_create_opt(threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio) +static struct thread_handle *thread_create_opt(threadFunc entry_point, void *param, size_t stack_size, enum thread_priority prio) { #ifndef WIN32 pthread_attr_t attr; @@ -226,7 +226,7 @@ struct thread_handle *thread_create_opt(threadFunc entry_point, void *param, siz } /// @copydoc thread_interface::destroy() -void thread_destroy(struct thread_handle *handle) +static void thread_destroy(struct thread_handle *handle) { #ifdef WIN32 if (TerminateThread(handle->hThread, 0) != FALSE) { @@ -244,7 +244,7 @@ void thread_destroy(struct thread_handle *handle) #endif } -struct thread_handle *thread_self(void) +static struct thread_handle *thread_self(void) { #ifdef HAS_TLS struct thread_handle *handle = &l_threads[g_rathread_ID]; @@ -273,7 +273,7 @@ struct thread_handle *thread_self(void) } /// @copydoc thread_interface::get_tid() -int thread_get_tid(void) +static int thread_get_tid(void) { #if defined(HAS_TLS) return g_rathread_ID; @@ -285,7 +285,7 @@ int thread_get_tid(void) } /// @copydoc thread_interface::wait() -bool thread_wait(struct thread_handle *handle, void **out_exit_code) +static bool thread_wait(struct thread_handle *handle, void **out_exit_code) { // Hint: // no thread data cleanup routine call here! @@ -302,20 +302,21 @@ bool thread_wait(struct thread_handle *handle, void **out_exit_code) } /// @copydoc thread_interface::prio_set() -void thread_prio_set(struct thread_handle *handle, enum thread_priority prio) +static void thread_prio_set(struct thread_handle *handle, enum thread_priority prio) { handle->prio = THREADPRIO_NORMAL; //@TODO } /// @copydoc thread_interface::prio_get() -enum thread_priority thread_prio_get(struct thread_handle *handle) +static enum thread_priority thread_prio_get(struct thread_handle *handle) { return handle->prio; } /// @copydoc thread_interface::yield() -void thread_yield(void) { +static void thread_yield(void) +{ #ifdef WIN32 SwitchToThread(); #else diff --git a/src/common/timer.c b/src/common/timer.c index ad11bc18d..d5f9c83d1 100644 --- a/src/common/timer.c +++ b/src/common/timer.c @@ -40,7 +40,7 @@ #include #include -struct timer_interface timer_s; +static struct timer_interface timer_s; struct timer_interface *timer; // If the server can't handle processing thousands of monsters @@ -54,7 +54,7 @@ static int timer_data_max = 0; static int timer_data_num = 1; // free timers (array) -static int* free_timer_list = NULL; +static int *free_timer_list = NULL; static int free_timer_list_max = 0; static int free_timer_list_pos = 0; @@ -72,20 +72,21 @@ static BHEAP_VAR(int, timer_heap); // server startup time -time_t start_time; +static time_t start_time; /*---------------------------- * Timer debugging *----------------------------*/ -struct timer_func_list { +static struct timer_func_list { struct timer_func_list* next; TimerFunc func; char* name; } *tfl_root = NULL; /// Sets the name of a timer function. -int timer_add_func_list(TimerFunc func, char* name) { +static int timer_add_func_list(TimerFunc func, char *name) +{ struct timer_func_list* tfl; nullpo_ret(func); @@ -108,7 +109,7 @@ int timer_add_func_list(TimerFunc func, char* name) { } /// Returns the name of the timer function. -char* search_timer_func_list(TimerFunc func) +static char *search_timer_func_list(TimerFunc func) { struct timer_func_list* tfl; @@ -124,9 +125,11 @@ char* search_timer_func_list(TimerFunc func) *----------------------------*/ #if defined(ENABLE_RDTSC) -static uint64 RDTSC_BEGINTICK = 0, RDTSC_CLOCK = 0; +static uint64 RDTSC_BEGINTICK = 0; +static uint64 RDTSC_CLOCK = 0; -static __inline uint64 rdtsc_(void) { +static __inline uint64 rdtsc_(void) +{ register union { uint64 qw; uint32 dw[2]; @@ -137,7 +140,8 @@ static __inline uint64 rdtsc_(void) { return t.qw; } -static void rdtsc_calibrate(void){ +static void rdtsc_calibrate(void) +{ uint64 t1, t2; int32 i; @@ -164,7 +168,8 @@ static void rdtsc_calibrate(void){ * platform-abstracted tick retrieval * @return server's current tick */ -static int64 sys_tick(void) { +static int64 sys_tick(void) +{ #if defined(WIN32) // Windows: GetTickCount/GetTickCount64: Return the number of // milliseconds that have elapsed since the system was started. @@ -226,25 +231,28 @@ static int64 sys_tick(void) { static int64 gettick_cache; static int gettick_count = 1; -int64 timer_gettick_nocache(void) { +static int64 timer_gettick_nocache(void) +{ gettick_count = TICK_CACHE; gettick_cache = sys_tick(); return gettick_cache; } -int64 timer_gettick(void) { +static int64 timer_gettick(void) +{ return ( --gettick_count == 0 ) ? gettick_nocache() : gettick_cache; } ////////////////////////////// #else ////////////////////////////// // tick doesn't get cached -int64 timer_gettick_nocache(void) +static int64 timer_gettick_nocache(void) { return sys_tick(); } -int64 timer_gettick(void) { +static int64 timer_gettick(void) +{ return sys_tick(); } ////////////////////////////////////////////////////////////////////////// @@ -256,7 +264,8 @@ int64 timer_gettick(void) { *--------------------------------------*/ /// Adds a timer to the timer_heap -static void push_timer_heap(int tid) { +static void push_timer_heap(int tid) +{ BHEAP_ENSURE(timer_heap, 1, 256); BHEAP_PUSH(timer_heap, tid, DIFFTICK_MINTOPCMP, swap); } @@ -266,7 +275,8 @@ static void push_timer_heap(int tid) { *--------------------------*/ /// Returns a free timer id. -static int acquire_timer(void) { +static int acquire_timer(void) +{ int tid; // select a free timer @@ -299,7 +309,8 @@ static int acquire_timer(void) { /// Starts a new timer that is deleted once it expires (single-use). /// Returns the timer's id. -int timer_add(int64 tick, TimerFunc func, int id, intptr_t data) { +static int timer_add(int64 tick, TimerFunc func, int id, intptr_t data) +{ int tid; nullpo_retr(INVALID_TIMER, func); @@ -328,7 +339,7 @@ int timer_add(int64 tick, TimerFunc func, int id, intptr_t data) { /// Starts a new timer that automatically restarts itself (infinite loop until manually removed). /// Returns the timer's id, or INVALID_TIMER if it fails. -int timer_add_interval(int64 tick, TimerFunc func, int id, intptr_t data, int interval) +static int timer_add_interval(int64 tick, TimerFunc func, int id, intptr_t data, int interval) { int tid; @@ -364,7 +375,8 @@ int timer_add_interval(int64 tick, TimerFunc func, int id, intptr_t data, int in } /// Retrieves internal timer data -const struct TimerData* timer_get(int tid) { +static const struct TimerData *timer_get(int tid) +{ Assert_retr(NULL, tid > 0); return ( tid >= 0 && tid < timer_data_num ) ? &timer_data[tid] : NULL; } @@ -372,7 +384,7 @@ const struct TimerData* timer_get(int tid) { /// Marks a timer specified by 'id' for immediate deletion once it expires. /// Param 'func' is used for debug/verification purposes. /// Returns 0 on success, < 0 on failure. -int timer_do_delete(int tid, TimerFunc func) +static int timer_do_delete(int tid, TimerFunc func) { nullpo_ret(func); @@ -402,7 +414,8 @@ int timer_do_delete(int tid, TimerFunc func) /// Adjusts a timer's expiration time. /// Returns the new tick value, or -1 if it fails. -int64 timer_addtick(int tid, int64 tick) { +static int64 timer_addtick(int tid, int64 tick) +{ if (tid < 1 || tid >= timer_data_num) { ShowError("timer_addtick error : no such timer [%d]\n", tid); Assert_retr(-1, 0); @@ -419,7 +432,7 @@ int64 timer_addtick(int tid, int64 tick) { * @return The new tick value. * @retval -1 in case of failure. */ -int64 timer_settick(int tid, int64 tick) +static int64 timer_settick(int tid, int64 tick) { int i; @@ -461,7 +474,7 @@ int64 timer_settick(int tid, int64 tick) * @param tick The current tick. * @return The value of the smallest non-expired timer (or 1 second if there aren't any). */ -int do_timer(int64 tick) +static int do_timer(int64 tick) { int64 diff = TIMER_MAX_INTERVAL; // return value @@ -515,11 +528,12 @@ int do_timer(int64 tick) return (int)cap_value(diff, TIMER_MIN_INTERVAL, TIMER_MAX_INTERVAL); } -unsigned long timer_get_uptime(void) { +static unsigned long timer_get_uptime(void) +{ return (unsigned long)difftime(time(NULL), start_time); } -void timer_init(void) +static void timer_init(void) { #if defined(ENABLE_RDTSC) rdtsc_calibrate(); @@ -528,7 +542,8 @@ void timer_init(void) time(&start_time); } -void timer_final(void) { +static void timer_final(void) +{ struct timer_func_list *tfl; struct timer_func_list *next; @@ -542,12 +557,14 @@ void timer_final(void) { BHEAP_CLEAR(timer_heap); if (free_timer_list) aFree(free_timer_list); } + /*===================================== -* Default Functions : timer.h -* Generated by HerculesInterfaceMaker -* created by Susu -*-------------------------------------*/ -void timer_defaults(void) { + * Default Functions : timer.h + * Generated by HerculesInterfaceMaker + * created by Susu + *-------------------------------------*/ +void timer_defaults(void) +{ timer = &timer_s; /* funcs */ diff --git a/src/common/utils.c b/src/common/utils.c index 44f3087c3..d4c838b56 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -45,11 +45,11 @@ #include #include // cache purposes [Ind/Hercules] -struct HCache_interface HCache_s; +static struct HCache_interface HCache_s; struct HCache_interface *HCache; /// Dumps given buffer into file pointed to by a handle. -void WriteDump(FILE* fp, const void* buffer, size_t length) +void WriteDump(FILE *fp, const void *buffer, size_t length) { size_t i; char hex[48+1], ascii[16+1]; @@ -109,7 +109,7 @@ void ShowDump(const void *buffer, size_t length) #ifdef WIN32 -static char* checkpath(char *path, const char *srcpath) +static char *checkpath(char *path, const char *srcpath) { // just make sure the char*path is not const char *p = path; @@ -128,7 +128,7 @@ static char* checkpath(char *path, const char *srcpath) return path; } -void findfile(const char *p, const char *pat, void (func)(const char*)) +void findfile(const char *p, const char *pat, void (func)(const char *)) { WIN32_FIND_DATAA FindFileData; HANDLE hFind; @@ -171,7 +171,7 @@ void findfile(const char *p, const char *pat, void (func)(const char*)) #define MAX_DIR_PATH 2048 -static char* checkpath(char *path, const char*srcpath) +static char *checkpath(char *path, const char *srcpath) { // just make sure the char*path is not const char *p=path; @@ -190,7 +190,7 @@ static char* checkpath(char *path, const char*srcpath) return path; } -void findfile(const char *p, const char *pat, void (func)(const char*)) +void findfile(const char *p, const char *pat, void (func)(const char *)) { DIR* dir; ///< pointer to the scanned directory. struct dirent* entry; ///< pointer to one directory entry. @@ -238,7 +238,7 @@ void findfile(const char *p, const char *pat, void (func)(const char*)) } #endif -bool exists(const char* filename) +bool exists(const char *filename) { return !access(filename, F_OK); } @@ -309,14 +309,14 @@ int32 MakeLongLE(int32 val) } // Reads an uint16 in little-endian from the buffer -uint16 GetUShort(const unsigned char* buf) +uint16 GetUShort(const unsigned char *buf) { return ( ((uint16)(buf[0])) ) | ( ((uint16)(buf[1])) << 0x08 ); } // Reads an uint32 in little-endian from the buffer -uint32 GetULong(const unsigned char* buf) +uint32 GetULong(const unsigned char *buf) { return ( ((uint32)(buf[0])) ) | ( ((uint32)(buf[1])) << 0x08 ) @@ -325,13 +325,13 @@ uint32 GetULong(const unsigned char* buf) } // Reads an int32 in little-endian from the buffer -int32 GetLong(const unsigned char* buf) +int32 GetLong(const unsigned char *buf) { return (int32)GetULong(buf); } // Reads a float (32 bits) from the buffer -float GetFloat(const unsigned char* buf) +float GetFloat(const unsigned char *buf) { uint32 val = GetULong(buf); return *((float*)(void*)&val); @@ -426,7 +426,7 @@ int apply_percentrate(int value, int rate, int maxrate) //----------------------------------------------------- // custom timestamp formatting (from eApp) //----------------------------------------------------- -const char* timestamp2string(char* str, size_t size, time_t timestamp, const char* format) +const char *timestamp2string(char *str, size_t size, time_t timestamp, const char *format) { size_t len; nullpo_retr(NULL, str); @@ -436,7 +436,7 @@ const char* timestamp2string(char* str, size_t size, time_t timestamp, const cha } /* [Ind/Hercules] Caching */ -bool HCache_check(const char *file) +static bool HCache_check(const char *file) { struct stat bufa, bufb; FILE *first, *second; @@ -487,7 +487,7 @@ bool HCache_check(const char *file) return true; } -FILE *HCache_open(const char *file, const char *opt) +static FILE *HCache_open(const char *file, const char *opt) { FILE *first; char s_path[255]; @@ -520,7 +520,7 @@ FILE *HCache_open(const char *file, const char *opt) return first; } -void HCache_init(void) +static void HCache_init(void) { struct stat buf; if (stat(SERVER_NAME, &buf) != 0) { -- cgit v1.2.3-70-g09d2 From 2e89d5b2824801ed49c62db9f6743f32593018bc Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 24 Jun 2018 05:11:00 +0200 Subject: Fix some warnings caused by static functions defined and unused Signed-off-by: Haru --- src/common/showmsg.c | 2 ++ src/common/socket.c | 10 ++++------ src/common/strlib.c | 9 --------- 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/common/showmsg.c b/src/common/showmsg.c index 91f84e9d3..32d1e7610 100644 --- a/src/common/showmsg.c +++ b/src/common/showmsg.c @@ -739,6 +739,7 @@ static void showmsg_clearScreen(void) #endif } +#if 0 // Unused static int ShowMessage_(enum msg_type flag, const char *string, ...) __attribute__((format(printf, 2, 3))); static int ShowMessage_(enum msg_type flag, const char *string, ...) { @@ -749,6 +750,7 @@ static int ShowMessage_(enum msg_type flag, const char *string, ...) va_end(ap); return ret; } +#endif // Unused // direct printf replacement static void showmsg_showMessage(const char *string, ...) __attribute__((format(printf, 1, 2))); diff --git a/src/common/socket.c b/src/common/socket.c index 6119a5341..290c7a1b3 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -78,8 +78,6 @@ static struct socket_interface sockt_s; struct socket_interface *sockt; -static struct socket_data **session; - static const char *SOCKET_CONF_FILENAME = "conf/common/socket.conf"; #ifdef SEND_SHORTLIST @@ -1332,6 +1330,7 @@ static bool access_list_add(struct config_setting_t *setting, const char *list_n #endif // MINICORE ////////////////////////////// +#ifndef MINICORE /** * Reads 'socket_configuration/ip_rules' and initializes required variables. * @@ -1343,7 +1342,6 @@ static bool access_list_add(struct config_setting_t *setting, const char *list_n */ static bool socket_config_read_iprules(const char *filename, struct config_t *config, bool imported) { -#ifndef MINICORE struct config_setting_t *setting = NULL; const char *temp = NULL; @@ -1386,11 +1384,12 @@ static bool socket_config_read_iprules(const char *filename, struct config_t *co } else { access_list_add(setting, "deny_list", &access_deny); } -#endif // ! MINICORE return true; } +#endif // ! MINICORE +#ifndef MINICORE /** * Reads 'socket_configuration/ddos' and initializes required variables. * @@ -1402,7 +1401,6 @@ static bool socket_config_read_iprules(const char *filename, struct config_t *co */ static bool socket_config_read_ddos(const char *filename, struct config_t *config, bool imported) { -#ifndef MINICORE struct config_setting_t *setting = NULL; nullpo_retr(false, filename); @@ -1419,9 +1417,9 @@ static bool socket_config_read_ddos(const char *filename, struct config_t *confi libconfig->setting_lookup_int(setting, "count", &ddos_count); libconfig->setting_lookup_int(setting, "autoreset", &ddos_autoreset); -#endif // ! MINICORE return true; } +#endif // ! MINICORE /** * Reads 'socket_configuration' and initializes required variables. diff --git a/src/common/strlib.c b/src/common/strlib.c index c9448177b..ddb1eb78a 100644 --- a/src/common/strlib.c +++ b/src/common/strlib.c @@ -1137,17 +1137,8 @@ void strlib_defaults(void) strlib->normalize_name_ = strlib_normalize_name; strlib->stristr_ = strlib_stristr; -#if !(defined(WIN32) && defined(_MSC_VER)) && !defined(HAVE_STRNLEN) strlib->strnlen_ = strlib_strnlen; -#else - strlib->strnlen_ = NULL; -#endif - -#ifdef WIN32 strlib->strtok_r_ = strlib_strtok_r; -#else - strlib->strtok_r_ = NULL; -#endif strlib->e_mail_check_ = strlib_e_mail_check; strlib->config_switch_ = strlib_config_switch; -- cgit v1.2.3-70-g09d2 From 4552fc0eab5cd9b723180a12d4ef50f7fe998b55 Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 24 Jun 2018 05:19:37 +0200 Subject: Change functions to static where possible (Part 2 - login) This fixes issues with plugins defining symbols with the same names Signed-off-by: Haru --- src/login/account.c | 46 +++++++-------- src/login/ipban.c | 26 +++++---- src/login/lclif.c | 80 ++++++++++++------------- src/login/login.c | 162 ++++++++++++++++++++++++++------------------------- src/login/loginlog.c | 18 +++--- 5 files changed, 169 insertions(+), 163 deletions(-) diff --git a/src/login/account.c b/src/login/account.c index 6308a73d1..783cf85ea 100644 --- a/src/login/account.c +++ b/src/login/account.c @@ -39,11 +39,11 @@ /// global defines #define ACCOUNT_SQL_DB_VERSION 20110114 -struct account_interface account_s; +static struct account_interface account_s; struct account_interface *account; /// public constructor -AccountDB* account_db_sql(void) +static AccountDB *account_db_sql(void) { AccountDB_SQL* db = (AccountDB_SQL*)aCalloc(1, sizeof(AccountDB_SQL)); @@ -80,7 +80,7 @@ AccountDB* account_db_sql(void) /* ------------------------------------------------------------------------- */ /// establishes database connection -static bool account_db_sql_init(AccountDB* self) +static bool account_db_sql_init(AccountDB *self) { AccountDB_SQL* db = (AccountDB_SQL*)self; struct Sql *sql_handle = NULL; @@ -109,7 +109,7 @@ static bool account_db_sql_init(AccountDB* self) } /// disconnects from database -static void account_db_sql_destroy(AccountDB* self) +static void account_db_sql_destroy(AccountDB *self) { AccountDB_SQL* db = (AccountDB_SQL*)self; @@ -120,7 +120,7 @@ static void account_db_sql_destroy(AccountDB* self) } /// Gets a property from this database. -static bool account_db_sql_get_property(AccountDB* self, const char* key, char* buf, size_t buflen) +static bool account_db_sql_get_property(AccountDB *self, const char *key, char *buf, size_t buflen) { /* TODO: * This functionality is not being used as of now, it was removed in @@ -206,7 +206,7 @@ static bool account_db_sql_get_property(AccountDB* self, const char* key, char* * * @retval false in case of error. */ -bool account_db_read_inter(AccountDB_SQL *db, const char *filename, bool imported) +static bool account_db_read_inter(AccountDB_SQL *db, const char *filename, bool imported) { struct config_t config; struct config_setting_t *setting = NULL; @@ -251,7 +251,7 @@ bool account_db_read_inter(AccountDB_SQL *db, const char *filename, bool importe * * @retval false in case of error. */ -static bool account_db_sql_set_property(AccountDB* self, struct config_t *config, bool imported) +static bool account_db_sql_set_property(AccountDB *self, struct config_t *config, bool imported) { AccountDB_SQL* db = (AccountDB_SQL*)self; struct config_setting_t *setting = NULL; @@ -283,7 +283,7 @@ static bool account_db_sql_set_property(AccountDB* self, struct config_t *config /// create a new account entry /// If acc->account_id is -1, the account id will be auto-generated, /// and its value will be written to acc->account_id if everything succeeds. -static bool account_db_sql_create(AccountDB* self, struct mmo_account* acc) +static bool account_db_sql_create(AccountDB *self, struct mmo_account *acc) { AccountDB_SQL* db = (AccountDB_SQL*)self; struct Sql *sql_handle; @@ -337,7 +337,7 @@ static bool account_db_sql_create(AccountDB* self, struct mmo_account* acc) } /// delete an existing account entry + its regs -static bool account_db_sql_remove(AccountDB* self, const int account_id) +static bool account_db_sql_remove(AccountDB *self, const int account_id) { AccountDB_SQL* db = (AccountDB_SQL*)self; struct Sql *sql_handle; @@ -360,21 +360,21 @@ static bool account_db_sql_remove(AccountDB* self, const int account_id) } /// update an existing account with the provided new data (both account and regs) -static bool account_db_sql_save(AccountDB* self, const struct mmo_account* acc) +static bool account_db_sql_save(AccountDB *self, const struct mmo_account *acc) { AccountDB_SQL* db = (AccountDB_SQL*)self; return account->mmo_auth_tosql(db, acc, false); } /// retrieve data from db and store it in the provided data structure -static bool account_db_sql_load_num(AccountDB* self, struct mmo_account* acc, const int account_id) +static bool account_db_sql_load_num(AccountDB *self, struct mmo_account *acc, const int account_id) { AccountDB_SQL* db = (AccountDB_SQL*)self; return account->mmo_auth_fromsql(db, acc, account_id); } /// retrieve data from db and store it in the provided data structure -static bool account_db_sql_load_str(AccountDB* self, struct mmo_account* acc, const char* userid) +static bool account_db_sql_load_str(AccountDB *self, struct mmo_account *acc, const char *userid) { AccountDB_SQL* db = (AccountDB_SQL*)self; struct Sql *sql_handle; @@ -413,9 +413,8 @@ static bool account_db_sql_load_str(AccountDB* self, struct mmo_account* acc, co return account->db_sql_load_num(self, acc, account_id); } - /// Returns a new forward iterator. -static AccountDBIterator* account_db_sql_iterator(AccountDB* self) +static AccountDBIterator *account_db_sql_iterator(AccountDB *self) { AccountDB_SQL* db = (AccountDB_SQL*)self; AccountDBIterator_SQL* iter; @@ -435,15 +434,14 @@ static AccountDBIterator* account_db_sql_iterator(AccountDB* self) /// Destroys this iterator, releasing all allocated memory (including itself). -static void account_db_sql_iter_destroy(AccountDBIterator* self) +static void account_db_sql_iter_destroy(AccountDBIterator *self) { AccountDBIterator_SQL* iter = (AccountDBIterator_SQL*)self; aFree(iter); } - /// Fetches the next account in the database. -static bool account_db_sql_iter_next(AccountDBIterator* self, struct mmo_account* acc) +static bool account_db_sql_iter_next(AccountDBIterator *self, struct mmo_account *acc) { AccountDBIterator_SQL* iter = (AccountDBIterator_SQL*)self; AccountDB_SQL* db; @@ -478,8 +476,7 @@ static bool account_db_sql_iter_next(AccountDBIterator* self, struct mmo_account return false; } - -static bool account_mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, int account_id) +static bool account_mmo_auth_fromsql(AccountDB_SQL *db, struct mmo_account *acc, int account_id) { struct Sql *sql_handle; char* data; @@ -524,7 +521,7 @@ static bool account_mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, return true; } -static bool account_mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* acc, bool is_new) +static bool account_mmo_auth_tosql(AccountDB_SQL *db, const struct mmo_account *acc, bool is_new) { struct Sql *sql_handle; struct SqlStmt *stmt; @@ -619,13 +616,13 @@ static bool account_mmo_auth_tosql(AccountDB_SQL* db, const struct mmo_account* return result; } -struct Sql *account_db_sql_up(AccountDB* self) +static struct Sql *account_db_sql_up(AccountDB *self) { AccountDB_SQL* db = (AccountDB_SQL*)self; return db ? db->accounts : NULL; } -void account_mmo_save_accreg2(AccountDB* self, int fd, int account_id, int char_id) +static void account_mmo_save_accreg2(AccountDB *self, int fd, int account_id, int char_id) { struct Sql *sql_handle; AccountDB_SQL* db = (AccountDB_SQL*)self; @@ -677,7 +674,7 @@ void account_mmo_save_accreg2(AccountDB* self, int fd, int account_id, int char_ } } -void account_mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) +static void account_mmo_send_accreg2(AccountDB *self, int fd, int account_id, int char_id) { struct Sql *sql_handle; AccountDB_SQL* db = (AccountDB_SQL*)self; @@ -822,7 +819,8 @@ void account_mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_ SQL->FreeResult(sql_handle); } -void account_defaults(void) { +void account_defaults(void) +{ account = &account_s; account->db_sql_up = account_db_sql_up; diff --git a/src/login/ipban.c b/src/login/ipban.c index 140e0dda6..32ee1a19b 100644 --- a/src/login/ipban.c +++ b/src/login/ipban.c @@ -34,12 +34,12 @@ #include -struct ipban_interface ipban_s; +static struct ipban_interface ipban_s; struct ipban_interface *ipban; -struct s_ipban_dbs ipbandbs; +static struct s_ipban_dbs ipbandbs; // initialize -void ipban_init(void) +static void ipban_init(void) { ipban->inited = true; @@ -68,7 +68,7 @@ void ipban_init(void) } // finalize -void ipban_final(void) +static void ipban_final(void) { if (!login->config->ipban) return;// ipban disabled @@ -94,7 +94,7 @@ void ipban_final(void) * @retval false in case of error. */ -bool ipban_config_read_inter(const char *filename, bool imported) +static bool ipban_config_read_inter(const char *filename, bool imported) { struct config_t config; struct config_setting_t *setting = NULL; @@ -138,7 +138,7 @@ bool ipban_config_read_inter(const char *filename, bool imported) * * @retval false in case of error. */ -bool ipban_config_read_connection(const char *filename, struct config_t *config, bool imported) +static bool ipban_config_read_connection(const char *filename, struct config_t *config, bool imported) { struct config_setting_t *setting = NULL; @@ -172,7 +172,7 @@ bool ipban_config_read_connection(const char *filename, struct config_t *config, * * @retval false in case of error. */ -bool ipban_config_read_dynamic(const char *filename, struct config_t *config, bool imported) +static bool ipban_config_read_dynamic(const char *filename, struct config_t *config, bool imported) { struct config_setting_t *setting = NULL; @@ -203,7 +203,7 @@ bool ipban_config_read_dynamic(const char *filename, struct config_t *config, bo * * @retval false in case of error. */ -bool ipban_config_read(const char *filename, struct config_t *config, bool imported) +static bool ipban_config_read(const char *filename, struct config_t *config, bool imported) { struct config_setting_t *setting = NULL; bool retval = true; @@ -234,7 +234,7 @@ bool ipban_config_read(const char *filename, struct config_t *config, bool impor } // check ip against active bans list -bool ipban_check(uint32 ip) +static bool ipban_check(uint32 ip) { uint8* p = (uint8*)&ip; char* data = NULL; @@ -262,7 +262,7 @@ bool ipban_check(uint32 ip) } // log failed attempt -void ipban_log(uint32 ip) +static void ipban_log(uint32 ip) { unsigned long failures; @@ -284,7 +284,8 @@ void ipban_log(uint32 ip) } // remove expired bans -int ipban_cleanup(int tid, int64 tick, int id, intptr_t data) { +static int ipban_cleanup(int tid, int64 tick, int id, intptr_t data) +{ if (!login->config->ipban) return 0;// ipban disabled @@ -294,7 +295,8 @@ int ipban_cleanup(int tid, int64 tick, int id, intptr_t data) { return 0; } -void ipban_defaults(void) { +void ipban_defaults(void) +{ ipban = &ipban_s; ipban->dbs = &ipbandbs; diff --git a/src/login/lclif.c b/src/login/lclif.c index f514932a2..f8fd30105 100644 --- a/src/login/lclif.c +++ b/src/login/lclif.c @@ -41,13 +41,13 @@ * Implementation of the login client interface. */ -struct lclif_interface lclif_s; -struct lclif_interface_private lclif_p; -struct lclif_interface_dbs lclif_dbs; +static struct lclif_interface lclif_s; +static struct lclif_interface_private lclif_p; +static struct lclif_interface_dbs lclif_dbs; struct lclif_interface *lclif; /// @copydoc lclif_interface::connection_error() -void lclif_connection_error(int fd, uint8 error) +static void lclif_connection_error(int fd, uint8 error) { struct packet_SC_NOTIFY_BAN *packet = NULL; WFIFOHEAD(fd, sizeof(*packet)); @@ -58,15 +58,15 @@ void lclif_connection_error(int fd, uint8 error) } /// @copydoc lclif_interface_private::parse_CA_CONNECT_INFO_CHANGED() -enum parsefunc_rcode lclif_parse_CA_CONNECT_INFO_CHANGED(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -enum parsefunc_rcode lclif_parse_CA_CONNECT_INFO_CHANGED(int fd, struct login_session_data *sd) +static enum parsefunc_rcode lclif_parse_CA_CONNECT_INFO_CHANGED(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +static enum parsefunc_rcode lclif_parse_CA_CONNECT_INFO_CHANGED(int fd, struct login_session_data *sd) { return PACKET_VALID; } /// @copydoc lclif_interface_private::parse_CA_EXE_HASHCHECK() -enum parsefunc_rcode lclif_parse_CA_EXE_HASHCHECK(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -enum parsefunc_rcode lclif_parse_CA_EXE_HASHCHECK(int fd, struct login_session_data *sd) +static enum parsefunc_rcode lclif_parse_CA_EXE_HASHCHECK(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +static enum parsefunc_rcode lclif_parse_CA_EXE_HASHCHECK(int fd, struct login_session_data *sd) { const struct packet_CA_EXE_HASHCHECK *packet = RP2PTR(fd); sd->has_client_hash = 1; @@ -75,8 +75,8 @@ enum parsefunc_rcode lclif_parse_CA_EXE_HASHCHECK(int fd, struct login_session_d } /// @copydoc lclif_interface_private::parse_CA_LOGIN() -enum parsefunc_rcode lclif_parse_CA_LOGIN(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -enum parsefunc_rcode lclif_parse_CA_LOGIN(int fd, struct login_session_data *sd) +static enum parsefunc_rcode lclif_parse_CA_LOGIN(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +static enum parsefunc_rcode lclif_parse_CA_LOGIN(int fd, struct login_session_data *sd) { const struct packet_CA_LOGIN *packet = RP2PTR(fd); @@ -94,8 +94,8 @@ enum parsefunc_rcode lclif_parse_CA_LOGIN(int fd, struct login_session_data *sd) } /// @copydoc lclif_interface_private::parse_CA_LOGIN2() -enum parsefunc_rcode lclif_parse_CA_LOGIN2(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -enum parsefunc_rcode lclif_parse_CA_LOGIN2(int fd, struct login_session_data *sd) +static enum parsefunc_rcode lclif_parse_CA_LOGIN2(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +static enum parsefunc_rcode lclif_parse_CA_LOGIN2(int fd, struct login_session_data *sd) { const struct packet_CA_LOGIN2 *packet = RP2PTR(fd); @@ -110,8 +110,8 @@ enum parsefunc_rcode lclif_parse_CA_LOGIN2(int fd, struct login_session_data *sd } /// @copydoc lclif_interface_private::parse_CA_LOGIN3() -enum parsefunc_rcode lclif_parse_CA_LOGIN3(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -enum parsefunc_rcode lclif_parse_CA_LOGIN3(int fd, struct login_session_data *sd) +static enum parsefunc_rcode lclif_parse_CA_LOGIN3(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +static enum parsefunc_rcode lclif_parse_CA_LOGIN3(int fd, struct login_session_data *sd) { const struct packet_CA_LOGIN3 *packet = RP2PTR(fd); @@ -128,8 +128,8 @@ enum parsefunc_rcode lclif_parse_CA_LOGIN3(int fd, struct login_session_data *sd } /// @copydoc lclif_interface_private::parse_CA_LOGIN4() -enum parsefunc_rcode lclif_parse_CA_LOGIN4(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -enum parsefunc_rcode lclif_parse_CA_LOGIN4(int fd, struct login_session_data *sd) +static enum parsefunc_rcode lclif_parse_CA_LOGIN4(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +static enum parsefunc_rcode lclif_parse_CA_LOGIN4(int fd, struct login_session_data *sd) { const struct packet_CA_LOGIN4 *packet = RP2PTR(fd); @@ -146,8 +146,8 @@ enum parsefunc_rcode lclif_parse_CA_LOGIN4(int fd, struct login_session_data *sd } /// @copydoc lclif_interface_private::parse_CA_LOGIN_PCBANG() -enum parsefunc_rcode lclif_parse_CA_LOGIN_PCBANG(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -enum parsefunc_rcode lclif_parse_CA_LOGIN_PCBANG(int fd, struct login_session_data *sd) +static enum parsefunc_rcode lclif_parse_CA_LOGIN_PCBANG(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +static enum parsefunc_rcode lclif_parse_CA_LOGIN_PCBANG(int fd, struct login_session_data *sd) { const struct packet_CA_LOGIN_PCBANG *packet = RP2PTR(fd); @@ -168,8 +168,8 @@ enum parsefunc_rcode lclif_parse_CA_LOGIN_PCBANG(int fd, struct login_session_da } /// @copydoc lclif_interface_private::parse_CA_LOGIN_HAN() -enum parsefunc_rcode lclif_parse_CA_LOGIN_HAN(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -enum parsefunc_rcode lclif_parse_CA_LOGIN_HAN(int fd, struct login_session_data *sd) +static enum parsefunc_rcode lclif_parse_CA_LOGIN_HAN(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +static enum parsefunc_rcode lclif_parse_CA_LOGIN_HAN(int fd, struct login_session_data *sd) { const struct packet_CA_LOGIN_HAN *packet = RP2PTR(fd); @@ -191,8 +191,8 @@ enum parsefunc_rcode lclif_parse_CA_LOGIN_HAN(int fd, struct login_session_data } /// @copydoc lclif_interface_private::parse_CA_SSO_LOGIN_REQ() -enum parsefunc_rcode lclif_parse_CA_SSO_LOGIN_REQ(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -enum parsefunc_rcode lclif_parse_CA_SSO_LOGIN_REQ(int fd, struct login_session_data *sd) +static enum parsefunc_rcode lclif_parse_CA_SSO_LOGIN_REQ(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +static enum parsefunc_rcode lclif_parse_CA_SSO_LOGIN_REQ(int fd, struct login_session_data *sd) { const struct packet_CA_SSO_LOGIN_REQ *packet = RP2PTR(fd); int tokenlen = (int)RFIFOREST(fd) - (int)sizeof(*packet); @@ -217,8 +217,8 @@ enum parsefunc_rcode lclif_parse_CA_SSO_LOGIN_REQ(int fd, struct login_session_d } /// @copydoc lclif_interface_private::parse_CA_LOGIN_OTP() -enum parsefunc_rcode lclif_parse_CA_LOGIN_OTP(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -enum parsefunc_rcode lclif_parse_CA_LOGIN_OTP(int fd, struct login_session_data *sd) +static enum parsefunc_rcode lclif_parse_CA_LOGIN_OTP(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +static enum parsefunc_rcode lclif_parse_CA_LOGIN_OTP(int fd, struct login_session_data *sd) { //const struct packet_CA_LOGIN_OTP *packet = RP2PTR(fd); login->client_login_otp(fd, sd); @@ -226,8 +226,8 @@ enum parsefunc_rcode lclif_parse_CA_LOGIN_OTP(int fd, struct login_session_data } /// @copydoc lclif_interface_private::parse_CA_REQ_HASH() -enum parsefunc_rcode lclif_parse_CA_REQ_HASH(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -enum parsefunc_rcode lclif_parse_CA_REQ_HASH(int fd, struct login_session_data *sd) +static enum parsefunc_rcode lclif_parse_CA_REQ_HASH(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +static enum parsefunc_rcode lclif_parse_CA_REQ_HASH(int fd, struct login_session_data *sd) { memset(sd->md5key, '\0', sizeof(sd->md5key)); sd->md5keylen = (uint16)(12 + rnd() % 4); @@ -238,8 +238,8 @@ enum parsefunc_rcode lclif_parse_CA_REQ_HASH(int fd, struct login_session_data * } /// @copydoc lclif_interface_private::parse_CA_CHARSERVERCONNECT() -enum parsefunc_rcode lclif_parse_CA_CHARSERVERCONNECT(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -enum parsefunc_rcode lclif_parse_CA_CHARSERVERCONNECT(int fd, struct login_session_data *sd) +static enum parsefunc_rcode lclif_parse_CA_CHARSERVERCONNECT(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +static enum parsefunc_rcode lclif_parse_CA_CHARSERVERCONNECT(int fd, struct login_session_data *sd) { char ip[16]; uint32 ipl = sockt->session[fd]->client_addr; @@ -251,7 +251,7 @@ enum parsefunc_rcode lclif_parse_CA_CHARSERVERCONNECT(int fd, struct login_sessi } /// @copydoc lclif_interface::server_list() -bool lclif_send_server_list(struct login_session_data *sd) +static bool lclif_send_server_list(struct login_session_data *sd) { int server_num = 0, i, n, length; uint32 ip; @@ -309,7 +309,7 @@ bool lclif_send_server_list(struct login_session_data *sd) } /// @copydoc lclif_interface::auth_failed() -void lclif_send_auth_failed(int fd, time_t ban, uint32 error) +static void lclif_send_auth_failed(int fd, time_t ban, uint32 error) { #if PACKETVER_ZERO_NUM >= 20180627 struct packet_AC_REFUSE_LOGIN_R2 *packet = NULL; @@ -333,7 +333,7 @@ void lclif_send_auth_failed(int fd, time_t ban, uint32 error) } /// @copydoc lclif_interface::login_error() -void lclif_send_login_error(int fd, uint8 error) +static void lclif_send_login_error(int fd, uint8 error) { struct packet_AC_REFUSE_LOGIN *packet = NULL; WFIFOHEAD(fd, sizeof(*packet)); @@ -345,8 +345,8 @@ void lclif_send_login_error(int fd, uint8 error) } /// @copydoc lclif_interface::coding_key() -void lclif_send_coding_key(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -void lclif_send_coding_key(int fd, struct login_session_data *sd) +static void lclif_send_coding_key(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +static void lclif_send_coding_key(int fd, struct login_session_data *sd) { struct packet_AC_ACK_HASH *packet = NULL; int16 size = sizeof(*packet) + sd->md5keylen; @@ -360,7 +360,7 @@ void lclif_send_coding_key(int fd, struct login_session_data *sd) } /// @copydoc lclif_interface::parse() -int lclif_parse(int fd) +static int lclif_parse(int fd) { struct login_session_data *sd = NULL; int i; @@ -426,7 +426,7 @@ int lclif_parse(int fd) } /// @copydoc lclif_interface_private::parse_sub() -enum parsefunc_rcode lclif_parse_sub(int fd, struct login_session_data *sd) +static enum parsefunc_rcode lclif_parse_sub(int fd, struct login_session_data *sd) { int packet_len = (int)RFIFOREST(fd); int16 packet_id = RFIFOW(fd, 0); @@ -474,7 +474,7 @@ enum parsefunc_rcode lclif_parse_sub(int fd, struct login_session_data *sd) } /// @copydoc lclif_interface::packet() -const struct login_packet_db *lclif_packet(int16 packet_id) +static const struct login_packet_db *lclif_packet(int16 packet_id) { if (packet_id == PACKET_ID_CA_CHARSERVERCONNECT) return &lclif->p->dbs->packet_db[0]; @@ -486,7 +486,7 @@ const struct login_packet_db *lclif_packet(int16 packet_id) } /// @copydoc lclif_interface::parse_packet() -enum parsefunc_rcode lclif_parse_packet(const struct login_packet_db *lpd, int fd, struct login_session_data *sd) +static enum parsefunc_rcode lclif_parse_packet(const struct login_packet_db *lpd, int fd, struct login_session_data *sd) { int result; result = (*lpd->pFunc)(fd, sd); @@ -495,7 +495,7 @@ enum parsefunc_rcode lclif_parse_packet(const struct login_packet_db *lpd, int f } /// @copydoc lclif_interface_private::packetdb_loaddb() -void packetdb_loaddb(void) +static void packetdb_loaddb(void) { int i; struct packet { @@ -536,13 +536,13 @@ void packetdb_loaddb(void) } /// @copydoc lclif_interface::init() -void lclif_init(void) +static void lclif_init(void) { lclif->p->packetdb_loaddb(); } /// @copydoc lclif_interface::final() -void lclif_final(void) +static void lclif_final(void) { } diff --git a/src/login/login.c b/src/login/login.c index c78729dd8..d54348834 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -50,17 +50,17 @@ * Implementation of the login interface. */ -struct login_interface login_s; +static struct login_interface login_s; struct login_interface *login; -struct s_login_dbs logindbs; -struct lchrif_interface lchrif_s; +static struct s_login_dbs logindbs; +static struct lchrif_interface lchrif_s; struct lchrif_interface *lchrif; -struct Login_Config login_config_; +static struct Login_Config login_config_; -struct Account_engine account_engine; +static struct Account_engine account_engine; // account database -AccountDB* accounts = NULL; +static AccountDB *accounts = NULL; //----------------------------------------------------- // Auth database @@ -80,7 +80,7 @@ static struct DBData login_create_online_user(union DBKey key, va_list args) return DB->ptr2data(p); } -struct online_login_data* login_add_online_user(int char_server, int account_id) +static struct online_login_data* login_add_online_user(int char_server, int account_id) { struct online_login_data* p; p = idb_ensure(login->online_db, account_id, login->create_online_user); @@ -93,7 +93,7 @@ struct online_login_data* login_add_online_user(int char_server, int account_id) return p; } -void login_remove_online_user(int account_id) +static void login_remove_online_user(int account_id) { struct online_login_data* p; p = (struct online_login_data*)idb_get(login->online_db, account_id); @@ -105,7 +105,8 @@ void login_remove_online_user(int account_id) idb_remove(login->online_db, account_id); } -static int login_waiting_disconnect_timer(int tid, int64 tick, int id, intptr_t data) { +static int login_waiting_disconnect_timer(int tid, int64 tick, int id, intptr_t data) +{ struct online_login_data* p = (struct online_login_data*)idb_get(login->online_db, id); if( p != NULL && p->waiting_disconnect == tid && p->account_id == id ) { @@ -150,7 +151,8 @@ static int login_online_data_cleanup_sub(union DBKey key, struct DBData *data, v return 0; } -static int login_online_data_cleanup(int tid, int64 tick, int id, intptr_t data) { +static int login_online_data_cleanup(int tid, int64 tick, int id, intptr_t data) +{ login->online_db->foreach(login->online_db, login->online_data_cleanup_sub); return 0; } @@ -159,7 +161,7 @@ static int login_online_data_cleanup(int tid, int64 tick, int id, intptr_t data) //-------------------------------------------------------------------- // Packet send to all char-servers, except one (wos: without our self) //-------------------------------------------------------------------- -int charif_sendallwos(int sfd, uint8* buf, size_t len) +static int charif_sendallwos(int sfd, uint8 *buf, size_t len) { int i, c; @@ -180,7 +182,7 @@ int charif_sendallwos(int sfd, uint8* buf, size_t len) /// Initializes a server structure. -void lchrif_server_init(int id) +static void lchrif_server_init(int id) { Assert_retv(id >= 0 && id < MAX_SERVERS); memset(&login->dbs->server[id], 0, sizeof(login->dbs->server[id])); @@ -189,7 +191,7 @@ void lchrif_server_init(int id) /// Destroys a server structure. -void lchrif_server_destroy(int id) +static void lchrif_server_destroy(int id) { Assert_retv(id >= 0 && id < MAX_SERVERS); if (login->dbs->server[id].fd != -1) @@ -201,7 +203,7 @@ void lchrif_server_destroy(int id) /// Resets all the data related to a server. -void lchrif_server_reset(int id) +static void lchrif_server_reset(int id) { login->online_db->foreach(login->online_db, login->online_db_setoffline, id); //Set all chars from this char server to offline. lchrif->server_destroy(id); @@ -210,7 +212,7 @@ void lchrif_server_reset(int id) /// Called when the connection to Char Server is disconnected. -void lchrif_on_disconnect(int id) +static void lchrif_on_disconnect(int id) { Assert_retv(id >= 0 && id < MAX_SERVERS); ShowStatus("Char-server '%s' has disconnected.\n", login->dbs->server[id].name); @@ -221,7 +223,8 @@ void lchrif_on_disconnect(int id) //----------------------------------------------------- // periodic ip address synchronization //----------------------------------------------------- -static int login_sync_ip_addresses(int tid, int64 tick, int id, intptr_t data) { +static int login_sync_ip_addresses(int tid, int64 tick, int id, intptr_t data) +{ uint8 buf[2]; ShowInfo("IP Sync in progress...\n"); WBUFW(buf,0) = 0x2735; @@ -233,7 +236,7 @@ static int login_sync_ip_addresses(int tid, int64 tick, int id, intptr_t data) { //----------------------------------------------------- // encrypted/unencrypted password check (from eApp) //----------------------------------------------------- -bool login_check_encrypted(const char* str1, const char* str2, const char* passwd) +static bool login_check_encrypted(const char *str1, const char *str2, const char *passwd) { char tmpstr[64+1], md5str[32+1]; @@ -246,7 +249,7 @@ bool login_check_encrypted(const char* str1, const char* str2, const char* passw return (0==strcmp(passwd, md5str)); } -bool login_check_password(const char* md5key, int passwdenc, const char* passwd, const char* refpass) +static bool login_check_password(const char *md5key, int passwdenc, const char *passwd, const char *refpass) { nullpo_ret(passwd); nullpo_ret(refpass); @@ -269,12 +272,12 @@ bool login_check_password(const char* md5key, int passwdenc, const char* passwd, * @retval 0 if it is a WAN IP. * @return the appropriate LAN server address to send, if it is a LAN IP. */ -uint32 login_lan_subnet_check(uint32 ip) +static uint32 login_lan_subnet_check(uint32 ip) { return sockt->lan_subnet_check(ip, NULL); } -void login_fromchar_auth_ack(int fd, int account_id, uint32 login_id1, uint32 login_id2, uint8 sex, int request_id, struct login_auth_node* node) +static void login_fromchar_auth_ack(int fd, int account_id, uint32 login_id1, uint32 login_id2, uint8 sex, int request_id, struct login_auth_node *node) { WFIFOHEAD(fd,33); WFIFOW(fd,0) = 0x2713; @@ -303,7 +306,7 @@ void login_fromchar_auth_ack(int fd, int account_id, uint32 login_id1, uint32 lo WFIFOSET(fd,33); } -void login_fromchar_parse_auth(int fd, int id, const char *const ip) +static void login_fromchar_parse_auth(int fd, int id, const char *const ip) { struct login_auth_node* node; @@ -339,7 +342,7 @@ void login_fromchar_parse_auth(int fd, int id, const char *const ip) } } -void login_fromchar_parse_update_users(int fd, int id) +static void login_fromchar_parse_update_users(int fd, int id) { int users = RFIFOL(fd,2); RFIFOSKIP(fd,6); @@ -353,7 +356,7 @@ void login_fromchar_parse_update_users(int fd, int id) } } -void login_fromchar_parse_request_change_email(int fd, int id, const char *const ip) +static void login_fromchar_parse_request_change_email(int fd, int id, const char *const ip) { struct mmo_account acc; char email[40]; @@ -375,7 +378,7 @@ void login_fromchar_parse_request_change_email(int fd, int id, const char *const } } -void login_fromchar_account(int fd, int account_id, struct mmo_account *acc) +static void login_fromchar_account(int fd, int account_id, struct mmo_account *acc) { WFIFOHEAD(fd,72); WFIFOW(fd,0) = 0x2717; @@ -419,7 +422,7 @@ void login_fromchar_account(int fd, int account_id, struct mmo_account *acc) WFIFOSET(fd,72); } -void login_fromchar_parse_account_data(int fd, int id, const char *const ip) +static void login_fromchar_parse_account_data(int fd, int id, const char *const ip) { struct mmo_account acc; @@ -436,20 +439,20 @@ void login_fromchar_parse_account_data(int fd, int id, const char *const ip) } } -void login_fromchar_pong(int fd) +static void login_fromchar_pong(int fd) { WFIFOHEAD(fd,2); WFIFOW(fd,0) = 0x2718; WFIFOSET(fd,2); } -void login_fromchar_parse_ping(int fd) +static void login_fromchar_parse_ping(int fd) { RFIFOSKIP(fd,2); login->fromchar_pong(fd); } -void login_fromchar_parse_change_email(int fd, int id, const char *const ip) +static void login_fromchar_parse_change_email(int fd, int id, const char *const ip) { struct mmo_account acc; char actual_email[40]; @@ -482,7 +485,7 @@ void login_fromchar_parse_change_email(int fd, int id, const char *const ip) } } -void login_fromchar_account_update_other(int account_id, unsigned int state) +static void login_fromchar_account_update_other(int account_id, unsigned int state) { uint8 buf[11]; WBUFW(buf,0) = 0x2731; @@ -492,7 +495,7 @@ void login_fromchar_account_update_other(int account_id, unsigned int state) charif_sendallwos(-1, buf, 11); } -void login_fromchar_parse_account_update(int fd, int id, const char *const ip) +static void login_fromchar_parse_account_update(int fd, int id, const char *const ip) { struct mmo_account acc; @@ -519,7 +522,7 @@ void login_fromchar_parse_account_update(int fd, int id, const char *const ip) } } -void login_fromchar_ban(int account_id, time_t timestamp) +static void login_fromchar_ban(int account_id, time_t timestamp) { uint8 buf[11]; WBUFW(buf,0) = 0x2731; @@ -529,7 +532,7 @@ void login_fromchar_ban(int account_id, time_t timestamp) charif_sendallwos(-1, buf, 11); } -void login_fromchar_parse_ban(int fd, int id, const char *const ip) +static void login_fromchar_parse_ban(int fd, int id, const char *const ip) { struct mmo_account acc; @@ -579,7 +582,7 @@ void login_fromchar_parse_ban(int fd, int id, const char *const ip) } } -void login_fromchar_change_sex_other(int account_id, char sex) +static void login_fromchar_change_sex_other(int account_id, char sex) { unsigned char buf[7]; WBUFW(buf,0) = 0x2723; @@ -588,7 +591,7 @@ void login_fromchar_change_sex_other(int account_id, char sex) charif_sendallwos(-1, buf, 7); } -void login_fromchar_parse_change_sex(int fd, int id, const char *const ip) +static void login_fromchar_parse_change_sex(int fd, int id, const char *const ip) { struct mmo_account acc; @@ -615,7 +618,7 @@ void login_fromchar_parse_change_sex(int fd, int id, const char *const ip) } } -void login_fromchar_parse_account_reg2(int fd, int id, const char *const ip) +static void login_fromchar_parse_account_reg2(int fd, int id, const char *const ip) { struct mmo_account acc; @@ -629,7 +632,7 @@ void login_fromchar_parse_account_reg2(int fd, int id, const char *const ip) RFIFOSKIP(fd,RFIFOW(fd,2)); } -void login_fromchar_parse_unban(int fd, int id, const char *const ip) +static void login_fromchar_parse_unban(int fd, int id, const char *const ip) { struct mmo_account acc; @@ -649,19 +652,19 @@ void login_fromchar_parse_unban(int fd, int id, const char *const ip) } } -void login_fromchar_parse_account_online(int fd, int id) +static void login_fromchar_parse_account_online(int fd, int id) { login->add_online_user(id, RFIFOL(fd,2)); RFIFOSKIP(fd,6); } -void login_fromchar_parse_account_offline(int fd) +static void login_fromchar_parse_account_offline(int fd) { login->remove_online_user(RFIFOL(fd,2)); RFIFOSKIP(fd,6); } -void login_fromchar_parse_online_accounts(int fd, int id) +static void login_fromchar_parse_online_accounts(int fd, int id) { uint32 i, users; login->online_db->foreach(login->online_db, login->online_db_setoffline, id); //Set all chars from this char-server offline first @@ -678,7 +681,7 @@ void login_fromchar_parse_online_accounts(int fd, int id) } } -void login_fromchar_parse_request_account_reg2(int fd) +static void login_fromchar_parse_request_account_reg2(int fd) { int account_id = RFIFOL(fd,2); int char_id = RFIFOL(fd,6); @@ -687,21 +690,21 @@ void login_fromchar_parse_request_account_reg2(int fd) account->mmo_send_accreg2(accounts,fd,account_id,char_id); } -void login_fromchar_parse_update_wan_ip(int fd, int id) +static void login_fromchar_parse_update_wan_ip(int fd, int id) { login->dbs->server[id].ip = ntohl(RFIFOL(fd,2)); ShowInfo("Updated IP of Server #%d to %u.%u.%u.%u.\n",id, CONVIP(login->dbs->server[id].ip)); RFIFOSKIP(fd,6); } -void login_fromchar_parse_all_offline(int fd, int id) +static void login_fromchar_parse_all_offline(int fd, int id) { ShowInfo("Setting accounts from char-server %d offline.\n", id); login->online_db->foreach(login->online_db, login->online_db_setoffline, id); RFIFOSKIP(fd,2); } -void login_fromchar_parse_change_pincode(int fd) +static void login_fromchar_parse_change_pincode(int fd) { struct mmo_account acc; @@ -713,7 +716,7 @@ void login_fromchar_parse_change_pincode(int fd) RFIFOSKIP(fd,11); } -bool login_fromchar_parse_wrong_pincode(int fd) +static bool login_fromchar_parse_wrong_pincode(int fd) { struct mmo_account acc; @@ -733,7 +736,7 @@ bool login_fromchar_parse_wrong_pincode(int fd) return false; } -void login_fromchar_accinfo(int fd, int account_id, int u_fd, int u_aid, int u_group, int map_fd, struct mmo_account *acc) +static void login_fromchar_accinfo(int fd, int account_id, int u_fd, int u_aid, int u_group, int map_fd, struct mmo_account *acc) { if (acc) { @@ -773,7 +776,7 @@ void login_fromchar_accinfo(int fd, int account_id, int u_fd, int u_aid, int u_g } } -void login_fromchar_parse_accinfo(int fd) +static void login_fromchar_parse_accinfo(int fd) { struct mmo_account acc; int account_id = RFIFOL(fd, 2), u_fd = RFIFOL(fd, 6), u_aid = RFIFOL(fd, 10), u_group = RFIFOL(fd, 14), map_fd = RFIFOL(fd, 18); @@ -788,7 +791,7 @@ void login_fromchar_parse_accinfo(int fd) //-------------------------------- // Packet parsing for char-servers //-------------------------------- -int login_parse_fromchar(int fd) +static int login_parse_fromchar(int fd) { int id; uint32 ipl; @@ -992,7 +995,8 @@ int login_parse_fromchar(int fd) //------------------------------------- // Make new account //------------------------------------- -int login_mmo_auth_new(const char* userid, const char* pass, const char sex, const char* last_ip) { +static int login_mmo_auth_new(const char *userid, const char *pass, const char sex, const char *last_ip) +{ static int num_regs = 0; // registration counter static int64 new_reg_tick = 0; int64 tick = timer->gettick(); @@ -1054,7 +1058,8 @@ int login_mmo_auth_new(const char* userid, const char* pass, const char sex, con // Check/authentication of a connection //----------------------------------------------------- // TODO: Map result values to an enum (or at least document them) -int login_mmo_auth(struct login_session_data* sd, bool isServer) { +static int login_mmo_auth(struct login_session_data *sd, bool isServer) +{ struct mmo_account acc; size_t len; @@ -1191,7 +1196,7 @@ int login_mmo_auth(struct login_session_data* sd, bool isServer) { return -1; // account OK } -void login_kick(struct login_session_data* sd) +static void login_kick(struct login_session_data *sd) { uint8 buf[6]; nullpo_retv(sd); @@ -1200,7 +1205,7 @@ void login_kick(struct login_session_data* sd) charif_sendallwos(-1, buf, 6); } -void login_auth_ok(struct login_session_data* sd) +static void login_auth_ok(struct login_session_data *sd) { int fd = 0; uint32 ip; @@ -1285,7 +1290,7 @@ void login_auth_ok(struct login_session_data* sd) } } -void login_auth_failed(struct login_session_data *sd, int result) +static void login_auth_failed(struct login_session_data *sd, int result) { int fd; uint32 ip; @@ -1336,8 +1341,8 @@ void login_auth_failed(struct login_session_data *sd, int result) lclif->auth_failed(fd, ban_time, result); } -bool login_client_login(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -bool login_client_login(int fd, struct login_session_data *sd) +static bool login_client_login(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +static bool login_client_login(int fd, struct login_session_data *sd) { int result; char ip[16]; @@ -1360,8 +1365,8 @@ bool login_client_login(int fd, struct login_session_data *sd) return false; } -bool login_client_login_otp(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); -bool login_client_login_otp(int fd, struct login_session_data *sd) +static bool login_client_login_otp(int fd, struct login_session_data *sd) __attribute__((nonnull (2))); +static bool login_client_login_otp(int fd, struct login_session_data *sd) { // send ok response with fake token #ifdef PACKETVER_ZERO @@ -1395,8 +1400,8 @@ bool login_client_login_otp(int fd, struct login_session_data *sd) #endif // PACKETVER_ZERO } -void login_char_server_connection_status(int fd, struct login_session_data* sd, uint8 status) __attribute__((nonnull (2))); -void login_char_server_connection_status(int fd, struct login_session_data* sd, uint8 status) +static void login_char_server_connection_status(int fd, struct login_session_data* sd, uint8 status) __attribute__((nonnull (2))); +static void login_char_server_connection_status(int fd, struct login_session_data* sd, uint8 status) { WFIFOHEAD(fd,3); WFIFOW(fd,0) = 0x2711; @@ -1405,8 +1410,8 @@ void login_char_server_connection_status(int fd, struct login_session_data* sd, } // CA_CHARSERVERCONNECT -void login_parse_request_connection(int fd, struct login_session_data* sd, const char *const ip, uint32 ipl) __attribute__((nonnull (2, 3))); -void login_parse_request_connection(int fd, struct login_session_data* sd, const char *const ip, uint32 ipl) +static void login_parse_request_connection(int fd, struct login_session_data* sd, const char *const ip, uint32 ipl) __attribute__((nonnull (2, 3))); +static void login_parse_request_connection(int fd, struct login_session_data* sd, const char *const ip, uint32 ipl) { char server_name[20]; char message[256]; @@ -1464,7 +1469,7 @@ void login_parse_request_connection(int fd, struct login_session_data* sd, const } } -void login_config_set_defaults(void) +static void login_config_set_defaults(void) { login->config->login_ip = INADDR_ANY; login->config->login_port = 6900; @@ -1503,7 +1508,7 @@ void login_config_set_defaults(void) * * @retval false in case of error. */ -bool login_config_read_inter(const char *filename, struct config_t *config, bool imported) +static bool login_config_read_inter(const char *filename, struct config_t *config, bool imported) { struct config_setting_t *setting = NULL; const char *str = NULL; @@ -1543,7 +1548,7 @@ bool login_config_read_inter(const char *filename, struct config_t *config, bool * * @retval false in case of error. */ -bool login_config_read_console(const char *filename, struct config_t *config, bool imported) +static bool login_config_read_console(const char *filename, struct config_t *config, bool imported) { struct config_setting_t *setting = NULL; @@ -1576,7 +1581,7 @@ bool login_config_read_console(const char *filename, struct config_t *config, bo * * @retval false in case of error. */ -bool login_config_read_log(const char *filename, struct config_t *config, bool imported) +static bool login_config_read_log(const char *filename, struct config_t *config, bool imported) { struct config_setting_t *setting = NULL; @@ -1604,7 +1609,7 @@ bool login_config_read_log(const char *filename, struct config_t *config, bool i * * @retval false in case of error. */ -bool login_config_read_account(const char *filename, struct config_t *config, bool imported) +static bool login_config_read_account(const char *filename, struct config_t *config, bool imported) { struct config_setting_t *setting = NULL; AccountDB *db = login->dbs->account_engine->db; @@ -1639,7 +1644,7 @@ bool login_config_read_account(const char *filename, struct config_t *config, bo /** * Frees login->config->client_hash_nodes **/ -void login_clear_client_hash_nodes(void) +static void login_clear_client_hash_nodes(void) { struct client_hash_node *node = login->config->client_hash_nodes; @@ -1657,7 +1662,7 @@ void login_clear_client_hash_nodes(void) * * @param setting The setting to read from. */ -void login_config_set_md5hash(struct config_setting_t *setting) +static void login_config_set_md5hash(struct config_setting_t *setting) { int i; int count = libconfig->setting_length(setting); @@ -1720,7 +1725,7 @@ void login_config_set_md5hash(struct config_setting_t *setting) * * @retval false in case of error. */ -bool login_config_read_permission_hash(const char *filename, struct config_t *config, bool imported) +static bool login_config_read_permission_hash(const char *filename, struct config_t *config, bool imported) { struct config_setting_t *setting = NULL; @@ -1745,7 +1750,7 @@ bool login_config_read_permission_hash(const char *filename, struct config_t *co /** * Clears login->config->dnsbl_servers, freeing any allocated memory. */ -void login_clear_dnsbl_servers(void) +static void login_clear_dnsbl_servers(void) { while (VECTOR_LENGTH(login->config->dnsbl_servers) > 0) { aFree(&VECTOR_POP(login->config->dnsbl_servers)); @@ -1758,7 +1763,7 @@ void login_clear_dnsbl_servers(void) * * @param setting The configuration setting to read from. */ -void login_config_set_dnsbl_servers(struct config_setting_t *setting) +static void login_config_set_dnsbl_servers(struct config_setting_t *setting) { int i; int count = libconfig->setting_length(setting); @@ -1790,7 +1795,7 @@ void login_config_set_dnsbl_servers(struct config_setting_t *setting) * * @retval false in case of error. */ -bool login_config_read_permission_blacklist(const char *filename, struct config_t *config, bool imported) +static bool login_config_read_permission_blacklist(const char *filename, struct config_t *config, bool imported) { struct config_setting_t *setting = NULL; @@ -1821,7 +1826,7 @@ bool login_config_read_permission_blacklist(const char *filename, struct config_ * * @retval false in case of error. */ -bool login_config_read_permission(const char *filename, struct config_t *config, bool imported) +static bool login_config_read_permission(const char *filename, struct config_t *config, bool imported) { struct config_setting_t *setting = NULL; bool retval = true; @@ -1858,7 +1863,7 @@ bool login_config_read_permission(const char *filename, struct config_t *config, * * @retval false in case of error. */ -bool login_config_read_users(const char *filename, struct config_t *config, bool imported) +static bool login_config_read_users(const char *filename, struct config_t *config, bool imported) { struct config_setting_t *setting = NULL; bool retval = true; @@ -1889,7 +1894,7 @@ bool login_config_read_users(const char *filename, struct config_t *config, bool * * @retval false in case of error. **/ -bool login_config_read(const char *filename, bool imported) +static bool login_config_read(const char *filename, bool imported) { struct config_t config; const char *import = NULL; @@ -1942,7 +1947,7 @@ bool login_config_read(const char *filename, bool imported) * * @retval users count or color id. **/ -uint16 login_convert_users_to_colors(uint16 users) +static uint16 login_convert_users_to_colors(uint16 users) { #if PACKETVER >= 20170726 if (!login->config->send_user_count_description) @@ -2020,13 +2025,14 @@ void do_abort(void) { } -void set_server_type(void) { +void set_server_type(void) +{ SERVER_TYPE = SERVER_TYPE_LOGIN; } /// Called when a terminate signal is received. -void do_shutdown_login(void) +static void do_shutdown_login(void) { if( core->runflag != LOGINSERVER_ST_SHUTDOWN ) { @@ -2091,7 +2097,7 @@ void cmdline_args_init_local(void) //------------------------------ // Login server initialization //------------------------------ -int do_init(int argc, char** argv) +int do_init(int argc, char **argv) { int i; diff --git a/src/login/loginlog.c b/src/login/loginlog.c index bf40d6ed8..19f269ab5 100644 --- a/src/login/loginlog.c +++ b/src/login/loginlog.c @@ -34,13 +34,13 @@ #include // exit -struct loginlog_interface loginlog_s; +static struct loginlog_interface loginlog_s; struct loginlog_interface *loginlog; -struct s_loginlog_dbs loginlogdbs; +static struct s_loginlog_dbs loginlogdbs; // Returns the number of failed login attempts by the ip in the last minutes. -unsigned long loginlog_failedattempts(uint32 ip, unsigned int minutes) +static unsigned long loginlog_failedattempts(uint32 ip, unsigned int minutes) { unsigned long failures = 0; @@ -66,7 +66,7 @@ unsigned long loginlog_failedattempts(uint32 ip, unsigned int minutes) * Records an event in the login log *---------------------------------------------*/ // TODO: add an enum of rcode values -void loginlog_log(uint32 ip, const char* username, int rcode, const char* message) +static void loginlog_log(uint32 ip, const char *username, int rcode, const char *message) { char esc_username[NAME_LENGTH*2+1]; char esc_message[255*2+1]; @@ -88,7 +88,7 @@ void loginlog_log(uint32 ip, const char* username, int rcode, const char* messag Sql_ShowDebug(loginlog->sql_handle); } -bool loginlog_init(void) +static bool loginlog_init(void) { loginlog->sql_handle = SQL->Malloc(); @@ -107,7 +107,7 @@ bool loginlog_init(void) return true; } -bool loginlog_final(void) +static bool loginlog_final(void) { SQL->Free(loginlog->sql_handle); loginlog->sql_handle = NULL; @@ -124,7 +124,7 @@ bool loginlog_final(void) * * @retval false in case of error. */ -bool loginlog_config_read_names(const char *filename, struct config_t *config, bool imported) +static bool loginlog_config_read_names(const char *filename, struct config_t *config, bool imported) { struct config_setting_t *setting = NULL; @@ -153,7 +153,7 @@ bool loginlog_config_read_names(const char *filename, struct config_t *config, b * * @retval false in case of error. */ -bool loginlog_config_read_log(const char *filename, struct config_t *config, bool imported) +static bool loginlog_config_read_log(const char *filename, struct config_t *config, bool imported) { struct config_setting_t *setting = NULL; @@ -188,7 +188,7 @@ bool loginlog_config_read_log(const char *filename, struct config_t *config, boo * * @retval false in case of error. **/ -bool loginlog_config_read(const char *filename, bool imported) +static bool loginlog_config_read(const char *filename, bool imported) { struct config_t config; const char *import = NULL; -- cgit v1.2.3-70-g09d2 From b7e6439f0c788ceacc567fbb017d3c7f09913f78 Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 24 Jun 2018 22:06:41 +0200 Subject: Change functions to static where possible (Part 3 - char) This fixes issues with plugins defining symbols with the same names Signed-off-by: Haru --- src/char/char.c | 447 ++++++++++++++++++++++++----------------------- src/char/geoip.c | 64 +++---- src/char/int_auction.c | 19 +- src/char/int_clan.c | 8 +- src/char/int_elemental.c | 19 +- src/char/int_guild.c | 76 ++++---- src/char/int_homun.c | 18 +- src/char/int_mail.c | 26 +-- src/char/int_mercenary.c | 23 +-- src/char/int_party.c | 40 +++-- src/char/int_pet.c | 22 ++- src/char/int_quest.c | 14 +- src/char/int_rodex.c | 12 +- src/char/int_storage.c | 22 +-- src/char/inter.c | 71 ++++---- src/char/loginif.c | 30 ++-- src/char/mapif.c | 331 ++++++++++++++++++----------------- src/char/pincode.c | 68 +++---- 18 files changed, 674 insertions(+), 636 deletions(-) diff --git a/src/char/char.c b/src/char/char.c index 04db83eb9..486cc7c03 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -96,8 +96,8 @@ char party_db[256] = "party"; char pet_db[256] = "pet"; char mail_db[256] = "mail"; // MAIL SYSTEM char auction_db[256] = "auction"; // Auctions System -char friend_db[256] = "friends"; -char hotkey_db[256] = "hotkey"; +static char friend_db[256] = "friends"; +static char hotkey_db[256] = "hotkey"; char quest_db[256] = "quest"; char rodex_db[256] = "rodex_mail"; char rodex_item_db[256] = "rodex_items"; @@ -107,41 +107,41 @@ char mercenary_db[256] = "mercenary"; char mercenary_owner_db[256] = "mercenary_owner"; char ragsrvinfo_db[256] = "ragsrvinfo"; char elemental_db[256] = "elemental"; -char account_data_db[256] = "account_data"; +static char account_data_db[256] = "account_data"; char acc_reg_num_db[32] = "acc_reg_num_db"; char acc_reg_str_db[32] = "acc_reg_str_db"; char char_reg_str_db[32] = "char_reg_str_db"; char char_reg_num_db[32] = "char_reg_num_db"; -struct char_interface char_s; +static struct char_interface char_s; struct char_interface *chr; char db_path[1024] = "db"; -char wisp_server_name[NAME_LENGTH] = "Server"; -char login_ip_str[128]; -uint32 login_ip = 0; -uint16 login_port = 6900; -char char_ip_str[128]; -char bind_ip_str[128]; -uint32 bind_ip = INADDR_ANY; -int char_maintenance_min_group_id = 0; -bool enable_char_creation = true; ///< Whether to allow character creation. - -bool name_ignoring_case = false; // Allow or not identical name for characters but with a different case by [Yor] +static char wisp_server_name[NAME_LENGTH] = "Server"; +static char login_ip_str[128]; +static uint32 login_ip = 0; +static uint16 login_port = 6900; +static char char_ip_str[128]; +static char bind_ip_str[128]; +static uint32 bind_ip = INADDR_ANY; +static int char_maintenance_min_group_id = 0; +static bool enable_char_creation = true; ///< Whether to allow character creation. + +static bool name_ignoring_case = false; // Allow or not identical name for characters but with a different case by [Yor] int char_name_option = 0; // Option to know which letters/symbols are authorized 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] -char unknown_char_name[NAME_LENGTH] = "Unknown"; // Name to use when the requested name cannot be determined +static char unknown_char_name[NAME_LENGTH] = "Unknown"; // Name to use when the requested name cannot be determined #define TRIM_CHARS "\255\xA0\032\t\x0A\x0D " //The following characters are trimmed regardless because they cause confusion and problems on the servers. [Skotlex] char char_name_letters[1024] = ""; // list of letters/symbols allowed (or not) in a character name. by [Yor] -int char_del_level = 0; ///< From which level you can delete character [Lupus] -int char_del_delay = 86400; -bool char_aegis_delete = false; ///< Verify if char is in guild/party or char and reacts as Aegis does (disallow deletion), @see chr->delete2_req. +static int char_del_level = 0; ///< From which level you can delete character [Lupus] +static int char_del_delay = 86400; +static bool char_aegis_delete = false; ///< Verify if char is in guild/party or char and reacts as Aegis does (disallow deletion), @see chr->delete2_req. -int max_connect_user = -1; -int gm_allow_group = -1; +static int max_connect_user = -1; +static int gm_allow_group = -1; int autosave_interval = DEFAULT_AUTOSAVE_INTERVAL; -int start_zeny = 0; +static int start_zeny = 0; /// Start items for new characters struct start_item_s { @@ -150,28 +150,28 @@ struct start_item_s { int loc; bool stackable; }; -VECTOR_DECL(struct start_item_s) start_items; +static VECTOR_DECL(struct start_item_s) start_items; int guild_exp_rate = 100; //Custom limits for the fame lists. [Skotlex] -int fame_list_size_chemist = MAX_FAME_LIST; -int fame_list_size_smith = MAX_FAME_LIST; -int fame_list_size_taekwon = MAX_FAME_LIST; +static int fame_list_size_chemist = MAX_FAME_LIST; +static int fame_list_size_smith = MAX_FAME_LIST; +static int fame_list_size_taekwon = MAX_FAME_LIST; // Char-server-side stored fame lists [DracoRPG] -struct fame_list smith_fame_list[MAX_FAME_LIST]; -struct fame_list chemist_fame_list[MAX_FAME_LIST]; -struct fame_list taekwon_fame_list[MAX_FAME_LIST]; +static struct fame_list smith_fame_list[MAX_FAME_LIST]; +static struct fame_list chemist_fame_list[MAX_FAME_LIST]; +static struct fame_list taekwon_fame_list[MAX_FAME_LIST]; // Initial position (it's possible to set it in conf file) #ifdef RENEWAL - struct point start_point = { 0, 97, 90 }; +static struct point start_point = { 0, 97, 90 }; #else - struct point start_point = { 0, 53, 111 }; +static struct point start_point = { 0, 53, 111 }; #endif -unsigned short skillid2idx[MAX_SKILL_ID]; +static unsigned short skillid2idx[MAX_SKILL_ID]; //----------------------------------------------------- // Auth database @@ -200,7 +200,7 @@ static struct DBData char_create_online_char_data(union DBKey key, va_list args) return DB->ptr2data(character); } -void char_set_account_online(int account_id) +static void char_set_account_online(int account_id) { WFIFOHEAD(chr->login_fd,6); WFIFOW(chr->login_fd,0) = 0x272b; @@ -208,7 +208,7 @@ void char_set_account_online(int account_id) WFIFOSET(chr->login_fd,6); } -void char_set_account_offline(int account_id) +static void char_set_account_offline(int account_id) { WFIFOHEAD(chr->login_fd,6); WFIFOW(chr->login_fd,0) = 0x272c; @@ -216,7 +216,7 @@ void char_set_account_offline(int account_id) WFIFOSET(chr->login_fd,6); } -void char_set_char_charselect(int account_id) +static void char_set_char_charselect(int account_id) { struct online_char_data* character; @@ -240,7 +240,7 @@ void char_set_char_charselect(int account_id) chr->set_account_online(account_id); } -void char_set_char_online(int map_id, int char_id, int account_id) +static void char_set_char_online(int map_id, int char_id, int account_id) { struct online_char_data* character; struct mmo_charstatus *cp; @@ -280,7 +280,7 @@ void char_set_char_online(int map_id, int char_id, int account_id) chr->set_account_online(account_id); } -void char_set_char_offline(int char_id, int account_id) +static void char_set_char_offline(int char_id, int account_id) { struct online_char_data* character; @@ -371,7 +371,7 @@ static int char_db_kickoffline(union DBKey key, struct DBData *data, va_list ap) return 1; } -void char_set_login_all_offline(void) +static void char_set_login_all_offline(void) { //Tell login-server to also mark all our characters as offline. WFIFOHEAD(chr->login_fd,2); @@ -379,7 +379,7 @@ void char_set_login_all_offline(void) WFIFOSET(chr->login_fd,2); } -void char_set_all_offline(int id) +static void char_set_all_offline(int id) { if (id < 0) ShowNotice("Sending all users offline.\n"); @@ -392,7 +392,7 @@ void char_set_all_offline(int id) chr->set_login_all_offline(); } -void char_set_all_offline_sql(void) +static void char_set_all_offline_sql(void) { //Set all players to 'OFFLINE' if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `online` = '0'", char_db) ) @@ -414,7 +414,7 @@ static struct DBData char_create_charstatus(union DBKey key, va_list args) return DB->ptr2data(cp); } -int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p) +static int char_mmo_char_tosql(int char_id, struct mmo_charstatus *p) { int i = 0; int count = 0; @@ -709,7 +709,7 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p) * @param[in] table Table to be used for the transaction. * @return -1 on failure or number of items added to the list if successful. */ -int char_getitemdata_from_sql(struct item *items, int max, int guid, enum inventory_table_type table) +static int char_getitemdata_from_sql(struct item *items, int max, int guid, enum inventory_table_type table) { int i = 0; struct SqlStmt *stmt = NULL; @@ -816,7 +816,7 @@ int char_getitemdata_from_sql(struct item *items, int max, int guid, enum invent * @param[in] tableswitch The type of table (@see enum inventory_table_type). * @retval -1 in case of failure, or number of changes made within the table. */ -int char_memitemdata_to_sql(const struct item *p_items, int guid, enum inventory_table_type table) +static int char_memitemdata_to_sql(const struct item *p_items, int guid, enum inventory_table_type table) { StringBuf buf; int i = 0, j = 0; @@ -1001,7 +1001,7 @@ int char_memitemdata_to_sql(const struct item *p_items, int guid, enum inventory * @retval SEX_FEMALE if the per-character sex is female * @retval 99 if the per-character sex is not defined or the current PACKETVER doesn't support it. */ -int char_mmo_gender(const struct char_session_data *sd, const struct mmo_charstatus *p, char sex) +static int char_mmo_gender(const struct char_session_data *sd, const struct mmo_charstatus *p, char sex) { #if PACKETVER >= 20141016 (void)sd; (void)p; // Unused @@ -1039,7 +1039,7 @@ int char_mmo_gender(const struct char_session_data *sd, const struct mmo_charsta //===================================================================================================== // Loads the basic character rooster for the given account. Returns total buffer used. -int char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf) +static int char_mmo_chars_fromsql(struct char_session_data *sd, uint8 *buf) { struct SqlStmt *stmt; struct mmo_charstatus p; @@ -1135,7 +1135,7 @@ int char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf) } //===================================================================================================== -int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything) +static int char_mmo_char_fromsql(int char_id, struct mmo_charstatus *p, bool load_everything) { int i = 0; char t_msg[128] = ""; @@ -1412,7 +1412,7 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every } //========================================================================================================== -int char_mmo_char_sql_init(void) +static int char_mmo_char_sql_init(void) { chr->char_db_= idb_alloc(DB_OPT_RELEASE_DATA); @@ -1429,7 +1429,8 @@ int char_mmo_char_sql_init(void) } /* [Ind/Hercules] - special thanks to Yommy for providing the packet structure/data */ -bool char_char_slotchange(struct char_session_data *sd, int fd, unsigned short from, unsigned short to) { +static bool char_char_slotchange(struct char_session_data *sd, int fd, unsigned short from, unsigned short to) +{ struct mmo_charstatus char_dat; int from_id = 0; @@ -1481,7 +1482,7 @@ bool char_char_slotchange(struct char_session_data *sd, int fd, unsigned short f //----------------------------------- // Function to change character's names //----------------------------------- -int char_rename_char_sql(struct char_session_data *sd, int char_id) +static int char_rename_char_sql(struct char_session_data *sd, int char_id) { struct mmo_charstatus char_dat; char esc_name[NAME_LENGTH*2+1]; @@ -1541,7 +1542,7 @@ int char_rename_char_sql(struct char_session_data *sd, int char_id) * @param esc_name Escaped version of the name, optional for faster processing. * @retval true if the character name already exists. */ -bool char_name_exists(const char *name, const char *esc_name) +static bool char_name_exists(const char *name, const char *esc_name) { char esc_name2[NAME_LENGTH * 2 + 1]; @@ -1579,7 +1580,7 @@ bool char_name_exists(const char *name, const char *esc_name) * @retval -2 if the name is too short or contains special characters. * @retval -5 if the name contains forbidden characters. */ -int char_check_char_name(const char *name, const char *esc_name) +static int char_check_char_name(const char *name, const char *esc_name) { int i; @@ -1639,7 +1640,7 @@ int char_check_char_name(const char *name, const char *esc_name) * -5: 'Symbols in Character Names are forbidden' * char_id: Success **/ -int char_make_new_char_sql(struct char_session_data *sd, const char *name_, int str, int agi, int vit, int int_, int dex, int luk, int slot, int hair_color, int hair_style, int16 starting_class, uint8 sex) +static int char_make_new_char_sql(struct char_session_data *sd, const char *name_, int str, int agi, int vit, int int_, int dex, int luk, int slot, int hair_color, int hair_style, int16 starting_class, uint8 sex) { char name[NAME_LENGTH]; char esc_name[NAME_LENGTH*2+1]; @@ -1749,7 +1750,7 @@ int char_make_new_char_sql(struct char_session_data *sd, const char *name_, int /*----------------------------------------------------------------------------------------------------------*/ /* Divorce Players */ /*----------------------------------------------------------------------------------------------------------*/ -int char_divorce_char_sql(int partner_id1, int partner_id2) +static int char_divorce_char_sql(int partner_id1, int partner_id2) { unsigned char buf[64]; @@ -1772,7 +1773,7 @@ int char_divorce_char_sql(int partner_id1, int partner_id2) /* Returns 0 if successful * Returns < 0 for error */ -int char_delete_char_sql(int char_id) +static int char_delete_char_sql(int char_id) { char name[NAME_LENGTH]; char esc_name[NAME_LENGTH*2+1]; //Name needs be escaped. @@ -1937,7 +1938,7 @@ int char_delete_char_sql(int char_id) //--------------------------------------------------------------------- // This function return the number of online players in all map-servers //--------------------------------------------------------------------- -int char_count_users(void) +static int char_count_users(void) { int i, users; @@ -1954,7 +1955,8 @@ int char_count_users(void) // Used in packets 0x6b (chars info) and 0x6d (new char info) // Returns the size #define MAX_CHAR_BUF 150 //Max size (for WFIFOHEAD calls) -int char_mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) { +static int char_mmo_char_tobuf(uint8 *buffer, struct mmo_charstatus *p) +{ unsigned short offset = 0; uint8* buf; @@ -2061,7 +2063,7 @@ int char_mmo_char_tobuf(uint8* buffer, struct mmo_charstatus* p) { } /* Made Possible by Yommy~! <3 */ -void char_mmo_char_send099d(int fd, struct char_session_data *sd) +static void char_mmo_char_send099d(int fd, struct char_session_data *sd) { // support added for client between 20121010 and 20130320 #if PACKETVER > 20120418 @@ -2074,7 +2076,8 @@ void char_mmo_char_send099d(int fd, struct char_session_data *sd) /* Sends character ban list */ /* Made Possible by Yommy~! <3 */ -void char_mmo_char_send_ban_list(int fd, struct char_session_data *sd) { +static void char_mmo_char_send_ban_list(int fd, struct char_session_data *sd) +{ int i; time_t now = time(NULL); @@ -2114,7 +2117,8 @@ void char_mmo_char_send_ban_list(int fd, struct char_session_data *sd) { //---------------------------------------- // [Ind/Hercules] notify client about charselect window data //---------------------------------------- -void char_mmo_char_send_slots_info(int fd, struct char_session_data* sd) { +static void char_mmo_char_send_slots_info(int fd, struct char_session_data *sd) +{ nullpo_retv(sd); WFIFOHEAD(fd,29); WFIFOW(fd,0) = 0x82d; @@ -2130,7 +2134,7 @@ void char_mmo_char_send_slots_info(int fd, struct char_session_data* sd) { //---------------------------------------- // Function to send characters to a player //---------------------------------------- -int char_mmo_char_send_characters(int fd, struct char_session_data* sd) +static int char_mmo_char_send_characters(int fd, struct char_session_data *sd) { int j, offset = 0; nullpo_ret(sd); @@ -2156,7 +2160,7 @@ int char_mmo_char_send_characters(int fd, struct char_session_data* sd) return 0; } -int char_char_married(int pl1, int pl2) +static int char_char_married(int pl1, int pl2) { if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `partner_id` FROM `%s` WHERE `char_id` = '%d'", char_db, pl1) ) Sql_ShowDebug(inter->sql_handle); @@ -2175,7 +2179,7 @@ int char_char_married(int pl1, int pl2) return 0; } -int char_char_child(int parent_id, int child_id) +static int char_char_child(int parent_id, int child_id) { if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `child` FROM `%s` WHERE `char_id` = '%d'", char_db, parent_id) ) Sql_ShowDebug(inter->sql_handle); @@ -2194,7 +2198,7 @@ int char_char_child(int parent_id, int child_id) return 0; } -int char_char_family(int cid1, int cid2, int cid3) +static int char_char_family(int cid1, int cid2, int cid3) { if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `char_id`,`partner_id`,`child` FROM `%s` WHERE `char_id` IN ('%d','%d','%d')", char_db, cid1, cid2, cid3) ) Sql_ShowDebug(inter->sql_handle); @@ -2224,7 +2228,7 @@ int char_char_family(int cid1, int cid2, int cid3) //---------------------------------------------------------------------- // Force disconnection of an online player (with account value) by [Yor] //---------------------------------------------------------------------- -void char_disconnect_player(int account_id) +static void char_disconnect_player(int account_id) { int i; struct char_session_data* sd; @@ -2235,7 +2239,7 @@ void char_disconnect_player(int account_id) sockt->eof(i); } -void char_authfail_fd(int fd, int type) +static void char_authfail_fd(int fd, int type) { WFIFOHEAD(fd,3); WFIFOW(fd,0) = 0x81; @@ -2243,7 +2247,7 @@ void char_authfail_fd(int fd, int type) WFIFOSET(fd,3); } -void char_request_account_data(int account_id) +static void char_request_account_data(int account_id) { WFIFOHEAD(chr->login_fd,6); WFIFOW(chr->login_fd,0) = 0x2716; @@ -2289,14 +2293,14 @@ static void char_auth_ok(int fd, struct char_session_data *sd) // continues when account data is received... } -void char_ping_login_server(int fd) +static void char_ping_login_server(int fd) { WFIFOHEAD(fd,2);// sends a ping packet to login server (will receive pong 0x2718) WFIFOW(fd,0) = 0x2719; WFIFOSET(fd,2); } -int char_parse_fromlogin_connection_state(int fd) +static int char_parse_fromlogin_connection_state(int fd) { if (RFIFOB(fd,2)) { //printf("connect login server error : %d\n", RFIFOB(fd,2)); @@ -2316,7 +2320,7 @@ int char_parse_fromlogin_connection_state(int fd) // 0 - rejected from server // -void char_auth_error(int fd, unsigned char flag) +static void char_auth_error(int fd, unsigned char flag) { WFIFOHEAD(fd,3); WFIFOW(fd,0) = 0x6c; @@ -2324,7 +2328,7 @@ void char_auth_error(int fd, unsigned char flag) WFIFOSET(fd,3); } -void char_parse_fromlogin_auth_state(int fd) +static void char_parse_fromlogin_auth_state(int fd) { struct char_session_data* sd = NULL; int account_id = RFIFOL(fd,2); @@ -2366,7 +2370,7 @@ void char_parse_fromlogin_auth_state(int fd) } } -void char_parse_fromlogin_account_data(int fd) +static void char_parse_fromlogin_account_data(int fd) { struct char_session_data* sd = (struct char_session_data*)sockt->session[fd]->session_data; int i; @@ -2409,14 +2413,14 @@ void char_parse_fromlogin_account_data(int fd) RFIFOSKIP(fd,72); } -void char_parse_fromlogin_login_pong(int fd) +static void char_parse_fromlogin_login_pong(int fd) { RFIFOSKIP(fd,2); if (sockt->session[fd]) sockt->session[fd]->flag.ping = 0; } -void char_changesex(int account_id, int sex) +static void char_changesex(int account_id, int sex) { unsigned char buf[7]; @@ -2437,7 +2441,7 @@ void char_changesex(int account_id, int sex) * @param class The character's current job class. * @param guild_id The character's guild ID. */ -void char_change_sex_sub(int sex, int acc, int char_id, int class, int guild_id) +static void char_change_sex_sub(int sex, int acc, int char_id, int class, int guild_id) { // job modification if (class == JOB_BARD || class == JOB_DANCER) @@ -2466,7 +2470,7 @@ void char_change_sex_sub(int sex, int acc, int char_id, int class, int guild_id) inter_guild->sex_changed(guild_id, acc, char_id, sex); } -int char_parse_fromlogin_changesex_reply(int fd) +static int char_parse_fromlogin_changesex_reply(int fd) { int char_id = 0, class = 0, guild_id = 0; int i; @@ -2513,14 +2517,14 @@ int char_parse_fromlogin_changesex_reply(int fd) return 0; } -void char_parse_fromlogin_account_reg2(int fd) +static void char_parse_fromlogin_account_reg2(int fd) { //Receive account_reg2 registry, forward to map servers. mapif->sendall(RFIFOP(fd, 0), RFIFOW(fd,2)); RFIFOSKIP(fd, RFIFOW(fd,2)); } -void char_parse_fromlogin_ban(int fd) +static void char_parse_fromlogin_ban(int fd) { mapif->ban(RFIFOL(fd,2), RFIFOB(fd,6), RFIFOL(fd,7)); // disconnect player if online on char-server @@ -2528,7 +2532,7 @@ void char_parse_fromlogin_ban(int fd) RFIFOSKIP(fd,11); } -void char_parse_fromlogin_kick(int fd) +static void char_parse_fromlogin_kick(int fd) { int aid = RFIFOL(fd,2); struct online_char_data* character = (struct online_char_data*)idb_get(chr->online_char_db, aid); @@ -2558,7 +2562,7 @@ void char_parse_fromlogin_kick(int fd) idb_remove(auth_db, aid);// reject auth attempts from map-server } -void char_update_ip(int fd) +static void char_update_ip(int fd) { WFIFOHEAD(fd,6); WFIFOW(fd,0) = 0x2736; @@ -2566,7 +2570,7 @@ void char_update_ip(int fd) WFIFOSET(fd,6); } -void char_parse_fromlogin_update_ip(int fd) +static void char_parse_fromlogin_update_ip(int fd) { unsigned char buf[2]; uint32 new_ip = 0; @@ -2589,14 +2593,14 @@ void char_parse_fromlogin_update_ip(int fd) RFIFOSKIP(fd,2); } -void char_parse_fromlogin_accinfo2_failed(int fd) +static void char_parse_fromlogin_accinfo2_failed(int fd) { inter->accinfo2(false, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOL(fd,14), NULL, NULL, NULL, NULL, NULL, NULL, NULL, -1, 0, 0); RFIFOSKIP(fd,18); } -void char_parse_fromlogin_accinfo2_ok(int fd) +static void char_parse_fromlogin_accinfo2_ok(int fd) { inter->accinfo2(true, RFIFOL(fd,167), RFIFOL(fd,171), RFIFOL(fd,175), RFIFOL(fd,179), RFIFOP(fd,2), RFIFOP(fd,26), RFIFOP(fd,59), RFIFOP(fd,99), RFIFOP(fd,119), @@ -2604,7 +2608,8 @@ void char_parse_fromlogin_accinfo2_ok(int fd) RFIFOSKIP(fd,183); } -int char_parse_fromlogin(int fd) { +static int char_parse_fromlogin(int fd) +{ // only process data from the login-server if( fd != chr->login_fd ) { ShowDebug("chr->parse_fromlogin: Disconnecting invalid session #%d (is not the login-server)\n", fd); @@ -2736,7 +2741,7 @@ int char_parse_fromlogin(int fd) { return 0; } -int char_request_accreg2(int account_id, int char_id) +static int char_request_accreg2(int account_id, int char_id) { if (chr->login_fd > 0) { WFIFOHEAD(chr->login_fd,10); @@ -2752,7 +2757,8 @@ int char_request_accreg2(int account_id, int char_id) /** * Handles global account reg saving that continues with chr->global_accreg_to_login_add and global_accreg_to_send **/ -void char_global_accreg_to_login_start (int account_id, int char_id) { +static void char_global_accreg_to_login_start(int account_id, int char_id) +{ WFIFOHEAD(chr->login_fd, 60000 + 300); WFIFOW(chr->login_fd,0) = 0x2728; WFIFOW(chr->login_fd,2) = 14; @@ -2764,14 +2770,16 @@ void char_global_accreg_to_login_start (int account_id, int char_id) { /** * Completes global account reg saving that starts chr->global_accreg_to_login_start and continues with chr->global_accreg_to_login_add **/ -void char_global_accreg_to_login_send (void) { +static void char_global_accreg_to_login_send(void) +{ WFIFOSET(chr->login_fd, WFIFOW(chr->login_fd,2)); } /** * Handles global account reg saving that starts chr->global_accreg_to_login_start and ends with global_accreg_to_send **/ -void char_global_accreg_to_login_add (const char *key, unsigned int index, intptr_t val, bool is_string) { +static void char_global_accreg_to_login_add(const char *key, unsigned int index, intptr_t val, bool is_string) +{ int nlen = WFIFOW(chr->login_fd, 2); size_t len = strlen(key)+1; @@ -2818,7 +2826,8 @@ void char_global_accreg_to_login_add (const char *key, unsigned int index, intpt } } -void char_read_fame_list(void) { +static void char_read_fame_list(void) +{ int i; char* data; size_t len; @@ -2876,7 +2885,8 @@ void char_read_fame_list(void) { } // Send map-servers the fame ranking lists -int char_send_fame_list(int fd) { +static int char_send_fame_list(int fd) +{ int i, len = 8; unsigned char buf[32000]; @@ -2911,7 +2921,8 @@ int char_send_fame_list(int fd) { return 0; } -void char_update_fame_list(int type, int index, int fame) { +static void char_update_fame_list(int type, int index, int fame) +{ unsigned char buf[8]; WBUFW(buf,0) = 0x2b22; WBUFB(buf,2) = type; @@ -2922,7 +2933,7 @@ void char_update_fame_list(int type, int index, int fame) { //Loads a character's name and stores it in the buffer given (must be NAME_LENGTH in size) and not NULL //Returns 1 on found, 0 on not found (buffer is filled with Unknown char name) -int char_loadName(int char_id, char* name) +static int char_loadName(int char_id, char *name) { char* data; size_t len; @@ -2942,13 +2953,13 @@ int char_loadName(int char_id, char* name) return 0; } -void char_parse_frommap_datasync(int fd) +static void char_parse_frommap_datasync(int fd) { sockt->datasync(fd, false); RFIFOSKIP(fd,RFIFOW(fd,2)); } -void char_parse_frommap_skillid2idx(int fd) +static void char_parse_frommap_skillid2idx(int fd) { int i; int j = RFIFOW(fd, 2) - 4; @@ -2966,7 +2977,7 @@ void char_parse_frommap_skillid2idx(int fd) RFIFOSKIP(fd, RFIFOW(fd, 2)); } -void char_map_received_ok(int fd) +static void char_map_received_ok(int fd) { WFIFOHEAD(fd, 3 + NAME_LENGTH); WFIFOW(fd,0) = 0x2afb; @@ -2975,7 +2986,7 @@ void char_map_received_ok(int fd) WFIFOSET(fd,3+NAME_LENGTH); } -void char_send_maps(int fd, int id, int j) +static void char_send_maps(int fd, int id, int j) { int k,i; @@ -3012,7 +3023,7 @@ void char_send_maps(int fd, int id, int j) } } -void char_parse_frommap_map_names(int fd, int id) +static void char_parse_frommap_map_names(int fd, int id) { int i; @@ -3033,7 +3044,7 @@ void char_parse_frommap_map_names(int fd, int id) RFIFOSKIP(fd,RFIFOW(fd,2)); } -void char_send_scdata(int fd, int aid, int cid) +static void char_send_scdata(int fd, int aid, int cid) { #ifdef ENABLE_SC_SAVING if( SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `type`, `tick`, `val1`, `val2`, `val3`, `val4` " @@ -3087,7 +3098,7 @@ void char_send_scdata(int fd, int aid, int cid) #endif } -void char_parse_frommap_request_scdata(int fd) +static void char_parse_frommap_request_scdata(int fd) { #ifdef ENABLE_SC_SAVING int aid = RFIFOL(fd,2); @@ -3097,7 +3108,7 @@ void char_parse_frommap_request_scdata(int fd) RFIFOSKIP(fd, 10); } -void char_parse_frommap_set_users_count(int fd, int id) +static void char_parse_frommap_set_users_count(int fd, int id) { if (RFIFOW(fd,2) != chr->server[id].users) { chr->server[id].users = RFIFOW(fd,2); @@ -3106,7 +3117,7 @@ void char_parse_frommap_set_users_count(int fd, int id) RFIFOSKIP(fd, 4); } -void char_parse_frommap_set_users(int fd, int id) +static void char_parse_frommap_set_users(int fd, int id) { //TODO: When data mismatches memory, update guild/party online/offline states. int i; @@ -3129,7 +3140,7 @@ void char_parse_frommap_set_users(int fd, int id) RFIFOSKIP(fd,RFIFOW(fd,2)); } -void char_save_character_ack(int fd, int aid, int cid) +static void char_save_character_ack(int fd, int aid, int cid) { WFIFOHEAD(fd,10); WFIFOW(fd,0) = 0x2b21; //Save ack only needed on final save. @@ -3138,7 +3149,7 @@ void char_save_character_ack(int fd, int aid, int cid) WFIFOSET(fd,10); } -void char_parse_frommap_save_character(int fd, int id) +static void char_parse_frommap_save_character(int fd, int id) { int aid = RFIFOL(fd,4), cid = RFIFOL(fd,8), size = RFIFOW(fd,2); struct online_char_data* character; @@ -3172,7 +3183,7 @@ void char_parse_frommap_save_character(int fd, int id) // 0 - not ok // 1 - ok -void char_select_ack(int fd, int account_id, uint8 flag) +static void char_select_ack(int fd, int account_id, uint8 flag) { WFIFOHEAD(fd,7); WFIFOW(fd,0) = 0x2b03; @@ -3181,7 +3192,7 @@ void char_select_ack(int fd, int account_id, uint8 flag) WFIFOSET(fd,7); } -void char_parse_frommap_char_select_req(int fd) +static void char_parse_frommap_char_select_req(int fd) { int account_id = RFIFOL(fd,2); uint32 login_id1 = RFIFOL(fd,6); @@ -3218,7 +3229,7 @@ void char_parse_frommap_char_select_req(int fd) } } -void char_change_map_server_ack(int fd, const uint8 *data, bool ok) +static void char_change_map_server_ack(int fd, const uint8 *data, bool ok) { WFIFOHEAD(fd,30); WFIFOW(fd,0) = 0x2b06; @@ -3228,7 +3239,7 @@ void char_change_map_server_ack(int fd, const uint8 *data, bool ok) WFIFOSET(fd,30); } -void char_parse_frommap_change_map_server(int fd) +static void char_parse_frommap_change_map_server(int fd) { int map_id, map_fd = -1; struct mmo_charstatus* char_data; @@ -3281,7 +3292,7 @@ void char_parse_frommap_change_map_server(int fd) RFIFOSKIP(fd,39); } -void char_parse_frommap_remove_friend(int fd) +static void char_parse_frommap_remove_friend(int fd) { int char_id = RFIFOL(fd,2); int friend_id = RFIFOL(fd,6); @@ -3292,7 +3303,7 @@ void char_parse_frommap_remove_friend(int fd) RFIFOSKIP(fd,10); } -void char_char_name_ack(int fd, int char_id) +static void char_char_name_ack(int fd, int char_id) { WFIFOHEAD(fd,30); WFIFOW(fd,0) = 0x2b09; @@ -3306,13 +3317,13 @@ void char_char_name_ack(int fd, int char_id) WFIFOSET(fd,30); } -void char_parse_frommap_char_name_request(int fd) +static void char_parse_frommap_char_name_request(int fd) { chr->char_name_ack(fd, RFIFOL(fd,2)); RFIFOSKIP(fd,6); } -void char_parse_frommap_change_email(int fd) +static void char_parse_frommap_change_email(int fd) { if (chr->login_fd > 0) { // don't send request if no login-server WFIFOHEAD(chr->login_fd,86); @@ -3323,7 +3334,7 @@ void char_parse_frommap_change_email(int fd) RFIFOSKIP(fd, 86); } -void char_ban(int account_id, int char_id, time_t *unban_time, short year, short month, short day, short hour, short minute, short second) +static void char_ban(int account_id, int char_id, time_t *unban_time, short year, short month, short day, short hour, short minute, short second) { time_t timestamp; struct tm *tmtime; @@ -3365,7 +3376,7 @@ void char_ban(int account_id, int char_id, time_t *unban_time, short year, short } } -void char_unban(int char_id, int *result) +static void char_unban(int char_id, int *result) { /* handled by char server, so no redirection */ if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `unban_time` = '0' WHERE `char_id` = '%d' LIMIT 1", char_db, char_id) ) { @@ -3375,7 +3386,7 @@ void char_unban(int char_id, int *result) } } -void char_ask_name_ack(int fd, int acc, const char* name, int type, int result) +static void char_ask_name_ack(int fd, int acc, const char *name, int type, int result) { nullpo_retv(name); WFIFOHEAD(fd,34); @@ -3397,7 +3408,7 @@ void char_ask_name_ack(int fd, int acc, const char* name, int type, int result) * @retval 0 in case of success. * @retval 1 in case of failure. */ -int char_changecharsex(int char_id, int sex) +static int char_changecharsex(int char_id, int sex) { int class = 0, guild_id = 0, account_id = 0; char *data; @@ -3430,7 +3441,7 @@ int char_changecharsex(int char_id, int sex) return 0; } -void char_parse_frommap_change_account(int fd) +static void char_parse_frommap_change_account(int fd) { int result = 0; // 0-login-server request done, 1-player not found, 2-gm level too low, 3-login-server offline char esc_name[NAME_LENGTH*2+1]; @@ -3516,7 +3527,7 @@ void char_parse_frommap_change_account(int fd) } } -void char_parse_frommap_fame_list(int fd) +static void char_parse_frommap_fame_list(int fd) { int cid = RFIFOL(fd, 2); int fame = RFIFOL(fd, 6); @@ -3567,13 +3578,13 @@ void char_parse_frommap_fame_list(int fd) RFIFOSKIP(fd,11); } -void char_parse_frommap_divorce_char(int fd) +static void char_parse_frommap_divorce_char(int fd) { chr->divorce_char_sql(RFIFOL(fd,2), RFIFOL(fd,6)); RFIFOSKIP(fd,10); } -void char_parse_frommap_ragsrvinfo(int fd) +static void char_parse_frommap_ragsrvinfo(int fd) { char esc_server_name[sizeof(chr->server_name)*2+1]; @@ -3587,32 +3598,32 @@ void char_parse_frommap_ragsrvinfo(int fd) RFIFOSKIP(fd,14); } -void char_parse_frommap_set_char_offline(int fd) +static void char_parse_frommap_set_char_offline(int fd) { chr->set_char_offline(RFIFOL(fd,2),RFIFOL(fd,6)); RFIFOSKIP(fd,10); } -void char_parse_frommap_set_all_offline(int fd, int id) +static void char_parse_frommap_set_all_offline(int fd, int id) { chr->set_all_offline(id); RFIFOSKIP(fd,2); } -void char_parse_frommap_set_char_online(int fd, int id) +static void char_parse_frommap_set_char_online(int fd, int id) { chr->set_char_online(id, RFIFOL(fd,2),RFIFOL(fd,6)); RFIFOSKIP(fd,10); } -void char_parse_frommap_build_fame_list(int fd) +static void char_parse_frommap_build_fame_list(int fd) { chr->read_fame_list(); chr->send_fame_list(-1); RFIFOSKIP(fd,2); } -void char_parse_frommap_save_status_change_data(int fd) +static void char_parse_frommap_save_status_change_data(int fd) { #ifdef ENABLE_SC_SAVING int aid = RFIFOL(fd, 4); @@ -3647,20 +3658,20 @@ void char_parse_frommap_save_status_change_data(int fd) RFIFOSKIP(fd, RFIFOW(fd, 2)); } -void char_send_pong(int fd) +static void char_send_pong(int fd) { WFIFOHEAD(fd,2); WFIFOW(fd,0) = 0x2b24; WFIFOSET(fd,2); } -void char_parse_frommap_ping(int fd) +static void char_parse_frommap_ping(int fd) { chr->send_pong(fd); RFIFOSKIP(fd,2); } -void char_map_auth_ok(int fd, int account_id, struct char_auth_node* node, struct mmo_charstatus* cd) +static void char_map_auth_ok(int fd, int account_id, struct char_auth_node *node, struct mmo_charstatus *cd) { nullpo_retv(cd); WFIFOHEAD(fd,25 + sizeof(struct mmo_charstatus)); @@ -3687,7 +3698,7 @@ void char_map_auth_ok(int fd, int account_id, struct char_auth_node* node, struc WFIFOSET(fd, WFIFOW(fd,2)); } -void char_map_auth_failed(int fd, int account_id, int char_id, int login_id1, char sex, uint32 ip) +static void char_map_auth_failed(int fd, int account_id, int char_id, int login_id1, char sex, uint32 ip) { WFIFOHEAD(fd,19); WFIFOW(fd,0) = 0x2b27; @@ -3699,7 +3710,7 @@ void char_map_auth_failed(int fd, int account_id, int char_id, int login_id1, ch WFIFOSET(fd,19); } -void char_parse_frommap_auth_request(int fd, int id) +static void char_parse_frommap_auth_request(int fd, int id) { struct mmo_charstatus char_dat; struct char_auth_node* node; @@ -3752,14 +3763,14 @@ void char_parse_frommap_auth_request(int fd, int id) } } -void char_parse_frommap_update_ip(int fd, int id) +static void char_parse_frommap_update_ip(int fd, int id) { chr->server[id].ip = ntohl(RFIFOL(fd, 2)); ShowInfo("Updated IP address of map-server #%d to %u.%u.%u.%u.\n", id, CONVIP(chr->server[id].ip)); RFIFOSKIP(fd,6); } -void char_parse_frommap_scdata_update(int fd) +static void char_parse_frommap_scdata_update(int fd) { int account_id = RFIFOL(fd, 2); int char_id = RFIFOL(fd, 6); @@ -3779,7 +3790,7 @@ void char_parse_frommap_scdata_update(int fd) RFIFOSKIP(fd, 28); } -void char_parse_frommap_scdata_delete(int fd) +static void char_parse_frommap_scdata_delete(int fd) { int account_id = RFIFOL(fd, 2); int char_id = RFIFOL(fd, 6); @@ -3793,7 +3804,7 @@ void char_parse_frommap_scdata_delete(int fd) RFIFOSKIP(fd, 12); } -int char_parse_frommap(int fd) +static int char_parse_frommap(int fd) { int id; @@ -4025,14 +4036,14 @@ int char_parse_frommap(int fd) return 0; } -void do_init_mapif(void) +static void do_init_mapif(void) { int i; for( i = 0; i < ARRAYLENGTH(chr->server); ++i ) mapif->server_init(i); } -void do_final_mapif(void) +static void do_final_mapif(void) { int i; for( i = 0; i < ARRAYLENGTH(chr->server); ++i ) @@ -4041,7 +4052,7 @@ void do_final_mapif(void) // Searches for the mapserver that has a given map (and optionally ip/port, if not -1). // If found, returns the server's index in the 'server' array (otherwise returns -1). -int char_search_mapserver(unsigned short map, uint32 ip, uint16 port) +static int char_search_mapserver(unsigned short map, uint32 ip, uint16 port) { int i, j; @@ -4073,7 +4084,7 @@ static int char_mapif_init(int fd) * @retval 0 if it is a WAN IP. * @return the appropriate LAN server address to send, if it is a LAN IP. */ -uint32 char_lan_subnet_check(uint32 ip) +static uint32 char_lan_subnet_check(uint32 ip) { struct s_subnet lan = {0}; if (sockt->lan_subnet_check(ip, &lan)) { @@ -4093,7 +4104,7 @@ uint32 char_lan_subnet_check(uint32 ip) /// 4 (0x71a): To delete a character you must withdraw from the guild. /// 5 (0x71b): To delete a character you must withdraw from the party. /// Any (0x718): An unknown error has occurred. -void char_delete2_ack(int fd, int char_id, uint32 result, time_t delete_date) +static void char_delete2_ack(int fd, int char_id, uint32 result, time_t delete_date) {// HC: <0828>.W .L .L .L WFIFOHEAD(fd,14); WFIFOW(fd,0) = 0x828; @@ -4108,7 +4119,7 @@ void char_delete2_ack(int fd, int char_id, uint32 result, time_t delete_date) WFIFOSET(fd,14); } -void char_delete2_accept_actual_ack(int fd, int char_id, uint32 result) +static void char_delete2_accept_actual_ack(int fd, int char_id, uint32 result) { WFIFOHEAD(fd,10); WFIFOW(fd,0) = 0x82a; @@ -4125,7 +4136,7 @@ void char_delete2_accept_actual_ack(int fd, int char_id, uint32 result) /// 4 (0x71d): Deleting not yet possible time. /// 5 (0x71e): Date of birth do not match. /// Any (0x718): An unknown error has occurred. -void char_delete2_accept_ack(int fd, int char_id, uint32 result) +static void char_delete2_accept_ack(int fd, int char_id, uint32 result) {// HC: <082a>.W .L .L #if PACKETVER >= 20130000 /* not sure the exact date -- must refresh or client gets stuck */ if( result == 1 ) { @@ -4140,7 +4151,7 @@ void char_delete2_accept_ack(int fd, int char_id, uint32 result) /// 1 (0x718): none/success, (if char id not in deletion process): An unknown error has occurred. /// 2 (0x719): A database error occurred. /// Any (0x718): An unknown error has occurred. -void char_delete2_cancel_ack(int fd, int char_id, uint32 result) +static void char_delete2_cancel_ack(int fd, int char_id, uint32 result) {// HC: <082c>.W .L .L WFIFOHEAD(fd,10); WFIFOW(fd,0) = 0x82c; @@ -4149,7 +4160,7 @@ void char_delete2_cancel_ack(int fd, int char_id, uint32 result) WFIFOSET(fd,10); } -static void char_delete2_req(int fd, struct char_session_data* sd) +static void char_delete2_req(int fd, struct char_session_data *sd) {// CH: <0827>.W .L int char_id, i; char* data; @@ -4220,7 +4231,7 @@ static void char_delete2_req(int fd, struct char_session_data* sd) chr->delete2_ack(fd, char_id, 1, delete_date); // 1: success } -static void char_delete2_accept(int fd, struct char_session_data* sd) +static void char_delete2_accept(int fd, struct char_session_data *sd) {// CH: <0829>.W .L .6B char birthdate[8+1]; int char_id, i; @@ -4292,7 +4303,7 @@ static void char_delete2_accept(int fd, struct char_session_data* sd) chr->delete2_accept_ack(fd, char_id, 1); // 1: success } -static void char_delete2_cancel(int fd, struct char_session_data* sd) +static void char_delete2_cancel(int fd, struct char_session_data *sd) {// CH: <082b>.W .L int char_id, i; @@ -4319,14 +4330,14 @@ static void char_delete2_cancel(int fd, struct char_session_data* sd) chr->delete2_cancel_ack(fd, char_id, 1); // 1: success } -void char_send_account_id(int fd, int account_id) +static void char_send_account_id(int fd, int account_id) { WFIFOHEAD(fd,4); WFIFOL(fd,0) = account_id; WFIFOSET(fd,4); } -void char_parse_char_connect(int fd, struct char_session_data* sd, uint32 ipl) +static void char_parse_char_connect(int fd, struct char_session_data *sd, uint32 ipl) { int account_id = RFIFOL(fd,2); uint32 login_id1 = RFIFOL(fd,6); @@ -4392,7 +4403,7 @@ void char_parse_char_connect(int fd, struct char_session_data* sd, uint32 ipl) } } -void char_send_map_info(int fd, int i, uint32 subnet_map_ip, struct mmo_charstatus *cd, char *dnsHost) +static void char_send_map_info(int fd, int i, uint32 subnet_map_ip, struct mmo_charstatus *cd, char *dnsHost) { #if PACKETVER < 20170329 const int cmd = 0x71; @@ -4420,7 +4431,7 @@ void char_send_map_info(int fd, int i, uint32 subnet_map_ip, struct mmo_charstat WFIFOSET(fd, len); } -void char_send_wait_char_server(int fd) +static void char_send_wait_char_server(int fd) { WFIFOHEAD(fd, 24); WFIFOW(fd, 0) = 0x840; @@ -4429,7 +4440,7 @@ void char_send_wait_char_server(int fd) WFIFOSET(fd, 24); } -int char_search_default_maps_mapserver(struct mmo_charstatus *cd) +static int char_search_default_maps_mapserver(struct mmo_charstatus *cd) { int i; int j; @@ -4461,8 +4472,8 @@ int char_search_default_maps_mapserver(struct mmo_charstatus *cd) return i; } -void char_parse_char_select(int fd, struct char_session_data* sd, uint32 ipl) __attribute__((nonnull (2))); -void char_parse_char_select(int fd, struct char_session_data* sd, uint32 ipl) +static void char_parse_char_select(int fd, struct char_session_data *sd, uint32 ipl) __attribute__((nonnull (2))); +static void char_parse_char_select(int fd, struct char_session_data *sd, uint32 ipl) { struct mmo_charstatus char_dat; struct mmo_charstatus *cd; @@ -4592,7 +4603,7 @@ void char_parse_char_select(int fd, struct char_session_data* sd, uint32 ipl) idb_put(auth_db, sd->account_id, node); } -void char_creation_failed(int fd, int result) +static void char_creation_failed(int fd, int result) { WFIFOHEAD(fd,3); WFIFOW(fd,0) = 0x6e; @@ -4615,7 +4626,7 @@ void char_creation_failed(int fd, int result) WFIFOSET(fd,3); } -void char_creation_ok(int fd, struct mmo_charstatus *char_dat) +static void char_creation_ok(int fd, struct mmo_charstatus *char_dat) { int len; @@ -4626,8 +4637,8 @@ void char_creation_ok(int fd, struct mmo_charstatus *char_dat) WFIFOSET(fd,len); } -void char_parse_char_create_new_char(int fd, struct char_session_data* sd) __attribute__((nonnull (2))); -void char_parse_char_create_new_char(int fd, struct char_session_data* sd) +static void char_parse_char_create_new_char(int fd, struct char_session_data *sd) __attribute__((nonnull (2))); +static void char_parse_char_create_new_char(int fd, struct char_session_data *sd) { int result; if (!enable_char_creation) { @@ -4680,7 +4691,7 @@ void char_parse_char_create_new_char(int fd, struct char_session_data* sd) // flag: // 0 = Incorrect Email address -void char_delete_char_failed(int fd, int flag) +static void char_delete_char_failed(int fd, int flag) { WFIFOHEAD(fd,3); WFIFOW(fd,0) = 0x70; @@ -4688,15 +4699,15 @@ void char_delete_char_failed(int fd, int flag) WFIFOSET(fd,3); } -void char_delete_char_ok(int fd) +static void char_delete_char_ok(int fd) { WFIFOHEAD(fd,2); WFIFOW(fd,0) = 0x6f; WFIFOSET(fd,2); } -void char_parse_char_delete_char(int fd, struct char_session_data* sd, unsigned short cmd) __attribute__((nonnull (2))); -void char_parse_char_delete_char(int fd, struct char_session_data* sd, unsigned short cmd) +static void char_parse_char_delete_char(int fd, struct char_session_data *sd, unsigned short cmd) __attribute__((nonnull (2))); +static void char_parse_char_delete_char(int fd, struct char_session_data *sd, unsigned short cmd) { char email[40]; int cid = RFIFOL(fd,2); @@ -4750,12 +4761,12 @@ void char_parse_char_delete_char(int fd, struct char_session_data* sd, unsigned chr->delete_char_ok(fd); } -void char_parse_char_ping(int fd) +static void char_parse_char_ping(int fd) { RFIFOSKIP(fd,6); } -void char_allow_rename(int fd, int flag) +static void char_allow_rename(int fd, int flag) { WFIFOHEAD(fd, 4); WFIFOW(fd,0) = 0x28e; @@ -4763,8 +4774,8 @@ void char_allow_rename(int fd, int flag) WFIFOSET(fd,4); } -void char_parse_char_rename_char(int fd, struct char_session_data* sd) __attribute__((nonnull (2))); -void char_parse_char_rename_char(int fd, struct char_session_data* sd) +static void char_parse_char_rename_char(int fd, struct char_session_data *sd) __attribute__((nonnull (2))); +static void char_parse_char_rename_char(int fd, struct char_session_data *sd) { int i, cid =RFIFOL(fd,2); char name[NAME_LENGTH]; @@ -4786,8 +4797,8 @@ void char_parse_char_rename_char(int fd, struct char_session_data* sd) chr->allow_rename(fd, i); } -void char_parse_char_rename_char2(int fd, struct char_session_data* sd) __attribute__((nonnull (2))); -void char_parse_char_rename_char2(int fd, struct char_session_data* sd) +static void char_parse_char_rename_char2(int fd, struct char_session_data *sd) __attribute__((nonnull (2))); +static void char_parse_char_rename_char2(int fd, struct char_session_data *sd) { int i, aid = RFIFOL(fd,2), cid =RFIFOL(fd,6); char name[NAME_LENGTH]; @@ -4811,7 +4822,7 @@ void char_parse_char_rename_char2(int fd, struct char_session_data* sd) chr->allow_rename(fd, i); } -void char_rename_char_ack(int fd, int flag) +static void char_rename_char_ack(int fd, int flag) { WFIFOHEAD(fd, 4); WFIFOW(fd,0) = 0x290; @@ -4819,8 +4830,8 @@ void char_rename_char_ack(int fd, int flag) WFIFOSET(fd,4); } -void char_parse_char_rename_char_confirm(int fd, struct char_session_data* sd) __attribute__((nonnull (2))); -void char_parse_char_rename_char_confirm(int fd, struct char_session_data* sd) +static void char_parse_char_rename_char_confirm(int fd, struct char_session_data *sd) __attribute__((nonnull (2))); +static void char_parse_char_rename_char_confirm(int fd, struct char_session_data *sd) { int i; int cid = RFIFOL(fd,2); @@ -4834,7 +4845,7 @@ void char_parse_char_rename_char_confirm(int fd, struct char_session_data* sd) chr->rename_char_ack(fd, i); } -void char_captcha_notsupported(int fd) +static void char_captcha_notsupported(int fd) { WFIFOHEAD(fd,5); WFIFOW(fd,0) = 0x7e9; @@ -4843,31 +4854,31 @@ void char_captcha_notsupported(int fd) WFIFOSET(fd,5); } -void char_parse_char_request_captcha(int fd) +static void char_parse_char_request_captcha(int fd) { chr->captcha_notsupported(fd); RFIFOSKIP(fd,8); } -void char_parse_char_check_captcha(int fd) +static void char_parse_char_check_captcha(int fd) { chr->captcha_notsupported(fd); RFIFOSKIP(fd,32); } -void char_parse_char_delete2_req(int fd, struct char_session_data* sd) +static void char_parse_char_delete2_req(int fd, struct char_session_data *sd) { chr->delete2_req(fd, sd); RFIFOSKIP(fd,6); } -void char_parse_char_delete2_accept(int fd, struct char_session_data* sd) +static void char_parse_char_delete2_accept(int fd, struct char_session_data *sd) { chr->delete2_accept(fd, sd); RFIFOSKIP(fd,12); } -void char_parse_char_delete2_cancel(int fd, struct char_session_data* sd) +static void char_parse_char_delete2_cancel(int fd, struct char_session_data *sd) { chr->delete2_cancel(fd, sd); RFIFOSKIP(fd,6); @@ -4876,7 +4887,7 @@ void char_parse_char_delete2_cancel(int fd, struct char_session_data* sd) // flag: // 0 - ok // 3 - error -void char_login_map_server_ack(int fd, uint8 flag) +static void char_login_map_server_ack(int fd, uint8 flag) { WFIFOHEAD(fd,3); WFIFOW(fd,0) = 0x2af9; @@ -4884,7 +4895,7 @@ void char_login_map_server_ack(int fd, uint8 flag) WFIFOSET(fd,3); } -void char_parse_char_login_map_server(int fd, uint32 ipl) +static void char_parse_char_login_map_server(int fd, uint32 ipl) { char l_user[24], l_pass[24]; int i; @@ -4916,8 +4927,8 @@ void char_parse_char_login_map_server(int fd, uint32 ipl) RFIFOSKIP(fd,60); } -void char_parse_char_pincode_check(int fd, struct char_session_data* sd) __attribute__((nonnull (2))); -void char_parse_char_pincode_check(int fd, struct char_session_data* sd) +static void char_parse_char_pincode_check(int fd, struct char_session_data *sd) __attribute__((nonnull (2))); +static void char_parse_char_pincode_check(int fd, struct char_session_data *sd) { if (RFIFOL(fd,2) == sd->account_id) pincode->check(fd, sd); @@ -4925,8 +4936,8 @@ void char_parse_char_pincode_check(int fd, struct char_session_data* sd) RFIFOSKIP(fd, 10); } -void char_parse_char_pincode_window(int fd, struct char_session_data* sd) __attribute__((nonnull (2))); -void char_parse_char_pincode_window(int fd, struct char_session_data* sd) +static void char_parse_char_pincode_window(int fd, struct char_session_data *sd) __attribute__((nonnull (2))); +static void char_parse_char_pincode_window(int fd, struct char_session_data *sd) { if (RFIFOL(fd,2) == sd->account_id) pincode->loginstate(fd, sd, PINCODE_LOGIN_NOTSET); @@ -4934,8 +4945,8 @@ void char_parse_char_pincode_window(int fd, struct char_session_data* sd) RFIFOSKIP(fd, 6); } -void char_parse_char_pincode_change(int fd, struct char_session_data* sd) __attribute__((nonnull (2))); -void char_parse_char_pincode_change(int fd, struct char_session_data* sd) +static void char_parse_char_pincode_change(int fd, struct char_session_data *sd) __attribute__((nonnull (2))); +static void char_parse_char_pincode_change(int fd, struct char_session_data *sd) { if (RFIFOL(fd,2) == sd->account_id) pincode->change(fd, sd); @@ -4943,21 +4954,21 @@ void char_parse_char_pincode_change(int fd, struct char_session_data* sd) RFIFOSKIP(fd, 14); } -void char_parse_char_pincode_first_pin(int fd, struct char_session_data* sd) __attribute__((nonnull (2))); -void char_parse_char_pincode_first_pin(int fd, struct char_session_data* sd) +static void char_parse_char_pincode_first_pin(int fd, struct char_session_data *sd) __attribute__((nonnull (2))); +static void char_parse_char_pincode_first_pin(int fd, struct char_session_data *sd) { if (RFIFOL(fd,2) == sd->account_id) pincode->setnew (fd, sd); RFIFOSKIP(fd, 10); } -void char_parse_char_request_chars(int fd, struct char_session_data* sd) +static void char_parse_char_request_chars(int fd, struct char_session_data *sd) { chr->mmo_char_send099d(fd, sd); RFIFOSKIP(fd,2); } -void char_change_character_slot_ack(int fd, bool ret) +static void char_change_character_slot_ack(int fd, bool ret) { WFIFOHEAD(fd, 8); WFIFOW(fd, 0) = 0x8d5; @@ -4967,7 +4978,7 @@ void char_change_character_slot_ack(int fd, bool ret) WFIFOSET(fd, 8); } -void char_parse_char_move_character(int fd, struct char_session_data* sd) +static void char_parse_char_move_character(int fd, struct char_session_data *sd) { bool ret = chr->char_slotchange(sd, fd, RFIFOW(fd, 2), RFIFOW(fd, 4)); chr->change_character_slot_ack(fd, ret); @@ -4981,14 +4992,14 @@ void char_parse_char_move_character(int fd, struct char_session_data* sd) RFIFOSKIP(fd, 8); } -int char_parse_char_unknown_packet(int fd, uint32 ipl) +static int char_parse_char_unknown_packet(int fd, uint32 ipl) { ShowError("chr->parse_char: Received unknown packet "CL_WHITE"0x%x"CL_RESET" from ip '"CL_WHITE"%s"CL_RESET"'! Disconnecting!\n", RFIFOW(fd,0), sockt->ip2str(ipl, NULL)); sockt->eof(fd); return 1; } -int char_parse_char(int fd) +static int char_parse_char(int fd) { unsigned short cmd; struct char_session_data* sd; @@ -5205,7 +5216,8 @@ int char_parse_char(int fd) return 0; } -int char_broadcast_user_count(int tid, int64 tick, int id, intptr_t data) { +static int char_broadcast_user_count(int tid, int64 tick, int id, intptr_t data) +{ int users = chr->count_users(); // only send an update when needed @@ -5244,7 +5256,8 @@ static int char_send_accounts_tologin_sub(union DBKey key, struct DBData *data, return 0; } -int char_send_accounts_tologin(int tid, int64 tick, int id, intptr_t data) { +static int char_send_accounts_tologin(int tid, int64 tick, int id, intptr_t data) +{ if (chr->login_fd > 0 && sockt->session[chr->login_fd]) { // send account list to login server @@ -5261,7 +5274,8 @@ int char_send_accounts_tologin(int tid, int64 tick, int id, intptr_t data) { return 0; } -int char_check_connect_login_server(int tid, int64 tick, int id, intptr_t data) { +static int char_check_connect_login_server(int tid, int64 tick, int id, intptr_t data) +{ if (chr->login_fd > 0 && sockt->session[chr->login_fd] != NULL) return 0; @@ -5285,7 +5299,8 @@ int char_check_connect_login_server(int tid, int64 tick, int id, intptr_t data) //Invoked 15 seconds after mapif->disconnectplayer in case the map server doesn't //replies/disconnect the player we tried to kick. [Skotlex] //------------------------------------------------ -static int char_waiting_disconnect(int tid, int64 tick, int id, intptr_t data) { +static int char_waiting_disconnect(int tid, int64 tick, int id, intptr_t data) +{ struct online_char_data* character; if ((character = (struct online_char_data*)idb_get(chr->online_char_db, id)) != NULL && character->waiting_disconnect == tid) { //Mark it offline due to timeout. @@ -5312,7 +5327,8 @@ static int char_online_data_cleanup_sub(union DBKey key, struct DBData *data, va return 0; } -static int char_online_data_cleanup(int tid, int64 tick, int id, intptr_t data) { +static int char_online_data_cleanup(int tid, int64 tick, int id, intptr_t data) +{ chr->online_char_db->foreach(chr->online_char_db, chr->online_data_cleanup_sub); return 0; } @@ -5325,7 +5341,7 @@ static int char_online_data_cleanup(int tid, int64 tick, int id, intptr_t data) * * @retval false in case of error. */ -bool char_sql_config_read(const char *filename, bool imported) +static bool char_sql_config_read(const char *filename, bool imported) { struct config_t config; const struct config_setting_t *setting = NULL; @@ -5382,7 +5398,7 @@ bool char_sql_config_read(const char *filename, bool imported) * * @retval false in case of error. */ -bool char_sql_config_read_registry(const char *filename, const struct config_t *config, bool imported) +static bool char_sql_config_read_registry(const char *filename, const struct config_t *config, bool imported) { const struct config_setting_t *setting = NULL; @@ -5413,7 +5429,7 @@ bool char_sql_config_read_registry(const char *filename, const struct config_t * * * @retval false in case of error. */ -bool char_sql_config_read_pc(const char *filename, const struct config_t *config, bool imported) +static bool char_sql_config_read_pc(const char *filename, const struct config_t *config, bool imported) { const struct config_setting_t *setting = NULL; @@ -5459,7 +5475,7 @@ bool char_sql_config_read_pc(const char *filename, const struct config_t *config * * @retval false in case of error. */ -bool char_sql_config_read_guild(const char *filename, const struct config_t *config, bool imported) +static bool char_sql_config_read_guild(const char *filename, const struct config_t *config, bool imported) { const struct config_setting_t *setting = NULL; @@ -5493,7 +5509,7 @@ bool char_sql_config_read_guild(const char *filename, const struct config_t *con * * @retval false in case of error. */ -bool char_config_read(const char *filename, bool imported) +static bool char_config_read(const char *filename, bool imported) { struct config_t config; const char *import = NULL; @@ -5549,7 +5565,7 @@ bool char_config_read(const char *filename, bool imported) * * @retval false in case of error. */ -bool char_config_read_top(const char *filename, const struct config_t *config, bool imported) +static bool char_config_read_top(const char *filename, const struct config_t *config, bool imported) { const struct config_setting_t *setting = NULL; @@ -5593,7 +5609,7 @@ bool char_config_read_top(const char *filename, const struct config_t *config, b * * @retval false in case of error. */ -bool char_config_read_inter(const char *filename, const struct config_t *config, bool imported) +static bool char_config_read_inter(const char *filename, const struct config_t *config, bool imported) { const struct config_setting_t *setting = NULL; const char *str = NULL; @@ -5637,7 +5653,7 @@ bool char_config_read_inter(const char *filename, const struct config_t *config, * * @retval false in case of error. */ -bool char_config_read_database(const char *filename, const struct config_t *config, bool imported) +static bool char_config_read_database(const char *filename, const struct config_t *config, bool imported) { const struct config_setting_t *setting = NULL; @@ -5669,7 +5685,7 @@ bool char_config_read_database(const char *filename, const struct config_t *conf * * @retval false in case of error. */ -bool char_config_read_console(const char *filename, const struct config_t *config, bool imported) +static bool char_config_read_console(const char *filename, const struct config_t *config, bool imported) { const struct config_setting_t *setting; @@ -5702,7 +5718,7 @@ bool char_config_read_console(const char *filename, const struct config_t *confi * * @retval false in case of error. */ -bool char_config_read_player(const char *filename, const struct config_t *config, bool imported) +static bool char_config_read_player(const char *filename, const struct config_t *config, bool imported) { bool retval = true; @@ -5730,7 +5746,7 @@ bool char_config_read_player(const char *filename, const struct config_t *config * * @retval false in case of error. */ -bool char_config_read_player_fame(const char *filename, const struct config_t *config, bool imported) +static bool char_config_read_player_fame(const char *filename, const struct config_t *config, bool imported) { const struct config_setting_t *setting = NULL; @@ -5774,7 +5790,7 @@ bool char_config_read_player_fame(const char *filename, const struct config_t *c * * @retval false in case of error. */ -bool char_config_read_player_deletion(const char *filename, const struct config_t *config, bool imported) +static bool char_config_read_player_deletion(const char *filename, const struct config_t *config, bool imported) { const struct config_setting_t *setting = NULL; @@ -5803,7 +5819,7 @@ bool char_config_read_player_deletion(const char *filename, const struct config_ * * @retval false in case of error. */ -bool char_config_read_player_name(const char *filename, const struct config_t *config, bool imported) +static bool char_config_read_player_name(const char *filename, const struct config_t *config, bool imported) { const struct config_setting_t *setting = NULL; @@ -5829,7 +5845,7 @@ bool char_config_read_player_name(const char *filename, const struct config_t *c * * @param setting The already retrieved start_item setting. */ -void char_config_set_start_item(const struct config_setting_t *setting) +static void char_config_set_start_item(const struct config_setting_t *setting) { int i, count; @@ -5878,7 +5894,7 @@ void char_config_set_start_item(const struct config_setting_t *setting) * * @retval false in case of error. */ -bool char_config_read_player_new(const char *filename, const struct config_t *config, bool imported) +static bool char_config_read_player_new(const char *filename, const struct config_t *config, bool imported) { const struct config_setting_t *setting = NULL, *setting2 = NULL; #ifdef RENEWAL @@ -5934,7 +5950,7 @@ bool char_config_read_player_new(const char *filename, const struct config_t *co * * @retval false in case of error. */ -bool char_config_read_permission(const char *filename, const struct config_t *config, bool imported) +static bool char_config_read_permission(const char *filename, const struct config_t *config, bool imported) { const struct config_setting_t *setting = NULL; @@ -5978,7 +5994,7 @@ bool char_config_read_permission(const char *filename, const struct config_t *co * * @retval false in case of error. */ -bool char_config_set_ip(const char *type, const char *value, uint32 *out_ip, char *out_ip_str) +static bool char_config_set_ip(const char *type, const char *value, uint32 *out_ip, char *out_ip_str) { uint32 ip = 0; @@ -5996,7 +6012,8 @@ bool char_config_set_ip(const char *type, const char *value, uint32 *out_ip, cha return true; } -int do_final(void) { +int do_final(void) +{ int i; ShowStatus("Terminating...\n"); @@ -6055,12 +6072,13 @@ void do_abort(void) { } -void set_server_type(void) { +void set_server_type(void) +{ SERVER_TYPE = SERVER_TYPE_CHAR; } /// Called when a terminate signal is received. -void do_shutdown(void) +static void do_shutdown(void) { if( core->runflag != CHARSERVER_ST_SHUTDOWN ) { @@ -6136,7 +6154,8 @@ void cmdline_args_init_local(void) CMDLINEARG_DEF2(net-config, netconfig, "Alternative network configuration.", CMDLINE_OPT_PARAM); } -int do_init(int argc, char **argv) { +int do_init(int argc, char **argv) +{ int i; memset(&skillid2idx, 0, sizeof(skillid2idx)); diff --git a/src/char/geoip.c b/src/char/geoip.c index 78c89bcac..2870e5f0c 100644 --- a/src/char/geoip.c +++ b/src/char/geoip.c @@ -30,9 +30,9 @@ #include #include // for stat/lstat/fstat - [Dekamaster/Ultimate GM Tool] -struct s_geoip geoip_data; +static struct s_geoip geoip_data; -struct geoip_interface geoip_s; +static struct geoip_interface geoip_s; struct geoip_interface *geoip; /* [Dekamaster/Nightroad] */ @@ -40,36 +40,38 @@ struct geoip_interface *geoip; #define GEOIP_STRUCTURE_INFO_MAX_SIZE 20 #define GEOIP_COUNTRY_BEGIN 16776960 -const char * geoip_countryname[GEOIP_MAX_COUNTRIES] = {"Unknown","Asia/Pacific Region","Europe","Andorra","United Arab Emirates","Afghanistan","Antigua and Barbuda","Anguilla","Albania","Armenia","Netherlands Antilles", - "Angola","Antarctica","Argentina","American Samoa","Austria","Australia","Aruba","Azerbaijan","Bosnia and Herzegovina","Barbados", - "Bangladesh","Belgium","Burkina Faso","Bulgaria","Bahrain","Burundi","Benin","Bermuda","Brunei Darussalam","Bolivia", - "Brazil","Bahamas","Bhutan","Bouvet Island","Botswana","Belarus","Belize","Canada","Cocos (Keeling) Islands","Congo, The Democratic Republic of the", - "Central African Republic","Congo","Switzerland","Cote D'Ivoire","Cook Islands","Chile","Cameroon","China","Colombia","Costa Rica", - "Cuba","Cape Verde","Christmas Island","Cyprus","Czech Republic","Germany","Djibouti","Denmark","Dominica","Dominican Republic", - "Algeria","Ecuador","Estonia","Egypt","Western Sahara","Eritrea","Spain","Ethiopia","Finland","Fiji", - "Falkland Islands (Malvinas)","Micronesia, Federated States of","Faroe Islands","France","France, Metropolitan","Gabon","United Kingdom","Grenada","Georgia","French Guiana", - "Ghana","Gibraltar","Greenland","Gambia","Guinea","Guadeloupe","Equatorial Guinea","Greece","South Georgia and the South Sandwich Islands","Guatemala", - "Guam","Guinea-Bissau","Guyana","Hong Kong","Heard Island and McDonald Islands","Honduras","Croatia","Haiti","Hungary","Indonesia", - "Ireland","Israel","India","British Indian Ocean Territory","Iraq","Iran, Islamic Republic of","Iceland","Italy","Jamaica","Jordan", - "Japan","Kenya","Kyrgyzstan","Cambodia","Kiribati","Comoros","Saint Kitts and Nevis","Korea, Democratic People's Republic of","Korea, Republic of","Kuwait", - "Cayman Islands","Kazakhstan","Lao People's Democratic Republic","Lebanon","Saint Lucia","Liechtenstein","Sri Lanka","Liberia","Lesotho","Lithuania", - "Luxembourg","Latvia","Libyan Arab Jamahiriya","Morocco","Monaco","Moldova, Republic of","Madagascar","Marshall Islands","Macedonia","Mali", - "Myanmar","Mongolia","Macau","Northern Mariana Islands","Martinique","Mauritania","Montserrat","Malta","Mauritius","Maldives", - "Malawi","Mexico","Malaysia","Mozambique","Namibia","New Caledonia","Niger","Norfolk Island","Nigeria","Nicaragua", - "Netherlands","Norway","Nepal","Nauru","Niue","New Zealand","Oman","Panama","Peru","French Polynesia", - "Papua New Guinea","Philippines","Pakistan","Poland","Saint Pierre and Miquelon","Pitcairn Islands","Puerto Rico","Palestinian Territory","Portugal","Palau", - "Paraguay","Qatar","Reunion","Romania","Russian Federation","Rwanda","Saudi Arabia","Solomon Islands","Seychelles","Sudan", - "Sweden","Singapore","Saint Helena","Slovenia","Svalbard and Jan Mayen","Slovakia","Sierra Leone","San Marino","Senegal","Somalia","Suriname", - "Sao Tome and Principe","El Salvador","Syrian Arab Republic","Swaziland","Turks and Caicos Islands","Chad","French Southern Territories","Togo","Thailand", - "Tajikistan","Tokelau","Turkmenistan","Tunisia","Tonga","Timor-Leste","Turkey","Trinidad and Tobago","Tuvalu","Taiwan", - "Tanzania, United Republic of","Ukraine","Uganda","United States Minor Outlying Islands","United States","Uruguay","Uzbekistan","Holy See (Vatican City State)","Saint Vincent and the Grenadines","Venezuela", - "Virgin Islands, British","Virgin Islands, U.S.","Vietnam","Vanuatu","Wallis and Futuna","Samoa","Yemen","Mayotte","Serbia","South Africa", - "Zambia","Montenegro","Zimbabwe","Anonymous Proxy","Satellite Provider","Other","Aland Islands","Guernsey","Isle of Man","Jersey", - "Saint Barthelemy", "Saint Martin", "Bonaire, Saint Eustatius and Saba", "South Sudan"}; +static const char *geoip_countryname[GEOIP_MAX_COUNTRIES] = { + "Unknown","Asia/Pacific Region","Europe","Andorra","United Arab Emirates","Afghanistan","Antigua and Barbuda","Anguilla","Albania","Armenia","Netherlands Antilles", + "Angola","Antarctica","Argentina","American Samoa","Austria","Australia","Aruba","Azerbaijan","Bosnia and Herzegovina","Barbados", + "Bangladesh","Belgium","Burkina Faso","Bulgaria","Bahrain","Burundi","Benin","Bermuda","Brunei Darussalam","Bolivia", + "Brazil","Bahamas","Bhutan","Bouvet Island","Botswana","Belarus","Belize","Canada","Cocos (Keeling) Islands","Congo, The Democratic Republic of the", + "Central African Republic","Congo","Switzerland","Cote D'Ivoire","Cook Islands","Chile","Cameroon","China","Colombia","Costa Rica", + "Cuba","Cape Verde","Christmas Island","Cyprus","Czech Republic","Germany","Djibouti","Denmark","Dominica","Dominican Republic", + "Algeria","Ecuador","Estonia","Egypt","Western Sahara","Eritrea","Spain","Ethiopia","Finland","Fiji", + "Falkland Islands (Malvinas)","Micronesia, Federated States of","Faroe Islands","France","France, Metropolitan","Gabon","United Kingdom","Grenada","Georgia","French Guiana", + "Ghana","Gibraltar","Greenland","Gambia","Guinea","Guadeloupe","Equatorial Guinea","Greece","South Georgia and the South Sandwich Islands","Guatemala", + "Guam","Guinea-Bissau","Guyana","Hong Kong","Heard Island and McDonald Islands","Honduras","Croatia","Haiti","Hungary","Indonesia", + "Ireland","Israel","India","British Indian Ocean Territory","Iraq","Iran, Islamic Republic of","Iceland","Italy","Jamaica","Jordan", + "Japan","Kenya","Kyrgyzstan","Cambodia","Kiribati","Comoros","Saint Kitts and Nevis","Korea, Democratic People's Republic of","Korea, Republic of","Kuwait", + "Cayman Islands","Kazakhstan","Lao People's Democratic Republic","Lebanon","Saint Lucia","Liechtenstein","Sri Lanka","Liberia","Lesotho","Lithuania", + "Luxembourg","Latvia","Libyan Arab Jamahiriya","Morocco","Monaco","Moldova, Republic of","Madagascar","Marshall Islands","Macedonia","Mali", + "Myanmar","Mongolia","Macau","Northern Mariana Islands","Martinique","Mauritania","Montserrat","Malta","Mauritius","Maldives", + "Malawi","Mexico","Malaysia","Mozambique","Namibia","New Caledonia","Niger","Norfolk Island","Nigeria","Nicaragua", + "Netherlands","Norway","Nepal","Nauru","Niue","New Zealand","Oman","Panama","Peru","French Polynesia", + "Papua New Guinea","Philippines","Pakistan","Poland","Saint Pierre and Miquelon","Pitcairn Islands","Puerto Rico","Palestinian Territory","Portugal","Palau", + "Paraguay","Qatar","Reunion","Romania","Russian Federation","Rwanda","Saudi Arabia","Solomon Islands","Seychelles","Sudan", + "Sweden","Singapore","Saint Helena","Slovenia","Svalbard and Jan Mayen","Slovakia","Sierra Leone","San Marino","Senegal","Somalia","Suriname", + "Sao Tome and Principe","El Salvador","Syrian Arab Republic","Swaziland","Turks and Caicos Islands","Chad","French Southern Territories","Togo","Thailand", + "Tajikistan","Tokelau","Turkmenistan","Tunisia","Tonga","Timor-Leste","Turkey","Trinidad and Tobago","Tuvalu","Taiwan", + "Tanzania, United Republic of","Ukraine","Uganda","United States Minor Outlying Islands","United States","Uruguay","Uzbekistan","Holy See (Vatican City State)","Saint Vincent and the Grenadines","Venezuela", + "Virgin Islands, British","Virgin Islands, U.S.","Vietnam","Vanuatu","Wallis and Futuna","Samoa","Yemen","Mayotte","Serbia","South Africa", + "Zambia","Montenegro","Zimbabwe","Anonymous Proxy","Satellite Provider","Other","Aland Islands","Guernsey","Isle of Man","Jersey", + "Saint Barthelemy", "Saint Martin", "Bonaire, Saint Eustatius and Saba", "South Sudan" +}; /* [Dekamaster/Nightroad] */ /* WHY NOT A DBMAP: There are millions of entries in GeoIP and it has its own algorithm to go quickly through them, a DBMap wouldn't be efficient */ -const char* geoip_getcountry(uint32 ipnum) +static const char *geoip_getcountry(uint32 ipnum) { int depth; unsigned int x; @@ -111,7 +113,7 @@ const char* geoip_getcountry(uint32 ipnum) * Disables GeoIP * frees geoip.cache **/ -void geoip_final(bool shutdown) +static void geoip_final(bool shutdown) { if (geoip->data->cache) { aFree(geoip->data->cache); @@ -130,7 +132,7 @@ void geoip_final(bool shutdown) * geoip.cache should be freed after use! * http://dev.maxmind.com/geoip/legacy/geolite/ **/ -void geoip_init(void) +static void geoip_init(void) { int fno; char db_type = 1; diff --git a/src/char/int_auction.c b/src/char/int_auction.c index 9cd4c900c..1e5b0a06d 100644 --- a/src/char/int_auction.c +++ b/src/char/int_auction.c @@ -40,7 +40,7 @@ #include #include -struct inter_auction_interface inter_auction_s; +static struct inter_auction_interface inter_auction_s; struct inter_auction_interface *inter_auction; static int inter_auction_count(int char_id, bool buy) @@ -59,7 +59,7 @@ static int inter_auction_count(int char_id, bool buy) return i; } -void inter_auction_save(struct auction_data *auction) +static void inter_auction_save(struct auction_data *auction) { int j; StringBuf buf; @@ -91,7 +91,7 @@ void inter_auction_save(struct auction_data *auction) StrBuf->Destroy(&buf); } -unsigned int inter_auction_create(struct auction_data *auction) +static unsigned int inter_auction_create(struct auction_data *auction) { int j; StringBuf buf; @@ -148,7 +148,8 @@ unsigned int inter_auction_create(struct auction_data *auction) return auction->auction_id; } -static int inter_auction_end_timer(int tid, int64 tick, int id, intptr_t data) { +static int inter_auction_end_timer(int tid, int64 tick, int id, intptr_t data) +{ struct auction_data *auction; if( (auction = (struct auction_data *)idb_get(inter_auction->db, id)) != NULL ) { @@ -170,7 +171,7 @@ static int inter_auction_end_timer(int tid, int64 tick, int id, intptr_t data) { return 0; } -void inter_auction_delete(struct auction_data *auction) +static void inter_auction_delete(struct auction_data *auction) { unsigned int auction_id; nullpo_retv(auction); @@ -186,7 +187,7 @@ void inter_auction_delete(struct auction_data *auction) idb_remove(inter_auction->db, auction_id); } -void inter_auctions_fromsql(void) +static void inter_auctions_fromsql(void) { int i; struct auction_data *auction; @@ -262,7 +263,7 @@ void inter_auctions_fromsql(void) /*========================================== * Packets From Map Server *------------------------------------------*/ -int inter_auction_parse_frommap(int fd) +static int inter_auction_parse_frommap(int fd) { switch(RFIFOW(fd,0)) { @@ -277,7 +278,7 @@ int inter_auction_parse_frommap(int fd) return 1; } -int inter_auction_sql_init(void) +static int inter_auction_sql_init(void) { inter_auction->db = idb_alloc(DB_OPT_RELEASE_DATA); inter_auction->fromsql(); @@ -285,7 +286,7 @@ int inter_auction_sql_init(void) return 0; } -void inter_auction_sql_final(void) +static void inter_auction_sql_final(void) { inter_auction->db->destroy(inter_auction->db,NULL); diff --git a/src/char/int_clan.c b/src/char/int_clan.c index 1b875d7e1..9fb8ad95e 100644 --- a/src/char/int_clan.c +++ b/src/char/int_clan.c @@ -38,7 +38,7 @@ #include #include -struct inter_clan_interface inter_clan_s; +static struct inter_clan_interface inter_clan_s; struct inter_clan_interface *inter_clan; /** @@ -51,7 +51,7 @@ struct inter_clan_interface *inter_clan; * @param kick_interval Time needed to consider a player inactive and kick it * @return 0 on failure, 1 on success */ -int inter_clan_kick_inactive_members(int clan_id, int kick_interval) +static int inter_clan_kick_inactive_members(int clan_id, int kick_interval) { if (clan_id <= 0) { ShowError("inter_clan_kick_inactive_members: Invalid clan id received '%d'\n", clan_id); @@ -81,7 +81,7 @@ int inter_clan_kick_inactive_members(int clan_id, int kick_interval) * @param clan_id Id of the clan * @param kick_interval Time needed to consider a player inactive and ignore it on the count */ -int inter_clan_count_members(int clan_id, int kick_interval) +static int inter_clan_count_members(int clan_id, int kick_interval) { struct SqlStmt *stmt; int count = 0; @@ -130,7 +130,7 @@ int inter_clan_count_members(int clan_id, int kick_interval) // Must Return // 1 : ok // 0 : error -int inter_clan_parse_frommap(int fd) +static int inter_clan_parse_frommap(int fd) { RFIFOHEAD(fd); diff --git a/src/char/int_elemental.c b/src/char/int_elemental.c index 8aeb01704..175007b66 100644 --- a/src/char/int_elemental.c +++ b/src/char/int_elemental.c @@ -37,7 +37,7 @@ #include #include -struct inter_elemental_interface inter_elemental_s; +static struct inter_elemental_interface inter_elemental_s; struct inter_elemental_interface *inter_elemental; /** @@ -50,7 +50,7 @@ struct inter_elemental_interface *inter_elemental; * @param[in,out] ele The new elemental's data. * @retval false in case of errors. */ -bool inter_elemental_create(struct s_elemental *ele) +static bool inter_elemental_create(struct s_elemental *ele) { nullpo_retr(false, ele); Assert_retr(false, ele->elemental_id == 0); @@ -73,7 +73,7 @@ bool inter_elemental_create(struct s_elemental *ele) * @param ele The elemental's data. * @retval false in case of errors. */ -bool inter_elemental_save(const struct s_elemental *ele) +static bool inter_elemental_save(const struct s_elemental *ele) { nullpo_retr(false, ele); Assert_retr(false, ele->elemental_id > 0); @@ -90,7 +90,7 @@ bool inter_elemental_save(const struct s_elemental *ele) return true; } -bool inter_elemental_load(int ele_id, int char_id, struct s_elemental *ele) +static bool inter_elemental_load(int ele_id, int char_id, struct s_elemental *ele) { char* data; @@ -135,7 +135,7 @@ bool inter_elemental_load(int ele_id, int char_id, struct s_elemental *ele) return true; } -bool inter_elemental_delete(int ele_id) +static bool inter_elemental_delete(int ele_id) { if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `ele_id` = '%d'", elemental_db, ele_id) ) { Sql_ShowDebug(inter->sql_handle); @@ -145,18 +145,21 @@ bool inter_elemental_delete(int ele_id) return true; } -void inter_elemental_sql_init(void) { +static void inter_elemental_sql_init(void) +{ return; } -void inter_elemental_sql_final(void) { +static void inter_elemental_sql_final(void) +{ return; } /*========================================== * Inter Packets *------------------------------------------*/ -int inter_elemental_parse_frommap(int fd) { +static int inter_elemental_parse_frommap(int fd) +{ unsigned short cmd = RFIFOW(fd,0); switch (cmd) { diff --git a/src/char/int_guild.c b/src/char/int_guild.c index c74c7f008..e7315ed50 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -51,12 +51,13 @@ #define GUILD_ALLIANCE_TYPE_MASK 0x01 #define GUILD_ALLIANCE_REMOVE 0x08 -struct inter_guild_interface inter_guild_s; +static struct inter_guild_interface inter_guild_s; struct inter_guild_interface *inter_guild; static const char dataToHex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; -int inter_guild_save_timer(int tid, int64 tick, int id, intptr_t data) { +static int inter_guild_save_timer(int tid, int64 tick, int id, intptr_t data) +{ static int last_id = 0; //To know in which guild we were. int state = 0; //0: Have not reached last guild. 1: Reached last guild, ready for save. 2: Some guild saved, don't do further saving. struct DBIterator *iter = db_iterator(inter_guild->guild_db); @@ -101,7 +102,7 @@ int inter_guild_save_timer(int tid, int64 tick, int id, intptr_t data) { return 0; } -int inter_guild_removemember_tosql(int account_id, int char_id) +static int inter_guild_removemember_tosql(int account_id, int char_id) { if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE from `%s` where `account_id` = '%d' and `char_id` = '%d'", guild_member_db, account_id, char_id) ) Sql_ShowDebug(inter->sql_handle); @@ -111,7 +112,7 @@ int inter_guild_removemember_tosql(int account_id, int char_id) } // Save guild into sql -int inter_guild_tosql(struct guild *g,int flag) +static int inter_guild_tosql(struct guild *g, int flag) { // Table guild (GS_BASIC_MASK) // GS_EMBLEM `emblem_len`,`emblem_id`,`emblem_data` @@ -343,7 +344,7 @@ int inter_guild_tosql(struct guild *g,int flag) } // Read guild from sql -struct guild * inter_guild_fromsql(int guild_id) +static struct guild *inter_guild_fromsql(int guild_id) { struct guild *g; char* data; @@ -533,7 +534,7 @@ struct guild * inter_guild_fromsql(int guild_id) } // `guild_castle` (`castle_id`, `guild_id`, `economy`, `defense`, `triggerE`, `triggerD`, `nextTime`, `payTime`, `createTime`, `visibleC`, `visibleG0`, `visibleG1`, `visibleG2`, `visibleG3`, `visibleG4`, `visibleG5`, `visibleG6`, `visibleG7`) -int inter_guild_castle_tosql(struct guild_castle *gc) +static int inter_guild_castle_tosql(struct guild_castle *gc) { StringBuf buf; int i; @@ -557,7 +558,7 @@ int inter_guild_castle_tosql(struct guild_castle *gc) } // Read guild_castle from SQL -struct guild_castle* inter_guild_castle_fromsql(int castle_id) +static struct guild_castle *inter_guild_castle_fromsql(int castle_id) { char *data; int i; @@ -609,7 +610,8 @@ struct guild_castle* inter_guild_castle_fromsql(int castle_id) // Read exp_guild.txt -bool inter_guild_exp_parse_row(char* split[], int column, int current) { +static bool inter_guild_exp_parse_row(char *split[], int column, int current) +{ int64 exp = strtoll(split[0], NULL, 10); nullpo_retr(true, split); @@ -623,7 +625,8 @@ bool inter_guild_exp_parse_row(char* split[], int column, int current) { } -int inter_guild_CharOnline(int char_id, int guild_id) { +static int inter_guild_CharOnline(int char_id, int guild_id) +{ struct guild *g; int i; @@ -672,7 +675,7 @@ int inter_guild_CharOnline(int char_id, int guild_id) { return 1; } -int inter_guild_CharOffline(int char_id, int guild_id) +static int inter_guild_CharOffline(int char_id, int guild_id) { struct guild *g=NULL; int online_count, i; @@ -728,7 +731,7 @@ int inter_guild_CharOffline(int char_id, int guild_id) } // Initialize guild sql -int inter_guild_sql_init(void) +static int inter_guild_sql_init(void) { //Initialize the guild cache inter_guild->guild_db= idb_alloc(DB_OPT_RELEASE_DATA); @@ -745,7 +748,7 @@ int inter_guild_sql_init(void) /** * @see DBApply */ -int inter_guild_db_final(union DBKey key, struct DBData *data, va_list ap) +static int inter_guild_db_final(union DBKey key, struct DBData *data, va_list ap) { struct guild *g = DB->data2ptr(data); nullpo_ret(g); @@ -756,7 +759,7 @@ int inter_guild_db_final(union DBKey key, struct DBData *data, va_list ap) return 0; } -void inter_guild_sql_final(void) +static void inter_guild_sql_final(void) { inter_guild->guild_db->destroy(inter_guild->guild_db, inter_guild->db_final); db_destroy(inter_guild->castle_db); @@ -764,7 +767,7 @@ void inter_guild_sql_final(void) } // Get guild_id by its name. Returns 0 if not found, -1 on error. -int inter_guild_search_guildname(const char *str) +static int inter_guild_search_guildname(const char *str) { int guild_id; char esc_name[NAME_LENGTH*2+1]; @@ -807,7 +810,8 @@ static bool inter_guild_check_empty(struct guild *g) return true; } -unsigned int inter_guild_nextexp(int level) { +static unsigned int inter_guild_nextexp(int level) +{ if (level == 0) return 1; if (level <= 0 || level > MAX_GUILDLEVEL) @@ -816,7 +820,7 @@ unsigned int inter_guild_nextexp(int level) { return inter_guild->exp[level-1]; } -int inter_guild_checkskill(struct guild *g, int id) +static int inter_guild_checkskill(struct guild *g, int id) { int idx = id - GD_SKILLBASE; @@ -827,7 +831,7 @@ int inter_guild_checkskill(struct guild *g, int id) return g->skill[idx].lv; } -int inter_guild_calcinfo(struct guild *g) +static int inter_guild_calcinfo(struct guild *g) { int i,c; unsigned int nextexp; @@ -891,7 +895,7 @@ int inter_guild_calcinfo(struct guild *g) return 0; } -struct guild *inter_guild_create(const char *name, const struct guild_member *master) +static struct guild *inter_guild_create(const char *name, const struct guild_member *master) { struct guild *g; int i=0; @@ -965,7 +969,7 @@ struct guild *inter_guild_create(const char *name, const struct guild_member *ma } // Add member to guild -bool inter_guild_add_member(int guild_id, const struct guild_member *member) +static bool inter_guild_add_member(int guild_id, const struct guild_member *member) { struct guild * g; int i; @@ -993,7 +997,7 @@ bool inter_guild_add_member(int guild_id, const struct guild_member *member) } // Delete member from guild -bool inter_guild_leave(int guild_id, int account_id, int char_id, int flag, const char *mes, int map_fd) +static bool inter_guild_leave(int guild_id, int account_id, int char_id, int flag, const char *mes, int map_fd) { int i; @@ -1049,7 +1053,7 @@ bool inter_guild_leave(int guild_id, int account_id, int char_id, int flag, cons } // Change member info -bool inter_guild_update_member_info_short(int guild_id, int account_id, int char_id, int online, int lv, int16 class) +static bool inter_guild_update_member_info_short(int guild_id, int account_id, int char_id, int online, int lv, int16 class) { // Could speed up by manipulating only guild_member struct guild *g; @@ -1099,7 +1103,7 @@ bool inter_guild_update_member_info_short(int guild_id, int account_id, int char } // BreakGuild -bool inter_guild_disband(int guild_id) +static bool inter_guild_disband(int guild_id) { struct guild *g = inter_guild->fromsql(guild_id); if (g == NULL) @@ -1150,7 +1154,7 @@ bool inter_guild_disband(int guild_id) * Changes basic guild information * The types are available in mmo.h::guild_basic_info **/ -bool inter_guild_update_basic_info(int guild_id, int type, const void *data, int len) +static bool inter_guild_update_basic_info(int guild_id, int type, const void *data, int len) { struct guild *g; struct guild_skill gd_skill; @@ -1206,7 +1210,7 @@ bool inter_guild_update_basic_info(int guild_id, int type, const void *data, int } // Modification of the guild -bool inter_guild_update_member_info(int guild_id, int account_id, int char_id, int type, const char *data, int len) +static bool inter_guild_update_member_info(int guild_id, int account_id, int char_id, int type, const char *data, int len) { // Could make some improvement in speed, because only change guild_member int i; @@ -1314,12 +1318,12 @@ bool inter_guild_update_member_info(int guild_id, int account_id, int char_id, i return true; } -int inter_guild_sex_changed(int guild_id, int account_id, int char_id, short gender) +static int inter_guild_sex_changed(int guild_id, int account_id, int char_id, short gender) { return inter_guild->update_member_info(guild_id, account_id, char_id, GMI_GENDER, (const char*)&gender, sizeof(gender)); } -int inter_guild_charname_changed(int guild_id, int account_id, int char_id, char *name) +static int inter_guild_charname_changed(int guild_id, int account_id, int char_id, char *name) { struct guild *g; int i, flag = 0; @@ -1357,7 +1361,7 @@ int inter_guild_charname_changed(int guild_id, int account_id, int char_id, char } // Change a position desc -bool inter_guild_update_position(int guild_id, int idx, const struct guild_position *p) +static bool inter_guild_update_position(int guild_id, int idx, const struct guild_position *p) { // Could make some improvement in speed, because only change guild_position struct guild *g; @@ -1375,7 +1379,7 @@ bool inter_guild_update_position(int guild_id, int idx, const struct guild_posit } // Guild Skill UP -bool inter_guild_use_skill_point(int guild_id, uint16 skill_id, int account_id, int max) +static bool inter_guild_use_skill_point(int guild_id, uint16 skill_id, int account_id, int max) { struct guild * g; int idx = skill_id - GD_SKILLBASE; @@ -1396,7 +1400,7 @@ bool inter_guild_use_skill_point(int guild_id, uint16 skill_id, int account_id, } //Manual deletion of an alliance when partnering guild does not exists. [Skotlex] -bool inter_guild_remove_alliance(struct guild *g, int guild_id, int account_id1, int account_id2, int flag) +static bool inter_guild_remove_alliance(struct guild *g, int guild_id, int account_id1, int account_id2, int flag) { int i; char name[NAME_LENGTH]; @@ -1415,7 +1419,7 @@ bool inter_guild_remove_alliance(struct guild *g, int guild_id, int account_id1, } // Alliance modification -bool inter_guild_change_alliance(int guild_id1, int guild_id2, int account_id1, int account_id2, int flag) +static bool inter_guild_change_alliance(int guild_id1, int guild_id2, int account_id1, int account_id2, int flag) { // Could speed up struct guild *g[2] = { NULL }; @@ -1460,7 +1464,7 @@ bool inter_guild_change_alliance(int guild_id1, int guild_id2, int account_id1, } // Change guild message -bool inter_guild_update_notice(int guild_id, const char *mes1, const char *mes2) +static bool inter_guild_update_notice(int guild_id, const char *mes1, const char *mes2) { struct guild *g; @@ -1477,7 +1481,7 @@ bool inter_guild_update_notice(int guild_id, const char *mes1, const char *mes2) return true; } -bool inter_guild_update_emblem(int len, int guild_id, const char *data) +static bool inter_guild_update_emblem(int len, int guild_id, const char *data) { struct guild * g; @@ -1497,7 +1501,7 @@ bool inter_guild_update_emblem(int len, int guild_id, const char *data) return true; } -bool inter_guild_update_castle_data(int castle_id, int index, int value) +static bool inter_guild_update_castle_data(int castle_id, int index, int value) { struct guild_castle *gc = inter_guild->castle_fromsql(castle_id); @@ -1536,7 +1540,7 @@ bool inter_guild_update_castle_data(int castle_id, int index, int value) return true; } -bool inter_guild_change_leader(int guild_id, const char *name, int len) +static bool inter_guild_change_leader(int guild_id, const char *name, int len) { struct guild * g; struct guild_member gm; @@ -1582,7 +1586,7 @@ bool inter_guild_change_leader(int guild_id, const char *name, int len) // Must Return // 1 : ok // 0 : error -int inter_guild_parse_frommap(int fd) +static int inter_guild_parse_frommap(int fd) { RFIFOHEAD(fd); switch(RFIFOW(fd,0)) { @@ -1611,7 +1615,7 @@ int inter_guild_parse_frommap(int fd) return 1; } -int inter_guild_broken(int guild_id) +static int inter_guild_broken(int guild_id) { return mapif->guild_broken(guild_id, 0); } diff --git a/src/char/int_homun.c b/src/char/int_homun.c index 28ec848be..5a1c9d23f 100644 --- a/src/char/int_homun.c +++ b/src/char/int_homun.c @@ -37,14 +37,14 @@ #include #include -struct inter_homunculus_interface inter_homunculus_s; +static struct inter_homunculus_interface inter_homunculus_s; struct inter_homunculus_interface *inter_homunculus; -int inter_homunculus_sql_init(void) +static int inter_homunculus_sql_init(void) { return 0; } -void inter_homunculus_sql_final(void) +static void inter_homunculus_sql_final(void) { return; } @@ -59,7 +59,7 @@ void inter_homunculus_sql_final(void) * @param[in,out] hd The new homunculus' data. * @retval false in case of errors. */ -bool inter_homunculus_create(struct s_homunculus *hd) +static bool inter_homunculus_create(struct s_homunculus *hd) { char esc_name[NAME_LENGTH*2+1]; @@ -86,7 +86,7 @@ bool inter_homunculus_create(struct s_homunculus *hd) * @param hd The homunculus' data. * @retval false in case of errors. */ -bool inter_homunculus_save(const struct s_homunculus *hd) +static bool inter_homunculus_save(const struct s_homunculus *hd) { bool flag = true; char esc_name[NAME_LENGTH*2+1]; @@ -128,7 +128,7 @@ bool inter_homunculus_save(const struct s_homunculus *hd) } // Load an homunculus -bool inter_homunculus_load(int homun_id, struct s_homunculus* hd) +static bool inter_homunculus_load(int homun_id, struct s_homunculus *hd) { char* data; size_t len; @@ -209,7 +209,7 @@ bool inter_homunculus_load(int homun_id, struct s_homunculus* hd) return true; } -bool inter_homunculus_delete(int homun_id) +static bool inter_homunculus_delete(int homun_id) { if (SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `homun_id` = '%d'", homunculus_db, homun_id) || SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `homun_id` = '%d'", skill_homunculus_db, homun_id) @@ -220,7 +220,7 @@ bool inter_homunculus_delete(int homun_id) return true; } -bool inter_homunculus_rename(const char *name) +static bool inter_homunculus_rename(const char *name) { int i; @@ -245,7 +245,7 @@ bool inter_homunculus_rename(const char *name) /*========================================== * Inter Packets *------------------------------------------*/ -int inter_homunculus_parse_frommap(int fd) +static int inter_homunculus_parse_frommap(int fd) { unsigned short cmd = RFIFOW(fd,0); diff --git a/src/char/int_mail.c b/src/char/int_mail.c index a20446710..e0625fcab 100644 --- a/src/char/int_mail.c +++ b/src/char/int_mail.c @@ -37,10 +37,10 @@ #include #include -struct inter_mail_interface inter_mail_s; +static struct inter_mail_interface inter_mail_s; struct inter_mail_interface *inter_mail; -static int inter_mail_fromsql(int char_id, struct mail_data* md) +static int inter_mail_fromsql(int char_id, struct mail_data *md) { int i, j; struct mail_message *msg; @@ -134,7 +134,7 @@ static int inter_mail_fromsql(int char_id, struct mail_data* md) /// Stores a single message in the database. /// Returns the message's ID if successful (or 0 if it fails). -int inter_mail_savemessage(struct mail_message* msg) +static int inter_mail_savemessage(struct mail_message *msg) { StringBuf buf; struct SqlStmt *stmt; @@ -179,7 +179,7 @@ int inter_mail_savemessage(struct mail_message* msg) /// Retrieves a single message from the database. /// Returns true if the operation succeeds (or false if it fails). -static bool inter_mail_loadmessage(int mail_id, struct mail_message* msg) +static bool inter_mail_loadmessage(int mail_id, struct mail_message *msg) { int j; StringBuf buf; @@ -245,7 +245,7 @@ static bool inter_mail_loadmessage(int mail_id, struct mail_message* msg) /*========================================== * Mark mail as 'Read' *------------------------------------------*/ -bool inter_mail_mark_read(int mail_id) +static bool inter_mail_mark_read(int mail_id) { if (SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `status` = '%d' WHERE `id` = '%d'", mail_db, MAIL_READ, mail_id)) { Sql_ShowDebug(inter->sql_handle); @@ -281,7 +281,7 @@ static bool inter_mail_DeleteAttach(int mail_id) return true; } -bool inter_mail_get_attachment(int char_id, int mail_id, struct mail_message *msg) +static bool inter_mail_get_attachment(int char_id, int mail_id, struct mail_message *msg) { nullpo_retr(false, msg); @@ -303,7 +303,7 @@ bool inter_mail_get_attachment(int char_id, int mail_id, struct mail_message *ms return true; } -bool inter_mail_delete(int char_id, int mail_id) +static bool inter_mail_delete(int char_id, int mail_id) { if (SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `id` = '%d'", mail_db, mail_id)) { Sql_ShowDebug(inter->sql_handle); @@ -312,7 +312,7 @@ bool inter_mail_delete(int char_id, int mail_id) return true; } -bool inter_mail_return_message(int char_id, int mail_id, int *new_mail) +static bool inter_mail_return_message(int char_id, int mail_id, int *new_mail) { struct mail_message msg; nullpo_retr(false, new_mail); @@ -349,7 +349,7 @@ bool inter_mail_return_message(int char_id, int mail_id, int *new_mail) } -bool inter_mail_send(int account_id, struct mail_message *msg) +static bool inter_mail_send(int account_id, struct mail_message *msg) { char esc_name[NAME_LENGTH*2+1]; @@ -377,7 +377,7 @@ bool inter_mail_send(int account_id, struct mail_message *msg) return true; } -void inter_mail_sendmail(int send_id, const char* send_name, int dest_id, const char* dest_name, const char* title, const char* body, int zeny, struct item *item) +static void inter_mail_sendmail(int send_id, const char* send_name, int dest_id, const char *dest_name, const char *title, const char *body, int zeny, struct item *item) { struct mail_message msg; nullpo_retv(send_name); @@ -405,7 +405,7 @@ void inter_mail_sendmail(int send_id, const char* send_name, int dest_id, const /*========================================== * Packets From Map Server *------------------------------------------*/ -int inter_mail_parse_frommap(int fd) +static int inter_mail_parse_frommap(int fd) { switch(RFIFOW(fd,0)) { @@ -421,12 +421,12 @@ int inter_mail_parse_frommap(int fd) return 1; } -int inter_mail_sql_init(void) +static int inter_mail_sql_init(void) { return 1; } -void inter_mail_sql_final(void) +static void inter_mail_sql_final(void) { return; } diff --git a/src/char/int_mercenary.c b/src/char/int_mercenary.c index 52afdcb9f..21bfb5538 100644 --- a/src/char/int_mercenary.c +++ b/src/char/int_mercenary.c @@ -38,10 +38,10 @@ #include #include -struct inter_mercenary_interface inter_mercenary_s; +static struct inter_mercenary_interface inter_mercenary_s; struct inter_mercenary_interface *inter_mercenary; -bool inter_mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status) +static bool inter_mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status) { char* data; @@ -70,7 +70,7 @@ bool inter_mercenary_owner_fromsql(int char_id, struct mmo_charstatus *status) return true; } -bool inter_mercenary_owner_tosql(int char_id, struct mmo_charstatus *status) +static bool inter_mercenary_owner_tosql(int char_id, struct mmo_charstatus *status) { nullpo_ret(status); if( SQL_ERROR == SQL->Query(inter->sql_handle, "REPLACE INTO `%s` (`char_id`, `merc_id`, `arch_calls`, `arch_faith`, `spear_calls`, `spear_faith`, `sword_calls`, `sword_faith`) VALUES ('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')", @@ -83,7 +83,7 @@ bool inter_mercenary_owner_tosql(int char_id, struct mmo_charstatus *status) return true; } -bool inter_mercenary_owner_delete(int char_id) +static bool inter_mercenary_owner_delete(int char_id) { if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `char_id` = '%d'", mercenary_owner_db, char_id) ) Sql_ShowDebug(inter->sql_handle); @@ -104,7 +104,7 @@ bool inter_mercenary_owner_delete(int char_id) * @param[in,out] merc The new mercenary's data. * @retval false in case of errors. */ -bool inter_mercenary_create(struct s_mercenary *merc) +static bool inter_mercenary_create(struct s_mercenary *merc) { nullpo_retr(false, merc); Assert_retr(false, merc->mercenary_id == 0); @@ -126,7 +126,7 @@ bool inter_mercenary_create(struct s_mercenary *merc) * @param merc The mercenary's data. * @retval false in case of errors. */ -bool inter_mercenary_save(const struct s_mercenary *merc) +static bool inter_mercenary_save(const struct s_mercenary *merc) { nullpo_retr(false, merc); Assert_retr(false, merc->mercenary_id > 0); @@ -141,7 +141,7 @@ bool inter_mercenary_save(const struct s_mercenary *merc) return true; } -bool inter_mercenary_load(int merc_id, int char_id, struct s_mercenary *merc) +static bool inter_mercenary_load(int merc_id, int char_id, struct s_mercenary *merc) { char* data; @@ -174,7 +174,7 @@ bool inter_mercenary_load(int merc_id, int char_id, struct s_mercenary *merc) return true; } -bool inter_mercenary_delete(int merc_id) +static bool inter_mercenary_delete(int merc_id) { if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `mer_id` = '%d'", mercenary_db, merc_id) ) { @@ -185,11 +185,12 @@ bool inter_mercenary_delete(int merc_id) return true; } -int inter_mercenary_sql_init(void) +static int inter_mercenary_sql_init(void) { return 0; } -void inter_mercenary_sql_final(void) + +static void inter_mercenary_sql_final(void) { return; } @@ -197,7 +198,7 @@ void inter_mercenary_sql_final(void) /*========================================== * Inter Packets *------------------------------------------*/ -int inter_mercenary_parse_frommap(int fd) +static int inter_mercenary_parse_frommap(int fd) { unsigned short cmd = RFIFOW(fd,0); diff --git a/src/char/int_party.c b/src/char/int_party.c index e089d1567..8ee03ecc5 100644 --- a/src/char/int_party.c +++ b/src/char/int_party.c @@ -39,11 +39,12 @@ #include #include -struct inter_party_interface inter_party_s; +static struct inter_party_interface inter_party_s; struct inter_party_interface *inter_party; //Updates party's level range and unsets even share if broken. -static int inter_party_check_lv(struct party_data *p) { +static int inter_party_check_lv(struct party_data *p) +{ int i; unsigned int lv; nullpo_ret(p); @@ -121,7 +122,7 @@ static void inter_party_calc_state(struct party_data *p) } // Save party to mysql -int inter_party_tosql(struct party *p, int flag, int index) +static int inter_party_tosql(struct party *p, int flag, int index) { // 'party' ('party_id','name','exp','item','leader_id','leader_char') char esc_name[NAME_LENGTH*2+1];// escaped party name @@ -196,7 +197,7 @@ int inter_party_tosql(struct party *p, int flag, int index) } // Read party from mysql -struct party_data *inter_party_fromsql(int party_id) +static struct party_data *inter_party_fromsql(int party_id) { int leader_id = 0; int leader_char = 0; @@ -268,7 +269,7 @@ struct party_data *inter_party_fromsql(int party_id) return p; } -int inter_party_sql_init(void) +static int inter_party_sql_init(void) { //memory alloc inter_party->db = idb_alloc(DB_OPT_RELEASE_DATA); @@ -287,7 +288,7 @@ int inter_party_sql_init(void) return 0; } -void inter_party_sql_final(void) +static void inter_party_sql_final(void) { inter_party->db->destroy(inter_party->db, NULL); aFree(inter_party->pt); @@ -295,7 +296,7 @@ void inter_party_sql_final(void) } // Search for the party according to its name -struct party_data* inter_party_search_partyname(const char *const str) +static struct party_data *inter_party_search_partyname(const char *const str) { char esc_name[NAME_LENGTH*2+1]; char* data; @@ -314,14 +315,14 @@ struct party_data* inter_party_search_partyname(const char *const str) } // Returns whether this party can keep having exp share or not. -int inter_party_check_exp_share(struct party_data *const p) +static int inter_party_check_exp_share(struct party_data *const p) { nullpo_ret(p); return (p->party.count < 2 || p->max_lv - p->min_lv <= party_share_level); } // Is there any member in the party? -int inter_party_check_empty(struct party_data *p) +static int inter_party_check_empty(struct party_data *p) { int i; if (p==NULL||p->party.party_id==0) return 1; @@ -334,7 +335,7 @@ int inter_party_check_empty(struct party_data *p) } // Create Party -struct party_data *inter_party_create(const char *name, int item, int item2, const struct party_member *leader) +static struct party_data *inter_party_create(const char *name, int item, int item2, const struct party_member *leader) { struct party_data *p; int i; @@ -389,7 +390,7 @@ struct party_data *inter_party_create(const char *name, int item, int item2, con } // Add a player to party request -bool inter_party_add_member(int party_id, const struct party_member *member) +static bool inter_party_add_member(int party_id, const struct party_member *member) { struct party_data *p; int i; @@ -425,7 +426,7 @@ bool inter_party_add_member(int party_id, const struct party_member *member) } //Party setting change request -bool inter_party_change_option(int party_id, int account_id, int exp, int item, int map_fd) +static bool inter_party_change_option(int party_id, int account_id, int exp, int item, int map_fd) { struct party_data *p; int flag = 0; @@ -446,7 +447,7 @@ bool inter_party_change_option(int party_id, int account_id, int exp, int item, } //Request leave party -bool inter_party_leave(int party_id, int account_id, int char_id) +static bool inter_party_leave(int party_id, int account_id, int char_id) { struct party_data *p; int i,j; @@ -488,7 +489,7 @@ bool inter_party_leave(int party_id, int account_id, int char_id) } // When member goes to other map or levels up. -bool inter_party_change_map(int party_id, int account_id, int char_id, unsigned short map, int online, unsigned int lv) +static bool inter_party_change_map(int party_id, int account_id, int char_id, unsigned short map, int online, unsigned int lv) { struct party_data *p; int i; @@ -546,7 +547,7 @@ bool inter_party_change_map(int party_id, int account_id, int char_id, unsigned } //Request party dissolution -bool inter_party_disband(int party_id) +static bool inter_party_disband(int party_id) { struct party_data *p; @@ -559,7 +560,7 @@ bool inter_party_disband(int party_id) return 0; } -bool inter_party_change_leader(int party_id, int account_id, int char_id) +static bool inter_party_change_leader(int party_id, int account_id, int char_id) { struct party_data *p; int i; @@ -587,7 +588,7 @@ bool inter_party_change_leader(int party_id, int account_id, int char_id) // Return : // 0 : error // 1 : ok -int inter_party_parse_frommap(int fd) +static int inter_party_parse_frommap(int fd) { RFIFOHEAD(fd); switch(RFIFOW(fd,0)) { @@ -606,7 +607,7 @@ int inter_party_parse_frommap(int fd) return 1; } -int inter_party_CharOnline(int char_id, int party_id) +static int inter_party_CharOnline(int char_id, int party_id) { struct party_data* p; int i; @@ -653,7 +654,8 @@ int inter_party_CharOnline(int char_id, int party_id) return 1; } -int inter_party_CharOffline(int char_id, int party_id) { +static int inter_party_CharOffline(int char_id, int party_id) +{ struct party_data *p=NULL; int i; diff --git a/src/char/int_pet.c b/src/char/int_pet.c index 0a3a51b3a..e824d7b58 100644 --- a/src/char/int_pet.c +++ b/src/char/int_pet.c @@ -37,7 +37,7 @@ #include #include -struct inter_pet_interface inter_pet_s; +static struct inter_pet_interface inter_pet_s; struct inter_pet_interface *inter_pet; /** @@ -51,7 +51,7 @@ struct inter_pet_interface *inter_pet; * @return The ID of the saved pet. * @retval 0 in case of errors. */ -int inter_pet_tosql(const struct s_pet *p) +static int inter_pet_tosql(const struct s_pet *p) { //`pet` (`pet_id`, `class`,`name`,`account_id`,`char_id`,`level`,`egg_id`,`equip`,`intimate`,`hungry`,`rename_flag`,`incubate`) char esc_name[NAME_LENGTH*2+1];// escaped pet name @@ -91,7 +91,7 @@ int inter_pet_tosql(const struct s_pet *p) return pet_id; } -int inter_pet_fromsql(int pet_id, struct s_pet* p) +static int inter_pet_fromsql(int pet_id, struct s_pet *p) { char* data; size_t len; @@ -138,17 +138,21 @@ int inter_pet_fromsql(int pet_id, struct s_pet* p) } //---------------------------------------------- -int inter_pet_sql_init(void) { +static int inter_pet_sql_init(void) +{ //memory alloc inter_pet->pt = (struct s_pet*)aCalloc(sizeof(struct s_pet), 1); return 0; } -void inter_pet_sql_final(void) { + +static void inter_pet_sql_final(void) +{ if (inter_pet->pt) aFree(inter_pet->pt); return; } //---------------------------------- -int inter_pet_delete(int pet_id) { +static int inter_pet_delete(int pet_id) +{ ShowInfo("delete pet request: %d...\n",pet_id); if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `pet_id`='%d'", pet_db, pet_id) ) @@ -156,7 +160,7 @@ int inter_pet_delete(int pet_id) { return 0; } //------------------------------------------------------ -struct s_pet *inter_pet_create(int account_id, int char_id, short pet_class, short pet_lv, short pet_egg_id, +static struct s_pet *inter_pet_create(int account_id, int char_id, short pet_class, short pet_lv, short pet_egg_id, short pet_equip, short intimate, short hungry, char rename_flag, char incubate, const char *pet_name) { nullpo_ret(pet_name); @@ -193,7 +197,7 @@ struct s_pet *inter_pet_create(int account_id, int char_id, short pet_class, sho return NULL; } -struct s_pet *inter_pet_load(int account_id, int char_id, int pet_id) +static struct s_pet *inter_pet_load(int account_id, int char_id, int pet_id) { memset(inter_pet->pt, 0, sizeof(struct s_pet)); @@ -213,7 +217,7 @@ struct s_pet *inter_pet_load(int account_id, int char_id, int pet_id) return NULL; } -int inter_pet_parse_frommap(int fd) +static int inter_pet_parse_frommap(int fd) { RFIFOHEAD(fd); switch(RFIFOW(fd, 0)){ diff --git a/src/char/int_quest.c b/src/char/int_quest.c index afd01579e..0fa7771cb 100644 --- a/src/char/int_quest.c +++ b/src/char/int_quest.c @@ -37,7 +37,7 @@ #include #include -struct inter_quest_interface inter_quest_s; +static struct inter_quest_interface inter_quest_s; struct inter_quest_interface *inter_quest; /** @@ -48,7 +48,7 @@ struct inter_quest_interface *inter_quest; * @return Array of found entries. It has *count entries, and it is care of the * caller to aFree() it afterwards. */ -struct quest *inter_quest_fromsql(int char_id, int *count) +static struct quest *inter_quest_fromsql(int char_id, int *count) { struct quest *questlog = NULL; struct quest tmp_quest; @@ -129,7 +129,7 @@ struct quest *inter_quest_fromsql(int char_id, int *count) * @param quest_id Quest ID * @return false in case of errors, true otherwise */ -bool inter_quest_delete(int char_id, int quest_id) +static bool inter_quest_delete(int char_id, int quest_id) { if (SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `quest_id` = '%d' AND `char_id` = '%d'", quest_db, quest_id, char_id)) { Sql_ShowDebug(inter->sql_handle); @@ -146,7 +146,7 @@ bool inter_quest_delete(int char_id, int quest_id) * @param qd Quest data * @return false in case of errors, true otherwise */ -bool inter_quest_add(int char_id, struct quest qd) +static bool inter_quest_add(int char_id, struct quest qd) { StringBuf buf; int i; @@ -178,7 +178,7 @@ bool inter_quest_add(int char_id, struct quest qd) * @param qd Quest data * @return false in case of errors, true otherwise */ -bool inter_quest_update(int char_id, struct quest qd) +static bool inter_quest_update(int char_id, struct quest qd) { StringBuf buf; int i; @@ -200,7 +200,7 @@ bool inter_quest_update(int char_id, struct quest qd) return true; } -bool inter_quest_save(int char_id, const struct quest *new_qd, int new_n) +static bool inter_quest_save(int char_id, const struct quest *new_qd, int new_n) { int i, j, k, old_n; struct quest *old_qd = NULL; @@ -243,7 +243,7 @@ bool inter_quest_save(int char_id, const struct quest *new_qd, int new_n) * * @see inter_parse_frommap */ -int inter_quest_parse_frommap(int fd) +static int inter_quest_parse_frommap(int fd) { switch(RFIFOW(fd,0)) { case 0x3060: mapif->parse_quest_load(fd); break; diff --git a/src/char/int_rodex.c b/src/char/int_rodex.c index ddd019bb8..e70a6bbf5 100644 --- a/src/char/int_rodex.c +++ b/src/char/int_rodex.c @@ -37,7 +37,7 @@ #include #include -struct inter_rodex_interface inter_rodex_s; +static struct inter_rodex_interface inter_rodex_s; struct inter_rodex_interface *inter_rodex; // Loads new mails of this char_id/account_id @@ -298,7 +298,7 @@ static bool inter_rodex_checkname(const char *name, int *target_char_id, short * /// Stores a single message in the database. /// Returns the message's ID if successful (or 0 if it fails). -int64 inter_rodex_savemessage(struct rodex_message* msg) +static int64 inter_rodex_savemessage(struct rodex_message *msg) { char sender_name[NAME_LENGTH * 2 + 1]; char receiver_name[NAME_LENGTH * 2 + 1]; @@ -349,7 +349,7 @@ int64 inter_rodex_savemessage(struct rodex_message* msg) /*========================================== * Update/Delete mail *------------------------------------------*/ -bool inter_rodex_updatemail(int64 mail_id, int8 flag) +static bool inter_rodex_updatemail(int64 mail_id, int8 flag) { Assert_retr(false, mail_id > 0); Assert_retr(false, flag >= 0 && flag <= 4); @@ -392,7 +392,7 @@ bool inter_rodex_updatemail(int64 mail_id, int8 flag) /*========================================== * Packets From Map Server *------------------------------------------*/ -int inter_rodex_parse_frommap(int fd) +static int inter_rodex_parse_frommap(int fd) { switch(RFIFOW(fd,0)) { @@ -407,12 +407,12 @@ int inter_rodex_parse_frommap(int fd) return 1; } -int inter_rodex_sql_init(void) +static int inter_rodex_sql_init(void) { return 1; } -void inter_rodex_sql_final(void) +static void inter_rodex_sql_final(void) { return; } diff --git a/src/char/int_storage.c b/src/char/int_storage.c index 3deb8d58b..da4522971 100644 --- a/src/char/int_storage.c +++ b/src/char/int_storage.c @@ -37,11 +37,11 @@ #include #include -struct inter_storage_interface inter_storage_s; +static struct inter_storage_interface inter_storage_s; struct inter_storage_interface *inter_storage; /// Save storage data to sql -int inter_storage_tosql(int account_id, const struct storage_data *p) +static int inter_storage_tosql(int account_id, const struct storage_data *p) { int i = 0, j = 0; bool matched_p[MAX_STORAGE] = { false }; @@ -165,7 +165,7 @@ int inter_storage_tosql(int account_id, const struct storage_data *p) } /// Load storage data to mem -int inter_storage_fromsql(int account_id, struct storage_data *p) +static int inter_storage_fromsql(int account_id, struct storage_data *p) { StringBuf buf; char* data; @@ -235,7 +235,7 @@ int inter_storage_fromsql(int account_id, struct storage_data *p) } /// Save guild_storage data to sql -bool inter_storage_guild_storage_tosql(int guild_id, const struct guild_storage *p) +static bool inter_storage_guild_storage_tosql(int guild_id, const struct guild_storage *p) { nullpo_ret(p); @@ -255,7 +255,7 @@ bool inter_storage_guild_storage_tosql(int guild_id, const struct guild_storage } /// Load guild_storage data to mem -int inter_storage_guild_storage_fromsql(int guild_id, struct guild_storage* p) +static int inter_storage_guild_storage_fromsql(int guild_id, struct guild_storage* p) { StringBuf buf; char* data; @@ -315,24 +315,24 @@ int inter_storage_guild_storage_fromsql(int guild_id, struct guild_storage* p) //--------------------------------------------------------- // storage data initialize -int inter_storage_sql_init(void) +static int inter_storage_sql_init(void) { return 1; } // storage data finalize -void inter_storage_sql_final(void) +static void inter_storage_sql_final(void) { return; } // q?f[^? -int inter_storage_delete(int account_id) +static int inter_storage_delete(int account_id) { if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `account_id`='%d'", storage_db, account_id) ) Sql_ShowDebug(inter->sql_handle); return 0; } -int inter_storage_guild_storage_delete(int guild_id) +static int inter_storage_guild_storage_delete(int guild_id) { if( SQL_ERROR == SQL->Query(inter->sql_handle, "DELETE FROM `%s` WHERE `guild_id`='%d'", guild_storage_db, guild_id) ) Sql_ShowDebug(inter->sql_handle); @@ -343,7 +343,7 @@ int inter_storage_guild_storage_delete(int guild_id) //Guild bound items pull for offline characters [Akinari] //Revised by [Mhalicot] //------------------------------------------------ -bool inter_storage_retrieve_bound_items(int char_id, int account_id, int guild_id) +static bool inter_storage_retrieve_bound_items(int char_id, int account_id, int guild_id) { #ifdef GP_BOUND_ITEMS StringBuf buf; @@ -517,7 +517,7 @@ bool inter_storage_retrieve_bound_items(int char_id, int account_id, int guild_i return true; } -int inter_storage_parse_frommap(int fd) +static int inter_storage_parse_frommap(int fd) { RFIFOHEAD(fd); switch(RFIFOW(fd,0)){ diff --git a/src/char/inter.c b/src/char/inter.c index 28e2f2488..718dfd60d 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -55,20 +55,20 @@ #define WISDATA_TTL (60*1000) // Wis data Time To Live (60 seconds) #define WISDELLIST_MAX 256 // Number of elements in the list Delete data Wis -struct inter_interface inter_s; +static struct inter_interface inter_s; struct inter_interface *inter; -int char_server_port = 3306; -char char_server_ip[32] = "127.0.0.1"; -char char_server_id[32] = "ragnarok"; -char char_server_pw[100] = "ragnarok"; -char char_server_db[32] = "ragnarok"; -char default_codepage[32] = ""; //Feature by irmin. +static int char_server_port = 3306; +static char char_server_ip[32] = "127.0.0.1"; +static char char_server_id[32] = "ragnarok"; +static char char_server_pw[100] = "ragnarok"; +static char char_server_db[32] = "ragnarok"; +static char default_codepage[32] = ""; //Feature by irmin. int party_share_level = 10; // recv. packet list -int inter_recv_packet_length[] = { +static int inter_recv_packet_length[] = { -1,-1, 7,-1, -1,13,36, (2 + 4 + 4 + 4 + NAME_LENGTH), 0, 0, 0, 0, 0, 0, 0, 0, // 3000- 6,-1, 0, 0, 0, 0, 0, 0, 10,-1, 0, 0, 0, 0, 0, 0, // 3010- Account Storage [Smokexyz] -1,10,-1,14, 14,19, 6,-1, 14,14, 0, 0, 0, 0, 0, 0, // 3020- Party @@ -85,9 +85,10 @@ static struct DBMap *wis_db = NULL; // int wis_id -> struct WisData* static int wis_dellist[WISDELLIST_MAX], wis_delnum; #define MAX_JOB_NAMES 150 -static char* msg_table[MAX_JOB_NAMES]; // messages 550 ~ 699 are job names +static char *msg_table[MAX_JOB_NAMES]; // messages 550 ~ 699 are job names -const char* inter_msg_txt(int msg_number) { +static const char *inter_msg_txt(int msg_number) +{ msg_number -= 550; if (msg_number >= 0 && msg_number < MAX_JOB_NAMES && msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0') @@ -106,7 +107,7 @@ const char* inter_msg_txt(int msg_number) { * @param[in] allow_override whether to allow duplicate message IDs to override the original value. * @return success state. */ -bool inter_msg_config_read(const char *cfg_name, bool allow_override) +static bool inter_msg_config_read(const char *cfg_name, bool allow_override) { int msg_number; char line[1024], w1[1024], w2[1024]; @@ -158,14 +159,14 @@ bool inter_msg_config_read(const char *cfg_name, bool allow_override) /*========================================== * Cleanup Message Data *------------------------------------------*/ -void inter_do_final_msg(void) +static void inter_do_final_msg(void) { int i; for (i = 0; i < MAX_JOB_NAMES; i++) aFree(msg_table[i]); } /* from pc.c due to @accinfo. any ideas to replace this crap are more than welcome. */ -const char* inter_job_name(int class) +static const char *inter_job_name(int class) { switch (class) { case JOB_NOVICE: // 550 @@ -398,7 +399,7 @@ const char* inter_job_name(int class) * Argument-list version of inter_msg_to_fd * @see inter_msg_to_fd */ -void inter_vmsg_to_fd(int fd, int u_fd, int aid, char* msg, va_list ap) +static void inter_vmsg_to_fd(int fd, int u_fd, int aid, char *msg, va_list ap) { char msg_out[512]; va_list apcopy; @@ -431,8 +432,8 @@ void inter_vmsg_to_fd(int fd, int u_fd, int aid, char* msg, va_list ap) * @param msg Message format string * @param ... Additional parameters for (v)sprinf */ -void inter_msg_to_fd(int fd, int u_fd, int aid, char *msg, ...) __attribute__((format(printf, 4, 5))); -void inter_msg_to_fd(int fd, int u_fd, int aid, char *msg, ...) +static void inter_msg_to_fd(int fd, int u_fd, int aid, char *msg, ...) __attribute__((format(printf, 4, 5))); +static void inter_msg_to_fd(int fd, int u_fd, int aid, char *msg, ...) { va_list ap; va_start(ap,msg); @@ -441,7 +442,7 @@ void inter_msg_to_fd(int fd, int u_fd, int aid, char *msg, ...) } /* [Dekamaster/Nightroad] */ -void inter_accinfo(int u_fd, int aid, int castergroup, const char *query, int map_fd) +static void inter_accinfo(int u_fd, int aid, int castergroup, const char *query, int map_fd) { char query_esq[NAME_LENGTH*2+1]; int account_id; @@ -499,7 +500,7 @@ void inter_accinfo(int u_fd, int aid, int castergroup, const char *query, int ma return; } -void inter_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int account_id, const char *userid, const char *user_pass, +static void inter_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int account_id, const char *userid, const char *user_pass, const char *email, const char *last_ip, const char *lastlogin, const char *pin_code, const char *birthdate, int group_id, int logincount, int state) { @@ -572,7 +573,7 @@ void inter_accinfo2(bool success, int map_fd, int u_fd, int u_aid, int account_i * @param val either str or int, depending on type * @param type false when int, true otherwise **/ -void inter_savereg(int account_id, int char_id, const char *key, unsigned int index, intptr_t val, bool is_string) +static void inter_savereg(int account_id, int char_id, const char *key, unsigned int index, intptr_t val, bool is_string) { char val_esq[1000]; nullpo_retv(key); @@ -625,7 +626,7 @@ void inter_savereg(int account_id, int char_id, const char *key, unsigned int in } // Load account_reg from sql (type=2) -int inter_accreg_fromsql(int account_id,int char_id, int fd, int type) +static int inter_accreg_fromsql(int account_id, int char_id, int fd, int type) { char* data; size_t len; @@ -802,7 +803,7 @@ int inter_accreg_fromsql(int account_id,int char_id, int fd, int type) * * @retval false in case of error. */ -bool inter_config_read_log(const char *filename, const struct config_t *config, bool imported) +static bool inter_config_read_log(const char *filename, const struct config_t *config, bool imported) { const struct config_setting_t *setting = NULL; @@ -830,7 +831,7 @@ bool inter_config_read_log(const char *filename, const struct config_t *config, * * @retval false in case of error. */ -bool inter_config_read_connection(const char *filename, const struct config_t *config, bool imported) +static bool inter_config_read_connection(const char *filename, const struct config_t *config, bool imported) { const struct config_setting_t *setting = NULL; @@ -863,7 +864,7 @@ bool inter_config_read_connection(const char *filename, const struct config_t *c * * @retval false in case of error. */ -bool inter_config_read(const char *filename, bool imported) +static bool inter_config_read(const char *filename, bool imported) { struct config_t config; const struct config_setting_t *setting = NULL; @@ -907,7 +908,7 @@ bool inter_config_read(const char *filename, bool imported) * Save interlog into sql (arglist version) * @see inter_log */ -int inter_vlog(char* fmt, va_list ap) +static int inter_vlog(char *fmt, va_list ap) { char str[255]; char esc_str[sizeof(str)*2+1];// escaped str @@ -930,7 +931,7 @@ int inter_vlog(char* fmt, va_list ap) * @param ... Additional (printf-like) arguments * @return Always 0 // FIXME */ -int inter_log(char* fmt, ...) +static int inter_log(char *fmt, ...) { va_list ap; int ret; @@ -943,7 +944,7 @@ int inter_log(char* fmt, ...) } // initialize -int inter_init_sql(const char *file) +static int inter_init_sql(const char *file) { inter->config_read(file, false); @@ -980,7 +981,7 @@ int inter_init_sql(const char *file) } // finalize -void inter_final(void) +static void inter_final(void) { wis_db->destroy(wis_db, NULL); @@ -1000,7 +1001,7 @@ void inter_final(void) return; } -int inter_mapif_init(int fd) +static int inter_mapif_init(int fd) { return 0; } @@ -1011,7 +1012,7 @@ int inter_mapif_init(int fd) * Existence check of WISP data * @see DBApply */ -int inter_check_ttl_wisdata_sub(union DBKey key, struct DBData *data, va_list ap) +static int inter_check_ttl_wisdata_sub(union DBKey key, struct DBData *data, va_list ap) { int64 tick; struct WisData *wd = DB->data2ptr(data); @@ -1024,7 +1025,7 @@ int inter_check_ttl_wisdata_sub(union DBKey key, struct DBData *data, va_list ap return 0; } -int inter_check_ttl_wisdata(void) +static int inter_check_ttl_wisdata(void) { int64 tick = timer->gettick(); int i; @@ -1044,7 +1045,7 @@ int inter_check_ttl_wisdata(void) return 0; } -struct WisData *inter_add_wisdata(int fd, const unsigned char *src, const unsigned char *dst, const unsigned char *msg, int msg_len) +static struct WisData *inter_add_wisdata(int fd, const unsigned char *src, const unsigned char *dst, const unsigned char *msg, int msg_len) { static int wisid = 0; struct WisData *wd; @@ -1066,12 +1067,12 @@ struct WisData *inter_add_wisdata(int fd, const unsigned char *src, const unsign return wd; } -struct WisData *inter_get_wisdata(int id) +static struct WisData *inter_get_wisdata(int id) { return idb_get(wis_db, id); } -void inter_remove_wisdata(int id) +static void inter_remove_wisdata(int id) { idb_remove(wis_db, id); } @@ -1082,7 +1083,7 @@ void inter_remove_wisdata(int id) /// or 0 if no complete packet exists in the queue. /// /// @param length The minimum allowed length, or -1 for dynamic lookup -int inter_check_length(int fd, int length) +static int inter_check_length(int fd, int length) { if( length == -1 ) {// variable-length packet @@ -1097,7 +1098,7 @@ int inter_check_length(int fd, int length) return length; } -int inter_parse_frommap(int fd) +static int inter_parse_frommap(int fd) { int cmd; int len = 0; diff --git a/src/char/loginif.c b/src/char/loginif.c index a34bac943..a093c8cf5 100644 --- a/src/char/loginif.c +++ b/src/char/loginif.c @@ -35,12 +35,12 @@ #include #include -struct loginif_interface loginif_s; +static struct loginif_interface loginif_s; struct loginif_interface *loginif; /// Resets all the data. -void loginif_reset(void) __attribute__ ((noreturn)); -void loginif_reset(void) +static void loginif_reset(void) __attribute__ ((noreturn)); +static void loginif_reset(void) { int id; // TODO kick everyone out and reset everything or wait for connect and try to reacquire locks [FlavioJS] @@ -54,7 +54,7 @@ void loginif_reset(void) /// Checks the conditions for the server to stop. /// Releases the cookie when all characters are saved. /// If all the conditions are met, it stops the core loop. -void loginif_check_shutdown(void) +static void loginif_check_shutdown(void) { if( core->runflag != CHARSERVER_ST_SHUTDOWN ) return; @@ -63,14 +63,14 @@ void loginif_check_shutdown(void) /// Called when the connection to Login Server is disconnected. -void loginif_on_disconnect(void) +static void loginif_on_disconnect(void) { ShowWarning("Connection to Login Server lost.\n\n"); } /// Called when all the connection steps are completed. -void loginif_on_ready(void) +static void loginif_on_ready(void) { int i; @@ -85,7 +85,7 @@ void loginif_on_ready(void) ShowStatus("Awaiting maps from map-server.\n"); } -void do_init_loginif(void) +static void do_init_loginif(void) { // establish char-login connection if not present timer->add_func_list(chr->check_connect_login_server, "chr->check_connect_login_server"); @@ -96,7 +96,7 @@ void do_init_loginif(void) timer->add_interval(timer->gettick() + 1000, chr->send_accounts_tologin, 0, 0, 3600 * 1000); //Sync online accounts every hour } -void do_final_loginif(void) +static void do_final_loginif(void) { if (chr->login_fd != -1) { sockt->close(chr->login_fd); @@ -104,7 +104,7 @@ void do_final_loginif(void) } } -void loginif_block_account(int account_id, int flag) +static void loginif_block_account(int account_id, int flag) { Assert_retv(chr->login_fd != -1); WFIFOHEAD(chr->login_fd,10); @@ -114,7 +114,7 @@ void loginif_block_account(int account_id, int flag) WFIFOSET(chr->login_fd,10); } -void loginif_ban_account(int account_id, short year, short month, short day, short hour, short minute, short second) +static void loginif_ban_account(int account_id, short year, short month, short day, short hour, short minute, short second) { Assert_retv(chr->login_fd != -1); WFIFOHEAD(chr->login_fd,18); @@ -129,7 +129,7 @@ void loginif_ban_account(int account_id, short year, short month, short day, sho WFIFOSET(chr->login_fd,18); } -void loginif_unban_account(int account_id) +static void loginif_unban_account(int account_id) { Assert_retv(chr->login_fd != -1); WFIFOHEAD(chr->login_fd,6); @@ -138,7 +138,7 @@ void loginif_unban_account(int account_id) WFIFOSET(chr->login_fd,6); } -void loginif_changesex(int account_id) +static void loginif_changesex(int account_id) { Assert_retv(chr->login_fd != -1); WFIFOHEAD(chr->login_fd,6); @@ -147,7 +147,7 @@ void loginif_changesex(int account_id) WFIFOSET(chr->login_fd,6); } -void loginif_auth(int fd, struct char_session_data* sd, uint32 ipl) +static void loginif_auth(int fd, struct char_session_data *sd, uint32 ipl) { Assert_retv(chr->login_fd != -1); nullpo_retv(sd); @@ -162,7 +162,7 @@ void loginif_auth(int fd, struct char_session_data* sd, uint32 ipl) WFIFOSET(chr->login_fd,23); } -void loginif_send_users_count(int users) +static void loginif_send_users_count(int users) { Assert_retv(chr->login_fd != -1); WFIFOHEAD(chr->login_fd,6); @@ -171,7 +171,7 @@ void loginif_send_users_count(int users) WFIFOSET(chr->login_fd,6); } -void loginif_connect_to_server(void) +static void loginif_connect_to_server(void) { Assert_retv(chr->login_fd != -1); WFIFOHEAD(chr->login_fd,86); diff --git a/src/char/mapif.c b/src/char/mapif.c index cb1d50698..e0565c126 100644 --- a/src/char/mapif.c +++ b/src/char/mapif.c @@ -49,7 +49,10 @@ #include -void mapif_ban(int id, unsigned int flag, int status) +static struct mapif_interface mapif_s; +struct mapif_interface *mapif; + +static void mapif_ban(int id, unsigned int flag, int status) { // send to all map-servers to disconnect the player unsigned char buf[11]; @@ -61,14 +64,14 @@ void mapif_ban(int id, unsigned int flag, int status) } /// Initializes a server structure. -void mapif_server_init(int id) +static void mapif_server_init(int id) { //memset(&chr->server[id], 0, sizeof(server[id])); chr->server[id].fd = -1; } /// Destroys a server structure. -void mapif_server_destroy(int id) +static void mapif_server_destroy(int id) { if (chr->server[id].fd == -1) { sockt->close(chr->server[id].fd); @@ -77,7 +80,7 @@ void mapif_server_destroy(int id) } /// Resets all the data related to a server. -void mapif_server_reset(int id) +static void mapif_server_reset(int id) { int i, j; unsigned char buf[16384]; @@ -104,13 +107,13 @@ void mapif_server_reset(int id) } /// Called when the connection to a Map Server is disconnected. -void mapif_on_disconnect(int id) +static void mapif_on_disconnect(int id) { ShowStatus("Map-server #%d has disconnected.\n", id); mapif->server_reset(id); } -void mapif_on_parse_accinfo(int account_id, int u_fd, int u_aid, int u_group, int map_fd) +static void mapif_on_parse_accinfo(int account_id, int u_fd, int u_aid, int u_group, int map_fd) { Assert_retv(chr->login_fd > 0); WFIFOHEAD(chr->login_fd, 22); @@ -123,7 +126,7 @@ void mapif_on_parse_accinfo(int account_id, int u_fd, int u_aid, int u_group, in WFIFOSET(chr->login_fd, 22); } -void mapif_char_ban(int char_id, time_t timestamp) +static void mapif_char_ban(int char_id, time_t timestamp) { unsigned char buf[11]; WBUFW(buf, 0) = 0x2b14; @@ -133,7 +136,7 @@ void mapif_char_ban(int char_id, time_t timestamp) mapif->sendall(buf, 11); } -int mapif_sendall(const unsigned char *buf, unsigned int len) +static int mapif_sendall(const unsigned char *buf, unsigned int len) { int i, c; @@ -152,7 +155,7 @@ int mapif_sendall(const unsigned char *buf, unsigned int len) return c; } -int mapif_sendallwos(int sfd, unsigned char *buf, unsigned int len) +static int mapif_sendallwos(int sfd, unsigned char *buf, unsigned int len) { int i, c; @@ -172,7 +175,7 @@ int mapif_sendallwos(int sfd, unsigned char *buf, unsigned int len) } -int mapif_send(int fd, unsigned char *buf, unsigned int len) +static int mapif_send(int fd, unsigned char *buf, unsigned int len) { nullpo_ret(buf); if (fd >= 0) { @@ -188,7 +191,7 @@ int mapif_send(int fd, unsigned char *buf, unsigned int len) return 0; } -void mapif_send_users_count(int users) +static void mapif_send_users_count(int users) { uint8 buf[6]; // send number of players to all map-servers @@ -198,7 +201,7 @@ void mapif_send_users_count(int users) } -void mapif_auction_message(int char_id, unsigned char result) +static void mapif_auction_message(int char_id, unsigned char result) { unsigned char buf[74]; @@ -208,7 +211,7 @@ void mapif_auction_message(int char_id, unsigned char result) mapif->sendall(buf, 7); } -void mapif_auction_sendlist(int fd, int char_id, short count, short pages, unsigned char *buf) +static void mapif_auction_sendlist(int fd, int char_id, short count, short pages, unsigned char *buf) { int len = (sizeof(struct auction_data) * count) + 12; @@ -224,7 +227,7 @@ void mapif_auction_sendlist(int fd, int char_id, short count, short pages, unsig WFIFOSET(fd, len); } -void mapif_parse_auction_requestlist(int fd) +static void mapif_parse_auction_requestlist(int fd) { char searchtext[NAME_LENGTH]; int char_id = RFIFOL(fd, 4), len = sizeof(struct auction_data); @@ -266,7 +269,7 @@ void mapif_parse_auction_requestlist(int fd) mapif->auction_sendlist(fd, char_id, j, pages, buf); } -void mapif_auction_register(int fd, struct auction_data *auction) +static void mapif_auction_register(int fd, struct auction_data *auction) { int len = sizeof(struct auction_data) + 4; @@ -279,7 +282,7 @@ void mapif_auction_register(int fd, struct auction_data *auction) WFIFOSET(fd, len); } -void mapif_parse_auction_register(int fd) +static void mapif_parse_auction_register(int fd) { struct auction_data auction; if( RFIFOW(fd, 2) != sizeof(struct auction_data) + 4 ) @@ -292,7 +295,7 @@ void mapif_parse_auction_register(int fd) mapif->auction_register(fd, &auction); } -void mapif_auction_cancel(int fd, int char_id, unsigned char result) +static void mapif_auction_cancel(int fd, int char_id, unsigned char result) { WFIFOHEAD(fd, 7); WFIFOW(fd, 0) = 0x3852; @@ -301,7 +304,7 @@ void mapif_auction_cancel(int fd, int char_id, unsigned char result) WFIFOSET(fd, 7); } -void mapif_parse_auction_cancel(int fd) +static void mapif_parse_auction_cancel(int fd) { int char_id = RFIFOL(fd, 2), auction_id = RFIFOL(fd, 6); struct auction_data *auction; @@ -328,7 +331,7 @@ void mapif_parse_auction_cancel(int fd) } -void mapif_auction_close(int fd, int char_id, unsigned char result) +static void mapif_auction_close(int fd, int char_id, unsigned char result) { WFIFOHEAD(fd, 7); WFIFOW(fd, 0) = 0x3853; @@ -337,7 +340,7 @@ void mapif_auction_close(int fd, int char_id, unsigned char result) WFIFOSET(fd, 7); } -void mapif_parse_auction_close(int fd) +static void mapif_parse_auction_close(int fd) { int char_id = RFIFOL(fd, 2), auction_id = RFIFOL(fd, 6); struct auction_data *auction; @@ -367,7 +370,7 @@ void mapif_parse_auction_close(int fd) mapif->auction_close(fd, char_id, 0); // You have ended the auction } -void mapif_auction_bid(int fd, int char_id, int bid, unsigned char result) +static void mapif_auction_bid(int fd, int char_id, int bid, unsigned char result) { WFIFOHEAD(fd, 11); WFIFOW(fd, 0) = 0x3855; @@ -377,7 +380,7 @@ void mapif_auction_bid(int fd, int char_id, int bid, unsigned char result) WFIFOSET(fd, 11); } -void mapif_parse_auction_bid(int fd) +static void mapif_parse_auction_bid(int fd) { int char_id = RFIFOL(fd, 4), bid = RFIFOL(fd, 12); unsigned int auction_id = RFIFOL(fd, 8); @@ -424,7 +427,7 @@ void mapif_parse_auction_bid(int fd) mapif->auction_bid(fd, char_id, 0, 1); // You have successfully bid in the auction } -void mapif_elemental_send(int fd, struct s_elemental *ele, unsigned char flag) +static void mapif_elemental_send(int fd, struct s_elemental *ele, unsigned char flag) { int size = sizeof(struct s_elemental) + 5; @@ -437,7 +440,7 @@ void mapif_elemental_send(int fd, struct s_elemental *ele, unsigned char flag) WFIFOSET(fd, size); } -void mapif_parse_elemental_create(int fd, const struct s_elemental *ele) +static void mapif_parse_elemental_create(int fd, const struct s_elemental *ele) { struct s_elemental ele_; bool result; @@ -448,14 +451,14 @@ void mapif_parse_elemental_create(int fd, const struct s_elemental *ele) mapif->elemental_send(fd, &ele_, result); } -void mapif_parse_elemental_load(int fd, int ele_id, int char_id) +static void mapif_parse_elemental_load(int fd, int ele_id, int char_id) { struct s_elemental ele; bool result = inter_elemental->load(ele_id, char_id, &ele); mapif->elemental_send(fd, &ele, result); } -void mapif_elemental_deleted(int fd, unsigned char flag) +static void mapif_elemental_deleted(int fd, unsigned char flag) { WFIFOHEAD(fd, 3); WFIFOW(fd, 0) = 0x387d; @@ -463,13 +466,13 @@ void mapif_elemental_deleted(int fd, unsigned char flag) WFIFOSET(fd, 3); } -void mapif_parse_elemental_delete(int fd, int ele_id) +static void mapif_parse_elemental_delete(int fd, int ele_id) { bool result = inter_elemental->delete(ele_id); mapif->elemental_deleted(fd, result); } -void mapif_elemental_saved(int fd, unsigned char flag) +static void mapif_elemental_saved(int fd, unsigned char flag) { WFIFOHEAD(fd, 3); WFIFOW(fd, 0) = 0x387e; @@ -477,13 +480,13 @@ void mapif_elemental_saved(int fd, unsigned char flag) WFIFOSET(fd, 3); } -void mapif_parse_elemental_save(int fd, const struct s_elemental *ele) +static void mapif_parse_elemental_save(int fd, const struct s_elemental *ele) { bool result = inter_elemental->save(ele); mapif->elemental_saved(fd, result); } -int mapif_guild_created(int fd, int account_id, struct guild *g) +static int mapif_guild_created(int fd, int account_id, struct guild *g) { WFIFOHEAD(fd, 10); WFIFOW(fd, 0) = 0x3830; @@ -500,7 +503,7 @@ int mapif_guild_created(int fd, int account_id, struct guild *g) } // Guild not found -int mapif_guild_noinfo(int fd, int guild_id) +static int mapif_guild_noinfo(int fd, int guild_id) { unsigned char buf[12]; WBUFW(buf, 0) = 0x3831; @@ -515,7 +518,7 @@ int mapif_guild_noinfo(int fd, int guild_id) } // Send guild info -int mapif_guild_info(int fd, struct guild *g) +static int mapif_guild_info(int fd, struct guild *g) { unsigned char buf[8 + sizeof(struct guild)]; nullpo_ret(g); @@ -530,7 +533,7 @@ int mapif_guild_info(int fd, struct guild *g) } // ACK member add -int mapif_guild_memberadded(int fd, int guild_id, int account_id, int char_id, int flag) +static int mapif_guild_memberadded(int fd, int guild_id, int account_id, int char_id, int flag) { WFIFOHEAD(fd, 15); WFIFOW(fd, 0) = 0x3832; @@ -543,7 +546,7 @@ int mapif_guild_memberadded(int fd, int guild_id, int account_id, int char_id, i } // ACK member leave -int mapif_guild_withdraw(int guild_id, int account_id, int char_id, int flag, const char *name, const char *mes) +static int mapif_guild_withdraw(int guild_id, int account_id, int char_id, int flag, const char *name, const char *mes) { unsigned char buf[55 + NAME_LENGTH]; @@ -563,7 +566,7 @@ int mapif_guild_withdraw(int guild_id, int account_id, int char_id, int flag, co } // Send short member's info -int mapif_guild_memberinfoshort(struct guild *g, int idx) +static int mapif_guild_memberinfoshort(struct guild *g, int idx) { unsigned char buf[23]; nullpo_ret(g); @@ -581,7 +584,7 @@ int mapif_guild_memberinfoshort(struct guild *g, int idx) } // Send guild broken -int mapif_guild_broken(int guild_id, int flag) +static int mapif_guild_broken(int guild_id, int flag) { unsigned char buf[7]; WBUFW(buf, 0) = 0x3836; @@ -593,7 +596,7 @@ int mapif_guild_broken(int guild_id, int flag) } // Send guild message -int mapif_guild_message(int guild_id, int account_id, const char *mes, int len, int sfd) +static int mapif_guild_message(int guild_id, int account_id, const char *mes, int len, int sfd) { unsigned char buf[512]; nullpo_ret(mes); @@ -609,7 +612,7 @@ int mapif_guild_message(int guild_id, int account_id, const char *mes, int len, } // Send basic info -int mapif_guild_basicinfochanged(int guild_id, int type, const void *data, int len) +static int mapif_guild_basicinfochanged(int guild_id, int type, const void *data, int len) { unsigned char buf[2048]; nullpo_ret(data); @@ -625,7 +628,7 @@ int mapif_guild_basicinfochanged(int guild_id, int type, const void *data, int l } // Send member info -int mapif_guild_memberinfochanged(int guild_id, int account_id, int char_id, int type, const void *data, int len) +static int mapif_guild_memberinfochanged(int guild_id, int account_id, int char_id, int type, const void *data, int len) { unsigned char buf[2048]; nullpo_ret(data); @@ -643,7 +646,7 @@ int mapif_guild_memberinfochanged(int guild_id, int account_id, int char_id, int } // ACK guild skill up -int mapif_guild_skillupack(int guild_id, uint16 skill_id, int account_id) +static int mapif_guild_skillupack(int guild_id, uint16 skill_id, int account_id) { unsigned char buf[14]; WBUFW(buf, 0) = 0x383c; @@ -655,7 +658,7 @@ int mapif_guild_skillupack(int guild_id, uint16 skill_id, int account_id) } // ACK guild alliance -int mapif_guild_alliance(int guild_id1, int guild_id2, int account_id1, int account_id2, int flag, const char *name1, const char *name2) +static int mapif_guild_alliance(int guild_id1, int guild_id2, int account_id1, int account_id2, int flag, const char *name1, const char *name2) { unsigned char buf[19 + 2 * NAME_LENGTH]; nullpo_ret(name1); @@ -673,7 +676,7 @@ int mapif_guild_alliance(int guild_id1, int guild_id2, int account_id1, int acco } // Send a guild position desc -int mapif_guild_position(struct guild *g, int idx) +static int mapif_guild_position(struct guild *g, int idx) { unsigned char buf[12 + sizeof(struct guild_position)]; nullpo_ret(g); @@ -688,7 +691,7 @@ int mapif_guild_position(struct guild *g, int idx) } // Send the guild notice -int mapif_guild_notice(struct guild *g) +static int mapif_guild_notice(struct guild *g) { unsigned char buf[256]; nullpo_ret(g); @@ -701,7 +704,7 @@ int mapif_guild_notice(struct guild *g) } // Send emblem data -int mapif_guild_emblem(struct guild *g) +static int mapif_guild_emblem(struct guild *g) { unsigned char buf[12 + sizeof(g->emblem_data)]; nullpo_ret(g); @@ -714,7 +717,7 @@ int mapif_guild_emblem(struct guild *g) return 0; } -int mapif_guild_master_changed(struct guild *g, int aid, int cid) +static int mapif_guild_master_changed(struct guild *g, int aid, int cid) { unsigned char buf[14]; nullpo_ret(g); @@ -726,7 +729,7 @@ int mapif_guild_master_changed(struct guild *g, int aid, int cid) return 0; } -int mapif_guild_castle_dataload(int fd, int sz, const int *castle_ids) +static int mapif_guild_castle_dataload(int fd, int sz, const int *castle_ids) { struct guild_castle *gc = NULL; int num = (sz - 4) / sizeof(int); @@ -746,7 +749,7 @@ int mapif_guild_castle_dataload(int fd, int sz, const int *castle_ids) } // Guild creation request -int mapif_parse_CreateGuild(int fd, int account_id, const char *name, const struct guild_member *master) +static int mapif_parse_CreateGuild(int fd, int account_id, const char *name, const struct guild_member *master) { struct guild *g; nullpo_ret(name); @@ -764,7 +767,7 @@ int mapif_parse_CreateGuild(int fd, int account_id, const char *name, const stru } // Return guild info to client -int mapif_parse_GuildInfo(int fd, int guild_id) +static int mapif_parse_GuildInfo(int fd, int guild_id) { struct guild * g = inter_guild->fromsql(guild_id); //We use this because on start-up the info of castle-owned guilds is required. [Skotlex] if (g != NULL) { @@ -777,7 +780,7 @@ int mapif_parse_GuildInfo(int fd, int guild_id) } // Add member to guild -int mapif_parse_GuildAddMember(int fd, int guild_id, const struct guild_member *m) +static int mapif_parse_GuildAddMember(int fd, int guild_id, const struct guild_member *m) { nullpo_ret(m); @@ -790,28 +793,28 @@ int mapif_parse_GuildAddMember(int fd, int guild_id, const struct guild_member * } // Delete member from guild -int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, int flag, const char *mes) +static int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, int flag, const char *mes) { inter_guild->leave(guild_id, account_id, char_id, flag, mes, fd); return 0; } // Change member info -int mapif_parse_GuildChangeMemberInfoShort(int fd, int guild_id, int account_id, int char_id, int online, int lv, int16 class) +static int mapif_parse_GuildChangeMemberInfoShort(int fd, int guild_id, int account_id, int char_id, int online, int lv, int16 class) { inter_guild->update_member_info_short(guild_id, account_id, char_id, online, lv, class); return 0; } // BreakGuild -int mapif_parse_BreakGuild(int fd, int guild_id) +static int mapif_parse_BreakGuild(int fd, int guild_id) { inter_guild->disband(guild_id); return 0; } // Forward Guild message to others map servers -int mapif_parse_GuildMessage(int fd, int guild_id, int account_id, const char *mes, int len) +static int mapif_parse_GuildMessage(int fd, int guild_id, int account_id, const char *mes, int len) { return mapif->guild_message(guild_id,account_id,mes,len, fd); } @@ -820,7 +823,7 @@ int mapif_parse_GuildMessage(int fd, int guild_id, int account_id, const char *m * Changes basic guild information * The types are available in mmo.h::guild_basic_info **/ -int mapif_parse_GuildBasicInfoChange(int fd, int guild_id, int type, const void *data, int len) +static int mapif_parse_GuildBasicInfoChange(int fd, int guild_id, int type, const void *data, int len) { inter_guild->update_basic_info(guild_id, type, data, len); // Information is already sent in mapif->guild_info @@ -829,14 +832,14 @@ int mapif_parse_GuildBasicInfoChange(int fd, int guild_id, int type, const void } // Modification of the guild -int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int char_id, int type, const char *data, int len) +static int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int char_id, int type, const char *data, int len) { inter_guild->update_member_info(guild_id, account_id, char_id, type, data, len); return 0; } // Change a position desc -int mapif_parse_GuildPosition(int fd, int guild_id, int idx, const struct guild_position *p) +static int mapif_parse_GuildPosition(int fd, int guild_id, int idx, const struct guild_position *p) { nullpo_ret(p); inter_guild->update_position(guild_id, idx, p); @@ -844,50 +847,50 @@ int mapif_parse_GuildPosition(int fd, int guild_id, int idx, const struct guild_ } // Guild Skill UP -int mapif_parse_GuildSkillUp(int fd, int guild_id, uint16 skill_id, int account_id, int max) +static int mapif_parse_GuildSkillUp(int fd, int guild_id, uint16 skill_id, int account_id, int max) { inter_guild->use_skill_point(guild_id, skill_id, account_id, max); return 0; } // Alliance modification -int mapif_parse_GuildAlliance(int fd, int guild_id1, int guild_id2, int account_id1, int account_id2, int flag) +static int mapif_parse_GuildAlliance(int fd, int guild_id1, int guild_id2, int account_id1, int account_id2, int flag) { inter_guild->change_alliance(guild_id1, guild_id2, account_id1, account_id2, flag); return 0; } // Change guild message -int mapif_parse_GuildNotice(int fd, int guild_id, const char *mes1, const char *mes2) +static int mapif_parse_GuildNotice(int fd, int guild_id, const char *mes1, const char *mes2) { inter_guild->update_notice(guild_id, mes1, mes2); return 0; } -int mapif_parse_GuildEmblem(int fd, int len, int guild_id, int dummy, const char *data) +static int mapif_parse_GuildEmblem(int fd, int len, int guild_id, int dummy, const char *data) { inter_guild->update_emblem(len, guild_id, data); return 0; } -int mapif_parse_GuildCastleDataLoad(int fd, int len, const int *castle_ids) +static int mapif_parse_GuildCastleDataLoad(int fd, int len, const int *castle_ids) { return mapif->guild_castle_dataload(fd, len, castle_ids); } -int mapif_parse_GuildCastleDataSave(int fd, int castle_id, int index, int value) +static int mapif_parse_GuildCastleDataSave(int fd, int castle_id, int index, int value) { inter_guild->update_castle_data(castle_id, index, value); return 0; } -int mapif_parse_GuildMasterChange(int fd, int guild_id, const char* name, int len) +static int mapif_parse_GuildMasterChange(int fd, int guild_id, const char* name, int len) { inter_guild->change_leader(guild_id, name, len); return 0; } -void mapif_homunculus_created(int fd, int account_id, const struct s_homunculus *sh, unsigned char flag) +static void mapif_homunculus_created(int fd, int account_id, const struct s_homunculus *sh, unsigned char flag) { nullpo_retv(sh); WFIFOHEAD(fd, sizeof(struct s_homunculus) + 9); @@ -899,7 +902,7 @@ void mapif_homunculus_created(int fd, int account_id, const struct s_homunculus WFIFOSET(fd, WFIFOW(fd, 2)); } -void mapif_homunculus_deleted(int fd, int flag) +static void mapif_homunculus_deleted(int fd, int flag) { WFIFOHEAD(fd, 3); WFIFOW(fd, 0) = 0x3893; @@ -907,7 +910,7 @@ void mapif_homunculus_deleted(int fd, int flag) WFIFOSET(fd, 3); } -void mapif_homunculus_loaded(int fd, int account_id, struct s_homunculus *hd) +static void mapif_homunculus_loaded(int fd, int account_id, struct s_homunculus *hd) { WFIFOHEAD(fd, sizeof(struct s_homunculus) + 9); WFIFOW(fd, 0) = 0x3891; @@ -923,7 +926,7 @@ void mapif_homunculus_loaded(int fd, int account_id, struct s_homunculus *hd) WFIFOSET(fd, sizeof(struct s_homunculus) + 9); } -void mapif_homunculus_saved(int fd, int account_id, bool flag) +static void mapif_homunculus_saved(int fd, int account_id, bool flag) { WFIFOHEAD(fd, 7); WFIFOW(fd, 0) = 0x3892; @@ -932,7 +935,7 @@ void mapif_homunculus_saved(int fd, int account_id, bool flag) WFIFOSET(fd, 7); } -void mapif_homunculus_renamed(int fd, int account_id, int char_id, unsigned char flag, const char *name) +static void mapif_homunculus_renamed(int fd, int account_id, int char_id, unsigned char flag, const char *name) { nullpo_retv(name); WFIFOHEAD(fd, NAME_LENGTH + 12); @@ -944,7 +947,7 @@ void mapif_homunculus_renamed(int fd, int account_id, int char_id, unsigned char WFIFOSET(fd, NAME_LENGTH + 12); } -void mapif_parse_homunculus_create(int fd, int len, int account_id, const struct s_homunculus *phd) +static void mapif_parse_homunculus_create(int fd, int len, int account_id, const struct s_homunculus *phd) { struct s_homunculus shd; bool result; @@ -955,32 +958,32 @@ void mapif_parse_homunculus_create(int fd, int len, int account_id, const struct mapif->homunculus_created(fd, account_id, &shd, result); } -void mapif_parse_homunculus_delete(int fd, int homun_id) +static void mapif_parse_homunculus_delete(int fd, int homun_id) { bool result = inter_homunculus->delete(homun_id); mapif->homunculus_deleted(fd, result); } -void mapif_parse_homunculus_load(int fd, int account_id, int homun_id) +static void mapif_parse_homunculus_load(int fd, int account_id, int homun_id) { struct s_homunculus hd; bool result = inter_homunculus->load(homun_id, &hd); mapif->homunculus_loaded(fd, account_id, (result ? &hd : NULL)); } -void mapif_parse_homunculus_save(int fd, int len, int account_id, const struct s_homunculus *phd) +static void mapif_parse_homunculus_save(int fd, int len, int account_id, const struct s_homunculus *phd) { bool result = inter_homunculus->save(phd); mapif->homunculus_saved(fd, account_id, result); } -void mapif_parse_homunculus_rename(int fd, int account_id, int char_id, const char *name) +static void mapif_parse_homunculus_rename(int fd, int account_id, int char_id, const char *name) { bool result = inter_homunculus->rename(name); mapif->homunculus_renamed(fd, account_id, char_id, result, name); } -void mapif_mail_sendinbox(int fd, int char_id, unsigned char flag, struct mail_data *md) +static void mapif_mail_sendinbox(int fd, int char_id, unsigned char flag, struct mail_data *md) { nullpo_retv(md); //FIXME: dumping the whole structure like this is unsafe [ultramage] @@ -996,7 +999,7 @@ void mapif_mail_sendinbox(int fd, int char_id, unsigned char flag, struct mail_d /*========================================== * Client Inbox Request *------------------------------------------*/ -void mapif_parse_mail_requestinbox(int fd) +static void mapif_parse_mail_requestinbox(int fd) { int char_id = RFIFOL(fd, 2); unsigned char flag = RFIFOB(fd, 6); @@ -1009,13 +1012,13 @@ void mapif_parse_mail_requestinbox(int fd) /*========================================== * Mark mail as 'Read' *------------------------------------------*/ -void mapif_parse_mail_read(int fd) +static void mapif_parse_mail_read(int fd) { int mail_id = RFIFOL(fd, 2); inter_mail->mark_read(mail_id); } -void mapif_mail_sendattach(int fd, int char_id, struct mail_message *msg) +static void mapif_mail_sendattach(int fd, int char_id, struct mail_message *msg) { nullpo_retv(msg); WFIFOHEAD(fd, sizeof(struct item) + 12); @@ -1027,7 +1030,7 @@ void mapif_mail_sendattach(int fd, int char_id, struct mail_message *msg) WFIFOSET(fd,WFIFOW(fd, 2)); } -void mapif_parse_mail_getattach(int fd) +static void mapif_parse_mail_getattach(int fd) { struct mail_message msg = { 0 }; int char_id = RFIFOL(fd, 2); @@ -1042,7 +1045,7 @@ void mapif_parse_mail_getattach(int fd) /*========================================== * Delete Mail *------------------------------------------*/ -void mapif_mail_delete(int fd, int char_id, int mail_id, bool failed) +static void mapif_mail_delete(int fd, int char_id, int mail_id, bool failed) { WFIFOHEAD(fd, 11); WFIFOW(fd, 0) = 0x384b; @@ -1052,7 +1055,7 @@ void mapif_mail_delete(int fd, int char_id, int mail_id, bool failed) WFIFOSET(fd, 11); } -void mapif_parse_mail_delete(int fd) +static void mapif_parse_mail_delete(int fd) { int char_id = RFIFOL(fd, 2); int mail_id = RFIFOL(fd, 6); @@ -1063,7 +1066,7 @@ void mapif_parse_mail_delete(int fd) /*========================================== * Report New Mail to Map Server *------------------------------------------*/ -void mapif_mail_new(struct mail_message *msg) +static void mapif_mail_new(struct mail_message *msg) { unsigned char buf[74]; @@ -1081,7 +1084,7 @@ void mapif_mail_new(struct mail_message *msg) /*========================================== * Return Mail *------------------------------------------*/ -void mapif_mail_return(int fd, int char_id, int mail_id, int new_mail) +static void mapif_mail_return(int fd, int char_id, int mail_id, int new_mail) { WFIFOHEAD(fd, 11); WFIFOW(fd, 0) = 0x384c; @@ -1091,7 +1094,7 @@ void mapif_mail_return(int fd, int char_id, int mail_id, int new_mail) WFIFOSET(fd, 11); } -void mapif_parse_mail_return(int fd) +static void mapif_parse_mail_return(int fd) { int char_id = RFIFOL(fd, 2); int mail_id = RFIFOL(fd, 6); @@ -1106,7 +1109,7 @@ void mapif_parse_mail_return(int fd) /*========================================== * Send Mail *------------------------------------------*/ -void mapif_mail_send(int fd, struct mail_message* msg) +static void mapif_mail_send(int fd, struct mail_message* msg) { int len = sizeof(struct mail_message) + 4; @@ -1118,7 +1121,7 @@ void mapif_mail_send(int fd, struct mail_message* msg) WFIFOSET(fd,len); } -void mapif_parse_mail_send(int fd) +static void mapif_parse_mail_send(int fd) { struct mail_message msg; int account_id = 0; @@ -1135,7 +1138,7 @@ void mapif_parse_mail_send(int fd) mapif->mail_new(&msg); // notify recipient } -void mapif_mercenary_send(int fd, struct s_mercenary *merc, unsigned char flag) +static void mapif_mercenary_send(int fd, struct s_mercenary *merc, unsigned char flag) { int size = sizeof(struct s_mercenary) + 5; @@ -1148,7 +1151,7 @@ void mapif_mercenary_send(int fd, struct s_mercenary *merc, unsigned char flag) WFIFOSET(fd,size); } -void mapif_parse_mercenary_create(int fd, const struct s_mercenary *merc) +static void mapif_parse_mercenary_create(int fd, const struct s_mercenary *merc) { struct s_mercenary merc_; bool result; @@ -1159,14 +1162,14 @@ void mapif_parse_mercenary_create(int fd, const struct s_mercenary *merc) mapif->mercenary_send(fd, &merc_, result); } -void mapif_parse_mercenary_load(int fd, int merc_id, int char_id) +static void mapif_parse_mercenary_load(int fd, int merc_id, int char_id) { struct s_mercenary merc; bool result = inter_mercenary->load(merc_id, char_id, &merc); mapif->mercenary_send(fd, &merc, result); } -void mapif_mercenary_deleted(int fd, unsigned char flag) +static void mapif_mercenary_deleted(int fd, unsigned char flag) { WFIFOHEAD(fd, 3); WFIFOW(fd, 0) = 0x3871; @@ -1174,13 +1177,13 @@ void mapif_mercenary_deleted(int fd, unsigned char flag) WFIFOSET(fd, 3); } -void mapif_parse_mercenary_delete(int fd, int merc_id) +static void mapif_parse_mercenary_delete(int fd, int merc_id) { bool result = inter_mercenary->delete(merc_id); mapif->mercenary_deleted(fd, result); } -void mapif_mercenary_saved(int fd, unsigned char flag) +static void mapif_mercenary_saved(int fd, unsigned char flag) { WFIFOHEAD(fd, 3); WFIFOW(fd, 0) = 0x3872; @@ -1188,14 +1191,14 @@ void mapif_mercenary_saved(int fd, unsigned char flag) WFIFOSET(fd, 3); } -void mapif_parse_mercenary_save(int fd, const struct s_mercenary *merc) +static void mapif_parse_mercenary_save(int fd, const struct s_mercenary *merc) { bool result = inter_mercenary->save(merc); mapif->mercenary_saved(fd, result); } // Create a party whether or not -int mapif_party_created(int fd, int account_id, int char_id, struct party *p) +static int mapif_party_created(int fd, int account_id, int char_id, struct party *p) { WFIFOHEAD(fd, 39); WFIFOW(fd, 0) = 0x3820; @@ -1217,7 +1220,7 @@ int mapif_party_created(int fd, int account_id, int char_id, struct party *p) } //Party information not found -void mapif_party_noinfo(int fd, int party_id, int char_id) +static void mapif_party_noinfo(int fd, int party_id, int char_id) { WFIFOHEAD(fd, 12); WFIFOW(fd, 0) = 0x3821; @@ -1229,7 +1232,7 @@ void mapif_party_noinfo(int fd, int party_id, int char_id) } //Digest party information -void mapif_party_info(int fd, struct party* p, int char_id) +static void mapif_party_info(int fd, struct party* p, int char_id) { unsigned char buf[8 + sizeof(struct party)]; nullpo_retv(p); @@ -1245,7 +1248,7 @@ void mapif_party_info(int fd, struct party* p, int char_id) } //Whether or not additional party members -int mapif_party_memberadded(int fd, int party_id, int account_id, int char_id, int flag) +static int mapif_party_memberadded(int fd, int party_id, int account_id, int char_id, int flag) { WFIFOHEAD(fd, 15); WFIFOW(fd, 0) = 0x3822; @@ -1259,7 +1262,7 @@ int mapif_party_memberadded(int fd, int party_id, int account_id, int char_id, i } // Party setting change notification -int mapif_party_optionchanged(int fd, struct party *p, int account_id, int flag) +static int mapif_party_optionchanged(int fd, struct party *p, int account_id, int flag) { unsigned char buf[16]; nullpo_ret(p); @@ -1277,7 +1280,7 @@ int mapif_party_optionchanged(int fd, struct party *p, int account_id, int flag) } //Withdrawal notification party -int mapif_party_withdraw(int party_id, int account_id, int char_id) +static int mapif_party_withdraw(int party_id, int account_id, int char_id) { unsigned char buf[16]; @@ -1290,7 +1293,7 @@ int mapif_party_withdraw(int party_id, int account_id, int char_id) } //Party map update notification -int mapif_party_membermoved(struct party *p, int idx) +static int mapif_party_membermoved(struct party *p, int idx) { unsigned char buf[20]; @@ -1308,7 +1311,7 @@ int mapif_party_membermoved(struct party *p, int idx) } //Dissolution party notification -int mapif_party_broken(int party_id, int flag) +static int mapif_party_broken(int party_id, int flag) { unsigned char buf[16]; WBUFW(buf, 0) = 0x3826; @@ -1320,7 +1323,7 @@ int mapif_party_broken(int party_id, int flag) } //Remarks in the party -int mapif_party_message(int party_id, int account_id, const char *mes, int len, int sfd) +static int mapif_party_message(int party_id, int account_id, const char *mes, int len, int sfd) { unsigned char buf[512]; nullpo_ret(mes); @@ -1334,7 +1337,7 @@ int mapif_party_message(int party_id, int account_id, const char *mes, int len, } // Create Party -int mapif_parse_CreateParty(int fd, const char *name, int item, int item2, const struct party_member *leader) +static int mapif_parse_CreateParty(int fd, const char *name, int item, int item2, const struct party_member *leader) { struct party_data *p; @@ -1355,7 +1358,7 @@ int mapif_parse_CreateParty(int fd, const char *name, int item, int item2, const } // Party information request -void mapif_parse_PartyInfo(int fd, int party_id, int char_id) +static void mapif_parse_PartyInfo(int fd, int party_id, int char_id) { struct party_data *p; p = inter_party->fromsql(party_id); @@ -1367,7 +1370,7 @@ void mapif_parse_PartyInfo(int fd, int party_id, int char_id) } // Add a player to party request -int mapif_parse_PartyAddMember(int fd, int party_id, const struct party_member *member) +static int mapif_parse_PartyAddMember(int fd, int party_id, const struct party_member *member) { nullpo_ret(member); @@ -1381,47 +1384,47 @@ int mapif_parse_PartyAddMember(int fd, int party_id, const struct party_member * } //Party setting change request -int mapif_parse_PartyChangeOption(int fd, int party_id, int account_id, int exp, int item) +static int mapif_parse_PartyChangeOption(int fd, int party_id, int account_id, int exp, int item) { inter_party->change_option(party_id, account_id, exp, item, fd); return 0; } //Request leave party -int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id) +static int mapif_parse_PartyLeave(int fd, int party_id, int account_id, int char_id) { inter_party->leave(party_id, account_id, char_id); return 0; } // When member goes to other map or levels up. -int mapif_parse_PartyChangeMap(int fd, int party_id, int account_id, int char_id, unsigned short map, int online, unsigned int lv) +static int mapif_parse_PartyChangeMap(int fd, int party_id, int account_id, int char_id, unsigned short map, int online, unsigned int lv) { inter_party->change_map(party_id, account_id, char_id, map, online, lv); return 0; } //Request party dissolution -int mapif_parse_BreakParty(int fd, int party_id) +static int mapif_parse_BreakParty(int fd, int party_id) { inter_party->disband(party_id); return 0; } //Party sending the message -int mapif_parse_PartyMessage(int fd, int party_id, int account_id, const char *mes, int len) +static int mapif_parse_PartyMessage(int fd, int party_id, int account_id, const char *mes, int len) { return mapif->party_message(party_id, account_id, mes, len, fd); } -int mapif_parse_PartyLeaderChange(int fd, int party_id, int account_id, int char_id) +static int mapif_parse_PartyLeaderChange(int fd, int party_id, int account_id, int char_id) { if (!inter_party->change_leader(party_id, account_id, char_id)) return 0; return 1; } -int mapif_pet_created(int fd, int account_id, struct s_pet *p) +static int mapif_pet_created(int fd, int account_id, struct s_pet *p) { WFIFOHEAD(fd, 12); WFIFOW(fd, 0) = 0x3880; @@ -1439,7 +1442,7 @@ int mapif_pet_created(int fd, int account_id, struct s_pet *p) return 0; } -int mapif_pet_info(int fd, int account_id, struct s_pet *p) +static int mapif_pet_info(int fd, int account_id, struct s_pet *p) { nullpo_ret(p); WFIFOHEAD(fd, sizeof(struct s_pet) + 9); @@ -1453,7 +1456,7 @@ int mapif_pet_info(int fd, int account_id, struct s_pet *p) return 0; } -int mapif_pet_noinfo(int fd, int account_id) +static int mapif_pet_noinfo(int fd, int account_id) { WFIFOHEAD(fd, sizeof(struct s_pet) + 9); WFIFOW(fd, 0) = 0x3881; @@ -1466,7 +1469,7 @@ int mapif_pet_noinfo(int fd, int account_id) return 0; } -int mapif_save_pet_ack(int fd, int account_id, int flag) +static int mapif_save_pet_ack(int fd, int account_id, int flag) { WFIFOHEAD(fd, 7); WFIFOW(fd, 0) = 0x3882; @@ -1477,7 +1480,7 @@ int mapif_save_pet_ack(int fd, int account_id, int flag) return 0; } -int mapif_delete_pet_ack(int fd, int flag) +static int mapif_delete_pet_ack(int fd, int flag) { WFIFOHEAD(fd, 3); WFIFOW(fd, 0) = 0x3883; @@ -1487,7 +1490,7 @@ int mapif_delete_pet_ack(int fd, int flag) return 0; } -int mapif_save_pet(int fd, int account_id, const struct s_pet *data) +static int mapif_save_pet(int fd, int account_id, const struct s_pet *data) { //here process pet save request. int len; @@ -1505,14 +1508,14 @@ int mapif_save_pet(int fd, int account_id, const struct s_pet *data) return 0; } -int mapif_delete_pet(int fd, int pet_id) +static int mapif_delete_pet(int fd, int pet_id) { mapif->delete_pet_ack(fd, inter_pet->delete_(pet_id)); return 0; } -int mapif_parse_CreatePet(int fd) +static int mapif_parse_CreatePet(int fd) { int account_id; struct s_pet *pet; @@ -1530,7 +1533,7 @@ int mapif_parse_CreatePet(int fd) return 0; } -int mapif_parse_LoadPet(int fd) +static int mapif_parse_LoadPet(int fd) { int account_id; struct s_pet *pet; @@ -1546,21 +1549,21 @@ int mapif_parse_LoadPet(int fd) return 0; } -int mapif_parse_SavePet(int fd) +static int mapif_parse_SavePet(int fd) { RFIFOHEAD(fd); mapif->save_pet(fd, RFIFOL(fd, 4), RFIFOP(fd, 8)); return 0; } -int mapif_parse_DeletePet(int fd) +static int mapif_parse_DeletePet(int fd) { RFIFOHEAD(fd); mapif->delete_pet(fd, RFIFOL(fd, 2)); return 0; } -void mapif_quest_save_ack(int fd, int char_id, bool success) +static void mapif_quest_save_ack(int fd, int char_id, bool success) { WFIFOHEAD(fd, 7); WFIFOW(fd, 0) = 0x3861; @@ -1576,7 +1579,7 @@ void mapif_quest_save_ack(int fd, int char_id, bool success) * * @see inter_parse_frommap */ -int mapif_parse_quest_save(int fd) +static int mapif_parse_quest_save(int fd) { int num = (RFIFOW(fd, 2) - 8) / sizeof(struct quest); int char_id = RFIFOL(fd, 4); @@ -1594,7 +1597,7 @@ int mapif_parse_quest_save(int fd) return 0; } -void mapif_send_quests(int fd, int char_id, struct quest *tmp_questlog, int num_quests) +static void mapif_send_quests(int fd, int char_id, struct quest *tmp_questlog, int num_quests) { WFIFOHEAD(fd,num_quests*sizeof(struct quest) + 8); WFIFOW(fd, 0) = 0x3860; @@ -1618,7 +1621,7 @@ void mapif_send_quests(int fd, int char_id, struct quest *tmp_questlog, int num_ * * @see inter_parse_frommap */ -int mapif_parse_quest_load(int fd) +static int mapif_parse_quest_load(int fd) { int char_id = RFIFOL(fd,2); struct quest *tmp_questlog = NULL; @@ -1638,7 +1641,7 @@ int mapif_parse_quest_load(int fd) /*========================================== * Inbox Request *------------------------------------------*/ -void mapif_parse_rodex_requestinbox(int fd) +static void mapif_parse_rodex_requestinbox(int fd) { int count; int char_id = RFIFOL(fd,2); @@ -1657,7 +1660,7 @@ void mapif_parse_rodex_requestinbox(int fd) VECTOR_CLEAR(mails); } -void mapif_rodex_sendinbox(int fd, int char_id, int8 opentype, int8 flag, int count, int64 mail_id, struct rodex_maillist *mails) +static void mapif_rodex_sendinbox(int fd, int char_id, int8 opentype, int8 flag, int count, int64 mail_id, struct rodex_maillist *mails) { int per_packet = (UINT16_MAX - 24) / sizeof(struct rodex_message); int sent = 0; @@ -1706,7 +1709,7 @@ void mapif_rodex_sendinbox(int fd, int char_id, int8 opentype, int8 flag, int co /*========================================== * Checks if there are new mails *------------------------------------------*/ -void mapif_parse_rodex_checkhasnew(int fd) +static void mapif_parse_rodex_checkhasnew(int fd) { int char_id = RFIFOL(fd, 2); int account_id = RFIFOL(fd, 6); @@ -1719,7 +1722,7 @@ void mapif_parse_rodex_checkhasnew(int fd) mapif->rodex_sendhasnew(fd, char_id, has_new); } -void mapif_rodex_sendhasnew(int fd, int char_id, bool has_new) +static void mapif_rodex_sendhasnew(int fd, int char_id, bool has_new) { Assert_retv(char_id > 0); @@ -1733,7 +1736,7 @@ void mapif_rodex_sendhasnew(int fd, int char_id, bool has_new) /*========================================== * Update/Delete mail *------------------------------------------*/ -void mapif_parse_rodex_updatemail(int fd) +static void mapif_parse_rodex_updatemail(int fd) { int64 mail_id = RFIFOL(fd, 2); int8 flag = RFIFOB(fd, 10); @@ -1744,7 +1747,7 @@ void mapif_parse_rodex_updatemail(int fd) /*========================================== * Send Mail *------------------------------------------*/ -void mapif_parse_rodex_send(int fd) +static void mapif_parse_rodex_send(int fd) { struct rodex_message msg = { 0 }; @@ -1758,7 +1761,7 @@ void mapif_parse_rodex_send(int fd) mapif->rodex_send(fd, msg.sender_id, msg.receiver_id, msg.receiver_accountid, msg.id > 0 ? true : false); } -void mapif_rodex_send(int fd, int sender_id, int receiver_id, int receiver_accountid, bool result) +static void mapif_rodex_send(int fd, int sender_id, int receiver_id, int receiver_accountid, bool result) { Assert_retv(sender_id >= 0); Assert_retv(receiver_id + receiver_accountid > 0); @@ -1775,7 +1778,7 @@ void mapif_rodex_send(int fd, int sender_id, int receiver_id, int receiver_accou /*------------------------------------------ * Check Player *------------------------------------------*/ -void mapif_parse_rodex_checkname(int fd) +static void mapif_parse_rodex_checkname(int fd) { int reqchar_id = RFIFOL(fd, 2); char name[NAME_LENGTH]; @@ -1790,7 +1793,7 @@ void mapif_parse_rodex_checkname(int fd) mapif->rodex_checkname(fd, reqchar_id, 0, 0, 0, name); } -void mapif_rodex_checkname(int fd, int reqchar_id, int target_char_id, short target_class, int target_level, char *name) +static void mapif_rodex_checkname(int fd, int reqchar_id, int target_char_id, short target_class, int target_level, char *name) { nullpo_retv(name); Assert_retv(reqchar_id > 0); @@ -1806,7 +1809,7 @@ void mapif_rodex_checkname(int fd, int reqchar_id, int target_char_id, short tar WFIFOSET(fd, 16 + NAME_LENGTH); } -int mapif_load_guild_storage(int fd, int account_id, int guild_id, char flag) +static int mapif_load_guild_storage(int fd, int account_id, int guild_id, char flag) { if (SQL_ERROR == SQL->Query(inter->sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", guild_db, guild_id)) { Sql_ShowDebug(inter->sql_handle); @@ -1833,7 +1836,7 @@ int mapif_load_guild_storage(int fd, int account_id, int guild_id, char flag) return 0; } -int mapif_save_guild_storage_ack(int fd, int account_id, int guild_id, int fail) +static int mapif_save_guild_storage_ack(int fd, int account_id, int guild_id, int fail) { WFIFOHEAD(fd, 11); WFIFOW(fd, 0) = 0x3819; @@ -1851,7 +1854,7 @@ int mapif_save_guild_storage_ack(int fd, int account_id, int guild_id, int fail) * @param account_id [in] account id of the session. * @return 1 on success, 0 on failure. */ -int mapif_account_storage_load(int fd, int account_id) +static int mapif_account_storage_load(int fd, int account_id) { struct storage_data stor = { 0 }; int count = 0, i = 0, len = 0; @@ -1882,7 +1885,7 @@ int mapif_account_storage_load(int fd, int account_id) * @param fd [in] file/socket descriptor * @return 1 on success, 0 on failure. */ -int mapif_parse_AccountStorageLoad(int fd) +static int mapif_parse_AccountStorageLoad(int fd) { int account_id = RFIFOL(fd, 2); @@ -1900,7 +1903,7 @@ int mapif_parse_AccountStorageLoad(int fd) * @param fd [in] file/socket descriptor. * @return 1 on success, 0 on failure. */ -int mapif_parse_AccountStorageSave(int fd) +static int mapif_parse_AccountStorageSave(int fd) { int payload_size = RFIFOW(fd, 2) - 8, account_id = RFIFOL(fd, 4); int i = 0, count = 0; @@ -1942,7 +1945,7 @@ int mapif_parse_AccountStorageSave(int fd) * @param account_id [in] Account ID of the storage in question. * @param flag [in] Save flag, true for success and false for failure. */ -void mapif_send_AccountStorageSaveAck(int fd, int account_id, bool flag) +static void mapif_send_AccountStorageSaveAck(int fd, int account_id, bool flag) { WFIFOHEAD(fd, 7); WFIFOW(fd, 0) = 0x3808; @@ -1951,7 +1954,7 @@ void mapif_send_AccountStorageSaveAck(int fd, int account_id, bool flag) WFIFOSET(fd, 7); } -int mapif_parse_LoadGuildStorage(int fd) +static int mapif_parse_LoadGuildStorage(int fd) { RFIFOHEAD(fd); @@ -1960,7 +1963,7 @@ int mapif_parse_LoadGuildStorage(int fd) return 0; } -int mapif_parse_SaveGuildStorage(int fd) +static int mapif_parse_SaveGuildStorage(int fd) { int guild_id; int len; @@ -1980,7 +1983,7 @@ int mapif_parse_SaveGuildStorage(int fd) return 0; } -int mapif_itembound_ack(int fd, int aid, int guild_id) +static int mapif_itembound_ack(int fd, int aid, int guild_id) { #ifdef GP_BOUND_ITEMS WFIFOHEAD(fd, 8); @@ -1992,7 +1995,7 @@ int mapif_itembound_ack(int fd, int aid, int guild_id) return 0; } -void mapif_parse_ItemBoundRetrieve(int fd) +static void mapif_parse_ItemBoundRetrieve(int fd) { #ifdef GP_BOUND_ITEMS int char_id = RFIFOL(fd, 2); @@ -2012,7 +2015,7 @@ void mapif_parse_ItemBoundRetrieve(int fd) mapif->itembound_ack(fd, RFIFOL(fd, 6), RFIFOW(fd, 10)); } -void mapif_parse_accinfo(int fd) +static void mapif_parse_accinfo(int fd) { char query[NAME_LENGTH]; int u_fd = RFIFOL(fd, 2), aid = RFIFOL(fd, 6), castergroup = RFIFOL(fd, 10); @@ -2023,7 +2026,7 @@ void mapif_parse_accinfo(int fd) } // broadcast sending -int mapif_broadcast(const unsigned char *mes, int len, unsigned int fontColor, short fontType, short fontSize, short fontAlign, short fontY, int sfd) +static int mapif_broadcast(const unsigned char *mes, int len, unsigned int fontColor, short fontType, short fontSize, short fontAlign, short fontY, int sfd) { unsigned char *buf = (unsigned char*)aMalloc((len)*sizeof(unsigned char)); @@ -2044,7 +2047,7 @@ int mapif_broadcast(const unsigned char *mes, int len, unsigned int fontColor, s } // Wis sending -int mapif_wis_message(struct WisData *wd) +static int mapif_wis_message(struct WisData *wd) { unsigned char buf[2048]; nullpo_ret(wd); @@ -2065,7 +2068,7 @@ int mapif_wis_message(struct WisData *wd) return 0; } -void mapif_wis_response(int fd, const unsigned char *src, int flag) +static void mapif_wis_response(int fd, const unsigned char *src, int flag) { unsigned char buf[27]; nullpo_retv(src); @@ -2076,7 +2079,7 @@ void mapif_wis_response(int fd, const unsigned char *src, int flag) } // Wis sending result -int mapif_wis_end(struct WisData *wd, int flag) +static int mapif_wis_end(struct WisData *wd, int flag) { nullpo_ret(wd); mapif->wis_response(wd->fd, wd->src, flag); @@ -2094,14 +2097,14 @@ static void mapif_account_reg(int fd, unsigned char *src) #endif // 0 // Send the requested account_reg -int mapif_account_reg_reply(int fd,int account_id,int char_id, int type) +static int mapif_account_reg_reply(int fd,int account_id,int char_id, int type) { inter->accreg_fromsql(account_id, char_id, fd, type); return 0; } //Request to kick char from a certain map server. [Skotlex] -int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason) +static int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason) { if (fd < 0) return -1; @@ -2115,14 +2118,14 @@ int mapif_disconnectplayer(int fd, int account_id, int char_id, int reason) } // broadcast sending -int mapif_parse_broadcast(int fd) +static int mapif_parse_broadcast(int fd) { mapif->broadcast(RFIFOP(fd, 16), RFIFOW(fd, 2), RFIFOL(fd, 4), RFIFOW(fd, 8), RFIFOW(fd, 10), RFIFOW(fd, 12), RFIFOW(fd, 14), fd); return 0; } // Wisp/page request to send -int mapif_parse_WisRequest(int fd) +static int mapif_parse_WisRequest(int fd) { struct WisData* wd; char name[NAME_LENGTH]; @@ -2166,7 +2169,7 @@ int mapif_parse_WisRequest(int fd) } // Wisp/page transmission result -int mapif_parse_WisReply(int fd) +static int mapif_parse_WisReply(int fd) { int id, flag; struct WisData *wd; @@ -2186,7 +2189,7 @@ int mapif_parse_WisReply(int fd) } // Received wisp message from map-server for ALL gm (just copy the message and resends it to ALL map-servers) -int mapif_parse_WisToGM(int fd) +static int mapif_parse_WisToGM(int fd) { unsigned char buf[2048]; // 0x3003/0x3803 .w .24B .w .?B @@ -2198,7 +2201,7 @@ int mapif_parse_WisToGM(int fd) } // Save account_reg into sql (type=2) -int mapif_parse_Registry(int fd) +static int mapif_parse_Registry(int fd) { int account_id = RFIFOL(fd, 4), char_id = RFIFOL(fd, 8), count = RFIFOW(fd, 12); @@ -2251,7 +2254,7 @@ int mapif_parse_Registry(int fd) } // Request the value of all registries. -int mapif_parse_RegistryRequest(int fd) +static int mapif_parse_RegistryRequest(int fd) { //Load Char Registry if (RFIFOB(fd, 12)) @@ -2265,7 +2268,7 @@ int mapif_parse_RegistryRequest(int fd) return 1; } -void mapif_namechange_ack(int fd, int account_id, int char_id, int type, int flag, const char *const name) +static void mapif_namechange_ack(int fd, int account_id, int char_id, int type, int flag, const char *const name) { nullpo_retv(name); WFIFOHEAD(fd, NAME_LENGTH+13); @@ -2278,7 +2281,7 @@ void mapif_namechange_ack(int fd, int account_id, int char_id, int type, int fla WFIFOSET(fd, NAME_LENGTH + 13); } -int mapif_parse_NameChangeRequest(int fd) +static int mapif_parse_NameChangeRequest(int fd) { int account_id, char_id, type; const char *name; @@ -2313,7 +2316,7 @@ int mapif_parse_NameChangeRequest(int fd) } // Clan System -int mapif_parse_ClanMemberKick(int fd, int clan_id, int kick_interval) +static int mapif_parse_ClanMemberKick(int fd, int clan_id, int kick_interval) { int count = 0; @@ -2328,7 +2331,7 @@ int mapif_parse_ClanMemberKick(int fd, int clan_id, int kick_interval) return 0; } -int mapif_parse_ClanMemberCount(int fd, int clan_id, int kick_interval) +static int mapif_parse_ClanMemberCount(int fd, int clan_id, int kick_interval) { WFIFOHEAD(fd, 10); WFIFOW(fd, 0) = 0x3858; @@ -2338,10 +2341,8 @@ int mapif_parse_ClanMemberCount(int fd, int clan_id, int kick_interval) return 0; } -struct mapif_interface mapif_s; -struct mapif_interface *mapif; - -void mapif_defaults(void) { +void mapif_defaults(void) +{ mapif = &mapif_s; mapif->ban = mapif_ban; diff --git a/src/char/pincode.c b/src/char/pincode.c index 8fc4e6c36..5a7eb1cab 100644 --- a/src/char/pincode.c +++ b/src/char/pincode.c @@ -37,10 +37,10 @@ #include #include -struct pincode_interface pincode_s; +static struct pincode_interface pincode_s; struct pincode_interface *pincode; -void pincode_handle (int fd, struct char_session_data* sd) +static void pincode_handle(int fd, struct char_session_data *sd) { struct online_char_data* character; @@ -72,7 +72,7 @@ void pincode_handle (int fd, struct char_session_data* sd) character->pincode_enable = -1; } -void pincode_check(int fd, struct char_session_data* sd) +static void pincode_check(int fd, struct char_session_data *sd) { char pin[5] = "\0\0\0\0"; @@ -104,12 +104,12 @@ void pincode_check(int fd, struct char_session_data* sd) } /** -* Check if this pincode is blacklisted or not -* -* @param (const char *) pin The pin to be verified -* @return bool -*/ -bool pincode_isBlacklisted(const char *pin) + * Check if this pincode is blacklisted or not + * + * @param (const char *) pin The pin to be verified + * @return bool + */ +static bool pincode_isBlacklisted(const char *pin) { int i; @@ -124,7 +124,7 @@ bool pincode_isBlacklisted(const char *pin) return false; } -int pincode_compare(int fd, struct char_session_data* sd, char* pin) +static int pincode_compare(int fd, struct char_session_data *sd, char *pin) { nullpo_ret(sd); nullpo_ret(pin); @@ -142,7 +142,7 @@ int pincode_compare(int fd, struct char_session_data* sd, char* pin) } } -void pincode_change(int fd, struct char_session_data* sd) +static void pincode_change(int fd, struct char_session_data *sd) { char oldpin[5] = "\0\0\0\0", newpin[5] = "\0\0\0\0"; @@ -174,7 +174,7 @@ void pincode_change(int fd, struct char_session_data* sd) pincode->loginstate(fd, sd, PINCODE_LOGIN_ASK); } -void pincode_setnew(int fd, struct char_session_data* sd) +static void pincode_setnew(int fd, struct char_session_data *sd) { char newpin[5] = "\0\0\0\0"; @@ -198,13 +198,13 @@ void pincode_setnew(int fd, struct char_session_data* sd) } /** -* Send state of making new pincode -* -* @param[in] fd -* @param[in, out] sd Session Data -* @param[in] state Pincode Edit State -*/ -void pincode_makestate(int fd, struct char_session_data *sd, enum pincode_make_response state) + * Send state of making new pincode + * + * @param[in] fd + * @param[in, out] sd Session Data + * @param[in] state Pincode Edit State + */ +static void pincode_makestate(int fd, struct char_session_data *sd, enum pincode_make_response state) { nullpo_retv(sd); @@ -216,13 +216,13 @@ void pincode_makestate(int fd, struct char_session_data *sd, enum pincode_make_r } /** -* Send state of editing pincode -* -* @param[in] fd -* @param[in, out] sd Session Data -* @param[in] state Pincode Edit State -*/ -void pincode_editstate(int fd, struct char_session_data *sd, enum pincode_edit_response state) + * Send state of editing pincode + * + * @param[in] fd + * @param[in, out] sd Session Data + * @param[in] state Pincode Edit State + */ +static void pincode_editstate(int fd, struct char_session_data *sd, enum pincode_edit_response state) { nullpo_retv(sd); @@ -242,7 +242,7 @@ void pincode_editstate(int fd, struct char_session_data *sd, enum pincode_edit_r // 6 = client shows msgstr(1897) Unable to use your KSSN number // 7 = char select window shows a button - client sends 0x8c5 // 8 = pincode was incorrect -void pincode_loginstate(int fd, struct char_session_data* sd, enum pincode_login_response state) +static void pincode_loginstate(int fd, struct char_session_data *sd, enum pincode_login_response state) { nullpo_retv(sd); @@ -265,7 +265,7 @@ void pincode_loginstate(int fd, struct char_session_data* sd, enum pincode_login // 8 = pincode was incorrect // [4144] pincode_loginstate2 can replace pincode_loginstate, // but kro using pincode_loginstate2 only for send wrong pin error or locked after 3 pins wrong -void pincode_loginstate2(int fd, struct char_session_data* sd, enum pincode_login_response state, enum pincode_login_response2 flag) +static void pincode_loginstate2(int fd, struct char_session_data *sd, enum pincode_login_response state, enum pincode_login_response2 flag) { #if PACKETVER_MAIN_NUM >= 20180124 || PACKETVER_RE_NUM >= 20180124 || PACKETVER_ZERO_NUM >= 20180131 nullpo_retv(sd); @@ -280,7 +280,7 @@ void pincode_loginstate2(int fd, struct char_session_data* sd, enum pincode_logi #endif } -void pincode_notifyLoginPinUpdate(int account_id, char* pin) +static void pincode_notifyLoginPinUpdate(int account_id, char *pin) { nullpo_retv(pin); @@ -292,7 +292,7 @@ void pincode_notifyLoginPinUpdate(int account_id, char* pin) WFIFOSET(chr->login_fd, 11); } -void pincode_notifyLoginPinError(int account_id) +static void pincode_notifyLoginPinError(int account_id) { WFIFOHEAD(chr->login_fd, 6); WFIFOW(chr->login_fd, 0) = 0x2739; @@ -300,7 +300,7 @@ void pincode_notifyLoginPinError(int account_id) WFIFOSET(chr->login_fd, 6); } -void pincode_decrypt(unsigned int userSeed, char* pin) +static void pincode_decrypt(unsigned int userSeed, char *pin) { int i; char tab[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; @@ -337,7 +337,7 @@ void pincode_decrypt(unsigned int userSeed, char* pin) * * @retval false in case of error. */ -bool pincode_config_read(const char *filename, const struct config_t *config, bool imported) +static bool pincode_config_read(const char *filename, const struct config_t *config, bool imported) { const struct config_setting_t *setting = NULL; const struct config_setting_t *temp = NULL; @@ -426,12 +426,12 @@ bool pincode_config_read(const char *filename, const struct config_t *config, bo return true; } -void do_pincode_init(void) +static void do_pincode_init(void) { VECTOR_INIT(pincode->blacklist); } -void do_pincode_final(void) +static void do_pincode_final(void) { while (VECTOR_LENGTH(pincode->blacklist) > 0) { aFree(VECTOR_POP(pincode->blacklist)); -- cgit v1.2.3-70-g09d2 From a675e06c38ec4e31a2758435a582b58a2199cfc4 Mon Sep 17 00:00:00 2001 From: Haru Date: Thu, 28 Jun 2018 03:17:32 +0200 Subject: Change functions to static where possible (Part 4 - map) This fixes issues with plugins defining symbols with the same names Signed-off-by: Haru --- src/map/HPMmap.c | 22 +- src/map/atcommand.c | 371 +++++--- src/map/battle.c | 172 ++-- src/map/battleground.c | 100 +- src/map/buyingstore.c | 27 +- src/map/channel.c | 44 +- src/map/chat.c | 39 +- src/map/chrif.c | 211 +++-- src/map/clan.c | 56 +- src/map/clif.c | 2362 ++++++++++++++++++++++++++---------------------- src/map/duel.c | 47 +- src/map/elemental.c | 107 ++- src/map/guild.c | 204 +++-- src/map/homunculus.c | 144 ++- src/map/instance.c | 62 +- src/map/intif.c | 376 ++++---- src/map/irc-bot.c | 60 +- src/map/itemdb.c | 173 ++-- src/map/log.c | 81 +- src/map/mail.c | 22 +- src/map/map.c | 463 ++++++---- src/map/mapreg_sql.c | 38 +- src/map/mercenary.c | 75 +- src/map/mob.c | 263 +++--- src/map/npc.c | 274 +++--- src/map/npc_chat.c | 26 +- src/map/party.c | 131 +-- src/map/path.c | 19 +- src/map/pc.c | 610 +++++++------ src/map/pc_groups.c | 37 +- src/map/pet.c | 108 ++- src/map/quest.c | 45 +- src/map/rodex.c | 38 +- src/map/script.c | 1560 ++++++++++++++++++-------------- src/map/searchstore.c | 29 +- src/map/skill.c | 506 ++++++----- src/map/status.c | 457 +++++----- src/map/storage.c | 146 +-- src/map/trade.c | 20 +- src/map/unit.c | 106 +-- src/map/vending.c | 18 +- 41 files changed, 5470 insertions(+), 4179 deletions(-) diff --git a/src/map/HPMmap.c b/src/map/HPMmap.c index 17b4fd813..e4640d09d 100644 --- a/src/map/HPMmap.c +++ b/src/map/HPMmap.c @@ -104,8 +104,8 @@ struct HPM_atcommand_list { AtCommandFunc func; }; -struct HPM_atcommand_list *atcommand_list = NULL; -unsigned int atcommand_list_items = 0; +static struct HPM_atcommand_list *atcommand_list = NULL; +static unsigned int atcommand_list_items = 0; /** * HPM plugin data store validator sub-handler (map-server) @@ -135,14 +135,16 @@ bool HPM_map_data_store_validate(enum HPluginDataTypes type, struct hplugin_data return false; } -void HPM_map_plugin_load_sub(struct hplugin *plugin) { +void HPM_map_plugin_load_sub(struct hplugin *plugin) +{ plugin->hpi->sql_handle = map->mysql_handle; plugin->hpi->addCommand = atcommand->create; plugin->hpi->addScript = script->addScript; plugin->hpi->addPCGPermission = HPM_map_add_group_permission; } -bool HPM_map_add_atcommand(char *name, AtCommandFunc func) { +bool HPM_map_add_atcommand(char *name, AtCommandFunc func) +{ unsigned int i = 0; for(i = 0; i < atcommand_list_items; i++) { @@ -162,7 +164,8 @@ bool HPM_map_add_atcommand(char *name, AtCommandFunc func) { return true; } -void HPM_map_atcommands(void) { +void HPM_map_atcommands(void) +{ unsigned int i; for(i = 0; i < atcommand_list_items; i++) { @@ -173,7 +176,8 @@ void HPM_map_atcommands(void) { /** * Adds a new group permission to the HPM-provided list **/ -void HPM_map_add_group_permission(unsigned int pluginID, char *name, unsigned int *mask) { +void HPM_map_add_group_permission(unsigned int pluginID, char *name, unsigned int *mask) +{ unsigned char index = pcg->HPMpermissions_count; RECREATE(pcg->HPMpermissions, struct pc_groups_new_permission, ++pcg->HPMpermissions_count); @@ -183,14 +187,16 @@ void HPM_map_add_group_permission(unsigned int pluginID, char *name, unsigned in pcg->HPMpermissions[index].mask = mask; } -void HPM_map_do_init(void) { +void HPM_map_do_init(void) +{ HPM->load_sub = HPM_map_plugin_load_sub; HPM->data_store_validate_sub = HPM_map_data_store_validate; HPM->datacheck_init(HPMDataCheck, HPMDataCheckLen, HPMDataCheckVer); HPM_shared_symbols(SERVER_TYPE_MAP); } -void HPM_map_do_final(void) { +void HPM_map_do_final(void) +{ if (atcommand_list) aFree(atcommand_list); /** diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 4e4508179..2d17f7ae7 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -74,14 +74,15 @@ #include #include -struct atcommand_interface atcommand_s; +static struct atcommand_interface atcommand_s; struct atcommand_interface *atcommand; static char atcmd_output[CHAT_SIZE_MAX]; static char atcmd_player_name[NAME_LENGTH]; // @commands (script-based) -struct atcmd_binding_data* get_atcommandbind_byname(const char* name) { +static struct atcmd_binding_data *get_atcommandbind_byname(const char *name) +{ int i = 0; nullpo_retr(NULL, name); @@ -93,14 +94,16 @@ struct atcmd_binding_data* get_atcommandbind_byname(const char* name) { return ( i < atcommand->binding_count ) ? atcommand->binding[i] : NULL; } -const char* atcommand_msgsd(struct map_session_data *sd, int msg_number) { +static const char *atcommand_msgsd(struct map_session_data *sd, int msg_number) +{ Assert_retr("??", msg_number >= 0 && msg_number < MAX_MSG && atcommand->msg_table[0][msg_number] != NULL); if (!sd || sd->lang_id >= atcommand->max_message_table || !atcommand->msg_table[sd->lang_id][msg_number]) return atcommand->msg_table[0][msg_number]; return atcommand->msg_table[sd->lang_id][msg_number]; } -const char* atcommand_msgfd(int fd, int msg_number) { +static const char *atcommand_msgfd(int fd, int msg_number) +{ struct map_session_data *sd = sockt->session_is_valid(fd) ? sockt->session[fd]->session_data : NULL; Assert_retr("??", msg_number >= 0 && msg_number < MAX_MSG && atcommand->msg_table[0][msg_number] != NULL); if (!sd || sd->lang_id >= atcommand->max_message_table || !atcommand->msg_table[sd->lang_id][msg_number]) @@ -111,7 +114,8 @@ const char* atcommand_msgfd(int fd, int msg_number) { //----------------------------------------------------------- // Return the message string of the specified number by [Yor] //----------------------------------------------------------- -const char* atcommand_msg(int msg_number) { +static const char *atcommand_msg(int msg_number) +{ Assert_retr("??", msg_number >= 0 && msg_number < MAX_MSG); if (atcommand->msg_table[map->default_lang_id][msg_number] != NULL && atcommand->msg_table[map->default_lang_id][msg_number][0] != '\0') return atcommand->msg_table[map->default_lang_id][msg_number]; @@ -129,7 +133,8 @@ const char* atcommand_msg(int msg_number) { * @param[in] allow_override whether to allow duplicate message IDs to override the original value. * @return success state. */ -bool msg_config_read(const char *cfg_name, bool allow_override) { +static bool msg_config_read(const char *cfg_name, bool allow_override) +{ int msg_number; char line[1024], w1[1024], w2[1024]; FILE *fp; @@ -176,7 +181,8 @@ bool msg_config_read(const char *cfg_name, bool allow_override) { /*========================================== * Cleanup Message Data *------------------------------------------*/ -void do_final_msg(void) { +static void do_final_msg(void) +{ int i, j; for(i = 0; i < atcommand->max_message_table; i++) { @@ -194,7 +200,8 @@ void do_final_msg(void) { /** * retrieves the help string associated with a given command. */ -static inline const char* atcommand_help_string(AtCommandInfo *info) { +static inline const char *atcommand_help_string(AtCommandInfo *info) +{ return info->help; } @@ -431,7 +438,8 @@ ACMD(send) /*========================================== * @rura, @warp, @mapmove *------------------------------------------*/ -ACMD(mapmove) { +ACMD(mapmove) +{ char map_name[MAP_NAME_LENGTH_EXT]; unsigned short map_index; short x = 0, y = 0; @@ -486,7 +494,8 @@ ACMD(mapmove) { /*========================================== * Displays where a character is. Corrected version by Silent. [Skotlex] *------------------------------------------*/ -ACMD(where) { +ACMD(where) +{ struct map_session_data* pl_sd; memset(atcmd_player_name, '\0', sizeof atcmd_player_name); @@ -514,7 +523,8 @@ ACMD(where) { /*========================================== * *------------------------------------------*/ -ACMD(jumpto) { +ACMD(jumpto) +{ struct map_session_data *pl_sd = NULL; if (!*message) { @@ -597,7 +607,8 @@ ACMD(jump) * Display list of online characters with * various info. *------------------------------------------*/ -ACMD(who) { +ACMD(who) +{ const struct map_session_data *pl_sd = NULL; struct s_mapiterator *iter = NULL; char player_name[NAME_LENGTH] = ""; @@ -794,7 +805,8 @@ ACMD(save) /*========================================== * *------------------------------------------*/ -ACMD(load) { +ACMD(load) +{ int16 m; m = map->mapindex2mapid(sd->status.save_point.map); @@ -932,7 +944,8 @@ ACMD(option) /*========================================== * *------------------------------------------*/ -ACMD(hide) { +ACMD(hide) +{ if (pc_isinvisible(sd)) { sd->sc.option &= ~OPTION_INVISIBLE; if (sd->disguise != -1 ) @@ -1473,7 +1486,8 @@ ACMD(joblevelup) /*========================================== * @help *------------------------------------------*/ -ACMD(help) { +ACMD(help) +{ const char *command_name = NULL; char *default_command = "help"; AtCommandInfo *tinfo = NULL; @@ -1541,7 +1555,7 @@ ACMD(help) { * Arglist parameters: * - (int) id: If 0, stop any attacks. Otherwise, the target block list id to stop attacking. */ -int atcommand_stopattack(struct block_list *bl,va_list ap) +static int atcommand_stopattack(struct block_list *bl, va_list ap) { struct unit_data *ud = NULL; int id = 0; @@ -1560,7 +1574,7 @@ int atcommand_stopattack(struct block_list *bl,va_list ap) /*========================================== * *------------------------------------------*/ -int atcommand_pvpoff_sub(struct block_list *bl,va_list ap) +static int atcommand_pvpoff_sub(struct block_list *bl, va_list ap) { struct map_session_data *sd = NULL; nullpo_ret(bl); @@ -1598,7 +1612,7 @@ ACMD(pvpoff) /*========================================== * *------------------------------------------*/ -int atcommand_pvpon_sub(struct block_list *bl,va_list ap) +static int atcommand_pvpon_sub(struct block_list *bl, va_list ap) { struct map_session_data *sd = NULL; nullpo_ret(bl); @@ -1641,7 +1655,8 @@ ACMD(pvpon) /*========================================== * *------------------------------------------*/ -ACMD(gvgoff) { +ACMD(gvgoff) +{ if (!map->list[sd->bl.m].flag.gvg) { clif->message(fd, msg_fd(fd,162)); // GvG is already Off. @@ -1870,7 +1885,8 @@ ACMD(hair_color) /*========================================== * @go [city_number or city_name] - Updated by Harbin *------------------------------------------*/ -ACMD(go) { +ACMD(go) +{ int town = INT_MAX; // Initialized to INT_MAX instead of -1 to avoid conflicts with those who map [-3:-1] to @memo locations. char map_name[MAP_NAME_LENGTH]; @@ -2100,7 +2116,7 @@ ACMD(monster) /*========================================== * *------------------------------------------*/ -int atkillmonster_sub(struct block_list *bl, va_list ap) +static int atkillmonster_sub(struct block_list *bl, va_list ap) { struct mob_data *md = NULL; int flag = va_arg(ap, int); @@ -2118,7 +2134,8 @@ int atkillmonster_sub(struct block_list *bl, va_list ap) return 1; } -ACMD(killmonster) { +ACMD(killmonster) +{ int map_id, drop_flag; char map_name[MAP_NAME_LENGTH_EXT]; @@ -2315,7 +2332,8 @@ ACMD(memo) /*========================================== * *------------------------------------------*/ -ACMD(gat) { +ACMD(gat) +{ int y; memset(atcmd_output, '\0', sizeof(atcmd_output)); @@ -2461,7 +2479,8 @@ ACMD(zeny) /*========================================== * *------------------------------------------*/ -ACMD(param) { +ACMD(param) +{ int i, value = 0, new_value, max; const char* param[] = { "str", "agi", "vit", "int", "dex", "luk" }; short* stats[6]; @@ -2521,7 +2540,8 @@ ACMD(param) { /*========================================== * Stat all by fritz (rewritten by [Yor]) *------------------------------------------*/ -ACMD(stat_all) { +ACMD(stat_all) +{ int index, count, value, max, new_value; short* stats[6]; //we don't use direct initialization because it isn't part of the c standard. @@ -2577,7 +2597,8 @@ ACMD(stat_all) { /*========================================== * *------------------------------------------*/ -ACMD(guildlevelup) { +ACMD(guildlevelup) +{ int level = 0; int16 added_level; struct guild *guild_info; @@ -2766,7 +2787,8 @@ ACMD(petrename) /*========================================== * *------------------------------------------*/ -ACMD(recall) { +ACMD(recall) +{ struct map_session_data *pl_sd = NULL; if (!*message) { @@ -3038,7 +3060,7 @@ ACMD(doommap) /*========================================== * *------------------------------------------*/ -void atcommand_raise_sub(struct map_session_data* sd) +static void atcommand_raise_sub(struct map_session_data *sd) { nullpo_retv(sd); status->revive(&sd->bl, 100, 100); @@ -3336,7 +3358,8 @@ ACMD(breakguild) /*========================================== * *------------------------------------------*/ -ACMD(agitstart) { +ACMD(agitstart) +{ if (map->agit_flag == 1) { clif->message(fd, msg_fd(fd,73)); // War of Emperium is currently in progress. return false; @@ -3352,7 +3375,8 @@ ACMD(agitstart) { /*========================================== * *------------------------------------------*/ -ACMD(agitstart2) { +ACMD(agitstart2) +{ if (map->agit2_flag == 1) { clif->message(fd, msg_fd(fd,404)); // "War of Emperium SE is currently in progress." return false; @@ -3368,7 +3392,8 @@ ACMD(agitstart2) { /*========================================== * *------------------------------------------*/ -ACMD(agitend) { +ACMD(agitend) +{ if (map->agit_flag == 0) { clif->message(fd, msg_fd(fd,75)); // War of Emperium is currently not in progress. return false; @@ -3384,7 +3409,8 @@ ACMD(agitend) { /*========================================== * *------------------------------------------*/ -ACMD(agitend2) { +ACMD(agitend2) +{ if (map->agit2_flag == 0) { clif->message(fd, msg_fd(fd,406)); // "War of Emperium SE is currently not in progress." return false; @@ -3400,7 +3426,8 @@ ACMD(agitend2) { /*========================================== * @mapexit - shuts down the map server *------------------------------------------*/ -ACMD(mapexit) { +ACMD(mapexit) +{ map->do_shutdown(); return true; } @@ -3610,7 +3637,8 @@ ACMD(reloaditemdb) /*========================================== * *------------------------------------------*/ -ACMD(reloadmobdb) { +ACMD(reloadmobdb) +{ mob->reload(); pet->read_db(); homun->reload(); @@ -3639,7 +3667,8 @@ ACMD(reloadskilldb) /*========================================== * @reloadatcommand - reloads conf/atcommand.conf conf/groups.conf *------------------------------------------*/ -ACMD(reloadatcommand) { +ACMD(reloadatcommand) +{ struct config_t run_test; if (!libconfig->load_file(&run_test, "conf/groups.conf")) { @@ -3713,7 +3742,8 @@ ACMD(reloadbattleconf) /*========================================== * @reloadstatusdb - reloads job_db1.txt job_db2.txt job_db2-2.txt refine_db.txt size_fix.txt *------------------------------------------*/ -ACMD(reloadstatusdb) { +ACMD(reloadstatusdb) +{ status->readdb(); clif->message(fd, msg_fd(fd,256)); return true; @@ -3731,7 +3761,8 @@ ACMD(reloadpcdb) /*========================================== * @reloadscript - reloads all scripts (npcs, warps, mob spawns, ...) *------------------------------------------*/ -ACMD(reloadscript) { +ACMD(reloadscript) +{ struct s_mapiterator* iter; struct map_session_data* pl_sd; @@ -4104,7 +4135,8 @@ ACMD(mount_peco) /*========================================== *Spy Commands by Syrus22 *------------------------------------------*/ -ACMD(guildspy) { +ACMD(guildspy) +{ char guild_name[NAME_LENGTH]; struct guild *g; @@ -4143,7 +4175,8 @@ ACMD(guildspy) { /*========================================== * *------------------------------------------*/ -ACMD(partyspy) { +ACMD(partyspy) +{ char party_name[NAME_LENGTH]; struct party_data *p; @@ -4212,7 +4245,8 @@ ACMD(repairall) /*========================================== * @nuke [Valaris] *------------------------------------------*/ -ACMD(nuke) { +ACMD(nuke) +{ struct map_session_data *pl_sd; memset(atcmd_player_name, '\0', sizeof(atcmd_player_name)); @@ -4241,7 +4275,8 @@ ACMD(nuke) { /*========================================== * @tonpc *------------------------------------------*/ -ACMD(tonpc) { +ACMD(tonpc) +{ char npcname[NAME_LENGTH+1]; struct npc_data *nd; @@ -4367,7 +4402,8 @@ ACMD(unloadnpc) /*========================================== * time in txt for time command (by [Yor]) *------------------------------------------*/ -char* txt_time(int fd, unsigned int duration) { +static char *txt_time(int fd, unsigned int duration) +{ int days, hours, minutes, seconds; static char temp1[CHAT_SIZE_MAX]; int tlen = 0; @@ -4405,7 +4441,8 @@ char* txt_time(int fd, unsigned int duration) { * @time/@date/@serverdate/@servertime: Display the date/time of the server (by [Yor] * Calculation management of GM modification (@day/@night GM commands) is done *------------------------------------------*/ -ACMD(servertime) { +ACMD(servertime) +{ time_t time_server; // variable for number of seconds (used with time() function) struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ... char temp[CHAT_SIZE_MAX]; @@ -4460,7 +4497,7 @@ ACMD(servertime) { //Added by Coltaro //We're using this function here instead of using time_t so that it only counts player's jail time when he/she's online (and since the idea is to reduce the amount of minutes one by one in status->change_timer...). //Well, using time_t could still work but for some reason that looks like more coding x_x -void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int* minute) +static void get_jail_time(int jailtime, int *year, int *month, int *day, int *hour, int *minute) { const int factor_year = 518400; //12*30*24*60 = 518400 const int factor_month = 43200; //30*24*60 = 43200 @@ -4494,7 +4531,8 @@ void get_jail_time(int jailtime, int* year, int* month, int* day, int* hour, int * @jail by [Yor] * Special warp! No check with nowarp and nowarpto flag *------------------------------------------*/ -ACMD(jail) { +ACMD(jail) +{ struct map_session_data *pl_sd; int x, y; unsigned short m_index; @@ -4547,7 +4585,8 @@ ACMD(jail) { * @unjail/@discharge by [Yor] * Special warp! No check with nowarp and nowarpto flag *------------------------------------------*/ -ACMD(unjail) { +ACMD(unjail) +{ struct map_session_data *pl_sd; memset(atcmd_player_name, '\0', sizeof(atcmd_player_name)); @@ -4581,7 +4620,8 @@ ACMD(unjail) { return true; } -ACMD(jailfor) { +ACMD(jailfor) +{ struct map_session_data *pl_sd = NULL; int year, month, day, hour, minute; char * modif_p; @@ -4865,7 +4905,8 @@ ACMD(undisguise) /*========================================== * UndisguiseAll *------------------------------------------*/ -ACMD(undisguiseall) { +ACMD(undisguiseall) +{ struct map_session_data *pl_sd; struct s_mapiterator* iter; @@ -5043,7 +5084,8 @@ ACMD(killer) * @killable by MouseJstr * enable other people killing you *------------------------------------------*/ -ACMD(killable) { +ACMD(killable) +{ sd->state.killable = !sd->state.killable; if (sd->state.killable) { @@ -5059,7 +5101,8 @@ ACMD(killable) { * @skillon by MouseJstr * turn skills on for the map *------------------------------------------*/ -ACMD(skillon) { +ACMD(skillon) +{ map->list[sd->bl.m].flag.noskill = 0; clif->message(fd, msg_fd(fd,244)); return true; @@ -5069,7 +5112,8 @@ ACMD(skillon) { * @skilloff by MouseJstr * Turn skills off on the map *------------------------------------------*/ -ACMD(skilloff) { +ACMD(skilloff) +{ map->list[sd->bl.m].flag.noskill = 1; clif->message(fd, msg_fd(fd,243)); return true; @@ -5079,7 +5123,8 @@ ACMD(skilloff) { * @npcmove by MouseJstr * move a npc *------------------------------------------*/ -ACMD(npcmove) { +ACMD(npcmove) +{ int x = 0, y = 0, m; struct npc_data *nd = 0; @@ -5149,7 +5194,8 @@ ACMD(addwarp) * @follow by [MouseJstr] * Follow a player .. staying no more then 5 spaces away *------------------------------------------*/ -ACMD(follow) { +ACMD(follow) +{ struct map_session_data *pl_sd = NULL; if (!*message) { @@ -5374,7 +5420,8 @@ ACMD(skillid) * @useskill by [MouseJstr] * A way of using skills without having to find them in the skills menu *------------------------------------------*/ -ACMD(useskill) { +ACMD(useskill) +{ struct map_session_data *pl_sd = NULL; struct block_list *bl; uint16 skill_id; @@ -5420,7 +5467,8 @@ ACMD(useskill) { * Debug command to locate new skill IDs. It sends the * three possible skill-effect packets to the area. *------------------------------------------*/ -ACMD(displayskill) { +ACMD(displayskill) +{ struct status_data *st; int64 tick; uint16 skill_id; @@ -5491,7 +5539,8 @@ ACMD(skilltree) } // Hand a ring with partners name on it to this char -void atcommand_getring(struct map_session_data* sd) { +static void atcommand_getring(struct map_session_data *sd) +{ int flag, item_id; struct item item_tmp; nullpo_retv(sd); @@ -5514,7 +5563,8 @@ void atcommand_getring(struct map_session_data* sd) { * @marry by [MouseJstr], fixed by Lupus * Marry two players *------------------------------------------*/ -ACMD(marry) { +ACMD(marry) +{ struct map_session_data *pl_sd = NULL; char player_name[NAME_LENGTH] = ""; @@ -5633,7 +5683,8 @@ ACMD(autotrade) * @changegm by durf (changed by Lupus) * Changes Master of your Guild to a specified guild member *------------------------------------------*/ -ACMD(changegm) { +ACMD(changegm) +{ struct guild *g; struct map_session_data *pl_sd; @@ -5665,7 +5716,8 @@ ACMD(changegm) { * @changeleader by Skotlex * Changes the leader of a party. *------------------------------------------*/ -ACMD(changeleader) { +ACMD(changeleader) +{ if (!message[0]) { clif->message(fd, msg_fd(fd,1185)); // Usage: @changeleader @@ -5854,7 +5906,8 @@ ACMD(autolootitem) * Credits: * chriser,Aleos *------------------------------------------*/ -ACMD(autoloottype) { +ACMD(autoloottype) +{ uint8 action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset enum item_types type = -1; int ITEM_NONE = 0; @@ -5967,8 +6020,8 @@ ACMD(snow) /*========================================== * Cherry tree snowstorm is made to fall. (Sakura) *------------------------------------------*/ -ACMD(sakura) { - +ACMD(sakura) +{ if (map->list[sd->bl.m].flag.sakura) { map->list[sd->bl.m].flag.sakura=0; clif->weather(sd->bl.m); @@ -5984,8 +6037,8 @@ ACMD(sakura) { /*========================================== * Clouds appear. *------------------------------------------*/ -ACMD(clouds) { - +ACMD(clouds) +{ if (map->list[sd->bl.m].flag.clouds) { map->list[sd->bl.m].flag.clouds=0; clif->weather(sd->bl.m); @@ -6002,8 +6055,8 @@ ACMD(clouds) { /*========================================== * Different type of clouds using effect 516 *------------------------------------------*/ -ACMD(clouds2) { - +ACMD(clouds2) +{ if (map->list[sd->bl.m].flag.clouds2) { map->list[sd->bl.m].flag.clouds2=0; clif->weather(sd->bl.m); @@ -6020,8 +6073,8 @@ ACMD(clouds2) { /*========================================== * Fog hangs over. *------------------------------------------*/ -ACMD(fog) { - +ACMD(fog) +{ if (map->list[sd->bl.m].flag.fog) { map->list[sd->bl.m].flag.fog=0; clif->weather(sd->bl.m); @@ -6037,8 +6090,8 @@ ACMD(fog) { /*========================================== * Fallen leaves fall. *------------------------------------------*/ -ACMD(leaves) { - +ACMD(leaves) +{ if (map->list[sd->bl.m].flag.leaves) { map->list[sd->bl.m].flag.leaves=0; clif->weather(sd->bl.m); @@ -6055,8 +6108,8 @@ ACMD(leaves) { /*========================================== * Fireworks appear. *------------------------------------------*/ -ACMD(fireworks) { - +ACMD(fireworks) +{ if (map->list[sd->bl.m].flag.fireworks) { map->list[sd->bl.m].flag.fireworks=0; clif->weather(sd->bl.m); @@ -6164,20 +6217,23 @@ ACMD(mobsearch) * @cleanmap - cleans items on the ground * @cleanarea - cleans items on the ground within an specified area *------------------------------------------*/ -int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap) { +static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap) +{ nullpo_ret(bl); map->clearflooritem(bl); return 0; } -ACMD(cleanmap) { +ACMD(cleanmap) +{ map->foreachinmap(atcommand->cleanfloor_sub, sd->bl.m, BL_ITEM); clif->message(fd, msg_fd(fd,1221)); // All dropped items have been cleaned up. return true; } -ACMD(cleanarea) { +ACMD(cleanarea) +{ int x0 = 0, y0 = 0, x1 = 0, y1 = 0, n = 0; if (!*message || (n=sscanf(message, "%d %d %d %d", &x0, &y0, &x1, &y1)) < 1) { @@ -6341,7 +6397,8 @@ ACMD(users) /*========================================== * *------------------------------------------*/ -ACMD(reset) { +ACMD(reset) +{ pc->resetstate(sd); pc->resetskill(sd, PCRESETSKILL_RESYNC); safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,208), sd->status.name); // '%s' skill and stats points reseted! @@ -6424,7 +6481,8 @@ ACMD(adjgroup) * @trade by [MouseJstr] * Open a trade window with a remote player *------------------------------------------*/ -ACMD(trade) { +ACMD(trade) +{ struct map_session_data *pl_sd = NULL; if (!*message) { @@ -6467,7 +6525,8 @@ ACMD(setbattleflag) /*========================================== * @unmute [Valaris] *------------------------------------------*/ -ACMD(unmute) { +ACMD(unmute) +{ struct map_session_data *pl_sd = NULL; if (!*message) { @@ -6518,7 +6577,8 @@ ACMD(uptime) * @changesex * => Changes one's sex. Argument sex can be 0 or 1, m or f, male or female. *------------------------------------------*/ -ACMD(changesex) { +ACMD(changesex) +{ int i; pc->resetskill(sd, PCRESETSKILL_CHSEX); @@ -6532,7 +6592,8 @@ ACMD(changesex) { /*================================================ * @mute - Mutes a player for a set amount of time *------------------------------------------------*/ -ACMD(mute) { +ACMD(mute) +{ struct map_session_data *pl_sd = NULL; int manner; @@ -6610,7 +6671,8 @@ ACMD(identify) return true; } -ACMD(misceffect) { +ACMD(misceffect) +{ int effect = 0; if (!*message) @@ -6851,7 +6913,8 @@ ACMD(showmobs) /*========================================== * homunculus level up [orn] *------------------------------------------*/ -ACMD(homlevel) { +ACMD(homlevel) +{ struct homun_data *hd; int level = 0; enum homun_type htype; @@ -6922,7 +6985,8 @@ ACMD(homevolution) return true; } -ACMD(hommutate) { +ACMD(hommutate) +{ int homun_id; enum homun_type m_class, m_id; @@ -6951,7 +7015,8 @@ ACMD(hommutate) { /*========================================== * call choosen homunculus [orn] *------------------------------------------*/ -ACMD(makehomun) { +ACMD(makehomun) +{ int homunid; if (!*message) { @@ -7071,7 +7136,8 @@ ACMD(homtalk) /*========================================== * Show homunculus stats *------------------------------------------*/ -ACMD(hominfo) { +ACMD(hominfo) +{ struct homun_data *hd; struct status_data *st; @@ -7331,7 +7397,8 @@ ACMD(whereis) return true; } -ACMD(version) { +ACMD(version) +{ safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1296), sysinfo->is64bit() ? 64 : 32, sysinfo->platform()); // Hercules %d-bit for %s clif->message(fd, atcmd_output); safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1295), sysinfo->vcstype(), sysinfo->vcsrevision_src(), sysinfo->vcsrevision_scripts()); // %s revision '%s' (src) / '%s' (scripts) @@ -7343,8 +7410,9 @@ ACMD(version) { /*========================================== * @mutearea by MouseJstr *------------------------------------------*/ -int atcommand_mutearea_sub(struct block_list *bl, va_list ap) -{ // As it is being used [ACMD(mutearea)] there's no need to be a bool, but if there's need to reuse it, it's better to be this way +static int atcommand_mutearea_sub(struct block_list *bl, va_list ap) +{ + // As it is being used [ACMD(mutearea)] there's no need to be a bool, but if there's need to reuse it, it's better to be this way int time, id; struct map_session_data *pl_sd = BL_CAST(BL_PC, bl); @@ -7364,7 +7432,8 @@ int atcommand_mutearea_sub(struct block_list *bl, va_list ap) return 1; } -ACMD(mutearea) { +ACMD(mutearea) +{ int time; if (!*message) { @@ -7579,7 +7648,8 @@ ACMD(fakename) /*========================================== * Ragnarok Resources *------------------------------------------*/ -ACMD(mapflag) { +ACMD(mapflag) +{ #define CHECKFLAG( cmd ) do { if (map->list[ sd->bl.m ].flag.cmd ) clif->message(sd->fd,#cmd);} while(0) #define SETFLAG( cmd ) do { \ if (strcmp( flag_name , #cmd ) == 0) { \ @@ -7767,7 +7837,8 @@ ACMD(invite) return true; } -ACMD(duel) { +ACMD(duel) +{ unsigned int maxpl = 0; if (sd->duel_group > 0) { @@ -7820,7 +7891,8 @@ ACMD(duel) { return true; } -ACMD(leave) { +ACMD(leave) +{ if (sd->duel_group <= 0) { // "Duel: @leave without @duel." clif->message(fd, msg_fd(fd,358)); @@ -7831,7 +7903,8 @@ ACMD(leave) { return true; } -ACMD(accept) { +ACMD(accept) +{ if (!duel->checktime(sd)) { char output[CHAT_SIZE_MAX]; // "Duel: You can take part in duel only one time per %d minutes." @@ -7859,7 +7932,8 @@ ACMD(accept) { return true; } -ACMD(reject) { +ACMD(reject) +{ if (sd->duel_invite <= 0) { // "Duel: @reject without invitation." clif->message(fd, msg_fd(fd,362)); @@ -7929,7 +8003,8 @@ ACMD(cash) } // @clone/@slaveclone/@evilclone [Valaris] -ACMD(clone) { +ACMD(clone) +{ int x=0,y=0,flag=0,master=0,i=0; struct map_session_data *pl_sd=NULL; @@ -8047,7 +8122,8 @@ ACMD(auction) /*========================================== * Kill Steal Protection *------------------------------------------*/ -ACMD(ksprotection) { +ACMD(ksprotection) +{ if( sd->state.noks ) { sd->state.noks = KSPROTECT_NONE; clif->message(fd, msg_fd(fd,1325)); // [ K.S Protection Inactive ] @@ -8307,7 +8383,8 @@ ACMD(stats) return true; } -ACMD(delitem) { +ACMD(delitem) +{ char item_name[100]; int nameid, amount = 0, total, idx; struct item_data* id; @@ -8368,7 +8445,8 @@ ACMD(delitem) { /*========================================== * Custom Fonts *------------------------------------------*/ -ACMD(font) { +ACMD(font) +{ int font_id; font_id = atoi(message); @@ -8403,7 +8481,7 @@ ACMD(font) { /*========================================== * type: 1 = commands (@), 2 = charcommands (#) *------------------------------------------*/ -void atcommand_commands_sub(struct map_session_data* sd, const int fd, AtCommandType type) +static void atcommand_commands_sub(struct map_session_data *sd, const int fd, AtCommandType type) { char line_buff[CHATBOX_SIZE]; char* cur = line_buff; @@ -8528,7 +8606,8 @@ ACMD(cashmount) return true; } -ACMD(accinfo) { +ACMD(accinfo) +{ char query[NAME_LENGTH]; if (!*message || strlen(message) > NAME_LENGTH ) { @@ -8657,12 +8736,16 @@ ACMD(set) aFree(data); return true; } -ACMD(reloadquestdb) { + +ACMD(reloadquestdb) +{ quest->reload(); clif->message(fd, msg_fd(fd,1377)); // Quest database has been reloaded. return true; } -ACMD(addperm) { + +ACMD(addperm) +{ int perm_size = pcg->permission_count; bool add = (strcmpi(info->command, "addperm") == 0) ? true : false; int i; @@ -8718,6 +8801,7 @@ ACMD(addperm) { return true; } + ACMD(unloadnpcfile) { if (!*message) { @@ -8733,7 +8817,9 @@ ACMD(unloadnpcfile) } return true; } -ACMD(cart) { + +ACMD(cart) +{ #define MC_CART_MDFY(x,idx) do { \ sd->status.skill[idx].id = (x)?MC_PUSHCART:0; \ sd->status.skill[idx].lv = (x)?1:0; \ @@ -8775,6 +8861,7 @@ ACMD(cart) { return true; #undef MC_CART_MDFY } + /* [Ind/Hercules] */ ACMD(join) { @@ -8818,8 +8905,10 @@ ACMD(join) return true; } + /* [Ind/Hercules] */ -void atcommand_channel_help(int fd, const char *command, bool can_create) { +static void atcommand_channel_help(int fd, const char *command, bool can_create) +{ nullpo_retv(command); safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1404),command); // %s failed. clif->message(fd, atcmd_output); @@ -8869,8 +8958,10 @@ void atcommand_channel_help(int fd, const char *command, bool can_create) { clif->message(fd, msg_fd(fd,1463));// - adds or removes