home · contact · privacy
MAJOR re-write. Split plomrogue into a server and a client. Re-wrote large parts
[plomrogue] / src / server / map_objects.h
1 /* src/server/map_objects.h
2  *
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.
5  */
6
7 #ifndef MAP_OBJECTS_H
8 #define MAP_OBJECTS_H
9
10 #include <stdint.h> /* uint8_t */
11 #include "../common/yx_uint16.h" /* yx_uint16 structs */
12
13
14
15 struct MapObj
16 {
17     struct MapObj * next;        /* pointer to next one in map object chain */
18     struct MapObj * owns;        /* chain of map objects owned / in inventory */
19     struct yx_uint16 pos;        /* coordinate on map */
20     uint8_t id;                  /* individual map object's unique identifier */
21     uint8_t type;                /* ID of appropriate map object definition */
22     uint8_t lifepoints;          /* 0: object is inanimate; >0: hitpoints */
23     uint8_t command;             /* map object's current action */
24     uint8_t arg;                 /* optional field for .command argument */
25     uint8_t progress;            /* turns already passed to realize .command */
26 };
27
28 struct MapObjDef
29 {
30     struct MapObjDef * next;
31     char char_on_map;   /* map object symbol to appear on map */
32     char * name;        /* string to describe object in game log */
33     uint8_t id;         /* map object definition identifier / sets .type */
34     uint8_t corpse_id;  /* type to change map object into upon destruction */
35     uint8_t lifepoints; /* default start value for map object's .lifepoints */
36 };
37
38
39
40 /* Initialize map object definitions chain from file at path "filename". */
41 extern void init_map_object_defs(char * filename);
42
43 /* Free map object definitions chain starting at "mod_start". */
44 extern void free_map_object_defs(struct MapObjDef * mod_start);
45
46 /* Add object(s) ("n": how many?) of "type" to map on random position(s). New
47  * animate objects are never placed in the same square with other animate ones.
48  */
49 extern void add_map_objects(uint8_t type, uint8_t n);
50
51 /* Free map objects in map object chain starting at "mo_start. */
52 extern void free_map_objects(struct MapObj * mo_start);
53
54 /* Move object of "id" from "source" inventory to "target" inventory. */
55 extern void own_map_object(struct MapObj ** target, struct MapObj ** source,
56                            uint8_t id);
57
58 /* Get pointer to the MapObj struct that represents the player. */
59 extern struct MapObj * get_player();
60
61 /* Get pointer to the map object definition of identifier "def_id". */
62 extern struct MapObjDef * get_map_object_def(uint8_t id);
63
64 /* Move not only "mo" to "pos", but also all map objects owned by it. */
65 extern void set_object_position(struct MapObj * mo, struct yx_uint16 pos);
66
67
68
69 #endif