47 "floor",
"no_pick",
"no_pick",
"item",
"item",
48 "item",
"living",
"living",
"fly",
"fly" 86 if (!strcmp(name, map->
path))
174 snprintf(t, buf+size-t,
"%s", s);
211 strlcpy(buf, name,
sizeof(buf));
213 return(_access(buf, 0));
216 if (stat(buf, &statbuf) != 0)
219 if (!S_ISREG(statbuf.st_mode))
222 if (((statbuf.st_mode&
S_IRGRP) && getegid() == statbuf.st_gid)
223 || ((statbuf.st_mode&
S_IRUSR) && geteuid() == statbuf.st_uid)
227 if ((statbuf.st_mode&
S_IWGRP && getegid() == statbuf.st_gid)
228 || (statbuf.st_mode&
S_IWUSR && geteuid() == statbuf.st_uid)
362 LOG(
llevError,
"blocked_link: Passed map, x, y coordinates outside of map\n");
400 tmp_head =
HEAD(tmp);
505 for (tmp = ob->
arch, part = ob; tmp != NULL; tmp = tmp->
more, part = part->
more) {
552 for (at = tmp->arch->
more, last = tmp; at != NULL; at = at->
more, last = op) {
560 if (tmp->name != op->
name) {
565 if (tmp->title != op->
title) {
595 if (tmp->head || tmp->more)
616 object *op, *prev = NULL, *last_more = NULL;
622 while ((i =
load_object(fp, op, bufstate, mapflags,
false))) {
633 if (op->
arch == NULL) {
643 LOG(
llevError,
"Discarding invalid item with type PLAYER in map %s\n", m->
path);
681 last_more->
more = op,
692 "load_objects on %s took %ld us\n", m->
path, diff));
693 for (i = 0; i < m->
width; i++) {
694 for (j = 0; j < m->
height; j++) {
726 int i, j = 0, unique = 0;
727 unsigned int count = 0;
732 long serialize_time, write_time;
773 LOG(
llevDebug,
"saved %d objects on %s (%ld us serializing, %ld us writing)\n", count, m->
path, serialize_time, write_time);
829 LOG(
llevError,
"allocate_map called with already allocated map (%s)\n", m->
path);
875 char *shop_string, *p, *q, *next_semicolon, *next_colon;
877 int i = 0, number_of_entries = 0;
900 for (i = 0; i < number_of_entries; i++) {
902 LOG(
llevError,
"parse_shop_string: I seem to have run out of string, that shouldn't happen.\n");
905 next_semicolon = strchr(p,
';');
906 next_colon = strchr(p,
':');
908 if (next_colon && (!next_semicolon || next_colon < next_semicolon))
909 items[i].
strength = atoi(strchr(p,
':')+1);
911 if (isdigit(*p) || *p ==
'*') {
912 items[i].
typenum = *p ==
'*' ? -1 : atoi(p);
919 q = strpbrk(p,
";:");
931 LOG(
llevError,
"invalid type %s defined in shopitems for %s in string %s\n", p, map->
name, input_string);
934 items[i].
index = number_of_entries;
936 p = ++next_semicolon;
959 output_string[0] =
'\0';
970 snprintf(tmp,
sizeof(tmp),
"*;");
972 snprintf(output_string+strlen(output_string), size-strlen(output_string),
"%s", tmp);
976 if (strlen(output_string) > 0) {
977 output_string[strlen(output_string) - 1] =
'\0';
1001 while (fgets(buf,
sizeof(buf), fp) != NULL) {
1004 p = strchr(buf,
'\n');
1006 LOG(
llevError,
"Error loading map header - did not find a newline - perhaps file is truncated? Buf=%s\n", buf);
1012 while (isspace(*key))
1016 value = strchr(key,
' ');
1020 while (isspace(*value)) {
1022 if (*value ==
'\0') {
1045 if (!strcmp(key,
"msg")) {
1049 while (fgets(buf,
sizeof(buf), fp) != NULL) {
1050 if (!strcmp(buf,
"endmsg\n"))
1053 snprintf(msgbuf+msgpos,
sizeof(msgbuf)-msgpos,
"%s", buf);
1054 msgpos += strlen(buf);
1067 }
else if (!strcmp(key,
"maplore")) {
1069 size_t maplorepos = 0;
1071 while (fgets(buf,
HUGE_BUF-1, fp) != NULL) {
1072 if (!strcmp(buf,
"endmaplore\n"))
1075 if (maplorepos >=
sizeof(maplorebuf)) {
1079 snprintf(maplorebuf+maplorepos,
sizeof(maplorebuf)-maplorepos,
"%s", buf);
1080 maplorepos += strlen(buf);
1083 if (maplorepos != 0)
1085 }
else if (!strcmp(key,
"end")) {
1087 }
else if (value == NULL) {
1088 LOG(
llevError,
"Got '%s' line without parameter in map header\n", key);
1089 }
else if (!strcmp(key,
"arch")) {
1091 if (strcmp(value,
"map")) {
1092 LOG(
llevError,
"load_map_header: expected 'arch map': check line endings?\n");
1095 }
else if (!strcmp(key,
"name")) {
1103 }
else if (!strcmp(key,
"enter_x")) {
1105 }
else if (!strcmp(key,
"enter_y")) {
1107 }
else if (!strcmp(key,
"width")) {
1108 m->
width = atoi(value);
1109 }
else if (!strcmp(key,
"height")) {
1111 }
else if (!strcmp(key,
"reset_timeout")) {
1113 }
else if (!strcmp(key,
"swap_time")) {
1115 }
else if (!strcmp(key,
"difficulty")) {
1117 }
else if (!strcmp(key,
"darkness")) {
1119 }
else if (!strcmp(key,
"fixed_resettime")) {
1121 }
else if (!strcmp(key,
"unique")) {
1123 }
else if (!strcmp(key,
"template")) {
1125 }
else if (!strcmp(key,
"region")) {
1127 }
else if (!strcmp(key,
"shopitems")) {
1129 }
else if (!strcmp(key,
"shopgreed")) {
1131 }
else if (!strcmp(key,
"shopmin")) {
1133 }
else if (!strcmp(key,
"shopmax")) {
1135 }
else if (!strcmp(key,
"shoprace")) {
1137 }
else if (!strcmp(key,
"outdoor")) {
1139 }
else if (!strcmp(key,
"nosmooth")) {
1141 }
else if (!strcmp(key,
"first_load")) {
1143 }
else if (!strncmp(key,
"tile_path_", 10)) {
1144 int tile = atoi(key+10);
1146 if (tile < 1 || tile > 4) {
1147 LOG(
llevError,
"load_map_header: tile location %d out of bounds (%s)\n", tile, m->
path);
1150 LOG(
llevError,
"load_map_header: tile location %d duplicated (%s)\n", tile, m->
path);
1155 }
else if (!strcmp(key,
"background_music")) {
1157 }
else if (!strcmp(key,
"reset_group")) {
1160 LOG(
llevError,
"Got unknown value in map header: %s %s\n", key, value);
1167 if (!key || strcmp(key,
"end")) {
1186 if ((fp = fopen(pathname,
"r")) == NULL) {
1188 "Can't open %s: %s\n", pathname, strerror(errno));
1195 LOG(
llevError,
"Error loading map header for %s, flags=%d\n", map, flags);
1229 map_path(map, flags, pathname,
sizeof(pathname));
1247 LOG(
llevDebug,
"mapfile_load on %s" " took %ld us\n", map, diff));
1269 if ((fp = fopen(m->
tmpname,
"r")) == NULL) {
1303 if ((fp = fopen(pathname,
"r")) == NULL) {
1309 LOG(
llevError,
"Error loading map header for overlay %s (%s)\n", m->
path, pathname);
1333 int i, j, unique = 0;
1360 char name[
MAX_BUF], firstname[
sizeof(name) + 4];
1363 for (count = 0; count < 10; count++) {
1364 snprintf(firstname,
sizeof(firstname),
"%s.v%02d", name, count);
1365 if (!access(firstname, R_OK))
1372 if ((fp = fopen(firstname,
"r")) == NULL) {
1376 LOG(
llevDebug,
"Can't open unique items file for %s\n", name);
1410 if (flag && !*m->
path) {
1424 if (m->
path[0] !=
'~') {
1426 "Cannot save unique map '%s' outside of LOCALDIR. Check " 1427 "that all exits to '%s' have FLAG_UNIQUE set correctly.\n",
1447 fprintf(fp,
"arch map\n");
1449 fprintf(fp,
"name %s\n", m->
name);
1458 fprintf(fp,
"difficulty %d\n", m->
difficulty);
1463 fprintf(fp,
"shopitems %s\n", shop);
1466 fprintf(fp,
"shopgreed %f\n", m->
shopgreed);
1472 fprintf(fp,
"shoprace %s\n", m->
shoprace);
1474 fprintf(fp,
"darkness %d\n", m->
darkness);
1476 fprintf(fp,
"width %d\n", m->
width);
1478 fprintf(fp,
"height %d\n", m->
height);
1480 fprintf(fp,
"enter_x %d\n", m->
enter_x);
1482 fprintf(fp,
"enter_y %d\n", m->
enter_y);
1484 fprintf(fp,
"msg\n%sendmsg\n", m->
msg);
1486 fprintf(fp,
"maplore\n%sendmaplore\n", m->
maplore);
1488 fprintf(fp,
"unique %d\n", m->
unique);
1492 fprintf(fp,
"outdoor %d\n", m->
outdoor);
1494 fprintf(fp,
"nosmooth %d\n", m->
nosmooth);
1504 for (i = 0; i < 4; i++)
1506 fprintf(fp,
"tile_path_%d %s\n", i+1, m->
tile_path[i]);
1508 fprintf(fp,
"end\n");
1516 char name[
MAX_BUF], final_unique[
sizeof(name) + 4];
1519 snprintf(final_unique,
sizeof(final_unique),
"%s.v00", name);
1520 fp2 =
of_open(&of2, final_unique);
1529 LOG(
llevError,
"Save error during object save: %d\n", res);
1538 LOG(
llevError,
"Save error during object save: %d\n", res);
1545 if (ftell(fp2) == 0) {
1551 unlink(final_unique);
1558 if (chmod(final_unique,
SAVE_MODE) != 0) {
1566 LOG(
llevError,
"Save error during object save: %d\n", res);
1577 LOG(
llevError,
"Could not set permissions on '%s'\n", filename);
1618 object *previous_obj = NULL;
1621 if (op == previous_obj) {
1622 LOG(
llevDebug,
"free_all_objects: Link error, bailing out.\n");
1644 LOG(
llevError,
"free_all_objects: object %s still on map after it should have been freed\n", op->
name);
1688 for (i = 0; i < 4; i++) {
1735 for (i = 0; i < 4; i++)
1795 if (strncmp(name, buf, strlen(buf)) == 0) {
1796 snprintf(buf2,
sizeof(buf2),
"~%s", name+strlen(buf)+1);
1801 if (name[0] ==
'~') {
1821 if (m == NULL)
return NULL;
1826 if (!(flags&(
MAP_FLUSH|MAP_PLAYER_UNIQUE)))
1891 if (op->animation) {
1893 op->facing = facings > 1 ? 1 + (
cf_random() % facings) : 1;
1894 op->direction = op->facing;
1896 op->state = max_state > 1 ?
cf_random() % max_state : 0;
1930 int64_t exp_pr_sq, total_exp = 0;
1940 total_exp += op->stats.exp;
1942 total_exp += op->stats.exp;
1945 at = op->other_arch ? op->other_arch : NULL;
1949 int lim = atoi(val ? val :
"0");
1951 if (!lim || lim >= 16)
1967 for (i = 1; i < 25; i++)
2003 LOG(
llevDebug,
"free_all_maps: Freed %d maps\n", real_maps);
2024 int new_level = m->
darkness+change;
2028 || (new_level <= 0 && m->darkness == 0)
2088 if (!honor_visibility)
2095 for (l1 = (l-1); l1 >= low_layer; l1--) {
2096 if (layers[l1]->face->visibility > layers[l1+1]->
face->
visibility) {
2098 layers[l1+1] = layers[l1];
2108 if (!honor_visibility) {
2113 layers[l] = layers[l+1];
2124 for (l = high_layer; l >= low_layer; l--) {
2126 for (l1 = low_layer; l1 < l; l1++)
2127 layers[l1] = layers[l1+1];
2149 uint8_t
flags = 0, oldflags, light = 0;
2152 MoveType move_block = 0, move_slow = 0, move_on = 0, move_off = 0, move_allow = 0;
2156 LOG(
llevDebug,
"update_position called with P_NEED_UPDATE not set: %s (%d, %d)\n", m->
path, x, y);
2160 memset(layers, 0,
MAP_LAYERS*
sizeof(
object *));
2175 if (tmp->glow_radius > light)
2182 if (!tmp->invisible && tmp->face !=
blank_face) {
2183 if (tmp->map_layer) {
2194 memset(layers+1, 0, (
MAP_LAYERS-1)*
sizeof(
object *));
2205 if (tmp == tmp->above) {
2210 move_slow |= tmp->move_slow;
2211 move_block |= tmp->move_block;
2212 move_on |= tmp->move_on;
2213 move_off |= tmp->move_off;
2214 move_allow |= tmp->move_allow;
2234 if (((oldflags&~(P_NEED_UPDATE|
P_NO_ERROR)) != flags)
2236 LOG(
llevDebug,
"update_position: updated flags do not match old flags: %s (x=%d,y=%d) %x != %x\n",
2237 m->
path, x, y, (oldflags&~P_NEED_UPDATE), flags);
2289 int dest_tile = (tile_num+2)%4;
2295 if (orig_map->
tile_map[tile_num] == NULL) {
2307 return orig_map->
tile_map[tile_num];
2324 int16_t xp = x, yp = y;
2357 if ( !m )
return NULL;
2452 }
else if (map1->
tile_map[0] == map2) {
2455 }
else if (map1->
tile_map[1] == map2) {
2458 }
else if (map1->
tile_map[2] == map2) {
2461 }
else if (map1->
tile_map[3] == map2) {
2529 retval->
part = NULL;
2539 if (!(flags&0x1) && op1->
more) {
2550 for (tmp = op1->
more; tmp != NULL; tmp = tmp->
more) {
2553 if (tmpi < best_distance) {
2554 best_distance = tmpi;
2563 retval->
part = best;
2597 retval->
part = NULL;
2603 retval->
part = NULL;
2669 char base[
HUGE_BUF], path[
sizeof(base) + 4];
2674 if (unlink(path) != 0) {
2675 LOG(
llevError,
"Could not delete %s: %s\n", path, strerror(errno));
2682 for (count = 0; count < 10; count++) {
2683 snprintf(path,
sizeof(path),
"%s.v%02d", base, count);
2694 if (item->
map != NULL) {
2695 if (strlen(item->
map->
path) > 0) {
2699 return item->
map->
name ? item->
map->
name :
"(empty path and name)";
2702 if (item->
env != NULL)
2705 return "(no map and no env!)";
2714 return path != NULL && path[0] ==
'~';
2738 if (real ==
nullptr)
2745 if (
ihypot(i - x, j - y) < light)
2764 if (!ob->
map)
return 0;
int save_objects(mapstruct *m, FILE *fp, FILE *fp2, int flag)
This saves all the objects on the map in a non destructive fashion.
#define FLAG_NO_MAGIC
Spells (some) can't pass this object.
int on_same_map(const object *op1, const object *op2)
Checks whether 2 objects are on the same map or not.
int check_path(const char *name, int prepend_dir)
This function checks if a file with the given path exists.
#define MSG_TYPE_MISC
Messages that don't go elsewhere.
signed long object_sum_weight(object *op)
object_sum_weight() is a recursive function which calculates the weight an object is carrying...
void of_cancel(OutputFile *of)
Cancels a save process.
int index
Being the size of the shopitems array.
#define FLAG_DAMNED
The object is very cursed.
#define FLAG_UNPAID
Object hasn't been paid for yet.
#define MOVE_WALK
Object walks.
void update_position(mapstruct *m, int x, int y)
This function updates various attributes about a specific space on the map (what it looks like...
char * stringbuffer_finish(StringBuffer *sb)
Deallocate the string buffer instance and return the string.
#define MAP_STYLE
Active objects shouldn't be put on active list.
#define FLAG_IS_LINKED
The object is linked with other objects.
bool map_path_unique(const char *path)
Return true if the given map path leads to a unique map.
see doc/Developers/objects
#define PROFILE_BEGIN(expr)
void create_template_pathname(const char *name, char *buf, size_t size)
same as create_pathname(), but for the template maps.
This is used by get_rangevector to determine where the other creature is.
struct archetype * arch
Pointer to archetype.
uint64_t shopmax
MMaximum price a shop will offer.
#define P_PLAYER
There is a player on this space.
#define SAVE_ERROR_OK
No error.
#define P_NEED_UPDATE
This space is out of date.
#define MAP_FLUSH
Always load map from the map directory, and don't do unique items or the like.
void free_all_maps(void)
Frees all allocated maps.
object * object_get_owner(object *op)
Returns the object which this object marks as being the owner.
#define MAX_LIGHT_RADII
Max radii for 'light' object, really large values allow objects that can slow down the game...
void allocate_map(mapstruct *m)
This basically allocates the dynamic array of spaces for the map.
void animate_object(object *op, int dir)
Updates the face-variable of an object.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
int load_object(FILE *fp, object *op, int bufstate, int map_flags, bool artifact_init)
#define OB_TYPE_MOVE_BLOCK(ob1, type)
Basic macro to see if if ob1 can not move onto a space based on the 'type' move_block parameter Add c...
static const Map_Layer_Info map_layer_info[MAP_LAYERS]
the ob->map_layer holds the low layer.
object * part
Part we found.
const typedata * get_typedata(int itemtype)
void map_path(const char *map, int flags, char *pathname, size_t bufsize)
#define EVENT_MAPUNLOAD
A map is freed (includes swapping out)
const char * name_pl
Plural name.
int save_map(mapstruct *m, int flag)
Saves a map to file.
char * background_music
Background music to use for this map.
static int load_temporary_map(mapstruct *m)
Loads a map, which has been loaded earlier, from file.
#define MAP_LAYER_ITEM1
Items that can be picked up.
#define FLAG_IS_FLOOR
Can't see what's underneath this object.
void dump_all_maps(void)
Prints out debug-information about all maps.
#define P_NO_MAGIC
Spells (some) can't pass this object.
void object_remove(object *op)
This function removes the object op from the linked list of objects which it is currently tied to...
void dump_map(const mapstruct *m)
Prints out debug-information about a map.
static int adjacent_map(const mapstruct *map1, const mapstruct *map2, int *dx, int *dy)
Return whether map2 is adjacent to map1.
uint32_t reset_timeout
How many seconds must elapse before this map should be reset.
static int load_map_header(FILE *fp, mapstruct *m)
This loads the header information of the map.
void free_map(mapstruct *m)
Frees everything allocated by the given mapstructure.
bool coords_in_shop(mapstruct *map, int x, int y)
Check if the given map coordinates are in a shop.
const char * playerdir
Where the player files are.
#define MAP_ENTER_X(m)
Default X coordinate for map enter.
int8_t strength
The degree of specialisation the shop has in this item, as a percentage from -100 to 100...
#define MAP_DEFAULTRESET
Default time to reset.
#define HUGE_BUF
Used for messages - some can be quite long.
#define MAP_MAXRESET
MAP_MAXRESET is the maximum time a map can have before being reset.
#define SET_MAP_LIGHT(M, X, Y, L)
Sets map light.
object * more
Pointer to the rest of a large body of objects.
sstring add_string(const char *str)
Share a string.
#define MAP_HEIGHT(m)
Map height.
#define FREE_AND_CLEAR_STR_IF(xyz)
object * above
Pointer to the object stacked above this one.
#define MAX_DARKNESS
Maximum map darkness, there is no practical reason to exceed this.
bool ob_move_block(object *ob1, object *ob2)
Basic macro to see if ob2 blocks ob1 from moving onto this space.
unsigned char MoveType
Typdef here to define type large enough to hold bitmask of all movement types.
void make_path_to_file(const char *filename)
Checks if any directories in the given path doesn't exist, and creates if necessary.
int map_light_on(mapstruct *m, int x, int y)
Return the light level at position (X, Y) on map M.
int16_t y
Position in the map for this object.
#define FREE_OBJ_NO_DESTROY_CALLBACK
Do not run the destroy callback.
MoveType move_block
What movement types this blocks.
StringBuffer * stringbuffer_new(void)
Create a new string buffer.
object * next
Pointer to the next object in the free/used list.
#define OUT_OF_REAL_MAP(M, X, Y)
Checks if a square is out of the map.
uint16_t height
Width and height of map.
int64_t level_exp(int level, double expmul)
Returns how much experience is needed for a player to become the given level.
void create_overlay_pathname(const char *name, char *buf, size_t size)
Same as create_pathname(), but for the overlay maps.
int ihypot(int a, int b)
Rough estimate of hypot(a, b).
#define SAVE_MODE_NORMAL
No special handling.
#define PROFILE_END(var, expr)
Global type definitions and header inclusions.
Link an object type with skill needed to identify, and general name.
static int load_overlay_map(const char *filename, mapstruct *m)
Loads an overlay for a map, which has been loaded earlier, from file.
static void create_items_path(const char *s, char *buf, size_t size)
This makes absolute path to the itemfile where unique objects will be saved.
oblinkpt * buttons
Linked list of linked lists of buttons.
void draw_ext_info(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *message)
Sends message to player(s).
const char * map_get_path(const object *item)
Return the map path on which the specified item is.
#define FLAG_REMOVED
Object is not in any map or invenory.
#define MAP_WHEN_RESET(m)
This is when the map will reset.
void events_execute_global_event(int eventcode,...)
Execute a global event.
static void load_unique_objects(mapstruct *m)
Loads unique objects from file(s) into the map which is in memory.
#define FLAG_CAN_ROLL
Object can be rolled.
mapstruct * get_empty_map(int sizex, int sizey)
Creates and returns a map of the specific size.
#define MAP_LAYER_LIVING2
uint32_t is_template
If set, this is a template map.
#define MOVE_ALL
Mask of all movement types.
const Face * blank_face
Following can just as easily be pointers, but it is easier to keep them like this.
sstring blocks_prayer
For update_position() mostly.
Information about a layer.
void free_string(sstring str)
This will reduce the refcount, and if it has reached 0, str will be freed.
#define SAVE_FLAG_SAVE_UNPAID
If set, unpaid items will be saved.
#define MAP_IN_MEMORY
Map is fully loaded.
#define MAP_LAYER_NO_PICK1
Non pickable ground objects.
void object_free(object *ob, int flags)
Frees everything allocated by an object, removes it from the list of used objects, and puts it on the list of free objects.
sstring reset_group
For reset purpose, all maps in the same group reset at the same time.
void save_object_in_sb(StringBuffer *sb, object *op, const int flag)
Store a string representation of op in sb.
#define FLAG_ALIVE
Object can fight (or be fought)
FILE * of_open(OutputFile *of, const char *fname)
Opens an output file.
#define MAP_OVERLAY
Map to load is an overlay.
#define FLAG_OBJ_ORIGINAL
NEVER SET THIS.
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
#define MAP_SWAPPED
Map spaces have been saved to disk.
uint32_t unique
If set, this is a per player unique map.
char * msg
Message map creator may have left.
void update_all_map_los(mapstruct *map)
update all_map_los is like update_all_los() below, but updates everyone on the map, no matter where they are.
#define INS_ON_TOP
Always put object on top.
Defines for loader.l / loader.c.
static void add_face_layer(int low_layer, int high_layer, object *ob, object *layers[], int honor_visibility)
This function is used for things that can have multiple layers - NO_PICK, ITEM, LIVING, FLYING.
object * arch_to_object(archetype *at)
Creates and returns a new object which is a copy of the given archetype.
char path[HUGE_BUF]
Filename of the map.
const char * tmpdir
Directory to use for temporary files.
object * env
Pointer to the object which is the environment.
uint8_t honor_visibility
If 0 then don't reorder items, else allow.
#define QUERY_FLAG(xyz, p)
void clean_tmp_map(mapstruct *m)
Removse the temporary file used by the map.
int blocked_link(object *ob, mapstruct *m, int16_t sx, int16_t sy)
Returns true if the given coordinate is blocked except by the object passed is not blocking...
#define SET_MAP_MOVE_SLOW(M, X, Y, C)
Sets the slowing state of a square.
double shopgreed
How much our shopkeeper overcharges.
#define OB_MOVE_BLOCK(ob1, ob2)
void object_fix_multipart(object *tmp)
Ensures specified object has its more parts correctly inserted in map.
void object_free_drop_inventory(object *ob)
Frees everything allocated by an object, removes it from the list of used objects, and puts it on the list of free objects.
void clean_object(object *op)
Remove and free all objects in the inventory of the given object.
#define MOVE_FLYING
Combo of fly_low and fly_high.
#define FOR_INV_FINISH()
Finishes FOR_INV_PREPARE().
static void link_multipart_objects(mapstruct *m)
Go through all the objects on the map looking for objects whose arch says they are multipart yet acco...
char * name
Shortend name of the region as maps refer to it.
object * head
Points to the main object of a large body.
#define MAP_LAYERS
This correspondes to the map layers in the map2 protocol.
#define SET_MAP_PLAYER(M, X, Y, C)
#define FLAG_BLOCKSVIEW
Object blocks view.
MapSpace * map_space(const mapstruct *m, int x, int y)
int ob_blocked(const object *ob, mapstruct *m, int16_t x, int16_t y)
Returns true if the given object can't fit in the given spot.
int calculate_difficulty(mapstruct *m)
This routine is supposed to find out the difficulty of the map.
int change_map_light(mapstruct *m, int change)
Used to change map light level (darkness) up or down.
int out_of_map(mapstruct *m, int x, int y)
Return 1 if coordinates X and Y are out of the map M, taking into account tiling. ...
#define INS_NO_WALK_ON
Don't call check_walk_on against the originator.
sstring object_get_value(const object *op, const char *const key)
Get an extra value by key.
#define EVENT_MAPREADY
A map is ready, either first load or after reload.
#define GET_MAP_LIGHT(M, X, Y)
Gets map light.
int typenum
Itemtype number we need to match, -1 if it is the default price.
const Face * face
Face with colors.
char * tile_path[4]
Path to adjoining maps.
#define MAP_ENTER_Y(m)
Default Y coordinate for map enter.
int8_t glow_radius
indicates the glow radius of the object
static void delete_unique_items(mapstruct *m)
This goes through map 'm' and removes any unique items on the map.
uint64_t shopmin
Minimum price a shop will trade for.
char * maplore
Map lore information.
int find_dir_2(int x, int y)
Computes a direction which you should travel to move of x and y.
#define FLAG_OVERLAY_FLOOR
Object is an overlay floor.
#define P_OUT_OF_MAP
This space is outside the map.
#define SAVE_ERROR_NO_PATH
Map had no path set.
#define GET_MAP_MOVE_BLOCK(M, X, Y)
Gets the blocking state of a square.
mapstruct * first_map
First map.
struct Settings settings
Global settings.
uint32_t map_size(mapstruct *m)
Calculate map size without intermediate sign extension.
const char * templatedir
Directory for the template map.
#define MAP_DIFFICULTY(m)
object * object_new(void)
Grabs an object from the list of unused objects, makes sure it is initialised, and returns it...
#define SAVE_ERROR_URENAME
Couldn't rename unique temporary file.
char * path_combine_and_normalize(const char *src, const char *dst, char *path, size_t size)
Combines the 2 paths.
#define MAP_SAVING
Map being saved.
#define SET_MAP_MOVE_OFF(M, X, Y, C)
Sets the move_off state of a square.
static void print_shop_string(mapstruct *m, char *output_string, int size)
Opposite of parse string(), this puts the string that was originally fed in to the map (or something ...
#define HEAD(op)
Returns the head part of an object.
#define INS_ABOVE_FLOOR_ONLY
Put object immediatly above the floor.
void fatal(enum fatal_error err)
fatal() is meant to be called whenever a fatal signal is intercepted.
#define FLAG_WIZ
Object has special privilegies.
MapSpace * spaces
Array of spaces on this map.
#define MAP_MINTIMEOUT
At least that many ticks before swapout.
#define SAVE_ERROR_CLOSE
Close error for regular file.
int isqrt(int n)
Compute the square root.
long seconds(void)
Return wall clock time in seconds.
living stats
Str, Con, Dex, etc.
#define MAP_NO_DIFFICULTY
If set then don't compute a map difficulty if it is 0.
#define MAX_BUF
Used for all kinds of things.
#define MSG_TYPE_ATTACK
Attack related messages.
char * shoprace
The preffered race of the local shopkeeper.
void delete_map(mapstruct *m)
Frees the map, including the mapstruct.
size_t strlcpy(char *dst, const char *src, size_t size)
Portable implementation of strlcpy(3).
mapstruct * get_map_from_coord(mapstruct *m, int16_t *x, int16_t *y)
This is basically the same as out_of_map above(), but instead we return NULL if no map is valid (coor...
mapstruct * get_linked_map(void)
Allocates, initialises, and returns a pointer to a mapstruct, linked through first_map.
#define MAP_LAYER_FLY1
Flying objects - creatures, spells.
struct mapstruct * map
Pointer to the map in which this object is present.
void object_remove_from_active_list(object *op)
This function removes object 'op' from the list of active objects.
object * map_find_by_flag(mapstruct *map, int x, int y, int flag)
Finds an object in a map tile by flag number.
Path-related function prototypes.
mapstruct * mapfile_load_lowlevel(const char *map, const char *pathname, int flags)
uint32_t in_memory
Combination of IN_MEMORY_xxx flags.
bool shop_contains(object *ob)
Check if an object is in a shop.
static const flag_definition flags[]
Flag mapping.
#define FOR_MAP_FINISH()
Finishes FOR_MAP_PREPARE().
const char * uniquedir
Directory for the unique items.
#define MAP_LAYER_NO_PICK2
Non pickable ground objects.
#define SAVE_FLAG_NO_REMOVE
If set, objects are not removed while saving.
uint8_t high_layer
Highest layer for this group.
const char * name_pl
Plural name.
#define SAVE_ERROR_UCREATION
Couldn't create the file for unique objects.
#define GET_MAP_FLAGS(M, X, Y)
Gets map flags.
const char * datadir
Read only data files.
int16_t enter_y
Enter_x and enter_y are default entrance coordinates to use for a map such that when an exit specifie...
void set_map_reset_time(mapstruct *map)
Updates the map's timeout.
#define SET_MAP_MOVE_ON(M, X, Y, C)
Sets the move_on state of a square.
#define SET_MAP_FLAGS(M, X, Y, C)
Sets map flags.
const typedata * get_typedata_by_name(const char *name)
mapstruct * tile_map[4]
Adjoining maps.
#define P_NEW_MAP
Coordinates passed result in a new tiled map.
#define FLAG_GENERATOR
Will generate type ob->stats.food.
#define MAP_LAYER_LIVING1
Living creatures.
#define INS_NO_MERGE
Don't try to merge with other items.
region * get_region_by_name(const char *region_name)
Gets a region by name.
static event_registration m
char * create_pathname(const char *name, char *buf, size_t size)
Get the full path to a map file.
This structure contains all information related to one map square.
const char * name
Object name.
int get_rangevector_from_mapcoord(const mapstruct *m, int x, int y, const object *op2, rv_vector *retval)
This is basically the same as get_rangevector() above, but instead of the first parameter being an ob...
long last_reset_time
A timestamp of the last original map loading.
#define NUM_ANIMATIONS(ob)
void map_reset_swap(mapstruct *m)
Call this when an in-memory map is used or referenced.
#define MAP_PLAYER_UNIQUE
This map is player-specific.
const char * localdir
Read/write data files.
MoveType move_type
Type of movement this object uses.
sstring name
The name of the object, obviously...
sstring title
Of foo, etc.
#define MAP_WIDTH(m)
Map width.
const char * name
Name of the item in question, null if it is the default item.
uint8_t visibility
How visible is the face compared to other faces, highest wins.
Only for debugging purposes.
int get_map_flags(mapstruct *oldmap, mapstruct **newmap, int16_t x, int16_t y, int16_t *nx, int16_t *ny)
This rolls up wall, blocks_magic, blocks_view, etc, all into one function that just returns a P_...
uint8_t darkness
Indicates level of darkness of map.
const char * mapdir
Where the map files are.
bool object_value_set_shared(const object *op, sstring key)
Determine if an extra value is set to a non empty or 0 value.
unsigned int distance
Distance, in squares.
void free_objectlinkpt(oblinkpt *obp)
Recursively frees all linked list of objectlink pointers.
int of_close(OutputFile *of)
Closes an output file.
const char *const map_layer_name[MAP_LAYERS]
These correspond to the layer names in map.h - since some of the types can be on multiple layers...
#define CLEAR_FLAG(xyz, p)
uint8_t type
PLAYER, BULLET, etc.
int direction
General direction to the targer.
void decay_objects(mapstruct *m)
Decay and destroy persihable items in a map.
#define SAVE_MODE
If you have defined SAVE_PLAYER, you might want to change this, too.
Functions for creating text output files.
void map_remove_unique_files(const mapstruct *map)
Remove files containing the map's unique items.
Shop-related information for a map.
void apply_auto_fix(mapstruct *m)
Go through the entire map (only the first time when an original map is loaded) and performs special a...
int get_rangevector(object *op1, const object *op2, rv_vector *retval, int flags)
From map.c This is used by get_player to determine where the other creature is.
#define MAP_RESET_TIMEOUT(m)
#define MAP_LOADING
This map is being loaded.
object * inv
Pointer to the first object in the inventory.
char * tmpname
Name of temporary file.
#define GET_MAP_FACE_OBJS(M, X, Y)
Returns the layers array so update_position can just copy the entire array over.
object * objects
Pointer to the list of used objects.
mapstruct * mapfile_load(const char *map, int flags)
Opens the file "filename" and reads information about the map from the given file, and stores it in a newly allocated mapstruct.
void strip_endline(char *buf)
Removes endline from buffer (modified in place).
#define GET_MAP_OB(M, X, Y)
Gets the bottom object on a map.
#define FLAG_MONSTER
Will attack players.
struct region * region
What jurisdiction in the game world this map is ruled by points to the struct containing all the prop...
#define NDI_UNIQUE
Print immediately, don't buffer.
#define EVENT_MAPLOAD
A map is loaded (pristine state)
uint32_t outdoor
True if an outdoor map.
mapstruct * has_been_loaded(const char *name)
Checks whether map has been loaded.
uint8_t flags
Flags about this space (see the P_ values above).
archetype * more
Next part of a linked object.
#define SAVE_ERROR_RCREATION
Couldn't create the regular save file.
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
Constructs a loop iterating over all objects of a map tile.
#define MSG_TYPE_ATTACK_NOKEY
Keys are like attacks, so...
#define P_BLOCKSVIEW
This spot blocks the player's view.
#define P_NO_ERROR
Purely temporary - if set, update_position does not complain if the flags are different.
A buffer that will be expanded as content is added to it.
struct shopitems * shopitems
List of item-types the map's shop will trade in.
uint16_t difficulty
What level the player should be to play here.
static void free_all_objects(mapstruct *m)
Remove and free all objects in the given map.
void set_darkness_map(mapstruct *m)
Set the darkness level for a map, based on the time of the day.
static void fix_container_multipart(object *container)
Go through all the objects in a container (recursively) looking for objects whose arch says they are ...
#define MAP_LAYER_FLY2
Arrows, etc.
#define P_IS_ALIVE
Something alive is on this space.
mapstruct * next
Next map, linked list.
object * object_insert_in_map_at(object *op, mapstruct *m, object *originator, int flag, int x, int y)
Same as object_insert_in_map() except it handle separate coordinates and do a clean job preparing mul...
static mapstruct * load_and_link_tiled_map(mapstruct *orig_map, int tile_num)
This updates the orig_map->tile_map[tile_num] value after loading the map.
uint32_t fixed_resettime
If true, reset time is not affected by players entering/exiting map.
#define FREE_AND_CLEAR(xyz)
Free the pointer and then set it to NULL.
#define FLAG_UNIQUE
Item is really unique (UNIQUE_ITEMS)
#define FLAG_NO_PICK
Object can't be picked up.
mapstruct * ready_map_name(const char *name, int flags)
Makes sure the given map is loaded and swapped in.
#define SET_MAP_MOVE_BLOCK(M, X, Y, C)
Sets the blocking state of a square.
void void ext_info_map(int color, const mapstruct *map, uint8_t type, uint8_t subtype, const char *str1)
Writes to everyone on the specified map.
int32_t timeout
Swapout is set to this.
void load_objects(mapstruct *m, FILE *fp, int mapflags)
Loads (and parses) the objects into a given map from the specified file pointer.
object clone
An object from which to do object_copy()
#define SAVE_MODE_OVERLAY
Map is persisted as an overlay.
#define P_NO_CLERIC
No clerical spells cast here.
uint32_t nosmooth
If set the content of this map has smoothlevel=0 forced.
#define FOR_INV_PREPARE(op_, it_)
Constructs a loop iterating over the inventory of an object.
char * name
Name of map as given by its creator.
static shopitems * parse_shop_string(const char *input_string, const mapstruct *map)
Takes a string from a map definition and outputs a pointer to the array of shopitems corresponding to...
#define INS_MAP_LOAD
Disable lots of checkings.