1 #ifndef __MEDIA_H 2 #define __MEDIA_H 3 4 /* 5 MEDIA.H 6 7 Copyright (C) 1991-2001 and beyond by Bungie Studios, Inc. 8 and the "Aleph One" developers. 9 10 This program is free software; you can redistribute it and/or modify 11 it under the terms of the GNU General Public License as published by 12 the Free Software Foundation; either version 3 of the License, or 13 (at your option) any later version. 14 15 This program is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 GNU General Public License for more details. 19 20 This license is contained in the file "COPYING", 21 which is included with this source code; it is available online at 22 http://www.gnu.org/licenses/gpl.html 23 24 Saturday, March 25, 1995 1:27:18 AM (Jason') 25 26 Feb 3, 2000 (Loren Petrich): 27 Added Jjaro media type 28 29 May 17, 2000 (Loren Petrich): 30 Added XML-parser support 31 32 June 3, 2000 (Loren Petrich): 33 Made accessors return the null pointer for invalid index values; 34 also added is-media-dangerous function for use in determining whether a monster 35 should step into it. 36 37 July 1, 2000 (Loren Petrich): 38 Inlined the media accessors; added map.h here to define SLOT_IS_USED 39 40 Aug 29, 2000 (Loren Petrich): 41 Added packing and unpacking routines 42 */ 43 44 #include <vector> 45 #include "map.h" 46 47 /* ---------- constants */ 48 49 // #define MAXIMUM_MEDIAS_PER_MAP 16 50 51 // LP addition: added JjaroGoo support 52 enum /* media types */ 53 { 54 _media_water, 55 _media_lava, 56 _media_goo, 57 _media_sewage, 58 _media_jjaro, 59 NUMBER_OF_MEDIA_TYPES 60 }; 61 62 enum /* media flags */ 63 { 64 _media_sound_obstructed_by_floor, // this media makes no sound when under the floor 65 66 NUMBER_OF_MEDIA_FLAGS /* <= 16 */ 67 }; 68 69 #define MEDIA_SOUND_OBSTRUCTED_BY_FLOOR(m) TEST_FLAG16((m)->flags, _media_sound_obstructed_by_floor) 70 71 #define SET_MEDIA_SOUND_OBSTRUCTED_BY_FLOOR(m, v) SET_FLAG16((m)->flags, _media_sound_obstructed_by_floor, (v)) 72 73 enum /* media detonation types */ 74 { 75 _small_media_detonation_effect, 76 _medium_media_detonation_effect, 77 _large_media_detonation_effect, 78 _large_media_emergence_effect, 79 NUMBER_OF_MEDIA_DETONATION_TYPES 80 }; 81 82 enum /* media sounds */ 83 { 84 _media_snd_feet_entering, 85 _media_snd_feet_leaving, 86 _media_snd_head_entering, 87 _media_snd_head_leaving, 88 _media_snd_splashing, 89 _media_snd_ambient_over, 90 _media_snd_ambient_under, 91 _media_snd_platform_entering, 92 _media_snd_platform_leaving, 93 94 NUMBER_OF_MEDIA_SOUNDS 95 }; 96 97 /* ---------- macros */ 98 99 #define UNDER_MEDIA(m, z) ((z)<=(m)->height) 100 101 /* ---------- structures */ 102 103 struct media_data /* 32 bytes */ 104 { 105 int16 type; 106 uint16 flags; 107 108 /* this light is not used as a real light; instead, the intensity of this light is used to 109 determine the height of the media: height= low + (high-low)*intensity ... this sounds 110 gross, but it makes media heights as flexible as light intensities; clearly discontinuous 111 light functions (e.g., strobes) should not be used */ 112 int16 light_index; 113 114 /* this is the maximum external velocity due to current; acceleration is 1/32nd of this */ 115 angle current_direction; 116 world_distance current_magnitude; 117 118 world_distance low, high; 119 120 world_point2d origin; 121 world_distance height; 122 123 _fixed minimum_light_intensity; 124 shape_descriptor texture; 125 int16 transfer_mode; 126 127 int16 unused[2]; 128 }; 129 const int SIZEOF_media_data = 32; 130 131 /* --------- globals */ 132 133 134 // Turned the list of lights into a variable array; 135 // took over their maximum number as how many of them 136 137 extern vector<media_data> MediaList; 138 #define medias (MediaList.data()) 139 #define MAXIMUM_MEDIAS_PER_MAP (MediaList.size()) 140 141 // extern struct media_data *medias; 142 143 /* --------- prototypes/MEDIA.C */ 144 145 size_t new_media(struct media_data *data); 146 147 void update_medias(void); 148 149 void get_media_detonation_effect(short media_index, short type, short *detonation_effect); 150 short get_media_sound(short media_index, short type); 151 short get_media_submerged_fade_effect(short media_index); 152 struct damage_definition *get_media_damage(short media_index, _fixed scale); 153 bool get_media_collection(short media_index, short& collection); 154 155 // LP addition: media dangerous? 156 bool IsMediaDangerous(short media_type); 157 158 bool media_in_environment(short media_type, short environment_code); 159 160 media_data *get_media_data( 161 const size_t media_index); 162 163 // LP addition: count number of media types used, 164 // for better Infinity compatibility when saving games 165 size_t count_number_of_medias_used(); 166 167 // LP: routines for packing and unpacking the data from streams of bytes 168 169 uint8 *unpack_media_data(uint8 *Stream, media_data* Objects, size_t Count); 170 uint8 *pack_media_data(uint8 *Stream, media_data* Objects, size_t Count); 171 172 class InfoTree; 173 void parse_mml_liquids(const InfoTree& root); 174 void reset_mml_liquids(); 175 176 #endif 177 178