1 /* src/server/map_objects.h
3 * Structs for objects on the map and their type definitions, and routines to
4 * initialize these and load and save them from/to files.
10 #include <stdint.h> /* uint8_t */
11 //#include <stdio.h> /* FILE */
12 #include "../common/yx_uint8.h" /* yx_uint8 structs */
13 //struct EntrySkeleton;
19 struct MapObj * next; /* pointer to next one in map object chain */
20 struct MapObj * owns; /* chain of map objects owned / in inventory */
21 struct yx_uint8 pos; /* coordinate on map */
22 uint8_t id; /* individual map object's unique identifier */
23 uint8_t type; /* ID of appropriate map object definition */
24 uint8_t lifepoints; /* 0: object is inanimate; >0: hitpoints */
25 uint8_t command; /* map object's current action; 0 if none */
26 uint8_t arg; /* optional field for .command argument */
27 uint8_t progress; /* turns already passed to realize .command */
32 uint8_t id; /* map object definition identifier / sets .type */
33 struct MapObjDef * next;
34 char char_on_map; /* map object symbol to appear on map */
35 char * name; /* string to describe object in game log */
36 uint8_t corpse_id; /* type to change map object into upon destruction */
37 uint8_t lifepoints; /* default start value for map object's .lifepoints */
38 uint8_t consumable; /* can be eaten if !0, for so much hitpoint win */
43 /* Read-in to "entry" multi-line entry from MapObjDef config "file", using
44 * pre-allocated "line", "linemax" and "context" as input for err_try_fgets().
46 //extern void read_map_object_def(char * line, uint32_t linemax, char * context,
47 // struct EntrySkeleton * entry, FILE * file);
49 /* Free map object definitions chain starting at "mod_start". */
50 extern void free_map_object_defs(struct MapObjDef * mod_start);
52 /* Add object(s) ("n": how many?) of "type" to map on random position(s). New
53 * animate objects are never placed in the same square with other animate ones.
55 extern void add_map_objects(uint8_t type, uint8_t n);
57 /* Free map objects in map object chain starting at "mo_start. */
58 extern void free_map_objects(struct MapObj * mo_start);
60 /* Move object of "id" from "source" inventory to "target" inventory. */
61 extern void own_map_object(struct MapObj ** target, struct MapObj ** source,
64 /* Get pointer to the MapObj struct that represents the player. */
65 extern struct MapObj * get_player();
67 /* Get pointer to the map object definition of identifier "def_id". */
68 extern struct MapObjDef * get_map_object_def(uint8_t id);
70 /* Move not only "mo" to "pos", but also all map objects owned by it. */
71 extern void set_object_position(struct MapObj * mo, struct yx_uint8 pos);