1 /* $Id: wall.c,v 1.14 2005-01-24 21:41:35 schaffner Exp $ */
3 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
4 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
5 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
6 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
7 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
8 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
9 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
10 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
11 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
12 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
17 * Destroyable wall stuff
26 static char rcsid[] = "$Id: wall.c,v 1.14 2005-01-24 21:41:35 schaffner Exp $";
55 #include "laser.h" // For seeing if a flare is stuck in a wall.
60 #include "editor/editor.h"
63 // Special door on boss level which is locked if not in multiplayer...sorry for this awful solution --MK.
64 #define BOSS_LOCKED_DOOR_LEVEL 7
65 #define BOSS_LOCKED_DOOR_SEG 595
66 #define BOSS_LOCKED_DOOR_SIDE 5
68 wall Walls[MAX_WALLS]; // Master walls array
69 int Num_walls=0; // Number of walls
71 wclip WallAnims[MAX_WALL_ANIMS]; // Wall animations
73 //--unused-- int walls_bm_num[MAX_WALL_ANIMS];
75 //door Doors[MAX_DOORS]; // Master doors array
77 active_door ActiveDoors[MAX_DOORS];
78 int Num_open_doors; // Number of open doors
80 #define CLOAKING_WALL_TIME f1_0
82 #define MAX_CLOAKING_WALLS 10
83 cloaking_wall CloakingWalls[MAX_CLOAKING_WALLS];
84 int Num_cloaking_walls;
86 //--unused-- grs_bitmap *wall_title_bms[MAX_WALL_ANIMS];
88 //#define BM_FLAG_TRANSPARENT 1
89 //#define BM_FLAG_SUPER_TRANSPARENT 2
92 char Wall_names[7][10] = {
103 // Function prototypes
104 void kill_stuck_objects(int wallnum);
108 // This function determines whether the current segment/side is transparent
111 int check_transparency( segment * seg, int side )
113 if ( (seg->sides[side].tmap_num2 & 0x3FFF) == 0) {
114 if (GameBitmaps[Textures[seg->sides[side].tmap_num].index].bm_flags & BM_FLAG_TRANSPARENT )
120 if (GameBitmaps[Textures[seg->sides[side].tmap_num2 & 0x3FFF ].index].bm_flags & BM_FLAG_SUPER_TRANSPARENT )
126 //-----------------------------------------------------------------
127 // This function checks whether we can fly through the given side.
128 // In other words, whether or not we have a 'doorway'
132 // WID_RENDPAST_FLAG 4
134 // WID_WALL 2 // 0/1/0 wall
135 // WID_TRANSPARENT_WALL 6 // 0/1/1 transparent wall
136 // WID_ILLUSORY_WALL 3 // 1/1/0 illusory wall
137 // WID_TRANSILLUSORY_WALL 7 // 1/1/1 transparent illusory wall
138 // WID_NO_WALL 5 // 1/0/1 no wall, can fly through
139 int wall_is_doorway ( segment * seg, int side )
143 //--Covered by macro // No child.
144 //--Covered by macro if (seg->children[side] == -1)
145 //--Covered by macro return WID_WALL;
147 //--Covered by macro if (seg->children[side] == -2)
148 //--Covered by macro return WID_EXTERNAL_FLAG;
150 //--Covered by macro // No wall present.
151 //--Covered by macro if (seg->sides[side].wall_num == -1)
152 //--Covered by macro return WID_NO_WALL;
154 Assert(seg-Segments>=0 && seg-Segments<=Highest_segment_index);
155 Assert(side>=0 && side<6);
157 type = Walls[seg->sides[side].wall_num].type;
158 flags = Walls[seg->sides[side].wall_num].flags;
160 if (type == WALL_OPEN)
163 if (type == WALL_ILLUSION) {
164 if (Walls[seg->sides[side].wall_num].flags & WALL_ILLUSION_OFF)
167 if (check_transparency( seg, side))
168 return WID_TRANSILLUSORY_WALL;
170 return WID_ILLUSORY_WALL;
174 if (type == WALL_BLASTABLE) {
175 if (flags & WALL_BLASTED)
176 return WID_TRANSILLUSORY_WALL;
178 if (check_transparency( seg, side))
179 return WID_TRANSPARENT_WALL;
184 if (flags & WALL_DOOR_OPENED)
185 return WID_TRANSILLUSORY_WALL;
187 if (type == WALL_CLOAKED)
188 return WID_RENDER_FLAG | WID_RENDPAST_FLAG | WID_CLOAKED_FLAG;
190 state = Walls[seg->sides[side].wall_num].state;
191 if ((type == WALL_DOOR) && (state == WALL_DOOR_OPENING))
192 return WID_TRANSPARENT_WALL;
194 // If none of the above flags are set, there is no doorway.
195 if (check_transparency( seg, side))
196 return WID_TRANSPARENT_WALL;
198 return WID_WALL; // There are children behind the door.
202 //-----------------------------------------------------------------
203 // Initializes all the walls (in other words, no special walls)
209 for (i=0;i<MAX_WALLS;i++) {
210 Walls[i].segnum = Walls[i].sidenum = -1;
211 Walls[i].type = WALL_NORMAL;
214 Walls[i].trigger = -1;
215 Walls[i].clip_num = -1;
216 Walls[i].linked_wall = -1;
219 Num_cloaking_walls = 0;
223 //-----------------------------------------------------------------
224 // Initializes one wall.
225 void wall_reset(segment *seg, int side)
229 i = seg->sides[side].wall_num;
232 mprintf((0, "Resetting Illegal Wall\n"));
236 Walls[i].segnum = seg-Segments;
237 Walls[i].sidenum = side;
238 Walls[i].type = WALL_NORMAL;
241 Walls[i].trigger = -1;
242 Walls[i].clip_num = -1;
243 Walls[i].linked_wall = -1;
247 //set the tmap_num or tmap_num2 field for a wall/door
248 void wall_set_tmap_num(segment *seg,int side,segment *csegp,int cside,int anim_num,int frame_num)
250 wclip *anim = &WallAnims[anim_num];
251 int tmap = anim->frames[frame_num];
253 if ( Newdemo_state==ND_STATE_PLAYBACK ) return;
255 if (anim->flags & WCF_TMAP1) {
256 seg->sides[side].tmap_num = csegp->sides[cside].tmap_num = tmap;
257 if ( Newdemo_state == ND_STATE_RECORDING )
258 newdemo_record_wall_set_tmap_num1(seg-Segments,side,csegp-Segments,cside,tmap);
260 Assert(tmap!=0 && seg->sides[side].tmap_num2!=0);
261 seg->sides[side].tmap_num2 = csegp->sides[cside].tmap_num2 = tmap;
262 if ( Newdemo_state == ND_STATE_RECORDING )
263 newdemo_record_wall_set_tmap_num2(seg-Segments,side,csegp-Segments,cside,tmap);
268 // -------------------------------------------------------------------------------
269 //when the wall has used all its hitpoints, this will destroy it
270 void blast_blastable_wall(segment *seg, int side)
276 Assert(seg->sides[side].wall_num != -1);
278 Walls[seg->sides[side].wall_num].hps = -1; //say it's blasted
280 csegp = &Segments[seg->children[side]];
281 Connectside = find_connect_side(seg, csegp);
282 Assert(Connectside != -1);
283 cwall_num = csegp->sides[Connectside].wall_num;
284 kill_stuck_objects(seg->sides[side].wall_num);
286 kill_stuck_objects(cwall_num);
288 //if this is an exploding wall, explode it
289 if (WallAnims[Walls[seg->sides[side].wall_num].clip_num].flags & WCF_EXPLODES)
290 explode_wall(seg-Segments,side);
292 //if not exploding, set final frame, and make door passable
293 a = Walls[seg->sides[side].wall_num].clip_num;
294 n = WallAnims[a].num_frames;
295 wall_set_tmap_num(seg,side,csegp,Connectside,a,n-1);
296 Walls[seg->sides[side].wall_num].flags |= WALL_BLASTED;
298 Walls[cwall_num].flags |= WALL_BLASTED;
304 //-----------------------------------------------------------------
305 // Destroys a blastable wall.
306 void wall_destroy(segment *seg, int side)
308 Assert(seg->sides[side].wall_num != -1);
309 Assert(seg-Segments != 0);
311 if (Walls[seg->sides[side].wall_num].type == WALL_BLASTABLE)
312 blast_blastable_wall( seg, side );
314 Error("Hey bub, you are trying to destroy an indestructable wall.");
317 //-----------------------------------------------------------------
318 // Deteriorate appearance of wall. (Changes bitmap (paste-ons))
319 void wall_damage(segment *seg, int side, fix damage)
321 int a, i, n, cwall_num;
323 if (seg->sides[side].wall_num == -1) {
324 mprintf((0, "Damaging illegal wall\n"));
328 if (Walls[seg->sides[side].wall_num].type != WALL_BLASTABLE)
331 if (!(Walls[seg->sides[side].wall_num].flags & WALL_BLASTED) && Walls[seg->sides[side].wall_num].hps >= 0)
336 csegp = &Segments[seg->children[side]];
337 Connectside = find_connect_side(seg, csegp);
338 Assert(Connectside != -1);
339 cwall_num = csegp->sides[Connectside].wall_num;
340 Walls[seg->sides[side].wall_num].hps -= damage;
342 Walls[cwall_num].hps -= damage;
344 a = Walls[seg->sides[side].wall_num].clip_num;
345 n = WallAnims[a].num_frames;
347 if (Walls[seg->sides[side].wall_num].hps < WALL_HPS*1/n) {
348 blast_blastable_wall( seg, side );
350 if (Game_mode & GM_MULTI)
351 multi_send_door_open(seg-Segments, side,Walls[seg->sides[side].wall_num].flags);
356 if (Walls[seg->sides[side].wall_num].hps < WALL_HPS*(n-i)/n) {
357 wall_set_tmap_num(seg,side,csegp,Connectside,a,i);
363 //-----------------------------------------------------------------
365 void wall_open_door(segment *seg, int side)
369 int Connectside, wall_num, cwall_num;
372 Assert(seg->sides[side].wall_num != -1); //Opening door on illegal wall
374 w = &Walls[seg->sides[side].wall_num];
375 wall_num = w - Walls;
376 //kill_stuck_objects(seg->sides[side].wall_num);
378 if ((w->state == WALL_DOOR_OPENING) || //already opening
379 (w->state == WALL_DOOR_WAITING) || //open, waiting to close
380 (w->state == WALL_DOOR_OPEN)) //open, & staying open
383 if (w->state == WALL_DOOR_CLOSING) { //closing, so reuse door
389 for (i=0;i<Num_open_doors;i++) { //find door
393 if (d->front_wallnum[0]==w-Walls || d->back_wallnum[0]==wall_num ||
394 (d->n_parts==2 && (d->front_wallnum[1]==wall_num || d->back_wallnum[1]==wall_num)))
398 if (i>=Num_open_doors && (Game_mode & GM_MULTI))
401 Assert(i<Num_open_doors); //didn't find door!
402 Assert( d!=NULL ); // Get John!
404 d->time = WallAnims[w->clip_num].play_time - d->time;
410 else { //create new door
411 Assert(w->state == WALL_DOOR_CLOSED);
413 d = &ActiveDoors[Num_open_doors];
416 Assert( Num_open_doors < MAX_DOORS );
420 w->state = WALL_DOOR_OPENING;
422 // So that door can't be shot while opening
423 csegp = &Segments[seg->children[side]];
424 Connectside = find_connect_side(seg, csegp);
425 Assert(Connectside != -1);
426 cwall_num = csegp->sides[Connectside].wall_num;
428 Walls[cwall_num].state = WALL_DOOR_OPENING;
430 //kill_stuck_objects(csegp->sides[Connectside].wall_num);
432 d->front_wallnum[0] = seg->sides[side].wall_num;
433 d->back_wallnum[0] = cwall_num;
435 Assert( seg-Segments != -1);
437 if (Newdemo_state == ND_STATE_RECORDING) {
438 newdemo_record_door_opening(seg-Segments, side);
441 if (w->linked_wall != -1) {
445 w2 = &Walls[w->linked_wall];
446 seg2 = &Segments[w2->segnum];
448 Assert(w2->linked_wall == seg->sides[side].wall_num);
449 //Assert(!(w2->flags & WALL_DOOR_OPENING || w2->flags & WALL_DOOR_OPENED));
451 w2->state = WALL_DOOR_OPENING;
453 csegp = &Segments[seg2->children[w2->sidenum]];
454 Connectside = find_connect_side(seg2, csegp);
455 Assert(Connectside != -1);
457 Walls[cwall_num].state = WALL_DOOR_OPENING;
460 d->front_wallnum[1] = w->linked_wall;
461 d->back_wallnum[1] = cwall_num;
467 if ( Newdemo_state != ND_STATE_PLAYBACK )
469 // NOTE THE LINK TO ABOVE!!!!
471 compute_center_point_on_side(&cp, seg, side );
472 if (WallAnims[w->clip_num].open_sound > -1 )
473 digi_link_sound_to_pos( WallAnims[w->clip_num].open_sound, seg-Segments, side, &cp, 0, F1_0 );
478 //-----------------------------------------------------------------
479 // start the transition from closed -> open wall
480 void start_wall_cloak(segment *seg, int side)
488 if ( Newdemo_state==ND_STATE_PLAYBACK ) return;
490 Assert(seg->sides[side].wall_num != -1); //Opening door on illegal wall
492 w = &Walls[seg->sides[side].wall_num];
494 if (w->type == WALL_OPEN || w->state == WALL_DOOR_CLOAKING) //already open or cloaking
497 csegp = &Segments[seg->children[side]];
498 Connectside = find_connect_side(seg, csegp);
499 Assert(Connectside != -1);
500 cwall_num = csegp->sides[Connectside].wall_num;
502 if (w->state == WALL_DOOR_DECLOAKING) { //decloaking, so reuse door
508 for (i=0;i<Num_cloaking_walls;i++) { //find door
510 d = &CloakingWalls[i];
512 if (d->front_wallnum==w-Walls || d->back_wallnum==w-Walls )
516 Assert(i<Num_cloaking_walls); //didn't find door!
517 Assert( d!=NULL ); // Get John!
519 d->time = CLOAKING_WALL_TIME - d->time;
522 else if (w->state == WALL_DOOR_CLOSED) { //create new door
523 d = &CloakingWalls[Num_cloaking_walls];
525 if (Num_cloaking_walls >= MAX_CLOAKING_WALLS) { //no more!
526 Int3(); //ran out of cloaking wall slots
529 Walls[cwall_num].type = WALL_OPEN;
532 Num_cloaking_walls++;
535 Int3(); //unexpected wall state
539 w->state = WALL_DOOR_CLOAKING;
541 Walls[cwall_num].state = WALL_DOOR_CLOAKING;
543 d->front_wallnum = seg->sides[side].wall_num;
544 d->back_wallnum = cwall_num;
546 Assert( seg-Segments != -1);
548 Assert(w->linked_wall == -1);
550 if ( Newdemo_state != ND_STATE_PLAYBACK ) {
552 compute_center_point_on_side(&cp, seg, side );
553 digi_link_sound_to_pos( SOUND_WALL_CLOAK_ON, seg-Segments, side, &cp, 0, F1_0 );
557 d->front_ls[i] = seg->sides[side].uvls[i].l;
559 d->back_ls[i] = csegp->sides[Connectside].uvls[i].l;
563 //-----------------------------------------------------------------
564 // start the transition from open -> closed wall
565 void start_wall_decloak(segment *seg, int side)
573 if ( Newdemo_state==ND_STATE_PLAYBACK ) return;
575 Assert(seg->sides[side].wall_num != -1); //Opening door on illegal wall
577 w = &Walls[seg->sides[side].wall_num];
579 if (w->type == WALL_CLOSED || w->state == WALL_DOOR_DECLOAKING) //already closed or decloaking
582 if (w->state == WALL_DOOR_CLOAKING) { //cloaking, so reuse door
588 for (i=0;i<Num_cloaking_walls;i++) { //find door
590 d = &CloakingWalls[i];
592 if (d->front_wallnum==w-Walls || d->back_wallnum==w-Walls )
596 Assert(i<Num_cloaking_walls); //didn't find door!
597 Assert( d!=NULL ); // Get John!
599 d->time = CLOAKING_WALL_TIME - d->time;
602 else if (w->state == WALL_DOOR_CLOSED) { //create new door
603 d = &CloakingWalls[Num_cloaking_walls];
605 if (Num_cloaking_walls >= MAX_CLOAKING_WALLS) { //no more!
606 Int3(); //ran out of cloaking wall slots
607 /* what is this _doing_ here?
608 w->type = WALL_CLOSED;
609 Walls[csegp->sides[Connectside].wall_num].type = WALL_CLOSED;
613 Num_cloaking_walls++;
616 Int3(); //unexpected wall state
620 w->state = WALL_DOOR_DECLOAKING;
622 // So that door can't be shot while opening
623 csegp = &Segments[seg->children[side]];
624 Connectside = find_connect_side(seg, csegp);
625 Assert(Connectside != -1);
626 cwall_num = csegp->sides[Connectside].wall_num;
628 Walls[cwall_num].state = WALL_DOOR_DECLOAKING;
630 d->front_wallnum = seg->sides[side].wall_num;
631 d->back_wallnum = csegp->sides[Connectside].wall_num;
633 Assert( seg-Segments != -1);
635 Assert(w->linked_wall == -1);
637 if ( Newdemo_state != ND_STATE_PLAYBACK ) {
639 compute_center_point_on_side(&cp, seg, side );
640 digi_link_sound_to_pos( SOUND_WALL_CLOAK_OFF, seg-Segments, side, &cp, 0, F1_0 );
644 d->front_ls[i] = seg->sides[side].uvls[i].l;
646 d->back_ls[i] = csegp->sides[Connectside].uvls[i].l;
650 //-----------------------------------------------------------------
651 // This function closes the specified door and restores the closed
652 // door texture. This is called when the animation is done
653 void wall_close_door_num(int door_num)
659 d = &ActiveDoors[door_num];
661 for (p=0;p<d->n_parts;p++) {
663 int Connectside, side;
664 segment *csegp, *seg;
666 w = &Walls[d->front_wallnum[p]];
668 seg = &Segments[w->segnum];
671 Assert(seg->sides[side].wall_num != -1); //Closing door on illegal wall
673 csegp = &Segments[seg->children[side]];
674 Connectside = find_connect_side(seg, csegp);
675 Assert(Connectside != -1);
676 cwall_num = csegp->sides[Connectside].wall_num;
677 Walls[seg->sides[side].wall_num].state = WALL_DOOR_CLOSED;
679 Walls[cwall_num].state = WALL_DOOR_CLOSED;
681 wall_set_tmap_num(seg,side,csegp,Connectside,w->clip_num,0);
685 for (i=door_num;i<Num_open_doors;i++)
686 ActiveDoors[i] = ActiveDoors[i+1];
692 int check_poke(int objnum,int segnum,int side)
694 object *obj = &Objects[objnum];
696 //note: don't let objects with zero size block door
698 if (obj->size && get_seg_masks(&obj->pos, segnum, obj->size, __FILE__, __LINE__).sidemask & (1 << side))
699 return 1; //pokes through side!
701 return 0; //does not!
705 //returns true of door in unobjstructed (& thus can close)
706 int is_door_free(segment *seg,int side)
712 csegp = &Segments[seg->children[side]];
713 Connectside = find_connect_side(seg, csegp);
714 Assert(Connectside != -1);
716 //go through each object in each of two segments, and see if
717 //it pokes into the connecting seg
719 for (objnum=seg->objects;objnum!=-1;objnum=Objects[objnum].next)
720 if (Objects[objnum].type!=OBJ_WEAPON && Objects[objnum].type!=OBJ_FIREBALL && check_poke(objnum,seg-Segments,side))
723 for (objnum=csegp->objects;objnum!=-1;objnum=Objects[objnum].next)
724 if (Objects[objnum].type!=OBJ_WEAPON && Objects[objnum].type!=OBJ_FIREBALL && check_poke(objnum,csegp-Segments,Connectside))
727 return 1; //doorway is free!
732 //-----------------------------------------------------------------
734 void wall_close_door(segment *seg, int side)
738 int Connectside, wall_num, cwall_num;
741 Assert(seg->sides[side].wall_num != -1); //Opening door on illegal wall
743 w = &Walls[seg->sides[side].wall_num];
744 wall_num = w - Walls;
745 if ((w->state == WALL_DOOR_CLOSING) || //already closing
746 (w->state == WALL_DOOR_WAITING) || //open, waiting to close
747 (w->state == WALL_DOOR_CLOSED)) //closed
750 if (!is_door_free(seg,side))
753 if (w->state == WALL_DOOR_OPENING) { //reuse door
759 for (i=0;i<Num_open_doors;i++) { //find door
763 if (d->front_wallnum[0]==wall_num || d->back_wallnum[0]==wall_num ||
764 (d->n_parts==2 && (d->front_wallnum[1]==wall_num || d->back_wallnum[1]==wall_num)))
768 Assert(i<Num_open_doors); //didn't find door!
769 Assert( d!=NULL ); // Get John!
771 d->time = WallAnims[w->clip_num].play_time - d->time;
777 else { //create new door
778 Assert(w->state == WALL_DOOR_OPEN);
779 d = &ActiveDoors[Num_open_doors];
782 Assert( Num_open_doors < MAX_DOORS );
785 w->state = WALL_DOOR_CLOSING;
787 // So that door can't be shot while opening
788 csegp = &Segments[seg->children[side]];
789 Connectside = find_connect_side(seg, csegp);
790 Assert(Connectside != -1);
791 cwall_num = csegp->sides[Connectside].wall_num;
793 Walls[cwall_num].state = WALL_DOOR_CLOSING;
795 d->front_wallnum[0] = seg->sides[side].wall_num;
796 d->back_wallnum[0] = cwall_num;
798 Assert( seg-Segments != -1);
800 if (Newdemo_state == ND_STATE_RECORDING) {
801 newdemo_record_door_opening(seg-Segments, side);
804 if (w->linked_wall != -1) {
805 Int3(); //don't think we ever used linked walls
811 if ( Newdemo_state != ND_STATE_PLAYBACK )
813 // NOTE THE LINK TO ABOVE!!!!
815 compute_center_point_on_side(&cp, seg, side );
816 if (WallAnims[w->clip_num].open_sound > -1 )
817 digi_link_sound_to_pos( WallAnims[w->clip_num].open_sound, seg-Segments, side, &cp, 0, F1_0 );
822 //-----------------------------------------------------------------
823 // Animates opening of a door.
824 // Called in the game loop.
825 void do_door_open(int door_num)
830 Assert(door_num != -1); //Trying to do_door_open on illegal door
832 d = &ActiveDoors[door_num];
834 for (p=0;p<d->n_parts;p++) {
836 int Connectside, side;
837 segment *csegp, *seg;
838 fix time_elapsed, time_total, one_frame;
841 w = &Walls[d->front_wallnum[p]];
842 kill_stuck_objects(d->front_wallnum[p]);
843 kill_stuck_objects(d->back_wallnum[p]);
845 seg = &Segments[w->segnum];
848 Assert(seg->sides[side].wall_num != -1); //Trying to do_door_open on illegal wall
850 csegp = &Segments[seg->children[side]];
851 Connectside = find_connect_side(seg, csegp);
852 Assert(Connectside != -1);
854 d->time += FrameTime;
856 time_elapsed = d->time;
857 n = WallAnims[w->clip_num].num_frames;
858 time_total = WallAnims[w->clip_num].play_time;
860 one_frame = time_total/n;
862 i = time_elapsed/one_frame;
865 wall_set_tmap_num(seg,side,csegp,Connectside,w->clip_num,i);
868 Walls[seg->sides[side].wall_num].flags |= WALL_DOOR_OPENED;
869 Walls[csegp->sides[Connectside].wall_num].flags |= WALL_DOOR_OPENED;
873 wall_set_tmap_num(seg,side,csegp,Connectside,w->clip_num,n-1);
875 // If our door is not automatic just remove it from the list.
876 if (!(Walls[seg->sides[side].wall_num].flags & WALL_DOOR_AUTO)) {
877 for (i=door_num;i<Num_open_doors;i++)
878 ActiveDoors[i] = ActiveDoors[i+1];
880 Walls[seg->sides[side].wall_num].state = WALL_DOOR_OPEN;
881 Walls[csegp->sides[Connectside].wall_num].state = WALL_DOOR_OPEN;
885 Walls[seg->sides[side].wall_num].state = WALL_DOOR_WAITING;
886 Walls[csegp->sides[Connectside].wall_num].state = WALL_DOOR_WAITING;
888 ActiveDoors[Num_open_doors].time = 0; //counts up
896 //-----------------------------------------------------------------
897 // Animates and processes the closing of a door.
898 // Called from the game loop.
899 void do_door_close(int door_num)
905 Assert(door_num != -1); //Trying to do_door_open on illegal door
907 d = &ActiveDoors[door_num];
909 w = &Walls[d->front_wallnum[0]];
911 //check for objects in doorway before closing
912 if (w->flags & WALL_DOOR_AUTO)
913 if (!is_door_free(&Segments[w->segnum],w->sidenum)) {
914 digi_kill_sound_linked_to_segment(w->segnum,w->sidenum,-1);
915 wall_open_door(&Segments[w->segnum],w->sidenum); //re-open door
919 for (p=0;p<d->n_parts;p++) {
921 int Connectside, side;
922 segment *csegp, *seg;
923 fix time_elapsed, time_total, one_frame;
926 w = &Walls[d->front_wallnum[p]];
928 seg = &Segments[w->segnum];
931 if (seg->sides[side].wall_num == -1) {
932 mprintf((0, "Trying to do_door_close on Illegal wall\n"));
936 //if here, must be auto door
937 // Assert(Walls[seg->sides[side].wall_num].flags & WALL_DOOR_AUTO);
938 //don't assert here, because now we have triggers to close non-auto doors
940 // Otherwise, close it.
941 csegp = &Segments[seg->children[side]];
942 Connectside = find_connect_side(seg, csegp);
943 Assert(Connectside != -1);
946 if ( Newdemo_state != ND_STATE_PLAYBACK )
947 // NOTE THE LINK TO ABOVE!!
948 if (p==0) //only play one sound for linked doors
949 if ( d->time==0 ) { //first time
951 compute_center_point_on_side(&cp, seg, side );
952 if (WallAnims[w->clip_num].close_sound > -1 )
953 digi_link_sound_to_pos( WallAnims[Walls[seg->sides[side].wall_num].clip_num].close_sound, seg-Segments, side, &cp, 0, F1_0 );
956 d->time += FrameTime;
958 time_elapsed = d->time;
959 n = WallAnims[w->clip_num].num_frames;
960 time_total = WallAnims[w->clip_num].play_time;
962 one_frame = time_total/n;
964 i = n-time_elapsed/one_frame-1;
967 Walls[seg->sides[side].wall_num].flags &= ~WALL_DOOR_OPENED;
968 Walls[csegp->sides[Connectside].wall_num].flags &= ~WALL_DOOR_OPENED;
973 wall_set_tmap_num(seg,side,csegp,Connectside,w->clip_num,i);
975 Walls[seg->sides[side].wall_num].state = WALL_DOOR_CLOSING;
976 Walls[csegp->sides[Connectside].wall_num].state = WALL_DOOR_CLOSING;
978 ActiveDoors[Num_open_doors].time = 0; //counts up
981 wall_close_door_num(door_num);
986 //-----------------------------------------------------------------
987 // Turns off an illusionary wall (This will be used primarily for
988 // wall switches or triggers that can turn on/off illusionary walls.)
989 void wall_illusion_off(segment *seg, int side)
994 csegp = &Segments[seg->children[side]];
995 cside = find_connect_side(seg, csegp);
998 if (seg->sides[side].wall_num == -1) {
999 mprintf((0, "Trying to shut off illusion illegal wall\n"));
1003 Walls[seg->sides[side].wall_num].flags |= WALL_ILLUSION_OFF;
1004 Walls[csegp->sides[cside].wall_num].flags |= WALL_ILLUSION_OFF;
1006 kill_stuck_objects(seg->sides[side].wall_num);
1007 kill_stuck_objects(csegp->sides[cside].wall_num);
1010 //-----------------------------------------------------------------
1011 // Turns on an illusionary wall (This will be used primarily for
1012 // wall switches or triggers that can turn on/off illusionary walls.)
1013 void wall_illusion_on(segment *seg, int side)
1018 csegp = &Segments[seg->children[side]];
1019 cside = find_connect_side(seg, csegp);
1020 Assert(cside != -1);
1022 if (seg->sides[side].wall_num == -1) {
1023 mprintf((0, "Trying to turn on illusion illegal wall\n"));
1027 Walls[seg->sides[side].wall_num].flags &= ~WALL_ILLUSION_OFF;
1028 Walls[csegp->sides[cside].wall_num].flags &= ~WALL_ILLUSION_OFF;
1031 // -----------------------------------------------------------------------------
1032 // Allowed to open the normally locked special boss door if in multiplayer mode.
1033 int special_boss_opening_allowed(int segnum, int sidenum)
1035 if (Game_mode & GM_MULTI)
1036 return (Current_level_num == BOSS_LOCKED_DOOR_LEVEL) && (segnum == BOSS_LOCKED_DOOR_SEG) && (sidenum == BOSS_LOCKED_DOOR_SIDE);
1041 //-----------------------------------------------------------------
1042 // Determines what happens when a wall is shot
1043 //returns info about wall. see wall.h for codes
1044 //obj is the object that hit...either a weapon or the player himself
1045 //playernum is the number the player who hit the wall or fired the weapon,
1046 //or -1 if a robot fired the weapon
1047 int wall_hit_process(segment *seg, int side, fix damage, int playernum, object *obj )
1052 Assert (seg-Segments != -1);
1054 // If it is not a "wall" then just return.
1055 if ( seg->sides[side].wall_num < 0 )
1056 return WHP_NOT_SPECIAL;
1058 w = &Walls[seg->sides[side].wall_num];
1060 if ( Newdemo_state == ND_STATE_RECORDING )
1061 newdemo_record_wall_hit_process( seg-Segments, side, damage, playernum );
1063 if (w->type == WALL_BLASTABLE) {
1064 if (obj->ctype.laser_info.parent_type == OBJ_PLAYER)
1065 wall_damage(seg, side, damage);
1066 return WHP_BLASTABLE;
1069 if (playernum != Player_num) //return if was robot fire
1070 return WHP_NOT_SPECIAL;
1072 Assert( playernum > -1 );
1074 // Determine whether player is moving forward. If not, don't say negative
1075 // messages because he probably didn't intentionally hit the door.
1076 if (obj->type == OBJ_PLAYER)
1077 show_message = (vm_vec_dot(&obj->orient.fvec, &obj->mtype.phys_info.velocity) > 0);
1078 else if (obj->type == OBJ_ROBOT)
1080 else if ((obj->type == OBJ_WEAPON) && (obj->ctype.laser_info.parent_type == OBJ_ROBOT))
1085 if (w->keys == KEY_BLUE)
1086 if (!(Players[playernum].flags & PLAYER_FLAGS_BLUE_KEY)) {
1087 if ( playernum==Player_num )
1089 HUD_init_message("%s %s",TXT_BLUE,TXT_ACCESS_DENIED);
1093 if (w->keys == KEY_RED)
1094 if (!(Players[playernum].flags & PLAYER_FLAGS_RED_KEY)) {
1095 if ( playernum==Player_num )
1097 HUD_init_message("%s %s",TXT_RED,TXT_ACCESS_DENIED);
1101 if (w->keys == KEY_GOLD)
1102 if (!(Players[playernum].flags & PLAYER_FLAGS_GOLD_KEY)) {
1103 if ( playernum==Player_num )
1105 HUD_init_message("%s %s",TXT_YELLOW,TXT_ACCESS_DENIED);
1109 if (w->type == WALL_DOOR)
1111 if ((w->flags & WALL_DOOR_LOCKED ) && !(special_boss_opening_allowed(seg-Segments, side)) ) {
1112 if ( playernum==Player_num )
1114 HUD_init_message(TXT_CANT_OPEN_DOOR);
1118 if (w->state != WALL_DOOR_OPENING)
1120 wall_open_door(seg, side);
1122 if (Game_mode & GM_MULTI)
1123 multi_send_door_open(seg-Segments, side,w->flags);
1131 return WHP_NOT_SPECIAL; //default is treat like normal wall
1134 //-----------------------------------------------------------------
1135 // Opens doors/destroys wall/shuts off triggers.
1136 void wall_toggle(segment *seg, int side)
1140 if (seg - Segments > Highest_segment_index)
1142 Warning("Can't toggle side %d of segment %d - nonexistent segment!\n", side, seg-Segments);
1145 Assert( side < MAX_SIDES_PER_SEGMENT );
1147 wall_num = seg->sides[side].wall_num;
1149 if (wall_num == -1) {
1150 mprintf((0, "Illegal wall_toggle\n"));
1154 if ( Newdemo_state == ND_STATE_RECORDING )
1155 newdemo_record_wall_toggle(seg-Segments, side );
1157 if (Walls[wall_num].type == WALL_BLASTABLE)
1158 wall_destroy(seg, side);
1160 if ((Walls[wall_num].type == WALL_DOOR) && (Walls[wall_num].state == WALL_DOOR_CLOSED))
1161 wall_open_door(seg, side);
1166 //-----------------------------------------------------------------
1167 // Tidy up Walls array for load/save purposes.
1172 if (Num_walls < 0) {
1173 mprintf((0, "Illegal Num_walls\n"));
1177 for (i=Num_walls;i<MAX_WALLS;i++) {
1178 Walls[i].type = WALL_NORMAL;
1181 Walls[i].trigger = -1;
1182 Walls[i].clip_num = -1;
1186 void do_cloaking_wall_frame(int cloaking_wall_num)
1189 wall *wfront,*wback;
1191 if ( Newdemo_state==ND_STATE_PLAYBACK ) return;
1193 d = &CloakingWalls[cloaking_wall_num];
1194 wfront = &Walls[d->front_wallnum];
1195 wback = (d->back_wallnum > -1) ? Walls + d->back_wallnum : NULL;
1197 d->time += FrameTime;
1199 if (d->time > CLOAKING_WALL_TIME) {
1202 wfront->type = WALL_OPEN;
1203 wfront->state = WALL_DOOR_CLOSED; //why closed? why not?
1205 wback->type = WALL_OPEN;
1206 wback->state = WALL_DOOR_CLOSED; //why closed? why not?
1209 for (i=cloaking_wall_num;i<Num_cloaking_walls;i++)
1210 CloakingWalls[i] = CloakingWalls[i+1];
1211 Num_cloaking_walls--;
1214 else if (d->time > CLOAKING_WALL_TIME/2) {
1215 int old_type=wfront->type;
1217 wfront->cloak_value = ((d->time - CLOAKING_WALL_TIME/2) * (GR_FADE_LEVELS-2)) / (CLOAKING_WALL_TIME/2);
1219 wback->cloak_value = wfront->cloak_value;
1221 if (old_type != WALL_CLOAKED) { //just switched
1224 wfront->type = WALL_CLOAKED;
1226 wback->type = WALL_CLOAKED;
1229 Segments[wfront->segnum].sides[wfront->sidenum].uvls[i].l = d->front_ls[i];
1231 Segments[wback->segnum].sides[wback->sidenum].uvls[i].l = d->back_ls[i];
1239 light_scale = fixdiv(CLOAKING_WALL_TIME/2-d->time,CLOAKING_WALL_TIME/2);
1242 Segments[wfront->segnum].sides[wfront->sidenum].uvls[i].l = fixmul(d->front_ls[i],light_scale);
1244 Segments[wback->segnum].sides[wback->sidenum].uvls[i].l = fixmul(d->back_ls[i],light_scale);
1248 if ( Newdemo_state == ND_STATE_RECORDING )
1249 newdemo_record_cloaking_wall(d->front_wallnum, d->back_wallnum, wfront->type, wfront->state, wfront->cloak_value, Segments[wfront->segnum].sides[wfront->sidenum].uvls[0].l, Segments[wfront->segnum].sides[wfront->sidenum].uvls[1].l, Segments[wfront->segnum].sides[wfront->sidenum].uvls[2].l, Segments[wfront->segnum].sides[wfront->sidenum].uvls[3].l);
1253 void do_decloaking_wall_frame(int cloaking_wall_num)
1256 wall *wfront,*wback;
1258 if ( Newdemo_state==ND_STATE_PLAYBACK ) return;
1260 d = &CloakingWalls[cloaking_wall_num];
1261 wfront = &Walls[d->front_wallnum];
1262 wback = (d->back_wallnum > -1) ? Walls + d->back_wallnum : NULL;
1264 d->time += FrameTime;
1266 if (d->time > CLOAKING_WALL_TIME) {
1269 wfront->state = WALL_DOOR_CLOSED;
1271 wback->state = WALL_DOOR_CLOSED;
1274 Segments[wfront->segnum].sides[wfront->sidenum].uvls[i].l = d->front_ls[i];
1276 Segments[wback->segnum].sides[wback->sidenum].uvls[i].l = d->back_ls[i];
1279 for (i=cloaking_wall_num;i<Num_cloaking_walls;i++)
1280 CloakingWalls[i] = CloakingWalls[i+1];
1281 Num_cloaking_walls--;
1284 else if (d->time > CLOAKING_WALL_TIME/2) { //fading in
1288 wfront->type = wback->type = WALL_CLOSED;
1290 light_scale = fixdiv(d->time-CLOAKING_WALL_TIME/2,CLOAKING_WALL_TIME/2);
1293 Segments[wfront->segnum].sides[wfront->sidenum].uvls[i].l = fixmul(d->front_ls[i],light_scale);
1295 Segments[wback->segnum].sides[wback->sidenum].uvls[i].l = fixmul(d->back_ls[i],light_scale);
1298 else { //cloaking in
1299 wfront->cloak_value = ((CLOAKING_WALL_TIME/2 - d->time) * (GR_FADE_LEVELS-2)) / (CLOAKING_WALL_TIME/2);
1300 wfront->type = WALL_CLOAKED;
1302 wback->cloak_value = wfront->cloak_value;
1303 wback->type = WALL_CLOAKED;
1307 if ( Newdemo_state == ND_STATE_RECORDING )
1308 newdemo_record_cloaking_wall(d->front_wallnum, d->back_wallnum, wfront->type, wfront->state, wfront->cloak_value, Segments[wfront->segnum].sides[wfront->sidenum].uvls[0].l, Segments[wfront->segnum].sides[wfront->sidenum].uvls[1].l, Segments[wfront->segnum].sides[wfront->sidenum].uvls[2].l, Segments[wfront->segnum].sides[wfront->sidenum].uvls[3].l);
1312 void wall_frame_process()
1316 for (i=0;i<Num_open_doors;i++) {
1320 d = &ActiveDoors[i];
1321 w = &Walls[d->front_wallnum[0]];
1323 if (w->state == WALL_DOOR_OPENING)
1325 else if (w->state == WALL_DOOR_CLOSING)
1327 else if (w->state == WALL_DOOR_WAITING) {
1328 d->time += FrameTime;
1330 //set flags to fix occatsional netgame problem where door is
1331 //waiting to close but open flag isn't set
1332 Assert(d->n_parts == 1);
1333 w->flags |= WALL_DOOR_OPENED;
1334 if (d->back_wallnum[0] > -1)
1335 Walls[d->back_wallnum[0]].flags |= WALL_DOOR_OPENED;
1337 if (d->time > DOOR_WAIT_TIME && is_door_free(&Segments[w->segnum],w->sidenum)) {
1338 w->state = WALL_DOOR_CLOSING;
1342 else if (w->state == WALL_DOOR_CLOSED || w->state == WALL_DOOR_OPEN) {
1343 //this shouldn't happen. if the wall is in one of these states,
1344 //there shouldn't be an activedoor entry for it. So we'll kill
1345 //the activedoor entry. Tres simple.
1347 Int3(); //a bad thing has happened, but I'll try to fix it up
1348 for (t=i;t<Num_open_doors;t++)
1349 ActiveDoors[t] = ActiveDoors[t+1];
1354 for (i=0;i<Num_cloaking_walls;i++) {
1358 d = &CloakingWalls[i];
1359 w = &Walls[d->front_wallnum];
1361 if (w->state == WALL_DOOR_CLOAKING)
1362 do_cloaking_wall_frame(i);
1363 else if (w->state == WALL_DOOR_DECLOAKING)
1364 do_decloaking_wall_frame(i);
1367 Int3(); //unexpected wall state
1372 int Num_stuck_objects=0;
1374 stuckobj Stuck_objects[MAX_STUCK_OBJECTS];
1376 // An object got stuck in a door (like a flare).
1377 // Add global entry.
1378 void add_stuck_object(object *objp, int segnum, int sidenum)
1383 wallnum = Segments[segnum].sides[sidenum].wall_num;
1385 if (wallnum != -1) {
1386 if (Walls[wallnum].flags & WALL_BLASTED)
1387 objp->flags |= OF_SHOULD_BE_DEAD;
1389 for (i=0; i<MAX_STUCK_OBJECTS; i++) {
1390 if (Stuck_objects[i].wallnum == -1) {
1391 Stuck_objects[i].wallnum = wallnum;
1392 Stuck_objects[i].objnum = objp-Objects;
1393 Stuck_objects[i].signature = objp->signature;
1394 // mprintf((0, "Added wall %i at index %i\n", wallnum, i));
1395 Num_stuck_objects++;
1399 if (i == MAX_STUCK_OBJECTS)
1400 mprintf((1, "Warning: Unable to add object %i which got stuck in wall %i to Stuck_objects\n", objp-Objects, wallnum));
1407 // --------------------------------------------------------------------------------------------------
1408 // Look at the list of stuck objects, clean up in case an object has gone away, but not been removed here.
1409 // Removes up to one/frame.
1410 void remove_obsolete_stuck_objects(void)
1414 // Safety and efficiency code. If no stuck objects, should never get inside the IF, but this is faster.
1415 if (!Num_stuck_objects)
1418 objnum = FrameCount % MAX_STUCK_OBJECTS;
1420 if (Stuck_objects[objnum].wallnum != -1)
1421 if ((Walls[Stuck_objects[objnum].wallnum].state != WALL_DOOR_CLOSED) || (Objects[Stuck_objects[objnum].objnum].signature != Stuck_objects[objnum].signature)) {
1422 Num_stuck_objects--;
1423 Objects[Stuck_objects[objnum].objnum].lifeleft = F1_0/8;
1424 Stuck_objects[objnum].wallnum = -1;
1429 extern void flush_fcd_cache(void);
1431 // ----------------------------------------------------------------------------------------------------
1432 // Door with wall index wallnum is opening, kill all objects stuck in it.
1433 void kill_stuck_objects(int wallnum)
1437 if (wallnum < 0 || Num_stuck_objects == 0) {
1441 Num_stuck_objects=0;
1443 for (i=0; i<MAX_STUCK_OBJECTS; i++)
1444 if (Stuck_objects[i].wallnum == wallnum) {
1445 if (Objects[Stuck_objects[i].objnum].type == OBJ_WEAPON) {
1446 Objects[Stuck_objects[i].objnum].lifeleft = F1_0/8;
1448 mprintf((1, "Warning: Stuck object of type %i, expected to be of type %i, see wall.c\n", Objects[Stuck_objects[i].objnum].type, OBJ_WEAPON));
1449 // Int3(); // What? This looks bad. Object is not a weapon and it is stuck in a wall!
1450 Stuck_objects[i].wallnum = -1;
1451 } else if (Stuck_objects[i].wallnum != -1) {
1452 Num_stuck_objects++;
1454 // Ok, this is awful, but we need to do things whenever a door opens/closes/disappears, etc.
1460 // -- unused -- // -----------------------------------------------------------------------------------
1461 // -- unused -- // Return object id of first flare found embedded in segp:sidenum.
1462 // -- unused -- // If no flare, return -1.
1463 // -- unused -- int contains_flare(segment *segp, int sidenum)
1465 // -- unused -- int i;
1467 // -- unused -- for (i=0; i<Num_stuck_objects; i++) {
1468 // -- unused -- object *objp = &Objects[Stuck_objects[i].objnum];
1470 // -- unused -- if ((objp->type == OBJ_WEAPON) && (objp->id == FLARE_ID)) {
1471 // -- unused -- if (Walls[Stuck_objects[i].wallnum].segnum == segp-Segments)
1472 // -- unused -- if (Walls[Stuck_objects[i].wallnum].sidenum == sidenum)
1473 // -- unused -- return objp-Objects;
1477 // -- unused -- return -1;
1480 // -----------------------------------------------------------------------------------
1481 // Initialize stuck objects array. Called at start of level
1482 void init_stuck_objects(void)
1486 for (i=0; i<MAX_STUCK_OBJECTS; i++)
1487 Stuck_objects[i].wallnum = -1;
1489 Num_stuck_objects = 0;
1492 // -----------------------------------------------------------------------------------
1493 // Clear out all stuck objects. Called for a new ship
1494 void clear_stuck_objects(void)
1498 for (i=0; i<MAX_STUCK_OBJECTS; i++) {
1499 if (Stuck_objects[i].wallnum != -1) {
1502 objnum = Stuck_objects[i].objnum;
1504 if ((Objects[objnum].type == OBJ_WEAPON) && (Objects[objnum].id == FLARE_ID))
1505 Objects[objnum].lifeleft = F1_0/8;
1507 Stuck_objects[i].wallnum = -1;
1509 Num_stuck_objects--;
1513 Assert(Num_stuck_objects == 0);
1517 // -----------------------------------------------------------------------------------
1518 #define MAX_BLAST_GLASS_DEPTH 5
1520 void bng_process_segment(object *objp, fix damage, segment *segp, int depth, sbyte *visited)
1524 if (depth > MAX_BLAST_GLASS_DEPTH)
1529 for (sidenum=0; sidenum<MAX_SIDES_PER_SEGMENT; sidenum++) {
1534 // Process only walls which have glass.
1535 if ((tm=segp->sides[sidenum].tmap_num2) != 0) {
1538 tm &= 0x3fff; //tm without flags
1540 if ((((ec=TmapInfo[tm].eclip_num)!=-1) && ((db=Effects[ec].dest_bm_num)!=-1 && !(Effects[ec].flags&EF_ONE_SHOT))) || (ec==-1 && (TmapInfo[tm].destroyed!=-1))) {
1541 compute_center_point_on_side(&pnt, segp, sidenum);
1542 dist = vm_vec_dist_quick(&pnt, &objp->pos);
1543 if (dist < damage/2) {
1544 dist = find_connected_distance(&pnt, segp-Segments, &objp->pos, objp->segnum, MAX_BLAST_GLASS_DEPTH, WID_RENDPAST_FLAG);
1545 if ((dist > 0) && (dist < damage/2))
1546 check_effect_blowup(segp, sidenum, &pnt, &Objects[objp->ctype.laser_info.parent_num], 1);
1552 for (i=0; i<MAX_SIDES_PER_SEGMENT; i++) {
1553 int segnum = segp->children[i];
1556 if (!visited[segnum]) {
1557 if (WALL_IS_DOORWAY(segp, i) & WID_FLY_FLAG) {
1558 visited[segnum] = 1;
1559 bng_process_segment(objp, damage, &Segments[segnum], depth, visited);
1566 // -----------------------------------------------------------------------------------
1567 // objp is going to detonate
1568 // blast nearby monitors, lights, maybe other things
1569 void blast_nearby_glass(object *objp, fix damage)
1572 sbyte visited[MAX_SEGMENTS];
1575 cursegp = &Segments[objp->segnum];
1576 for (i=0; i<=Highest_segment_index; i++)
1579 visited[objp->segnum] = 1;
1580 bng_process_segment(objp, damage, cursegp, 0, visited);
1585 #define MAX_CLIP_FRAMES_D1 20
1588 * reads a wclip structure from a CFILE
1590 int wclip_read_n_d1(wclip *wc, int n, CFILE *fp)
1594 for (i = 0; i < n; i++) {
1595 wc[i].play_time = cfile_read_fix(fp);
1596 wc[i].num_frames = cfile_read_short(fp);
1597 for (j = 0; j < MAX_CLIP_FRAMES_D1; j++)
1598 wc[i].frames[j] = cfile_read_short(fp);
1599 wc[i].open_sound = cfile_read_short(fp);
1600 wc[i].close_sound = cfile_read_short(fp);
1601 wc[i].flags = cfile_read_short(fp);
1602 cfread(wc[i].filename, 13, 1, fp);
1603 wc[i].pad = cfile_read_byte(fp);
1608 #ifndef FAST_FILE_IO
1610 * reads a wclip structure from a CFILE
1612 int wclip_read_n(wclip *wc, int n, CFILE *fp)
1616 for (i = 0; i < n; i++) {
1617 wc[i].play_time = cfile_read_fix(fp);
1618 wc[i].num_frames = cfile_read_short(fp);
1619 for (j = 0; j < MAX_CLIP_FRAMES; j++)
1620 wc[i].frames[j] = cfile_read_short(fp);
1621 wc[i].open_sound = cfile_read_short(fp);
1622 wc[i].close_sound = cfile_read_short(fp);
1623 wc[i].flags = cfile_read_short(fp);
1624 cfread(wc[i].filename, 13, 1, fp);
1625 wc[i].pad = cfile_read_byte(fp);
1631 * reads a v16_wall structure from a CFILE
1633 extern void v16_wall_read(v16_wall *w, CFILE *fp)
1635 w->type = cfile_read_byte(fp);
1636 w->flags = cfile_read_byte(fp);
1637 w->hps = cfile_read_fix(fp);
1638 w->trigger = cfile_read_byte(fp);
1639 w->clip_num = cfile_read_byte(fp);
1640 w->keys = cfile_read_byte(fp);
1644 * reads a v19_wall structure from a CFILE
1646 extern void v19_wall_read(v19_wall *w, CFILE *fp)
1648 w->segnum = cfile_read_int(fp);
1649 w->sidenum = cfile_read_int(fp);
1650 w->type = cfile_read_byte(fp);
1651 w->flags = cfile_read_byte(fp);
1652 w->hps = cfile_read_fix(fp);
1653 w->trigger = cfile_read_byte(fp);
1654 w->clip_num = cfile_read_byte(fp);
1655 w->keys = cfile_read_byte(fp);
1656 w->linked_wall = cfile_read_int(fp);
1660 * reads a wall structure from a CFILE
1662 extern void wall_read(wall *w, CFILE *fp)
1664 w->segnum = cfile_read_int(fp);
1665 w->sidenum = cfile_read_int(fp);
1666 w->hps = cfile_read_fix(fp);
1667 w->linked_wall = cfile_read_int(fp);
1668 w->type = cfile_read_byte(fp);
1669 w->flags = cfile_read_byte(fp);
1670 w->state = cfile_read_byte(fp);
1671 w->trigger = cfile_read_byte(fp);
1672 w->clip_num = cfile_read_byte(fp);
1673 w->keys = cfile_read_byte(fp);
1674 w->controlling_trigger = cfile_read_byte(fp);
1675 w->cloak_value = cfile_read_byte(fp);
1679 * reads a v19_door structure from a CFILE
1681 extern void v19_door_read(v19_door *d, CFILE *fp)
1683 d->n_parts = cfile_read_int(fp);
1684 d->seg[0] = cfile_read_short(fp);
1685 d->seg[1] = cfile_read_short(fp);
1686 d->side[0] = cfile_read_short(fp);
1687 d->side[1] = cfile_read_short(fp);
1688 d->type[0] = cfile_read_short(fp);
1689 d->type[1] = cfile_read_short(fp);
1690 d->open = cfile_read_fix(fp);
1694 * reads an active_door structure from a CFILE
1696 extern void active_door_read(active_door *ad, CFILE *fp)
1698 ad->n_parts = cfile_read_int(fp);
1699 ad->front_wallnum[0] = cfile_read_short(fp);
1700 ad->front_wallnum[1] = cfile_read_short(fp);
1701 ad->back_wallnum[0] = cfile_read_short(fp);
1702 ad->back_wallnum[1] = cfile_read_short(fp);
1703 ad->time = cfile_read_fix(fp);