summaryrefslogtreecommitdiff
path: root/src/map/mapreg.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/mapreg.h')
-rw-r--r--src/map/mapreg.h67
1 files changed, 39 insertions, 28 deletions
diff --git a/src/map/mapreg.h b/src/map/mapreg.h
index b3b89e1b2..4318eaea8 100644
--- a/src/map/mapreg.h
+++ b/src/map/mapreg.h
@@ -21,55 +21,66 @@
#ifndef MAP_MAPREG_H
#define MAP_MAPREG_H
-#include "map/script.h" // struct reg_db
-#include "common/hercules.h"
+#include "map/script.h"
#include "common/db.h"
+#include "common/hercules.h"
-/* Forward Declarations */
-struct config_setting_t; // common/conf.h
+/** Forward Declarations **/
+struct config_setting_t;
struct eri;
-/** Container for a mapreg value */
+#ifndef MAPREG_AUTOSAVE_INTERVAL
+#define MAPREG_AUTOSAVE_INTERVAL (300 * 1000) //!< Interval for auto-saving permanent global variables to the database in milliseconds.
+#endif /** MAPREG_AUTOSAVE_INTERVAL **/
+
+/** Global variable structure. **/
struct mapreg_save {
- int64 uid; ///< Unique ID
- union {
- int i; ///< Numeric value
- char *str; ///< String value
+ int64 uid; //!< The variable's unique ID.
+ union value { //!< The variable's value container.
+ int i; //!< The variable's integer value.
+ char *str; //!< The variable's string value.
} u;
- bool is_string; ///< true if it's a string, false if it's a number
- bool save; ///< Whether a save operation is pending
+ bool is_string; //!< Whether the variable's value is a string.
+ bool save; //!< Whether the variable's save operation is pending.
};
+/** The mapreg interface structure. **/
struct mapreg_interface {
- struct reg_db regs;
- /* */
- bool skip_insert;
- /* */
- struct eri *ers; //[Ind/Hercules]
- /* */
- char table[32];
- /* */
- bool dirty; ///< Whether there are modified regs to be saved
- /* */
- void (*init) (void);
- void (*final) (void);
- /* */
+ /** Interface variables. **/
+ struct eri *ers; //!< Entry manager for global variables.
+ struct reg_db regs; //!< Generic database for global variables.
+ bool dirty; //!< Whether there are modified global variables to be saved.
+ bool skip_insert; //!< Whether to skip inserting the variable into the SQL database in mapreg_set_*_db().
+ char num_db[32]; //!< Name of SQL table which holds permanent global integer variables.
+ char str_db[32]; //!< Name of SQL table which holds permanent global string variables.
+
+ /** Interface functions. **/
int (*readreg) (int64 uid);
- char* (*readregstr) (int64 uid);
+ char *(*readregstr) (int64 uid);
+ bool (*set_num_db) (int64 uid, const char *name, unsigned int index, int value);
+ bool (*delete_num_db) (int64 uid, const char *name, unsigned int index);
bool (*setreg) (int64 uid, int val);
+ bool (*set_str_db) (int64 uid, const char *name, unsigned int index, const char *value);
+ bool (*delete_str_db) (int64 uid, const char *name, unsigned int index);
bool (*setregstr) (int64 uid, const char *str);
+ void (*load_num_db) (void);
+ void (*load_str_db) (void);
void (*load) (void);
+ void (*save_num_db) (const char *name, unsigned int index, int value);
+ void (*save_str_db) (const char *name, unsigned int index, const char *value);
void (*save) (void);
int (*save_timer) (int tid, int64 tick, int id, intptr_t data);
int (*destroyreg) (union DBKey key, struct DBData *data, va_list ap);
void (*reload) (void);
- bool (*config_read) (const char *filename, const struct config_setting_t *config, bool imported);
+ bool (*config_read_registry) (const char *filename, const struct config_setting_t *config, bool imported);
+ void (*final) (void);
+ void (*init) (void);
};
#ifdef HERCULES_CORE
void mapreg_defaults(void);
-#endif // HERCULES_CORE
+#endif /** HERCULES_CORE **/
HPShared struct mapreg_interface *mapreg;
-#endif /* MAP_MAPREG_H */
+#endif /** MAP_MAPREG_H **/