Mercurial > hg > batmud > maputils
view liblocfile.h @ 1674:3f52fa562a46
Update copyrights and add copyright headers.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 18 Apr 2017 19:44:58 +0300 |
parents | c2a6e11ea44c |
children | cc59f80b0e78 |
line wrap: on
line source
/* * liblocfile - Location file format handling * Programmed by Matti 'ccr' Hämäläinen (Ggr Pupunen) * (C) Copyright 2006-2017 Tecnic Software productions (TNSP) */ #ifndef LIBLOCFILE_H #define LIBLOCFILE_H #include "libutil.h" #include <time.h> #include <stdio.h> /* Version string */ #define LOC_MAGIC "MapUtils LOC file" #define LOC_VERSION_MAJOR (4) #define LOC_VERSION_MINOR (0) /* LOCD_* is an enum describing the preferred orientation of the * location marker _label_ in relation to the marker spot. */ enum { LOCD_NONE = 0, LOCD_LEFT, LOCD_LEFTDOWN, LOCD_DOWN }; /* Timestamp used in loc-files, in sscanf() format. */ #define LOC_TIMEFMT "%02d.%02d.%04d" /* These flags are used to describe the marker/location type and label * related information: [LOCF_M_*] Draw marker of specified type (by default, * no marker is drawn). LOCF_M_CITY and LOCF_M_PCITY are special, they also * work as aliases to LOCF_T_CITY/PCITY and thus have similar functionality. * * [LOCF_T_*] specify the type of the location/marker. Currently the effect * of this settings is addition of "GUILD", "SHRINE"-type strings to labels, * but this information can be used in other ways too. */ #define LOCF_NONE (0x00000) /* Marker types */ #define LOCF_M_SCENIC1 (0x000001) /* '?' Scenic marker */ #define LOCF_M_SCENIC2 (0x000002) /* '%' Shrine marker/etc */ #define LOCF_M_PCITY (0x000004) /* 'C' Player city */ #define LOCF_M_CITY (0x000008) /* 'c' City */ #define LOCF_M_MASK (0x00000F) /* Location types */ #define LOCF_T_SHRINE (0x000010) /* 'S' Raceshrine */ #define LOCF_T_GUILD (0x000020) /* 'G' Guild */ #define LOCF_T_SS (0x000040) /* 'P' Player guild/Secret Society */ #define LOCF_T_MONSTER (0x000080) /* 'M' Special monster */ #define LOCF_T_TRAINER (0x000100) /* 'T' Guild trainer */ #define LOCF_T_FORT (0x000200) /* 'F' Regions fort */ #define LOCF_T_MASK (0x00FFF0) #define LOCF_MASK (LOCF_M_MASK | LOCF_T_MASK) /* Extra flags */ #define LOCF_INVIS (0x010000) /* '-' Invisible marker / Don't show label */ #define LOCF_CLOSED (0x020000) /* '!' Area is CLOSED */ #define LOCF_INSTANCED (0x040000) /* 'I' Location is "instanced" for each player */ #define LOCF_INVALID (0x400000) /* Possibly invalid location */ #define LOCF_NOMARKER (0x800000) /* Location has no marker in mapdata or explicitly defined */ #define LOCF_Q_MASK (0xFF0000) /* Misc constants */ #define LOC_MAX_NAMES (64) /* Probably more than enough? */ #define LOC_MARKERS "?%C" #define LOC_MAX_FILES (64) #define NAME_ORIG (0x00001) /* '@' Original area name or coder */ #define NAME_RECODER (0x00002) /* '!' Converter or recoder of area */ #define NAME_MAINTAINER (0x00004) /* '%' Maintainer */ #define NAME_EXPANDER (0x00008) /* '&' Expander, adding new things */ /* Structures */ typedef struct { int day, month, year; } LocDateStruct; typedef struct { char *filename; char *continent; int x, y; } LocFileInfo; typedef struct { char *name; int flags; } LocName; typedef struct { LocFileInfo *file; // Reference to file/continent data int x, y, ox, oy; // Location coordinates int align; // Label alignment value int flags; // Flags (see LOCF_*) LocDateStruct added; // Date / time information BOOL valid; int nnames, ncoders; LocName names[LOC_MAX_NAMES], coders[LOC_MAX_NAMES]; char *uri, *freeform; int val; // Special value for sorting purposes } LocMarker; typedef struct { int n; LocMarker **locations; } MapLocations; /* Location file parsing and data handling */ BOOL locAddNew(MapLocations *l, int x, int y, int dir, int flags, LocName *names, LocName *coders, LocDateStruct *added, BOOL valid, const char *uri, const char *freeform, LocFileInfo *file); BOOL locParseLocStream(FILE *fp, LocFileInfo *file, MapLocations *l, int offX, int offY); void locFreeMarkerData(LocMarker *marker); void locFreeMapLocations(MapLocations *loc); int locFindByCoords(MapLocations *l, int x, int y, BOOL locTrue); const char * locGetType(int flags); const char * locGetLocationType(int flags); LocMarker *locCopyLocMarker(LocMarker *); void locCopyLocations(MapLocations *dst, MapLocations *src); void setLocFileInfo(LocFileInfo *f, const char *filename, const char *continent); #endif