summaryrefslogtreecommitdiff
path: root/src/map/map.h
diff options
context:
space:
mode:
authorhemagx <ibrahem.h.basyone@gmail.com>2017-01-16 19:02:15 +0200
committerHaru <haru@dotalux.com>2018-02-17 15:10:12 +0100
commit400076f4e26a121746545cf9f6483ca8e93896b5 (patch)
treea962db573b5483965bcc5e74c127aec08ff350f7 /src/map/map.h
parent59f02f1d406a1238f90d072949ac07279a90e9ea (diff)
downloadhercules-400076f4e26a121746545cf9f6483ca8e93896b5.tar.gz
hercules-400076f4e26a121746545cf9f6483ca8e93896b5.tar.bz2
hercules-400076f4e26a121746545cf9f6483ca8e93896b5.tar.xz
hercules-400076f4e26a121746545cf9f6483ca8e93896b5.zip
New mapcache system
* Now each map is in separated file so now it will be easier to know which map got updated or delete on updates * Now there's md5 checksum check for each map * Now the map cache is platform safe, the old format was not packed which may result in undefined behavior * The map cache tool got converted into hercules plugin Signed-off-by: hemagx <ibrahem.h.basyone@gmail.com>
Diffstat (limited to 'src/map/map.h')
-rw-r--r--src/map/map.h32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/map/map.h b/src/map/map.h
index facf1d921..5c4c6d59d 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -909,7 +909,10 @@ struct map_data {
/* */
int (*getcellp)(struct map_data* m, const struct block_list *bl, int16 x, int16 y, cell_chk cellchk);
void (*setcell) (int16 m, int16 x, int16 y, cell_t cell, bool flag);
- char *cellPos;
+ struct {
+ uint8 *data;
+ int len;
+ } cell_buf;
/* ShowEvent Data Cache */
struct questinfo *qi_data;
@@ -1064,20 +1067,20 @@ struct charid2nick {
struct charid_request* requests;// requests of notification on this nick
};
-// This is the main header found at the very beginning of the map cache
-struct map_cache_main_header {
- uint32 file_size;
- uint16 map_count;
-};
-
-// This is the header appended before every compressed map cells info in the map cache
-struct map_cache_map_info {
- char name[MAP_NAME_LENGTH];
+// New mcache file format header
+#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute
+#pragma pack(push, 1)
+#endif // not NetBSD < 6 / Solaris
+struct map_cache_header {
+ int16 version;
+ uint8 md5_checksum[16];
int16 xs;
int16 ys;
int32 len;
-};
-
+} __attribute__((packed));
+#if !defined(sun) && (!defined(__NETBSD__) || __NetBSD_Version__ >= 600000000) // NetBSD 5 and Solaris don't like pragma pack but accept the packed attribute
+#pragma pack(pop)
+#endif // not NetBSD < 6 / Solaris
/*=====================================
* Interface : map.h
@@ -1167,7 +1170,6 @@ END_ZEROED_BLOCK;
struct map_data *list;
/* [Ind/Hercules] */
struct eri *iterator_ers;
- char *cache_buffer; // Has the uncompressed gat data of all maps, so just one allocation has to be made
/* */
struct eri *flooritem_ers;
/* */
@@ -1317,8 +1319,8 @@ END_ZEROED_BLOCK;
void (*iwall_nextxy) (int16 x, int16 y, int8 dir, int pos, int16 *x1, int16 *y1);
struct DBData (*create_map_data_other_server) (union DBKey key, va_list args);
int (*eraseallipport_sub) (union DBKey key, struct DBData *data, va_list va);
- char* (*init_mapcache) (FILE *fp);
- int (*readfromcache) (struct map_data *m, char *buffer);
+ bool (*readfromcache) (struct map_data *m);
+ bool (*readfromcache_v1) (FILE *fp, struct map_data *m, unsigned int file_size);
int (*addmap) (const char *mapname);
void (*delmapid) (int id);
void (*zone_db_clear) (void);