 |
Crossfire Server, Trunk
1.75.0
|
Go to the documentation of this file.
47 "floor",
"no_pick",
"no_pick",
"item",
"item",
48 "item",
"living",
"living",
"fly",
"fly"
174 snprintf(
t,
buf+size-
t,
"%s", s);
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)
252 if (
m->maplore != NULL)
255 if (
m->tmpname != NULL)
362 LOG(
llevError,
"blocked_link: Passed map, x, y coordinates outside of map\n");
370 mflags =
m->spaces[sx+
m->width*sy].flags;
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);
649 LOG(
llevError,
" object %s not on valid map position %s:%d:%d\n", op->
name ? op->
name :
"(null)",
m->path, op->
x, op->
y);
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);
809 return (uint32_t)
m->width * (uint32_t)
m->height;
829 LOG(
llevError,
"allocate_map called with already allocated map (%s)\n",
m->path);
835 if (
m->spaces == NULL)
875 char *shop_string, *p, *q, *next_semicolon, *next_colon;
877 int i = 0, number_of_entries = 0;
901 for (i = 0; i < number_of_entries; i++) {
903 LOG(
llevError,
"parse_shop_string: I seem to have run out of string, that shouldn't happen.\n");
906 next_semicolon = strchr(p,
';');
907 next_colon = strchr(p,
':');
909 if (next_colon && (!next_semicolon || next_colon < next_semicolon))
910 items[i].
strength = atoi(strchr(p,
':')+1);
912 if (isdigit(*p) || *p ==
'*') {
913 items[i].
typenum = *p ==
'*' ? -1 : atoi(p);
920 q = strpbrk(p,
";:");
932 LOG(
llevError,
"invalid type %s defined in shopitems for %s in string %s\n", p, map->
name, input_string);
935 items[i].
index = number_of_entries;
937 p = ++next_semicolon;
960 output_string[0] =
'\0';
961 for (i = 0; i <
m->shopitems[0].index; i++) {
962 if (
m->shopitems[i].typenum != -1) {
963 if (
m->shopitems[i].strength) {
964 snprintf(tmp,
sizeof(tmp),
"%s:%d;",
m->shopitems[i].name,
m->shopitems[i].strength);
966 snprintf(tmp,
sizeof(tmp),
"%s;",
m->shopitems[i].name);
968 if (
m->shopitems[i].strength) {
969 snprintf(tmp,
sizeof(tmp),
"*:%d;",
m->shopitems[i].strength);
971 snprintf(tmp,
sizeof(tmp),
"*;");
973 snprintf(output_string+strlen(output_string), size-strlen(output_string),
"%s", tmp);
977 if (strlen(output_string) > 0) {
978 output_string[strlen(output_string) - 1] =
'\0';
1001 m->width =
m->height = 0;
1002 while (fgets(
buf,
sizeof(
buf), fp) != NULL) {
1005 p = strchr(
buf,
'\n');
1007 LOG(
llevError,
"Error loading map header - did not find a newline - perhaps file is truncated? Buf=%s\n",
buf);
1013 while (isspace(*key))
1017 value = strchr(key,
' ');
1021 while (isspace(*value)) {
1023 if (*value ==
'\0') {
1046 if (!strcmp(key,
"msg")) {
1050 while (fgets(
buf,
sizeof(
buf), fp) != NULL) {
1051 if (!strcmp(
buf,
"endmsg\n"))
1055 msgpos += strlen(
buf);
1068 }
else if (!strcmp(key,
"maplore")) {
1070 size_t maplorepos = 0;
1073 if (!strcmp(
buf,
"endmaplore\n"))
1076 if (maplorepos >=
sizeof(maplorebuf)) {
1080 snprintf(maplorebuf+maplorepos,
sizeof(maplorebuf)-maplorepos,
"%s",
buf);
1081 maplorepos += strlen(
buf);
1084 if (maplorepos != 0)
1086 }
else if (!strcmp(key,
"end")) {
1088 }
else if (value == NULL) {
1089 LOG(
llevError,
"Got '%s' line without parameter in map header\n", key);
1090 }
else if (!strcmp(key,
"arch")) {
1092 if (strcmp(value,
"map")) {
1093 LOG(
llevError,
"load_map_header: expected 'arch map': check line endings?\n");
1096 }
else if (!strcmp(key,
"name")) {
1104 }
else if (!strcmp(key,
"enter_x")) {
1105 m->enter_x = atoi(value);
1106 }
else if (!strcmp(key,
"enter_y")) {
1107 m->enter_y = atoi(value);
1108 }
else if (!strcmp(key,
"width")) {
1109 m->width = atoi(value);
1110 }
else if (!strcmp(key,
"height")) {
1111 m->height = atoi(value);
1112 }
else if (!strcmp(key,
"reset_timeout")) {
1113 m->reset_timeout = atoi(value);
1114 }
else if (!strcmp(key,
"swap_time")) {
1116 }
else if (!strcmp(key,
"difficulty")) {
1117 m->difficulty = atoi(value);
1118 }
else if (!strcmp(key,
"darkness")) {
1119 m->darkness = atoi(value);
1120 }
else if (!strcmp(key,
"fixed_resettime")) {
1121 m->fixed_resettime = atoi(value);
1122 }
else if (!strcmp(key,
"unique")) {
1123 m->unique = atoi(value);
1124 }
else if (!strcmp(key,
"template")) {
1125 m->is_template = atoi(value);
1126 }
else if (!strcmp(key,
"region")) {
1128 }
else if (!strcmp(key,
"shopitems")) {
1130 }
else if (!strcmp(key,
"shopgreed")) {
1131 m->shopgreed = atof(value);
1132 }
else if (!strcmp(key,
"shopmin")) {
1133 m->shopmin = atol(value);
1134 }
else if (!strcmp(key,
"shopmax")) {
1135 m->shopmax = atol(value);
1136 }
else if (!strcmp(key,
"shoprace")) {
1138 }
else if (!strcmp(key,
"outdoor")) {
1139 m->outdoor = atoi(value);
1140 }
else if (!strcmp(key,
"nosmooth")) {
1141 m->nosmooth = atoi(value);
1142 }
else if (!strcmp(key,
"first_load")) {
1143 m->last_reset_time = atoi(value);
1144 }
else if (!strncmp(key,
"tile_path_", 10)) {
1145 int tile = atoi(key+10);
1147 if (tile < 1 || tile > 4) {
1148 LOG(
llevError,
"load_map_header: tile location %d out of bounds (%s)\n", tile,
m->path);
1150 if (
m->tile_path[tile-1]) {
1151 LOG(
llevError,
"load_map_header: tile location %d duplicated (%s)\n", tile,
m->path);
1152 free(
m->tile_path[tile-1]);
1156 }
else if (!strcmp(key,
"background_music")) {
1158 }
else if (!strcmp(key,
"reset_group")) {
1161 LOG(
llevError,
"Got unknown value in map header: %s %s\n", key, value);
1164 if ((
m->width == 0) || (
m->height == 0)) {
1168 if (!key || strcmp(key,
"end")) {
1187 if ((fp = fopen(pathname,
"r")) == NULL) {
1189 "Can't open %s: %s\n", pathname, strerror(errno));
1248 LOG(
llevDebug,
"mapfile_load on %s" " took %ld us\n", map, diff));
1266 LOG(
llevError,
"No temporary filename for map %s\n",
m->path);
1270 if ((fp = fopen(
m->tmpname,
"r")) == NULL) {
1271 LOG(
llevError,
"Cannot open %s: %s\n",
m->tmpname, strerror(errno));
1276 LOG(
llevError,
"Error loading map header for %s (%s)\n",
m->path,
m->tmpname);
1304 if ((fp = fopen(pathname,
"r")) == NULL) {
1310 LOG(
llevError,
"Error loading map header for overlay %s (%s)\n",
m->path, pathname);
1334 int i, j, unique = 0;
1364 for (count = 0; count < 10; count++) {
1365 snprintf(firstname,
sizeof(firstname),
"%s.v%02d",
name, count);
1366 if (!access(firstname, R_OK))
1373 if ((fp = fopen(firstname,
"r")) == NULL) {
1382 if (
m->tmpname == NULL)
1411 if (flag && !*
m->path) {
1419 if (!
m->unique && !
m->is_template) {
1425 if (
m->path[0] !=
'~') {
1427 "Cannot save unique map '%s' outside of LOCALDIR. Check "
1428 "that all exits to '%s' have FLAG_UNIQUE set correctly.\n",
1439 strlcpy(filename,
m->tmpname,
sizeof(filename));
1448 fprintf(fp,
"arch map\n");
1450 fprintf(fp,
"name %s\n",
m->name);
1451 if (
m->reset_timeout)
1452 fprintf(fp,
"reset_timeout %u\n",
m->reset_timeout);
1453 if (
m->fixed_resettime)
1454 fprintf(fp,
"fixed_resettime %d\n",
m->fixed_resettime);
1459 fprintf(fp,
"difficulty %d\n",
m->difficulty);
1461 fprintf(fp,
"region %s\n",
m->region->name);
1464 fprintf(fp,
"shopitems %s\n", shop);
1467 fprintf(fp,
"shopgreed %f\n",
m->shopgreed);
1469 fprintf(fp,
"shopmin %" FMT64U "\n",
m->shopmin);
1471 fprintf(fp,
"shopmax %" FMT64U "\n",
m->shopmax);
1473 fprintf(fp,
"shoprace %s\n",
m->shoprace);
1475 fprintf(fp,
"darkness %d\n",
m->darkness);
1477 fprintf(fp,
"width %d\n",
m->width);
1479 fprintf(fp,
"height %d\n",
m->height);
1481 fprintf(fp,
"enter_x %d\n",
m->enter_x);
1483 fprintf(fp,
"enter_y %d\n",
m->enter_y);
1485 fprintf(fp,
"msg\n%sendmsg\n",
m->msg);
1487 fprintf(fp,
"maplore\n%sendmaplore\n",
m->maplore);
1489 fprintf(fp,
"unique %d\n",
m->unique);
1491 fprintf(fp,
"template %d\n",
m->is_template);
1493 fprintf(fp,
"outdoor %d\n",
m->outdoor);
1495 fprintf(fp,
"nosmooth %d\n",
m->nosmooth);
1496 if (
m->last_reset_time)
1497 fprintf(fp,
"first_load %ld\n",
m->last_reset_time);
1498 if (
m->background_music)
1499 fprintf(fp,
"background_music %s\n",
m->background_music);
1501 fprintf(fp,
"reset_group %s\n",
m->reset_group);
1505 for (i = 0; i < 4; i++)
1506 if (
m->tile_path[i])
1507 fprintf(fp,
"tile_path_%d %s\n", i+1,
m->tile_path[i]);
1509 fprintf(fp,
"end\n");
1520 snprintf(final_unique,
sizeof(final_unique),
"%s.v00",
name);
1521 fp2 =
of_open(&of2, final_unique);
1530 LOG(
llevError,
"Save error during object save: %d\n", res);
1539 LOG(
llevError,
"Save error during object save: %d\n", res);
1546 if (ftell(fp2) == 0) {
1552 unlink(final_unique);
1559 if (chmod(final_unique,
SAVE_MODE) != 0) {
1567 LOG(
llevError,
"Save error during object save: %d\n", res);
1578 LOG(
llevError,
"Could not set permissions on '%s'\n", filename);
1582 LOG(
llevDebug,
"save_map on %s" " took %ld us\n",
m->path, diff));
1619 object *previous_obj = NULL;
1622 if (op == previous_obj) {
1623 LOG(
llevDebug,
"free_all_objects: Link error, bailing out.\n");
1645 LOG(
llevError,
"free_all_objects: object %s still on map after it should have been freed\n", op->
name);
1663 if (!
m->in_memory) {
1684 if (
m->background_music)
1689 for (i = 0; i < 4; i++) {
1690 if (
m->tile_path[i])
1692 m->tile_map[i] = NULL;
1736 for (i = 0; i < 4; i++)
1749 LOG(
llevError,
"delete_map: Unable to find map %s in list\n",
m->path);
1751 last->
next =
m->next;
1797 snprintf(buf2,
sizeof(buf2),
"~%s",
name+strlen(
buf)+1);
1802 if (
name[0] ==
'~') {
1822 if (
m == NULL)
return NULL;
1880 if (
m->last_reset_time == 0) {
1892 if (op->animation) {
1894 op->facing = facings > 1 ? 1 + (
cf_random() % facings) : 1;
1895 op->direction = op->facing;
1897 op->state = max_state > 1 ?
cf_random() % max_state : 0;
1931 int64_t exp_pr_sq, total_exp = 0;
1941 total_exp += op->stats.exp;
1943 total_exp += op->stats.exp;
1946 at = op->other_arch ? op->other_arch : NULL;
1950 int lim = atoi(val ? val :
"0");
1952 if (!lim || lim >= 16)
1968 for (i = 1; i < 25; i++)
1984 if (
m->tmpname == NULL)
1986 (void)unlink(
m->tmpname);
2004 LOG(
llevDebug,
"free_all_maps: Freed %d maps\n", real_maps);
2025 int new_level =
m->darkness+change;
2029 || (new_level <= 0 && m->darkness == 0)
2050 m->darkness = new_level;
2079 static inline void add_face_layer(
int low_layer,
int high_layer,
object *ob,
object *layers[],
int honor_visibility) {
2083 for (l = low_layer; l <= high_layer; l++) {
2089 if (!honor_visibility)
2096 for (l1 = (l-1); l1 >= low_layer; l1--) {
2099 layers[l1+1] = layers[l1];
2109 if (!honor_visibility) {
2113 for (l = low_layer; l < high_layer; l++)
2114 layers[l] = layers[l+1];
2115 layers[high_layer] = ob;
2125 for (l = high_layer; l >= low_layer; l--) {
2127 for (l1 = low_layer; l1 < l; l1++)
2128 layers[l1] = layers[l1+1];
2150 uint8_t
flags = 0, oldflags, light = 0;
2153 MoveType move_block = 0, move_slow = 0, move_on = 0, move_off = 0, move_allow = 0;
2157 LOG(
llevDebug,
"update_position called with P_NEED_UPDATE not set: %s (%d, %d)\n",
m->path, x, y);
2161 memset(layers, 0,
MAP_LAYERS*
sizeof(
object *));
2176 if (tmp->glow_radius > light)
2177 light = tmp->glow_radius;
2183 if (!tmp->invisible && tmp->face !=
blank_face) {
2184 if (tmp->map_layer) {
2195 memset(layers+1, 0, (
MAP_LAYERS-1)*
sizeof(
object *));
2206 if (tmp == tmp->above) {
2211 move_slow |= tmp->move_slow;
2212 move_block |= tmp->move_block;
2213 move_on |= tmp->move_on;
2214 move_off |= tmp->move_off;
2215 move_allow |= tmp->move_allow;
2237 LOG(
llevDebug,
"update_position: updated flags do not match old flags: %s (x=%d,y=%d) %x != %x\n",
2290 int dest_tile = (tile_num+2)%4;
2296 if (orig_map->
tile_map[tile_num] == NULL) {
2308 return orig_map->
tile_map[tile_num];
2325 int16_t xp = x, yp = y;
2358 if ( !
m )
return NULL;
2378 if (!
m->tile_path[3])
2383 if (!
m->tile_map[3])
2390 if (!
m->tile_path[1])
2395 if (!
m->tile_map[1])
2404 if (!
m->tile_path[0])
2409 if (!
m->tile_map[0])
2416 if (!
m->tile_path[2])
2421 if (!
m->tile_map[2])
2453 }
else if (map1->
tile_map[0] == map2) {
2456 }
else if (map1->
tile_map[1] == map2) {
2459 }
else if (map1->
tile_map[2] == map2) {
2462 }
else if (map1->
tile_map[3] == map2) {
2530 retval->
part = NULL;
2551 for (tmp = op1->
more; tmp != NULL; tmp = tmp->
more) {
2554 if (tmpi < best_distance) {
2555 best_distance = tmpi;
2564 retval->
part = best;
2598 retval->
part = NULL;
2604 retval->
part = NULL;
2670 char base[
HUGE_BUF], path[
sizeof(base) + 4];
2675 if (unlink(path) != 0) {
2676 LOG(
llevError,
"Could not delete %s: %s\n", path, strerror(errno));
2683 for (count = 0; count < 10; count++) {
2684 snprintf(path,
sizeof(path),
"%s.v%02d", base, count);
2695 if (item->
map != NULL) {
2696 if (strlen(item->
map->
path) > 0) {
2700 return item->
map->
name ? item->
map->
name :
"(empty path and name)";
2703 if (item->
env != NULL)
2706 return "(no map and no env!)";
2715 return path != NULL && path[0] ==
'~';
2719 if (
m->spaces == NULL)
2723 return &
m->spaces[x +
m->width * y];
2739 if (real ==
nullptr)
2746 if (
ihypot(i - x, j - y) < light)
2765 if (!ob->
map)
return 0;
char * tile_path[4]
Path to adjoining maps.
#define GET_MAP_OB(M, X, Y)
Gets the bottom object on a map.
int8_t strength
The degree of specialisation the shop has in this item, as a percentage from -100 to 100.
object * object_get_owner(object *op)
Returns the object which this object marks as being the owner.
const char * mapdir
Where the map files are.
#define FREE_AND_CLEAR_STR_IF(xyz)
#define FREE_OBJ_NO_DESTROY_CALLBACK
Do not run the destroy callback.
struct Settings settings
Global settings.
#define INS_NO_WALK_ON
Don't call check_walk_on against the originator.
#define FOR_MAP_FINISH()
Finishes FOR_MAP_PREPARE().
#define SAVE_MODE
If you have defined SAVE_PLAYER, you might want to change this, too.
#define MAP_SAVING
Map being saved.
@ llevError
Error, serious thing.
#define MAP_NO_DIFFICULTY
If set then don't compute a map difficulty if it is 0.
#define MOVE_ALL
Mask of all movement types.
#define EVENT_MAPUNLOAD
A map is freed (includes swapping out)
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
mapstruct * get_empty_map(int sizex, int sizey)
Creates and returns a map of the specific size.
#define FLAG_OVERLAY_FLOOR
Object is an overlay floor.
int of_close(OutputFile *of)
Closes an output file.
archetype * more
Next part of a linked object.
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.
region * get_region_by_name(const char *region_name)
Gets a region by name.
FILE * of_open(OutputFile *of, const char *fname)
Opens an output file.
#define FLAG_GENERATOR
Will generate type ob->stats.food.
#define MAP_RESET_TIMEOUT(m)
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.
object * inv
Pointer to the first object in the inventory.
#define SAVE_FLAG_NO_REMOVE
If set, objects are not removed while saving.
static void delete_unique_items(mapstruct *m)
This goes through map 'm' and removes any unique items on the map.
mapstruct * ready_map_name(const char *name, int flags)
Makes sure the given map is loaded and swapped in.
#define QUERY_FLAG(xyz, p)
static int load_temporary_map(mapstruct *m)
Loads a map, which has been loaded earlier, from file.
bool ob_move_block(object *ob1, object *ob2)
Basic macro to see if ob2 blocks ob1 from moving onto this space.
mapstruct * has_been_loaded(const char *name)
Checks whether map has been loaded.
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 ...
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,...
int map_light_on(mapstruct *m, int x, int y)
Return the light level at position (X, Y) on map M.
const char * datadir
Read only data files.
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,...
struct archetype * arch
Pointer to archetype.
StringBuffer * stringbuffer_new(void)
Create a new string buffer.
#define FLAG_UNIQUE
Item is really unique (UNIQUE_ITEMS)
#define FLAG_OBJ_ORIGINAL
NEVER SET THIS.
struct mapstruct * map
Pointer to the map in which this object is present.
unsigned char MoveType
Typdef here to define type large enough to hold bitmask of all movement types.
int index
Being the size of the shopitems array.
#define SET_MAP_MOVE_ON(M, X, Y, C)
Sets the move_on state of a square.
void map_path(const char *map, int flags, char *pathname, size_t bufsize)
static const Map_Layer_Info map_layer_info[MAP_LAYERS]
the ob->map_layer holds the low layer.
static const flag_definition flags[]
Flag mapping.
const char * name
Object name.
void clean_object(object *op)
Remove and free all objects in the inventory of the given object.
#define MAP_PLAYER_UNIQUE
This map is player-specific.
int load_object(FILE *fp, object *op, int bufstate, int map_flags, bool artifact_init)
Loads an object from the given file-pointer.
#define PROFILE_BEGIN(expr)
#define MAP_OVERLAY
Map to load is an overlay.
const char * name_pl
Plural name.
void dump_map(const mapstruct *m)
Prints out debug-information about a map.
#define FLAG_NO_MAGIC
Spells (some) can't pass this object.
const Face * blank_face
Following can just as easily be pointers, but it is easier to keep them like this.
#define P_NO_MAGIC
Spells (some) can't pass this object.
@ TRANSPORT
see doc/Developers/objects
#define FLAG_BLOCKSVIEW
Object blocks view.
object * part
Part we found.
sstring title
Of foo, etc.
char path[HUGE_BUF]
Filename of the map.
#define GET_MAP_FACE_OBJS(M, X, Y)
Returns the layers array so update_position can just copy the entire array over.
#define P_IS_ALIVE
Something alive is on this space.
#define MSG_TYPE_MISC
Messages that don't go elsewhere.
void free_all_maps(void)
Frees all allocated maps.
object * above
Pointer to the object stacked above this one.
#define HUGE_BUF
Used for messages - some can be quite long.
int ihypot(int a, int b)
Rough estimate of hypot(a, b).
#define MAP_LAYER_ITEM1
Items that can be picked up.
uint8_t honor_visibility
If 0 then don't reorder items, else allow.
#define FLAG_NO_PICK
Object can't be picked up.
Plugin animator file specs[Config] name
#define MAP_STYLE
Active objects shouldn't be put on active list.
#define FLAG_IS_FLOOR
Can't see what's underneath this object.
#define SAVE_MODE_OVERLAY
Map is persisted as an overlay.
#define FLAG_ALIVE
Object can fight (or be fought)
#define INS_ABOVE_FLOOR_ONLY
Put object immediatly above the floor.
void map_remove_unique_files(const mapstruct *map)
Remove files containing the map's unique items.
Link an object type with skill needed to identify, and general name.
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 PROFILE_END(var, expr)
int16_t y
Position in the map for this object.
static event_registration m
void set_darkness_map(mapstruct *m)
Set the darkness level for a map, based on the time of the day.
#define MAP_IN_MEMORY
Map is fully loaded.
char * stringbuffer_finish(StringBuffer *sb)
Deallocate the string buffer instance and return the string.
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...
#define MAP_LAYER_NO_PICK2
Non pickable ground objects.
#define MAP_DIFFICULTY(m)
void object_free_drop_inventory(object *ob)
Frees everything allocated by an object, removes it from the list of used objects,...
#define MAP_MINTIMEOUT
At least that many ticks before swapout.
uint32_t map_size(mapstruct *m)
Calculate map size without intermediate sign extension.
#define P_NEW_MAP
Coordinates passed result in a new tiled map.
#define SAVE_ERROR_CLOSE
Close error for regular file.
bool object_value_set_shared(const object *op, sstring key)
Determine if an extra value is set to a non empty or 0 value.
void of_cancel(OutputFile *of)
Cancels a save process.
const typedata * get_typedata(int itemtype)
#define P_NO_ERROR
Purely temporary - if set, update_position does not complain if the flags are different.
#define MSG_TYPE_ATTACK_NOKEY
Keys are like attacks, so...
#define MOVE_WALK
Object walks.
char * path_combine_and_normalize(const char *src, const char *dst, char *path, size_t size)
Combines the 2 paths.
static void load_unique_objects(mapstruct *m)
Loads unique objects from file(s) into the map which is in memory.
object clone
An object from which to do object_copy()
sstring add_string(const char *str)
This will add 'str' to the hash table.
mapstruct * first_map
First map.
#define HEAD(op)
Returns the head part of an object.
void clean_tmp_map(mapstruct *m)
Removse the temporary file used by the map.
#define SAVE_ERROR_RCREATION
Couldn't create the regular save file.
#define MAP_WHEN_RESET(m)
This is when the map will reset.
int change_map_light(mapstruct *m, int change)
Used to change map light level (darkness) up or down.
MoveType move_type
Type of movement this object uses.
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.
mapstruct * mapfile_load_lowlevel(const char *map, const char *pathname, int flags)
const Face * face
Face with colors.
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 MAX_DARKNESS
Maximum map darkness, there is no practical reason to exceed this.
#define MSG_TYPE_ATTACK
Attack related messages.
int isqrt(int n)
Compute the square root.
#define MOVE_FLYING
Combo of fly_low and fly_high.
uint8_t type
PLAYER, BULLET, etc.
#define INS_NO_MERGE
Don't try to merge with other items.
#define FLAG_DAMNED
The object is very cursed.
in that case they will be relative to whatever the PWD of the crossfire server process is You probably shouldn t
#define SET_MAP_FLAGS(M, X, Y, C)
Sets map flags.
#define MAP_LAYER_LIVING1
Living creatures.
const char * name_pl
Plural name.
#define MAP_LAYER_FLY1
Flying objects - creatures, spells.
void object_free(object *ob, int flags)
Frees everything allocated by an object, removes it from the list of used objects,...
#define GET_MAP_MOVE_BLOCK(M, X, Y)
Gets the blocking state of a square.
#define FOR_INV_FINISH()
Finishes FOR_INV_PREPARE().
#define MAP_DEFAULTRESET
Default time to reset.
#define FLAG_CAN_ROLL
Object can be rolled.
void free_map(mapstruct *m)
Frees everything allocated by the given mapstructure.
int64_t level_exp(int level, double expmul)
Returns how much experience is needed for a player to become the given level.
static void free_all_objects(mapstruct *m)
Remove and free all objects in the given map.
The archetype structure is a set of rules on how to generate and manipulate objects which point to ar...
#define P_PLAYER
There is a player on this space.
#define GET_MAP_LIGHT(M, X, Y)
Gets map light.
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...
This structure contains all information related to one map square.
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...
object * map_find_by_flag(mapstruct *map, int x, int y, int flag)
Finds an object in a map tile by flag number.
void delete_map(mapstruct *m)
Frees the map, including the mapstruct.
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.
#define SAVE_ERROR_NO_PATH
Map had no path set.
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...
long last_reset_time
A timestamp of the last original map loading.
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...
#define FLAG_MONSTER
Will attack players.
const typedata * get_typedata_by_name(const char *name)
void fatal(enum fatal_error err)
fatal() is meant to be called whenever a fatal signal is intercepted.
mapstruct * get_linked_map(void)
Allocates, initialises, and returns a pointer to a mapstruct, linked through first_map.
long seconds(void)
Return wall clock time in seconds.
#define MAP_WIDTH(m)
Map width.
void create_template_pathname(const char *name, char *buf, size_t size)
same as create_pathname(), but for the template maps.
#define P_OUT_OF_MAP
This space is outside the map.
#define MAX_BUF
Used for all kinds of things.
#define INS_ON_TOP
Always put object on top.
#define EVENT_MAPREADY
A map is ready, either first load or after reload.
size_t strlcpy(char *dst, const char *src, size_t size)
Portable implementation of strlcpy(3).
MapSpace * map_space(const mapstruct *m, int x, int y)
object * object_new(void)
Grabs an object from the list of unused objects, makes sure it is initialised, and returns it.
void create_overlay_pathname(const char *name, char *buf, size_t size)
Same as create_pathname(), but for the overlay maps.
#define OB_MOVE_BLOCK(ob1, ob2)
int typenum
Itemtype number we need to match, -1 if it is the default price.
object * head
Points to the main object of a large body.
void set_map_reset_time(mapstruct *map)
Updates the map's timeout.
void free_string(sstring str)
This will reduce the refcount, and if it has reached 0, str will be freed.
#define SAVE_MODE_NORMAL
No special handling.
const char * playerdir
Where the player files are.
#define SAVE_ERROR_UCREATION
Couldn't create the file for unique objects.
A buffer that will be expanded as content is added to it.
#define SET_MAP_MOVE_SLOW(M, X, Y, C)
Sets the slowing state of a square.
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
Constructs a loop iterating over all objects of a map tile.
#define OUT_OF_REAL_MAP(M, X, Y)
Checks if a square is out of the map.
int find_dir_2(int x, int y)
Computes a direction which you should travel to move of x and y.
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.
#define FLAG_REMOVED
Object is not in any map or invenory.
#define MAP_LAYER_NO_PICK1
Non pickable ground objects.
#define INS_MAP_LOAD
Disable lots of checkings.
#define FLAG_WIZ
Object has special privilegies.
void decay_objects(mapstruct *m)
Decay and destroy persihable items in a map.
#define NDI_UNIQUE
Print immediately, don't buffer.
sstring name
The name of the object, obviously...
Information about a layer.
static int load_map_header(FILE *fp, mapstruct *m)
This loads the header information of the map.
#define FREE_AND_CLEAR(xyz)
Free the pointer and then set it to NULL.
const char * name
Name of the item in question, null if it is the default item.
uint8_t high_layer
Highest layer for this group.
static int adjacent_map(const mapstruct *map1, const mapstruct *map2, int *dx, int *dy)
Return whether map2 is adjacent to map1.
uint8_t visibility
How visible is the face compared to other faces, highest wins.
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_.
#define P_NEED_UPDATE
This space is out of date.
object * env
Pointer to the object which is the environment.
char * create_pathname(const char *name, char *buf, size_t size)
Get the full path to a map file.
Magical Runes Runes are magical inscriptions on the dungeon floor
static char msgbuf[HUGE_BUF]
uint8_t flags
Flags about this space (see the P_ values above).
void animate_object(object *op, int dir)
Updates the face-variable of an object.
char * name
Name of map as given by its creator.
bool shop_contains(object *ob)
Check if an object is in a shop.
uint32_t in_memory
Combination of IN_MEMORY_xxx flags.
This is used by get_rangevector to determine where the other creature is.
#define MAP_SWAPPED
Map spaces have been saved to disk.
object * objects
Pointer to the list of used objects.
Shop-related information for a map.
sstring object_get_value(const object *op, const char *const key)
Get an extra value by key.
const char * map_get_path(const object *item)
Return the map path on which the specified item is.
#define SET_MAP_MOVE_BLOCK(M, X, Y, C)
Sets the blocking state of a square.
int on_same_map(const object *op1, const object *op2)
Checks whether 2 objects are on the same map or not.
#define CLEAR_FLAG(xyz, p)
bool map_path_unique(const char *path)
Return true if the given map path leads to a unique map.
#define MAP_HEIGHT(m)
Map height.
void save_object_in_sb(StringBuffer *sb, object *op, const int flag)
Store a string representation of op in sb.
#define NUM_ANIMATIONS(ob)
#define MAP_ENTER_Y(m)
Default Y coordinate for map enter.
#define SAVE_ERROR_URENAME
Couldn't rename unique temporary file.
void strip_endline(char *buf)
Removes endline from buffer (modified in place).
mapstruct * tile_map[4]
Adjoining maps.
void object_remove_from_active_list(object *op)
This function removes object 'op' from the list of active objects.
object * arch_to_object(archetype *at)
Creates and returns a new object which is a copy of the given archetype.
MapSpace * spaces
Array of spaces on this map.
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.
void update_all_map_los(mapstruct *map)
update all_map_los is like update_all_los() below, but updates everyone on the map,...
void allocate_map(mapstruct *m)
This basically allocates the dynamic array of spaces for the map.
#define MAP_LAYER_FLY2
Arrows, etc.
#define SAVE_ERROR_OK
No error.
void object_fix_multipart(object *tmp)
Ensures specified object has its more parts correctly inserted in map.
static void fix_container_multipart(object *container)
Go through all the objects in a container (recursively) looking for objects whose arch says they are ...
void free_objectlinkpt(oblinkpt *obp)
Recursively frees all linked list of objectlink pointers.
#define MAP_ENTER_X(m)
Default X coordinate for map enter.
const char * templatedir
Directory for the template map.
void object_remove(object *op)
This function removes the object op from the linked list of objects which it is currently tied to.
#define MAP_FLUSH
Always load map from the map directory, and don't do unique items or the like.
#define GET_MAP_FLAGS(M, X, Y)
Gets map flags.
signed long object_sum_weight(object *op)
object_sum_weight() is a recursive function which calculates the weight an object is carrying.
#define FLAG_UNPAID
Object hasn't been paid for yet.
#define EVENT_MAPLOAD
A map is loaded (pristine state)
#define MAP_LAYER_LIVING2
#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...
#define P_NO_CLERIC
No clerical spells cast here.
void make_path_to_file(const char *filename)
Checks if any directories in the given path doesn't exist, and creates if necessary.
uint32_t unique
If set, this is a per player unique map.
int save_map(mapstruct *m, int flag)
Saves a map to file.
int calculate_difficulty(mapstruct *m)
This routine is supposed to find out the difficulty of the map.
#define FLAG_IS_LINKED
The object is linked with other objects.
mapstruct * next
Next map, linked list.
living stats
Str, Con, Dex, etc.
object * more
Pointer to the rest of a large body of objects.
#define SET_MAP_PLAYER(M, X, Y, C)
sstring blocks_prayer
For update_position() mostly.
const char * tmpdir
Directory to use for temporary files.
mapstruct * mapfile_load(const char *map, int flags)
Opens the file "filename" and reads information about the map from the given file,...
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 MAP_MAXRESET
MAP_MAXRESET is the maximum time a map can have before being reset.
#define SAVE_FLAG_SAVE_UNPAID
If set, unpaid items will be saved.
int direction
General direction to the targer.
#define SET_MAP_LIGHT(M, X, Y, L)
Sets map light.
unsigned int distance
Distance, in squares.
void map_reset_swap(mapstruct *m)
Call this when an in-memory map is used or referenced.
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 MAP_LOADING
This map is being loaded.
MoveType move_block
What movement types this blocks.
object * next
Pointer to the next object in the free/used list.
static int load_overlay_map(const char *filename, mapstruct *m)
Loads an overlay for a map, which has been loaded earlier, from file.
#define FOR_INV_PREPARE(op_, it_)
Constructs a loop iterating over the inventory of an object.
int check_path(const char *name, int prepend_dir)
This function checks if a file with the given path exists.
#define MAX_LIGHT_RADII
Max radii for 'light' object, really large values allow objects that can slow down the game.
void dump_all_maps(void)
Prints out debug-information about all maps.
void events_execute_global_event(int eventcode,...)
Execute a global event.
void load_objects(mapstruct *m, FILE *fp, int mapflags)
Loads (and parses) the objects into a given map from the specified file pointer.
@ llevDebug
Only for debugging purposes.
#define P_BLOCKSVIEW
This spot blocks the player's view.
bool coords_in_shop(mapstruct *map, int x, int y)
Check if the given map coordinates are in a shop.
in that case they will be relative to whatever the PWD of the crossfire server process is You probably shouldn though Notes on Specific and settings file datadir Usually usr share crossfire Contains data that the server does not need to modify while such as the etc A default install will pack the and treasurelist definitions into a single or trs file and the graphics into a face(metadata) and .tar(bitmaps) file
const char * uniquedir
Directory for the unique items.
#define SET_MAP_MOVE_OFF(M, X, Y, C)
Sets the move_off state of a square.
const char * localdir
Read/write data files.