diff options
author | Haru <haru@dotalux.com> | 2015-09-17 01:21:28 +0200 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2015-10-11 00:24:22 +0200 |
commit | 70265291d62280c525adc317158e9f531e0147ff (patch) | |
tree | 8beae9d0edc99a38bc678b86f2709780314ad327 /src/common/HPM.h | |
parent | 502703d2b632125b35a2b8d341a90a13d7445f02 (diff) | |
download | hercules-70265291d62280c525adc317158e9f531e0147ff.tar.gz hercules-70265291d62280c525adc317158e9f531e0147ff.tar.bz2 hercules-70265291d62280c525adc317158e9f531e0147ff.tar.xz hercules-70265291d62280c525adc317158e9f531e0147ff.zip |
Cleanup of the HPluginData implementation (First part)
- Several explicit casts are removed, to have a slightly better
type-checking at compile time.
- A destructor function is provided, to remove code duplication.
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/common/HPM.h')
-rw-r--r-- | src/common/HPM.h | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/common/HPM.h b/src/common/HPM.h index 444829419..1d13a178f 100644 --- a/src/common/HPM.h +++ b/src/common/HPM.h @@ -65,7 +65,7 @@ struct hpm_symbol { void *ptr; ///< The symbol value }; -struct HPluginData { +struct hplugin_data_entry { unsigned int pluginID; unsigned int type; struct { @@ -74,6 +74,11 @@ struct HPluginData { void *data; }; +struct hplugin_data_store { + struct hplugin_data_entry **array; + unsigned int count; +}; + struct HPluginPacket { unsigned int pluginID; unsigned short cmd; @@ -86,10 +91,6 @@ struct HPMFileNameCache { char *name; }; -struct HPDataOperationStorage { - void **HPDataSRCPtr; - unsigned int *hdatac; -}; /* */ struct HPConfListenStorage { unsigned int pluginID; @@ -136,15 +137,18 @@ struct HPM_interface { unsigned char (*parse_packets) (int fd, enum HPluginPacketHookingPoints point); void (*load_sub) (struct hplugin *plugin); bool (*addhook_sub) (enum HPluginHookType type, const char *target, void *hook, unsigned int pID); - void (*grabHPData) (struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr); - /* for server-specific HPData e.g. map_session_data */ - bool (*grabHPDataSub) (struct HPDataOperationStorage *ret, enum HPluginDataTypes type, void *ptr); /* for custom config parsing */ bool (*parseConf) (const char *w1, const char *w2, enum HPluginConfType point); /* validates plugin data */ bool (*DataCheck) (struct s_HPMDataCheck *src, unsigned int size, int version, char *name); void (*datacheck_init) (const struct s_HPMDataCheck *src, unsigned int length, int version); void (*datacheck_final) (void); + + struct hplugin_data_store *(*data_store_create) (void); + void (*data_store_destroy) (struct hplugin_data_store *store); + bool (*data_store_validate) (enum HPluginDataTypes type, struct hplugin_data_store **store); + /* for server-specific HPData e.g. map_session_data */ + bool (*data_store_validate_sub) (enum HPluginDataTypes type, struct hplugin_data_store **store); }; CMDLINEARG(loadplugin); |