1 /* 2 Copyright (C) 1994-1995 Apogee Software, Ltd. 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. 12 13 See the GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 19 */ 20 #ifndef _rt_door_public 21 #define _rt_door_public 22 23 //*************************************************************************** 24 // 25 // RT_DOOR.C - doors 26 // 27 //*************************************************************************** 28 29 #define MAXTOUCHPLATES 64 30 #define MAXMASKED 300 // max masked walls 31 #define MAXDOORS 150 // max number of sliding doors 32 #define MAXPWALLS 150 // max number of pushwalls 33 #define DF_TIMED 0x01 34 #define DF_ELEVLOCKED 0x02 35 #define DF_MULTI 0x04 36 #define MAXELEVATORS 16 37 38 #define PW_DAMAGE 0x01 39 40 #define NUMELEVATORACTIONS 5 41 42 typedef enum 43 {ev_ras, //ready at source 44 ev_rad, //ready at destination 45 ev_mts, //moving to source 46 ev_mtd, //moving to destination 47 //door at elevator location open 48 ev_doorclosing //door at elevator location closed 49 }estate; 50 51 typedef enum 52 { 53 mw_peephole, 54 mw_dogwall, 55 mw_multi1, 56 mw_multi2, 57 mw_multi3, 58 mw_singlepane, 59 mw_normal1, 60 mw_normal2, 61 mw_normal3, 62 mw_exitarch, 63 mw_secretexitarch, 64 mw_railing, 65 mw_hiswitchon, 66 mw_hiswitchoff, 67 mw_platform1, 68 mw_platform2, 69 mw_platform3, 70 mw_platform4, 71 mw_platform5, 72 mw_platform6, 73 mw_platform7, 74 mw_entrygate 75 }masked_walls; 76 77 typedef struct elevator 78 { short sx,sy; 79 short dx,dy; 80 short esx,esy,edx,edy; 81 short door1,door2; 82 signed char state; 83 short doortoopen; 84 short doorclosing; 85 short ticcount; 86 short nextaction; 87 }elevator_t; 88 89 90 typedef struct doorstruct 91 { 92 thingtype which; 93 byte tilex,tiley; 94 word texture; 95 word alttexture; 96 word sidepic; 97 word basetexture; 98 byte lock; 99 byte flags; 100 short int ticcount; 101 signed char eindex; 102 boolean vertical; 103 int soundhandle; 104 int position; 105 enum {dr_open,dr_closed,dr_opening,dr_closing} action; 106 } doorobj_t; 107 108 typedef struct pwallstruct 109 { 110 thingtype which; 111 int x,y; 112 int momentumx,momentumy; 113 byte areanumber; 114 byte lock; 115 byte dir; 116 byte tilex,tiley; 117 byte num; 118 byte speed; 119 word texture; 120 int soundhandle; 121 enum {pw_npushed,pw_pushing,pw_pushed,pw_moving} action; 122 int state; 123 byte flags; 124 } pwallobj_t; 125 126 typedef struct tplate 127 { void (*action)(int); 128 void (*swapaction)(int); 129 struct tplate * nextaction; 130 struct tplate * prevaction; 131 int whichobj; 132 byte tictime; 133 byte ticcount; 134 byte triggered; 135 byte done; 136 byte complete; 137 byte clocktype; 138 } touchplatetype; 139 140 #define MW_SHOOTABLE 0x01 141 #define MW_BLOCKING 0x02 142 #define MW_MULTI 0x04 143 #define MW_BLOCKINGCHANGES 0x08 144 #define MW_ABOVEPASSABLE 0x10 145 #define MW_NONDOGBLOCKING 0x20 146 #define MW_WEAPONBLOCKING 0x40 147 #define MW_BOTTOMPASSABLE 0x80 148 #define MW_MIDDLEPASSABLE 0x100 149 #define MW_ABP 0x200 150 #define MW_SWITCHON 0x400 151 #define MW_BOTTOMFLIPPING 0x800 152 #define MW_TOPFLIPPING 0x1000 153 #define M_ISDOOR(x,y) ((tilemap[x][y] & 0x8000) && (!(tilemap[x][y] & 0x4000))) 154 #define M_ISMWALL(x,y) ((tilemap[x][y] & 0x8000) && (tilemap[x][y] & 0x4000)) 155 156 157 typedef struct mwall 158 { 159 thingtype which; 160 byte tilex,tiley; 161 signed char areanumber; 162 signed short toptexture; 163 signed short midtexture; 164 signed short bottomtexture; 165 word flags; 166 boolean vertical; 167 int sidepic; 168 169 struct mwall *next; 170 struct mwall *prev; 171 172 } maskedwallobj_t; 173 174 typedef struct animmwall 175 { 176 word num; 177 byte count; 178 signed char ticcount; 179 struct animmwall *next; 180 struct animmwall *prev; 181 182 } animmaskedwallobj_t; 183 184 extern elevator_t ELEVATOR[MAXELEVATORS]; 185 extern int _numelevators; 186 extern animmaskedwallobj_t *FIRSTANIMMASKEDWALL,*LASTANIMMASKEDWALL; 187 extern maskedwallobj_t *FIRSTMASKEDWALL,*LASTMASKEDWALL; 188 extern byte touchindices[MAPSIZE][MAPSIZE],lasttouch; 189 extern touchplatetype *touchplate[MAXTOUCHPLATES],*lastaction[MAXTOUCHPLATES]; 190 extern byte TRIGGER[MAXTOUCHPLATES]; 191 192 extern doorobj_t *doorobjlist[MAXDOORS]; 193 extern int doornum; 194 extern maskedwallobj_t *maskobjlist[MAXMASKED]; 195 extern int maskednum; 196 extern pwallobj_t *pwallobjlist[MAXPWALLS]; 197 extern int pwallnum; 198 // 0xffff = fully open 199 extern byte areaconnect[NUMAREAS][NUMAREAS]; 200 extern boolean areabyplayer[NUMAREAS]; 201 202 203 void ActivateAllPushWalls(void); 204 boolean CheckTile(int,int); 205 void FindEmptyTile(int*,int*); 206 int Number_of_Empty_Tiles_In_Area_Around(int,int); 207 void AddTouchplateAction(touchplatetype*,int); 208 void RemoveTouchplateAction(touchplatetype*,int); 209 210 void InitElevators(void); 211 void ProcessElevators(void); 212 void OperateElevatorDoor(int); 213 214 215 int PlatformHeight(int,int); 216 void Link_To_Touchplate(word, word, void (*)(int), void (*)(int),int, int); 217 void TriggerStuff(void); 218 void ClockLink(void (*)(int),void(*)(int),int,int); 219 void RecursiveConnect(int); 220 void ConnectAreas(void); 221 void InitAreas(void); 222 void InitDoorList(void); 223 void SpawnDoor(int,int,int,int); 224 void SpawnMaskedWall (int tilex, int tiley, int which, int flags); 225 void OpenDoor(int); 226 void CloseDoor(int); 227 void OperateDoor (int keys, int door, boolean localplayer ); 228 void DoorOpen(int); 229 void DoorOpening(int); 230 void DoorClosing(int door); 231 void MoveDoors(void); 232 void SpawnPushWall (int tilex, int tiley, int lock, int texture, int dir, int type); 233 void MovePWalls(void); 234 void WallPushing (int pwall); 235 void PushWall (int pwall, int dir); 236 void OperatePushWall (int pwall, int dir, boolean localplayer ); 237 void ActivatePushWall (int pwall); 238 void ActivateMoveWall (int pwall); 239 int UpdateMaskedWall (int num); 240 241 void FixDoorAreaNumbers ( void ); 242 void FixMaskedWallAreaNumbers ( void ); 243 void SaveMaskedWalls(byte ** buf, int * size); 244 void LoadMaskedWalls(byte * buf, int size); 245 void SaveDoors(byte ** buf, int * size); 246 void SaveTouchPlates(byte ** buf, int * size); 247 void LoadDoors(byte * buf, int size); 248 void LoadTouchPlates(byte * buf, int size); 249 void SavePushWalls(byte ** buf, int * sz); 250 void LoadPushWalls(byte * bufptr, int sz); 251 252 void DeactivateAnimMaskedWall(animmaskedwallobj_t* amwall); 253 void ActivateAnimMaskedWall(animmaskedwallobj_t* amwall); 254 255 void SpawnAnimatedMaskedWall ( int num ); 256 void KillAnimatedMaskedWall ( animmaskedwallobj_t * temp ); 257 258 void DoAnimatedMaskedWalls ( void ); 259 260 void SaveElevators(byte ** buffer,int *size); 261 262 void LoadElevators(byte * buffer,int size); 263 264 void MakeWideDoorVisible ( int doornum ); 265 void LinkedCloseDoor (int door); 266 void LinkedOpenDoor (int door); 267 int IsWall (int tilex, int tiley); 268 int IsDoor (int tilex, int tiley); 269 int IsMaskedWall (int tilex, int tiley); 270 #endif 271