 |
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)
364 LOG(
llevError,
"blocked_link: Passed map, x, y coordinates outside of map\n");
372 mflags =
m->spaces[sx+
m->width*sy].flags;
402 tmp_head =
HEAD(tmp);
507 for (tmp = ob->
arch, part = ob; tmp != NULL; tmp = tmp->
more, part = part->
more) {
554 for (at = tmp->arch->
more, last = tmp; at != NULL; at = at->
more, last = op) {
562 if (tmp->name != op->
name) {
567 if (tmp->title != op->
title) {
597 if (tmp->head || tmp->more)
618 object *op, *prev = NULL, *last_more = NULL;
624 while ((i =
load_object(fp, op, bufstate, mapflags,
false))) {
635 if (op->
arch == NULL) {
645 LOG(
llevError,
"Discarding invalid item with type PLAYER in map %s\n",
m->path);
651 LOG(
llevError,
" object %s not on valid map position %s:%d:%d\n", op->
name ? op->
name :
"(null)",
m->path, op->
x, op->
y);
683 last_more->
more = op,
694 "load_objects on %s took %ld us\n",
m->path, diff));
695 for (i = 0; i <
m->width; i++) {
696 for (j = 0; j <
m->height; j++) {
728 int i, j = 0, unique = 0;
729 unsigned int count = 0;
734 long serialize_time, write_time;
775 LOG(
llevDebug,
"saved %d objects on %s (%ld us serializing, %ld us writing)\n", count,
m->path, serialize_time, write_time);
811 return (uint32_t)
m->width * (uint32_t)
m->height;
831 LOG(
llevError,
"allocate_map called with already allocated map (%s)\n",
m->path);
837 if (
m->spaces == NULL)
877 char *shop_string, *p, *q, *next_semicolon, *next_colon;
879 int i = 0, number_of_entries = 0;
903 for (i = 0; i < number_of_entries; i++) {
905 LOG(
llevError,
"parse_shop_string: I seem to have run out of string, that shouldn't happen.\n");
908 next_semicolon = strchr(p,
';');
909 next_colon = strchr(p,
':');
911 if (next_colon && (!next_semicolon || next_colon < next_semicolon))
912 items[i].
strength = atoi(strchr(p,
':')+1);
914 if (isdigit(*p) || *p ==
'*') {
915 items[i].
typenum = *p ==
'*' ? -1 : atoi(p);
922 q = strpbrk(p,
";:");
934 LOG(
llevError,
"invalid type %s defined in shopitems for %s in string %s\n", p, map->
name, input_string);
937 items[i].
index = number_of_entries;
939 p = ++next_semicolon;
962 output_string[0] =
'\0';
963 for (i = 0; i <
m->shopitems[0].index; i++) {
964 if (
m->shopitems[i].typenum != -1) {
965 if (
m->shopitems[i].strength) {
966 snprintf(tmp,
sizeof(tmp),
"%s:%d;",
m->shopitems[i].name,
m->shopitems[i].strength);
968 snprintf(tmp,
sizeof(tmp),
"%s;",
m->shopitems[i].name);
970 if (
m->shopitems[i].strength) {
971 snprintf(tmp,
sizeof(tmp),
"*:%d;",
m->shopitems[i].strength);
973 snprintf(tmp,
sizeof(tmp),
"*;");
975 snprintf(output_string+strlen(output_string), size-strlen(output_string),
"%s", tmp);
979 if (strlen(output_string) > 0) {
980 output_string[strlen(output_string) - 1] =
'\0';
1003 m->width =
m->height = 0;
1004 while (fgets(
buf,
sizeof(
buf), fp) != NULL) {
1007 p = strchr(
buf,
'\n');
1009 LOG(
llevError,
"Error loading map header - did not find a newline - perhaps file is truncated? Buf=%s\n",
buf);
1015 while (isspace(*key))
1019 value = strchr(key,
' ');
1023 while (isspace(*value)) {
1025 if (*value ==
'\0') {
1048 if (!strcmp(key,
"msg")) {
1052 while (fgets(
buf,
sizeof(
buf), fp) != NULL) {
1053 if (!strcmp(
buf,
"endmsg\n"))
1057 msgpos += strlen(
buf);
1070 }
else if (!strcmp(key,
"maplore")) {
1072 size_t maplorepos = 0;
1075 if (!strcmp(
buf,
"endmaplore\n"))
1078 if (maplorepos >=
sizeof(maplorebuf)) {
1082 snprintf(maplorebuf+maplorepos,
sizeof(maplorebuf)-maplorepos,
"%s",
buf);
1083 maplorepos += strlen(
buf);
1086 if (maplorepos != 0)
1088 }
else if (!strcmp(key,
"end")) {
1090 }
else if (value == NULL) {
1091 LOG(
llevError,
"Got '%s' line without parameter in map header\n", key);
1092 }
else if (!strcmp(key,
"arch")) {
1094 if (strcmp(value,
"map")) {
1095 LOG(
llevError,
"load_map_header: expected 'arch map': check line endings?\n");
1098 }
else if (!strcmp(key,
"name")) {
1106 }
else if (!strcmp(key,
"enter_x")) {
1107 m->enter_x = atoi(value);
1108 }
else if (!strcmp(key,
"enter_y")) {
1109 m->enter_y = atoi(value);
1110 }
else if (!strcmp(key,
"width")) {
1111 m->width = atoi(value);
1112 }
else if (!strcmp(key,
"height")) {
1113 m->height = atoi(value);
1114 }
else if (!strcmp(key,
"reset_timeout")) {
1115 m->reset_timeout = atoi(value);
1116 }
else if (!strcmp(key,
"swap_time")) {
1118 }
else if (!strcmp(key,
"difficulty")) {
1119 m->difficulty = atoi(value);
1120 }
else if (!strcmp(key,
"darkness")) {
1121 m->darkness = atoi(value);
1122 }
else if (!strcmp(key,
"fixed_resettime")) {
1123 m->fixed_resettime = atoi(value);
1124 }
else if (!strcmp(key,
"unique")) {
1125 m->unique = atoi(value);
1126 }
else if (!strcmp(key,
"template")) {
1127 m->is_template = atoi(value);
1128 }
else if (!strcmp(key,
"region")) {
1130 }
else if (!strcmp(key,
"shopitems")) {
1132 }
else if (!strcmp(key,
"shopgreed")) {
1133 m->shopgreed = atof(value);
1134 }
else if (!strcmp(key,
"shopmin")) {
1135 m->shopmin = atol(value);
1136 }
else if (!strcmp(key,
"shopmax")) {
1137 m->shopmax = atol(value);
1138 }
else if (!strcmp(key,
"shoprace")) {
1140 }
else if (!strcmp(key,
"outdoor")) {
1141 m->outdoor = atoi(value);
1142 }
else if (!strcmp(key,
"nosmooth")) {
1143 m->nosmooth = atoi(value);
1144 }
else if (!strcmp(key,
"first_load")) {
1145 m->last_reset_time = atoi(value);
1146 }
else if (!strncmp(key,
"tile_path_", 10)) {
1147 int tile = atoi(key+10);
1149 if (tile < 1 || tile > 4) {
1150 LOG(
llevError,
"load_map_header: tile location %d out of bounds (%s)\n", tile,
m->path);
1152 if (
m->tile_path[tile-1]) {
1153 LOG(
llevError,
"load_map_header: tile location %d duplicated (%s)\n", tile,
m->path);
1154 free(
m->tile_path[tile-1]);
1158 }
else if (!strcmp(key,
"background_music")) {
1160 }
else if (!strcmp(key,
"reset_group")) {
1163 LOG(
llevError,
"Got unknown value in map header: %s %s\n", key, value);
1166 if ((
m->width == 0) || (
m->height == 0)) {
1170 if (!key || strcmp(key,
"end")) {
1189 if ((fp = fopen(pathname,
"r")) == NULL) {
1191 "Can't open %s: %s\n", pathname, strerror(errno));
1250 LOG(
llevDebug,
"mapfile_load on %s" " took %ld us\n", map, diff));
1268 LOG(
llevError,
"No temporary filename for map %s\n",
m->path);
1272 if ((fp = fopen(
m->tmpname,
"r")) == NULL) {
1273 LOG(
llevError,
"Cannot open %s: %s\n",
m->tmpname, strerror(errno));
1278 LOG(
llevError,
"Error loading map header for %s (%s)\n",
m->path,
m->tmpname);
1306 if ((fp = fopen(pathname,
"r")) == NULL) {
1312 LOG(
llevError,
"Error loading map header for overlay %s (%s)\n",
m->path, pathname);
1336 int i, j, unique = 0;
1366 for (count = 0; count < 10; count++) {
1367 snprintf(firstname,
sizeof(firstname),
"%s.v%02d",
name, count);
1368 if (!access(firstname, R_OK))
1375 if ((fp = fopen(firstname,
"r")) == NULL) {
1384 if (
m->tmpname == NULL)
1413 if (flag && !*
m->path) {
1421 if (!
m->unique && !
m->is_template) {
1427 if (
m->path[0] !=
'~') {
1429 "Cannot save unique map '%s' outside of LOCALDIR. Check "
1430 "that all exits to '%s' have FLAG_UNIQUE set correctly.\n",
1441 strlcpy(filename,
m->tmpname,
sizeof(filename));
1450 fprintf(fp,
"arch map\n");
1452 fprintf(fp,
"name %s\n",
m->name);
1453 if (
m->reset_timeout)
1454 fprintf(fp,
"reset_timeout %u\n",
m->reset_timeout);
1455 if (
m->fixed_resettime)
1456 fprintf(fp,
"fixed_resettime %d\n",
m->fixed_resettime);
1461 fprintf(fp,
"difficulty %d\n",
m->difficulty);
1463 fprintf(fp,
"region %s\n",
m->region->name);
1466 fprintf(fp,
"shopitems %s\n", shop);
1469 fprintf(fp,
"shopgreed %f\n",
m->shopgreed);
1471 fprintf(fp,
"shopmin %" FMT64U "\n",
m->shopmin);
1473 fprintf(fp,
"shopmax %" FMT64U "\n",
m->shopmax);
1475 fprintf(fp,
"shoprace %s\n",
m->shoprace);
1477 fprintf(fp,
"darkness %d\n",
m->darkness);
1479 fprintf(fp,
"width %d\n",
m->width);
1481 fprintf(fp,
"height %d\n",
m->height);
1483 fprintf(fp,
"enter_x %d\n",
m->enter_x);
1485 fprintf(fp,
"enter_y %d\n",
m->enter_y);
1487 fprintf(fp,
"msg\n%sendmsg\n",
m->msg);
1489 fprintf(fp,
"maplore\n%sendmaplore\n",
m->maplore);
1491 fprintf(fp,
"unique %d\n",
m->unique);
1493 fprintf(fp,
"template %d\n",
m->is_template);
1495 fprintf(fp,
"outdoor %d\n",
m->outdoor);
1497 fprintf(fp,
"nosmooth %d\n",
m->nosmooth);
1498 if (
m->last_reset_time)
1499 fprintf(fp,
"first_load %ld\n",
m->last_reset_time);
1500 if (
m->background_music)
1501 fprintf(fp,
"background_music %s\n",
m->background_music);
1503 fprintf(fp,
"reset_group %s\n",
m->reset_group);
1507 for (i = 0; i < 4; i++)
1508 if (
m->tile_path[i])
1509 fprintf(fp,
"tile_path_%d %s\n", i+1,
m->tile_path[i]);
1511 fprintf(fp,
"end\n");
1522 snprintf(final_unique,
sizeof(final_unique),
"%s.v00",
name);
1523 fp2 =
of_open(&of2, final_unique);
1532 LOG(
llevError,
"Save error during object save: %d\n", res);
1541 LOG(
llevError,
"Save error during object save: %d\n", res);
1548 if (ftell(fp2) == 0) {
1554 unlink(final_unique);
1561 if (chmod(final_unique,
SAVE_MODE) != 0) {
1569 LOG(
llevError,
"Save error during object save: %d\n", res);
1580 LOG(
llevError,
"Could not set permissions on '%s'\n", filename);
1584 LOG(
llevDebug,
"save_map on %s" " took %ld us\n",
m->path, diff));
1621 object *previous_obj = NULL;
1624 if (op == previous_obj) {
1625 LOG(
llevDebug,
"free_all_objects: Link error, bailing out.\n");
1647 LOG(
llevError,
"free_all_objects: object %s still on map after it should have been freed\n", op->
name);
1665 if (!
m->in_memory) {
1686 if (
m->background_music)
1691 for (i = 0; i < 4; i++) {
1692 if (
m->tile_path[i])
1694 m->tile_map[i] = NULL;
1738 for (i = 0; i < 4; i++)
1751 LOG(
llevError,
"delete_map: Unable to find map %s in list\n",
m->path);
1753 last->
next =
m->next;
1799 snprintf(buf2,
sizeof(buf2),
"~%s",
name+strlen(
buf)+1);
1804 if (
name[0] ==
'~') {
1824 if (
m == NULL)
return NULL;
1882 if (
m->last_reset_time == 0) {
1913 int64_t exp_pr_sq, total_exp = 0;
1923 total_exp += op->stats.exp;
1925 total_exp += op->stats.exp;
1928 at = op->other_arch ? op->other_arch : NULL;
1932 int lim = atoi(val ? val :
"0");
1934 if (!lim || lim >= 16)
1950 for (i = 1; i < 25; i++)
1966 if (
m->tmpname == NULL)
1968 (void)unlink(
m->tmpname);
1986 LOG(
llevDebug,
"free_all_maps: Freed %d maps\n", real_maps);
2007 int new_level =
m->darkness+change;
2011 || (new_level <= 0 && m->darkness == 0)
2032 m->darkness = new_level;
2061 static inline void add_face_layer(
int low_layer,
int high_layer,
object *ob,
object *layers[],
int honor_visibility) {
2065 for (l = low_layer; l <= high_layer; l++) {
2071 if (!honor_visibility)
2078 for (l1 = (l-1); l1 >= low_layer; l1--) {
2081 layers[l1+1] = layers[l1];
2091 if (!honor_visibility) {
2095 for (l = low_layer; l < high_layer; l++)
2096 layers[l] = layers[l+1];
2097 layers[high_layer] = ob;
2107 for (l = high_layer; l >= low_layer; l--) {
2109 for (l1 = low_layer; l1 < l; l1++)
2110 layers[l1] = layers[l1+1];
2132 uint8_t
flags = 0, oldflags, light = 0;
2135 MoveType move_block = 0, move_slow = 0, move_on = 0, move_off = 0, move_allow = 0;
2139 LOG(
llevDebug,
"update_position called with P_NEED_UPDATE not set: %s (%d, %d)\n",
m->path, x, y);
2143 memset(layers, 0,
MAP_LAYERS*
sizeof(
object *));
2158 if (tmp->glow_radius > light)
2159 light = tmp->glow_radius;
2165 if (!tmp->invisible && tmp->face !=
blank_face) {
2166 if (tmp->map_layer) {
2177 memset(layers+1, 0, (
MAP_LAYERS-1)*
sizeof(
object *));
2188 if (tmp == tmp->above) {
2193 move_slow |= tmp->move_slow;
2194 move_block |= tmp->move_block;
2195 move_on |= tmp->move_on;
2196 move_off |= tmp->move_off;
2197 move_allow |= tmp->move_allow;
2219 LOG(
llevDebug,
"update_position: updated flags do not match old flags: %s (x=%d,y=%d) %x != %x\n",
2272 int dest_tile = (tile_num+2)%4;
2278 if (orig_map->
tile_map[tile_num] == NULL) {
2290 return orig_map->
tile_map[tile_num];
2307 int16_t xp = x, yp = y;
2340 if ( !
m )
return NULL;
2360 if (!
m->tile_path[3])
2365 if (!
m->tile_map[3])
2372 if (!
m->tile_path[1])
2377 if (!
m->tile_map[1])
2386 if (!
m->tile_path[0])
2391 if (!
m->tile_map[0])
2398 if (!
m->tile_path[2])
2403 if (!
m->tile_map[2])
2435 }
else if (map1->
tile_map[0] == map2) {
2438 }
else if (map1->
tile_map[1] == map2) {
2441 }
else if (map1->
tile_map[2] == map2) {
2444 }
else if (map1->
tile_map[3] == map2) {
2512 retval->
part = NULL;
2533 for (tmp = op1->
more; tmp != NULL; tmp = tmp->
more) {
2536 if (tmpi < best_distance) {
2537 best_distance = tmpi;
2546 retval->
part = best;
2580 retval->
part = NULL;
2586 retval->
part = NULL;
2657 if (unlink(
path) != 0) {
2665 for (count = 0; count < 10; count++) {
2666 snprintf(
path,
sizeof(
path),
"%s.v%02d", base, count);
2677 if (item->
map != NULL) {
2678 if (strlen(item->
map->
path) > 0) {
2682 return item->
map->
name ? item->
map->
name :
"(empty path and name)";
2685 if (item->
env != NULL)
2688 return "(no map and no env!)";
2697 return path != NULL &&
path[0] ==
'~';
2701 if (
m->spaces == NULL)
2705 return &
m->spaces[x +
m->width * y];
2721 if (real ==
nullptr)
2728 if (
ihypot(i - x, j - y) < light)
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
Server 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.
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.
#define EVENT_MAPLOAD
A map is loaded (pristine state)
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.
const char * object_get_value(const object *op, const char *const key)
Get an extra value by key.
#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...
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 EVENT_MAPUNLOAD
A map is freed (includes swapping out)
#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.
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.
pluglist shows those as well as a short text describing each the list will simply appear empty The keyword for the Python plugin is Python plugout< keyword > Unloads a given identified by its _keyword_ So if you want to unload the Python you need to do plugout Python plugin< libname > Loads a given whose _filename_ is libname So in the case of you d have to do a plugin cfpython so Note that all filenames are relative to the default plugin path(SHARE/plugins). Console messages. ----------------- When Crossfire starts
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.
static char msgbuf[HUGE_BUF]
uint8_t flags
Flags about this space (see the P_ values above).
char * name
Name of map as given by its creator.
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.
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 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 EVENT_MAPREADY
A map is ready, either first load or after reload.
#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 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.
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.