Debian Codegraph @

prboom2/src/dsda/mapinfo/doom/parser.h

raw
1 //
2 // Copyright(C) 2023 by Ryan Krafnick
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // DESCRIPTION:
15 // DSDA MAPINFO Doom Parser
16 //
17
18 #ifndef __DSDA_MAPINFO_DOOM_PARSER__
19 #define __DSDA_MAPINFO_DOOM_PARSER__
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
25 #include <inttypes.h>
26
27 typedef enum {
28 dmi_end_null,
29 dmi_end_game_scroll,
30 dmi_end_game_cast,
31 } dmi_end_t;
32
33 typedef struct {
34 char* map;
35 char* end_pic;
36 char* end_pic_b;
37 char* music;
38 dboolean loop_music;
39 dmi_end_t end;
40 } doom_mapinfo_map_next_t;
41
42 typedef struct {
43 char* lump;
44 // float scrollspeed;
45 } doom_mapinfo_sky_t;
46
47 typedef struct {
48 int monster_type;
49 int action_special;
50 int special_args[5];
51 } doom_mapinfo_special_action_t;
52
53 #define DMI_INTERMISSION 0x00000001ul
54 #define DMI_ALLOW_MONSTER_TELEFRAGS 0x00000002ul
55 #define DMI_ACTIVATE_OWN_DEATH_SPECIALS 0x00000004ul
56 #define DMI_LAX_MONSTER_ACTIVATION 0x00000008ul
57 #define DMI_MISSILES_ACTIVATE_IMPACT_LINES 0x00000010ul
58 #define DMI_FILTER_STARTS 0x00000020ul
59 #define DMI_ALLOW_RESPAWN 0x00000040ul
60 #define DMI_ALLOW_JUMP 0x00000080ul
61 #define DMI_ALLOW_FREE_LOOK 0x00000100ul
62 #define DMI_CHECK_SWITCH_RANGE 0x00000200ul
63 #define DMI_RESET_HEALTH 0x00000400ul
64 #define DMI_RESET_INVENTORY 0x00000800ul
65 #define DMI_USE_PLAYER_START_Z 0x00001000ul
66 #define DMI_VERTICAL_EXPLOSION_THRUST 0x00002000ul
67 #define DMI_EXPLODE_IN_3D 0x00004000ul
68 #define DMI_SHOW_AUTHOR 0x00008000ul
69 #define DMI_PASSOVER 0x00010000ul
70 #define DMI_EVEN_LIGHTING 0x00020000ul
71 #define DMI_SMOOTH_LIGHTING 0x00040000ul
72
73 typedef uint32_t doom_mapinfo_map_flags_t;
74
75 typedef struct {
76 char* lump_name;
77 char* nice_name;
78 char* author;
79 int level_num;
80 int cluster;
81 doom_mapinfo_map_next_t next;
82 doom_mapinfo_map_next_t secret_next;
83 doom_mapinfo_sky_t sky1;
84 char* title_patch;
85 char* exit_pic;
86 char* enter_pic;
87 char* border_texture;
88 char* music;
89 char* inter_music;
90 int par;
91 char* gravity;
92 char* air_control;
93 char* colormap;
94 size_t num_special_actions;
95 doom_mapinfo_special_action_t* special_actions;
96 doom_mapinfo_map_flags_t flags;
97 } doom_mapinfo_map_t;
98
99 #define DSI_SPAWN_MULTI 0x0001
100 #define DSI_FAST_MONSTERS 0x0002
101 #define DSI_INSTANT_REACTION 0x0004
102 #define DSI_NO_PAIN 0x0010
103 #define DSI_DEFAULT_SKILL 0x0020
104 #define DSI_PLAYER_RESPAWN 0x0080
105 #define DSI_EASY_BOSS_BRAIN 0x0100
106 #define DSI_MUST_CONFIRM 0x0200
107 #define DSI_AUTO_USE_HEALTH 0x0400 // not applicable to doom
108
109 typedef uint16_t doom_mapinfo_skill_flags_t;
110
111 typedef struct {
112 char* unique_id;
113 char* ammo_factor;
114 char* damage_factor;
115 char* armor_factor;
116 char* health_factor;
117 char* monster_health_factor;
118 char* friend_health_factor;
119 int respawn_time;
120 int spawn_filter;
121 char key;
122 char* must_confirm;
123 char* name;
124 char* pic_name;
125 char* text_color;
126 doom_mapinfo_skill_flags_t flags;
127 } doom_mapinfo_skill_t;
128
129 typedef struct {
130 int id;
131 char* enter_text;
132 char* exit_text;
133 char* music;
134 char* flat;
135 char* pic;
136 } doom_mapinfo_cluster_t;
137
138 typedef struct {
139 char* map_lump;
140 char* name;
141 char* pic_name;
142 char key;
143 } doom_mapinfo_episode_t;
144
145 typedef struct {
146 size_t num_maps;
147 doom_mapinfo_map_t* maps;
148 size_t num_skills;
149 doom_mapinfo_skill_t* skills;
150 size_t num_clusters;
151 doom_mapinfo_cluster_t* clusters;
152 size_t num_episodes;
153 doom_mapinfo_episode_t* episodes;
154 int loaded;
155 int skills_cleared;
156 int episodes_cleared;
157 } doom_mapinfo_t;
158
159 extern doom_mapinfo_t doom_mapinfo;
160
161 typedef void (*doom_mapinfo_errorfunc)(const char *fmt, ...); // this must not return!
162
163 void dsda_ParseDoomMapInfo(const unsigned char* buffer, size_t length, doom_mapinfo_errorfunc err);
164
165 #ifdef __cplusplus
166 }
167 #endif
168
169 #endif